BetaGUI
Minimal GUI overlay system
- License Public Domain
- Status Stable
- Dependencies Ogre 1.2+
- Latest Version 1.0'15
- Instructions Code Usage and Examples
- Support Forum Thread
- Lead Developer Betajaen(Ogre Expert User)
- Start Date 07-Nov-2006
What it does and what it does not do
Using overlays it is capable of doing seven things:
- Creating a Window
- Resizing the window via a bottom-right button.
- Moving the window around via a top bar button.
- Creating a push button in a window with a inactive and active material state.
- Calling back to a function or class to report when that button has been "pushed"
- Creating a functional text gadget on a window to accept textual input to n characters.
- Creating a static piece of text on a window.
It does nothing more or nothing less.
A video demonstrating the features 1.26Mb, playable in VLC.
BetaGUI is an incredibly small, very free to use, and incredibly unreadable piece of code that creates a fully working {LEX()}GUI{LEX} system with no external libraries except for Ogre.
So whats the point if it can't do feature x?
You may ask, whats the point? {LEX()}CEGUI{LEX} or OpenGUI can do the same but 10x as better, yes it can. But perhaps you don't want the dependencies or perhaps your application is brand new and you just really wanted to get the core of it done and out of the away with before messing around with XML layouts.
What it is the differences between a fully features GUI library, once you get to that point. Then BetaGUI is no longer for you.
Download and Usage
This is the full source right here, it depends on nothing except for Ogre. Just paste it into a header file and you should be good to go. It is under the Whatevar! licence. Do what you want to do it, just keep the original copyright header in the code.
C++ Version
Code
015 Version - 88 Lines, by Betajaen
/// Betajaen's GUI 015 /// Written by Robin "Betajaen" Southern 07-Nov-2006, http://www.ogre3d.org/wiki/index.php/BetaGUI /// This code is under the Whatevar! licence. Do what you want; but keep the original copyright header. /// This code is not meant to be readable, if you base your future source on this, I will laugh at you. #include "Ogre.h" using namespace Ogre;using namespace std;namespace BetaGUI {class GUI;class Window;class Button; class TextInput;class Callback;enum wt{NONE=0,MOVE=1,RESIZE=2,RESIZE_AND_MOVE=3}; class GUI{public:friend class Window;friend class Button;friend class TextInput; GUI(String font, uint fontSize);~GUI(); bool injectMouse(uint x, uint y, bool LMB); bool injectKey(String key, uint x, uint y);void injectBackspace(uint x, uint y){injectKey("!b",x,y);} Window* createWindow(Vector4,String,wt,String c="");void destroyWindow(Window *w){mXW=w;} OverlayContainer* createOverlay(String,Vector2,Vector2,String m="",String="",bool a=true); OverlayContainer* createMousePointer(Vector2 size,String material);protected:uint wc,bc,tc; Overlay* mO;vector<Window*>WN;Window *mXW;OverlayContainer* mMP;String mFont;uint mFontSize;}; class Window{public:friend class Button;friend class TextInput;friend class GUI; Button* createButton(Vector4 Dimensions, String Material, String Text, Callback callback); TextInput* createTextInput(Vector4 Dimensions, String Material, String Value, uint length); void createStaticText(Vector4 Dimensions, String Text); void hide(){mO->hide();}void show(){mO->show();}bool isVisible(){return mO->isVisible();} protected:Window(Vector4 Dimensions, String Material, wt type, String caption, GUI *gui);~Window(); bool check(uint x, uint y, bool LMB); bool checkKey(String key, uint x, uint y);TextInput* mATI; Button *mRZ,*mAB,*mTB;uint x,y,w,h;GUI *mGUI;OverlayContainer* mO;vector<BetaGUI::Button*>mB;vector<BetaGUI::TextInput*>mT;}; class BetaGUIListener{public:virtual void onButtonPress(Button *ref) = 0;}; class Callback{public:friend class Window;friend class Button;Callback(){t=0;} Callback(void(*functionPointer)(Button *ref)){t=1;fp=functionPointer;} Callback(BetaGUIListener *L){t=2;LS=L;}protected:uchar t;void(*fp)(Button *r);BetaGUIListener *LS;}; class Button{public:friend class Window;protected: Button(Vector4 Dimensions, String Material, String Text, Callback callback, Window *parent); ~Button(){mO->getParent()->removeChild(mO->getName());mCP->getParent()->removeChild(mCP->getName());} void activate(bool a){if(!a&&mmn!="")mO->setMaterialName(mmn);if(a&&mma!="")mO->setMaterialName(mma);} bool in(uint mx,uint my,uint px,uint py) {return(!(mx>=x+px&&my>=y+py))||(!(mx<=x+px+w&&my<=y+py+h));} OverlayContainer* mO,*mCP;String mmn,mma;Callback callback;uint x,y,w,h;}; class TextInput{protected: friend class Window; TextInput(Vector4 Dimensions, String Material, String Value, uint length, Window *parent);~TextInput(){} bool in(uint mx,uint my,uint px,uint py) {return(!(mx>=x+px&&my>=y+py))||(!(mx<=x+px+w&&my<=y+py+h));} OverlayContainer* mO,*mCP;String mmn,mma,value;uint x,y,w,h,length; public:String getValue(){return value;}void setValue(String v){mCP->setCaption(value=v);}}; }
/*** Optional Seperate Code that goes into a .cpp part : Cut downwards and paste ***/ using namespace Ogre;using namespace std;namespace BetaGUI { GUI::GUI(String font, uint fontSize):mXW(0), mMP(0),mFont(font),mFontSize(fontSize),wc(0),bc(0),tc(0){ mO=OverlayManager::getSingleton().create("BetaGUI");mO->show();} GUI::~GUI(){for(uint i=0;i < WN.size();i++)delete WN[i];WN.clear();} bool GUI::injectMouse(uint x,uint y,bool LMB){if(mMP)mMP->setPosition(x,y); if(mXW){for(vector<Window*>::iterator i=WN.begin();i!=WN.end();i++) {if(mXW==(*i)){delete mXW;WN.erase(i);mXW=0;return false;}}} for(uint i=0;i<WN.size();i++){if(WN[i]->check(x,y,LMB)){return true;}}return false;} bool GUI::injectKey(String key, uint x,uint y){for(uint i=0;i<WN.size();i++){if(WN[i]->checkKey(key,x,y)){return true;}}return false;} OverlayContainer* GUI::createOverlay(String N,Vector2 P,Vector2 D,String M,String C,bool A){String t="Panel";if (C!="")t="TextArea"; OverlayContainer* e=static_cast<OverlayContainer*>(OverlayManager::getSingleton().createOverlayElement(t, N)); e->setMetricsMode(GMM_PIXELS);e->setDimensions(D.x,D.y);e->setPosition(P.x,P.y);if (M!="")e->setMaterialName(M); if (C!=""){e->setCaption(C);e->setParameter("font_name",mFont);e->setParameter("char_height",StringConverter::toString(mFontSize));} if(A){mO->add2D(e);e->show();}return e;} OverlayContainer* GUI::createMousePointer(Vector2 d, String m) { Overlay* o=OverlayManager::getSingleton().create("BetaGUI.MP");o->setZOrder(649);mMP=createOverlay("bg.mp",Vector2(0,0),d,m,"", false); o->add2D(mMP);o->show();mMP->show();return mMP;} Window* GUI::createWindow(Vector4 D,String M, wt T,String C){Window* w=new Window(D,M,T,C,this);WN.push_back(w);return w;} Window::Window(Vector4 D,String M, wt t,String C, GUI *G):x(D.x),y(D.y),w(D.z),h(D.w),mGUI(G),mTB(0),mRZ(0),mATI(0),mAB(0){ mO=G->createOverlay("BetaGUI.w"+StringConverter::toString(G->wc++),Vector2(D.x,D.y),Vector2(D.z,D.w),M); if(t>=2){Callback c;c.t=4;mRZ=createButton(Vector4(D.z-16,D.w-16,16,16),M+".resize","",c);} if(t==1||t==3){Callback c;c.t=3;mTB=createButton(Vector4(0,0,D.z,22),M+".titlebar",C,c);}} Window::~Window(){for(uint i=0;i<mB.size();i++)delete mB[i];for(uint i=0;i<mT.size();i++)delete mT[i];mGUI->mO->remove2D(mO);} Button* Window::createButton(Vector4 D,String M,String T,Callback C) {Button *x=new Button(D,M,T,C,this);mB.push_back(x);return x;} Button::Button(Vector4 D, String M, String T, Callback C, Window *P):x(D.x),y(D.y),w(D.z),h(D.w),mmn(M),mma(M){ ResourcePtr ma=MaterialManager::getSingleton().getByName(mmn+".active");if(!ma.isNull())mma+=".active"; mO=P->mGUI->createOverlay(P->mO->getName()+"b"+StringConverter::toString(P->mGUI->bc++),Vector2(x,y),Vector2(w,h),M,"",false); mCP=P->mGUI->createOverlay(mO->getName()+"c",Vector2(4,(h-P->mGUI->mFontSize)/2),Vector2(w,h),"",T,false); P->mO->addChild(mO);mO->show();mO->addChild(mCP);mCP->show();callback=C;} TextInput* Window::createTextInput(Vector4 D,String M,String V,uint L){TextInput *x=new TextInput(D,M,V,L,this);mT.push_back(x);return x;} void Window::createStaticText(Vector4 D,String T){OverlayContainer* x=mGUI->createOverlay(mO->getName()+StringConverter::toString(mGUI->tc++), Vector2(D.x,D.y),Vector2(D.z,D.w),"", T,false);mO->addChild(x);x->show();} TextInput::TextInput(Vector4 D,String M,String V,uint L,Window *P):x(D.x),y(D.y),w(D.z),h(D.w),value(V),mmn(M),mma(M),length(L) { ResourcePtr ma=Ogre::MaterialManager::getSingleton().getByName(mmn+".active");if(!ma.isNull())mma+=".active"; mO=P->mGUI->createOverlay(P->mO->getName()+"t"+StringConverter::toString(P->mGUI->tc++) ,Vector2(x,y),Vector2(w,h),M,"",false); mCP=P->mGUI->createOverlay(mO->getName()+"c",Vector2(4,(h-P->mGUI->mFontSize)/2),Vector2(w,h),"",V,false); P->mO->addChild(mO);mO->show();mO->addChild(mCP);mCP->show();} bool Window::checkKey(String k, uint px, uint py){if(mATI==0)return false;if(!mO->isVisible())return false; if(!(px>=x&&py>=y)||!(px<=x+w&&py<=y+h))return false;if(k=="!b"){mATI->setValue(mATI->value.substr(0,mATI->value.length()-1)); return true;}if(mATI->value.length() >= mATI->length)return true;mATI->mCP->setCaption(mATI->value+=k);return true;} bool Window::check(uint px, uint py, bool LMB){if(!mO->isVisible())return false; if(!(px>=x&&py>=y)||!(px<=x+w&&py<=y+h)){if(mAB){mAB->activate(false);}return false;} if(mAB){mAB->activate(false);}for(uint i=0;i<mB.size();i++){if (mB[i]->in(px,py,x,y))continue; if(mAB){mAB->activate(false);}mAB=mB[i];mAB->activate(true);if(!LMB)return true; if(mATI){mATI->mO->setMaterialName(mATI->mmn);mATI=0;}switch(mAB->callback.t){default: return true; case 1:mAB->callback.fp(mAB);return true;case 2:mAB->callback.LS->onButtonPress(mAB);return true; case 3:mO->setPosition(x=px-(mAB->w/2),y=py-(mAB->h/2));return true;case 4:mO->setDimensions(w=px-x+8,h=py-y+8); mRZ->mO->setPosition(mRZ->x=w-16,mRZ->y=h-16);if(mTB){mTB->mO->setWidth(mTB->w=w);}return true;}}if (!LMB)return true; for(uint i=0;i<mT.size();i++){if(mT[i]->in(px,py,x,y))continue;mATI=mT[i];mATI->mO->setMaterialName(mATI->mma);return true;} if(mATI){mATI->mO->setMaterialName(mATI->mmn);mATI=0;}return true;} } // End of Betajaen's GUI. Normal programming can resume now.
Uncompressed version...
/// Betajaen's GUI 015 Uncompressed /// Written by Robin "Betajaen" Southern 07-Nov-2006, http://www.ogre3d.org/wiki/index.php/BetaGUI /// This code is under the Whatevar! licence. Do what you want; but keep the original copyright header. #include "Ogre.h" using namespace Ogre; using namespace std; namespace BetaGUI { /// This code is not meant to be readable, if you base your future source on this, I will laugh at you. class GUI; class Window; class Button; class TextInput; class Callback; enum wt { /* Window Type */ NONE=0, MOVE=1, RESIZE=2, RESIZE_AND_MOVE=3 }; class GUI { public: friend class Window; friend class Button; friend class TextInput; GUI(String font, uint fontSize); ~GUI(); bool injectMouse(uint x, uint y, bool LMB); bool injectKey(String key, uint x, uint y); void injectBackspace(uint x, uint y); Window* createWindow(Vector4 Dimensions, String Material, wt type, String caption = ""); void destroyWindow(Window *window) { mXW=window; } OverlayContainer* createOverlay(Ogre::String name, Vector2 position, Vector2 dimensions, Ogre::String material = "", Ogre::String caption = "", bool autoAdd = true); OverlayContainer* createMousePointer(Vector2 dimensions, Ogre::String material); protected: Overlay* mO; // Main sheet overlay vector<Window*>WN; // Windows Window *mXW; // Window to destroy OverlayContainer* mMP; // Mouse Pointer Overlay String mFont; uint mFontSize; uint wc, bc, tc; }; class Window { public: friend class Button; friend class TextInput; friend class GUI; Button* createButton(Vector4 Dimensions, String Material, String Text, Callback callback); TextInput* createTextInput(Vector4 Dimensions, String Material, String Value, uint length); void createStaticText(Vector4 Dimensions, String Text); void hide(){ mO->hide(); } void show(){ mO->show(); } bool isVisible() { return mO->isVisible(); } protected: Window(Vector4 Dimensions, String Material, wt type, String caption, GUI *gui); ~Window(); bool check(uint x, uint y, bool LMB); bool checkKey(String key, uint x, uint y); TextInput* mATI; // Active TextInput Button *mRZ,*mAB,*mTB; // Resizer, ActiveButton, Titlebar uint x,y,w,h; // Dimensions GUI *mGUI; // mGUI pointer OverlayContainer* mO; // Overlay vector<BetaGUI::Button*> mB; // Buttons vector<BetaGUI::TextInput*> mT; // TextInputs }; class BetaGUIListener { public: virtual void onButtonPress(Button *ref) = 0; }; class Callback { public: friend class Window; friend class Button; Callback() { t=0; } Callback( void(*functionPointer)(Button *ref) ) { t=1; fp = functionPointer; } Callback(BetaGUIListener *l){ t = 2; LS = l; } protected: uchar t; // Type of callback: 0 - None, 1 - FunctionPointer 2 - GUIListener, 3 - Move Window, 4 - Resize void(*fp)(Button *ref); // Function pointer (if 1) BetaGUIListener *LS; // GuiListener (if 2) }; class Button { public: friend class Window; Button(Vector4 Dimensions, String Material, String Text, Callback callback, Window *parent); ~Button() { mO->getParent()->removeChild(mO->getName()); mCP->getParent()->removeChild(mCP->getName()); } protected: void activate(bool a) { if (!a && mmn!="") mO->setMaterialName(mmn); if (a && mma!="") mO->setMaterialName(mma); } bool in(uint mx, uint my, uint px, uint py) { return ( !(mx >= x + px && my >= y + py)) || ( ! (mx <= x + px + w && my <= y + py + h) ); } OverlayContainer* mO,*mCP; // Main Overlay and Caption String mmn,mma; // MaterialName Normal, MaterialName Active BetaGUI::Callback callback; // Callback to use uint x,y,w,h; // Dimensions. }; class TextInput { public: friend class Window; TextInput(Vector4 Dimensions, String Material, String Value, uint length, Window *parent); ~TextInput(){} String getValue() { return value; } void setValue(String v) { mCP->setCaption(value=v); } protected: bool in(uint mx, uint my, uint px, uint py) { return ( !(mx >= x + px && my >= y + py)) || ( ! (mx <= x + px + w && my <= y + py + h) ); } OverlayContainer* mO,*mCP; String mmn, mma, value; uint x,y,w,h,length; }; } // End of Namespace /*** Optional Seperate Code that goes into a .cpp part : Cut downwards and paste ***/ using namespace Ogre; using namespace std; namespace BetaGUI { GUI::GUI(String font, uint fontSize) :mXW(0), mMP(0), mFont(font), mFontSize(fontSize), wc(0), bc(0), tc(0) { mO = OverlayManager::getSingleton().create("BetaGUI"); mO->show(); } GUI::~GUI() { for(uint i=0;i < WN.size();i++) delete WN[i]; WN.clear(); } bool GUI::injectMouse(uint x, uint y, bool LMB) { if (mMP) mMP->setPosition(x,y); if (mXW) { for(vector<Window*>::iterator i=WN.begin();i!=WN.end();i++) { if(mXW==(*i)) { delete mXW; WN.erase(i); mXW=0; return false; } } } for(uint i=0;i<WN.size();i++) { if(WN[i]->check(x,y,LMB)) { return true; } } return false; } bool GUI::injectKey(String key, uint x, uint y) { for(uint i=0;i<WN.size();i++) { if(WN[i]->checkKey(key,x,y)) { return true; } } return false; } void GUI::injectBackspace(uint x, uint y) { injectKey("!b", x, y); } OverlayContainer* GUI::createOverlay(String name, Vector2 position, Vector2 dimensions, String material, String caption, bool autoAdd) { String type="Panel"; if (caption!="") type="TextArea"; OverlayContainer* e=static_cast<OverlayContainer*>(OverlayManager::getSingleton().createOverlayElement(type, name)); e->setMetricsMode(Ogre::GMM_PIXELS); e->setDimensions(dimensions.x, dimensions.y); e->setPosition(position.x, position.y); if (material!="") e->setMaterialName(material); if (caption!="") { e->setCaption(caption); e->setParameter("font_name",mFont); e->setParameter("char_height",StringConverter::toString(mFontSize)); } if(autoAdd) { mO->add2D(e); e->show(); } return e; } OverlayContainer* GUI::createMousePointer(Vector2 d, String m) { Overlay* o = OverlayManager::getSingleton().create("BetaGUI.MP"); o->setZOrder(649); mMP = createOverlay("bg.mp", Vector2(0,0), d, m, "", false); o->add2D(mMP); o->show(); mMP->show(); return mMP; } Window* GUI::createWindow(Vector4 Dimensions, String Material, wt type, String caption) { Window* window = new BetaGUI::Window(Dimensions, Material, type, caption, this); WN.push_back(window); return window; } Window::Window(Vector4 Dimensions, String Material, wt t, String caption, GUI *gui) : x(Dimensions.x), y(Dimensions.y), w(Dimensions.z), h(Dimensions.w), mGUI(gui), mTB(0), mRZ(0), mATI(0), mAB(0) { mO = gui->createOverlay("BetaGUI.w" + StringConverter::toString(gui->wc++), Vector2(Dimensions.x,Dimensions.y), Vector2(Dimensions.z,Dimensions.w), Material); if (t >= 2) { Callback c;c.t=4; mRZ=createButton(Vector4(Dimensions.z-16,Dimensions.w-16,16,16),Material+".resize", "",c); } if (t == 1 || t == 3) { Callback c;c.t=3; mTB = createButton(Vector4(0,0,Dimensions.z,22),Material + ".titlebar", caption, c); } } Window::~Window() { for(uint i=0;i<mB.size();i++) delete mB[i]; for(uint i=0;i<mT.size();i++) delete mT[i]; mGUI->mO->remove2D(mO); } Button* Window::createButton(Vector4 D, String M, String T, Callback C) { Button *x = new Button(D, M, T, C, this); mB.push_back(x); return x; } Button::Button(Vector4 Dimensions, String m, String Text, Callback cb, Window *parent) : x(Dimensions.x), y(Dimensions.y), w(Dimensions.z), h(Dimensions.w), mmn(m), mma(m) { Ogre::ResourcePtr ma=Ogre::MaterialManager::getSingleton().getByName(mmn + ".active"); if(!ma.isNull()) mma += ".active"; mO = parent->mGUI->createOverlay(parent->mO->getName() + "b" + StringConverter::toString(parent->mGUI->bc++), Vector2(x,y),Vector2(w,h),m,"",false); mCP = parent->mGUI->createOverlay(mO->getName() + "c",Vector2(4,(h - parent->mGUI->mFontSize) / 2),Vector2(w, h),"",Text,false); parent->mO->addChild(mO); mO->show(); mO->addChild(mCP); mCP->show(); callback = cb; } TextInput* Window::createTextInput(Vector4 D, String M, String V, uint L) { TextInput *x = new TextInput(D,M,V,L,this); mT.push_back(x); return x; } void Window::createStaticText(Vector4 D, String T) { OverlayContainer* x = mGUI->createOverlay(mO->getName() + StringConverter::toString(mGUI->tc++),Vector2(D.x,D.y),Vector2(D.z,D.w),"", T,false); mO->addChild(x); x->show(); } TextInput::TextInput(Vector4 D, String M, String V, uint L, Window *P) : x(D.x),y(D.y),w(D.z),h(D.w),value(V),mmn(M), mma(M), length(L) { ResourcePtr ma=Ogre::MaterialManager::getSingleton().getByName(mmn + ".active"); if(!ma.isNull()) mma += ".active"; mO=P->mGUI->createOverlay(P->mO->getName() + "t" + StringConverter::toString(P->mGUI->tc++) ,Vector2(x,y),Vector2(w,h),M,"",false); mCP=P->mGUI->createOverlay(mO->getName() + "c",Vector2(4,(h - P->mGUI->mFontSize) / 2),Vector2(w,h),"",V,false); P->mO->addChild(mO); mO->show(); mO->addChild(mCP); mCP->show(); } bool Window::checkKey(String k, uint px, uint py) { if (!mO->isVisible()) return false; if(!(px>=x&&py>=y)||!(px<=x+w&&py<=y+h))return false; if(mATI == 0) return false; if(k=="!b") { mATI->setValue(mATI->value.substr(0,mATI->value.length()-1)); return true; } if(mATI->value.length() >= mATI->length) return true; mATI->mCP->setCaption(mATI->value+=k); return true; } bool Window::check(uint px, uint py, bool LMB) { if (!mO->isVisible()) return false; if (!(px >= x && py >= y) || !(px <= x + w && py <= y + h)) { if (mAB) { mAB->activate(false); } return false; } if (mAB) { mAB->activate(false); } for (uint i=0;i < mB.size();i++) { if (mB[i]->in(px,py,x,y)) continue; if (mAB) { mAB->activate(false); } mAB=mB[i]; mAB->activate(true); if (!LMB) return true; if(mATI) { mATI->mO->setMaterialName(mATI->mmn); mATI=0; } switch(mAB->callback.t) { default: return true; case 1: mAB->callback.fp(mAB); return true; case 2: mAB->callback.LS->onButtonPress(mAB); return true; case 3: mO->setPosition(x=px-(mAB->w/2),y=py-(mAB->h/2)); return true; case 4: mO->setDimensions(w=px-x+8,h=py-y+8); mRZ->mO->setPosition(mRZ->x=w-16,mRZ->y=h-16); if(mTB){ mTB->mO->setWidth(mTB->w=w); } return true; } } if (!LMB) return true; for (uint i=0;i<mT.size();i++) { if (mT[i]->in(px,py,x,y)) continue; mATI=mT[i]; mATI->mO->setMaterialName(mATI->mma); return true; } if(mATI) { mATI->mO->setMaterialName(mATI->mmn); mATI=0; } return true; } } // End of Betajaen's GUI. Normal programming can resume now.
Usage
The usage is very simple. You create the main instance when you start initilasing your application as so:
mGUI = new BetaGUI::GUI("MyFontName",MyFontSize);
And delete it when shutting down:
delete mGUI;
To inject actions into the GUI, in your InputListener you'll need to handle four-ish actions:
mGUI->injectKey(<character>, <pointer x>, <pointer y>); mGUI->injectBackspace(<pointer x>, <pointer y>); // mGUI->injectMouse(<pointer x>, <pointer y>, true); // Mouse key down. mGUI->injectMouse(<pointer x>, <pointer y>, false); // Mouse key not down.
Now to create a window with a few things is just as easy to. Just remember to make sure your material images are the same size as your windows, buttons and textinputs else they will be stretched.
BetaGUI::Window* window = mGUI->createWindow(Vector4(100,100,300,100), "my window material", BetaGUI::RESIZE_AND_MOVE, "Magical Doubler"); window->createStaticText(Vector4(4,22,198,40), "Type in a number and I'll double it!"); BetaGUI::Button* mDoubleIt = window->createButton(Vector4(108,50,104,24), "my button material", "Go on then!", BetaGUI::Callback(myCallback)); BetaGUI::TextInput* mAmount = window->createTextInput(Vector4(4,50,104,24), "my textinput material", "1", 3);
And to finalise it all, you'll need a callback
class myCallbackOrMainClass : public public BetaGUI::BetaGUIListener { ... void onButtonPress(BetaGUI::Button *ref) { if (ref == mDoubleIt) cout << "The answer is:" << StringConverter::parseUnsignedInt(mAmount->getValue()) * 2 << endl; } ... }
Some notes when setting up:
- If your window has a resize option, you will need to create a material called <windowmaterialname>.resize, The image should be 16,16 pixels.
- If your window has a titlebar option, you will need to create a material called <windowmaterialname>.titlebar, The image should be x,22 pixels.
- All of your buttons can have active states just create an extra material with .active at the end, it even applies to resize or titlebars.
- InputText must have a material.
That's it!
C# Version with MOgre
Content moved to MogreBetaGUI.
Perl Version
I ported BetaGUI version 016 to Perl:
browse here.
As an example, I ported Intermediate Tutorial 2,
Intermediate Tutorial 3, and
Intermediate Tutorial 4
(the ones where you place robots with a -CEGUI mouse cursor):
tute 2,
tute 3,
tute 4
Note: you should probably also know there are some (incomplete)
Perl bindings for OGRE
Addons
Further iterations and versions of BetaGUI can be found HERE
Betajaen's GUI Resources
Simple dark transparent look for all GUI parts with active states.
Copy the ZIP to your resources directory and append the following to your resources.cfg
Zip=bguires.zip
Use the following settings when creating your GUI for the correct look
- Pointer Material: "bgui.pointer" Size(32,32)
- Window Material: "bgui.window"
- Button Material: "bgui.button" Size(72,22)
- TextInput Material: "bgui.textinput" Size(100,22) Length(10)
re