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
|
||||
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));
|
||||
|
||||
// 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]);
|
||||
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);
|
||||
// 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);
|
||||
tabs.addTab(table, "TAB_TABLE_LAYOUT"c);
|
||||
|
|
|
@ -149,7 +149,7 @@
|
|||
fontSize="16"
|
||||
/>
|
||||
<style id="COMBO_BOX"
|
||||
backgroundImageId="editbox_background"
|
||||
backgroundImageId="btn_background"
|
||||
padding="2,2,2,2"
|
||||
margins="2,2,2,2"
|
||||
minWidth="40"
|
||||
|
@ -164,6 +164,12 @@
|
|||
fontFamily="SansSerif"
|
||||
fontSize="16"
|
||||
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"
|
||||
backgroundImageId="editbox_background"
|
||||
|
|
|
@ -80,6 +80,7 @@ class ComboBoxBase : HorizontalLayout, OnClickHandler {
|
|||
|
||||
protected ImageButton createButton() {
|
||||
ImageButton res = new ImageButton("COMBOBOX_BUTTON", "scrollbar_btn_down");
|
||||
res.styleId = "COMBO_BOX_BUTTON";
|
||||
res.layoutWeight = 0;
|
||||
res.onClickListener = this;
|
||||
return res;
|
||||
|
@ -121,6 +122,8 @@ class ComboBoxBase : HorizontalLayout, OnClickHandler {
|
|||
super(ID);
|
||||
_adapter = adapter;
|
||||
_ownAdapter = ownAdapter;
|
||||
styleId = "COMBO_BOX";
|
||||
trackHover = true;
|
||||
init();
|
||||
}
|
||||
|
||||
|
@ -204,8 +207,8 @@ class ComboBox : ComboBoxBase {
|
|||
}
|
||||
|
||||
override protected Widget createSelectedItemWidget() {
|
||||
TextWidget res = new TextWidget("COMBOBOX_BODY");
|
||||
res.styleId = "COMBO_BOX";
|
||||
TextWidget res = new TextWidget("COMBO_BOX_BODY");
|
||||
res.styleId = "COMBO_BOX_BODY";
|
||||
res.clickable = true;
|
||||
res.layoutWidth = FILL_PARENT;
|
||||
res.layoutHeight = WRAP_CONTENT;
|
||||
|
|
|
@ -333,7 +333,7 @@ class Widget {
|
|||
if (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
|
||||
p.offset(FOCUS_RECT_PADDING, FOCUS_RECT_PADDING);
|
||||
}
|
||||
|
@ -599,10 +599,10 @@ class Widget {
|
|||
|
||||
protected bool _focusable;
|
||||
/// 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 bool focused() {
|
||||
@property bool focused() const {
|
||||
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
|
||||
@property Widget parent() { return _parent; }
|
||||
@property Widget parent() const { return cast(Widget)_parent; }
|
||||
/// sets parent for widget
|
||||
@property Widget parent(Widget parent) { _parent = parent; return this; }
|
||||
/// returns window (if widget or its parent is attached to window)
|
||||
@property Window window() {
|
||||
Widget p = this;
|
||||
@property Window window() const {
|
||||
Widget p = cast(Widget)this;
|
||||
while (p !is null) {
|
||||
if (p._window !is null)
|
||||
return p._window;
|
||||
return cast(Window)p._window;
|
||||
p = p.parent;
|
||||
}
|
||||
return null;
|
||||
|
|
Loading…
Reference in New Issue