From a740aa0f0cf7fc06592f59cb059002641d13a5ee Mon Sep 17 00:00:00 2001 From: Vadim Lopatin Date: Tue, 10 Mar 2015 13:32:22 +0300 Subject: [PATCH] dark theme fixes --- src/dlangui/widgets/editors.d | 5 +- src/dlangui/widgets/grid.d | 44 ++++++++++++++---- src/dlangui/widgets/styles.d | 2 +- .../mdpi/popup_window_background_dark.9.png | Bin 490 -> 491 bytes views/res/theme_dark.xml | 34 +++++++++----- views/res/theme_default.xml | 10 ++++ 6 files changed, 72 insertions(+), 23 deletions(-) diff --git a/src/dlangui/widgets/editors.d b/src/dlangui/widgets/editors.d index 7211c7e9..860cf925 100644 --- a/src/dlangui/widgets/editors.d +++ b/src/dlangui/widgets/editors.d @@ -233,6 +233,7 @@ class EditWidgetBase : ScrollWidgetBase, EditableContentListener, MenuItemAction protected uint _leftPaneLineNumberBackgroundColor = 0xF0F0F0; protected uint _caretColor = 0x000000; protected uint _caretColorReplace = 0x808080FF; + protected uint _matchingBracketHightlightColor = 0x60FFE0B0; protected uint _iconsPaneWidth = 16; protected uint _foldingPaneWidth = 12; protected uint _modificationMarksPaneWidth = 4; @@ -810,6 +811,7 @@ class EditWidgetBase : ScrollWidgetBase, EditableContentListener, MenuItemAction _leftPaneBackgroundColor3 = style.customColor("editor_left_pane_background3"); _leftPaneLineNumberColor = style.customColor("editor_left_pane_line_number_text"); _leftPaneLineNumberBackgroundColor = style.customColor("editor_left_pane_line_number_background"); + _matchingBracketHightlightColor = style.customColor("editor_matching_bracket_highlight"); super.onThemeChanged(); } @@ -1490,6 +1492,7 @@ class EditLine : EditWidgetBase { wantTabs = false; styleId = STYLE_EDIT_LINE; text = initialContent; + onThemeChanged(); } protected dstring _measuredText; @@ -1684,8 +1687,8 @@ class EditBox : EditWidgetBase { new Action(EditorActions.ZoomIn, KeyCode.ADD, KeyFlag.Control), new Action(EditorActions.ZoomOut, KeyCode.SUB, KeyFlag.Control), ]); + onThemeChanged(); } - protected uint _matchingBracketHightlightColor = 0x60FFE0B0; protected int _firstVisibleLine; diff --git a/src/dlangui/widgets/grid.d b/src/dlangui/widgets/grid.d index f46ece19..31f403d8 100644 --- a/src/dlangui/widgets/grid.d +++ b/src/dlangui/widgets/grid.d @@ -289,6 +289,14 @@ class GridWidgetBase : ScrollWidgetBase { /// set row count @property GridWidgetBase rows(int r) { resize(cols, r); return this; } + protected uint _selectionColor = 0x804040FF; + protected uint _selectionColorRowSelect = 0xC0A0B0FF; + protected uint _fixedCellBackgroundColor = 0xC0E0E0E0; + protected uint _cellBorderColor = 0xC0C0C0C0; + protected uint _cellHeaderBorderColor = 0xC0202020; + protected uint _cellHeaderBackgroundColor = 0xC0909090; + protected uint _cellHeaderSelectedBackgroundColor = 0x80FFC040; + /// row header column count @property int headerCols() { return _headerCols; } @property GridWidgetBase headerCols(int c) { @@ -1171,13 +1179,16 @@ class StringGridWidget : StringGridWidgetBase { this(string ID) { super(ID); styleId = STYLE_EDIT_BOX; + onThemeChanged(); } + /// get cell text override dstring cellText(int col, int row) { if (col >= 0 && col < cols && row >= 0 && row < rows) return _data[row][col]; return ""d; } + /// set cell text override StringGridWidgetBase setCellText(int col, int row, dstring text) { if (col >= 0 && col < cols && row >= 0 && row < rows) @@ -1288,18 +1299,31 @@ class StringGridWidget : StringGridWidgetBase { if (_rowSelect && selectedRow) selectedCell = true; // draw header cell background - uint cl = 0xC0909090; + uint cl = _cellHeaderBackgroundColor; if (c >= _headerCols || r >= _headerRows) { if (c < _headerCols && selectedRow) - cl = 0x80FFC040; + cl = _cellHeaderSelectedBackgroundColor; if (r < _headerRows && selectedCol) - cl = 0x80FFC040; + cl = _cellHeaderSelectedBackgroundColor; } buf.fillRect(rc, cl); - buf.fillRect(vborder, 0xC0202020); - buf.fillRect(hborder, 0xC0202020); + buf.fillRect(vborder, _cellHeaderBorderColor); + buf.fillRect(hborder, _cellHeaderBorderColor); } + + /// handle theme change: e.g. reload some themed resources + override void onThemeChanged() { + _selectionColor = style.customColor("grid_selection_color", 0x804040FF); + _selectionColorRowSelect = style.customColor("grid_selection_color_row", 0xC0A0B0FF); + _fixedCellBackgroundColor = style.customColor("grid_cell_background_fixed", 0xC0E0E0E0); + _cellBorderColor = style.customColor("grid_cell_border_color", 0xC0C0C0C0); + _cellHeaderBorderColor = style.customColor("grid_cell_border_color_header", 0xC0202020); + _cellHeaderBackgroundColor = style.customColor("grid_cell_background_header", 0xC0909090); + _cellHeaderSelectedBackgroundColor = style.customColor("grid_cell_background_header_selected", 0x80FFC040); + super.onThemeChanged(); + } + /// draw cell background protected override void drawCellBackground(DrawBuf buf, Rect rc, int c, int r) { Rect vborder = rc; @@ -1315,15 +1339,15 @@ class StringGridWidget : StringGridWidgetBase { // normal cell background if (c < _fixedCols || r < _fixedRows) { // fixed cell background - buf.fillRect(rc, 0xC0E0E0E0); + buf.fillRect(rc, _fixedCellBackgroundColor); } - buf.fillRect(vborder, 0xC0C0C0C0); - buf.fillRect(hborder, 0xC0C0C0C0); + buf.fillRect(vborder, _cellBorderColor); + buf.fillRect(hborder, _cellBorderColor); if (selectedCell) { if (_rowSelect) - buf.drawFrame(rc, 0xC0A0B0FF, Rect(0,1,0,1), 0xE0FFFF40); + buf.drawFrame(rc, _selectionColorRowSelect, Rect(0,1,0,1), _cellBorderColor); else - buf.drawFrame(rc, 0x804040FF, Rect(1,1,1,1), 0xE0FFFF40); + buf.drawFrame(rc, _selectionColor, Rect(1,1,1,1), _cellBorderColor); } } diff --git a/src/dlangui/widgets/styles.d b/src/dlangui/widgets/styles.d index edf6d2c9..a212fba1 100644 --- a/src/dlangui/widgets/styles.d +++ b/src/dlangui/widgets/styles.d @@ -1234,7 +1234,7 @@ bool loadStyleAttributes(Style style, Element elem, bool allowStates) { uint stateValue = 0; extractStateFlags(item.tag.attr, stateMask, stateValue); if (stateMask) { - Style state = style.createState(stateMask, stateValue); + Style state = style.getOrCreateState(stateMask, stateValue); loadStyleAttributes(state, item, false); } } else if (item.tag.name.equal("drawable")) { diff --git a/views/res/mdpi/popup_window_background_dark.9.png b/views/res/mdpi/popup_window_background_dark.9.png index 1e3450a6fe28c7d6f753feaa4b3ef49877f682df..0e466dc0f652b6eafcd685519bdf4e88867d7a37 100644 GIT binary patch delta 459 zcmV;+0W|*V1M35jDu4d~{{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G` z2j2q<3L62`2jDaS00DSOL_t(Y$E}s!PQpMGgum9MP*5-?UKk@pV|)SM{}FftuDBsl z@rU2?Q|isESz*D}>?EhVZQ7ab**$Y24pC4JQR$bukI!XEy?+=E`gefQ;l%XceivJw8!fc2P_9f{{38u0%j4@>hK@S9%f&oI1*GAGY1> z1^99W79!bcK6cJ_TtXmsvM>|*)aM<=KRxIuz5$6WV)m>oZYcl&002ovPDHLkV1nOh B$N2yN delta 458 zcmV;*0X6>X1L^~iDt{jUJ^;k24|N{^000SaNLh0L01FcU01FcV0GgZ_00007bV*G` z2j2q*2oo=fS_~xs00DPNL_t(Y$E}s!PQpMGgukv!v7kasxG+YDhWG-$|0D1QTyaAp zqA34ArQXb%3JbPoCpq11)6Q(q?wJ#DjErK43cu9uz7!?(Vt>%@JpfjV+W~9E)Di}F zKt%#8U!uwb0a6i<^?Ybck3a@Qq3R%Ugc`G7e=z9xo@Kcm;1Re7Zh@K##~hq@ ztF+WaUXewl>IbRfCq=Q!+m(C+XzIS=Ip4_z9?kMN`u + @@ -18,6 +19,14 @@ + + + + + + + + @@ -210,20 +222,20 @@ align="Left|VCenter" textFlags="UnderlineHotKeys" > - +