From 6c7641cd0b4650f9089681d9f1bdcd5e0fdec580 Mon Sep 17 00:00:00 2001 From: chrox Date: Sun, 28 Jul 2013 16:07:51 +0800 Subject: [PATCH] fix long definition not shown properly in dictionary window --- frontend/ui/reader/readerdictionary.lua | 1 + frontend/ui/widget/dict.lua | 66 ++++++++++++++++--------- 2 files changed, 45 insertions(+), 22 deletions(-) diff --git a/frontend/ui/reader/readerdictionary.lua b/frontend/ui/reader/readerdictionary.lua index 391e71995..17e3f7769 100644 --- a/frontend/ui/reader/readerdictionary.lua +++ b/frontend/ui/reader/readerdictionary.lua @@ -39,6 +39,7 @@ function ReaderDictionary:showDict(results) results = results, dictionary = self.default_dictionary, width = Screen:getWidth() - scaleByDPI(120), + height = Screen:getHeight()*0.43, }) end end diff --git a/frontend/ui/widget/dict.lua b/frontend/ui/widget/dict.lua index c0cce51a4..482352e34 100644 --- a/frontend/ui/widget/dict.lua +++ b/frontend/ui/widget/dict.lua @@ -14,35 +14,43 @@ DictQuickLookup = InputContainer:new{ word_face = Font:getFace("tfont", 20), content_face = Font:getFace("cfont", 20), width = nil, + height = nil, title_padding = scaleByDPI(5), title_margin = scaleByDPI(2), - word_padding = scaleByDPI(5), + word_padding = scaleByDPI(2), word_margin = scaleByDPI(2), - definition_padding = scaleByDPI(5), + definition_padding = scaleByDPI(2), definition_margin = scaleByDPI(2), button_padding = scaleByDPI(14), } function DictQuickLookup:init() - if Device:hasKeyboard() then - key_events = { - AnyKeyPressed = { { Input.group.Any }, - seqtext = "any key", doc = _("close dialog") } - } - else - self.ges_events.TapCloseDict = { - GestureRange:new{ - ges = "tap", - range = Geom:new{ - x = 0, y = 0, - w = Screen:getWidth(), - h = Screen:getHeight(), - } - } + self:changeToDefaultDict() + if Device:isTouchDevice() then + self.ges_events = { + TapCloseDict = { + GestureRange:new{ + ges = "tap", + range = Geom:new{ + x = 0, y = 0, + w = Screen:getWidth(), + h = Screen:getHeight(), + } + }, + }, + Swipe = { + GestureRange:new{ + ges = "swipe", + range = Geom:new{ + x = 0, y = 0, + w = Screen:getWidth(), + h = Screen:getHeight(), + } + }, + }, } end - self:changeToDefaultDict() end function DictQuickLookup:update() @@ -73,10 +81,12 @@ function DictQuickLookup:update() padding = self.definition_padding, margin = self.definition_margin, bordersize = 0, - TextBoxWidget:new{ + ScrollTextWidget:new{ text = self.definition, - face = self.content_face, + font_face = self.content_face, width = self.width, + height = self.height*0.8, + dialog = self, }, } local button_table = ButtonTable:new{ @@ -138,9 +148,21 @@ function DictQuickLookup:update() self.dict_title, title_bar, -- word - lookup_word, + CenterContainer:new{ + dimen = Geom:new{ + w = title_bar:getSize().w, + h = lookup_word:getSize().h, + }, + lookup_word, + }, -- definition - definition, + CenterContainer:new{ + dimen = Geom:new{ + w = title_bar:getSize().w, + h = definition:getSize().h, + }, + definition, + }, -- buttons CenterContainer:new{ dimen = Geom:new{