@@ -24,9 +24,9 @@ local basalt = require("basalt") -- we need basalt here
24
24
local main = basalt .createFrame ():setTheme ({FrameBG = colors .lightGray , FrameFG = colors .black }) -- we change the default bg and fg color for frames
25
25
26
26
local sub = { -- here we create a table where we gonna add some frames
27
- main :addFrame ():setPosition (1 , 2 ):setSize (" { parent.w} " , " { parent.h - 1} " ), -- obviously the first one should be shown on program start
28
- main :addFrame ():setPosition (1 , 2 ):setSize (" { parent.w} " , " { parent.h - 1} " ):hide (),
29
- main :addFrame ():setPosition (1 , 2 ):setSize (" { parent.w} " , " { parent.h - 1} " ):hide (),
27
+ main :addFrame ():setPosition (1 , 2 ):setSize (" parent.w" , " parent.h - 1" ), -- obviously the first one should be shown on program start
28
+ main :addFrame ():setPosition (1 , 2 ):setSize (" parent.w" , " parent.h - 1" ):hide (),
29
+ main :addFrame ():setPosition (1 , 2 ):setSize (" parent.w" , " parent.h - 1" ):hide (),
30
30
}
31
31
32
32
local function openSubFrame (id ) -- we create a function which switches the frame for us
@@ -39,7 +39,7 @@ local function openSubFrame(id) -- we create a function which switches the frame
39
39
end
40
40
41
41
local menubar = main :addMenubar ():setScrollable () -- we create a menubar in our main frame.
42
- :setSize (" { parent.w} " )
42
+ :setSize (" parent.w" )
43
43
:onChange (function (self , val )
44
44
openSubFrame (self :getItemIndex ()) -- here we open the sub frame based on the table index
45
45
end )
@@ -78,23 +78,23 @@ local main = basalt.createFrame():setTheme({FrameBG = colors.lightGray, FrameFG
78
78
79
79
--[[
80
80
Here we create the sidebar, on focus it should change the position to parent.w - (self.w-1) which "opens the frame"
81
- when the focus gets lost we simply change the position to "{ parent.w} "
81
+ when the focus gets lost we simply change the position to "parent.w"
82
82
As you can see we add :setZIndex(25) - this makes sure the sidebar frame is always more important than our normal sub frames.
83
83
:setScrollable just makes the sidebar frame scrollable (in case you're adding more frames)
84
84
]]
85
- local sidebar = main :addFrame ():setBackground (colors .gray ):setPosition (" { parent.w} " , 1 ):setSize (15 , " { parent.h} " ):setZIndex (25 ):setScrollable ()
85
+ local sidebar = main :addFrame ():setBackground (colors .gray ):setPosition (" parent.w" , 1 ):setSize (15 , " parent.h" ):setZIndex (25 ):setScrollable ()
86
86
:onGetFocus (function (self )
87
- self :setPosition (" { parent.w - (self.w-1)} " )
87
+ self :setPosition (" parent.w - (self.w-1)" )
88
88
end )
89
89
:onLoseFocus (function (self )
90
- self :setPosition (" { parent.w} " )
90
+ self :setPosition (" parent.w" )
91
91
end )
92
92
93
93
-- Once again we add 3 frames, the first one should be immediatly visible
94
94
local sub = {
95
- main :addFrame ():setPosition (1 , 1 ):setSize (" { parent.w} " , " { parent.h} " ),
96
- main :addFrame ():setPosition (1 , 1 ):setSize (" { parent.w} " , " { parent.h} " ):hide (),
97
- main :addFrame ():setPosition (1 , 1 ):setSize (" { parent.w} " , " { parent.h} " ):hide (),
95
+ main :addFrame ():setPosition (1 , 1 ):setSize (" parent.w" , " parent.h" ),
96
+ main :addFrame ():setPosition (1 , 1 ):setSize (" parent.w" , " parent.h" ):hide (),
97
+ main :addFrame ():setPosition (1 , 1 ):setSize (" parent.w" , " parent.h" ):hide (),
98
98
}
99
99
100
100
-- This part of the code adds buttons based on the sub table.
@@ -103,7 +103,7 @@ for k,v in pairs(sub)do
103
103
sidebar :addButton ():setText (" Example " .. k ) -- creating the button and adding a name k is just the index
104
104
:setBackground (colors .black )
105
105
:setForeground (colors .lightGray )
106
- :setSize (" { parent.w - 2} " , 3 )
106
+ :setSize (" parent.w - 2" , 3 )
107
107
:setPosition (2 , y )
108
108
:onClick (function () -- here we create a on click event which hides ALL sub frames and then shows the one which is linked to the button
109
109
for a , b in pairs (sub )do
@@ -153,13 +153,13 @@ local function openProgram(path, title, x, y, w, h)
153
153
:setPosition (x or math.random (2 , 12 ), y or math.random (2 , 8 ))
154
154
155
155
f :addLabel ()
156
- :setSize (" { parent.w} " , 1 )
156
+ :setSize (" parent.w" , 1 )
157
157
:setBackground (colors .black )
158
158
:setForeground (colors .lightGray )
159
159
:setText (title or " New Program" )
160
160
161
161
f :addProgram ()
162
- :setSize (" { parent.w-1} " , " { parent.h - 2} " )
162
+ :setSize (" parent.w-1" , " parent.h - 2" )
163
163
:setPosition (1 , 2 )
164
164
:execute (path or " rom/programs/shell.lua" )
165
165
@@ -168,7 +168,7 @@ local function openProgram(path, title, x, y, w, h)
168
168
:setText (" X" )
169
169
:setBackground (colors .black )
170
170
:setForeground (colors .red )
171
- :setPosition (" { parent.w-1} " , 1 )
171
+ :setPosition (" parent.w-1" , 1 )
172
172
:onClick (function ()
173
173
f :remove ()
174
174
processes [pId ] = nil
179
179
180
180
openProgram (" rom/programs/fun/worm.lua" )
181
181
182
- main :addButton ():setPosition (" { parent.w - 16} " , 2 ):setText (" Open" ):onClick (function ()
182
+ main :addButton ():setPosition (" parent.w - 16" , 2 ):setText (" Open" ):onClick (function ()
183
183
openProgram ()
184
184
end )
185
185
@@ -215,7 +215,7 @@ local function makeResizeable(frame, minW, minH, maxW, maxH)
215
215
maxW = maxW or 99
216
216
maxH = maxH or 99
217
217
local btn = frame :addButton ()
218
- :setPosition (" { parent.w-1} " , " { parent.h-1} " )
218
+ :setPosition (" parent.w-1" , " parent.h-1" )
219
219
:setSize (1 , 1 )
220
220
:setText (" /" )
221
221
:setForeground (colors .blue )
0 commit comments