@ -100,7 +100,7 @@ function MenuCloseButton:init()
-- diagonally aligned with the top right corner (assuming padding_right=0,
-- or padding_right = padding_top so the diagonal aligment is preserved).
local text_size = text_widget : getSize ( )
local text_width_pad = ( text_size.h - text_size.w ) / 2
local text_width_pad = math.floor ( ( text_size.h - text_size.w ) / 2 )
self [ 1 ] = FrameContainer : new {
bordersize = 0 ,
@ -216,7 +216,7 @@ function MenuItem:init()
}
local state_indent = self.state and self.state . indent or " "
local state_container = LeftContainer : new {
dimen = Geom : new { w = self.content_width/ 2 , h = self.dimen . h } ,
dimen = Geom : new { w = math.floor( self.content_width / 2 ) , h = self.dimen . h } ,
HorizontalGroup : new {
TextWidget : new {
text = state_indent ,
@ -457,8 +457,8 @@ end
function MenuItem : getGesPosition ( ges )
local dimen = self [ 1 ] . dimen
return {
x = ( ges.pos . x - dimen.x ) / dimen.w ,
y = ( ges.pos . y - dimen.y ) / dimen.h ,
x = math.floor ( ( ges.pos . x - dimen.x ) / dimen.w ) ,
y = math.floor ( ( ges.pos . y - dimen.y ) / dimen.h ) ,
}
end
@ -590,8 +590,12 @@ function Menu:_recalculateDimen()
if self.dimen . h > Screen : getHeight ( ) or self.dimen . h == nil then
self.dimen . h = Screen : getHeight ( )
end
self.inner_dimen = Geom : new {
w = self.dimen . w - 2 * self.border_size ,
h = self.dimen . h - 2 * self.border_size ,
}
self.item_dimen = Geom : new {
w = self.dimen . w ,
w = self. inner_ dimen. w ,
h = Screen : scaleBySize ( 46 ) ,
}
local height_dim
@ -602,9 +606,9 @@ function Menu:_recalculateDimen()
+ 2 * Size.padding . button
end
if self.menu_title and not self.no_title then
top_height = self.menu_title_group : getSize ( ) . h + 2 * Size.padding . small
top_height = self.menu_title_group : getSize ( ) . h + self.header_padding
end
height_dim = self. dimen. h - bottom_height - top_height
height_dim = self. inner_ dimen. h - bottom_height - top_height
self.item_dimen . h = math.floor ( height_dim / self.perpage )
self.span_width = math.floor ( ( height_dim - ( self.perpage * ( self.item_dimen . h ) ) ) / 2 - 1 )
self.page_num = math.ceil ( # self.item_table / self.perpage )
@ -620,6 +624,13 @@ function Menu:init()
if self.dimen . h > Screen : getHeight ( ) or self.dimen . h == nil then
self.dimen . h = Screen : getHeight ( )
end
self.border_size = self.is_borderless and 0 or Size.border . window
self.inner_dimen = Geom : new {
w = self.dimen . w - 2 * self.border_size ,
h = self.dimen . h - 2 * self.border_size ,
}
self.page = 1
self.paths = { } -- per instance table to trace navigation path
@ -634,7 +645,7 @@ function Menu:init()
}
local menu_title_container = CenterContainer : new {
dimen = Geom : new {
w = self. dimen. w ,
w = self. inner_ dimen. w ,
h = self.menu_title : getSize ( ) . h ,
} ,
self.menu_title ,
@ -645,12 +656,12 @@ function Menu:init()
self.path_text = TextWidget : new {
face = Font : getFace ( " xx_smallinfofont " ) ,
text = BD.directory ( self.path ) ,
max_width = self. dimen. w - 2 * Size.padding . small ,
max_width = self. inner_ dimen. w - 2 * Size.padding . small ,
truncate_left = true ,
}
path_text_container = CenterContainer : new {
dimen = Geom : new {
w = self. dimen. w ,
w = self. inner_ dimen. w ,
h = self.path_text : getSize ( ) . h ,
} ,
self.path_text ,
@ -668,7 +679,7 @@ function Menu:init()
end
-- group for title bar
self.title_bar = OverlapGroup : new {
dimen = { w = self. dimen. w , h = self.menu_title_group : getSize ( ) . h } ,
dimen = { w = self. inner_ dimen. w , h = self.menu_title_group : getSize ( ) . h } ,
self.menu_title_group ,
}
-- group for items
@ -776,6 +787,7 @@ function Menu:init()
hint_func = hint_func ,
buttons = buttons ,
} ,
call_hold_input_on_tap = true ,
bordersize = 0 ,
text_font_face = " cfont " ,
text_font_size = 20 ,
@ -785,7 +797,9 @@ function Menu:init()
self.page_info_first_chev ,
self.page_info_spacer ,
self.page_info_left_chev ,
self.page_info_spacer ,
self.page_info_text ,
self.page_info_spacer ,
self.page_info_right_chev ,
self.page_info_spacer ,
self.page_info_last_chev ,
@ -815,11 +829,11 @@ function Menu:init()
}
local body = self.item_group
local footer = BottomContainer : new {
dimen = self. dimen: copy ( ) ,
dimen = self. inner_ dimen: copy ( ) ,
self.page_info ,
}
local page_return = BottomContainer : new {
dimen = self. dimen: copy ( ) ,
dimen = self. inner_ dimen: copy ( ) ,
WidgetContainer : new {
dimen = Geom : new {
w = Screen : getWidth ( ) ,
@ -852,7 +866,7 @@ function Menu:init()
-- to have this complex Menu, and all widgets based on it,
-- be mirrored correctly with RTL languages
allow_mirroring = false ,
dimen = self. dimen: copy ( ) ,
dimen = self. inner_ dimen: copy ( ) ,
self.content_group ,
page_return ,
footer ,
@ -860,7 +874,7 @@ function Menu:init()
self [ 1 ] = FrameContainer : new {
background = Blitbuffer.COLOR_WHITE ,
bordersize = self. is_borderless and 0 or Size.border . window ,
bordersize = self. border_size ,
padding = 0 ,
margin = 0 ,
radius = self.is_popout and math.floor ( self.dimen . w / 20 ) or 0 ,
@ -967,16 +981,16 @@ function Menu:updatePageInfo(select_number)
self.selected = { x = 1 , y = select_number }
end
-- update page information
if self.page_num > 1 then
self.page_info_text : setText ( FFIUtil.template ( _ ( " Page %1 of %2 " ) , self.page , self.page_num ) )
if self.page_num > 1 then
self.page_info_text : enable ( )
else
self.page_info_text : setText( " " ) ;
self.page_info_text : disableWithoutDimming( )
end
self.page_info_left_chev : show Hide ( self.page_num > 1 )
self.page_info_right_chev : show Hide ( self.page_num > 1 )
self.page_info_first_chev : show Hide ( self.page_num > 2 )
self.page_info_last_chev : show Hide ( self.page_num > 2 )
self.page_info_left_chev : show ( )
self.page_info_right_chev : show ( )
self.page_info_first_chev : show ( )
self.page_info_last_chev : show ( )
self.page_return_arrow : showHide ( self.onReturn ~= nil )
self.page_info_left_chev : enableDisable ( self.page > 1 )
@ -986,7 +1000,7 @@ function Menu:updatePageInfo(select_number)
self.page_return_arrow : enableDisable ( # self.paths > 0 )
else
self.page_info_text : setText ( _ ( " No choices available " ) )
self.page_info_text : disable ( )
self.page_info_text : disable WithoutDimming ( )
end
end
@ -1069,12 +1083,6 @@ function Menu:updateItems(select_number)
local refresh_dimen =
old_dimen and old_dimen : combine ( self.dimen )
or self.dimen
if not self.is_borderless then
refresh_dimen = refresh_dimen : copy ( )
local bordersize = Size.border . window
refresh_dimen.w = refresh_dimen.w + bordersize * 2
refresh_dimen.h = refresh_dimen.h + bordersize * 2
end
return " ui " , refresh_dimen
end )
end