diff --git a/src/dlangui/graphics/colors.d b/src/dlangui/graphics/colors.d index fb2538c2..5d309107 100644 --- a/src/dlangui/graphics/colors.d +++ b/src/dlangui/graphics/colors.d @@ -27,6 +27,8 @@ immutable uint COLOR_UNSPECIFIED = 0xFFDEADFF; /// transparent color constant immutable uint COLOR_TRANSPARENT = 0xFFFFFFFF; +immutable string COLOR_DRAWABLE = "#color"; + immutable uint COLOR_TRANSFORM_OFFSET_NONE = 0x80808080; immutable uint COLOR_TRANSFORM_MULTIPLY_NONE = 0x40404040; diff --git a/src/dlangui/widgets/styles.d b/src/dlangui/widgets/styles.d index 658b1d86..c5a911ac 100644 --- a/src/dlangui/widgets/styles.d +++ b/src/dlangui/widgets/styles.d @@ -530,7 +530,9 @@ public: /// font size @property string backgroundImageId() const { - if (_backgroundImageId !is null) + if (_backgroundImageId == COLOR_DRAWABLE) + return null; + else if (_backgroundImageId !is null) return _backgroundImageId; else return parentStyle.backgroundImageId; @@ -702,7 +704,7 @@ public: @property Style backgroundColor(uint color) { _backgroundColor = color; - _backgroundImageId = null; + _backgroundImageId = COLOR_DRAWABLE; _backgroundDrawable.clear(); return this; } @@ -853,6 +855,20 @@ public: return createState(stateMask, stateValue); } + /// find substyle based on widget state (e.g. focused, pressed, ...) + Style forState(uint state) { + if (state == State.Normal) + return this; + //Log.d("forState ", state, " styleId=", _id, " substates=", _substates.length); + if (parentStyle !is null && _substates.length == 0 && parentStyle._substates.length > 0) //id is null && + return parentStyle.forState(state); + foreach(item; _substates) { + if ((item._stateMask & state) == item._stateValue) + return item; + } + return this; // fallback to current style + } + /// find substyle based on widget state (e.g. focused, pressed, ...) const(Style) forState(uint state) const { if (state == State.Normal) @@ -1016,6 +1032,11 @@ class Theme : Style { return this; } + /// find substyle based on widget state (e.g. focused, pressed, ...) + override Style forState(uint state) { + return this; + } + void dumpStats() { Log.d("Theme ", _id, ": children:", _children.length, ", substates:", _substates.length, ", mapsize:", _byId.length); } diff --git a/src/dlangui/widgets/widget.d b/src/dlangui/widgets/widget.d index 96c49e5d..68b9252e 100644 --- a/src/dlangui/widgets/widget.d +++ b/src/dlangui/widgets/widget.d @@ -252,7 +252,7 @@ public: } /// enforces widget's own style - allows override some of style properties - protected @property Style ownStyle() { + @property Style ownStyle() { if (_ownStyle is null) _ownStyle = currentTheme.modifyStyle(_styleId); return _ownStyle;