The Lo-Fi Apocalypse Forums

kickass indie games!
It is currently Sun Sep 05, 2010 4:21 pm

All times are UTC - 4 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Introducing buttonGUI
PostPosted: Thu Sep 11, 2008 12:26 am 
Offline
L.F.A. TEAM
L.F.A. TEAM
User avatar

Joined: Thu Jun 02, 2005 11:16 pm
Posts: 62
OK, so you may wondering why did anyone bother to write yet another GUI for Ogre? Especially when I do not claim that this one is neither the most powerful nor the most optimized?

Most of the GUI solutions were too complex for what I needed... I just wanted buttons and text fields, the two I found closest to what I needed were Navi and BetaGUI. Here are some of the positives and negatives that led me to make buttonGUI:
*I in no way claim the following to be a comprehensive list of positives and negatives of navi or betaGUI... these are only the ones that relate to buttonGUI.

Navi positives:
- extremely easy and intuitive to use
- very well documented
- fading

Navi negatives:
- not readily multiplatform
- does not allow custom fonts
- requires > 10 MB of dependencies

betaGUI positives:
- extremely easy to setup/integrate
- readily multiplatform
- small yet feature rich
- only dependency is Ogre
- custom font supported

betaGUI negatives
- hit and miss documentation
- not all versions compile
- was hard for me to understand/modify the code (sorry Betajaen, I still think you are awesome though!!)... it could be because i am not a professional programmer.

So I decided to make buttonGUI in an attempt to join the positives of Navi and betaGUI into a single GUI.
...and also in a secret attempt to bump betaGUI from its slot of "GUI to use when you just need something in there to start." (sorry again Betajaen >_<)

betaGUI positives + Navi positives = buttonGUI!!!
- brain-dead easy to setup/integrate
- readily multiplatform
- allows for custom fonts and colors
- fading buttons
- small yet feature rich
- easy and intuitive to use (as much as i could, anyway :P)
- well documented
- only dependency is Ogre (and a little OIS)
- allows 3D meshes on your buttons (idea ripped from myGUI, except not with RTT, mesh is simply loaded into an Overlay)

A special thanks to ajs15822, a bunch of his code is inside buttonGUI, and a special thanks to betajaen ( I think there might be a sliver of betaGUI code left in there too ^_^ )

click for larger:
Image
Image

Here are some details (excerpt from readme):
Quote:
ButtonGUI is based on the idea that there are no widgets, everything is a button.

One of the goals of buttonGUI is to be able to simply drop in buttonGUI.h and buttonGUI.cpp into your project and get started with an a relatively robust GUI system in just a few minutes.

Every button can be configured to report any combination of 4 events (aka enum buttonAction):
    - onClick
    - onRelease
    - mouseOver
    - mouseOff

Every 'button' can have 4 types of children:
    - other buttons
    - textAreas*
    - buttonMeshes*
    - textInputAreas (a special type of button that can send more than the basic 4 events)
* these do not send buttonEvents and are generally handled as attributes of buttons.


So I hope I reached my goal... please keep in mind I am not a professional programmer, but I did my best to make something that anyone could use really quickly and easily.
If you find bugs, need support, or have a feature you would like to add please post them on the LFA forums and let me know.

DOWNLOAD HERE:
BUTTONGUI DEMO
buttonGUI.h
buttonGUI.cpp
buttonGUI.readme (with usage instructions)


buttonGUI might be right for you if:
    you just need an interface in and working quickly
    you don't care for complex widgets, tabs, radio buttons etc.
    you are a beginner or not a professional programmer
    you require a multiplatform solution
    you feel a GUI should be as simple as "user click = GUI DO!"

buttonGUI might NOT be right for you if:
    you will need to have more than 20 separate 2D elements on screen at a time during a game
    your application requires tabs, submenus, sliders or other intricate widgets
    your application requires users to be able to dynamically size GUI windows
PS
I realize the cpp and h are a little bit cumbersome to have several classes in a single file. This is simply for ease of integration.


Top
 Profile  
 
 Post subject: Re: Introducing buttonGUI
PostPosted: Mon Sep 15, 2008 11:58 pm 
Offline
L.F.A. TEAM
L.F.A. TEAM
User avatar

Joined: Thu Jun 02, 2005 11:16 pm
Posts: 62
USAGE INSTRUCTIONS:
Code:
// you must set this on your camera,  or any changes to the resolution or fov will mess up the alignment of any buttonMeshes.
camera->setAutoAspectRatio(true);


//create a text scheme
textScheme myTextScheme("myFont",20, 0,1,0,1);

//instance the buttonManager
buttonMgr = new buttonGUI::buttonManager("myTextAreaMaterial",myTextScheme, sceneMgr,"MainCam");

//create a button
buttonMgr->createButton("building", "buildingMat", buttonPosition(TOP_RIGHT, 300,300), 64,64);

//in your update loop call getEvent() until it returns NULL
void Update()
{
   buttonEvent * e = buttonMgr->getEvent();         //THE FOLLOWING LOOP IS HOW TO GET EVENTS FROM buttonGUI
   while(e)
   {
      handleButtonEvent(e);
      e = buttonMgr->getEvent();         
   }   
   buttonMgr->update();
}

//do something with the event
void handleButtonEvent(buttonEvent * e)
{
   std::string name;
   if (e->actionButton)
      name = *(e->actionButton->getName()) ;  //store the name of the main button.

   if ((e->action == ONCLICK)&&(name == "building"))
   {
         //do stuff...
   }
}

//call this if your resolution ever changes to realign all the buttonMeshes to proper locations.
buttonMgr->resetScreenResolution();


//when you are done.
if (buttonMgr)
{
   buttonMgr->shutdown();
   delete buttonMgr;
   buttonMgr = NULL;
}




Top
 Profile  
 
 Post subject: Re: Introducing buttonGUI
PostPosted: Thu Nov 06, 2008 4:27 pm 
Offline
L.F.A. TEAM
L.F.A. TEAM
User avatar

Joined: Thu Jun 02, 2005 11:16 pm
Posts: 62
ok i fixed some bugs, added some features and updated the source files to 1.1
buttonGUI.h
buttonGUI.cpp

heres the changelist:
buttonGUI 1.1
    children now inherit 'suppressed' from parent on creation.
    changed isVisible() to getVisibility()
    changed isMovable() to getMovable()
    fixed capital D reported a Q
    fixed bug that when you click on a textInputArea it would never show onClick focus material
    added accessor to all buttons from buttonManager
    added accessor to all textAreas from a button
    added ability to limit button movement so that you could make sliders
    added forceMove function to allow the placement of the mouse relative to a specific buttons
    added forceClick function to facilitate the forcing of a button click
    added injectMouseMove override that can use a buttonPosition as input
    added button pref defocusOnSubmit, in case you want to keep a textInputArea focused after text submission

NOTE:
- you can create a slider, but i haven't yet created a mechanism to report its location as a buttonEvent when moved.
- I HAVE NOT UPDATED THE DEMO, DEMO STILL USES 1.0 source.


Top
 Profile  
 
 Post subject: Re: Introducing buttonGUI
PostPosted: Thu Feb 18, 2010 10:48 pm 
Offline
L.F.A. TEAM
L.F.A. TEAM
User avatar

Joined: Thu Jun 02, 2005 11:16 pm
Posts: 62
buttonGUI 1.2 released!
Major features added are:
- setting limits on button movements (this allows for any kind of slider widgets)
- option to make textInputAreas behave as password fields by depicting only *'s
- TAB now cycles through active textInputAreas

the DEMO has been updated and all links have been updated to use 1.2

below is a complete list:

buttonGUI 1.2
    added setInputIsPassword() to textInputAreas to allow masking of password inputs
    added getChildButton() function to button
    added getButtonMesh() function to button
    added getTextScheme() function to button (returns a copy, not a reference to its textScheme)
    added getName() function to buttonMesh
    added getDisplayText to textInputArea (this will return correct text even if the field is a password field)
    added forceClickButton(button*) which will force a click on a button
    added accessors to width/height
    added a getPosition() override that allows access from outside buttonGUI to get position data of a button
    added offsetPositionToScreenCoord() that can move a button to an absolute coordinate without changing its position type from relative to absolute
    added cycleTextInputArea() which can be used to force input into the next textInputArea
    by default i made TAB cycle between active textFields in the order of creation.
    removed forceMove() since its usefullness is generally replaced by forceClickButton()
    put a call to shutdown() into the destructor of buttonManager to reduce possibility for memory leaks.


Top
 Profile  
 
 Post subject: Re: Introducing buttonGUI
PostPosted: Tue Jun 15, 2010 11:58 am 
Offline
L.F.A. TEAM
L.F.A. TEAM
User avatar

Joined: Thu Jun 02, 2005 11:16 pm
Posts: 62
buttonGUI 1.21
this is a small update to fix a memory leak in buttonMeshes.
If you have modified buttonGUI you can uncomment the line with this text:
//TEMPORARILY DISABLING BUTTON DELETION
or of course you can update buttonGUI from the links.
(I forgot to uncomment this line while working on 1.2. thanks to polygon9 for bringing this to my attention)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 4 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group