From 36478262bf3d8d1579e4817e44a0ee2d57889bcb Mon Sep 17 00:00:00 2001 From: Frans de Jonge Date: Sat, 23 Sep 2017 22:01:30 +0200 Subject: [PATCH] [UX] Smaller top menu icons (#3253) --- frontend/ui/widget/iconbutton.lua | 4 ++++ frontend/ui/widget/touchmenu.lua | 12 ++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/frontend/ui/widget/iconbutton.lua b/frontend/ui/widget/iconbutton.lua index c7f552de0..f69720f2f 100644 --- a/frontend/ui/widget/iconbutton.lua +++ b/frontend/ui/widget/iconbutton.lua @@ -14,6 +14,8 @@ local IconButton = InputContainer:new{ dimen = nil, -- show_parent is used for UIManager:setDirty, so we can trigger repaint show_parent = nil, + width = nil, + height = nil, scale_for_dpi = true, horizontal_padding = 0, callback = function() end, @@ -23,6 +25,8 @@ function IconButton:init() self.image = ImageWidget:new{ file = self.icon_file, scale_for_dpi = self.scale_for_dpi, + width = self.width, + height = self.height, } self.show_parent = self.show_parent or self diff --git a/frontend/ui/widget/touchmenu.lua b/frontend/ui/widget/touchmenu.lua index ffcaede99..56c0d6abd 100644 --- a/frontend/ui/widget/touchmenu.lua +++ b/frontend/ui/widget/touchmenu.lua @@ -162,12 +162,13 @@ function TouchMenuBar:init() local icon_sep_width = Size.span.vertical_default local icons_sep_width = icon_sep_width * (#self.icons + 1) -- we assume all icons are of the same width - local tmp_ib = IconButton:new{icon_file = self.icons[1]} + local icon_width = Screen:scaleBySize(40) + local icon_height = icon_width -- content_width is the width of all the icon images - local content_width = tmp_ib:getSize().w * #self.icons + icons_sep_width + local content_width = icon_width * #self.icons + icons_sep_width local spacing_width = (self.width - content_width)/(#self.icons*2) - local icon_padding = math.min(spacing_width, Screen:scaleBySize(20)) - self.height = tmp_ib:getSize().h + Screen:scaleBySize(10) + local icon_padding = math.min(spacing_width, Screen:scaleBySize(16)) + self.height = icon_height + Size.span.vertical_large self.show_parent = self.show_parent or self self.bar_icon_group = HorizontalGroup:new{} -- build up image widget for menu icon bar @@ -187,6 +188,9 @@ function TouchMenuBar:init() local ib = IconButton:new{ show_parent = self.show_parent, icon_file = v, + width = icon_width, + height = icon_height, + scale_for_dpi = false, callback = nil, horizontal_padding = icon_padding, }