fix theme update; fix dark theme

This commit is contained in:
Vadim Lopatin 2017-08-28 11:29:28 +03:00
parent c16c69c344
commit fa1654887b
7 changed files with 54 additions and 13 deletions

View File

@ -320,14 +320,24 @@ class ScrollBar : AbstractSlider, OnClickHandler {
override @property AbstractSlider orientation(Orientation value) { override @property AbstractSlider orientation(Orientation value) {
if (_orientation != value) { if (_orientation != value) {
_orientation = value; _orientation = value;
_btnBack.drawableId = style.customDrawableId(_orientation == Orientation.Vertical ? ATTR_SCROLLBAR_BUTTON_UP : ATTR_SCROLLBAR_BUTTON_LEFT); updateDrawableIds();
_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);
requestLayout(); requestLayout();
} }
return this; 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 /// set string property value, for ML loaders
override bool setStringProperty(string name, string value) { override bool setStringProperty(string name, string value) {
if (name.equal("orientation")) { if (name.equal("orientation")) {

View File

@ -295,6 +295,13 @@ struct DrawableAttributeList {
set(key, value.drawableId); set(key, value.drawableId);
} }
} }
void onThemeChanged() {
foreach(key, ref value; _customDrawables) {
if (value) {
value.onThemeChanged();
}
}
}
} }
/// style properties /// style properties
@ -348,7 +355,7 @@ public:
s.onThemeChanged(); s.onThemeChanged();
foreach(s; _children) foreach(s; _children)
s.onThemeChanged(); s.onThemeChanged();
_customDrawables.clear(); _customDrawables.onThemeChanged();
} }
@property const(Theme) theme() const { @property const(Theme) theme() const {
@ -1663,6 +1670,12 @@ public:
_drawable.clear(); _drawable.clear();
_initialized = false; _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 /// returns custom drawable replacement id for specified id from current theme, or returns passed value if not found or no current theme

BIN
views/res/close_dark.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 177 B

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="true"
android:drawable="@drawable/scrollbar_btn_background_pressed_dark" />
<item android:state_focused="true" android:state_enabled="true"
android:drawable="@drawable/scrollbar_btn_background_normal_dark" />
<item android:state_enabled="true" android:state_hovered="true"
android:drawable="@drawable/scrollbar_btn_background_hover_dark" />
<item android:state_enabled="true"
android:drawable="@null" />
<item
android:drawable="@null" />
</selector>

BIN
views/res/tab_more_dark.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 373 B

View File

@ -77,21 +77,18 @@
<style id="BUTTON_NOMARGINS" <style id="BUTTON_NOMARGINS"
backgroundImageId="btn_background_dark" backgroundImageId="btn_background_dark"
/> />
<drawable id="close" value="close_dark"/>
<drawable id="tab_more" value="tab_more_dark"/>
<drawable id="btn_check" value="btn_check_dark"/> <drawable id="btn_check" value="btn_check_dark"/>
<drawable id="btn_radio" value="btn_radio_dark"/> <drawable id="btn_radio" value="btn_radio_dark"/>
<drawable id="arrow_right_down_black" value="arrow_right_down_black_dark"/> <drawable id="arrow_right_down_black" value="arrow_right_down_black_dark"/>
<drawable id="arrow_right_hollow" value="arrow_right_hollow_dark"/> <drawable id="arrow_right_hollow" value="arrow_right_hollow_dark"/>
<drawable id="toolbar_separator" value="toolbar_separator_dark"/> <drawable id="toolbar_separator" value="toolbar_separator_dark"/>
<drawable id="scrollbar_button_up" value="scrollbar_btn_up"/> <drawable id="scrollbar_button_up" value="scrollbar_btn_up_dark"/>
<drawable id="scrollbar_button_down" value="scrollbar_btn_down"/> <drawable id="scrollbar_button_down" value="scrollbar_btn_down_dark"/>
<drawable id="scrollbar_button_left" value="scrollbar_btn_left"/> <drawable id="scrollbar_button_left" value="scrollbar_btn_left_dark"/>
<drawable id="scrollbar_button_right" value="scrollbar_btn_right"/> <drawable id="scrollbar_button_right" value="scrollbar_btn_right_dark"/>
<drawable id="scrollbar_btn_up" value="scrollbar_btn_up_dark"/>
<drawable id="scrollbar_btn_down" value="scrollbar_btn_down_dark"/>
<drawable id="scrollbar_btn_left" value="scrollbar_btn_left_dark"/>
<drawable id="scrollbar_btn_right" value="scrollbar_btn_right_dark"/>
<drawable id="scrollbar_indicator_vertical" value="scrollbar_indicator_vertical"/> <drawable id="scrollbar_indicator_vertical" value="scrollbar_indicator_vertical"/>
<drawable id="scrollbar_indicator_horizontal" value="scrollbar_indicator_horizontal"/> <drawable id="scrollbar_indicator_horizontal" value="scrollbar_indicator_horizontal"/>
@ -103,6 +100,10 @@
backgroundImageId="scrollbar_btn_background_dark" backgroundImageId="scrollbar_btn_background_dark"
align="Center" align="Center"
/> />
<style id="SCROLLBAR_BUTTON_TRANSPARENT"
backgroundImageId="scrollbar_btn_transparent_background_dark"
align="Center"
/>
<style id="SLIDER" <style id="SLIDER"
backgroundImageId="slider_background_dark" backgroundImageId="slider_background_dark"
align="Center" align="Center"

View File

@ -21,6 +21,7 @@ res/btn_radio_dark.xml
res/btn_radio_background.xml res/btn_radio_background.xml
res/btn_radio_background_dark.xml res/btn_radio_background_dark.xml
res/close.png res/close.png
res/close_dark.png
res/combobox_background.xml res/combobox_background.xml
res/combobox_background_dark.xml res/combobox_background_dark.xml
res/editbox_background.xml res/editbox_background.xml
@ -284,6 +285,7 @@ res/scrollbar_btn_left_dark.png
res/scrollbar_btn_right.png res/scrollbar_btn_right.png
res/scrollbar_btn_right_dark.png res/scrollbar_btn_right_dark.png
res/scrollbar_btn_transparent_background.xml res/scrollbar_btn_transparent_background.xml
res/scrollbar_btn_transparent_background_dark.xml
res/scrollbar_btn_up.png res/scrollbar_btn_up.png
res/scrollbar_btn_up_dark.png res/scrollbar_btn_up_dark.png
res/scrollbar_indicator_horizontal.png res/scrollbar_indicator_horizontal.png
@ -308,6 +310,7 @@ res/tab_btn_up_normal_dark.9.png
res/tab_btn_up_selected.9.png res/tab_btn_up_selected.9.png
res/tab_btn_up_selected_dark.9.png res/tab_btn_up_selected_dark.9.png
res/tab_more.png res/tab_more.png
res/tab_more_dark.png
res/tab_down_background_dark.xml res/tab_down_background_dark.xml
res/tab_down_background_theme_dark.xml res/tab_down_background_theme_dark.xml
res/tab_up_background.9.png res/tab_up_background.9.png