From 3816e39155845c7fa8411472340cd510c8d27ac9 Mon Sep 17 00:00:00 2001 From: and3md Date: Mon, 17 Jul 2017 17:04:33 +0200 Subject: [PATCH] Add font change handler. --- src/dlangui/widgets/widget.d | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/dlangui/widgets/widget.d b/src/dlangui/widgets/widget.d index 80ac58ca..6993c33e 100644 --- a/src/dlangui/widgets/widget.d +++ b/src/dlangui/widgets/widget.d @@ -498,6 +498,7 @@ public: ownStyle.textFlags = value; bool oldHotkeys = (ownStyle.textFlags & (TextFlag.HotKeys | TextFlag.UnderlineHotKeys | TextFlag.UnderlineHotKeysWhenAltPressed)) != 0; bool newHotkeys = (value & (TextFlag.HotKeys | TextFlag.UnderlineHotKeys | TextFlag.UnderlineHotKeysWhenAltPressed)) != 0; + handleFontChanged(); if (oldHotkeys != newHotkeys) requestLayout(); else @@ -509,6 +510,7 @@ public: /// set font face for widget - override one from style @property Widget fontFace(string face) { ownStyle.fontFace = face; + handleFontChanged(); requestLayout(); return this; } @@ -517,6 +519,7 @@ public: /// set font style (italic/normal) for widget - override one from style @property Widget fontItalic(bool italic) { ownStyle.fontStyle = italic ? FONT_STYLE_ITALIC : FONT_STYLE_NORMAL; + handleFontChanged(); requestLayout(); return this; } @@ -529,6 +532,7 @@ public: else if (weight > 900) weight = 900; ownStyle.fontWeight = cast(ushort)weight; + handleFontChanged(); requestLayout(); return this; } @@ -537,6 +541,7 @@ public: /// set font size for widget - override one from style @property Widget fontSize(int size) { ownStyle.fontSize = size; + handleFontChanged(); requestLayout(); return this; } @@ -545,6 +550,7 @@ public: /// set font family for widget - override one from style @property Widget fontFamily(FontFamily family) { ownStyle.fontFamily = family; + handleFontChanged(); requestLayout(); return this; } @@ -569,6 +575,9 @@ public: @property Widget text(dstring s) { return this; } /// sets widget content text (override to support this) @property Widget text(UIString s) { return this; } + + /// override to handle font changes + protected void handleFontChanged() {} //================================================================== // Layout and drawing related methods