buggins / dlangui

Cross Platform GUI for D programming language
Boost Software License 1.0
804 stars 120 forks source link

Creating an alternative theme #546

Open aberba opened 6 years ago

aberba commented 6 years ago
  1. I have been working on a theme but I can't find a way to theming button border lines and border radius.
 <style id="BUTTON"
        align="Center"
        margins="2pt, 2pt, 2pt, 2pt"
        padding="2pt,2pt,2pt,2pt"
        fontSize="16px"
        fontWeight="bold"
        borderWidth="2px"
        borderColor="red"
        backgroundColor="#F5F5F5"
        focusRectColors="#F5F5F5"
        > 
...

But it doesn't work. Is such things supported? Where can I find the list of supported properties for each widgets?

  1. The images used in theming are hard to tract since they are not organized into folders based on widget using it or some criteria.

  2. Using XML is not only less productive, but also hard to keep tract of XML attributes and value style of setting properties. Its much easiest to theme with a CSS syntax.. CSS is designed with that syntax for styling. Like GTK+ does [1][2] [1] https://developer.gnome.org/gtk3/stable/chap-css-overview.html [2] https://developer.gnome.org/gtk3/stable/chap-css-properties.html

and3md commented 6 years ago

DlangUI uses nine patch drawables like in android:

https://developer.android.com/guide/topics/graphics/2d-graphics.html#nine-patch

triplejam commented 6 years ago

There's some css support it's just not fully implemented yet.

dayllenger commented 6 years ago

Borders (without border radius yet), box shadows, linear gradients. They are not yet documented anywhere, maybe I'll find a time to write about it on wiki. By the way, you can type padding="2pt" instead of padding="2pt,2pt,2pt,2pt" and same with margins, border etc.

aberba commented 6 years ago

@dayllenger thanks very much. See

<style id="MAIN_MENU"
    backgroundImageId="#linear,30deg,#bdf,#fff"
/>

I thought backgroundImageId is used to reference images. Does it also support gradients as well?

Also, where can I find the implementation of supported styles not documented so I can utilize whilst waiting for it to be documented?

@triplejam how does the CSS implementation work?

dayllenger commented 6 years ago

backgroundImageId is used similarly to CSS background e.g. background: linear-gradient(-90deg, #f00, #ff0);

Styles implementation is quite spreaded. You can look at supported properties here, entire Style class or at some drawable classes starting here.

triplejam commented 6 years ago

@aberba I don't really know to be honest. I just know there is some implementation in core/css.d and core/cssparser.d and they just have a unittest. It will be easier to just use the xml. There are some graphical tools like TreeLine which make it easier for editing xml files. If you try TreeLine use the "export" option for saving the theme.

aberba commented 6 years ago

Can someone please explain to me what these XML file in themes do. Exmaple switch.xml has the content:

<selector>
<item android:state_checked="false" android:state_enabled="true" android:drawable="@drawable/switch_off"/>
<item android:state_checked="true" android:state_enabled="true" android:drawable="@drawable/switch_on"/>
<item android:state_checked="false" android:drawable="@drawable/switch_off_disabled"/>
<item android:state_checked="true" android:drawable="@drawable/switch_on_disabled"/>
</selector>

What's the meaning of the android:state_* attributes and what do they do? How are they loaded as part of the theme?

and3md commented 6 years ago

@aberba This file choose a drawable (graphics) for widget based on state for example enabled, disabled, pressed, hover etc.

aberba commented 6 years ago

OH ok. Will test my own version and see