@@ -24,9 +24,9 @@ local basalt = require("basalt") -- we need basalt here
2424local main = basalt .createFrame ():setTheme ({FrameBG = colors .lightGray , FrameFG = colors .black }) -- we change the default bg and fg color for frames
2525
2626local 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 (),
3030}
3131
3232local 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
3939end
4040
4141local menubar = main :addMenubar ():setScrollable () -- we create a menubar in our main frame.
42- :setSize (" { parent.w} " )
42+ :setSize (" parent.w" )
4343 :onChange (function (self , val )
4444 openSubFrame (self :getItemIndex ()) -- here we open the sub frame based on the table index
4545 end )
@@ -78,23 +78,23 @@ local main = basalt.createFrame():setTheme({FrameBG = colors.lightGray, FrameFG
7878
7979--[[
8080Here 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"
8282As you can see we add :setZIndex(25) - this makes sure the sidebar frame is always more important than our normal sub frames.
8383:setScrollable just makes the sidebar frame scrollable (in case you're adding more frames)
8484]]
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 ()
8686:onGetFocus (function (self )
87- self :setPosition (" { parent.w - (self.w-1)} " )
87+ self :setPosition (" parent.w - (self.w-1)" )
8888end )
8989:onLoseFocus (function (self )
90- self :setPosition (" { parent.w} " )
90+ self :setPosition (" parent.w" )
9191end )
9292
9393-- Once again we add 3 frames, the first one should be immediatly visible
9494local 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 (),
9898}
9999
100100-- This part of the code adds buttons based on the sub table.
@@ -103,7 +103,7 @@ for k,v in pairs(sub)do
103103 sidebar :addButton ():setText (" Example " .. k ) -- creating the button and adding a name k is just the index
104104 :setBackground (colors .black )
105105 :setForeground (colors .lightGray )
106- :setSize (" { parent.w - 2} " , 3 )
106+ :setSize (" parent.w - 2" , 3 )
107107 :setPosition (2 , y )
108108 :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
109109 for a , b in pairs (sub )do
@@ -153,13 +153,13 @@ local function openProgram(path, title, x, y, w, h)
153153 :setPosition (x or math.random (2 , 12 ), y or math.random (2 , 8 ))
154154
155155 f :addLabel ()
156- :setSize (" { parent.w} " , 1 )
156+ :setSize (" parent.w" , 1 )
157157 :setBackground (colors .black )
158158 :setForeground (colors .lightGray )
159159 :setText (title or " New Program" )
160160
161161 f :addProgram ()
162- :setSize (" { parent.w-1} " , " { parent.h - 2} " )
162+ :setSize (" parent.w-1" , " parent.h - 2" )
163163 :setPosition (1 , 2 )
164164 :execute (path or " rom/programs/shell.lua" )
165165
@@ -168,7 +168,7 @@ local function openProgram(path, title, x, y, w, h)
168168 :setText (" X" )
169169 :setBackground (colors .black )
170170 :setForeground (colors .red )
171- :setPosition (" { parent.w-1} " , 1 )
171+ :setPosition (" parent.w-1" , 1 )
172172 :onClick (function ()
173173 f :remove ()
174174 processes [pId ] = nil
179179
180180openProgram (" rom/programs/fun/worm.lua" )
181181
182- main :addButton ():setPosition (" { parent.w - 16} " , 2 ):setText (" Open" ):onClick (function ()
182+ main :addButton ():setPosition (" parent.w - 16" , 2 ):setText (" Open" ):onClick (function ()
183183 openProgram ()
184184end )
185185
@@ -215,7 +215,7 @@ local function makeResizeable(frame, minW, minH, maxW, maxH)
215215 maxW = maxW or 99
216216 maxH = maxH or 99
217217 local btn = frame :addButton ()
218- :setPosition (" { parent.w-1} " , " { parent.h-1} " )
218+ :setPosition (" parent.w-1" , " parent.h-1" )
219219 :setSize (1 , 1 )
220220 :setText (" /" )
221221 :setForeground (colors .blue )
0 commit comments