From fa1654887b5a5601431d4e43ffaede0b50259492 Mon Sep 17 00:00:00 2001 From: Vadim Lopatin Date: Mon, 28 Aug 2017 11:29:28 +0300 Subject: [PATCH] fix theme update; fix dark theme --- src/dlangui/widgets/scrollbar.d | 16 ++++++++++++--- src/dlangui/widgets/styles.d | 15 +++++++++++++- views/res/close_dark.png | Bin 0 -> 177 bytes ...ollbar_btn_transparent_background_dark.xml | 14 +++++++++++++ views/res/tab_more_dark.png | Bin 0 -> 373 bytes views/res/theme_dark.xml | 19 +++++++++--------- views/standard_resources.list | 3 +++ 7 files changed, 54 insertions(+), 13 deletions(-) create mode 100644 views/res/close_dark.png create mode 100644 views/res/scrollbar_btn_transparent_background_dark.xml create mode 100644 views/res/tab_more_dark.png diff --git a/src/dlangui/widgets/scrollbar.d b/src/dlangui/widgets/scrollbar.d index e2d3d779..bb5ed4e9 100644 --- a/src/dlangui/widgets/scrollbar.d +++ b/src/dlangui/widgets/scrollbar.d @@ -320,14 +320,24 @@ class ScrollBar : AbstractSlider, OnClickHandler { override @property AbstractSlider orientation(Orientation value) { if (_orientation != value) { _orientation = value; - _btnBack.drawableId = style.customDrawableId(_orientation == Orientation.Vertical ? ATTR_SCROLLBAR_BUTTON_UP : ATTR_SCROLLBAR_BUTTON_LEFT); - _btnForward.drawableId = style.customDrawableId(_orientation == Orientation.Vertical ? ATTR_SCROLLBAR_BUTTON_DOWN : ATTR_SCROLLBAR_BUTTON_RIGHT); - _indicator.drawableId = style.customDrawableId(_orientation == Orientation.Vertical ? ATTR_SCROLLBAR_INDICATOR_VERTICAL : ATTR_SCROLLBAR_INDICATOR_HORIZONTAL); + updateDrawableIds(); requestLayout(); } return this; } + void updateDrawableIds() { + _btnBack.drawableId = style.customDrawableId(_orientation == Orientation.Vertical ? ATTR_SCROLLBAR_BUTTON_UP : ATTR_SCROLLBAR_BUTTON_LEFT); + _btnForward.drawableId = style.customDrawableId(_orientation == Orientation.Vertical ? ATTR_SCROLLBAR_BUTTON_DOWN : ATTR_SCROLLBAR_BUTTON_RIGHT); + _indicator.drawableId = style.customDrawableId(_orientation == Orientation.Vertical ? ATTR_SCROLLBAR_INDICATOR_VERTICAL : ATTR_SCROLLBAR_INDICATOR_HORIZONTAL); + } + + /// handle theme change: e.g. reload some themed resources + override void onThemeChanged() { + super.onThemeChanged(); + updateDrawableIds(); + } + /// set string property value, for ML loaders override bool setStringProperty(string name, string value) { if (name.equal("orientation")) { diff --git a/src/dlangui/widgets/styles.d b/src/dlangui/widgets/styles.d index 6091e4cf..76ddcbcb 100644 --- a/src/dlangui/widgets/styles.d +++ b/src/dlangui/widgets/styles.d @@ -295,6 +295,13 @@ struct DrawableAttributeList { set(key, value.drawableId); } } + void onThemeChanged() { + foreach(key, ref value; _customDrawables) { + if (value) { + value.onThemeChanged(); + } + } + } } /// style properties @@ -348,7 +355,7 @@ public: s.onThemeChanged(); foreach(s; _children) s.onThemeChanged(); - _customDrawables.clear(); + _customDrawables.onThemeChanged(); } @property const(Theme) theme() const { @@ -1663,6 +1670,12 @@ public: _drawable.clear(); _initialized = false; } + void onThemeChanged() { + if (!_drawableId) { + _drawable.clear(); + _initialized = false; + } + } } /// returns custom drawable replacement id for specified id from current theme, or returns passed value if not found or no current theme diff --git a/views/res/close_dark.png b/views/res/close_dark.png new file mode 100644 index 0000000000000000000000000000000000000000..6fbe47328348429c47ed43525d5cdf04b42afa55 GIT binary patch literal 177 zcmeAS@N?(olHy`uVBq!ia0vp^{2apv5`Hh$}TFR03&7ST%#5jbG8f$J1=_1tUgBkukAUhb`SI96`z UZIPnyK+_mJUHx3vIVCg!0MgJk&j0`b literal 0 HcmV?d00001 diff --git a/views/res/scrollbar_btn_transparent_background_dark.xml b/views/res/scrollbar_btn_transparent_background_dark.xml new file mode 100644 index 00000000..2f43b424 --- /dev/null +++ b/views/res/scrollbar_btn_transparent_background_dark.xml @@ -0,0 +1,14 @@ + + + + + + + + + diff --git a/views/res/tab_more_dark.png b/views/res/tab_more_dark.png new file mode 100644 index 0000000000000000000000000000000000000000..8451008c9338089721636309e10f0c54f93cf53e GIT binary patch literal 373 zcmeAS@N?(olHy`uVBq!ia0vp@Ak4uAB#T}@sR2@KN#5=*KpF^sI`6IrQk(@Ik;M!Q z+?^oIXnykaTA(0%iKnkC`$G;H4ne*~#(C!$7#Nv6T^vI+&aa)g*NZt&p!NK{zXx^8 zZkq~de`LMXxpeO8gc)uu@(#IwDg^{xS+Xym=-9BxX~NdR$>uxOC+MHKmpw7U^-=3p zg?UBKYKqe&9`Ju+NJxE~l=k3jB0nQTPX3wR^!5j=3>UO}*cm>5++4Lf+bvY*o z!x + + - - - - - - - - - + + + + @@ -103,6 +100,10 @@ backgroundImageId="scrollbar_btn_background_dark" align="Center" /> +