resize mconfdialog

This commit is contained in:
ruki
2020-05-05 23:48:32 +08:00
parent cafdf174d7
commit 868fc3e4d5
2 changed files with 40 additions and 11 deletions

View File

@@ -55,6 +55,10 @@ Pressing <Y> includes, <N> excludes. Enter <Esc> or <Back> to go back, <?> for H
-- insert menu config
self:box():panel():insert(self:menuconf())
self:box():panel():action_add(action.ac_on_resized, function (v)
local bounds = self:box():panel():bounds()
self:menuconf():bounds_set(rect:new(0, 0, bounds:width(), bounds:height()))
end)
-- disable to select to box (disable Tab switch and only response to buttons)
self:box():option_set("selectable", false)
@@ -305,5 +309,15 @@ function mconfdialog:on_event(e)
return boxdialog.on_event(self, e)
end
-- on resize
function mconfdialog:on_resize()
self:helpdialog():bounds_set(self:bounds())
self:resultdialog():bounds_set(self:bounds())
self:inputdialog():bounds_set(rect{0, 0, math.min(80, self:width() - 8), math.min(8, self:height())})
self:choicedialog():bounds_set(rect{0, 0, math.min(80, self:width() - 8), math.min(20, self:height())})
self:searchdialog():bounds_set(rect{0, 0, math.min(80, self:width() - 8), math.min(8, self:height())})
boxdialog.on_resize(self)
end
-- return module
return mconfdialog

View File

@@ -72,14 +72,29 @@ function demo:init()
table.insert(configs, menuconf.choice {value = 3, values = {1, 5, 6, 7}, description = "choice config item"})
-- init menu config dialog
local mconfdialog = mconfdialog:new("mconfdialog.main", rect {1, 1, self:width() - 1, self:height() - 1}, "menu config")
mconfdialog:load(configs)
mconfdialog:action_set(action.ac_on_exit, function (v) self:quit() end)
mconfdialog:action_set(action.ac_on_save, function (v)
self:dialog_mconf():load(configs)
self:insert(self:dialog_mconf())
end
-- get mconfdialog
function demo:dialog_mconf()
local dialog_mconf = self._DIALOG_MCONF
if not dialog_mconf then
dialog_mconf = mconfdialog:new("mconfdialog.main", rect{1, 1, self:width() - 1, self:height() - 1}, "menu config")
dialog_mconf:action_set(action.ac_on_exit, function (v) self:quit() end)
dialog_mconf:action_set(action.ac_on_save, function (v)
-- TODO save configs
mconfdialog:quit()
dialog_mconf:quit()
end)
self:insert(mconfdialog)
self._DIALOG_MCONF = dialog_mconf
end
return dialog_mconf
end
-- on resize
function demo:on_resize()
self:dialog_mconf():bounds_set(rect{1, 1, self:width() - 1, self:height() - 1})
application.on_resize(self)
end
-- run demo