invert button on tap

pull/564/head
chrox 10 years ago
parent 659e5f6bdd
commit 877cff2933

@ -32,6 +32,7 @@ function PageCropDialog:init()
radius = 7,
text_font_face = "cfont",
text_font_size = 20,
show_parent = self,
}
local cancel_button = Button:new{
text = self.cancel_text,
@ -41,6 +42,7 @@ function PageCropDialog:init()
radius = 7,
text_font_face = "cfont",
text_font_size = 20,
show_parent = self,
}
local ok_container = RightContainer:new{
dimen = Geom:new{ w = Screen:getWidth()*0.33, h = Screen:getHeight()/12},

@ -6,7 +6,9 @@ local Geom = require("ui/geometry")
local GestureRange = require("ui/gesturerange")
local FrameContainer = require("ui/widget/container/framecontainer")
local CenterContainer = require("ui/widget/container/centercontainer")
local UIManager = require("ui/uimanager")
local Device = require("ui/device")
local DEBUG = require("dbg")
local _ = require("gettext")
--[[
@ -139,7 +141,13 @@ end
function Button:onTapSelect()
if self.enabled then
self.callback()
self[1].invert = true
UIManager:setDirty(self.show_parent, "partial")
UIManager:scheduleIn(0.1, function()
self.callback()
self[1].invert = false
UIManager:setDirty(self.show_parent, "partial")
end)
end
return true
end

@ -39,6 +39,7 @@ function ButtonDialog:init()
ButtonTable:new{
width = Screen:getWidth()*0.9,
buttons = self.buttons,
show_parent = self,
},
background = 0,
bordersize = 2,

@ -42,6 +42,7 @@ function ButtonTable:init()
padding = 0,
text_font_face = self.button_font_face,
text_font_size = self.button_font_size,
show_parent = self.show_parent,
}
local button_dim = button:getSize()
local vertical_sep = LineWidget:new{

@ -43,6 +43,7 @@ function ConfirmBox:init()
self.ok_callback()
UIManager:close(self)
end,
show_parent = self,
}
local cancel_button = Button:new{
text = self.cancel_text,
@ -51,6 +52,7 @@ function ConfirmBox:init()
self.cancel_callback()
UIManager:close(self)
end,
show_parent = self,
}
self.layout = { { ok_button, cancel_button } }

@ -34,7 +34,7 @@ local DictQuickLookup = InputContainer:new{
content_face = Font:getFace("cfont", DDICT_FONT_SIZE),
width = nil,
height = nil,
title_padding = Screen:scaleByDPI(5),
title_margin = Screen:scaleByDPI(2),
word_padding = Screen:scaleByDPI(2),
@ -113,13 +113,13 @@ function DictQuickLookup:update()
height = self.height*0.7,
dialog = self,
},
}
}
local button_table = ButtonTable:new{
width = math.max(self.width, definition:getSize().w),
button_font_face = "cfont",
button_font_size = 20,
buttons = {
{
{
{
text = _("<<"),
enabled = self:isPrevDictAvaiable(),
@ -153,6 +153,7 @@ function DictQuickLookup:update()
},
},
zero_sep = true,
show_parent = self,
}
local title_bar = LineWidget:new{
--background = 8,
@ -161,12 +162,12 @@ function DictQuickLookup:update()
h = Screen:scaleByDPI(2),
}
}
self.dict_bar = OverlapGroup:new{
dimen = {w = button_table:getSize().w, h = self.dict_title:getSize().h},
self.dict_title,
}
self.dict_frame = FrameContainer:new{
radius = 8,
bordersize = 3,
@ -237,7 +238,7 @@ function DictQuickLookup:changeDictionary(index)
self.dictionary = self.results[index].dict
self.lookupword = self.results[index].word
self.definition = self.results[index].definition
local orig_dimen = self.dict_frame and self.dict_frame.dimen or Geom:new{}
self:update()
@ -248,7 +249,7 @@ function DictQuickLookup:changeDictionary(index)
end
end
function DictQuickLookup:changeToDefaultDict()
function DictQuickLookup:changeToDefaultDict()
if self.dictionary then
-- dictionaries that have definition of the first word(accurate word)
-- excluding Fuzzy queries.

@ -59,6 +59,7 @@ function InputDialog:init()
button_font_size = 20,
buttons = self.buttons,
zero_sep = true,
show_parent = self,
}
self.title_bar = LineWidget:new{
--background = 8,

@ -355,11 +355,13 @@ function Menu:init()
icon = "resources/icons/appbar.chevron.left.png",
callback = function() self:onPrevPage() end,
bordersize = 0,
show_parent = self,
}
self.page_info_right_chev = Button:new{
icon = "resources/icons/appbar.chevron.right.png",
callback = function() self:onNextPage() end,
bordersize = 0,
show_parent = self,
}
self.page_info_left_chev:hide()
self.page_info_right_chev:hide()

@ -41,6 +41,10 @@ function TouchMenuItem:init()
},
}
local item_enabled = self.item.enabled
if self.item.enabled_func then
item_enabled = self.item.enabled_func()
end
self.item_frame = FrameContainer:new{
width = self.dimen.w,
bordersize = 0,
@ -50,6 +54,8 @@ function TouchMenuItem:init()
HorizontalSpan:new{ width = 10 },
TextWidget:new{
text = self.item.text or self.item.text_func(),
bgcolor = 0.0,
fgcolor = item_enabled ~= false and 1.0 or 0.5,
face = self.face,
},
},
@ -58,6 +64,12 @@ function TouchMenuItem:init()
end
function TouchMenuItem:onTapSelect(arg, ges)
local enabled = self.item.enabled
if self.item.enabled_func then
enabled = self.item.enabled_func()
end
if enabled == false then return end
self.item_frame.invert = true
UIManager:setDirty(self.show_parent, "partial")
UIManager:scheduleIn(0.5, function()
@ -401,18 +413,31 @@ function TouchMenu:onSwipe(arg, ges_ev)
end
function TouchMenu:onMenuSelect(item)
if item.sub_item_table == nil then
if item.callback then
local enabled = item.enabled
if item.enabled_func then
enabled = item.enabled_func()
end
if enabled == false then return end
local sub_item_table = item.sub_item_table
if item.sub_item_table_func then
sub_item_table = item.sub_item_table_func()
end
if sub_item_table == nil then
local callback = item.callback
if item.callback_func then
callback = item.callback_func()
end
if callback then
-- put stuff in scheduler so we can See
-- the effect of inverted menu item
UIManager:scheduleIn(0.1, function()
self:closeMenu()
item.callback()
callback()
end)
end
else
table.insert(self.item_table_stack, self.item_table)
self.item_table = item.sub_item_table
self.item_table = sub_item_table
self:updateItems()
end
return true

Loading…
Cancel
Save