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;
|
||||
}
|
||||
|
||||
/// 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)
|
||||
Setting objectByPath(string path, bool createIfNotExist = false) {
|
||||
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 {
|
||||
protected SettingsPage _parent;
|
||||
protected ObjectList!SettingsPage _children;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue