Skip to main content

History: MyGUI quickstart

Source of version: 6

Copy to clipboard
            This is quickstart for __MyGUI 3.0__. If you want to use earlier version of MyGUI use ((MyGUI quickstart old|this page)).

Copy ''MyGUI_Media'' folder from downloaded package (or from svn) and add the path to it in your ''resources.cfg''.

Compile MyGUI and put ''MyGUIEngine(_d).dll'' near the executable file and add ''MyGUIEngine(_d).lib'' to additional dependencies.

You will also need to compile MyGUI.OgrePlatform as an interface for the MyGui library to the Ogre rendering engine and add ''MyGUI.OgrePlatform(_d).lib'' to additional dependencies.

!!Code
__includes:__
You need to have additional include folder for this - ''path_to_MyGUI/MyGUIEngine/include'' and ''path_to_MyGUI/Platforms/Ogre/OgrePlatform/include'' and add to your code next includes:
{CODE(wrap="1", colors="c++")}   #include "MyGUI.h"
   #include "MyGUI_OgrePlatform.h"
{CODE}

Before you initialize the GUI, be sure to create a viewport. This is sent to the OgrePlatform class and stores it for use later during the "initialise" method call.

__declaration:__
{CODE(wrap="1", colors="c++")}  MyGUI::Gui * mGUI;{CODE}

__create Code:__
{CODE(wrap="1", colors="c++")}   MyGUI::OgrePlatform* mPlatform = new MyGUI::OgrePlatform();
   mPlatform->initialise(mWindow, mSceneManager); // mWindow is Ogre::RenderWindow*, mSceneManager is Ogre::SceneManager*
   mGUI = new MyGUI::Gui();
   mGUI->initialise();

 class CLASS_NAME : public OIS::MouseListener , public OIS::KeyListener

 bool CLASS_NAME::mouseMoved( const OIS::MouseEvent &arg )
 {
     mGUI->injectMouseMove(arg.state.X.abs, arg.state.Y.abs, arg.state.Z.abs);
     //...
 }
 
 bool CLASS_NAME::mousePressed( const OIS::MouseEvent &arg, OIS::MouseButtonID id )
 {
     mGUI->injectMousePress(arg.state.X.abs, arg.state.Y.abs, MyGUI::MouseButton::Enum(id));
     //...
 }
 
 bool CLASS_NAME::mouseReleased( const OIS::MouseEvent &arg, OIS::MouseButtonID id )
 {
     mGUI->injectMouseRelease(arg.state.X.abs, arg.state.Y.abs, MyGUI::MouseButton::Enum(id));
     //...
 }
 
 bool CLASS_NAME::keyPressed( const OIS::KeyEvent &arg )
 {
     mGUI->injectKeyPress(MyGUI::KeyCode::Enum(arg.key), arg.text);
     //...
 }
 
 bool CLASS_NAME::keyReleased( const OIS::KeyEvent &arg )
 {
     mGUI->injectKeyRelease(MyGUI::KeyCode::Enum(arg.key));
     //...
 }
{CODE}
%note% __Note:__ for those who used previous versions of MyGUI: you don't need to call injectFrameEntered every frame in MyGUI 3.0 (now renderer do this)

%note% __Note:__ if you can't move your cursor all over the rendering area, you may need to add the following code to your app's initialization (and also to your "window resize event" callback):
{CODE(wrap="1", colors="c++")}const OIS::MouseState &mouseState = mMouse->getMouseState(); // mMouse is type of OIS::Mouse*
mouseState.width = 1024; // your rendering area width
mouseState.height = 768; // your rendering area height{CODE}

__create button and set callback:__
{CODE(wrap="1", colors="c++")}   MyGUI::ButtonPtr button = mGUI->createWidget<MyGUI::Button>("Button", 10, 10, 300, 26, MyGUI::Align::Default, "Main");
   button->setCaption("exit");
   // set callback
   button->eventMouseButtonClick = MyGUI::newDelegate(CLASS_POINTER, &CLASS_NAME::METHOD_NAME); // CLASS_POINTER is pointer to instance of a CLASS_NAME (usually '''this''')
   // or
   //button->eventMouseButtonClick = MyGUI::newDelegate(STATIC_METHOD_NAME);
   //button->eventMouseButtonClick = MyGUI::newDelegate(GLOBAL_FUNC_NAME);
{CODE}
__another way of creating button and setting callback:__
in ''sample.layout'':
{CODE(wrap="1", colors="xml")}   <?xml version="1.0" encoding="UTF-8"?>
   
   <MyGUI type="Layout">
   
     <Widget type="Button" skin="Button" position="10 10 300 26" align="Default" layer="Main" name="MyFirstButton" >
       <Property key="Widget_Caption" value="exit" />
     </Widget>
   
   </MyGUI>
{CODE}
__code:__
{CODE(wrap="1", colors="c++")}   // load layout
   MyGUI::LayoutManager::getInstance().load("sample.layout");
   // set callback
   MyGUI::ButtonPtr button = mGUI->findWidget<MyGUI::Button>("MyFirstButton");
   button->eventMouseButtonClick = MyGUI::newDelegate(CLASS_POINTER, &CLASS_NAME::METHOD_NAME); // CLASS_POINTER is pointer to CLASS_NAME ('''this''')
   // or
   //button->eventMouseButtonClick = MyGUI::newDelegate(STATIC_METHOD_NAME);
   //button->eventMouseButtonClick = MyGUI::newDelegate(GLOBAL_FUNC_NAME);
{CODE}
__method signature for eventMouseButtonClick:__
{CODE(wrap="1", colors="c++")}   void CLASS_NAME::METHOD_NAME(MyGUI::WidgetPtr _sender)
   {
     //...
   }
 
   void CLASS_NAME::STATIC_METHOD_NAME(MyGUI::WidgetPtr _sender)
   {
     //...
   }
 
   void GLOBAL_FUNC_NAME(MyGUI::WidgetPtr _sender)
   {
     //...
   }
{CODE}
__destroy:__
{CODE(wrap="1", colors="c++")}   mGUI->shutdown();
   delete mGUI;
   mGUI = 0;   
   mPlatform->shutdown();
   delete mPlatform;
   mPlatform = 0;
{CODE}

        

History

Information Version
Thu 21 of Aug, 2014 11:15 GMT-0000 Altren even deleting whole page source doesn't provent page from infinite load on chrome 30
Thu 21 of Aug, 2014 11:02 GMT-0000 Altren trying to fix http://www.ogre3d.org/addonforums/viewtopic.php?f=17&t=14793 [rollback version 25] [rollback version 27] 29
Thu 21 of Aug, 2014 11:04 GMT-0000 Altren [rollback version 26] 28
Thu 21 of Aug, 2014 11:01 GMT-0000 Altren trying to fix http://www.ogre3d.org/addonforums/viewtopic.php?f=17&t=14793 24
Thu 21 of Aug, 2014 10:57 GMT-0000 Altren trying to fix tikiwiki bug: http://www.ogre3d.org/addonforums/viewtopic.php?f=17&t=14793 23
Thu 21 of Aug, 2014 10:55 GMT-0000 Altren 22
Thu 21 of Aug, 2014 10:54 GMT-0000 Altren 21
Sun 06 of Apr, 2014 09:54 GMT-0000 Enhex Made it more visible. 20
Sun 06 of Apr, 2014 09:47 GMT-0000 Enhex We need to keep a pointer to mPlatform in order to delete it. 19
Sun 06 of Apr, 2014 09:45 GMT-0000 Enhex Added important information about creating buttons properly. 18
Thu 06 of Mar, 2014 08:38 GMT-0000 yoni0505 17
Wed 18 of Sep, 2013 17:10 GMT-0000 slicky 16
Sun 21 of Jul, 2013 21:30 GMT-0000 An00biS Added NOTE: Init MyGUI after loading resources! 15
Sat 31 of Mar, 2012 14:06 GMT-0000 Altren 14
Sat 25 of Feb, 2012 13:13 GMT-0000 Hronom 13
Fri 24 of Feb, 2012 23:47 GMT-0000 Datalore fixed some grammar errors 12
Mon 16 of Jan, 2012 08:18 GMT-0000 Altren info about linking MyGUI as static library 11
Thu 11 of Aug, 2011 06:17 GMT-0000 Altren 10
Mon 08 of Aug, 2011 06:38 GMT-0000 Altren 9
Sun 31 of Jul, 2011 23:20 GMT-0000 jacmoe 8
Fri 15 of Oct, 2010 09:46 GMT-0000 Altren fix code formatting 7
Sat 01 of May, 2010 01:28 GMT-0000 jacmoe 6
Sat 09 of Jan, 2010 04:39 GMT-0000 jacmoe 5
Sat 09 of Jan, 2010 04:38 GMT-0000 jacmoe 4
Mon 28 of Dec, 2009 05:38 GMT-0000 jacmoe 3
  • «
  • 1 (current)
  • 2