Skip to content

Commit 6f45ba4

Browse files
committed
Started Frame example.
1 parent 9f744c4 commit 6f45ba4

File tree

4 files changed

+115
-7
lines changed

4 files changed

+115
-7
lines changed

Controls/Frame.moon

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
Button = assert require MeowUI.c_cwd .."Button"
2+
Content = assert require MeowUI.c_cwd .."Content"
3+
4+
manager = MeowUI.manager
5+
Graphics = love.graphics
6+
7+
8+
drawToolBar = =>
9+
box = @getBoundingBox!
10+
r, g, b, a = Graphics.getColor!
11+
boxW = box\getWidth!
12+
13+
local _toolBarColor
14+
if @focused
15+
_toolBarColor = @toolBarColor
16+
else
17+
_toolBarColor = @toolBarColorUnfocused
18+
19+
Graphics.setColor _toolBarColor
20+
Graphics.rectangle "fill", box.x, box.y, boxW, @toolBarHeight, @rx, @ry
21+
Graphics.setColor @backgroundColor
22+
Graphics.rectangle "line", box.x, box.y, boxW, @toolBarHeight, @rx, @ry
23+
24+
Graphics.setColor r, g, b, a
25+
26+
27+
class Frame extends Content
28+
29+
30+
new: (label, vbar, hbar) =>
31+
super label, vbar, hbar, false
32+
33+
@toolBarHeight = 26
34+
35+
-- colors
36+
t = @getTheme!
37+
38+
@toolBarColor = t.frame.toolBarColor
39+
@toolBarColorUnfocused = t.frame.toolBarColorUnfocused
40+
@backgroundColor = t.frame.contentBackground
41+
42+
@closeBtn = Button "Box"
43+
44+
with @closeBtn
45+
\setLabel "Frame_closeBtn"
46+
\setSize 18, 18
47+
\setImage MeowUI.assets .. "cross.png", true
48+
\setStroke 0
49+
\setNotifyParent true
50+
\onClick ->
51+
nil
52+
-- TODO : destruct
53+
54+
@on "UI_DRAW", @onDraw, @
55+
@on "UI_FOCUS", @onFocus, @
56+
@on "UI_UN_FOCUS", @onUnFocus, @
57+
58+
@addChild @closeBtn
59+
60+
onDraw: =>
61+
drawToolBar @
62+
63+
box = @getBoundingBox!
64+
r, g, b, a = Graphics.getColor!
65+
boxW, boxH = box\getWidth!, box\getHeight!
66+
67+
Graphics.setColor @backgroundColor
68+
Graphics.rectangle "fill", box.x, box.y + @toolBarHeight, boxW, boxH - @toolBarHeight, @rx, @ry
69+
70+
Graphics.setColor r, g, b, a
71+
72+
73+
setSize: (w, h) =>
74+
super w, h
75+
76+
@closeBtn\setPosition w - 20, 6
77+
78+
setPosition: (x, y) =>
79+
super x, y
80+
81+
addChild: (child) =>
82+
super child
83+
84+
onFocus: =>
85+
@focused = true
86+
87+
onUnFocus: =>
88+
@focused = false
89+
90+
91+
Frame

Controls/assets/cross.png

264 Bytes
Loading

Controls/themes/blues.moon

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ Default =
2020
stroke: 2
2121
fontSize: 13
2222
iconAndTextSpace: 8
23+
24+
frame:
25+
toolBarColor: {0.161, 0.29, 0.478}
26+
toolBarColorUnfocused: {0.62, 0.62, 0.576}
27+
contentBackground: {0.082, 0.086, 0.09}
2328

2429
button:
2530
width: 100

init.moon

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,17 @@ root = path .. "."
1212
love = love
1313
import keyboard from love
1414

15+
os = love.system.getOS!
16+
local _separator
17+
18+
if os == "Windows"
19+
_separator = '\\'
20+
else
21+
_separator = '/'
22+
23+
print root
24+
_assets = root\gsub '%.', _separator
25+
1526
-- Love config
1627
keyboard.setKeyRepeat true
1728

@@ -24,14 +35,15 @@ export MeowUI = {
2435
author: "Tourahi Amine"
2536
}
2637

27-
MeowUI["cwd"] = cwd
28-
MeowUI["c_cwd"] = c_cwd
29-
MeowUI["root"] = root
30-
MeowUI["manager"] = assert require MeowUI.cwd .. "Core.Manager"
31-
MeowUI["Control"] = assert require MeowUI.cwd .. "Core.Control"
32-
MeowUI["theme"] = assert(require(MeowUI.root .. "Controls.themes")[MeowUI.defTheme]!)
38+
MeowUI["cwd"] = cwd
39+
MeowUI["c_cwd"] = c_cwd
40+
MeowUI["root"] = root
41+
MeowUI["assets"] = _assets .. "Controls" .. _separator .. "assets" .. _separator
42+
MeowUI["path_seperator"] = _separator
43+
MeowUI["manager"] = assert require MeowUI.cwd .. "Core.Manager"
44+
MeowUI["Control"] = assert require MeowUI.cwd .. "Core.Control"
45+
MeowUI["theme"] = assert(require(MeowUI.root .. "Controls.themes")[MeowUI.defTheme]!)
3346
MeowUI["useThirdParty-utf8"] = true -- utf8.lua - https://github.com/Stepets/utf8.lua
3447

35-
3648
if MeowUI["useThirdParty-utf8"]
3749
export utf8 = assert require(MeowUI.cwd .. "ThirdParty.utf8")\init!

0 commit comments

Comments
 (0)