@@ -2,7 +2,6 @@ local BD = require("ui/bidi")
22local Blitbuffer = require (" ffi/blitbuffer" )
33local ButtonTable = require (" ui/widget/buttontable" )
44local CenterContainer = require (" ui/widget/container/centercontainer" )
5- local CloseButton = require (" ui/widget/closebutton" )
65local Device = require (" device" )
76local Geom = require (" ui/geometry" )
87local Event = require (" ui/event" )
@@ -12,7 +11,6 @@ local GestureRange = require("ui/gesturerange")
1211local IconButton = require (" ui/widget/iconbutton" )
1312local InputContainer = require (" ui/widget/container/inputcontainer" )
1413local InputDialog = require (" ui/widget/inputdialog" )
15- local LineWidget = require (" ui/widget/linewidget" )
1614local Math = require (" optmath" )
1715local MovableContainer = require (" ui/widget/container/movablecontainer" )
1816local OverlapGroup = require (" ui/widget/overlapgroup" )
@@ -21,6 +19,7 @@ local ScrollTextWidget = require("ui/widget/scrolltextwidget")
2119local Size = require (" ui/size" )
2220local TextWidget = require (" ui/widget/textwidget" )
2321local TimeVal = require (" ui/timeval" )
22+ local TitleBar = require (" ui/widget/titlebar" )
2423local Translator = require (" ui/translator" )
2524local UIManager = require (" ui/uimanager" )
2625local VerticalGroup = require (" ui/widget/verticalgroup" )
@@ -205,50 +204,16 @@ function DictQuickLookup:init()
205204 -- components, when we know how much height they are taking.
206205
207206 -- Dictionary title
208- -- (a bit convoluted with margin & padding but no border, but let's
209- -- do as other widgets to get the same look)
210- local title_margin = Size .margin .title
211- local title_padding = Size .padding .default
212- local title_width = inner_width - 2 * title_padding - 2 * title_margin
213- local close_button = CloseButton :new { window = self , padding_top = title_margin , }
214- self .dict_title_text = TextWidget :new {
215- text = self .displaydictname ,
216- face = Font :getFace (" x_smalltfont" ),
217- bold = true ,
218- max_width = title_width - close_button :getSize ().w + close_button .padding_left
219- -- Allow text to eat on the CloseButton padding_left (which
220- -- is quite large to ensure a bigger tap area)
221- }
222- local dict_title_widget = self .dict_title_text
223- if self .is_wiki then
224- -- Visual hint: title left aligned for dict, but centered for Wikipedia
225- dict_title_widget = CenterContainer :new {
226- dimen = Geom :new {
227- w = title_width ,
228- h = self .dict_title_text :getSize ().h ,
229- },
230- self .dict_title_text ,
231- }
232- end
233- self .dict_title = FrameContainer :new {
234- margin = title_margin ,
235- bordersize = 0 ,
236- padding = title_padding ,
237- dict_title_widget ,
238- }
239- local title_bar = OverlapGroup :new {
240- dimen = {
241- w = inner_width ,
242- h = self .dict_title :getSize ().h
243- },
244- self .dict_title ,
245- close_button ,
246- }
247- local title_sep = LineWidget :new {
248- dimen = Geom :new {
249- w = inner_width ,
250- h = Size .line .thick ,
251- }
207+ self .dict_title = TitleBar :new {
208+ width = inner_width ,
209+ title = self .displaydictname ,
210+ with_bottom_line = true ,
211+ bottom_v_padding = 0 , -- padding handled below
212+ close_callback = function () self :onClose () end ,
213+ close_hold_callback = function () self :onHoldClose () end ,
214+ -- visual hint: title left aligned for dict, centered for Wikipedia
215+ align = self .is_wiki and " center" or " left" ,
216+ show_parent = self ,
252217 }
253218
254219 -- This padding and the resulting width apply to the content
@@ -577,8 +542,7 @@ function DictQuickLookup:init()
577542 self .align = " center"
578543
579544 local others_height = frame_bordersize * 2 -- DictQuickLookup border
580- + title_bar :getSize ().h
581- + title_sep :getSize ().h
545+ + self .dict_title :getHeight ()
582546 + top_to_word_span :getSize ().h
583547 + lookup_word :getSize ().h
584548 + word_to_definition_span :getSize ().h
@@ -684,8 +648,7 @@ function DictQuickLookup:init()
684648 background = Blitbuffer .COLOR_WHITE ,
685649 VerticalGroup :new {
686650 align = " left" ,
687- title_bar ,
688- title_sep ,
651+ self .dict_title ,
689652 top_to_word_span ,
690653 -- word
691654 CenterContainer :new {
@@ -839,7 +802,7 @@ function DictQuickLookup:update()
839802 self [1 ]:free ()
840803
841804 -- Update TextWidgets
842- self .dict_title_text : setText (self .displaydictname )
805+ self .dict_title : setTitle (self .displaydictname )
843806 if self .displaynb then
844807 self .displaynb_text :setText (self .displaynb )
845808 end
0 commit comments