[Python-ogre-commit] SF.net SVN: python-ogre: [578] trunk/python-ogre
Brought to you by:
andy_miller,
roman_yakovenko
|
From: <and...@us...> - 2008-02-24 08:05:24
|
Revision: 578
http://python-ogre.svn.sourceforge.net/python-ogre/?rev=578&view=rev
Author: andy_miller
Date: 2008-02-24 00:05:30 -0800 (Sun, 24 Feb 2008)
Log Message:
-----------
Various updates for the 1.2 release --and force Py++ to rev 1234
Revision Links:
--------------
http://python-ogre.svn.sourceforge.net/python-ogre/?rev=1234&view=rev
Modified Paths:
--------------
trunk/python-ogre/ChangeLog.txt
trunk/python-ogre/PythonOgreConfig_nt.py
trunk/python-ogre/PythonOgreConfig_posix.py
trunk/python-ogre/PythonOgreInstallCreator.iss
trunk/python-ogre/ThirdParty/betagui/BetaGUI.h
trunk/python-ogre/ThirdParty/betagui/BetaGui.cpp
trunk/python-ogre/ThirdParty/nxogre_0.9/NxOgrePhysXDriver.cpp
trunk/python-ogre/ThirdParty/nxogre_0.9/NxOgreWorld.cpp
trunk/python-ogre/ThirdParty/ogreal/OgreALOggSound.cpp
trunk/python-ogre/ThirdParty/ogreal/OgreALSound.cpp
trunk/python-ogre/ThirdParty/ogreal/OgreALWavSound.cpp
trunk/python-ogre/code_generators/betagui/generate_code.py
trunk/python-ogre/code_generators/betagui/python_betagui_aliases.h
trunk/python-ogre/code_generators/common_utils/__init__.py
trunk/python-ogre/code_generators/navi/generate_code.py
trunk/python-ogre/code_generators/navi/python_navi_aliases.h
trunk/python-ogre/code_generators/navi/python_navi_sizeof.h
trunk/python-ogre/code_generators/nxogre_09/generate_code.py
trunk/python-ogre/code_generators/ogre/generate_code.py
trunk/python-ogre/code_generators/ogre/hand_made_wrappers.py
trunk/python-ogre/code_generators/quickgui/generate_code.py
trunk/python-ogre/demos/cegui/plugins.cfg
trunk/python-ogre/demos/et/plugins.cfg
trunk/python-ogre/demos/navi/ogre.cfg
trunk/python-ogre/demos/navi/plugins.cfg
trunk/python-ogre/demos/navi/resources.cfg
trunk/python-ogre/demos/nxogre/CakeFramework.py
trunk/python-ogre/demos/nxogre/Demo_102.py
trunk/python-ogre/demos/nxogre/config.yaml
trunk/python-ogre/demos/ogreal/Demo_RenderToTexture.py
trunk/python-ogre/demos/ogreforests/Demo_Forest.py
trunk/python-ogre/demos/ogreforests/plugins.cfg
trunk/python-ogre/demos/particleuniverse/Demo_Particle.py
trunk/python-ogre/demos/plib/Demo_Sound.py
trunk/python-ogre/demos/qgui/Demo_QuickGUI01.py
trunk/python-ogre/demos/qgui/media/skins/qgui/SkinSet.qgui.png
trunk/python-ogre/demos/qgui/media/skins/qgui/qgui.skinset
trunk/python-ogre/demos/theora/demo_video.py
trunk/python-ogre/environment.py
trunk/python-ogre/scripts/UpdateDLLs.bat
trunk/python-ogre/scripts/compilesource.bat
trunk/python-ogre/scripts/epydoc_config
Added Paths:
-----------
trunk/python-ogre/demos/Enums.py
Modified: trunk/python-ogre/ChangeLog.txt
===================================================================
--- trunk/python-ogre/ChangeLog.txt 2008-02-23 06:13:35 UTC (rev 577)
+++ trunk/python-ogre/ChangeLog.txt 2008-02-24 08:05:30 UTC (rev 578)
@@ -1,5 +1,12 @@
-Feb 2008: Release
-=================
+Feb 19 2008: Release 1.2 RC1
+======================
+ISSUES:
+This is an "Release Candiate 1" release so there are some things that are not completed:
+ NAVI -- Doesn't work
+ NxOgre -- Bleeding -- not yet wrapped
+ NxOgre_09 -- Wrapper improvements, not yet completed
+ QuickGUI - Demo needs to be rewritten
+
Code Generation:
* Fix to the Automatic Function transformation code as it wasn't picking up constant void pointers.
This fixes PixelUtil::unpackColour and a number of other functions
@@ -7,7 +14,7 @@
* Fix to OgreForests as the API had changed in base C++ library
* Fix to Py++ to remove reference when building wrapper code in "transformers.py" - bug showed in renderQueueListener
* Fix to BuildModule.py to only set the environment once (-C now works for compiling everything)
-* Fix to ComonUtils/__init__.py - Free Functions wheren't being handled by Futional Transformation or Return Pointer fixing.
+* Fix to ComonUtils/__init__.py - Free Functions wheren't being handled by Futional Transformation or Return Pointer fixing
* Enhancements to MemoryDataStream to make it simplier to use (can be used for any 'DataStream' requirements)
Updates and General Library Improvements to:
@@ -16,11 +23,12 @@
* Particle Universe 0.6
* Bullet 2.66
* Caelum Rev 127 and updated media.
-* Physx - free functions are now exposed so should work as an independ library
+* Physx - free functions are now exposed so should work as an independ library
+* Ogrevideoffmpeg - updated to latest ffmpeg
-New Modules:
+No New Modules in this release -- however looking at...
* Hydrax 0.1
-* opensteer
+* opensteer
Janurary 08 2008: Snapshot
==========================
@@ -48,7 +56,7 @@
Module Specifics:
* betagui -- now using version 2.x of the source code
-* bullet -- Updated to verssion 2.64
+* bullet -- Updated to version 2.64
* caleum -- SVN version r112 - small change to hanve noncopyable changes
* cegui -- still using 0.5.0, small changes to generator for noncopyable classes
* et -- no changes - built on 2.2 source
Modified: trunk/python-ogre/PythonOgreConfig_nt.py
===================================================================
--- trunk/python-ogre/PythonOgreConfig_nt.py 2008-02-23 06:13:35 UTC (rev 577)
+++ trunk/python-ogre/PythonOgreConfig_nt.py 2008-02-24 08:05:30 UTC (rev 578)
@@ -59,8 +59,8 @@
PATH_noise= os.path.join(PATH_THIRDPARTY, 'noise')
PATH_ofusion= os.path.join(PATH_THIRDPARTY, 'ofusion')
PATH_cadunetree= os.path.join(PATH_THIRDPARTY, 'cadunetree')
+PATH_opensteer = os.path.join(BASE_DIR, 'opensteer', 'trunk')
-
PATH_ogrevideoffmpeg = os.path.join(PATH_THIRDPARTY,'ffmpeg')
PATH_Bullet= os.path.join(BASE_DIR, 'bullet-2.66')
PATH_PhysX= "c:/program files/AGEIA Technologies/SDK/v2.7.3/SDKs"
@@ -101,7 +101,7 @@
PATH_LIB_Bullet = os.path.join(PATH_Bullet, 'out/release8/libs' )
PATH_LIB_Theora= os.path.join(PATH_Theora, 'bin', 'Release')
PATH_LIB_ogrevideoffmpeg = PATH_ogrevideoffmpeg
-PATH_LIB_ffmpeg= os.path.join(PATH_ffmpeg, 'lib')
+PATH_LIB_ffmpeg= os.path.join(BASE_DIR, 'ffmpeg', 'lib')
PATH_LIB_plib = PATH_plib
PATH_LIB_navi= os.path.join(PATH_navi, 'lib')
PATH_LIB_ogredshow = PATH_ogredshow
@@ -110,9 +110,10 @@
PATH_LIB_Ogre_CEGUIRenderer = os.path.join( PATH_Ogre, 'lib')
PATH_LIB_OIS = os.path.join( PATH_Ogre, 'Dependencies/lib/Release') ## NOTE Posix platforms this lives in'lib' not 'dll'
PATH_LIB_CEGUI = os.path.join( PATH_Ogre, 'lib' )
+
+PATH_LIB_opensteer = os.path.join(PATH_opensteer, 'win32','release')
-
PATH_INCLUDE_Ogre= os.path.join(PATH_Ogre,'OgreMain/include')
PATH_INCLUDE_Ogre_Dependencies = os.path.join( PATH_Ogre, 'Dependencies/include')
PATH_INCLUDE_OIS = os.path.join(PATH_OIS,'includes') ## Note the plural include's
@@ -171,6 +172,8 @@
,os.path.join(PATH_PhysX, 'NxCharacter','include')
,os.path.join(PATH_PhysX, 'NxExtensions','include')
]
+PATH_INCLUDE_opensteer = os.path.join(PATH_opensteer, 'include')
+PATH_INCLUDE_opensteer_opensteer = os.path.join(PATH_opensteer, 'include', 'OpenSteer')
if SDK:
PATH_INCLUDE_OIS = os.path.join(PATH_Ogre,'Dependencies/include/OIS') ## Note the plural include's
Modified: trunk/python-ogre/PythonOgreConfig_posix.py
===================================================================
--- trunk/python-ogre/PythonOgreConfig_posix.py 2008-02-23 06:13:35 UTC (rev 577)
+++ trunk/python-ogre/PythonOgreConfig_posix.py 2008-02-24 08:05:30 UTC (rev 578)
@@ -77,6 +77,7 @@
PATH_navi = os.path.join(BASE_DIR, 'navi','Navi')
PATH_particleuniverse = os.path.join(PATH_Ogre, 'PlugIns', 'ParticleUniverse' )
PATH_cadunetree= os.path.join(PATH_THIRDPARTY, 'cadunetree')
+PATH_opensteer = os.path.join(BASE_DIR, 'opensteer', 'trunk')
###
@@ -115,6 +116,7 @@
PATH_LIB_plib = PATH_plib
PATH_LIB_navi= os.path.join(PATH_navi, 'lib')
PATH_LIB_particleuniverse = os.path.join(PATH_particleuniverse, 'bin', 'release')
+PATH_LIB_opensteer = os.path.join(LOCAL_LIB)
PATH_INCLUDE_Ogre= os.path.join(LOCAL_INCLUDE,'OGRE') # os.path.join(PATH_Ogre,'OgreMain/include')
@@ -180,3 +182,5 @@
,os.path.join(physxbase, 'NxExtensions','include')
,os.path.join(physxbase, 'Physics','include')
]
+PATH_INCLUDE_opensteer = os.path.join(LOCAL_INCLUDE, 'OpenSteer')
+PATH_INCLUDE_opensteer_opensteer = os.path.join(LOCAL_INCLUDE, 'OpenSteer')
Modified: trunk/python-ogre/PythonOgreInstallCreator.iss
===================================================================
--- trunk/python-ogre/PythonOgreInstallCreator.iss 2008-02-23 06:13:35 UTC (rev 577)
+++ trunk/python-ogre/PythonOgreInstallCreator.iss 2008-02-24 08:05:30 UTC (rev 578)
@@ -3,13 +3,13 @@
;
[Setup]
AppName=Python-Ogre
-AppVerName=Python-Ogre 1.2
+AppVerName=Python-Ogre 1.2 RC1
DefaultDirName=C:\PythonOgre
DefaultGroupName=Python-Ogre
OutputBaseFilename=PythonOgreInstaller
OutputDir=C:\temp
SourceDir=C:\Development\PythonOgreRelease
-VersionInfoDescription=Release 1.2 of Python-Ogre
+VersionInfoDescription=Release 1.2 RC1 of Python-Ogre
AllowNoIcons=true
AppPublisher=OpenSource (Andy and Team)
AppPublisherURL=http://www.python-ogre.org
@@ -220,7 +220,7 @@
Name: {group}\OgreNewt Demos\Ragdoll; Filename: {code:GetPythonExe}; Parameters: Demo08_ragdoll.py; WorkingDir: {app}\Demos\OgreNewt
Name: {group}\Video Demos\ffmpeg Video; Filename: {code:GetPythonExe}; Parameters: Demo_Video.py; WorkingDir: {app}\Demos\ffmpeg
-Name: {group}\Video Demos\DirectShow Video; Filename: {code:GetPythonExe}; Parameters: Demo_Video.py; WorkingDir: {app}\Demos\dshow
+;Name: {group}\Video Demos\DirectShow Video; Filename: {code:GetPythonExe}; Parameters: Demo_Video.py; WorkingDir: {app}\Demos\dshow
Name: {group}\Video Demos\Theora Video; Filename: {code:GetPythonExe}; Parameters: Demo_Video.py; WorkingDir: {app}\Demos\theora
Name: {group}\NxOgre\Download AGEIA drivers first; Filename: http://www.ageia.com/drivers/drivers.html
@@ -233,8 +233,11 @@
Name: {group}\Plib Demos\Networking - Client; Filename: {code:GetPythonExe}; Parameters: Demo_Client.py; WorkingDir: {app}\Demos\plib
;Name: {group}\Plib Demos\Sound; Filename: {code:GetPythonExe}; Parameters: Demo_Sound.py; WorkingDir: {app}\Demos\plib
-Name: {group}\OgreForests Demos\ogreforests; Filename: {code:GetPythonExe}; Parameters: Demo_Forest.py; WorkingDir: {app}\Demos\ogreforests
-Name: {group}\Editable Terrain Demo\Editable Terrain; Filename: {code:GetPythonExe}; Parameters: Demo_CEGUI_ET.py; WorkingDir: {app}\Demos\et
+Name: {group}\Special Effects\Forests; Filename: {code:GetPythonExe}; Parameters: Demo_Forest.py; WorkingDir: {app}\Demos\ogreforests
+Name: {group}\Special Effects\Editable Terrain; Filename: {code:GetPythonExe}; Parameters: Demo_CEGUI_ET.py; WorkingDir: {app}\Demos\et
+Name: {group}\Special Effects\Caelum Sky; Filename: {code:GetPythonExe}; Parameters: Demo_Caelum01.py; WorkingDir: {app}\Demos\caelum
+Name: {group}\Special Effects\Noise Generation; Filename: {code:GetPythonExe}; Parameters: Demo_Noise_01.py; WorkingDir: {app}\Demos\noise
+Name: {group}\Special Effects\Particle Universe; Filename: {code:GetPythonExe}; Parameters: Demo_Particle.py; WorkingDir: {app}\Demos\particleuniverse
Name: {group}\Uninstall Python-Ogre; Filename: {uninstallexe}
Name: {group}\Python-Ogre API Documenatation; Filename: {app}\docs\Python-Ogre.chm
Modified: trunk/python-ogre/ThirdParty/betagui/BetaGUI.h
===================================================================
--- trunk/python-ogre/ThirdParty/betagui/BetaGUI.h 2008-02-23 06:13:35 UTC (rev 577)
+++ trunk/python-ogre/ThirdParty/betagui/BetaGUI.h 2008-02-24 08:05:30 UTC (rev 578)
@@ -1,244 +1,638 @@
-// Betajaen's GUI "BetaGUI 2.0", Version 35-uncompressed, http://www.ogre3d.org/wiki/index.php/BetaGUI
-//
-// Copyright (c) 2007 Robin Southern <bet...@ih...>
-//
-// Permission is hereby granted, free of charge, to any person
-// obtaining a copy of this software and associated documentation
-// files (the "Software"), to deal in the Software without
-// restriction, including without limitation the rights to use,
-// copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the
-// Software is furnished to do so, subject to the following
-// conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-// OTHER DEALINGS IN THE SOFTWARE.
-
#ifndef BETAGUI_H
#define BETAGUI_H
+/// Betajaen's GUI 016 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"
+#include "OgreTextAreaOverlayElement.h"
-#pragma pointers_to_members(full_generality, virtual_inheritance)
+#include <iostream>
-namespace BetaGUI {
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- class GUI;
- class Style;
- struct WindowStyle;
- struct WidgetStyle;
- class Window;
- class Widget;
- class Button;
- class TextInput;
- class Slider;
- class NumericSlider;
- class StringSlider;
- class Meter;
- class Select;
- class GUIListener{};
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- enum WindowFeatureType { WFT_NONE = 0, WFT_MOVE, WFT_RESIZE, WFT_RESIZE_AND_MOVE, WFT_ON_TOP };
- enum FocusState { FS_NONE = 0, FS_SELECT, FS_SELECT_OFF, FS_DRAG };
- enum SpecialKey { SK_BACKSPACE = 0, SK_ENTER, SK_TAB, SK_ESCAPE };
- enum WindowRole { WR_NONE = 0, WR_DRAG, WR_RESIZE, WR_CLOSE };
- enum WindowMode { WM_NONE = 0, WM_DRAG, WM_RESIZE, WM_LMB_DOWN, WM_SLIDER_MOVE };
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- typedef void (BetaGUI::GUIListener::*ButtonMethodPtr)(BetaGUI::Button*, BetaGUI::FocusState);
- typedef void (BetaGUI::GUIListener::*SliderMethodPtr)(BetaGUI::Slider*, BetaGUI::FocusState);
- typedef void (BetaGUI::GUIListener::*TextInputMethodPtr)(BetaGUI::TextInput*, BetaGUI::FocusState);
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- class GUI { friend class Window;friend class Button;friend class TextInput;
+using namespace Ogre;
+using namespace std;
+
+namespace BetaGUI
+{
+ //------------------------------------------------------------------------------------------------
+ class GUI;
+
+ class Widget;
+ class Window;
+
+ class Button;
+ class BoolButton;
+ class MenuButton;
+ class RealButton;
+
+ class StaticText;
+ class TextInput;
+
+ class Callback;
+
+ class Effect;
+ class AlphaEffect;
+ class MoveEffect;
+ class SizeEffect;
+
+ //------------------------------------------------------------------------------------------------
+ enum WindowFeatureType
+ {
+ WFT_NONE = 0,
+ WFT_MOVE ,
+ WFT_RESIZE ,
+ WFT_RESIZE_AND_MOVE
+ };
+ //------------------------------------------------------------------------------------------------
+ enum WindowPlacementType
+ {
+ WPT_NONE = 0,
+ WPT_VERTICAL ,
+ WPT_HORIZONTAL
+ };
+ //------------------------------------------------------------------------------------------------
+ enum WindowActivity
+ {
+ WA_NONE = 0,
+ WA_MOVE ,
+ WA_RESIZE ,
+ WA_PRESS
+ };
+ //------------------------------------------------------------------------------------------------
+ class GUI
+ {
public:
- GUI(Ogre::RenderWindow*);
+
+ friend class Window;
+
+ friend class Button;
+
+ friend class MenuButton;
+ friend class BoolButton;
+ friend class RealButton;
+
+ friend class StaticText;
+ friend class TextInput;
+
+ GUI(const Ogre::String &baseOverlay, const Ogre::String &font, int fontSize, Ogre::RenderWindow *win);
+
~GUI();
-
- bool injectRelMouse(int RelX, int RelY, bool selectDown);
- bool injectMouse(unsigned int ScreenX, unsigned int ScreenY, bool selectDown);
- bool injectKey(const Ogre::String& key, unsigned int x, unsigned int y);
- void injectSpecialKey(SpecialKey, unsigned int ScreenX, unsigned int ScreenY);
-
- Style* createStyle(const Ogre::String& name);
- Window* createWindow(int x, int y, unsigned int width, unsigned int height, const Ogre::String& Style, WindowFeatureType type, const Ogre::String& caption, GUIListener*);
- void destroyWindow(Window *window);
-
- Ogre::OverlayContainer* createMousePointer(const Ogre::String& material, unsigned int w, unsigned int h);
- Ogre::OverlayContainer* createOverlayFromWidgetStyle(const Ogre::String &name, const Ogre::String &style, const Ogre::String &widget, int x, int y, const Ogre::String &caption = "");
- Ogre::OverlayContainer* createOverlayFromWindowStyle(const Ogre::String &name, const Ogre::String &style, int x, int y, int w, int h);
- protected:
- void __updateCenteredOverlay(Ogre::OverlayContainer*);
- Ogre::OverlayContainer* __getOverlay(const Ogre::String&, const Ogre::String& = "Panel", int x=0, int y=0, int w=0,int h=0);
- Ogre::Overlay* mOverlay; // Main sheet overlay
- std::vector<Window*> mWindow; // Windows
- std::map<Ogre::String, Style*> mStyle; // Styles
- Window *mWindowToDestroy; // Window to destroy
- Ogre::OverlayContainer* mMousePointer; // Mouse Pointer Overlay
- unsigned int mWindowCount, mButtonCount, mTextInputCount, mRenderWindowWidth, mRenderWindowHeight;
- Ogre::Real mWindowRatio;
- };
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- class Window { friend class Button;friend class TextInput;friend class GUI;
+ void sortZOrder() ;
+
+ void setZRangeOrder(int nearZ, int FarZ);
+
+ bool injectMouse(int x, int y, bool LMB);
+ bool injectMouse(float x, float y, bool LMB);
+
+ bool injectKey(const Ogre::String &key, int x, int y);
+
+ void injectBackspace(int x, int y);
+
+ Window* createWindow(
+ const Ogre::Vector4 &Dimensions,
+ const Ogre::String &Material,
+ WindowFeatureType type,
+ const Ogre::String &caption = "");
+
+ void destroyWindow(Window *window) {
+ mNextWindowToDestroy=window;
+ }
+ Ogre::OverlayContainer* createOverlay(const Ogre::String &name,
+ const Ogre::Vector2 &position,
+ const Ogre::Vector2 &dimensions,
+ const Ogre::String &material = "",
+ const Ogre::String &caption = "");
+
+ Ogre::OverlayContainer* createMousePointer(Ogre::Vector2 dimensions,
+ const Ogre::String &material);
+
+
+
+ Window *addMenuWindow(const Ogre::Vector2 dimensions);
+
+ void update(Ogre::Real timeElapsed);
+ void addEffect (Effect* e);
+ Ogre::Real getUpTime() const {return mUpTime;}
+
+ protected:
+ //Ogre::Overlay* mGuiOverlay; // Main sheet overlay
+ std::vector<Window*> mWindows; // Windows
+ Window * mNextWindowToDestroy; // Window to destroy
+ Ogre::OverlayContainer* mMousePointerOverlay; // Mouse Pointer Overlay
+
+ Ogre::String mFont;
+ int mFontSize;
+ int mWindowCount, mButtonCount, mTextCaptionCount, mTextCaptionCountArea, mButtonCountTextArea;
+
+
+ Ogre::uint mDragWindowAction;
+
+ int mDragX, mDragY;
+ int mDragWindowX, mDragWindowY;
+
+ Window * mActiveDraggedWindow;
+ TextInput * mActiveTextInput;
+ Button * mActiveButton;
+
+ Ogre::Vector2 mNextMenuWindowPos;
+ Window * mMenuWindow;
+ Ogre::RenderWindow * mRenderWindow;
+
+ std::list<Effect*> mActiveEffects;
+
+ Ogre::Real mUpTime;
+ Ogre::String mName;
+ int mFarZ;
+ int mNearZ;
+ };
+ //------------------------------------------------------------------------------------------------
+ class Widget
+ {
+ public:
+
+ friend class GUI;
+
+ Widget(const Ogre::Vector4 &Dimension,
+ const Ogre::String &materialNameNormal,
+ bool hasOverState = true,
+ bool hasActiveState = true);
+
+ virtual ~Widget();
+
+ Ogre::Vector2 getPosition() const{return Ogre::Vector2(mPosX,mPosY);}
+ Ogre::Vector2 getSize() const {return Ogre::Vector2(mWidth,mHeight); }
+
+ void setPosition(const Ogre::Vector2 &position);
+ void setSize(const Ogre::Vector2 &size);
+
+ virtual void show(){setAlpha (1.0, true);};
+ virtual void hide(){setAlpha (0.0, true);};
+
+ virtual bool isVisible() {return mMainOverlay->isVisible ();};
+
+ virtual void over(const bool a);
+ virtual void activate(const bool a);
+
+ virtual void adjustSizeToContent();
+
+ virtual void setPosition(float X,float Y);
+ virtual void setPosition(int X,int Y);
+ virtual void setSize(int X,int Y);
+ virtual void setAlpha(const Ogre::Real alpha, const bool isContainer);
+ virtual void setMaterialBlendFactor(const Ogre::Real blendFactor, const bool isContainer);
+
+ // mUnderEffect getter
+ bool getUnderEffect() const { return mUnderEffect; }
+ // mUnderEffect setter
+ void setUnderEffect(bool val);
+
+ // mOver getter
+ bool getOver() const { return mOver; }
+ // mOver setter
+ void setOver(bool val) { mOver = val; }
+ // mActive getter
+ bool getActive() const { return mActive; }
+ // mActive setter
+ void setActive(bool val) { mActive = val; }
+
+ // mActive setter
+ void setMainMaterial(const Ogre::String& mat) {
+ mMainOverlay->setMaterialName(mat);
+ }
+
+ void setCaptionMaterial(const Ogre::String& mat) {
+ mCaptionOverlay->setMaterialName(mat);
+ }
+
+ void setText(const Ogre::String& t) {
+ mCaptionOverlay->setCaption(t);
+ }
+
+ Ogre::String getText() const {
+ return mCaptionOverlay->getCaption();
+ }
+
+ protected:
+ //------------------------------------------------------------------------------------------------
+ inline bool isOut (const int x, const int y) const
+ {
+ return (x < mPosX) || (y < mPosY)
+ || (x > (mPosX + mWidth)) ||
+ (y > (mPosY + mHeight));
+ }
+ //------------------------------------------------------------------------------------------------
+ inline bool isIn (const int x, const int y) const
+ {
+ return (x >= mPosX) && (y >= mPosY)
+ && (x <= (mPosX + mWidth)) &&
+ (y <= (mPosY + mHeight));
+ }
+
+ void instantiateMaterial(Ogre::OverlayContainer * const oc, bool reset) const;
+ void setOverlayAlpha(Ogre::OverlayContainer * const oc, const Ogre::Real alpha) const;
+ void setOverlayMaterialBlendFactor(Ogre::OverlayContainer * const oc, const Ogre::Real blendFactor) const;
+
+ int mPosX, mPosY, mWidth, mHeight;
+
+ std::vector<Widget *> mChildren;
+ Ogre::OverlayContainer* mMainOverlay;
+ Ogre::OverlayContainer* mCaptionOverlay;
+ Ogre::String mMaterialName;
+
+ bool mHasMaterial;
+ bool mHasOverState;
+ bool mHasActiveState;
+ bool mUnderEffect;
+ bool mOver;
+ bool mActive;
+ };
+ //------------------------------------------------------------------------------------------------
+ class Window : public Widget
+ {
public:
- Button* createButton(int x, int y, const Ogre::String& Caption, ButtonMethodPtr);
- TextInput* createTextInput(int x, int y, int w, const Ogre::String& intialValue, unsigned maxLength);
- Ogre::OverlayContainer* createStaticText(int x, int y, const Ogre::String& caption);
- void hide() { mOverlay->hide();}
- void show() { mOverlay->show();}
- bool isVisible() { return mOverlay->isVisible();}
- void setPosition(unsigned int X,unsigned int Y);
- Ogre::Vector2 getPosition();
- Ogre::Vector2 getSize();
- void setSize(unsigned int X,unsigned int Y);
- Ogre::OverlayContainer* mOverlay; // Overlay
- ~Window();
+ friend class Button;
+ friend class TextInput;
+ friend class StaticText;
+ friend class GUI;
+
+ Window(const Ogre::Vector4 &Dimensions, const Ogre::String &Material, WindowFeatureType type, const Ogre::String &caption, GUI *gui);
+ virtual ~Window();
+
+ Button* createButton(const Ogre::Vector4 &Dimensions, const Ogre::String &Material,
+ const Ogre::String &Text, Callback callback);
+
+ TextInput* createTextInput(const Ogre::Vector4 &Dimensions, const Ogre::String &Material,
+ const Ogre::String & Value, int length);
+
+ StaticText* createStaticText(const Ogre::Vector4 &Dimensions, const Ogre::String &Text);
+
+ void setSize(int X,int Y);
+
+ MenuButton *addMenuButton(Window *target, const Ogre::String &label, WindowPlacementType wpt = WPT_NONE);
+ BoolButton *addBoolButton(bool value, const Ogre::String &label, WindowPlacementType wpt = WPT_NONE);
+ RealButton *addRealButton(Ogre::Real value, const Ogre::Vector4 &SliderMoves, const Ogre::String &label, WindowPlacementType wpt = WPT_NONE);
+ StaticText* addStaticText(const Ogre::String &label, WindowPlacementType wpt = WPT_NONE);
+
+ Window *addMenuWindowTab(const Ogre::String &label,
+ bool titleBarWin = true,
+ WindowPlacementType wpt = WPT_VERTICAL);
+
+ MenuButton* createMenuButton(const Ogre::Vector4 &D, const Ogre::String &M, const Ogre::String &T, Callback C, Window *t);
+ BoolButton* createBoolButton(const Ogre::Vector4 &D, const Ogre::String &M, const Ogre::String &T, Callback C, bool boolValue);
+
+ RealButton *createRealButton(Ogre::Real value,
+ const Ogre::Vector4 &SliderMoves,
+ const Ogre::String &label,
+ const Ogre::Vector2 &pos);
+
+ GUI* getGUI() const {return mGUI;}
+
+ void setFadeOut(bool f){mFadeOut = f;}
+ void setZOrder(int zOrder){mGuiOverlay->setZOrder (zOrder);}
protected:
- Window(int x, int y, unsigned int width, unsigned int height, const Ogre::String& Style, WindowFeatureType type, const Ogre::String& caption, GUIListener*, GUI*);
+
- bool check(unsigned int x, unsigned int y, bool LMB);
- bool checkKey(const Ogre::String& key, unsigned int x, unsigned int y);
- unsigned int x,y,w,h;int dx,dy; // Dimensions
- Button *mResizeButton,*mActiveButton,*mTitlebarButton; // Resizer, ActiveButton, Titlebar
- TextInput* mActiveTextInput; // Active TextInput
- GUI *mGUI; // mGUI pointer
- std::vector<BetaGUI::Button*> mButtons; // Buttons
- std::vector<BetaGUI::TextInput*> mTextInputs; // TextInputs
- Ogre::String mStyle;
- WindowMode mMode;
- GUIListener* mListener;
- };
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- struct WidgetStyle {
- WidgetStyle() {WidgetStyle("");}
- WidgetStyle(const Ogre::String&);
- void fromStyle(const Ogre::String&);
- Ogre::String mBackground, mFontFace;
- unsigned int mFontSize, mDecalSize, mHeight; Ogre::ColourValue mColour; bool centerText;
- };
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- class Style {
- public:
- void addStyle(Ogre::String widgetName, const Ogre::String& style);
- std::map<Ogre::String, WidgetStyle> mWidgets;
- Ogre::String mWindow_Background, mFontFace;
- unsigned int mFontSize;
- static bool _set(const Ogre::String&, std::pair<Ogre::String,Ogre::String>&, unsigned int&);
- static bool _set(const Ogre::String&, std::pair<Ogre::String,Ogre::String>&, int&);
- static bool _set(const Ogre::String&, std::pair<Ogre::String,Ogre::String>&, bool&);
- static bool _set(const Ogre::String&, std::pair<Ogre::String,Ogre::String>&, Ogre::Real&);
- static bool _set(const Ogre::String&, std::pair<Ogre::String,Ogre::String>&, Ogre::String&);
- static bool _set(const Ogre::String&, std::pair<Ogre::String,Ogre::String>&, Ogre::ColourValue&);
- };
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- class Button {
- friend class Window;
+ bool check(int x, int y, bool LMB);
+ bool checkKey(const Ogre::String &key, int x, int y);
+
+ TextInput* mActiveTextInput; // Active TextInput
+
+ Button
+ *mCloseButton,
+ *mResizerButton,
+ *mActiveButton,
+ *mTitleBarButton; // Resizer, ActiveButton, Title bar
+
+ GUI *mGUI; // mGUI pointer
- void setCaption(const Ogre::String&, bool resize = false);
+ std::vector<Button*> mButtons; // Buttons
+ std::vector<TextInput*> mTextInput; // TextInputs
- protected:
+ Ogre::Overlay *mGuiOverlay;
- Button(int x, int y, const Ogre::String& caption, ButtonMethodPtr, Window *parent);
- Button(int x, int y, int w, int h, const Ogre::String& caption, Window *parent, WindowRole);
- ~Button() {
- mOverlay->getParent()->removeChild(mOverlay->getName());
- }
- void setToActive();
- void setToNormal();
+ void addWidget(const Widget * const w, WindowPlacementType wpt);
+ Ogre::Vector2 mNextWidgetPos;
+ WindowActivity mDragType;
- bool out(unsigned int mx, unsigned int my, unsigned int px, unsigned int py) {
- return ( !(mx >= x + px && my >= y + py)) || ( ! (mx <= x + px + w && my <= y + py + h) );
- }
+ bool mFadeOut;
- Ogre::OverlayContainer* mOverlay, *mCaptionOverlay,*mDecalLeft,*mDecalRight; // Main Overlay and Caption
- Ogre::String mBackground_Normal,mBackground_Active; // MaterialName Normal, MaterialName Active
- int x,y; unsigned int w,h; // Dimensions.
- ButtonMethodPtr mMethod;
- WindowRole mRole;
- Window *mParent;
- };
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- class TextInput {
+ };
+ //------------------------------------------------------------------------------------------------
+ class BetaGUIListener
+ {
public:
+ virtual void onButtonPress(Button*, unsigned char) = 0;
+ };
+ //------------------------------------------------------------------------------------------------
+ class Callback
+ {
+ public:
friend class Window;
+ friend class Button;
- protected:
- TextInput(int x, int y, int w, const Ogre::String& intialValue, unsigned maxLength, Window *parent);
- ~TextInput(){}
- Ogre::String getValue() const {
- return mValue;
+ Callback() {
+ mCallbackType=0;
}
- void setValue(const Ogre::String& v) {
- mCaptionOverlay->setCaption(mValue=v);
+ Callback( void(*functionPointer)(BetaGUI::Button*, bool) ) {
+ mCallbackType=1;
+ fp = functionPointer;
}
+ Callback(BetaGUIListener *l){
+ mCallbackType = 2;
+ mListener = l;
+ }
protected:
- bool in(unsigned int mx, unsigned int my, unsigned int px, unsigned int py) {
- return ( !(mx >= x + px && my >= y + py)) || ( ! (mx <= x + px + w && my <= y + py + h) );
- }
- Ogre::OverlayContainer* mOverlay,*mCaptionOverlay,*mDecalLeft,*mDecalRight;
- Ogre::String mBackground_Normal, mBackground_Active, mValue;
- int x,y;
- unsigned int w,h, mLength;
- Window* mParent;
- };
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- class Slider {
- friend class Window;
-
+ unsigned char mCallbackType; // Type of callback: 0 - None, 1 - FunctionPointer 2 - GUIListener, 3 - Move Window, 4 - Resize
+ void(*fp)(BetaGUI::Button*, bool); // Function pointer (if 1)
+ BetaGUIListener *mListener; // GuiListener (if 2)
+ };
+ //------------------------------------------------------------------------------------------------
+ class Button : public Widget
+ {
public:
-
- class SliderValueRange {
- public:
- // Mark has to be between 0 and 1 (marker / width).
-// virtual void set(Ogre::Real marker, Ogre::String &value) {}
-// virtual Ogre::Real get() {return 0;}
-// virtual Ogre::String get() {return "";}
- };
+ friend class Window;
+ friend class GUI;
+
+ Button(const Ogre::Vector4 &Dimensions, const Ogre::String &Material,
+ const Ogre::String &Text, Callback callback, Window *parent);
+ virtual ~Button() {}
- class NumericSliderValueRange : public SliderValueRange{
- public:
- NumericSliderValueRange(Ogre::Real min, Ogre::Real max, Ogre::Real step = 1.0);
- NumericSliderValueRange(Ogre::Real minA, Ogre::Real maxA, Ogre::Real stepA, Ogre::Real minB, Ogre::Real maxB, Ogre::Real stepB);
+ protected:
+ Callback mCallback; // Callback to use
+ };
+ //------------------------------------------------------------------------------------------------
+ class MenuButton : public Button
+ {
+ public:
+ MenuButton(const Ogre::Vector4 &Dimensions, const Ogre::String &Material,
+ const Ogre::String &Text, Callback callback, Window *parent,
+ Window *target) :
+ Button(Dimensions, Material, Text, callback, parent),
+ mTarget(target)
+ {};
+ virtual ~MenuButton(){};
+ protected:
+ void activate(const bool a) ;
-
- // 1. (from 0,1) 2. Value.
- // std::map<Ogre::Real, Ogre::Real>;
- };
+ Window *mTarget;
+ };
+ //------------------------------------------------------------------------------------------------
+ class BoolButton : public Button
+ {
+ public:
+ BoolButton(const Ogre::Vector4 &Dimensions, const Ogre::String &Material,
+ const Ogre::String &Text, Callback callback, Window *parent, bool boolValue):
+ Button(Dimensions, Material, Text, callback, parent),
+ mBoolValue(boolValue)
+ {}
+ virtual ~BoolButton(){};
- class DictionarySliderValueRange {
+ protected:
+ void activate(const bool a) ;
- };
+ bool mBoolValue;
+ };
+ //------------------------------------------------------------------------------------------------
+ class TextInput : public Widget
+ {
+ public:
+ friend class Window;
+ friend class GUI;
+
+ TextInput(const Ogre::Vector4 &Dimensions, const Ogre::String &Material,
+ const Ogre::String &Value, unsigned int length, Window *parent);
+ virtual ~TextInput(){}
+ const Ogre::String &getValue() const {return mValueText;}
+ void setValue(const Ogre::String &v) {mCaptionOverlay->setCaption(mValueText = v);}
protected:
-
- Slider(int x, int y, int width, SliderValueRange*, Window *parent);
+ unsigned int length;
+ Ogre::String mValueText;// MaterialName Normal, MaterialName Active
- void setToActive();
- void setToNormal();
+ };
+ //------------------------------------------------------------------------------------------------
+ class StaticText : public Widget
+ {
+ public:
+ friend class Window;
- bool out(unsigned int mx, unsigned int my, unsigned int px, unsigned int py) {
- return ( !(mx >= x + px && my >= y + py)) || ( ! (mx <= x + px + w && my <= y + py + h) );
- }
+ StaticText(const Ogre::Vector4 &Dimensions,
+ const Ogre::String &Value,
+ Window *parent);
+ virtual ~StaticText(){}
- Ogre::OverlayContainer* mOverlay, *mMarkerOverlay,*mDecalLeft,*mDecalRight, *mSelection; // Main Overlay and Caption
- std::vector<Ogre::OverlayContainer*> mMarkers;
- Ogre::String mBackground_Normal,mBackground_Active; // MaterialName Normal, MaterialName Active
- int x,y; unsigned int w, h; // Dimensions.
- ButtonMethodPtr mMethod;
- bool mHorizontalSlider;
- SliderValueRange* mRange;
- Window *mParent;
- };
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ const Ogre::String &getValue() const
+ {return mValueText;}
+
+ void setValue(const Ogre::String &v)
+ {
+ mCaptionOverlay->setCaption(mValueText = v);
+ mWidth = static_cast<int> (mValueText.size () * 7);
+ mParent->adjustSizeToContent ();
+ }
+
+ protected:
+
+ int length;
+ Ogre::String mValueText;
+ Window *mParent;
+ };
+ //------------------------------------------------------------------------------------------------
+ class RealButton : public BetaGUIListener, public Widget
+ {
+ public:
+ friend class Window;
+
+ RealButton(BetaGUI::Window *window,
+ Ogre::Real value,
+ const Ogre::Vector4 &SliderMoves,
+ const Ogre::String &label,
+ const Ogre::Vector2 &pos);
+
+ virtual ~RealButton(){};
+
+ Ogre::Real getValue() const {return mValue;}
+
+ void setValue(const Ogre::Real v);
+
+ void onButtonPress(BetaGUI::Button *ref, Ogre::uchar type);
+ protected:
+
+ int length;
+
+ BetaGUI::TextInput *mtextValueInput;
+ BetaGUI::Button *mForward, *mFastForward, *mRewind, *mFastRewind;
+
+ Ogre::Real mValue;
+ Ogre::String mValueText;
+
+ Ogre::Real mLowSlideUnit;
+ Ogre::Real mFastSlideUnit;
+ Ogre::Real mMinValue;
+ Ogre::Real mMaxValue;
+
+ };
+ //------------------------------------------------------------------------------------------------
+ class Effect
+ {
+ public:
+ enum EffectInterpolatorType
+ {
+ EFFECT_LINEAR = 0,
+ EFFECT_LINEARX2,
+ EFFECT_LINEARX4,
+ EFFECT_SIN
+ };
+ public:
+ Effect(Widget * const widget, const Ogre::Real duration,
+ const Ogre::Real startTime, const Ogre::Real currTime = 0, const bool repeat = false,
+ EffectInterpolatorType type = EFFECT_LINEARX4) :
+ mWidget(widget),
+ mStartTime(startTime),
+ mDuration(duration),
+ mRepeat(repeat),
+ mCurrTime(currTime),
+ mType(type)
+ {
+ assert (duration != 0);
+ }
+ virtual ~Effect(){};
+
+ virtual void updateValue(const Ogre::Real factor) = 0;
+
+ bool update(Ogre::Real timeElapsed);
+ Ogre::Real getTimeFactor() ;
+ bool getTimeOrIsFinished();
+// Ogre::Real linearInterpolate(const Ogre::Real start,
+// const Ogre::Real end,
+// const Ogre::Real timeFactor) const;
+ Ogre::Real interpolate(const Ogre::Real start,
+ const Ogre::Real end,
+ const Ogre::Real timeFactor) const;
+
+ protected:
+ Widget * const mWidget;
+ const Ogre::Real mStartTime;
+ const Ogre::Real mDuration;
+ const bool mRepeat;
+
+ Ogre::Real mCurrTime;
+ const EffectInterpolatorType mType;
+ };
+ //------------------------------------------------------------------------------------------------
+ class AlphaEffect : public Effect
+ {
+ public:
+
+ AlphaEffect(Widget * const widget,
+ const Ogre::Real duration,
+ const Ogre::Real startAlpha,
+ const Ogre::Real endAlpha,
+ const Ogre::Real startTime,
+ const Ogre::Real currTime = 0,
+ const bool repeat = false,
+ EffectInterpolatorType type = EFFECT_LINEARX4) :
+ Effect(widget, duration, startTime, currTime, repeat),
+ mStartAlpha(startAlpha),
+ mEndAlpha(endAlpha)
+ {
+ assert(mStartAlpha >= 0.0 && mStartAlpha <= 1.0);
+ assert(mEndAlpha >= 0.0 && mEndAlpha <= 1.0);
+ }
+ virtual ~AlphaEffect(){};
+
+ void updateValue(const Ogre::Real factor);
+ private:
+ const Ogre::Real mStartAlpha;
+ const Ogre::Real mEndAlpha;
+ };
+ //------------------------------------------------------------------------------------------------
+ class MoveEffect : public Effect
+ {
+ public:
+ MoveEffect(Widget * const widget,
+ const Ogre::Real duration,
+ const Ogre::Vector2 &startPosition,
+ const Ogre::Vector2 &endPosition,
+ const Ogre::Real startTime,
+ const Ogre::Real currTime = 0,
+ const bool repeat = false,
+ EffectInterpolatorType type = EFFECT_LINEARX4) :
+ Effect(widget, duration, startTime, currTime, repeat),
+ mStartPosition(startPosition),
+ mEndPosition(endPosition)
+ {}
+ virtual ~MoveEffect(){};
+ void updateValue(const Ogre::Real factor);
+
+ private:
+ const Ogre::Vector2 mStartPosition;
+ const Ogre::Vector2 mEndPosition;
+ };
+ //------------------------------------------------------------------------------------------------
+ class SizeEffect : public Effect
+ {
+ public:
+ SizeEffect(Widget * const widget,
+ const Ogre::Real duration,
+ const Ogre::Vector2 &startSize,
+ const Ogre::Vector2 &endSize,
+ const Ogre::Real startTime,
+ const Ogre::Real currTime = 0,
+ const bool repeat = false,
+ EffectInterpolatorType type = EFFECT_LINEARX4) :
+ Effect(widget, duration, startTime, currTime, repeat),
+ mStartSize(startSize),
+ mEndSize(endSize)
+ {}
+ virtual ~SizeEffect(){};
+ void updateValue(const Ogre::Real factor);
+
+ private:
+ const Ogre::Vector2 mStartSize;
+ const Ogre::Vector2 mEndSize;
+ };
+ //------------------------------------------------------------------------------------------------
+ class ActivateEffect : public Effect
+ {
+ public:
+ ActivateEffect(Widget * const widget,
+ const Ogre::Real duration,
+ const Ogre::Real startTime,
+ const Ogre::Real currTime = 0,
+ const bool repeat = false,
+ EffectInterpolatorType type = EFFECT_LINEARX4):
+ Effect(widget, duration, startTime, currTime, repeat)
+ {};
+ virtual ~ActivateEffect(){};
+ void updateValue(const Ogre::Real factor);
+
+ };
+ //------------------------------------------------------------------------------------------------
+ class OverEffect : public Effect
+ {
+ public:
+ OverEffect(Widget * const widget,
+ const Ogre::Real duration,
+ const Ogre::Real startTime,
+ const Ogre::Real currTime = 0,
+ const bool repeat = false,
+ EffectInterpolatorType type = EFFECT_LINEARX4):
+ Effect(widget, duration, startTime, currTime, repeat)
+ {};
+ virtual ~OverEffect(){};
+ void updateValue(const Ogre::Real factor);
+
+ };
+ //------------------------------------------------------------------------------------------------
+
+
} // End of Namespace
-#endif
\ No newline at end of file
+
+///////////////////////////////////////////////////////////////////////////////
+#endif
+
Modified: trunk/python-ogre/ThirdParty/betagui/BetaGui.cpp
===================================================================
--- trunk/python-ogre/ThirdParty/betagui/BetaGui.cpp 2008-02-23 06:13:35 UTC (rev 577)
+++ trunk/python-ogre/ThirdParty/betagui/BetaGui.cpp 2008-02-24 08:05:30 UTC (rev 578)
@@ -1,463 +1,1269 @@
-// Betajaen's GUI "BetaGUI 2.0", Version 35-uncompressed, http://www.ogre3d.org/wiki/index.php/BetaGUI
-//
-// Copyright (c) 2007 Robin Southern <bet...@ih...>
-//
-// Permission is hereby granted, free of charge, to any person
-// obtaining a copy of this software and associated documentation
-// files (the "Software"), to deal in the Software without
-// restriction, including without limitation the rights to use,
-// copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the
-// Software is furnished to do so, subject to the following
-// conditions:
-//
-// The above copyright notice and this permission notice shall be
-// included in all copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
-// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
-// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
-// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-// OTHER DEALINGS IN THE SOFTWARE.
-
#include "BetaGUI.h"
-#include "OgreFontManager.h"
-#include "OgreFont.h"
-#include "OgreTextAreaOverlayElement.h"
-namespace BetaGUI {
- ////////////////////////////////////////////////////////////////////////////////////
- WidgetStyle::WidgetStyle(const Ogre::String &style) {
- mBackground = "default"; centerText = false; mColour = Ogre::ColourValue::White; mDecalSize = 0;
- mHeight = 16; mFontSize = 0; mFontFace = ""; if (style.length()>=0) fromStyle(style);}
- ////////////////////////////////////////////////////////////////////////////////////
- GUI::GUI(Ogre::RenderWindow* w) : mWindowToDestroy(0), mMousePointer(0), mWindowCount(0), mButtonCount(0),
- mTextInputCount(0), mRenderWindowWidth(w->getWidth()), mRenderWindowHeight(w->getHeight()),
- mWindowRatio(Ogre::Real(mRenderWindowWidth) / Ogre::Real(mRenderWindowHeight)) {
- mOverlay = Ogre::OverlayManager::getSingleton().create("BetaGUI");
- mOverlay->show();}
- ////////////////////////////////////////////////////////////////////////////////////
- GUI::~GUI() {
- for(unsigned int i=0;i < mWindow.size();i++) delete mWindow[i];
- for (std::map<Ogre::String, Style*>::iterator it = mStyle.begin();it!=mStyle.end();it++) delete (*it).second;
- mStyle.clear(); mWindow.clear();}
- ////////////////////////////////////////////////////////////////////////////////////
- bool GUI::injectRelMouse(int x, int y, bool LMB) {
- return injectMouse(mMousePointer->getLeft() + x, mMousePointer->getTop() + y, LMB);}
- ////////////////////////////////////////////////////////////////////////////////////
- bool GUI::injectMouse(unsigned int x, unsigned int y, bool LMB) {
-
- if (mMousePointer)
- mMousePointer->setPosition(x,y);
+namespace BetaGUI
+{
+ //------------------------------------------------------------------------------------------------
+ GUI::GUI(const String &baseOverlay, const String &font, int fontSize, RenderWindow *win)
+ :mNextWindowToDestroy(0),
+ mMousePointerOverlay(0),
+ mFont(font),
+ mFontSize(fontSize),
+ mWindowCount(0),
+ mButtonCount(0),
+ mTextCaptionCount(0),
+ mTextCaptionCountArea(0),
+ mButtonCountTextArea(0),
+ mNextMenuWindowPos(0,0),
+ mMenuWindow(0),
+ mRenderWindow(win),
+ mDragWindowAction(WA_NONE),
+ mActiveDraggedWindow(0),
+ mActiveTextInput(0),
+ mActiveButton(0),
+ mUpTime(0),
+ mFarZ(100),
+ mNearZ(101),
+ mName(baseOverlay)
+ {
+
+ }
+ //------------------------------------------------------------------------------------------------
+ GUI::~GUI()
+ {
+ for(std::vector<Window*>::iterator i=mWindows.begin();i!=mWindows.end();++i)
+ {
+ delete (*i);
+ }
- for(std::vector<Window*>::iterator i=mWindow.begin();i!=mWindow.end();i++) {
- if (mWindowToDestroy == (*i)) {
- delete (*i);
- mWindow.erase(i);
- mWindowToDestroy = 0;
- return false;
- }
+ std::list<Effect*>::iterator itEffect = mActiveEffects.begin();
+ while (itEffect != mActiveEffects.end())
+ {
+ delete *itEffect;
+ ++itEffect;
+ }
+ }
+ //------------------------------------------------------------------------------------------------
+ void GUI::setZRangeOrder(int nearZ, int FarZ)
+ {
+ assert (mNearZ > mFarZ);
+ mNearZ = nearZ;
+ mFarZ = FarZ;
+ sortZOrder();
+ };
+ //------------------------------------------------------------------------------------------------
+ void GUI::sortZOrder()
+ {
+ assert (mNearZ > mFarZ);
+ int farZ = mFarZ;
+ for(std::vector<Window*>::iterator i=mWindows.begin();i!=mWindows.end();++i)
+ {
+ (*i)->setZOrder(farZ) ;
+ if (farZ + 1 < mNearZ)
+ farZ++;
+ }
+ if (mActiveDraggedWindow)
+ mActiveDraggedWindow->setZOrder(mNearZ) ;
+ }
+ //------------------------------------------------------------------------------------------------
+ void GUI::update (Ogre::Real timeElapsed)
+ {
+ mUpTime += timeElapsed;
- if((*i)->check(x,y,LMB)) {
- return true;
- }
- }
-
+ {
+ std::vector<Window*>::iterator itWindow = mWindows.begin();
+ while (itWindow != mWindows.end())
+ {
+ (*itWindow)->setUnderEffect(false);
+ ++itWindow;
+ }
+ }
+ {
+ std::list<Effect*>::iterator itEffect = mActiveEffects.begin();
+ while (itEffect != mActiveEffects.end())
+ {
+ if ((*itEffect)->update(timeElapsed))
+ {
+ delete *itEffect;
+ itEffect = mActiveEffects.erase(itEffect);
+ }
+ else
+ {
+ ++itEffect;
+ }
+ }
+ }
+ if (mNextWindowToDestroy)
+ {
+ for(std::vector<Window*>::iterator i=mWindows.begin();i!=mWindows.end();++i)
+ {
+ if(mNextWindowToDestroy==(*i))
+ {
+ delete mNextWindowToDestroy;
+ mWindows.erase(i);
+ mNextWindowToDestroy=0;
+ }
+ }
+ }
+ }
+ //------------------------------------------------------------------------------------------------
+ void GUI::addEffect (Effect* e)
+ {
+ mActiveEffects.push_back(e);
+ }
+ //-----------------------------------------------------------------------------
+ bool GUI::injectMouse(float x, float y, bool LMB)
+ {
+ return injectMouse ( int(x), int(y), LMB );
+ }
+
+ bool GUI::injectMouse(int x, int y, bool LMB)
+ {
+ // if (mMousePointerOverlay)
+ // {
+ // mMousePointerOverlay->hide ();
+ mMousePointerOverlay->setPosition(x,y);
+ // }
+
+
+ if (LMB)
+ {
+ if (mActiveTextInput)
+ {
+ mActiveTextInput->mMainOverlay->setMaterialName(mActiveTextInput->mMaterialName);
+ mActiveTextInput = 0;
+ }
+
+
+ if (mActiveButton && mActiveDraggedWindow)
+ {
+ if (mActiveDraggedWindow->mDragType == WA_MOVE)
+ {
+ mDragWindowAction = WA_MOVE;
+ mActiveDraggedWindow->setPosition (
+ mDragWindowX + (x - mDragX),
+ mDragWindowY + (y - mDragY)
+ );
+ return true;
+ }
+ else if (mActiveDraggedWindow->mDragType == WA_RESIZE)
+ {
+ mDragWindowAction = WA_RESIZE;
+ mActiveDraggedWindow->setSize (
+ mDragWindowX + (x - mDragX),
+ mDragWindowY + (y - mDragY)
+ );
+ return true;
+ }
+ }
+ }
+ else if (mDragWindowAction != WA_NONE)
+ {
+ mDragWindowAction = WA_NONE;
+ mActiveDraggedWindow = 0;
+ sortZOrder ();
+ }
+
+ assert (mDragWindowAction == WA_NONE) ;
+ for(std::vector<Window*>::iterator i=mWindows.begin();i!=mWindows.end();++i)
+ {
+ if((*i)->isVisible() &&
+ (*i)->check(x, y, LMB))
+ {
+ mActiveDraggedWindow = (*i);
+ sortZOrder ();
+
+ //if (mMousePointerOverlay)
+ // mMousePointerOverlay->show ();
+ return true;
+ }
+ }
+
return false;
- }
- ////////////////////////////////////////////////////////////////////////////////////
- bool GUI::injectKey(const Ogre::String& key, unsigned int x, unsigned int y) {
- for(unsigned int i=0;i<mWindow.size();i++) {
- if(mWindow[i]->checkKey(key,x,y)) {
- return true;}}
- return false;
- }
- ////////////////////////////////////////////////////////////////////////////////////
-/* void GUI::injectBackspace(unsigned int x, unsigned int y) {
+ }
+ //------------------------------------------------------------------------------------------------
+ bool GUI::injectKey(const String &key, int x, int y)
+ {
+ if (mActiveTextInput == 0 || key.empty())
+ return false;
+
+ if (key == "!b")
+ {
+ mActiveTextInput->setValue(
+ mActiveTextInput->mValueText.substr(0, mActiveTextInput->mValueText.length()-1)
+ );
+ return true;
+ }
+
+ if (mActiveTextInput->mValueText.length() >= mActiveTextInput->length)
+ return true;
+
+ mActiveTextInput->mCaptionOverlay->setCaption(mActiveTextInput->mValueText += key);
+ return false;
+ }
+ //------------------------------------------------------------------------------------------------
+ void GUI::injectBackspace(int x, int y)
+ {
injectKey("!b", x, y);
- }
-*/
- ////////////////////////////////////////////////////////////////////////////////////
- Ogre::OverlayContainer* GUI::__getOverlay(const Ogre::String& name, const Ogre::String& type,int x,int y, int w, int h) {
- Ogre::OverlayContainer* oc; try { oc = static_cast<Ogre::OverlayContainer*>(Ogre::OverlayManager::getSingleton().getOverlayElement(name));
- }catch(...) {oc = static_cast<Ogre::OverlayContainer*>(Ogre::OverlayManager::getSingleton().createOverlayElement(type, name));}
- oc->setMetricsMode(Ogre::GMM_PIXELS);
- if (x==0&&y==0&&w==0)return oc; oc->setPosition(x,y); oc->setDimensions(w,h); return oc;
- }
- ////////////////////////////////////////////////////////////////////////////////////
- Ogre::OverlayContainer* GUI::createOverlayFromWidgetStyle(const Ogre::String &name, const Ogre::String &styleName, const Ogre::String &widgetType, int x, int y, const Ogre::String &text) {
- WidgetStyle ws = mStyle[styleName]->mWidgets[widgetType];
- Ogre::OverlayContainer* oc = __getOverlay(name,"Panel", x,y, 32, ws.mHeight);
- oc->setMaterialName(ws.mBackground);
- if (text.length() >= 1) {
- int fontSize = ws.mFontSize ? ws.mFontSize : mStyle[styleName]->mFontSize;
- Ogre::String fontName = ws.mFontFace.length() ? ws.mFontFace : mStyle[styleName]->mFontFace;
- Ogre::OverlayContainer* caption = __getOverlay(name + "-caption", "TextArea", 0,((ws.mHeight * 0.5f) - ((float) fontSize) * 0.5f) * mWindowRatio, 32, fontSize);
- oc->addChild(caption);
- caption->setCaption(text);caption->setParameter("font_name", fontName);caption->setParameter("char_height", Ogre::StringConverter::toString(fontSize));
- Ogre::Font* f = dynamic_cast<Ogre::Font*>(Ogre::FontManager::getSingletonPtr()->getByName(fontName).get());
- f->setTrueTypeSize(fontSize); float textWidth = 0; Ogre::Real sp = f->getGlyphAspectRatio(0x0030) * fontSize;
- for(unsigned int i=0; i < text.length();i++){
- if (text[i] == 0x0020) textWidth += sp;
- else textWidth += f->getGlyphAspectRatio(text[i]) * fontSize;}
- oc->setWidth(Ogre::Math::Ceil(textWidth * 1.25f)); caption->setWidth(textWidth); caption->setHeight(fontSize);
- if (ws.centerText) caption->setLeft(textWidth * 0.125f);
- caption->setColour(ws.mColour);}
- return oc;
- }
- ////////////////////////////////////////////////////////////////////////////////////
- Ogre::OverlayContainer* GUI::createOverlayFromWindowStyle(const Ogre::String &name, const Ogre::String &styleName, int x, int y, int w, int h) {
- Ogre::OverlayContainer* oc = __getOverlay(name);
- oc->setPosition(x,y);oc->setDimensions(w,h);oc->setMaterialName(mStyle[styleName]->mWindow_Background);
- return oc;
- }
- ////////////////////////////////////////////////////////////////////////////////////
- void GUI::__updateCenteredOverlay(Ogre::OverlayContainer* overlay) {
- Ogre::OverlayContainer* caption = static_cast<Ogre::OverlayContainer*>(overlay->getChild(overlay->getName() + "-caption"));
- caption->setLeft((overlay->getWidth() * 0.5f) - (caption->getWidth() * 0.5f));
- caption->setTop(2 + (overlay->getHeight() * 0.5f) - (caption->getHeight() * 0.5f));
- }
- ////////////////////////////////////////////////////////////////////////////////////
- Ogre::OverlayContainer* GUI::createMousePointer(const Ogre::String& m, unsigned int w, unsigned int h) {
- Ogre::Overlay* o = Ogre::OverlayManager::getSingleton().create("BetaGUI.MP");
- mMousePointer = __getOverlay("BetaGUI.MousePointer", "Panel", mRenderWindowWidth * 0.5f, mRenderWindowHeight * 0.5f, w, h);
- mMousePointer->setMaterialName(m);
- o->setZOrder(649); o->add2D(mMousePointer); o->show(); mMousePointer->show();
- return mMousePointer;
- }
- ////////////////////////////////////////////////////////////////////////////////////
- Style* GUI::createStyle(const Ogre::String& name) {
- mStyle[name] = new Style;
- return mStyle[name];
- }
- ////////////////////////////////////////////////////////////////////////////////////
- Window* GUI::createWindow(int x, int y, unsigned int width, unsigned int height, const Ogre::String& style, WindowFeatureType type, const Ogre::String& caption, GUIListener* listener) {
- Window* window = new BetaGUI::Window(x,y,width,height, style,type,caption, listener, this);
- mWindow.push_back(window);
- return window;
- }
- ////////////////////////////////////////////////////////////////////////////////////
- void GUI::destroyWindow(Window *window) {
- mWindowToDestroy=window;}
- ////////////////...
[truncated message content] |