From e8f7d2ded48b366c59eb9e8b0c840ea4f754b9af Mon Sep 17 00:00:00 2001 From: and3md Date: Thu, 29 Jun 2017 20:30:43 +0200 Subject: [PATCH] Fix dialogs to be compatible with new window size/content managment. --- src/dlangui/dialogs/dialog.d | 2 ++ src/dlangui/dialogs/filedlg.d | 17 +++++++++-------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/dlangui/dialogs/dialog.d b/src/dlangui/dialogs/dialog.d index 029eee5b..4a098ebb 100644 --- a/src/dlangui/dialogs/dialog.d +++ b/src/dlangui/dialogs/dialog.d @@ -208,6 +208,8 @@ class Dialog : VerticalLayout { _popup = _parentWindow.showPopup(_frame); _popup.flags(PopupFlags.Modal); } else { + if (_initialWidth == 0 && _initialHeight == 0) + wflags |= WindowFlag.MeasureSize; _window = Platform.instance.createWindow(_caption, _parentWindow, wflags, _initialWidth, _initialHeight); static if (BACKEND_GUI) { if (_window && _icon) diff --git a/src/dlangui/dialogs/filedlg.d b/src/dlangui/dialogs/filedlg.d index 2bac87e0..36bfdd47 100644 --- a/src/dlangui/dialogs/filedlg.d +++ b/src/dlangui/dialogs/filedlg.d @@ -600,6 +600,8 @@ class FileDialog : Dialog, CustomGridCellAdapter { _fileList.multiSelect = _allowMultipleFiles; _fileList.cellPopupMenu = &getCellPopupMenu; _fileList.menuItemAction = &handleAction; + _fileList.minVisibleRows = 10; + _fileList.minVisibleCols = 4; _fileList.keyEvent = delegate(Widget source, KeyEvent event) { if (_shortcutHelper.onKeyEvent(event)) @@ -766,13 +768,15 @@ class FilePathPanelButtons : WidgetGroupDefaultDrawing { override void measure(int parentWidth, int parentHeight) { Rect m = margins; Rect p = padding; + // calc size constraints for children - int pwidth = parentWidth; - int pheight = parentHeight; + int pwidth = 0; + int pheight = 0; if (parentWidth != SIZE_UNSPECIFIED) - pwidth -= m.left + m.right + p.left + p.right; + pwidth = parentWidth - (m.left + m.right + p.left + p.right); + if (parentHeight != SIZE_UNSPECIFIED) - pheight -= m.top + m.bottom + p.top + p.bottom; + pheight = parentHeight - (m.top + m.bottom + p.top + p.bottom); int reservedForEmptySpace = parentWidth / 20; if (reservedForEmptySpace > 40.pointsToPixels) reservedForEmptySpace = 40.pointsToPixels; @@ -785,17 +789,14 @@ class FilePathPanelButtons : WidgetGroupDefaultDrawing { bool exceeded = false; for (int i = 0; i < _children.count; i++) { Widget item = _children.get(i); - item.visibility = Visibility.Visible; item.measure(pwidth, pheight); if (sz.y < item.measuredHeight) sz.y = item.measuredHeight; if (sz.x + item.measuredWidth > pwidth) { exceeded = true; } - if (!exceeded || i == 0) // at least one item must be visible + if (!exceeded || i == 0) // at least one item must be measured sz.x += item.measuredWidth; - else - item.visibility = Visibility.Gone; } measuredContent(parentWidth, parentHeight, sz.x, sz.y); }