mirror of https://github.com/buggins/dlangui.git
combo box styles reworked
This commit is contained in:
parent
c815bdbffe
commit
9a8eb66e6b
|
@ -530,11 +530,17 @@ extern (C) int UIAppMain(string[] args) {
|
||||||
// row 3
|
// row 3
|
||||||
table.addChild((new TextWidget(null, "Param 3"d)).alignment(Align.Right | Align.VCenter));
|
table.addChild((new TextWidget(null, "Param 3"d)).alignment(Align.Right | Align.VCenter));
|
||||||
table.addChild((new EditLine("edit3", "Parameter 3 value"d)).layoutWidth(FILL_PARENT));
|
table.addChild((new EditLine("edit3", "Parameter 3 value"d)).layoutWidth(FILL_PARENT));
|
||||||
|
// normal readonly combo box
|
||||||
ComboBox combo1 = new ComboBox("combo1", ["item value 1"d, "item value 2"d, "item value 3"d, "item value 4"d, "item value 5"d, "item value 6"d]);
|
ComboBox combo1 = new ComboBox("combo1", ["item value 1"d, "item value 2"d, "item value 3"d, "item value 4"d, "item value 5"d, "item value 6"d]);
|
||||||
table.addChild((new TextWidget(null, "Combo box param"d)).alignment(Align.Right | Align.VCenter));
|
table.addChild((new TextWidget(null, "Combo box param"d)).alignment(Align.Right | Align.VCenter));
|
||||||
combo1.selectedItemIndex(3);
|
combo1.selectedItemIndex = 3;
|
||||||
table.addChild(combo1).layoutWidth(FILL_PARENT);
|
table.addChild(combo1).layoutWidth(FILL_PARENT);
|
||||||
|
// disabled readonly combo box
|
||||||
|
ComboBox combo2 = new ComboBox("combo2", ["item value 1"d, "item value 2"d, "item value 3"d]);
|
||||||
|
table.addChild((new TextWidget(null, "Disabled combo box"d)).alignment(Align.Right | Align.VCenter));
|
||||||
|
combo2.enabled = false;
|
||||||
|
combo2.selectedItemIndex = 0;
|
||||||
|
table.addChild(combo2).layoutWidth(FILL_PARENT);
|
||||||
|
|
||||||
table.margins(Rect(10,10,10,10)).layoutWidth(FILL_PARENT);
|
table.margins(Rect(10,10,10,10)).layoutWidth(FILL_PARENT);
|
||||||
tabs.addTab(table, "TAB_TABLE_LAYOUT"c);
|
tabs.addTab(table, "TAB_TABLE_LAYOUT"c);
|
||||||
|
|
|
@ -149,7 +149,7 @@
|
||||||
fontSize="16"
|
fontSize="16"
|
||||||
/>
|
/>
|
||||||
<style id="COMBO_BOX"
|
<style id="COMBO_BOX"
|
||||||
backgroundImageId="editbox_background"
|
backgroundImageId="btn_background"
|
||||||
padding="2,2,2,2"
|
padding="2,2,2,2"
|
||||||
margins="2,2,2,2"
|
margins="2,2,2,2"
|
||||||
minWidth="40"
|
minWidth="40"
|
||||||
|
@ -164,6 +164,12 @@
|
||||||
fontFamily="SansSerif"
|
fontFamily="SansSerif"
|
||||||
fontSize="16"
|
fontSize="16"
|
||||||
align="Left|VCenter"
|
align="Left|VCenter"
|
||||||
|
focusRectColors="#000"
|
||||||
|
/>
|
||||||
|
<style id="COMBO_BOX_BUTTON"
|
||||||
|
padding="2,2,2,2"
|
||||||
|
backgroundImageId="btn_background_transparent"
|
||||||
|
align="Center"
|
||||||
/>
|
/>
|
||||||
<style id="EDIT_BOX"
|
<style id="EDIT_BOX"
|
||||||
backgroundImageId="editbox_background"
|
backgroundImageId="editbox_background"
|
||||||
|
|
|
@ -80,6 +80,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.styleId = "COMBO_BOX_BUTTON";
|
||||||
res.layoutWeight = 0;
|
res.layoutWeight = 0;
|
||||||
res.onClickListener = this;
|
res.onClickListener = this;
|
||||||
return res;
|
return res;
|
||||||
|
@ -121,6 +122,8 @@ class ComboBoxBase : HorizontalLayout, OnClickHandler {
|
||||||
super(ID);
|
super(ID);
|
||||||
_adapter = adapter;
|
_adapter = adapter;
|
||||||
_ownAdapter = ownAdapter;
|
_ownAdapter = ownAdapter;
|
||||||
|
styleId = "COMBO_BOX";
|
||||||
|
trackHover = true;
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -204,8 +207,8 @@ class ComboBox : ComboBoxBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
override protected Widget createSelectedItemWidget() {
|
override protected Widget createSelectedItemWidget() {
|
||||||
TextWidget res = new TextWidget("COMBOBOX_BODY");
|
TextWidget res = new TextWidget("COMBO_BOX_BODY");
|
||||||
res.styleId = "COMBO_BOX";
|
res.styleId = "COMBO_BOX_BODY";
|
||||||
res.clickable = true;
|
res.clickable = true;
|
||||||
res.layoutWidth = FILL_PARENT;
|
res.layoutWidth = FILL_PARENT;
|
||||||
res.layoutHeight = WRAP_CONTENT;
|
res.layoutHeight = WRAP_CONTENT;
|
||||||
|
|
|
@ -333,7 +333,7 @@ class Widget {
|
||||||
if (p.bottom < dp.bottom)
|
if (p.bottom < dp.bottom)
|
||||||
p.bottom = dp.bottom;
|
p.bottom = dp.bottom;
|
||||||
}
|
}
|
||||||
if (focusable && focusRectColors) {
|
if ((focusable || ((state & State.Parent) && parent.focusable)) && focusRectColors) {
|
||||||
// add two pixels to padding when focus rect is required - one pixel for focus rect, one for additional space
|
// add two pixels to padding when focus rect is required - one pixel for focus rect, one for additional space
|
||||||
p.offset(FOCUS_RECT_PADDING, FOCUS_RECT_PADDING);
|
p.offset(FOCUS_RECT_PADDING, FOCUS_RECT_PADDING);
|
||||||
}
|
}
|
||||||
|
@ -599,10 +599,10 @@ class Widget {
|
||||||
|
|
||||||
protected bool _focusable;
|
protected bool _focusable;
|
||||||
/// whether widget can be focused
|
/// whether widget can be focused
|
||||||
@property bool focusable() { return _focusable; }
|
@property bool focusable() const { return _focusable; }
|
||||||
@property Widget focusable(bool flg) { _focusable = flg; return this; }
|
@property Widget focusable(bool flg) { _focusable = flg; return this; }
|
||||||
|
|
||||||
@property bool focused() {
|
@property bool focused() const {
|
||||||
return (window !is null && window.focusedWidget is this && (state & State.Focused));
|
return (window !is null && window.focusedWidget is this && (state & State.Focused));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1264,15 +1264,15 @@ class Widget {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// returns parent widget, null for top level widget
|
/// returns parent widget, null for top level widget
|
||||||
@property Widget parent() { return _parent; }
|
@property Widget parent() const { return cast(Widget)_parent; }
|
||||||
/// sets parent for widget
|
/// sets parent for widget
|
||||||
@property Widget parent(Widget parent) { _parent = parent; return this; }
|
@property Widget parent(Widget parent) { _parent = parent; return this; }
|
||||||
/// returns window (if widget or its parent is attached to window)
|
/// returns window (if widget or its parent is attached to window)
|
||||||
@property Window window() {
|
@property Window window() const {
|
||||||
Widget p = this;
|
Widget p = cast(Widget)this;
|
||||||
while (p !is null) {
|
while (p !is null) {
|
||||||
if (p._window !is null)
|
if (p._window !is null)
|
||||||
return p._window;
|
return cast(Window)p._window;
|
||||||
p = p.parent;
|
p = p.parent;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
Loading…
Reference in New Issue