-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrule_code_row.cr
52 lines (44 loc) · 1.01 KB
/
rule_code_row.cr
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
# Rule code row state.
#
# Rule code row contains one and only one buffer editor: the
# rule code buffer editor.
class RuleCodeRowState < BufferEditorRowState
def string
editor = @states[0].as(BufferEditorState)
editor.string
end
def min_size
1
end
def max_size
1
end
end
# The appearance of a rule code row, which is a row of one and
# only one buffer editor with some padding.
class RuleCodeRowView < BufferEditorRowView
# Specifies the horizontal padding (content inset) for left,
# right sides of this view.
def px
SF.vector2f(6, 8)
end
# Specifies the vertical padding (content inset) for top,
# bottom sides of this view.
def py
SF.vector2f(4, 6)
end
# Returns padding X, Y vector in the top-left corner.
def padding_tl
SF.vector2f(px.x, py.x)
end
# Returns padding X, Y vector in the bottom-right corner.
def padding_br
SF.vector2f(px.y, py.y)
end
def origin
position + padding_tl
end
def size
super + padding_tl + padding_br
end
end