Fix for sub-menus on the far-right of the screen

This commit is contained in:
Emmanuel Lepage Vallee 2014-02-02 00:35:50 -05:00
parent b1f3190ae3
commit ffcace786f
2 changed files with 19 additions and 2 deletions

View File

@ -46,8 +46,15 @@ local function set_position(self)
ret={x=parent.x-self.width,y=parent.y+(self.parent_item.y)}
else
ret={x=parent.x+parent.width,y=parent.y+(self.parent_item.y)- (parent.show_filter and parent.item_height or 0)}
--Handle when the menu doesn't fit in the srceen horizontally
if ret.x+self.width > src_geo.x + src_geo.width then
ret.x = src_geo.x + src_geo.width - self.width - parent.width
end
-- Handle when the menu doesn't fit on the screen vertically
if ret.y+self.height > src_geo.height then
ret.y = ret.y - self.height + self.item_height
ret.y = ret.y - self.height + self.item_height
end
end
elseif parent then
@ -80,6 +87,8 @@ local function set_position(self)
end
end
end
--Handle when menu doesn't fit horizontally (if not handled earlier)
if ret.x+self.width > src_geo.x + src_geo.width then
ret.x = ret.x - (ret.x+self.width - (src_geo.x + src_geo.width))
elseif ret.x < 0 then

View File

@ -20,13 +20,21 @@ local capi,module = { mouse = mouse , screen = screen , keygrabber = keygrabber
local function setup_drawable(data)
local internal = data._internal
local get_map,set_map,private_data = internal.get_map,internal.set_map,internal.private_data
get_map.visible = function() return true end --Let the parent handle that
-- An embeded menu can only be visible if the parent is
get_map.visible = function() return data._embeded_parent and data._embeded_parent.visible or false end --Let the parent handle that
set_map.visible = function(v) if data._embeded_parent then data._embeded_parent.visible = v end end
-- Enumate geometry --BUG this is fake, but better than nothing
get_map.width = function() return data._embeded_parent and data._embeded_parent.width end
get_map.y = function() return data._embeded_parent and data._embeded_parent.y end
get_map.x = function() return data._embeded_parent and data._embeded_parent.x end
if not data.layout then
data.layout = layout.vertical
end
internal.layout = data.layout(data)
data.width,data.height = data._internal.layout:fit()
data.margins={left=0,right=0,bottom=0,top=0}
end
local function setup_item(data,item,args)