Canvas GUI: left position for checkbox text
This commit is contained in:
parent
f8375dab68
commit
4fd8092e38
1 changed files with 10 additions and 4 deletions
|
@ -111,6 +111,7 @@ DefaultStyle.widgets.button = {
|
|||
DefaultStyle.widgets.checkbox = {
|
||||
new: func(parent, cfg)
|
||||
{
|
||||
me._label_position = cfg.get("label-position", "right");
|
||||
me._root = parent.createChild("group", "checkbox");
|
||||
me._icon =
|
||||
me._root.createChild("image", "checkbox-icon")
|
||||
|
@ -123,8 +124,13 @@ DefaultStyle.widgets.checkbox = {
|
|||
},
|
||||
setSize: func(model, w, h)
|
||||
{
|
||||
me._icon.setTranslation(0, int((h - 18) / 2));
|
||||
me._label.setTranslation(24, int(h / 2) + 1);
|
||||
if (me._label_position == "left") {
|
||||
me._label.setTranslation(3, int((h / 2) + 1));
|
||||
me._icon.setTranslation(me._label.maxWidth() + 6, int((h - 18) / 2));
|
||||
} else {
|
||||
me._icon.setTranslation(3, int((h - 18) / 2));
|
||||
me._label.setTranslation(24, int(h / 2) + 1);
|
||||
}
|
||||
|
||||
return me;
|
||||
},
|
||||
|
@ -132,7 +138,7 @@ DefaultStyle.widgets.checkbox = {
|
|||
{
|
||||
me._label.setText(text);
|
||||
|
||||
var min_width = me._label.maxWidth() + 24;
|
||||
var min_width = me._label.maxWidth() + 3 + 24;
|
||||
model.setLayoutMinimumSize([min_width, 18]);
|
||||
model.setLayoutSizeHint([min_width, 24]);
|
||||
|
||||
|
@ -721,4 +727,4 @@ DefaultStyle.widgets.slider = {
|
|||
}
|
||||
return me;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue