mirror of
https://github.com/koreader/koreader.git
synced 2025-08-10 00:52:38 +00:00
Top menu: long-press on truncated menu item to show full text
This commit is contained in:
@@ -50,6 +50,7 @@ local TextWidget = Widget:new{
|
||||
_height = 0,
|
||||
_baseline_h = 0,
|
||||
_maxlength = 1200,
|
||||
_is_truncated = nil,
|
||||
|
||||
-- Additional properties only used when using xtext
|
||||
use_xtext = G_reader_settings:nilOrTrue("use_xtext"),
|
||||
@@ -122,6 +123,7 @@ function TextWidget:updateSize()
|
||||
self._length = 0
|
||||
return
|
||||
end
|
||||
self._is_truncated = false
|
||||
|
||||
-- Compute width:
|
||||
if self.use_xtext then
|
||||
@@ -170,6 +172,7 @@ function TextWidget:updateSize()
|
||||
-- smaller than max_width when dropping the truncated glyph).
|
||||
tsize = RenderText:sizeUtf8Text(0, self.max_width, self.face, self._text_to_draw, true, self.bold)
|
||||
self._length = math.floor(tsize.x)
|
||||
self._is_truncated = true
|
||||
end
|
||||
end
|
||||
dbg:guard(TextWidget, "updateSize",
|
||||
@@ -227,6 +230,7 @@ function TextWidget:_measureWithXText()
|
||||
self._shape_idx_to_substitute_with_ellipsis = self._shape_end
|
||||
end
|
||||
end
|
||||
self._is_truncated = true
|
||||
end
|
||||
end
|
||||
|
||||
@@ -294,6 +298,11 @@ function TextWidget:getWidth()
|
||||
return self._length
|
||||
end
|
||||
|
||||
function TextWidget:isTruncated()
|
||||
self:updateSize()
|
||||
return self._is_truncated
|
||||
end
|
||||
|
||||
function TextWidget:getBaseline()
|
||||
self:updateSize()
|
||||
return self._baseline_h
|
||||
|
||||
Reference in New Issue
Block a user