diff --git a/src/dlangui/dialogs/filedlg.d b/src/dlangui/dialogs/filedlg.d index abdc5494..2e61ec0e 100644 --- a/src/dlangui/dialogs/filedlg.d +++ b/src/dlangui/dialogs/filedlg.d @@ -473,7 +473,7 @@ class FilePathPanelItem : HorizontalLayout { } /// Panel with buttons - path segments - for fast navigation to subdirs. -class FilePathPanelButtons : WidgetGroup { +class FilePathPanelButtons : WidgetGroupDefaultDrawing { protected string _path; Listener!OnPathSelectionHandler onPathSelectionListener; protected bool onPathSelected(string path) { @@ -583,22 +583,6 @@ class FilePathPanelButtons : WidgetGroup { } - /// Draw widget at its position to buffer - override void onDraw(DrawBuf buf) { - if (visibility != Visibility.Visible) - return; - super.onDraw(buf); - Rect rc = _pos; - applyMargins(rc); - applyPadding(rc); - auto saver = ClipRectSaver(buf, rc); - for (int i = 0; i < _children.count; i++) { - Widget item = _children.get(i); - if (item.visibility != Visibility.Visible) - continue; - item.onDraw(buf); - } - } } diff --git a/src/dlangui/widgets/layouts.d b/src/dlangui/widgets/layouts.d index 54a3fec3..72e84405 100644 --- a/src/dlangui/widgets/layouts.d +++ b/src/dlangui/widgets/layouts.d @@ -472,7 +472,7 @@ class ResizerWidget : Widget { /// Arranges items either vertically or horizontally -class LinearLayout : WidgetGroup { +class LinearLayout : WidgetGroupDefaultDrawing { protected Orientation _orientation = Orientation.Vertical; /// returns linear layout orientation (Vertical, Horizontal) @property Orientation orientation() { return _orientation; } @@ -519,22 +519,6 @@ class LinearLayout : WidgetGroup { applyPadding(rc); _layoutItems.layout(rc); } - /// Draw widget at its position to buffer - override void onDraw(DrawBuf buf) { - if (visibility != Visibility.Visible) - return; - super.onDraw(buf); - Rect rc = _pos; - applyMargins(rc); - applyPadding(rc); - auto saver = ClipRectSaver(buf, rc); - for (int i = 0; i < _children.count; i++) { - Widget item = _children.get(i); - if (item.visibility != Visibility.Visible) - continue; - item.onDraw(buf); - } - } } @@ -565,7 +549,7 @@ class HorizontalLayout : LinearLayout { } /// place all children into same place (usually, only one child should be visible at a time) -class FrameLayout : WidgetGroup { +class FrameLayout : WidgetGroupDefaultDrawing { /// empty parameter list constructor - for usage by factory this() { this(null); @@ -617,23 +601,6 @@ class FrameLayout : WidgetGroup { } } - /// Draw widget at its position to buffer - override void onDraw(DrawBuf buf) { - if (visibility != Visibility.Visible) - return; - super.onDraw(buf); - Rect rc = _pos; - applyMargins(rc); - applyPadding(rc); - auto saver = ClipRectSaver(buf, rc); - for (int i = 0; i < _children.count; i++) { - Widget item = _children.get(i); - if (item.visibility != Visibility.Visible) - continue; - item.onDraw(buf); - } - } - /// make one of children (with specified ID) visible, for the rest, set visibility to otherChildrenVisibility bool showChild(string ID, Visibility otherChildrenVisibility = Visibility.Invisible, bool updateFocus = false) { bool found = false; @@ -655,7 +622,7 @@ class FrameLayout : WidgetGroup { } /// layout children as table with rows and columns -class TableLayout : WidgetGroup { +class TableLayout : WidgetGroupDefaultDrawing { this(string ID = null) { super(ID); @@ -845,21 +812,4 @@ class TableLayout : WidgetGroup { _cells.layout(rc); } - /// Draw widget at its position to buffer - override void onDraw(DrawBuf buf) { - if (visibility != Visibility.Visible) - return; - super.onDraw(buf); - Rect rc = _pos; - applyMargins(rc); - applyPadding(rc); - auto saver = ClipRectSaver(buf, rc); - for (int i = 0; i < _children.count; i++) { - Widget item = _children.get(i); - if (item.visibility != Visibility.Visible) - continue; - item.onDraw(buf); - } - } - } diff --git a/src/dlangui/widgets/menu.d b/src/dlangui/widgets/menu.d index 158585ec..21b5b276 100644 --- a/src/dlangui/widgets/menu.d +++ b/src/dlangui/widgets/menu.d @@ -206,7 +206,7 @@ class MenuItem { } /// widget to draw menu item -class MenuItemWidget : WidgetGroup { +class MenuItemWidget : WidgetGroupDefaultDrawing { protected bool _mainMenu; protected MenuItem _item; protected ImageWidget _icon; @@ -298,24 +298,6 @@ class MenuItemWidget : WidgetGroup { resetState(State.Checked); } - /// Draw widget at its position to buffer - override void onDraw(DrawBuf buf) { - if (visibility != Visibility.Visible) - return; - super.onDraw(buf); - Rect rc = _pos; - applyMargins(rc); - applyPadding(rc); - updateState(); - auto saver = ClipRectSaver(buf, rc, alpha); - for (int i = 0; i < _children.count; i++) { - Widget item = _children.get(i); - if (item.visibility != Visibility.Visible) - continue; - item.onDraw(buf); - } - } - this(MenuItem item, bool mainMenu) { id="menuitem"; _mainMenu = mainMenu; diff --git a/src/dlangui/widgets/scroll.d b/src/dlangui/widgets/scroll.d index 0d4e8a3a..44135370 100644 --- a/src/dlangui/widgets/scroll.d +++ b/src/dlangui/widgets/scroll.d @@ -300,9 +300,9 @@ class ScrollWidgetBase : WidgetGroup, OnScrollHandler { If size of content widget exceeds available space, allows to scroll it. */ class ScrollWidget : ScrollWidgetBase { - protected WidgetGroup _contentWidget; - @property WidgetGroup contentWidget() { return _contentWidget; } - @property ScrollWidget contentWidget(WidgetGroup newContent) { + protected Widget _contentWidget; + @property Widget contentWidget() { return _contentWidget; } + @property ScrollWidget contentWidget(Widget newContent) { if (_contentWidget) { removeChild(childIndex(_contentWidget)); destroy(_contentWidget); diff --git a/src/dlangui/widgets/tabs.d b/src/dlangui/widgets/tabs.d index 1a8a267b..2be382c1 100644 --- a/src/dlangui/widgets/tabs.d +++ b/src/dlangui/widgets/tabs.d @@ -167,7 +167,7 @@ class TabItemList { } /// tab header - tab labels, with optional More button -class TabControl : WidgetGroup { +class TabControl : WidgetGroupDefaultDrawing { protected TabItemList _items; protected ImageButton _moreButton; protected bool _enableCloseButton; @@ -338,24 +338,6 @@ class TabControl : WidgetGroup { } //Log.d("tabControl.layout exit"); } - /// Draw widget at its position to buffer - override void onDraw(DrawBuf buf) { - //Log.d("tabControl.onDraw enter"); - if (visibility != Visibility.Visible) - return; - super.onDraw(buf); - Rect rc = _pos; - applyMargins(rc); - applyPadding(rc); - auto saver = ClipRectSaver(buf, rc); - for (int i = 0; i < _children.count; i++) { - Widget item = _children.get(i); - if (item.visibility != Visibility.Visible) - continue; - item.onDraw(buf); - } - //Log.d("tabControl.onDraw exit"); - } protected string _selectedTabId; diff --git a/src/dlangui/widgets/widget.d b/src/dlangui/widgets/widget.d index 5f84e289..e14cf24f 100644 --- a/src/dlangui/widgets/widget.d +++ b/src/dlangui/widgets/widget.d @@ -1336,6 +1336,34 @@ class WidgetGroup : Widget { } +/** WidgetGroup with default drawing of children (just draw all children) */ +class WidgetGroupDefaultDrawing : WidgetGroup { + /// empty parameter list constructor - for usage by factory + this() { + this(null); + } + /// create with ID parameter + this(string ID) { + super(ID); + } + /// Draw widget at its position to buffer + override void onDraw(DrawBuf buf) { + if (visibility != Visibility.Visible) + return; + super.onDraw(buf); + Rect rc = _pos; + applyMargins(rc); + applyPadding(rc); + auto saver = ClipRectSaver(buf, rc); + for (int i = 0; i < _children.count; i++) { + Widget item = _children.get(i); + if (item.visibility != Visibility.Visible) + continue; + item.onDraw(buf); + } + } +} + immutable long ONE_SECOND = 10000000L; /// Helper to handle animation progress