Skip to content

Commit 36c498a

Browse files
committed
Frame toolbar title.
1 parent 9e0348d commit 36c498a

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

Controls/Frame.moon

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class Frame extends Content
3838
@toolBarColor = t.frame.toolBarColor
3939
@toolBarColorUnfocused = t.frame.toolBarColorUnfocused
4040
@backgroundColor = t.frame.contentBackground
41+
@toolBarTitleColor = t.frame.toolBarTitleColor
4142

4243
@closeBtn = Button "Box"
4344

@@ -60,12 +61,18 @@ class Frame extends Content
6061
@setDrag true
6162
@setMakeTopWhenClicked true
6263

64+
@setToolBarTitle label, math.ceil(@toolBarHeight/2)
65+
6366
onDraw: =>
6467
drawToolBar @
6568

6669
box = @getBoundingBox!
6770
r, g, b, a = Graphics.getColor!
6871
boxW, boxH = box\getWidth!, box\getHeight!
72+
73+
Graphics.setColor @toolBarTitleColor
74+
Graphics.draw @toolBarTitle, box.x + @titleOffSet, box.y + @titleOffSet
75+
6976

7077
Graphics.setColor @backgroundColor
7178
Graphics.rectangle "fill", box.x, box.y + @toolBarHeight, boxW, boxH - @toolBarHeight, @rx, @ry
@@ -106,5 +113,16 @@ class Frame extends Content
106113
manager\setFocus @
107114
@onFocus!
108115

116+
setToolBarTitle: (text = @text, size, font) =>
117+
if size and font
118+
if type(font) == "number" then @font = Graphics.newFont font
119+
if type(font) == "string" then @font = Graphics.newFont font, size
120+
@toolBarTitle = Graphics.newText @font, text
121+
if size
122+
@font = Graphics.newFont size
123+
@toolBarTitle = Graphics.newText @font, text
124+
125+
@titleOffSet = math.floor ((@toolBarHeight-1) / 2) - (size/2)
126+
109127

110128
Frame

Controls/themes/blues.moon

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ Default =
2525
toolBarColor: {0.161, 0.29, 0.478}
2626
toolBarColorUnfocused: {0.62, 0.62, 0.576}
2727
contentBackground: {0.082, 0.086, 0.09}
28+
toolBarTitleColor: {1, 1, 1}
2829

2930
button:
3031
width: 100

src/Core/Control.moon

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,7 @@ class Control
190190

191191
if @childrenEnabled
192192
for i = #@children, 1, -1
193-
control = @children[i]
194-
hitControl = control\hitTest x, y
193+
hitControl = @children[i]\hitTest x, y
195194
if hitControl then return hitControl
196195

197196
if @enabled
@@ -449,6 +448,7 @@ class Control
449448
@children[i]\setParent nil
450449
Tremove @children, i
451450
child.events\dispatch child.events\getEvent "UI_ON_REMOVE"
451+
child = nil
452452
break
453453

454454
--- drops the control children.

0 commit comments

Comments
 (0)