move sidebar mode management code to init

from onAboutToShow(). this allows the frames to be calculated correctly
during widget instantiation. otherwise widgets can end up with -1 width
develop
myk002 2022-04-29 12:10:05 -07:00
parent af47434f52
commit e603fee3ce
No known key found for this signature in database
GPG Key ID: 8A39CA0FA0C16E78
1 changed files with 7 additions and 5 deletions

@ -443,11 +443,7 @@ MenuOverlay.ATTRS {
sidebar_mode = DEFAULT_NIL, sidebar_mode = DEFAULT_NIL,
} }
function MenuOverlay:computeFrame(parent_rect) function MenuOverlay:init()
return self.df_layout.menu, gui.inset_frame(self.df_layout.menu, self.frame_inset)
end
function MenuOverlay:onAboutToShow(parent)
if not dfhack.isMapLoaded() then if not dfhack.isMapLoaded() then
-- sidebar menus are only valid when a fort map is loaded -- sidebar menus are only valid when a fort map is loaded
error('A fortress map must be loaded.') error('A fortress map must be loaded.')
@ -471,7 +467,13 @@ function MenuOverlay:onAboutToShow(parent)
enterSidebarMode(self.sidebar_mode) enterSidebarMode(self.sidebar_mode)
end end
end
function MenuOverlay:computeFrame(parent_rect)
return self.df_layout.menu, gui.inset_frame(self.df_layout.menu, self.frame_inset)
end
function MenuOverlay:onAboutToShow(parent)
self:updateLayout() self:updateLayout()
if not self.df_layout.menu then if not self.df_layout.menu then
error("The menu panel of dwarfmode is not visible") error("The menu panel of dwarfmode is not visible")