1
0
Fork 0

canvas.gui: Tweak size hints and MessageBox size.

This commit is contained in:
Thomas Geymayer 2014-06-19 01:14:38 +02:00
parent e091ff9c40
commit 351f67952c
2 changed files with 17 additions and 13 deletions

View file

@ -45,8 +45,8 @@ var MessageBox = {
return me;
}
var MARGIN = 8; # TODO implement margin in C++ layouting code
var dlg = canvas.Window.new([250,120], "dialog")
var MARGIN = 12; # TODO implement margin in C++ layouting code
var dlg = canvas.Window.new([300,120], "dialog")
.setTitle(me._title);
var root = dlg.getCanvas(1)
.set("background", style.getColor("bg_color"))
@ -57,6 +57,7 @@ var MessageBox = {
var text_box = HBoxLayout.new();
vbox.addItem(text_box);
text_box.setSpacing(MARGIN);
text_box.addSpacing(MARGIN);
@ -116,6 +117,9 @@ var MessageBox = {
vbox.addSpacing(MARGIN);
var w = vbox.sizeHint()[0];
dlg.setSize(w, math.max(130, vbox.heightForWidth(w)));
return me;
},
show: func(title, text, icon = nil, cb = nil, buttons = nil)

View file

@ -51,9 +51,9 @@ DefaultStyle.widgets.button = {
{
me._label.set("text", text);
# TODO get real font metrics
model.setMinimumSize([size(text) * 5 + 6, 16]);
model.setSizeHint([size(text) * 8 + 16, 32]);
var min_width = math.max(80, me._label.maxWidth() + 16);
model.setMinimumSize([min_width, 16]);
model.setSizeHint([min_width, 28]);
return me;
},
@ -123,8 +123,8 @@ DefaultStyle.widgets.checkbox = {
},
setSize: func(model, w, h)
{
me._icon.setTranslation(0, (h - 18) / 2);
me._label.setTranslation(20, h / 2);
me._icon.setTranslation(0, int((h - 18) / 2));
me._label.setTranslation(24, int(h / 2) + 1);
return me;
},
@ -132,9 +132,9 @@ DefaultStyle.widgets.checkbox = {
{
me._label.set("text", text);
var text_width = me._label.maxWidth();
model.setMinimumSize([text_width + 20, 18]);
model.setSizeHint([text_width + 26, 24]);
var min_width = me._label.maxWidth() + 24;
model.setMinimumSize([min_width, 18]);
model.setSizeHint([min_width, 24]);
return me;
},
@ -213,9 +213,9 @@ DefaultStyle.widgets.label = {
}
else
{
# TODO get real font metrics
model.setMinimumSize([size(text) * 5 + 4, 14]);
model.setSizeHint([size(text) * 5 + 14, 24]);
var min_width = me._text.maxWidth() + 4;
model.setMinimumSize([min_width, 14]);
model.setSizeHint([min_width, 24]);
}
return me;