Posted 15 September 2017 - 03:42 AM
Budj
Dave-ee's GUI API!
Dave-ee's GUI API!
Look! Another GUI API!
Yep. As a not-so-wise-man once said: "anudder one". It's not quite as good as something like Touchpoint, but it's got some different features that might be useful to some.
I despise having to use someone else's GUI APIs, as I always prefer to write my own APIs. It's more interesting, better for the learning experience, and better for your own applications. So, I made Budj. Budj is a top-notch bloke. He can do all kinds of things.
He can have multiple whiteboards for you to slap buttons and checkboxes on, he can draw and undraw objects, he can swap whiteboards when he wants to change whats on the screen. He can do all kinds of cool things.He can even assign functions to objects, handle your events for you and re-align or re-assign labels.
Usage:
Spoiler
It's an API..you just..load it..
os.loadAPI("/budj")
Functions:
Spoiler
General functions:
error(string) -- Returns an error (overrides old 'error', but still uses it)
-- Returns nothing
handleEvent(...)
-- Handles mouse clicks and mouse ups
-- If mouse_click it replies "wait" if user clicked on an object, also returning the object as a second argument
-- If mouse_up on an object it runs the object's function, returning true, the object and the returned from the function as a table
Boards:
budj.BOARD:new(label)
-- Returns board as an object
budj.BOARD:toggleActive(boolean) -- Toggles the board active or not (doesn't need argument)
-- Returns nothing
budj.BOARD:draw() -- Draws all objects that the board has on it
-- Returns nothing
budj.BOARD:undraw() -- Undraws all objects that the board has on it
-- Returns nothing
Buttons:
budj.BUTTON:new(board,label,x,y,w,h,colour_text,colour_button_background,colour_button_background_clicked,button_filled)
-- returns button as an object
budj.BUTTON:draw() -- Draws the button
-- returns nothing
budj.BUTTON:undraw() -- Undraws the button
-- returns nothing
budj.BUTTON:toggleActive(boolean) -- Toggles button inactive or not (doesn't need argument)
-- returns nothing
budj.BUTTON:run() -- Runs the function that is linked to the button
-- returns the function's return
budj.BUTTON:alignLabel(alignment_type_x,alignment_type_y) -- Aligns the label (more doc. in API)
-- returns nothing
budj.BUTTON:assignLabel(label) -- Gives button a new label and automatically re-aligns it to how you had it before
-- returns nothing
budj.BUTTON:assignFunction(function) -- Gives the button a new function
-- returns nothing
budj.BUTTON:assignBoard(board)[/s] -- Assigns the button to another board (WIP atm, don't use)
Checkboxes:
budj.CHECKBOX:new(board,label,x,y,colour_text,colour_text_background,colour_checkbox_text,colour_checkbox_background,colour_checkbox_clicked)
-- returns checkbox as an object
budj.CHECKBOX:draw() -- Draws the checkbox
-- returns nothing
budj.CHECKBOX:undraw() -- Undraws the checkbox
-- returns nothing
budj.CHECKBOX:toggleActive() -- Toggles button inactive or not(doesn't need argument)
-- returns nothing
budj.CHECKBOX:toggleState() -- Toggles on/off
-- returns state (true/false)
budj.CHECKBOX:getState() -- Gets state of checkbox
-- returns state (true/false)
budj.CHECKBOX:run() -- Runs the function that is linked to the checkbox and toggles the state
-- returns the function's return and the state of the checkbox
budj.CHECKBOX:alignLabel(alignment_type_x) -- Aligns the label (more doc. in API)
-- returns nothing
budj.CHECKBOX:assignLabel(label) -- Gives checkbox a new label and automatically re-aligns it to how you had it before
-- returns nothing
budj.CHECKBOX:assignFunction(function) -- Gives the checkbox a new function (doesn't stop it from toggling)
-- returns nothing
budj.CHECKBOX:assignBoard(board)[/s] -- Assigns the checkbox to another board (WIP atm, don't use)
Demo program:
The demo program is pretty cool. Let me explain what it does.
When you click the button, it toggles the checkbox's 'DRAWN' variable. While it's undrawn you cannot interact with it.
When you click the button again, it toggles the checkbox to be drawn again.
When you toggle the checkbox it changes the button's label. You can actually swap the functions between the two objects, or even create more. I built the demo so it was very versatile and shows you what you can do.
Demo program's pastebin:
pastebin get Kte8gY84 demo
API's pastebin:
pastebin get ugKWxVGj budj
PLEASE give suggestions and feedback!
Edited on 17 September 2017 - 10:56 PM