mirror of https://github.com/buggins/dlangui.git
controls
This commit is contained in:
parent
2cceeb94fb
commit
042c675431
|
@ -1059,6 +1059,30 @@ final class Setting {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// returns setting by path like "editors/sourceEditor/tabSize", creates object tree "editors/sourceEditor" and object of specified type if part of path does not exist.
|
||||||
|
Setting settingByPath(string path, SettingType type) {
|
||||||
|
if (type != SettingType.OBJECT)
|
||||||
|
clear(SettingType.OBJECT);
|
||||||
|
string part1, part2;
|
||||||
|
if (splitKey(path, part1, part2)) {
|
||||||
|
auto s = this[part1];
|
||||||
|
if (!s) {
|
||||||
|
s = new Setting();
|
||||||
|
s.clear(SettingType.OBJECT);
|
||||||
|
this[part1] = s;
|
||||||
|
}
|
||||||
|
return s.settingByPath(part2, type);
|
||||||
|
} else {
|
||||||
|
auto s = this[path];
|
||||||
|
if (!s) {
|
||||||
|
s = new Setting();
|
||||||
|
s.clear(type);
|
||||||
|
this[path] = s;
|
||||||
|
}
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// get (or optionally create) object (map) by slash delimited path (e.g. key1/subkey2/subkey3)
|
/// get (or optionally create) object (map) by slash delimited path (e.g. key1/subkey2/subkey3)
|
||||||
Setting objectByPath(string path, bool createIfNotExist = false) {
|
Setting objectByPath(string path, bool createIfNotExist = false) {
|
||||||
if (type != SettingType.OBJECT) {
|
if (type != SettingType.OBJECT) {
|
||||||
|
|
|
@ -40,6 +40,20 @@ class SettingsItem {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// items shows checkbox
|
||||||
|
class CheckboxItem : SettingsItem {
|
||||||
|
this(string id, UIString label) {
|
||||||
|
super(id, label);
|
||||||
|
}
|
||||||
|
/// create setting widget
|
||||||
|
override Widget createWidget(Setting settings) {
|
||||||
|
CheckBox res = new CheckBox(_id, _label);
|
||||||
|
Setting setting = settings.settingByPath(_id, SettingType.FALSE);
|
||||||
|
res.checked = setting.boolean;
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class SettingsPage {
|
class SettingsPage {
|
||||||
protected SettingsPage _parent;
|
protected SettingsPage _parent;
|
||||||
protected ObjectList!SettingsPage _children;
|
protected ObjectList!SettingsPage _children;
|
||||||
|
|
|
@ -313,6 +313,9 @@ class CheckBox : ImageTextButton {
|
||||||
this(string ID, dstring labelText) {
|
this(string ID, dstring labelText) {
|
||||||
super(ID, "btn_check", labelText);
|
super(ID, "btn_check", labelText);
|
||||||
}
|
}
|
||||||
|
this(string ID, UIString label) {
|
||||||
|
super(ID, "btn_check", label);
|
||||||
|
}
|
||||||
override protected void init(string drawableId, UIString caption) {
|
override protected void init(string drawableId, UIString caption) {
|
||||||
super.init(drawableId, caption);
|
super.init(drawableId, caption);
|
||||||
styleId = STYLE_CHECKBOX;
|
styleId = STYLE_CHECKBOX;
|
||||||
|
|
Loading…
Reference in New Issue