mirror of https://github.com/buggins/dlangui.git
settings dialog, part 1
This commit is contained in:
parent
964e05bc00
commit
192d3474dc
|
@ -1,7 +1,7 @@
|
|||
Dlang UI
|
||||
========
|
||||
|
||||
Cross platform GUI for D. Layouts, styles, themes, unicode, i18n, OpenGL based acceleration, widget set.
|
||||
Cross platform GUI for D. Widgets, layouts, styles, themes, unicode, i18n, OpenGL based acceleration.
|
||||
|
||||
GitHub page: [https://github.com/buggins/dlangui](https://github.com/buggins/dlangui)
|
||||
|
||||
|
@ -254,11 +254,11 @@ DlangIDE project
|
|||
|
||||
It is a project to build D language IDE using DlangUI library.
|
||||
|
||||
Now it's in early alpha stage, and could be used as a demo for DlangUI.
|
||||
|
||||
But it already can open DUB based projects, edit, build and run them.
|
||||
|
||||
There is simple syntax highlight.
|
||||
Simple syntax highlight.
|
||||
|
||||
DCD integration: go to definition and autocompletion for D source code.
|
||||
|
||||
Project page: [https://github.com/buggins/dlangide](https://github.com/buggins/dlangide)
|
||||
|
||||
|
|
|
@ -365,6 +365,7 @@
|
|||
<File path="src\dlangui\dialogs\dialog.d" />
|
||||
<File path="src\dlangui\dialogs\filedlg.d" />
|
||||
<File path="src\dlangui\dialogs\msgbox.d" />
|
||||
<File path="src\dlangui\dialogs\settingsdialog.d" />
|
||||
</Folder>
|
||||
<Folder name="graphics">
|
||||
<File path="src\dlangui\graphics\colors.d" />
|
||||
|
|
|
@ -1,53 +1,55 @@
|
|||
// Written in the D programming language.
|
||||
|
||||
/**
|
||||
Definition of standard actions commonly used in dialogs and controls.
|
||||
|
||||
Synopsis:
|
||||
|
||||
----
|
||||
import dlangui.core.stdaction;
|
||||
|
||||
----
|
||||
|
||||
Copyright: Vadim Lopatin, 2014
|
||||
License: Boost License 1.0
|
||||
Authors: Vadim Lopatin, coolreader.org@gmail.com
|
||||
*/
|
||||
// Written in the D programming language.
|
||||
|
||||
/**
|
||||
Definition of standard actions commonly used in dialogs and controls.
|
||||
|
||||
Synopsis:
|
||||
|
||||
----
|
||||
import dlangui.core.stdaction;
|
||||
|
||||
----
|
||||
|
||||
Copyright: Vadim Lopatin, 2014
|
||||
License: Boost License 1.0
|
||||
Authors: Vadim Lopatin, coolreader.org@gmail.com
|
||||
*/
|
||||
module dlangui.core.stdaction;
|
||||
|
||||
public import dlangui.core.events;
|
||||
|
||||
/// standard (commonly used) action codes
|
||||
enum StandardAction : int {
|
||||
Ok = 1,
|
||||
Cancel,
|
||||
Yes,
|
||||
No,
|
||||
Close,
|
||||
Abort,
|
||||
Retry,
|
||||
Ignore,
|
||||
Open,
|
||||
Save,
|
||||
SaveAll,
|
||||
DiscardChanges,
|
||||
DiscardAll,
|
||||
OpenUrl,
|
||||
}
|
||||
|
||||
const Action ACTION_OK = new Action(StandardAction.Ok, "ACTION_OK"c, "dialog-ok");
|
||||
const Action ACTION_CANCEL = new Action(StandardAction.Cancel, "ACTION_CANCEL"c, "dialog-cancel");
|
||||
const Action ACTION_YES = new Action(StandardAction.Yes, "ACTION_YES"c, "dialog-ok");
|
||||
const Action ACTION_NO = new Action(StandardAction.No, "ACTION_NO"c, "dialog-cancel");
|
||||
const Action ACTION_CLOSE = new Action(StandardAction.Close, "ACTION_CLOSE"c, "dialog-close");
|
||||
const Action ACTION_ABORT = new Action(StandardAction.Abort, "ACTION_ABORT"c);
|
||||
const Action ACTION_RETRY = new Action(StandardAction.Retry, "ACTION_RETRY"c);
|
||||
const Action ACTION_IGNORE = new Action(StandardAction.Ignore, "ACTION_IGNORE"c);
|
||||
const Action ACTION_OPEN = new Action(StandardAction.Open, "ACTION_OPEN"c);
|
||||
const Action ACTION_SAVE = new Action(StandardAction.Save, "ACTION_SAVE"c);
|
||||
const Action ACTION_SAVE_ALL = new Action(StandardAction.SaveAll, "ACTION_SAVE_ALL"c);
|
||||
const Action ACTION_DISCARD_CHANGES = new Action(StandardAction.DiscardChanges, "ACTION_DISCARD_CHANGES"c);
|
||||
const Action ACTION_DISCARD_ALL = new Action(StandardAction.DiscardAll, "ACTION_DISCARD_ALL"c);
|
||||
const Action ACTION_OPEN_URL = (new Action(StandardAction.OpenUrl)).iconId("applications-internet");
|
||||
|
||||
public import dlangui.core.events;
|
||||
|
||||
/// standard (commonly used) action codes
|
||||
enum StandardAction : int {
|
||||
Ok = 1,
|
||||
Cancel,
|
||||
Yes,
|
||||
No,
|
||||
Close,
|
||||
Abort,
|
||||
Retry,
|
||||
Ignore,
|
||||
Open,
|
||||
Save,
|
||||
SaveAll,
|
||||
DiscardChanges,
|
||||
DiscardAll,
|
||||
OpenUrl,
|
||||
Apply,
|
||||
}
|
||||
|
||||
const Action ACTION_OK = new Action(StandardAction.Ok, "ACTION_OK"c, "dialog-ok");
|
||||
const Action ACTION_CANCEL = new Action(StandardAction.Cancel, "ACTION_CANCEL"c, "dialog-cancel");
|
||||
const Action ACTION_APPLY = new Action(StandardAction.Apply, "ACTION_APPLY"c, null);
|
||||
const Action ACTION_YES = new Action(StandardAction.Yes, "ACTION_YES"c, "dialog-ok");
|
||||
const Action ACTION_NO = new Action(StandardAction.No, "ACTION_NO"c, "dialog-cancel");
|
||||
const Action ACTION_CLOSE = new Action(StandardAction.Close, "ACTION_CLOSE"c, "dialog-close");
|
||||
const Action ACTION_ABORT = new Action(StandardAction.Abort, "ACTION_ABORT"c);
|
||||
const Action ACTION_RETRY = new Action(StandardAction.Retry, "ACTION_RETRY"c);
|
||||
const Action ACTION_IGNORE = new Action(StandardAction.Ignore, "ACTION_IGNORE"c);
|
||||
const Action ACTION_OPEN = new Action(StandardAction.Open, "ACTION_OPEN"c);
|
||||
const Action ACTION_SAVE = new Action(StandardAction.Save, "ACTION_SAVE"c);
|
||||
const Action ACTION_SAVE_ALL = new Action(StandardAction.SaveAll, "ACTION_SAVE_ALL"c);
|
||||
const Action ACTION_DISCARD_CHANGES = new Action(StandardAction.DiscardChanges, "ACTION_DISCARD_CHANGES"c);
|
||||
const Action ACTION_DISCARD_ALL = new Action(StandardAction.DiscardAll, "ACTION_DISCARD_ALL"c);
|
||||
const Action ACTION_OPEN_URL = (new Action(StandardAction.OpenUrl)).iconId("applications-internet");
|
||||
|
||||
|
|
|
@ -316,9 +316,7 @@ class FileDialog : Dialog, CustomGridCellAdapter {
|
|||
override void init() {
|
||||
_roots = getRootPaths;
|
||||
|
||||
layoutWidth(FILL_PARENT);
|
||||
layoutWidth(FILL_PARENT);
|
||||
minWidth = 600;
|
||||
layoutWidth(FILL_PARENT).layoutHeight(FILL_PARENT).minWidth(600);
|
||||
//minHeight = 400;
|
||||
|
||||
LinearLayout content = new HorizontalLayout("dlgcontent");
|
||||
|
|
|
@ -0,0 +1,108 @@
|
|||
module dlangui.dialogs.settingsdialog;
|
||||
|
||||
import dlangui.core.events;
|
||||
import dlangui.core.i18n;
|
||||
import dlangui.core.stdaction;
|
||||
import dlangui.core.files;
|
||||
import dlangui.core.settings;
|
||||
import dlangui.widgets.controls;
|
||||
import dlangui.widgets.lists;
|
||||
import dlangui.widgets.layouts;
|
||||
import dlangui.widgets.tree;
|
||||
import dlangui.widgets.editors;
|
||||
import dlangui.widgets.menu;
|
||||
import dlangui.widgets.combobox;
|
||||
import dlangui.platforms.common.platform;
|
||||
import dlangui.dialogs.dialog;
|
||||
|
||||
private import std.algorithm;
|
||||
private import std.file;
|
||||
private import std.path;
|
||||
private import std.utf;
|
||||
private import std.conv : to;
|
||||
private import std.array : split;
|
||||
|
||||
class SettingsItem {
|
||||
protected string _id;
|
||||
protected UIString _label;
|
||||
protected SettingsPage _page;
|
||||
this(string id, UIString label) {
|
||||
_id = id;
|
||||
_label = label;
|
||||
}
|
||||
/// setting path, e.g. "editor/tabSize"
|
||||
@property string id() { return _id; }
|
||||
@property ref UIString label() { return _label; }
|
||||
}
|
||||
|
||||
class SettingsPage {
|
||||
protected SettingsPage _parent;
|
||||
protected ObjectList!SettingsPage _children;
|
||||
protected ObjectList!SettingsItem _items;
|
||||
protected string _id;
|
||||
protected UIString _label;
|
||||
|
||||
this(string id, UIString label) {
|
||||
_id = id;
|
||||
_label = label;
|
||||
}
|
||||
|
||||
@property string id() { return _id; }
|
||||
@property ref UIString label() { return _label; }
|
||||
|
||||
@property int childCount() {
|
||||
return _children.count;
|
||||
}
|
||||
|
||||
/// returns child page by index
|
||||
SettingsPage child(int index) {
|
||||
return _children[index];
|
||||
}
|
||||
|
||||
void addChild(SettingsPage item) {
|
||||
_children.add(item);
|
||||
item._parent = this;
|
||||
}
|
||||
|
||||
@property int itemCount() {
|
||||
return _items.count;
|
||||
}
|
||||
|
||||
/// returns page item by index
|
||||
SettingsItem item(int index) {
|
||||
return _items[index];
|
||||
}
|
||||
|
||||
void addChild(SettingsItem item) {
|
||||
_items.add(item);
|
||||
item._page = this;
|
||||
}
|
||||
}
|
||||
|
||||
class SettingsDialog : Dialog {
|
||||
protected TreeWidget _tree;
|
||||
protected FrameLayout _frame;
|
||||
protected SettingsFile _settings;
|
||||
|
||||
this(UIString caption, Window parent, SettingsFile settings) {
|
||||
super(caption, parent, DialogFlag.Modal | DialogFlag.Resizable | DialogFlag.Popup);
|
||||
_settings = settings;
|
||||
}
|
||||
|
||||
void onTreeItemSelected(TreeItems source, TreeItem selectedItem, bool activated) {
|
||||
if (!selectedItem)
|
||||
return;
|
||||
}
|
||||
|
||||
/// override to implement creation of dialog controls
|
||||
override void init() {
|
||||
minWidth(600).minHeight(400);
|
||||
_tree = new TreeWidget("prop_tree");
|
||||
_tree.layoutHeight(FILL_PARENT).layoutHeight(FILL_PARENT);
|
||||
_tree.selectionListener = &onTreeItemSelected;
|
||||
_tree.fontSize = 16;
|
||||
_frame = new FrameLayout("prop_pages");
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -335,7 +335,6 @@
|
|||
/>
|
||||
|
||||
<style id="TREE_ITEM"
|
||||
padding="1,1,1,1"
|
||||
minWidth="100"
|
||||
minHeight="14"
|
||||
layoutWidth="FILL_PARENT"
|
||||
|
@ -343,18 +342,15 @@
|
|||
>
|
||||
</style>
|
||||
<style id="TREE_ITEM_EXPAND_ICON"
|
||||
margins="0,0,0,0"
|
||||
align="Left|VCenter"
|
||||
textFlags="Parent"
|
||||
/>
|
||||
<style id="TREE_ITEM_BODY"
|
||||
margins="0,0,0,0"
|
||||
align="Left|VCenter"
|
||||
textFlags="Parent"
|
||||
backgroundImageId="list_item_background"
|
||||
/>
|
||||
<style id="TREE_ITEM_ICON"
|
||||
margins="2,0,2,0"
|
||||
align="Left|VCenter"
|
||||
textFlags="Parent"
|
||||
/>
|
||||
|
|
Loading…
Reference in New Issue