From 427da958cb859388d93594ee17a30babe5e0c497 Mon Sep 17 00:00:00 2001 From: chrox Date: Thu, 5 Jun 2014 12:58:57 +0800 Subject: [PATCH] adapt touch menu for small screen --- frontend/ui/widget/touchmenu.lua | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/frontend/ui/widget/touchmenu.lua b/frontend/ui/widget/touchmenu.lua index ebcf6b5cc..dd562d0fc 100644 --- a/frontend/ui/widget/touchmenu.lua +++ b/frontend/ui/widget/touchmenu.lua @@ -16,6 +16,7 @@ local IconButton = require("ui/widget/iconbutton") local UIManager = require("ui/uimanager") local Screen = require("ui/screen") local Geom = require("ui/geometry") +local DEBUG = require("dbg") local _ = require("gettext") --[[ @@ -84,7 +85,6 @@ end TouchMenuBar widget --]] local TouchMenuBar = InputContainer:new{ - height = Screen:scaleByDPI(70), width = Screen:getWidth(), icons = {}, -- touch menu that holds the bar, used for trigger repaint on icons @@ -93,17 +93,18 @@ local TouchMenuBar = InputContainer:new{ } function TouchMenuBar:init() - self.show_parent = self.show_parent or self - - self.dimen = Geom:new{ - w = self.width, - h = self.height, - } - - self.bar_icon_group = HorizontalGroup:new{} - local icon_sep_width = Screen:scaleByDPI(2) local icons_sep_width = icon_sep_width * (#self.icons + 1) + -- we assume all icons are of the same width + local ib = IconButton:new{icon_file = self.icons[1]} + local content_width = ib:getSize().w * #self.icons + icons_sep_width + local spacing_width = (self.width - content_width)/(#self.icons*2) + local spacing = HorizontalSpan:new{ + width = math.min(spacing_width, Screen:scaleByDPI(20)) + } + self.height = ib:getSize().h + Screen:scaleByDPI(10) + self.show_parent = self.show_parent or self + self.bar_icon_group = HorizontalGroup:new{} -- build up image widget for menu icon bar self.icon_widgets = {} -- hold icon seperators @@ -119,12 +120,6 @@ function TouchMenuBar:init() callback = nil, } - -- we assume all icons are of the same width - local content_width = ib:getSize().w * #self.icons + icons_sep_width - local spacing_width = (Screen:getWidth()-content_width)/(#self.icons*2) - local spacing = HorizontalSpan:new{ - width = math.min(spacing_width, Screen:scaleByDPI(20)) - } table.insert(self.icon_widgets, HorizontalGroup:new{ spacing, ib, spacing, }) @@ -188,6 +183,7 @@ function TouchMenuBar:init() self.bar_sep }, } + self.dimen = Geom:new{ w = self.width, h = self.height } end