From 90cf7253ca8baa83cdd26c4b947b2ec86c0a6572 Mon Sep 17 00:00:00 2001 From: Vadim Lopatin Date: Tue, 27 Jan 2015 15:47:52 +0300 Subject: [PATCH] file dialogs in popup by default; update style for floating windows --- src/dlangui/dialogs/dialog.d | 12 ++++++++++++ src/dlangui/dialogs/filedlg.d | 4 +++- src/dlangui/widgets/styles.d | 2 ++ views/res/mdpi/popup_window_background.9.png | Bin 0 -> 556 bytes views/res/theme_default.xml | 7 +++++++ views/standard_resources.list | 1 + 6 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 views/res/mdpi/popup_window_background.9.png diff --git a/src/dlangui/dialogs/dialog.d b/src/dlangui/dialogs/dialog.d index 263aef37..894ba2df 100644 --- a/src/dlangui/dialogs/dialog.d +++ b/src/dlangui/dialogs/dialog.d @@ -64,6 +64,17 @@ class Dialog : VerticalLayout { _icon = "dlangui-logo1"; } + /** + Measure widget according to desired width and height constraints. (Step 1 of two phase layout). + */ + void measure(int parentWidth, int parentHeight) { + super.measure(parentWidth, parentHeight); + if ((_flags & DialogFlag.Resizable) && (_flags & DialogFlag.Popup)) { + Point sz = Point(_parentWindow.width * 4 / 5, _parentWindow.height * 4 / 5); + measuredContent(parentWidth, parentHeight, sz.x, sz.y); + } + } + /// get icon resource id @property string windowIcon() { return _icon; @@ -204,6 +215,7 @@ class DialogFrame : WindowFrame { protected Dialog _dialog; this(Dialog dialog, bool enableCloseButton) { super(dialog.id ~ "_frame", enableCloseButton); + styleId = STYLE_FLOATING_WINDOW; _dialog = dialog; _caption.text = _dialog.windowCaption.value; bodyWidget = _dialog; diff --git a/src/dlangui/dialogs/filedlg.d b/src/dlangui/dialogs/filedlg.d index 2e61ec0e..0b541eb5 100644 --- a/src/dlangui/dialogs/filedlg.d +++ b/src/dlangui/dialogs/filedlg.d @@ -69,6 +69,8 @@ struct FileFilterEntry { } } +__gshared bool SHOW_FILE_DIALOG_IN_POPUP = true; + /// File open / save dialog class FileDialog : Dialog, CustomGridCellAdapter { protected FilePathPanel _edPath; @@ -90,7 +92,7 @@ class FileDialog : Dialog, CustomGridCellAdapter { protected bool _isOpenDialog; this(UIString caption, Window parent, Action action = null, uint fileDialogFlags = DialogFlag.Modal | DialogFlag.Resizable | FileDialogFlag.FileMustExist) { - super(caption, parent, fileDialogFlags); + super(caption, parent, fileDialogFlags | (SHOW_FILE_DIALOG_IN_POPUP ? DialogFlag.Popup : 0)); _isOpenDialog = !(_flags & FileDialogFlag.ConfirmOverwrite); if (action is null) { if (_isOpenDialog) diff --git a/src/dlangui/widgets/styles.d b/src/dlangui/widgets/styles.d index cdcde587..997e0282 100644 --- a/src/dlangui/widgets/styles.d +++ b/src/dlangui/widgets/styles.d @@ -134,6 +134,8 @@ immutable string STYLE_DOCK_WINDOW = "DOCK_WINDOW"; immutable string STYLE_DOCK_WINDOW_CAPTION_LABEL = "DOCK_WINDOW_CAPTION_LABEL"; /// standard style id for dock window body immutable string STYLE_DOCK_WINDOW_BODY = "DOCK_WINDOW_BODY"; +/// standard style id for toolbar separator +immutable string STYLE_FLOATING_WINDOW = "FLOATING_WINDOW"; /// standard style id for tab control in dock frame immutable string STYLE_TAB_UP_DARK = "TAB_UP_DARK"; diff --git a/views/res/mdpi/popup_window_background.9.png b/views/res/mdpi/popup_window_background.9.png new file mode 100644 index 0000000000000000000000000000000000000000..14d80259cf5c1f6fafbbdf3d21cbea27729eb4dd GIT binary patch literal 556 zcmV+{0@MA8P)} z8$bdyffmq~bie`F0&DG=t4YcM9iRuCN;U;h0CQkg2f(t=fDv#GuM`N=Hk|_mWQMpC2{dWNX69Bshy&(D2SU0~4>KufGLrCDYgSQyZ@l#kUa z`Ua%ZMIBXQuJRuU$h*LT_*@?WSF)xX0XSHIOc%$%1h^1L*SHFk``(J7X>KfNL?##5k#_;>@rw)lIjOyI2f-$q&TN_xUgtJ&05Fu7MS>kSx?$j|$CCq*B|7 zN%Bp>ZGokl+>2(y$^vZk$Ge7w6N@kgv5NPkR+ +