-
Notifications
You must be signed in to change notification settings - Fork 2
/
gridclue.lua
52 lines (46 loc) · 1.39 KB
/
gridclue.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
local Blitbuffer = require("ffi/blitbuffer")
local CenterContainer = require("ui/widget/container/centercontainer")
local InputContainer = require("ui/widget/container/inputcontainer")
local Font = require("ui/font")
local Geom = require("ui/geometry")
local FrameContainer = require("ui/widget/container/framecontainer")
local TextBoxWidget = require("ui/widget/textboxwidget")
local logger = require("logger")
local GridClue = InputContainer:new{
height = nil,
width = nil,
clue_font_face = "infofont",
clue_font_size = nil,
clue_value = nil,
}
function GridClue:init()
self.clue_font_size = TextBoxWidget:getFontSizeToFitHeight(self.height, 1, 0.3)
self.clue_widget = TextBoxWidget:new{
text = self.clue_value,
face = Font:getFace(self.clue_font_face, self.clue_font_size),
width = self.width,
alignment = "center",
fgcolor = Blitbuffer.COLOR_WHITE,
bgcolor = Blitbuffer.COLOR_BLACK,
padding = 0,
bold = true,
}
self[1] = FrameContainer:new{
width = self.width,
height = self.height,
padding = 0,
margin = self.margin or 0,
bordersize = 0,
-- Keep the letter centered
CenterContainer:new{
dimen = Geom:new{
w = self.width,
h = self.height,
},
padding = 0,
-- Add the letter
self.clue_widget,
},
}
end
return GridClue