diff --git a/src/dlangui/platforms/common/platform.d b/src/dlangui/platforms/common/platform.d index e373327e..346e15cd 100644 --- a/src/dlangui/platforms/common/platform.d +++ b/src/dlangui/platforms/common/platform.d @@ -622,8 +622,11 @@ class Window : CustomEventTarget { targetState = State.Focused | State.KeyboardFocused; if (oldFocus is newFocus) return oldFocus; - if (oldFocus !is null) + if (oldFocus !is null) { oldFocus.resetState(targetState); + if (oldFocus) + oldFocus.focusGroupFocused(false); + } if (newFocus is null || isChild(newFocus)) { if (newFocus !is null) { // when calling, setState(focused), window.focusedWidget is still previously focused widget @@ -631,6 +634,8 @@ class Window : CustomEventTarget { newFocus.setState(targetState); } _focusedWidget = newFocus; + if (_focusedWidget) + _focusedWidget.focusGroupFocused(true); // after focus change, ask for actions update automatically //requestActionsUpdate(); } diff --git a/src/dlangui/widgets/docks.d b/src/dlangui/widgets/docks.d index 9fb8a83d..5ddedcdb 100644 --- a/src/dlangui/widgets/docks.d +++ b/src/dlangui/widgets/docks.d @@ -321,6 +321,7 @@ class DockWindow : WindowFrame { this(string ID) { super(ID); + focusGroup = true; } override protected void initialize() { diff --git a/src/dlangui/widgets/tabs.d b/src/dlangui/widgets/tabs.d index a1576f0c..6dba34c9 100644 --- a/src/dlangui/widgets/tabs.d +++ b/src/dlangui/widgets/tabs.d @@ -120,6 +120,7 @@ class TabItemWidget : HorizontalLayout { setItem(item); clickable = true; trackHover = true; + _label.trackHover = true; } void setStyles(string tabButtonStyle, string tabButtonTextStyle) { styleId = tabButtonStyle; @@ -814,9 +815,10 @@ class TabWidget : VerticalLayout, TabHandler, TabCloseHandler { } /// change style ids - void setStyles(string tabWidgetStyle, string tabStyle, string tabButtonStyle, string tabButtonTextStyle) { + void setStyles(string tabWidgetStyle, string tabStyle, string tabButtonStyle, string tabButtonTextStyle, string tabHostStyle = null) { styleId = tabWidgetStyle; _tabControl.setStyles(tabStyle, tabButtonStyle, tabButtonTextStyle); + _tabHost.styleId = tabHostStyle; } private bool _tabNavigationInProgress; diff --git a/src/dlangui/widgets/widget.d b/src/dlangui/widgets/widget.d index ff1b893a..3021c6e6 100644 --- a/src/dlangui/widgets/widget.d +++ b/src/dlangui/widgets/widget.d @@ -282,7 +282,9 @@ public: @property uint state() const { if ((_state & State.Parent) != 0 && _parent !is null) return _parent.state; - return _state | State.WindowFocused; // TODO: + if (focusGroupFocused) + return _state | State.WindowFocused; // TODO: + return _state; } /// override to handle focus changes protected void handleFocusChange(bool focused, bool receivedFocusFromKeyboard = false) { @@ -296,6 +298,8 @@ public: } /// set new widget state (set of flags from State enum) @property Widget state(uint newState) { + if ((_state & State.Parent) != 0 && _parent !is null) + return _parent.state(newState); if (newState != _state) { uint oldState = _state; _state = newState; @@ -791,10 +795,41 @@ public: @property bool focusGroup() { return _focusGroup; } /// set focus group flag for container widget @property Widget focusGroup(bool flg) { _focusGroup = flg; return this; } + @property bool focusGroupFocused() const { + Widget w = focusGroupWidget(); + return (w._state & State.WindowFocused) != 0; + } + protected bool setWindowFocusedFlag(bool flg) { + if (flg) { + if ((_state & State.WindowFocused) == 0) { + _state |= State.WindowFocused; + invalidate(); + return true; + } + } else { + if ((_state & State.WindowFocused) != 0) { + _state &= ~State.WindowFocused; + invalidate(); + return true; + } + } + return false; + } + @property Widget focusGroupFocused(bool flg) { + Widget w = focusGroupWidget(); + w.setWindowFocusedFlag(flg); + while (w.parent) { + w = w.parent; + if (w.parent is null || w.focusGroup) { + w.setWindowFocusedFlag(flg); + } + } + return this; + } /// find nearest parent of this widget with focusGroup flag, returns topmost parent if no focusGroup flag set to any of parents. - Widget focusGroupWidget() { - Widget p = this; + Widget focusGroupWidget() inout { + Widget p = cast(Widget)this; while (p) { if (!p.parent || p.focusGroup) break; @@ -1694,6 +1729,11 @@ class WidgetGroup : Widget { _children.clear(destroyObj); } + /// replace child with other child + void replaceChild(Widget newChild, Widget oldChild) { + _children.replace(newChild, oldChild); + } + } /** WidgetGroup with default drawing of children (just draw all children) */ diff --git a/src/dlangui/widgets/winframe.d b/src/dlangui/widgets/winframe.d index f322449c..dd656ad5 100644 --- a/src/dlangui/widgets/winframe.d +++ b/src/dlangui/widgets/winframe.d @@ -27,7 +27,7 @@ class WindowFrame : VerticalLayout { protected Widget _bodyWidget; @property Widget bodyWidget() { return _bodyWidget; } @property void bodyWidget(Widget widget) { - _children.replace(widget, _bodyWidget); + _bodyLayout.replaceChild(widget, _bodyWidget); _bodyWidget = widget; _bodyWidget.layoutWidth(FILL_PARENT).layoutHeight(FILL_PARENT); _bodyWidget.parent = this; @@ -38,6 +38,7 @@ class WindowFrame : VerticalLayout { protected TextWidget _caption; protected ImageButton _closeButton; protected bool _showCloseButton; + protected HorizontalLayout _bodyLayout; @property TextWidget caption() { return _caption; } @@ -76,11 +77,16 @@ class WindowFrame : VerticalLayout { _captionLayout.addChild(_caption); _captionLayout.addChild(_closeButton); + _bodyLayout = new HorizontalLayout(); + _bodyLayout.styleId = STYLE_DOCK_WINDOW_BODY; + _bodyWidget = createBodyWidget(); - _bodyWidget.styleId = STYLE_DOCK_WINDOW_BODY; + _bodyLayout.addChild(_bodyWidget); + _bodyWidget.layoutWidth(FILL_PARENT).layoutHeight(FILL_PARENT); + //_bodyWidget.styleId = STYLE_DOCK_WINDOW_BODY; addChild(_captionLayout); - addChild(_bodyWidget); + addChild(_bodyLayout); } protected Widget createBodyWidget() { diff --git a/views/res/dock_window_background.xml b/views/res/dock_window_background.xml new file mode 100644 index 00000000..f4972e45 --- /dev/null +++ b/views/res/dock_window_background.xml @@ -0,0 +1,8 @@ + + + + + diff --git a/views/res/dock_window_background_focused.9.png b/views/res/dock_window_background_focused.9.png new file mode 100644 index 00000000..9e4181bc Binary files /dev/null and b/views/res/dock_window_background_focused.9.png differ diff --git a/views/res/dock_window_background_normal.9.png b/views/res/dock_window_background_normal.9.png new file mode 100644 index 00000000..0311ac08 Binary files /dev/null and b/views/res/dock_window_background_normal.9.png differ diff --git a/views/res/dock_window_caption_background.xml b/views/res/dock_window_caption_background.xml new file mode 100644 index 00000000..683dd8b4 --- /dev/null +++ b/views/res/dock_window_caption_background.xml @@ -0,0 +1,8 @@ + + + + + diff --git a/views/res/dock_window_caption_background_down.xml b/views/res/dock_window_caption_background_down.xml new file mode 100644 index 00000000..39355aac --- /dev/null +++ b/views/res/dock_window_caption_background_down.xml @@ -0,0 +1,8 @@ + + + + + diff --git a/views/res/dock_window_caption_background_focused.9.png b/views/res/dock_window_caption_background_focused.9.png new file mode 100644 index 00000000..cb94b3f1 Binary files /dev/null and b/views/res/dock_window_caption_background_focused.9.png differ diff --git a/views/res/dock_window_caption_background_focused_down.9.png b/views/res/dock_window_caption_background_focused_down.9.png new file mode 100644 index 00000000..ec5df142 Binary files /dev/null and b/views/res/dock_window_caption_background_focused_down.9.png differ diff --git a/views/res/dock_window_caption_background_normal.9.png b/views/res/dock_window_caption_background_normal.9.png new file mode 100644 index 00000000..77d8d545 Binary files /dev/null and b/views/res/dock_window_caption_background_normal.9.png differ diff --git a/views/res/dock_window_caption_background_normal_down.9.png b/views/res/dock_window_caption_background_normal_down.9.png new file mode 100644 index 00000000..dd69c780 Binary files /dev/null and b/views/res/dock_window_caption_background_normal_down.9.png differ diff --git a/views/res/main_menu_background.9.png b/views/res/main_menu_background.9.png new file mode 100644 index 00000000..13a25e84 Binary files /dev/null and b/views/res/main_menu_background.9.png differ diff --git a/views/res/mdpi/tab_btn_dark_down_focused.9.png b/views/res/mdpi/tab_btn_dark_down_focused.9.png index 0ea1b0f9..0e8e0b5e 100644 Binary files a/views/res/mdpi/tab_btn_dark_down_focused.9.png and b/views/res/mdpi/tab_btn_dark_down_focused.9.png differ diff --git a/views/res/mdpi/tab_btn_dark_down_focused_hover.9.png b/views/res/mdpi/tab_btn_dark_down_focused_hover.9.png new file mode 100644 index 00000000..f2bb072a Binary files /dev/null and b/views/res/mdpi/tab_btn_dark_down_focused_hover.9.png differ diff --git a/views/res/mdpi/tab_btn_dark_down_focused_selected.9.png b/views/res/mdpi/tab_btn_dark_down_focused_selected.9.png index 8fd60b3d..b70e1d48 100644 Binary files a/views/res/mdpi/tab_btn_dark_down_focused_selected.9.png and b/views/res/mdpi/tab_btn_dark_down_focused_selected.9.png differ diff --git a/views/res/mdpi/tab_btn_dark_down_hover.9.png b/views/res/mdpi/tab_btn_dark_down_hover.9.png index 65a3dbac..da9eb2f4 100644 Binary files a/views/res/mdpi/tab_btn_dark_down_hover.9.png and b/views/res/mdpi/tab_btn_dark_down_hover.9.png differ diff --git a/views/res/mdpi/tab_btn_dark_down_normal.9.png b/views/res/mdpi/tab_btn_dark_down_normal.9.png index c30090b6..14fa6ed0 100644 Binary files a/views/res/mdpi/tab_btn_dark_down_normal.9.png and b/views/res/mdpi/tab_btn_dark_down_normal.9.png differ diff --git a/views/res/mdpi/tab_btn_dark_down_selected.9.png b/views/res/mdpi/tab_btn_dark_down_selected.9.png index d5ae72ec..9b2fa154 100644 Binary files a/views/res/mdpi/tab_btn_dark_down_selected.9.png and b/views/res/mdpi/tab_btn_dark_down_selected.9.png differ diff --git a/views/res/mdpi/tab_btn_dark_up_focused.9.png b/views/res/mdpi/tab_btn_dark_up_focused.9.png index 74c57673..95d260aa 100644 Binary files a/views/res/mdpi/tab_btn_dark_up_focused.9.png and b/views/res/mdpi/tab_btn_dark_up_focused.9.png differ diff --git a/views/res/mdpi/tab_btn_dark_up_focused_hover.9.png b/views/res/mdpi/tab_btn_dark_up_focused_hover.9.png new file mode 100644 index 00000000..65cba338 Binary files /dev/null and b/views/res/mdpi/tab_btn_dark_up_focused_hover.9.png differ diff --git a/views/res/mdpi/tab_btn_dark_up_focused_selected.9.png b/views/res/mdpi/tab_btn_dark_up_focused_selected.9.png index 95057205..08a7cbd1 100644 Binary files a/views/res/mdpi/tab_btn_dark_up_focused_selected.9.png and b/views/res/mdpi/tab_btn_dark_up_focused_selected.9.png differ diff --git a/views/res/mdpi/tab_btn_dark_up_hover.9.png b/views/res/mdpi/tab_btn_dark_up_hover.9.png index c4ac1a8b..eb81d9ed 100644 Binary files a/views/res/mdpi/tab_btn_dark_up_hover.9.png and b/views/res/mdpi/tab_btn_dark_up_hover.9.png differ diff --git a/views/res/mdpi/tab_btn_dark_up_normal.9.png b/views/res/mdpi/tab_btn_dark_up_normal.9.png index 002ed6fc..f57cbdc4 100644 Binary files a/views/res/mdpi/tab_btn_dark_up_normal.9.png and b/views/res/mdpi/tab_btn_dark_up_normal.9.png differ diff --git a/views/res/mdpi/tab_btn_dark_up_selected.9.png b/views/res/mdpi/tab_btn_dark_up_selected.9.png index 81658702..7e50ce1b 100644 Binary files a/views/res/mdpi/tab_btn_dark_up_selected.9.png and b/views/res/mdpi/tab_btn_dark_up_selected.9.png differ diff --git a/views/res/mdpi/toolbar_background.9.png b/views/res/mdpi/toolbar_background.9.png index c348ca45..8612803a 100644 Binary files a/views/res/mdpi/toolbar_background.9.png and b/views/res/mdpi/toolbar_background.9.png differ diff --git a/views/res/mdpi/toolbar_host_background.9.png b/views/res/mdpi/toolbar_host_background.9.png new file mode 100644 index 00000000..8f6725e1 Binary files /dev/null and b/views/res/mdpi/toolbar_host_background.9.png differ diff --git a/views/res/tab_btn_dark_down.xml b/views/res/tab_btn_dark_down.xml index 666103a6..2ed91e0e 100644 --- a/views/res/tab_btn_dark_down.xml +++ b/views/res/tab_btn_dark_down.xml @@ -3,6 +3,9 @@ + diff --git a/views/res/tab_btn_dark_up.xml b/views/res/tab_btn_dark_up.xml index b00959da..2945ff6a 100644 --- a/views/res/tab_btn_dark_up.xml +++ b/views/res/tab_btn_dark_up.xml @@ -3,6 +3,9 @@ + diff --git a/views/res/theme_default.xml b/views/res/theme_default.xml index dd553d4d..c266e32d 100644 --- a/views/res/theme_default.xml +++ b/views/res/theme_default.xml @@ -164,7 +164,7 @@ @@ -173,24 +173,21 @@ backgroundImageId="tab_btn_dark_down" />