Fix dialogs to be compatible with new window size/content managment.

This commit is contained in:
and3md 2017-06-29 20:30:43 +02:00
parent c8ebb6bd68
commit e8f7d2ded4
2 changed files with 11 additions and 8 deletions

View File

@ -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)

View File

@ -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);
}