2
0
mirror of https://github.com/koreader/koreader synced 2024-11-10 01:10:34 +00:00
koreader/frontend/ui/widget/fixedtextwidget.lua
NiLuJe 19ed35e59c ConfigDialog: Don't enforce 0x0 dimensions on initial display
FrameContainer now behaves like other widgets, and no longer re-computes
dimensions in paintTo *if you provide a dimen*.
Since we do here, for.... reasons I'm not entirely sure still make any
sense, make sure we actually compute valid dimensions,
instead of an empty rect from Geom:new ;).

Fix #11389
2024-01-19 21:11:02 +01:00

26 lines
578 B
Lua

local TextWidget = require("ui/widget/textwidget")
local Geom = require("ui/geometry")
--[[
FixedTextWidget
--]]
local FixedTextWidget = TextWidget:extend{}
function FixedTextWidget:updateSize()
TextWidget.updateSize(self)
-- Only difference from TextWidget:
-- no vertical padding, baseline is height
self._height = self.face.size
self._baseline_h = self.face.size
end
function FixedTextWidget:getSize()
self:updateSize()
if self._length == 0 then
return Geom:new()
end
return TextWidget.getSize(self)
end
return FixedTextWidget