Page 1 of 12
BetaGUI : BetaGUI 2.5 update - Style system added.
Posted: Tue Nov 07, 2006 8:23 pm
by betajaen
Introduction
BetaGUI is a small project I've been working on for the last day to implement a GUI system into the NxOgre tutorials without any dependencies but Ogre.
It's main features, which I like to call the core 7 are:
- Create a Window.
- Move that Window around.
- Resize it.
- Create a Button in a window
- When that button is pushed call some code
- Create a textual input gadget in a window
- Create some plain text in a window
That's it. The entire feature list. What it doesn't make up in feature list sizes it makes up in functionality, as BetaGUI can do the two main things of a GUI. Respond to an action and receive some input, any GUI system you make from it will use those as a foundation.
Your probably thinking CEGUI or OpenGUI is better, I agree with you. But your missing the point. BetaGUI isn't meant to be a competitor, it's meant for those small applications that don't need 4 other libraries and a load of resources to run, or when your programming your core of your code, and you just want to test it out without fiddling with XML files. That is the usage right there.
Oh, I should point out again the source is 264 lines long and completely unreadable!
Usage
The demo above is one of the NxTutorials, for those non-NxOgre users out there; A NxTutorial is just a tutorial explaining some feature. In this case Spheres and torque.
Super imposed on the screen is an BetaGUI window made up of a Button, some StaticText and a InputText, stylised with several materials.
It was created as so:
Code: Select all
BetaGUI::Window* window = mGUI->createWindow(Vector4(100,100,250,100), "bgui.window", true, true);
window->createStaticText(Vector4(4,22,198,40), "Create one or more bodies:");
mAddButton = window->createButton(Vector4(108,50,104,24), "bgui.button", "Add", BetaGUI::Callback(this));
mAmount = window->createTextInput(Vector4(4,50,104,24), "bgui.text104", "1", 3);
Nice and simple.
Bugs
The captions on the buttons and TextInput will not center. I am running Eihort CVS so I do not know if the bug is in Dagon.
Download
The full download , usage instructions, basically everything is on the
Wiki page.
I wish you all the best using it, and I expect there will be quite a few forks in the future

Posted: Tue Nov 07, 2006 8:59 pm
by jacmoe
Totally awesome, betajaen!
Are you saying that it requires absolutely no external dependencies, besides Ogre itself?
And that you can use it with stock (un-patched) Ogre?
Wow.

Posted: Tue Nov 07, 2006 9:04 pm
by betajaen
Yep!
It just uses overlays and materials, anything else would be too complicated and unneeded.
Posted: Tue Nov 07, 2006 9:21 pm
by colezero
Great, this is really awesome, for how long did i look for an easy-to-use GUI like that? Thx, really thats great..Its simple and usefull..
Posted: Tue Nov 07, 2006 9:35 pm
by rUmbl3
wow! thats really awesome

never thought that such a little gui could be that easy

a listbox kind of widget and i would throw cegui away

Posted: Tue Nov 07, 2006 9:39 pm
by betajaen
If I implemented a destroyWindow function, you could mimic it with a button, once pressed a window would appear containing a few buttons; The choices, once any of those have been pressed then the window is destroyed.
Simple.
Posted: Tue Nov 07, 2006 9:44 pm
by rUmbl3
hm listbox in cegui is something else. You would add a text at the bottom and all the other text goes one step up. I will have a look at your code .. maybe i can implement that ..

Posted: Tue Nov 07, 2006 9:48 pm
by jacmoe
I hope BetaGUI continues to stay small and sexy!
Leave ListBoxes and things like that for CEGUI.
And roll up your sleeves if you want it there. IMO.
Version 0.6.x is about adding new widgets, AFAIK.
Posted: Tue Nov 07, 2006 9:51 pm
by rUmbl3
Well you could see things like that as little "Addons" for betaGUI to enhance the functionality! Of course they should also stay small and sexy like you called it

Posted: Tue Nov 07, 2006 9:59 pm
by betajaen
rUmbl3 wrote:hm listbox in cegui is something else. You would add a text at the bottom and all the other text goes one step up. I will have a look at your code .. maybe i can implement that ..

Ahh. The nearest to that would be StaticText. Anything complicated as that would be creating a new class, a new vector in Window, mouse checking code and so on.
Like Jacmoe says it has to be Small and Sexy.
Posted: Tue Nov 07, 2006 10:13 pm
by jacmoe
I just checked out the BetaGUI Wiki page!
Is that source great, or what? I will grab it and put it in my programs at once!
One little suggestion: Add
#include <ogre.h> to the source listing.
Otherwise we'll get zillions of complaints about it not working.
Posted: Tue Nov 07, 2006 10:21 pm
by betajaen
You might want to re-download it as I've implemented the destroyWindow function.
And the source is down to 254 lines. Well 255 thanks to your #include "Ogre.h" bit.

Posted: Tue Nov 07, 2006 10:23 pm
by rUmbl3
I found a little g++ specific bug! You need to change all the friend * thingies to friend class * or every g++ user will have hundreds of errors.
Posted: Tue Nov 07, 2006 10:28 pm
by betajaen
Done. I think.
232 Lines. (Blank lines are the devils playthings

)
Posted: Tue Nov 07, 2006 10:30 pm
by jacmoe
Gah!
How many times must I download this thing!

Posted: Tue Nov 07, 2006 10:31 pm
by betajaen
Download!? It's copying and pasting!
I can get it down by another 4-5 lines, but I'll let the dust settle

WOW!
Posted: Wed Nov 08, 2006 8:58 am
by irrdev
Wow! This is great! A ton better than CEGUI for implimenting some simple window features in a game!

Posted: Wed Nov 08, 2006 11:49 am
by Wretched_Wyx
Very nice, per usual. It never ceases to amaze me how much functionality, or at least usability one can cram into such a small amount of code. Ever since I first saw a 4k demo from the good ol' (and still going) days, this has intrigued me.
Do you have any other planned features for BetaGUI?
Posted: Wed Nov 08, 2006 12:20 pm
by betajaen
Wretched_Wyx wrote:Very nice, per usual. It never ceases to amaze me how much functionality, or at least usability one can cram into such a small amount of code. Ever since I first saw a 4k demo from the good ol' (and still going) days, this has intrigued me.
I remember on the days on the Amiga, one particular language AMOS (I'm sure there is a few people here who can remember it), had a few competitions now and again by creating a game using only 10 lines of code.
Of course you could cheat and put multiple statements per line.
Wretched_Wyx wrote:Do you have any other planned features for
BetaGUI?
Nope, apart from bug fixes, and maybe having the title bar having it's own material; thats it. No more features, anything other GUI gadgets/widgets can be replicated via those three anyway.
[Edit]
I've posted revision 007, it's 187 lines now.
No major features added, but I've made it so you can split the code up between the .h and .cpp now. Just look really closely for the line that says " Optional Seperate Code that goes into a .cpp part", then cut and paste downwards.
Posted: Wed Nov 08, 2006 9:08 pm
by betajaen
Well I've done the impossible.
I've condensed the code down to an amazing 99 lines, but wait. I've actually added some features.
- Mouse pointer! - Activate it via mGUI->createMousePointer();
- Create Window uses enumerators - Much easier to read than those bools.
- Window Captions and own material - The window can have it's own caption and it's own material like the resizer it goes windowmaterialname.titlebar
That's it, I won't be adding anymore features. Like Jacmoe said "small and sexy". But I'll have a go at fixing the centering text problem.
Enjoy!

Posted: Wed Nov 08, 2006 9:16 pm
by Game_Ender
You don't actually edit the 99 line version do you? It looks more like the obfuscated C contest. Small is sexy, but so is maintability

. Oh yes, and it renforces my sterotype that most windows programmers don't know how to make code that is 80 characters per line. Now that would be sexy

.
Posted: Wed Nov 08, 2006 9:44 pm
by jacmoe
betajaen wrote:That's it, I won't be adding anymore features.
I wonder how many times betajaen will say that ..
Anyway, this is totally awesome!
<Gah! The feature is already there! />

Posted: Wed Nov 08, 2006 10:08 pm
by betajaen
Actually I lied. This it, last time. Ever.
Revision 011 - 99 lines
Features:
- Fixed/Hacked the "center" bug. They are all aligned to the left, but vertically to the middle.
- TextInput's now have an active state. Quite pretty really.
I've also added the images and materials I use as a resource set. So in theory you'll be up and running in less than a minute
Details and download are all on the wiki page.
Alright that's it for now.
Posted: Wed Nov 08, 2006 10:13 pm
by DaCracker
Fancy stuff!

Posted: Wed Nov 08, 2006 11:00 pm
by big_o
Whoaaaah!!!
Awesome, but you weren't kidding when you said it was unreadable.
Two small requests/questions (I can't really telll what is implemented and what isn't). I need to get the mouse position back from the menu for aiming purposes, is this already in there? and is it possible to add some kind of enumerator that allows the text when a label is created.
Why are there two publics on the callback example?
This looks very awesome though, and I will be trying to implementing it soon.