BetaGUI : BetaGUI 2.5 update - Style system added.
-
Banthia
- Gnoblar
- Posts: 3
- Joined: Thu Jun 01, 2006 6:49 pm
Cool little piece of code, thank you, betajaen. I slipped BetaGUI into an existing overlay abstraction framework that manages simple gui views and state, just a few wrinkles. I did remove the global "using namespace" statements, replacing with the fully qualified Ogre:: and std:: throughout your file, as there were a few ambiguities with other namespaces. Obfuscation, hehe this extra bit didn't hurt 
- nikki
- Old One
- Posts: 2730
- Joined: Sat Sep 17, 2005 10:08 am
- Location: San Francisco
- x 13
- Contact:
Does the uncompressed version you posted earlier have these changes?betajaen wrote:I've added some changes to BetaGUI onto the non-compressed version which handles multiple BetaGUI's at the same time (so you can have different levels of Z-Ordering), another bug fix, and the biggest change the ability to detect mouse overs and mouse outs on buttons.
I get this error (always for number 11):-
Code: Select all
Error #: 6
Function: OverlayManager::createOverlayElement
Description: OverlayElement with name BetaGUI.w11 already exists..
File: c:\ogre\ogrenew\ogremain\src\ogreoverlaymanager.cpp
Line: 549
Stack unwinding: <<beginning of stack>>I am (almost) sure that it crashes only at the number 11 (I have tried not creating some windows, creating extra windows etc.). It isn't that it happens to the same window, just the window called 'BetaGUI.w11'.
- betajaen
- OGRE Moderator

- Posts: 3447
- Joined: Mon Jul 18, 2005 4:15 pm
- Location: Wales, UK
- x 58
- Contact:
Hmm.
I think I may of fixed that problem already. Try it with this uncompressed unreleased version and see how it goes:
http://get.nxogre.org/betagui/
I think I may of fixed that problem already. Try it with this uncompressed unreleased version and see how it goes:
http://get.nxogre.org/betagui/
- nikki
- Old One
- Posts: 2730
- Joined: Sat Sep 17, 2005 10:08 am
- Location: San Francisco
- x 13
- Contact:
- betajaen
- OGRE Moderator

- Posts: 3447
- Joined: Mon Jul 18, 2005 4:15 pm
- Location: Wales, UK
- x 58
- Contact:
- nikki
- Old One
- Posts: 2730
- Joined: Sat Sep 17, 2005 10:08 am
- Location: San Francisco
- x 13
- Contact:
I still get the error (a bit different though):-
GUIBase is the baseOverlayName that I passed to the GUI.
Code: Select all
Error #: 6
Function: OverlayManager::createOverlayElement
Description: OverlayElement with name GUIBase.w11 already exists..
File: c:\ogre\ogrenew\ogremain\src\ogreoverlaymanager.cpp
Line: 549
Stack unwinding: <<beginning of stack>>- betajaen
- OGRE Moderator

- Posts: 3447
- Joined: Mon Jul 18, 2005 4:15 pm
- Location: Wales, UK
- x 58
- Contact:
- betajaen
- OGRE Moderator

- Posts: 3447
- Joined: Mon Jul 18, 2005 4:15 pm
- Location: Wales, UK
- x 58
- Contact:
- nikki
- Old One
- Posts: 2730
- Joined: Sat Sep 17, 2005 10:08 am
- Location: San Francisco
- x 13
- Contact:
In my main menu screen, an arrow is drawn beside the button when the mouse is over it. This was done by creating a window.betajaen wrote:Enlighten me, what was the fix or problem?nikki wrote:Yes! I fixed it blah blah ...
I was thinking that when the uint passed to the callback is zero it means the mouse entered the button (an event), not that it means the mouse is inside the button (called every frame the mouse is in). I created the arrow window whenever this callback function was called with this particular parameter.
So, more than a 1000 windows were created in no time.
Later, I fixed it so that a window is created only when the mouse enters the button.
-
grizzley90
- Gnome
- Posts: 318
- Joined: Wed Jan 18, 2006 7:22 pm
- Location: Montreal, Canada
Is it possible to have a version with full variable names and comments because im trying to translate it to another language and i can't understand what some of the code does and why its there, its really not understandable especially with the really really short variable names. I know its not meant to be readable but still i would like to use it. I dont know if this is possible but i hope it will be.
-
zzgame
- Gnoblar
- Posts: 19
- Joined: Tue May 16, 2006 8:38 am
- Location: bj, china
but I donot Know how to use this code in the wiki:
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.
class myCallbackOrMainClass : public public BetaGUI::BetaGUIListener {
...
void onButtonPress(BetaGUI::Button *ref) {
if (ref == mDoubleIt)
cout << "The answer is:" << StringConverter::parseUnsignedInt(mAmount->getValue()) * 2 << endl;
}
...
}
who can help me thanks!
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.
class myCallbackOrMainClass : public public BetaGUI::BetaGUIListener {
...
void onButtonPress(BetaGUI::Button *ref) {
if (ref == mDoubleIt)
cout << "The answer is:" << StringConverter::parseUnsignedInt(mAmount->getValue()) * 2 << endl;
}
...
}
who can help me thanks!
- nikki
- Old One
- Posts: 2730
- Joined: Sat Sep 17, 2005 10:08 am
- Location: San Francisco
- x 13
- Contact:
-
yarock
- Halfling
- Posts: 42
- Joined: Fri Apr 14, 2006 8:06 pm
add me to that question.. can someone give us a simple exit button example??? please some help here....zzgame wrote:but I donot Know how to use this code in the wiki:
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.
class myCallbackOrMainClass : public public BetaGUI::BetaGUIListener {
...
void onButtonPress(BetaGUI::Button *ref) {
if (ref == mDoubleIt)
cout << "The answer is:" << StringConverter::parseUnsignedInt(mAmount->getValue()) * 2 << endl;
}
...
}
- lonewolff
- Ogre Magi
- Posts: 1207
- Joined: Wed Dec 28, 2005 12:58 am
- x 6
Yeah, some sample code would be great.
I am trying to implement something basic into 'Basic Tutorial 1' from the wiki.
And I get errors like the following;
I am trying to implement something basic into 'Basic Tutorial 1' from the wiki.
And I get errors like the following;
Tutorials for us noobs would be greatly appreciated.mGUI: undeclared identifier //what should it be declared as?
left of '->createWindow' must point to a class/struct/union //what the?
typecast: cannot convert from 'TutorialApplication *const' to 'BetaGUI::callback' //again what the?
- betajaen
- OGRE Moderator

- Posts: 3447
- Joined: Mon Jul 18, 2005 4:15 pm
- Location: Wales, UK
- x 58
- Contact:
Alright, this is what the NxOgre tutorials use.
It's written for OIS/Eihort but it's easily adaptable to the Dagon Input system:
Basic setup Note the: "public BetaGUI::BetaGUIListener"
Create the GUI, Window and Mouse pointer
Handle callbacks
Injecting mouse movement
Injecting a keypress
That's it!
It's written for OIS/Eihort but it's easily adaptable to the Dagon Input system:
Basic setup Note the: "public BetaGUI::BetaGUIListener"
Code: Select all
class SimpleTutorialEihort : public FrameListener, public OIS::KeyListener, public BetaGUI::BetaGUIListener {
BetaGUI::GUI* mGUI;
BetaGUI::Window* mGUI_ExitWindow;
BetaGUI::Button* mGUI_ExitButton;
uint mouseX, mouseY;
bool mShutdown;
Create the GUI, Window and Mouse pointer
Code: Select all
void createGUI() {
mShutdown = false;
mouseX = 0;
mouseY = 0;
// Create the GUI
mGUI = new BetaGUI::GUI("nxogrefont",16);
// Create a window
mGUI_ExitWindow = GUI->createWindow(100,100,200,200), "Wee", BetaGUI::RESIZE_AND_MOVE);
mGUI_ExitButton = mGUI_ExitWindow->createButton(Vector4(4 ,28,100,22), "bgui.button", "Quit", BetaGUI::Callback(this));
// Create the mouse pointer
mPointer = mGUI->createMousePointer(Vector2(32,32), "bgui.pointer");
// OIS setup code goes here.
}
Handle callbacks
Code: Select all
void onButtonPress(BetaGUI::Button *ref) {
if (ref == mGUI_ExitButton)
mShutdown = true;
}
Code: Select all
bool frameStarted(const FrameEvent& evt) {
if (mShutdown)
return false;
const MouseState &ms = mMouse->getMouseState();
// Mouse injection must be absolute position than relative.
mouseX+= ms.relX;
mouseY+= ms.relY;
if (ms.buttons == 1)
mGUI->injectMouse(mouseX, mouseY, true); // LMB is down.
else
mGUI->injectMouse(mouseX, mouseY, false); // LMB is not down.
return true;
}
Code: Select all
bool keyPressed( const KeyEvent &arg ) {
// Injecting a backspace
if (arg.text == 8) {
mGUI->injectBackspace(mPointer->getLeft(), mPointer->getTop());
return true;
}
// Ignore non-printable or "unsafe" characters.
if (arg.text < 32 || arg.text > 126)
return true;
// Convert keycode into a (1 char) string.
string k;
k = static_cast<char>(arg.text);
mGUI->injectKey(k, mouseX, mouseY);
return true;
}
};
-
yarock
- Halfling
- Posts: 42
- Joined: Fri Apr 14, 2006 8:06 pm
thnaks ..
as you see you are ussing in the learning code , without define a mMouse, i make a mMouse a , only for the getmousesate(), but can some one explain me what i do need to put in the params for the getmousesate()!!?????, in the example, was nothing, but... not working 4 me ( dagon user) please i some help
Code: Select all
const MouseState &ms = mMouse->getMouseState();Code: Select all
InputReader *mMouse;-
yarock
- Halfling
- Posts: 42
- Joined: Fri Apr 14, 2006 8:06 pm
sorry the noob question, but what are the equivalents values for thats variables( mMouse, and OIS::FrameListener), y tried wthis ogre inputreader, ogre key and mouse Listeners,,,.... please help
im with Dagon....
im with Dagon....
Last edited by yarock on Fri Dec 01, 2006 1:10 am, edited 1 time in total.
-
yarock
- Halfling
- Posts: 42
- Joined: Fri Apr 14, 2006 8:06 pm
your using BetaGui??, i be so thanksfull if you or some body explain or send a example or compiled tutorial, thanks,
.. and dont matter about input text, i just need a panel with exit button, start button, just that
right now, i can show a pointer, and a gui( w/ betagui), but i dont know the event part, and mouse movement,
.. and dont matter about input text, i just need a panel with exit button, start button, just that
right now, i can show a pointer, and a gui( w/ betagui), but i dont know the event part, and mouse movement,
-
zzgame
- Gnoblar
- Posts: 19
- Joined: Tue May 16, 2006 8:38 am
- Location: bj, china
my code here:
GuiListener.h
#pragma once
#include "BetaGUI.h"
#include "ogre.h"
#include "ExampleFrameListener.h"
#include <OgreEventQueue.h>
class CGuiListener :public ExampleFrameListener, public Ogre::MouseMotionListener, public Ogre::MouseListener
{
public:
CGuiListener(RenderWindow* win, Ogre::Camera* cam,BetaGUI::GUI* m_GUI) : ExampleFrameListener(win,cam)
{
mGUI = m_GUI;
///////
mInputDevice2 = mInputDevice;
mEventProcessor = new Ogre::EventProcessor();
mEventProcessor->initialise(win);
mEventProcessor->startProcessingEvents();
mEventProcessor->addKeyListener(this);
mEventProcessor->addMouseMotionListener(this);
mEventProcessor->addMouseListener(this);
mInputDevice = mEventProcessor->getInputReader();
}
~CGuiListener()
{
mEventProcessor->stopProcessingEvents();
mEventProcessor->removeKeyListener(this);
mEventProcessor->removeMouseMotionListener(this);
mEventProcessor->removeMouseListener(this);
delete mEventProcessor;
mInputDevice = mInputDevice2;
}
virtual void mouseMoved (MouseEvent *e)
{
int a = e->getRelX();
int b = e->getRelY();
int c = mWindow->getWidth();
int d = mWindow->getHeight();
mGUI->injectMouse(e->getX()* mWindow->getWidth(),e->getY() * mWindow->getHeight(),false);
e->consume();
}
virtual void mouseDragged (MouseEvent *e)
{
mouseMoved(e);
}
virtual void keyPressed (KeyEvent *e)
{
Ogre::String key;
char a[2];
a[0] = e->getKeyChar();
a[1] = '\0';
key = a;
mGUI->injectKey(key,5,51);
e->consume();
}
virtual void keyReleased (KeyEvent *e)
{
}
virtual void mousePressed (MouseEvent *e)
{
mGUI->injectMouse(e->getX()* mWindow->getWidth(),e->getY() * mWindow->getHeight(),true);
e->consume();
}
virtual void mouseReleased (MouseEvent *e)
{
mGUI->injectMouse(e->getX()* mWindow->getWidth(),e->getY() * mWindow->getHeight(),false);
e->consume();
}
virtual void keyClicked (KeyEvent *e) {}
virtual void mouseClicked (MouseEvent *e) {}
virtual void mouseEntered (MouseEvent *e) {}
virtual void mouseExited (MouseEvent *e) {}
bool frameStarted(const FrameEvent& evt);
protected:
Ogre::EventProcessor* mEventProcessor;
Ogre::InputReader* mInputDevice2;
BetaGUI::GUI* mGUI;
};
GuiListener.h
#pragma once
#include "BetaGUI.h"
#include "ogre.h"
#include "ExampleFrameListener.h"
#include <OgreEventQueue.h>
class CGuiListener :public ExampleFrameListener, public Ogre::MouseMotionListener, public Ogre::MouseListener
{
public:
CGuiListener(RenderWindow* win, Ogre::Camera* cam,BetaGUI::GUI* m_GUI) : ExampleFrameListener(win,cam)
{
mGUI = m_GUI;
///////
mInputDevice2 = mInputDevice;
mEventProcessor = new Ogre::EventProcessor();
mEventProcessor->initialise(win);
mEventProcessor->startProcessingEvents();
mEventProcessor->addKeyListener(this);
mEventProcessor->addMouseMotionListener(this);
mEventProcessor->addMouseListener(this);
mInputDevice = mEventProcessor->getInputReader();
}
~CGuiListener()
{
mEventProcessor->stopProcessingEvents();
mEventProcessor->removeKeyListener(this);
mEventProcessor->removeMouseMotionListener(this);
mEventProcessor->removeMouseListener(this);
delete mEventProcessor;
mInputDevice = mInputDevice2;
}
virtual void mouseMoved (MouseEvent *e)
{
int a = e->getRelX();
int b = e->getRelY();
int c = mWindow->getWidth();
int d = mWindow->getHeight();
mGUI->injectMouse(e->getX()* mWindow->getWidth(),e->getY() * mWindow->getHeight(),false);
e->consume();
}
virtual void mouseDragged (MouseEvent *e)
{
mouseMoved(e);
}
virtual void keyPressed (KeyEvent *e)
{
Ogre::String key;
char a[2];
a[0] = e->getKeyChar();
a[1] = '\0';
key = a;
mGUI->injectKey(key,5,51);
e->consume();
}
virtual void keyReleased (KeyEvent *e)
{
}
virtual void mousePressed (MouseEvent *e)
{
mGUI->injectMouse(e->getX()* mWindow->getWidth(),e->getY() * mWindow->getHeight(),true);
e->consume();
}
virtual void mouseReleased (MouseEvent *e)
{
mGUI->injectMouse(e->getX()* mWindow->getWidth(),e->getY() * mWindow->getHeight(),false);
e->consume();
}
virtual void keyClicked (KeyEvent *e) {}
virtual void mouseClicked (MouseEvent *e) {}
virtual void mouseEntered (MouseEvent *e) {}
virtual void mouseExited (MouseEvent *e) {}
bool frameStarted(const FrameEvent& evt);
protected:
Ogre::EventProcessor* mEventProcessor;
Ogre::InputReader* mInputDevice2;
BetaGUI::GUI* mGUI;
};