From 8dbaa2c76cdc77e0245f43f972a273f49f10ab47 Mon Sep 17 00:00:00 2001 From: chrox Date: Mon, 22 Jul 2013 22:08:40 +0800 Subject: [PATCH] use regional update when selecting config panels --- frontend/ui/widget/config.lua | 40 +++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/frontend/ui/widget/config.lua b/frontend/ui/widget/config.lua index da1f116e6..c68fb0f0d 100644 --- a/frontend/ui/widget/config.lua +++ b/frontend/ui/widget/config.lua @@ -37,12 +37,13 @@ end OptionTextItem = InputContainer:new{} function OptionTextItem:init() local text_widget = self[1] - self.dimen = text_widget:getSize() + self[1] = UnderlineContainer:new{ text_widget, padding = self.padding, color = self.color, - } + } + self.dimen = self[1]:getSize() -- we need this table per-instance, so we declare it here if Device:isTouchDevice() then self.ges_events = { @@ -255,7 +256,6 @@ function ConfigOption:init() end end end - if self.options[c].item_text then for d = 1, #self.options[c].item_text do local option_item = nil @@ -421,13 +421,10 @@ function ConfigDialog:init() ------------------------------------------ -- start to set up widget layout --------- ------------------------------------------ - self.config_panel = ConfigPanel:new{ - config_dialog = self, - } self.config_menubar = MenuBar:new{ config_dialog = self, } - self:makeDialog() + self:update() ------------------------------------------ -- start to set up input event callback -- ------------------------------------------ @@ -449,19 +446,17 @@ function ConfigDialog:init() self.key_events.FocusRight = nil end self.key_events.Select = { {"Press"}, doc = _("select current menu item") } - - UIManager:setDirty(self, "partial") end function ConfigDialog:updateConfigPanel(index) - self.panel_index = index + +end + +function ConfigDialog:update() self.config_panel = ConfigPanel:new{ - index = index, + index = self.panel_index, config_dialog = self, } -end - -function ConfigDialog:makeDialog() self.dialog_frame = FrameContainer:new{ background = 0, VerticalGroup:new{ @@ -474,12 +469,20 @@ function ConfigDialog:makeDialog() dimen = Screen:getSize(), self.dialog_frame, } + UIManager.repaint_all = true end function ConfigDialog:onShowConfigPanel(index) - self:updateConfigPanel(index) - self:makeDialog() - UIManager.repaint_all = true + self.panel_index = index + local orig_dimen = self.dialog_frame and self.dialog_frame.dimen or Geom:new{} + + self:update() + + UIManager.update_region_func = function() + local update_region = self.dialog_frame.dimen:combine(orig_dimen) + DEBUG("update region", update_region) + return update_region + end return true end @@ -487,12 +490,13 @@ function ConfigDialog:onConfigChoice(option_name, option_value) --DEBUG("config option value", option_name, option_value) self.configurable[option_name] = option_value self.ui:handleEvent(Event:new("StartActivityIndicator")) + return true end function ConfigDialog:onConfigEvent(option_event, option_arg) --DEBUG("config option event", option_event, option_arg) self.ui:handleEvent(Event:new(option_event, option_arg)) - self:onShowConfigPanel(self.panel_index) + return true end function ConfigDialog:closeDialog()