add frames around menu panels

develop
myk002 2022-11-06 16:42:13 -08:00
parent 6e005d4a8d
commit ae2d9008ef
No known key found for this signature in database
GPG Key ID: 8A39CA0FA0C16E78
1 changed files with 36 additions and 19 deletions

@ -48,8 +48,8 @@ OVERLAY_WIDGETS = {menu=HotspotMenuWidget}
-- ---------- -- -- ---------- --
local ARROW = string.char(26) local ARROW = string.char(26)
local MENU_WIDTH = 40 local MENU_WIDTH = 42
local MENU_HEIGHT = 10 local MENU_HEIGHT = 12
MenuScreen = defclass(MenuScreen, gui.Screen) MenuScreen = defclass(MenuScreen, gui.Screen)
MenuScreen.ATTRS{ MenuScreen.ATTRS{
@ -84,31 +84,45 @@ function MenuScreen:init()
end end
self:addviews{ self:addviews{
widgets.ResizingPanel{
autoarrange_subviews=true,
frame=list_frame,
frame_style=gui.GREY_LINE_FRAME,
frame_background=gui.CLEAR_PEN,
subviews={
widgets.List{ widgets.List{
view_id='list', view_id='list',
frame=list_frame,
choices=choices, choices=choices,
icon_width=2, icon_width=2,
on_select=self:callback('onSelect'), on_select=self:callback('onSelect'),
on_submit=self:callback('onSubmit'), on_submit=self:callback('onSubmit'),
on_submit2=self:callback('onSubmit2'), on_submit2=self:callback('onSubmit2'),
}, },
},
},
widgets.ResizingPanel{
view_id='help_panel',
autoarrange_subviews=true,
frame=help_frame,
frame_style=gui.GREY_LINE_FRAME,
frame_background=gui.CLEAR_PEN,
subviews={
widgets.WrappedLabel{ widgets.WrappedLabel{
view_id='help', view_id='help',
frame=help_frame,
text_to_wrap='', text_to_wrap='',
scroll_keys={}, scroll_keys={},
}, },
},
},
} }
end end
function MenuScreen:onSelect(_, choice) function MenuScreen:onSelect(_, choice)
if not choice then return end if not choice or #self.subviews == 0 then return end
local help = self.subviews.help
local first_word = choice.command:trim():split(' +')[1] local first_word = choice.command:trim():split(' +')[1]
if not help or #first_word == 0 then return end self.subviews.help.text_to_wrap = helpdb.is_entry(first_word) and
help.text_to_wrap = helpdb.get_entry_short_help(first_word) helpdb.get_entry_short_help(first_word) or 'Command not found'
help:updateLayout() self.subviews.help_panel:updateLayout()
end end
function MenuScreen:onSubmit(_, choice) function MenuScreen:onSubmit(_, choice)
@ -129,8 +143,11 @@ function MenuScreen:onInput(keys)
return self:inputToSubviews(keys) return self:inputToSubviews(keys)
end end
function MenuScreen:onRenderBody(dc) function MenuScreen:onRenderFrame(dc, rect)
self:renderParent() self:renderParent()
end
function MenuScreen:onRenderBody(dc)
local list = self.subviews.list local list = self.subviews.list
local idx = list:getIdxUnderMouse() local idx = list:getIdxUnderMouse()
if idx and idx ~= self.last_mouse_idx then if idx and idx ~= self.last_mouse_idx then