From 4d62cdd35915ff2a4caaeee81c9ab4d64859b533 Mon Sep 17 00:00:00 2001 From: Vadim Lopatin Date: Wed, 4 Mar 2015 10:16:32 +0300 Subject: [PATCH] settings dialog --- src/dlangui/dialogs/settingsdialog.d | 27 ++++++++++++++++++++++----- src/dlangui/widgets/styles.d | 6 ++++++ views/res/theme_default.xml | 19 +++++++++++++++++++ 3 files changed, 47 insertions(+), 5 deletions(-) diff --git a/src/dlangui/dialogs/settingsdialog.d b/src/dlangui/dialogs/settingsdialog.d index 97851dc9..1df5e723 100644 --- a/src/dlangui/dialogs/settingsdialog.d +++ b/src/dlangui/dialogs/settingsdialog.d @@ -12,6 +12,7 @@ import dlangui.widgets.tree; import dlangui.widgets.editors; import dlangui.widgets.menu; import dlangui.widgets.combobox; +import dlangui.widgets.styles; import dlangui.platforms.common.platform; import dlangui.dialogs.dialog; @@ -120,8 +121,20 @@ class SettingsPage { /// create page widget (default implementation creates empty page) Widget createWidget(Setting settings) { - Widget res = new Widget(_id); - res.minWidth(200).minHeight(200); + VerticalLayout res = new VerticalLayout(_id); + res.minWidth(200).minHeight(200).layoutWidth(FILL_PARENT).layoutHeight(FILL_PARENT); + if (itemCount > 0) { + TextWidget caption = new TextWidget("prop-body-caption-" ~ _id, _label); + caption.styleId = STYLE_SETTINGS_PAGE_TITLE; + caption.layoutWidth(FILL_PARENT); + res.addChild(caption); + for (int i = 0; i < itemCount; i++) { + SettingsItem v = item(i); + Widget w = v.createWidget(settings); + if (w) + res.addChild(w); + } + } return res; } @@ -151,6 +164,7 @@ class SettingsDialog : Dialog { void onTreeItemSelected(TreeItems source, TreeItem selectedItem, bool activated) { if (!selectedItem) return; + _frame.showChild(selectedItem.id); } void createControls(SettingsPage page, TreeItem base) { @@ -172,12 +186,13 @@ class SettingsDialog : Dialog { override void init() { minWidth(600).minHeight(400); _tree = new TreeWidget("prop_tree"); - _tree.layoutHeight(FILL_PARENT).layoutHeight(FILL_PARENT); - _tree.minHeight(200).minWidth(100); + _tree.styleId = STYLE_SETTINGS_TREE; + _tree.layoutHeight(FILL_PARENT).layoutHeight(FILL_PARENT).minHeight(200).minWidth(100); _tree.selectionListener = &onTreeItemSelected; _tree.fontSize = 16; _frame = new FrameLayout("prop_pages"); - _frame.minHeight(200).minWidth(100); + _frame.minHeight(200).minWidth(100).layoutHeight(FILL_PARENT).layoutHeight(FILL_PARENT); + _frame.styleId = STYLE_SETTINGS_PAGES; createControls(_layout, _tree.items); HorizontalLayout content = new HorizontalLayout("settings_dlg_content"); content.addChild(_tree); @@ -185,6 +200,8 @@ class SettingsDialog : Dialog { content.layoutHeight(FILL_PARENT).layoutHeight(FILL_PARENT); addChild(content); addChild(createButtonsPanel([ACTION_APPLY, ACTION_CANCEL], 0, 0)); + if (_layout.childCount > 0) + _tree.selectItem(_layout.child(0).id); } } diff --git a/src/dlangui/widgets/styles.d b/src/dlangui/widgets/styles.d index 7cb3f394..199d24c1 100644 --- a/src/dlangui/widgets/styles.d +++ b/src/dlangui/widgets/styles.d @@ -159,6 +159,12 @@ immutable string STYLE_TOOLBAR_CONTROL = "TOOLBAR_CONTROL"; /// standard style id for toolbar separator immutable string STYLE_TOOLBAR_SEPARATOR = "TOOLBAR_SEPARATOR"; +/// standard style id for settings dialog tree +immutable string STYLE_SETTINGS_TREE = "SETTINGS_TREE"; +/// standard style id for settings dialog content pages frame +immutable string STYLE_SETTINGS_PAGES = "SETTINGS_PAGES"; +/// standard style id for settings dialog page title +immutable string STYLE_SETTINGS_PAGE_TITLE = "SETTINGS_PAGE_TITLE"; // Layout size constants /// layout option, to occupy all available place diff --git a/views/res/theme_default.xml b/views/res/theme_default.xml index 79596061..6d4d9db1 100644 --- a/views/res/theme_default.xml +++ b/views/res/theme_default.xml @@ -360,6 +360,25 @@ align="Left|VCenter" textFlags="Parent" /> + +