EazyGadgets - Simple but functional GUI

Monkey Forums/Monkey Code/EazyGadgets - Simple but functional GUI

Supertino(Posted 2014) [#1]
Hey all

I just put together a simple GUI module that support 10 different gadget types.

You can try it out here http://moarlasers.com/ezgadgets/html5/ezgadgets.html

You can also go to my google drive and grab the source used in this example to see how all the gadgets are put together. https://drive.google.com/folderview?id=0B1jBbicq8v_dbXBybzVDLVNJLUU&usp=sharing

1. Canvases
2. List boxes
3. Buttons
4. Text boxes
5. Spinners
6. Combo boxes
7. Sliders
8. Labels
9. Check Boxes
10. Message Boxes

There are much better ones already available but this one does not require any setup, external files or frameworks, just import the .monkey file and that's it.

Basic but functional is how I would describe it good for internal tools and editors probably not good for public.



Save this out and import into your project, or grab from my google (link above)



Example


[h2]List of gadget Methods[/h2]

Shared methods, all gadget have these methods
Update - Needs to be called within OnUpdate
Render - Needs to be called within OnRender
LayoutX - Screen X position of the gadget
LayoutY - Screen Y position of the gadget
LayoutWidth - The width of the gadget
LayoutHeight - The height of the gadget
Hide - A hidden gadget is not rendered and cannot be used
Disabled - Gadget cannot be used but is rendered.

Canvas
Mouse_X - Relative mouse Y position
Mouse_Y - Relative mouse X position
MouseInCanvas - Return true if the mouse is over the canvas
Push - Call before needing to draw to the canvas
Pop - Call after your done drawing on the canvas

List box
AddItem - Add an item to the list
Clear - Clear all items off the list
Index - Return the selected index value
Item - Return the selected Item text
Export - Return the list of items as a String array

Button
SetLabel - Sets the text that appears on the button
Update - Return true if the button has been pressed

Text box
Clear - Clears any text
SetLabel - Sets the label that appears to the left of the box
Value - Returns the text in the box
SetValue - Set what text to appear in the box

Spinner
SetRange - set min and max values and the step value (how much each press should add/remove)
Value - Return the number is the box
SetValue - Set a box value

Combo box
AddItem - Add a item to the list
Clear - Clear all items
Index - Return the selected index value
Item - Return the selected Item text

Slider
SetRange - Set the size of the knob (handle you drag), set max slide value (0..max)
SetValue - Set the slider value
Value - Return the slider value

Label
SetText - Set the label text

Check box
SetState - Set the state of the checkbox 0=uncheck 1=checked
State - Return the checkbox state 0=uncheck 1=checked
SetLabel - Set the label text to appear to the right of the check box



Message box is not an object you create unlike the others, just call ezMessageBox when you want to use it, see commands below

When you want to show the message you must continually call ezMessageBox.Show, best assign a variable to flag when to show the gadget, then when a message box button is pressed the variable should be turned off.

ezMessageBox.Show - Show the message box, this disabled all other gadgets
ezMessageBox.YesOk - Returns True if the Yes or OK button has been pressed
ezMessageBox.NoCancel - Returns True if the No or Cancel button has been pressed
ezMessageBox.SetMessage - Sets the body message ~r for line breaks
ezMessageBox.SetTitle - Sets the messagebox title


DruggedBunny(Posted 2014) [#2]
Works really well, thanks!


consty(Posted 2014) [#3]
Very nice! Good work and thanks for posting.


DiabloV(Posted 2014) [#4]
This domain has expired. If you owned this domain, contact your domain registration service provider for further assistance. If you need .............


Supertino(Posted 2014) [#5]
I knew there was something I was meant to do last weekend, should be back up in a few hours.


Sammy(Posted 2014) [#6]
Lucky for me, I missed this, thank you Supertino.


Sammy(Posted 2014) [#7]
Worked fine but it really does not like Autofit, mainly due to SetScissors() being device coord dependant I believe. Not the fault of your lib though.


Supertino(Posted 2014) [#8]
Yeah lots of scissor and matrix calls, not virtual resolution friendly at all I am afraid.


GC-Martijn(Posted 2015) [#9]
I'm searching for a one file class simple gui for glfw (desktop only).
So I'm very happy with this, except its not working :( :(

First it was complaining about Private bla, so I removed some Private things.
Now its saying
eazyGadget.monkey<450> : Error : Identifier 'SetScissor' not found.

But then I tought let add this line at top of the file
Import mojo

And i'm using strict so the code I'm using was
txtInput.Update()
		If butSend.Update() Then 
			Print txtInput.Value()
			txtInput.Clear()
		End


And now I can see the sample inside my game !
Hoping that the slider is working


Supertino(Posted 2015) [#10]
You might want to try this version, its a newer version without all the scissors and other fancy stuff, cleaner code too and some nicer gadgets.



Working example



GC-Martijn(Posted 2015) [#11]
going to check that tomorrow !
edit: Yep the code is looking better, and now with real sizes (instead of -2 or +2 etc) ;)


Supertino(Posted 2015) [#12]
Still not as featured as I'd like it, but each version should get better.