1
0
Fork 0

improve dialog layout

This commit is contained in:
mfranz 2008-10-05 16:13:13 +00:00
parent 5d87e8a5d3
commit eab70dccda

View file

@ -93,22 +93,26 @@ var Dialog = {
me.isopen = 0; me.isopen = 0;
}, },
update : func(cmd, title, options) { update : func(cmd, title, options) {
if (!size(cmd))
var (title, r, g, b) = ("Command Mode", 1, 0.7, 0);
elsif (title)
var (r, g, b) = (0.7, 1, 0.7);
else
var (title, r, g, b) = ("<unknown>", 1, 0.4, 0.4);
me.del();
var dlg = gui.Widget.new(); var dlg = gui.Widget.new();
dlg.set("name", me.name); dlg.set("name", me.name);
dlg.set("y", -80); dlg.set("y", -80);
dlg.set("layout", "vbox"); dlg.set("layout", "vbox");
dlg.set("default-padding", 5); dlg.set("default-padding", 2);
# title/description
var t = dlg.addChild("text"); var t = dlg.addChild("text");
t.set("label", title); if (!size(cmd)) {
t.setColor(r, g, b); t.set("label", " Command Mode ");
t.setColor(1, 0.7, 0);
} elsif (title) {
t.set("label", " " ~ title ~ " ");
t.setColor(0.7, 1, 0.7);
} else {
t.set("label", " <unknown> ");
t.setColor(1, 0.4, 0.4);
}
# typed command
var t = dlg.addChild("text"); var t = dlg.addChild("text");
if (me.firstrun) { if (me.firstrun) {
me.firstrun = 0; me.firstrun = 0;
@ -117,7 +121,8 @@ var Dialog = {
} }
t.set("label", cmd); t.set("label", cmd);
if (options != nil and size(options)) { # option menu
if (size(options)) {
dlg.addChild("hrule"); dlg.addChild("hrule");
var g = dlg.addChild("group"); var g = dlg.addChild("group");
g.set("layout", "table"); g.set("layout", "table");
@ -141,6 +146,7 @@ var Dialog = {
c.set("halign", "left"); c.set("halign", "left");
} }
} }
me.del();
fgcommand("dialog-new", dlg.prop()); fgcommand("dialog-new", dlg.prop());
fgcommand("dialog-show", me.prop); fgcommand("dialog-show", me.prop);
me.isopen = 1; me.isopen = 1;