mirror of https://github.com/buggins/dlangui.git
editline development; fix padding and margins attributes support in styles}
This commit is contained in:
parent
d1a794dcb2
commit
7bce36f40d
|
@ -70,6 +70,7 @@ extern (C) int UIAppMain(string[] args) {
|
|||
|
||||
|
||||
LinearLayout hlayout = new HorizontalLayout();
|
||||
hlayout.layoutWidth(FILL_PARENT);
|
||||
//hlayout.addChild((new Button()).text("<<")); //.textColor(0x40FF4000)
|
||||
hlayout.addChild((new TextWidget()).text("Several").alignment(Align.Center));
|
||||
hlayout.addChild((new ImageWidget()).drawableId("btn_radio").padding(Rect(5,5,5,5)).alignment(Align.Center));
|
||||
|
@ -77,7 +78,7 @@ extern (C) int UIAppMain(string[] args) {
|
|||
hlayout.addChild((new ImageWidget()).drawableId("btn_check").padding(Rect(5,5,5,5)).alignment(Align.Center));
|
||||
hlayout.addChild((new TextWidget()).text("in horizontal layout"));
|
||||
hlayout.addChild((new ImageWidget()).drawableId("exit").padding(Rect(5,5,5,5)).alignment(Align.Center));
|
||||
hlayout.addChild((new EditLine("editline", "Some text to edit"d)));
|
||||
hlayout.addChild((new EditLine("editline", "Some text to edit"d)).alignment(Align.Center).layoutWidth(FILL_PARENT));
|
||||
//hlayout.addChild((new Button()).text(">>")); //.textColor(0x40FF4000)
|
||||
hlayout.backgroundColor = 0x8080C0;
|
||||
layout.addChild(hlayout);
|
||||
|
|
|
@ -158,6 +158,18 @@ class EditLine : Widget {
|
|||
measuredContent(parentWidth, parentHeight, sz.x, sz.y);
|
||||
}
|
||||
|
||||
/// Set widget rectangle to specified value and layout widget contents. (Step 2 of two phase layout).
|
||||
override void layout(Rect rc) {
|
||||
_needLayout = false;
|
||||
if (visibility == Visibility.Gone) {
|
||||
return;
|
||||
}
|
||||
Point sz = Point(rc.width, measuredHeight);
|
||||
applyAlign(rc, sz);
|
||||
_pos = rc;
|
||||
}
|
||||
|
||||
/// draw content
|
||||
override void onDraw(DrawBuf buf) {
|
||||
if (visibility != Visibility.Visible)
|
||||
return;
|
||||
|
@ -169,8 +181,8 @@ class EditLine : Widget {
|
|||
FontRef font = font();
|
||||
dstring txt = text;
|
||||
Point sz = font.textSize(txt);
|
||||
applyAlign(rc, sz);
|
||||
font.drawText(buf, rc.left, rc.top, txt, textColor);
|
||||
//applyAlign(rc, sz);
|
||||
font.drawText(buf, rc.left, rc.top + sz.y / 10, txt, textColor);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -240,14 +240,14 @@ class Style {
|
|||
|
||||
/// padding
|
||||
@property ref const(Rect) padding() const {
|
||||
if (_stateValue != 0)
|
||||
if (_stateValue != State.Enabled)
|
||||
return parentStyle._padding;
|
||||
return _padding;
|
||||
}
|
||||
|
||||
/// margins
|
||||
@property ref const(Rect) margins() const {
|
||||
if (_stateValue != 0)
|
||||
if (_stateValue != State.Enabled)
|
||||
return parentStyle._margins;
|
||||
return _margins;
|
||||
}
|
||||
|
@ -713,7 +713,7 @@ Theme createDefaultTheme() {
|
|||
//listItem.createState(State.Selected, State.Selected).backgroundColor(0xC04040FF).textColor(0x000000);
|
||||
//listItem.createState(State.Enabled, 0).textColor(0x80000000); // half transparent text for disabled item
|
||||
|
||||
Style editLine = res.createSubstyle("EDIT_LINE").backgroundImageId("editbox_background").padding(Rect(4,2,4,2));
|
||||
Style editLine = res.createSubstyle("EDIT_LINE").backgroundImageId("editbox_background").padding(Rect(5,6,5,6)).margins(Rect(2,2,2,2)).minWidth(40);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
|
|
@ -167,10 +167,12 @@ class Widget {
|
|||
}
|
||||
/// override to handle focus changes
|
||||
protected void handleFocusChange(bool focused) {
|
||||
invalidate();
|
||||
onFocusChangeListener(this, checked);
|
||||
}
|
||||
/// override to handle check changes
|
||||
protected void handleCheckChange(bool checked) {
|
||||
invalidate();
|
||||
onCheckChangeListener(this, checked);
|
||||
}
|
||||
/// set new widget state (set of flags from State enum)
|
||||
|
@ -419,6 +421,7 @@ class Widget {
|
|||
return null;
|
||||
if (!visible)
|
||||
return window.focusedWidget;
|
||||
invalidate();
|
||||
if (!canFocus) {
|
||||
Widget w = findFocusableChild(true);
|
||||
if (!w)
|
||||
|
@ -482,7 +485,7 @@ class Widget {
|
|||
if (canClick) {
|
||||
if (event.action == MouseAction.ButtonDown && event.button == MouseButton.Left) {
|
||||
setState(State.Pressed);
|
||||
if (focusable)
|
||||
if (canFocus)
|
||||
setFocus();
|
||||
return true;
|
||||
}
|
||||
|
@ -501,8 +504,9 @@ class Widget {
|
|||
return true;
|
||||
}
|
||||
}
|
||||
if (focusable && event.action == MouseAction.ButtonDown && event.button == MouseButton.Left) {
|
||||
if (canFocus && event.action == MouseAction.ButtonDown && event.button == MouseButton.Left) {
|
||||
setFocus();
|
||||
return true;
|
||||
}
|
||||
if (trackHover) {
|
||||
if (event.action == MouseAction.FocusOut || event.action == MouseAction.Cancel) {
|
||||
|
|
Loading…
Reference in New Issue