Simple Controls System [GUI]

A place to show off your latest screenshots and for people to comment on them. Only start a new thread here if you have some nice images to show off!
Post Reply
User avatar
Wasted
Gnoblar
Posts: 19
Joined: Thu Mar 20, 2008 11:50 pm
Location: Poland
Contact:

Simple Controls System [GUI]

Post by Wasted »

I would like to introduce my simple controls system. It is simple GUI. My idea is based on BetaGUI. Last version of BetaGUI I found has numerous lacks and it is very very simple and unreadable, while I was needing something more than it but smaller than big GUI systems (MyGui etc.), so I decided to write this. I use it in my commercial games tools, but I would like to share it with the community. Maybe someone need something like this too.

But main aim of releasing it is to let community develop many new cool controls :)

GUI has no name, it is just pack of overlay based controls. Main features now are:
- No additional libraries needed
- Very simple to use!
- Very easy to create new control type
- Perfect for map editors, character editors etc.
- Controls: Form, Label, Edit, Button, Scrollbar, Number (like the Blender3D number fields with mouse "scrolling")

Some rules:
- All controls must be children of Form
- Control shoud have unique name

And instruction:

1. Creating the system

Code: Select all

Interface::ControlMgr myControlMgr;

myControlMgr.Initialise("BlueHighway", 16);
myControlMgr.CreateMouse(mMouse, "bgui.pointer", 32, 32);
myControlMgr.CreateKeyboard(mKeyboard);
myControlMgr.MaterialButton=	"bgui.button";
myControlMgr.MaterialButtonPressed="bgui.button.active";
myControlMgr.MaterialForm=	"bgui.window";
myControlMgr.MaterialHeader=	"bgui.window.titlebar";
myControlMgr.MaterialEdit = "bgui.textinput";
myControlMgr.MaterialEditFocused = "bgui.textinput.active";
As you can see, I have used material from BetaGUI, because it looks quite good. Small number of materials means that controls doesn't look as cool as in MyGui, but appeareance is not the main point of my system :P
mMouse and mKeyboard are just OIS::... pointers.

2. Updating GUI

Code: Select all

myControlMgr.Update(TimeDelta);
Only this function is needed to update GUI. Nothing more :)

3. Creating controls :)
3.1 Setting up Form

Code: Select all

Interface::ControlForm *myForm=new Interface::ControlForm("my cool form name", myControlMgr.Root);
myForm->Caption="My Window!";
myForm->X=200;
myForm->Y=200;
myForm->Width=400;
myForm->Height=200;
To set up more controls, you need at least one Form, children of Root. Root can be used only for creating Forms. Function CreateControl took two parameters of string type: control type name and unique control name.

3.2 Let's create button!

Code: Select all

Interface::ControlButton *myButton=new Interface::ControlButton("button name", myForm);
myButton->Caption="Press Me!";
myButton->X=30;
myButton->Y=30;
myButton->Width=100;
myButton->Height=30;
You see? It is the same structure like creating form, except parent - it is not the Root now, but our form.

Buttons usually do something when pressed. It is done by setting event function:

Code: Select all

myButton->OnPressed=myOnPressedFunction;
Event function have to be an void with 0 parameters and it will be executed automaticaly when user press the button (exactly when he release mouse, like in Windows). There is also second way to serve this event: variable (bool) myButton->OnPressedEvent. It is set to true in frame which should execute event.

To see more variables of controls, just see headers.

4. Creating new control type
4.1 Main rule is that all controls must inherits from Control type. Simples one:

Code: Select all

#include "Control.h"

namespace Interface {
class ControlMyType:public Control {
public:
	ControlMyType(Ogre::String name, Control *parent);
	bool Update();
	bool Remove();
};

};

4.4 ctor

Basic contructor must set type name to itself, and define parent and manager like this:

Code: Select all

ControlLabel::ControlLabel(Ogre::String name, Control *parent)
{
	Type="Label";
	Name=name;
	Parent=parent;
	Manager=parent->Manager;
... 
...
...
	Parent->AddChildren(this);

};
In constructor you can create overlays etc, have a look into controls which are already done.


Thats all. I think it is very simple code to modify.

I'll create new controls sometime (but only ones which I need to my work)
If you create some new controls, you can post but it would be nice if you'll keep the existing notation:
- ControlTypeName.cpp and ControlTypeName.h
- Names of variables and methods started with capital.
- class named Control{Type name}
- no additional libraries, to keep simplicity

Links:

Source: http://www.sendspace.com/file/wingk6
Video (utube): http://www.youtube.com/watch?v=TqHwbeH7XsU
Video (file): http://www.sendspace.com/file/y56fc5
Screen:
Image
Last edited by Wasted on Mon Jun 30, 2008 10:19 am, edited 6 times in total.
User avatar
betajaen
OGRE Moderator
OGRE Moderator
Posts: 3447
Joined: Mon Jul 18, 2005 4:15 pm
Location: Wales, UK
x 58
Contact:

Post by betajaen »

Good work! You are right about BetaGUI and I'm glad you started on your own project rather than extend it or worst go overboard.

For the record; I am working on a new BetaGUI (most likely with a different name) and it will be nothing like any of the GUI systems we have for Ogre.
User avatar
nullsquared
Old One
Posts: 3245
Joined: Tue Apr 24, 2007 8:23 pm
Location: NY, NY, USA
x 9

Post by nullsquared »

betajaen wrote: For the record; I am working on a new BetaGUI (most likely with a different name) and it will be nothing like any of the GUI systems we have for Ogre.
Will it be able to arbitrarily render to any target whatsoever, on demand? That's why I'm sticking with QuickGUI (not that it has no other benefits, but this is what is most important to me), since all of the other GUI's are in one way or another tied to the concept of a single GUI rendered on top of the main scene in a window.
User avatar
Wasted
Gnoblar
Posts: 19
Joined: Thu Mar 20, 2008 11:50 pm
Location: Poland
Contact:

Post by Wasted »

Will it be able to arbitrarily render to any target whatsoever, on demand?
I'm wondering how to create 'aero glass' effect. I know that I need to render things behind the window to render target and apply blur shader and use it as window form background... But I don't think that rendering things behind window is possible :/
User avatar
betajaen
OGRE Moderator
OGRE Moderator
Posts: 3447
Joined: Mon Jul 18, 2005 4:15 pm
Location: Wales, UK
x 58
Contact:

Post by betajaen »

nullsquared wrote:Will it be able to arbitrarily render to any target whatsoever, on demand?
Perhaps. I was planning to use my own image library to draw on the buttons onto a texture, so there is no reason why it can't be redirected to a material/mesh than a overlay.

What I was referring to was how the GUI system is implemented into ones code and that is very different from the others.
User avatar
KungFooMasta
OGRE Contributor
OGRE Contributor
Posts: 2087
Joined: Thu Mar 03, 2005 7:11 am
Location: WA, USA
x 16
Contact:

Post by KungFooMasta »

Nice! GUIs can get really complex really fast, its good to have light alternatives.
For the record; I am working on a new BetaGUI (most likely with a different name) and it will be nothing like any of the GUI systems we have for Ogre.
Keep us posted. :twisted:
Creator of QuickGUI!
User avatar
Wasted
Gnoblar
Posts: 19
Joined: Thu Mar 20, 2008 11:50 pm
Location: Poland
Contact:

Changes

Post by Wasted »

I noticed that adding new control types could be done much more easly, so I modified the code. Also the way of adding new controls is changed.

//EDIT: all changes in first post

Updated Code link: http://www.sendspace.com/file/wingk6
User avatar
Wasted
Gnoblar
Posts: 19
Joined: Thu Mar 20, 2008 11:50 pm
Location: Poland
Contact:

New control - ControlImage

Post by Wasted »

This is new control: ControlImage.

ControlImage.h
ControlImage.cpp

Special Properties:
Ogre::String Material; - Specify material name for image. You can put video, or RTT texture.... everything that material system allow you to do.

Screen:
Image
User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19265
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 66
Contact:

Post by sinbad »

Nice work. I swear we must have the record for the highest number of GUI system options now :) Choice is a good thing!
couple4ever
Gnoblar
Posts: 8
Joined: Thu Feb 26, 2009 4:02 pm

Re: Changes

Post by couple4ever »

Wasted wrote:I noticed that adding new control types could be done much more easly, so I modified the code. Also the way of adding new controls is changed.

//EDIT: all changes in first post

Updated Code link: http://www.sendspace.com/file/wingk6
-> Link dies.

Plz reup
Kosmos
Kobold
Posts: 29
Joined: Mon Aug 01, 2011 5:08 pm
Location: Russia

Re: Simple Controls System [GUI]

Post by Kosmos »

erm, could anyone reupload it somewhere?
User avatar
amigoface
Greenskin
Posts: 132
Joined: Mon Oct 13, 2008 3:01 pm

Re: Simple Controls System [GUI]

Post by amigoface »

maybe i am wrong but it looks like this one
http://www.ogre3d.org/addonforums/viewf ... 93d03346fe
Post Reply