mirror of https://github.com/buggins/dlangui.git
i18n: fix fallback value; FileDialog: filetype combobox
This commit is contained in:
parent
66f02db2f1
commit
15226e85a4
|
@ -90,7 +90,7 @@ struct UIString {
|
||||||
/** create string with resource id and raw value as fallback for missing translations */
|
/** create string with resource id and raw value as fallback for missing translations */
|
||||||
this(string id, dstring fallbackValue) {
|
this(string id, dstring fallbackValue) {
|
||||||
_id = id;
|
_id = id;
|
||||||
_value = value;
|
_value = fallbackValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -326,7 +326,7 @@ synchronized class UIStringTranslator {
|
||||||
s = _fallback.get(id);
|
s = _fallback.get(id);
|
||||||
if (s !is null)
|
if (s !is null)
|
||||||
return s;
|
return s;
|
||||||
if (fallbackValue !is null)
|
if (fallbackValue.length > 0)
|
||||||
return fallbackValue;
|
return fallbackValue;
|
||||||
return "UNTRANSLATED: "d ~ toUTF32(id);
|
return "UNTRANSLATED: "d ~ toUTF32(id);
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,6 +34,7 @@ import dlangui.widgets.layouts;
|
||||||
import dlangui.widgets.grid;
|
import dlangui.widgets.grid;
|
||||||
import dlangui.widgets.editors;
|
import dlangui.widgets.editors;
|
||||||
import dlangui.widgets.menu;
|
import dlangui.widgets.menu;
|
||||||
|
import dlangui.widgets.combobox;
|
||||||
import dlangui.platforms.common.platform;
|
import dlangui.platforms.common.platform;
|
||||||
import dlangui.dialogs.dialog;
|
import dlangui.dialogs.dialog;
|
||||||
|
|
||||||
|
@ -68,10 +69,20 @@ struct FileFilterEntry {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class HorizontalLayoutTest : HorizontalLayout {
|
||||||
|
this() {
|
||||||
|
}
|
||||||
|
/// Set widget rectangle to specified value and layout widget contents. (Step 2 of two phase layout).
|
||||||
|
override void layout(Rect rc) {
|
||||||
|
super.layout(rc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// File open / save dialog
|
/// File open / save dialog
|
||||||
class FileDialog : Dialog, CustomGridCellAdapter {
|
class FileDialog : Dialog, CustomGridCellAdapter {
|
||||||
protected FilePathPanel _edPath;
|
protected FilePathPanel _edPath;
|
||||||
protected EditLine _edFilename;
|
protected EditLine _edFilename;
|
||||||
|
protected ComboBox _cbFilters;
|
||||||
protected StringGridWidget _fileList;
|
protected StringGridWidget _fileList;
|
||||||
protected VerticalLayout leftPanel;
|
protected VerticalLayout leftPanel;
|
||||||
protected VerticalLayout rightPanel;
|
protected VerticalLayout rightPanel;
|
||||||
|
@ -143,7 +154,7 @@ class FileDialog : Dialog, CustomGridCellAdapter {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected bool reopenDirectory() {
|
protected bool reopenDirectory() {
|
||||||
return true;
|
return openDirectory(_path, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected bool openDirectory(string dir, string selectedItemPath) {
|
protected bool openDirectory(string dir, string selectedItemPath) {
|
||||||
|
@ -330,11 +341,30 @@ class FileDialog : Dialog, CustomGridCellAdapter {
|
||||||
_edPath.layoutWeight = 0;
|
_edPath.layoutWeight = 0;
|
||||||
_edPath.onPathSelectionListener = &onPathSelected;
|
_edPath.onPathSelectionListener = &onPathSelected;
|
||||||
|
|
||||||
|
HorizontalLayout fnlayout = new HorizontalLayoutTest();
|
||||||
|
fnlayout.layoutWidth(FILL_PARENT);
|
||||||
_edFilename = new EditLine("filename");
|
_edFilename = new EditLine("filename");
|
||||||
_edFilename.layoutWidth(FILL_PARENT);
|
_edFilename.layoutWidth(FILL_PARENT);
|
||||||
_edFilename.layoutWeight = 0;
|
//_edFilename.layoutWeight = 0;
|
||||||
|
fnlayout.addChild(_edFilename);
|
||||||
|
if (_filters.length) {
|
||||||
|
dstring[] filterLabels;
|
||||||
|
foreach(f; _filters)
|
||||||
|
filterLabels ~= f.label.value;
|
||||||
|
_cbFilters = new ComboBox("filter", filterLabels);
|
||||||
|
_cbFilters.selectedItemIndex = _filterIndex;
|
||||||
|
_cbFilters.onItemClickListener = delegate(Widget source, int itemIndex) {
|
||||||
|
_filterIndex = itemIndex;
|
||||||
|
reopenDirectory();
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
_cbFilters.layoutWidth(WRAP_CONTENT);
|
||||||
|
_cbFilters.layoutWeight(0);
|
||||||
|
//_cbFilters.backgroundColor = 0xFFC0FF;
|
||||||
|
fnlayout.addChild(_cbFilters);
|
||||||
|
//fnlayout.backgroundColor = 0xFFFFC0;
|
||||||
|
}
|
||||||
|
|
||||||
rightPanel.addChild(_edPath);
|
|
||||||
_fileList = new StringGridWidget("files");
|
_fileList = new StringGridWidget("files");
|
||||||
_fileList.layoutWidth(FILL_PARENT).layoutHeight(FILL_PARENT);
|
_fileList.layoutWidth(FILL_PARENT).layoutHeight(FILL_PARENT);
|
||||||
_fileList.resize(4, 3);
|
_fileList.resize(4, 3);
|
||||||
|
@ -344,8 +374,10 @@ class FileDialog : Dialog, CustomGridCellAdapter {
|
||||||
_fileList.setColTitle(3, "Modified"d);
|
_fileList.setColTitle(3, "Modified"d);
|
||||||
_fileList.showRowHeaders = false;
|
_fileList.showRowHeaders = false;
|
||||||
_fileList.rowSelect = true;
|
_fileList.rowSelect = true;
|
||||||
|
|
||||||
|
rightPanel.addChild(_edPath);
|
||||||
rightPanel.addChild(_fileList);
|
rightPanel.addChild(_fileList);
|
||||||
rightPanel.addChild(_edFilename);
|
rightPanel.addChild(fnlayout);
|
||||||
|
|
||||||
|
|
||||||
addChild(content);
|
addChild(content);
|
||||||
|
|
|
@ -55,8 +55,16 @@ class ComboBoxBase : HorizontalLayout, OnClickHandler {
|
||||||
} else {
|
} else {
|
||||||
res = new Widget("COMBOBOX_BODY");
|
res = new Widget("COMBOBOX_BODY");
|
||||||
}
|
}
|
||||||
res.layoutWidth = FILL_PARENT;
|
res.layoutWidth = WRAP_CONTENT;
|
||||||
res.layoutHeight = WRAP_CONTENT;
|
res.layoutHeight = WRAP_CONTENT;
|
||||||
|
int maxItemWidth = 0;
|
||||||
|
for(int i = 0; i < _adapter.itemCount; i++) {
|
||||||
|
Widget item = _adapter.itemWidget(i);
|
||||||
|
item.measure(SIZE_UNSPECIFIED, SIZE_UNSPECIFIED);
|
||||||
|
if (maxItemWidth < item.measuredWidth)
|
||||||
|
maxItemWidth = item.measuredWidth;
|
||||||
|
}
|
||||||
|
res.minWidth = maxItemWidth;
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,6 +88,7 @@ class ComboBoxBase : HorizontalLayout, OnClickHandler {
|
||||||
|
|
||||||
protected ImageButton createButton() {
|
protected ImageButton createButton() {
|
||||||
ImageButton res = new ImageButton("COMBOBOX_BUTTON", "scrollbar_btn_down");
|
ImageButton res = new ImageButton("COMBOBOX_BUTTON", "scrollbar_btn_down");
|
||||||
|
res.layoutWeight = 0;
|
||||||
res.onClickListener = this;
|
res.onClickListener = this;
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue