fix theme change handling - close buggins/dlangide#132

This commit is contained in:
Vadim Lopatin 2016-02-01 15:01:56 +03:00
parent 8d5c118922
commit c9896d9cb4
3 changed files with 14 additions and 1 deletions

View File

@ -213,6 +213,7 @@ class ImageWidget : Widget {
/// handle theme change: e.g. reload some themed resources
override void onThemeChanged() {
super.onThemeChanged();
if (_drawableId !is null)
_drawable.clear(); // remove cached drawable
}

View File

@ -886,6 +886,16 @@ class ListWidget : WidgetGroup, OnScrollHandler, OnAdapterChangeHandler {
return true;
}
/// handle theme change: e.g. reload some themed resources
override void onThemeChanged() {
super.onThemeChanged();
_scrollbar.onThemeChanged();
for (int i = 0; i < itemCount; i++) {
Widget w = itemWidget(i);
w.onThemeChanged();
}
}
/// Measure widget according to desired width and height constraints. (Step 1 of two phase layout).
override void measure(int parentWidth, int parentHeight) {
if (visibility == Visibility.Gone) {

View File

@ -255,13 +255,15 @@ public:
/// handle theme change: e.g. reload some themed resources
void onThemeChanged() {
_cachedStyle = currentTheme.get(_styleId);
// default implementation: call recursive for children
for (int i = 0; i < childCount; i++)
child(i).onThemeChanged();
if (_ownStyle) {
_ownStyle.onThemeChanged();
}
if (_cachedStyle) {
_cachedStyle = currentTheme.get(_styleId);
}
}
/// returns widget id, null if not set