diff options
| author | ruki <[email protected]> | 2018-01-24 22:35:22 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2018-01-24 09:32:13 +0800 |
| commit | 630c94df8a7b3b51a35c166c6a310a97c754989b (patch) | |
| tree | 3fcc820a6ce2f958b48768dfc893da73ea4d2ed6 | |
| parent | 4a4240f062d9c74e22d3a92761dd26def077502d (diff) | |
add some other configs in menuconf
| -rw-r--r-- | tests/ui/mconfdialog.lua | 10 | ||||
| -rw-r--r-- | xmake/core/ui/menuconf.lua | 28 |
2 files changed, 28 insertions, 10 deletions
diff --git a/tests/ui/mconfdialog.lua b/tests/ui/mconfdialog.lua index d0b5bf75b..a9f1e71b8 100644 --- a/tests/ui/mconfdialog.lua +++ b/tests/ui/mconfdialog.lua @@ -47,7 +47,15 @@ function demo:init() -- init menu config dialog local mconfdialog = mconfdialog:new("mconfdialog.main", rect {1, 1, self:width() - 1, self:height() - 1}, "menu config") mconfdialog:action_set(action.ac_on_exit, function (v) self:quit() end) - mconfdialog:action_set(action.ac_on_load, function (v) log:print("load") end) + mconfdialog:action_set(action.ac_on_load, function (v) + local menuconf = v:menuconf() + menuconf:insert({default = false, description = "boolean config item"}) + menuconf:insert({default = true, new = true, description = {"boolean config item2", "more"}}) + menuconf:insert({kind = "number", value = 6, default = 10, description = "number config item"}) + menuconf:insert({value = "x86_64", description = "string config item"}) + menuconf:insert({kind = "menu", description = "menu config item"}) + menuconf:insert({kind = "choice", value = 3, values = {1, 5, 6, 7}, description = "choice config item"}) + end) mconfdialog:action_set(action.ac_on_save, function (v) log:print("save") end) self:insert(mconfdialog) end diff --git a/xmake/core/ui/menuconf.lua b/xmake/core/ui/menuconf.lua index 870e7a4fb..3e7e53af3 100644 --- a/xmake/core/ui/menuconf.lua +++ b/xmake/core/ui/menuconf.lua @@ -39,27 +39,31 @@ function menuconf:init(name, bounds) -- init panel panel.init(self, name, bounds) - - self:insert({default = false, description = "boolean config item"}) - self:insert({default = true, new = true, description = {"boolean config item2", "more"}}) - self:insert({kind = "number", value = 6, default = 10, description = "number config item"}) end -- insert a config item -- -- kind --- - {kind = "number/boolean/choice/menu"} +-- - {kind = "number/boolean/string/choice/menu"} -- -- description -- - {description = "config item description"} -- - {description = {"config item description", "line2", "line3", "more description ..."}} -- --- bool config --- - {kind = "boolean", value = true, default = true, description = "bool config item", new = true/false} +-- boolean config +-- - {name = "...", kind = "boolean", value = true, default = true, description = "boolean config item", new = true/false} +-- +-- number config +-- - {name = "...", kind = "number", value = 10, default = 0, description = "number config item", new = true/false} +-- +-- string config +-- - {name = "...", kind = "string", value = "xmake", default = "", description = "string config item", new = true/false} -- --- int config --- - {kind = "number", value = 10, default = 0, description = "int config item", new = true/false} +-- choice config +-- - {name = "...", kind = "choice", value = "...", default = "...", description = "choice config item", values = {1, 2, 3, 4, 5}} -- +-- menu config +-- - {name = "...", kind = "menu", description = "menu config item", configs = {...}} -- function menuconf:insert(config) @@ -93,6 +97,12 @@ function menuconf:_text(config) text = (value and "[*] " or "[ ] ") .. text elseif config.kind == "number" or (not config.kind and type(value) == "number") then -- number config? text = "(" .. tostring(value or 0) .. ") " .. text + elseif config.kind == "string" or (not config.kind and type(value) == "string") then -- string config? + text = "(" .. tostring(value or "") .. ") " .. text + elseif config.kind == "choice" then -- choice config? + text = " " .. text .. " (" .. tostring(value or "") .. ")" .. " --->" + elseif config.kind == "menu" then -- menu config? + text = " " .. text .. " --->" end -- new config? |
