From: <and...@us...> - 2007-12-02 06:20:46
|
Revision: 482 http://python-ogre.svn.sourceforge.net/python-ogre/?rev=482&view=rev Author: andy_miller Date: 2007-12-01 22:20:51 -0800 (Sat, 01 Dec 2007) Log Message: ----------- Missing files... Added Paths: ----------- trunk/python-ogre/ThirdParty/betagui/old/ trunk/python-ogre/ThirdParty/betagui/old/BetaGUI.h trunk/python-ogre/ThirdParty/betagui/old/BetaGui.cpp trunk/python-ogre/ThirdParty/betagui/old/BetaGui.py trunk/python-ogre/ThirdParty/caelum/CameraBoundElement.cpp trunk/python-ogre/ThirdParty/ptypes/ trunk/python-ogre/ThirdParty/ptypes/LICENSE trunk/python-ogre/ThirdParty/ptypes/Makefile trunk/python-ogre/ThirdParty/ptypes/doc/ trunk/python-ogre/ThirdParty/ptypes/doc/async.examples.html trunk/python-ogre/ThirdParty/ptypes/doc/async.html trunk/python-ogre/ThirdParty/ptypes/doc/async.jobqueue.html trunk/python-ogre/ThirdParty/ptypes/doc/async.message.html trunk/python-ogre/ThirdParty/ptypes/doc/async.msgqueue.html trunk/python-ogre/ThirdParty/ptypes/doc/async.mutex.html trunk/python-ogre/ThirdParty/ptypes/doc/async.rwlock.html trunk/python-ogre/ThirdParty/ptypes/doc/async.semaphore.html trunk/python-ogre/ThirdParty/ptypes/doc/async.thread.html trunk/python-ogre/ThirdParty/ptypes/doc/async.trigger.html trunk/python-ogre/ThirdParty/ptypes/doc/async.utils.html trunk/python-ogre/ThirdParty/ptypes/doc/basic.html trunk/python-ogre/ThirdParty/ptypes/doc/changes.html trunk/python-ogre/ThirdParty/ptypes/doc/compiling.html trunk/python-ogre/ThirdParty/ptypes/doc/criterrors.html trunk/python-ogre/ThirdParty/ptypes/doc/cset.constructors.html trunk/python-ogre/ThirdParty/ptypes/doc/cset.html trunk/python-ogre/ThirdParty/ptypes/doc/cset.manipulation.html trunk/python-ogre/ThirdParty/ptypes/doc/cset.operators.html trunk/python-ogre/ThirdParty/ptypes/doc/deploying.html trunk/python-ogre/ThirdParty/ptypes/doc/freshmeat-logo.png trunk/python-ogre/ThirdParty/ptypes/doc/htsrc.html trunk/python-ogre/ThirdParty/ptypes/doc/include/ trunk/python-ogre/ThirdParty/ptypes/doc/include/pasync.h.html trunk/python-ogre/ThirdParty/ptypes/doc/include/pinet.h.html trunk/python-ogre/ThirdParty/ptypes/doc/include/pport.h.html trunk/python-ogre/ThirdParty/ptypes/doc/include/pstreams.h.html trunk/python-ogre/ThirdParty/ptypes/doc/include/ptime.h.html trunk/python-ogre/ThirdParty/ptypes/doc/include/ptypes.h.html trunk/python-ogre/ThirdParty/ptypes/doc/index.html trunk/python-ogre/ThirdParty/ptypes/doc/inet.examples.html trunk/python-ogre/ThirdParty/ptypes/doc/inet.html trunk/python-ogre/ThirdParty/ptypes/doc/inet.ipmessage.html trunk/python-ogre/ThirdParty/ptypes/doc/inet.ipmsgserver.html trunk/python-ogre/ThirdParty/ptypes/doc/inet.ipstmserver.html trunk/python-ogre/ThirdParty/ptypes/doc/inet.ipstream.html trunk/python-ogre/ThirdParty/ptypes/doc/inet.utils.html trunk/python-ogre/ThirdParty/ptypes/doc/intro.html trunk/python-ogre/ThirdParty/ptypes/doc/lists.html trunk/python-ogre/ThirdParty/ptypes/doc/lists.textmap.html trunk/python-ogre/ThirdParty/ptypes/doc/lists.tobjlist.html trunk/python-ogre/ThirdParty/ptypes/doc/lists.tpodlist.html trunk/python-ogre/ThirdParty/ptypes/doc/lists.tstrlist.html trunk/python-ogre/ThirdParty/ptypes/doc/portability.html trunk/python-ogre/ThirdParty/ptypes/doc/ref.html trunk/python-ogre/ThirdParty/ptypes/doc/ref.tmpl.html trunk/python-ogre/ThirdParty/ptypes/doc/source-forge-logo.png trunk/python-ogre/ThirdParty/ptypes/doc/streams.errors.html trunk/python-ogre/ThirdParty/ptypes/doc/streams.examples.html trunk/python-ogre/ThirdParty/ptypes/doc/streams.html trunk/python-ogre/ThirdParty/ptypes/doc/streams.infile.html trunk/python-ogre/ThirdParty/ptypes/doc/streams.inmem.html trunk/python-ogre/ThirdParty/ptypes/doc/streams.instm.html trunk/python-ogre/ThirdParty/ptypes/doc/streams.iobase.html trunk/python-ogre/ThirdParty/ptypes/doc/streams.logfile.html trunk/python-ogre/ThirdParty/ptypes/doc/streams.md5.html trunk/python-ogre/ThirdParty/ptypes/doc/streams.namedpipe.html trunk/python-ogre/ThirdParty/ptypes/doc/streams.npserver.html trunk/python-ogre/ThirdParty/ptypes/doc/streams.outfile.html trunk/python-ogre/ThirdParty/ptypes/doc/streams.outmem.html trunk/python-ogre/ThirdParty/ptypes/doc/streams.outstm.html trunk/python-ogre/ThirdParty/ptypes/doc/streams.stdio.html trunk/python-ogre/ThirdParty/ptypes/doc/string.constructors.html trunk/python-ogre/ThirdParty/ptypes/doc/string.conversion.html trunk/python-ogre/ThirdParty/ptypes/doc/string.html trunk/python-ogre/ThirdParty/ptypes/doc/string.manipulation.html trunk/python-ogre/ThirdParty/ptypes/doc/string.operators.html trunk/python-ogre/ThirdParty/ptypes/doc/string.typecasts.html trunk/python-ogre/ThirdParty/ptypes/doc/styles.css trunk/python-ogre/ThirdParty/ptypes/doc/time.calendar.html trunk/python-ogre/ThirdParty/ptypes/doc/time.datetime.html trunk/python-ogre/ThirdParty/ptypes/doc/time.html trunk/python-ogre/ThirdParty/ptypes/doc/time.time.html trunk/python-ogre/ThirdParty/ptypes/doc/title-21.png trunk/python-ogre/ThirdParty/ptypes/doc/unit.html trunk/python-ogre/ThirdParty/ptypes/doc/unknown.html trunk/python-ogre/ThirdParty/ptypes/doc/variant.arrays.html trunk/python-ogre/ThirdParty/ptypes/doc/variant.html trunk/python-ogre/ThirdParty/ptypes/doc/variant.objrefs.html trunk/python-ogre/ThirdParty/ptypes/doc/variant.typecasts.html trunk/python-ogre/ThirdParty/ptypes/doc/variant.utils.html trunk/python-ogre/ThirdParty/ptypes/doc/wshare.html trunk/python-ogre/ThirdParty/ptypes/include/ trunk/python-ogre/ThirdParty/ptypes/include/pasync.h trunk/python-ogre/ThirdParty/ptypes/include/pinet.h trunk/python-ogre/ThirdParty/ptypes/include/pport.h trunk/python-ogre/ThirdParty/ptypes/include/pstreams.h trunk/python-ogre/ThirdParty/ptypes/include/ptime.h trunk/python-ogre/ThirdParty/ptypes/include/ptypes/ trunk/python-ogre/ThirdParty/ptypes/include/ptypes/pasync.h trunk/python-ogre/ThirdParty/ptypes/include/ptypes/pinet.h trunk/python-ogre/ThirdParty/ptypes/include/ptypes/pport.h trunk/python-ogre/ThirdParty/ptypes/include/ptypes/pstreams.h trunk/python-ogre/ThirdParty/ptypes/include/ptypes/ptime.h trunk/python-ogre/ThirdParty/ptypes/include/ptypes/ptypes.h trunk/python-ogre/ThirdParty/ptypes/include/ptypes.h trunk/python-ogre/ThirdParty/ptypes/index.html trunk/python-ogre/ThirdParty/ptypes/src/ trunk/python-ogre/ThirdParty/ptypes/src/Makefile.Darwin trunk/python-ogre/ThirdParty/ptypes/src/Makefile.FreeBSD trunk/python-ogre/ThirdParty/ptypes/src/Makefile.HP-UX trunk/python-ogre/ThirdParty/ptypes/src/Makefile.Linux trunk/python-ogre/ThirdParty/ptypes/src/Makefile.SunOS trunk/python-ogre/ThirdParty/ptypes/src/Makefile.common trunk/python-ogre/ThirdParty/ptypes/src/pasync.cxx trunk/python-ogre/ThirdParty/ptypes/src/patomic.cxx trunk/python-ogre/ThirdParty/ptypes/src/patomic.sparc.s trunk/python-ogre/ThirdParty/ptypes/src/pcomponent.cxx trunk/python-ogre/ThirdParty/ptypes/src/pcset.cxx trunk/python-ogre/ThirdParty/ptypes/src/pcsetdbg.cxx trunk/python-ogre/ThirdParty/ptypes/src/pexcept.cxx trunk/python-ogre/ThirdParty/ptypes/src/pfatal.cxx trunk/python-ogre/ThirdParty/ptypes/src/pfdxstm.cxx trunk/python-ogre/ThirdParty/ptypes/src/pinfile.cxx trunk/python-ogre/ThirdParty/ptypes/src/pinfilter.cxx trunk/python-ogre/ThirdParty/ptypes/src/pinmem.cxx trunk/python-ogre/ThirdParty/ptypes/src/pinstm.cxx trunk/python-ogre/ThirdParty/ptypes/src/pintee.cxx trunk/python-ogre/ThirdParty/ptypes/src/piobase.cxx trunk/python-ogre/ThirdParty/ptypes/src/pipbase.cxx trunk/python-ogre/ThirdParty/ptypes/src/pipmsg.cxx trunk/python-ogre/ThirdParty/ptypes/src/pipmsgsv.cxx trunk/python-ogre/ThirdParty/ptypes/src/pipstm.cxx trunk/python-ogre/ThirdParty/ptypes/src/pipstmsv.cxx trunk/python-ogre/ThirdParty/ptypes/src/pipsvbase.cxx trunk/python-ogre/ThirdParty/ptypes/src/pmd5.cxx trunk/python-ogre/ThirdParty/ptypes/src/pmem.cxx trunk/python-ogre/ThirdParty/ptypes/src/pmsgq.cxx trunk/python-ogre/ThirdParty/ptypes/src/pmtxtable.cxx trunk/python-ogre/ThirdParty/ptypes/src/pnpipe.cxx trunk/python-ogre/ThirdParty/ptypes/src/pnpserver.cxx trunk/python-ogre/ThirdParty/ptypes/src/pobjlist.cxx trunk/python-ogre/ThirdParty/ptypes/src/poutfile.cxx trunk/python-ogre/ThirdParty/ptypes/src/poutfilter.cxx trunk/python-ogre/ThirdParty/ptypes/src/poutmem.cxx trunk/python-ogre/ThirdParty/ptypes/src/poutstm.cxx trunk/python-ogre/ThirdParty/ptypes/src/ppipe.cxx trunk/python-ogre/ThirdParty/ptypes/src/ppodlist.cxx trunk/python-ogre/ThirdParty/ptypes/src/pputf.cxx trunk/python-ogre/ThirdParty/ptypes/src/prwlock.cxx trunk/python-ogre/ThirdParty/ptypes/src/psemaphore.cxx trunk/python-ogre/ThirdParty/ptypes/src/pstdio.cxx trunk/python-ogre/ThirdParty/ptypes/src/pstrcase.cxx trunk/python-ogre/ThirdParty/ptypes/src/pstrconv.cxx trunk/python-ogre/ThirdParty/ptypes/src/pstring.cxx trunk/python-ogre/ThirdParty/ptypes/src/pstrlist.cxx trunk/python-ogre/ThirdParty/ptypes/src/pstrmanip.cxx trunk/python-ogre/ThirdParty/ptypes/src/pstrtoi.cxx trunk/python-ogre/ThirdParty/ptypes/src/pstrutils.cxx trunk/python-ogre/ThirdParty/ptypes/src/ptextmap.cxx trunk/python-ogre/ThirdParty/ptypes/src/pthread.cxx trunk/python-ogre/ThirdParty/ptypes/src/ptime.cxx trunk/python-ogre/ThirdParty/ptypes/src/ptimedsem.cxx trunk/python-ogre/ThirdParty/ptypes/src/ptrigger.cxx trunk/python-ogre/ThirdParty/ptypes/src/ptypes_test.cxx trunk/python-ogre/ThirdParty/ptypes/src/punit.cxx trunk/python-ogre/ThirdParty/ptypes/src/punknown.cxx trunk/python-ogre/ThirdParty/ptypes/src/pvariant.cxx trunk/python-ogre/ThirdParty/ptypes/src/pversion.cxx trunk/python-ogre/ThirdParty/ptypes/win32/ trunk/python-ogre/ThirdParty/ptypes/win32/PTypes.sln trunk/python-ogre/ThirdParty/ptypes/win32/PTypes_DLL.vcproj trunk/python-ogre/ThirdParty/ptypes/win32/PTypes_Lib.vcproj trunk/python-ogre/ThirdParty/ptypes/win32/PTypes_Lib_ST.vcproj trunk/python-ogre/ThirdParty/ptypes/win32/PTypes_Test.vcproj trunk/python-ogre/ThirdParty/ptypes/win32/PTypes_Test_ST.vcproj trunk/python-ogre/ThirdParty/ptypes/win32/dll_version.rc trunk/python-ogre/ThirdParty/ptypes/win32/resource.h trunk/python-ogre/ThirdParty/ptypes/win32/wshare.vcproj trunk/python-ogre/ThirdParty/ptypes/wshare/ trunk/python-ogre/ThirdParty/ptypes/wshare/Makefile.Darwin trunk/python-ogre/ThirdParty/ptypes/wshare/Makefile.FreeBSD trunk/python-ogre/ThirdParty/ptypes/wshare/Makefile.HP-UX trunk/python-ogre/ThirdParty/ptypes/wshare/Makefile.Linux trunk/python-ogre/ThirdParty/ptypes/wshare/Makefile.SunOS trunk/python-ogre/ThirdParty/ptypes/wshare/Makefile.common trunk/python-ogre/ThirdParty/ptypes/wshare/clients.cxx trunk/python-ogre/ThirdParty/ptypes/wshare/clients.h trunk/python-ogre/ThirdParty/ptypes/wshare/config.cxx trunk/python-ogre/ThirdParty/ptypes/wshare/config.h trunk/python-ogre/ThirdParty/ptypes/wshare/log.cxx trunk/python-ogre/ThirdParty/ptypes/wshare/log.h trunk/python-ogre/ThirdParty/ptypes/wshare/mimetable.awk trunk/python-ogre/ThirdParty/ptypes/wshare/mimetable.cxx trunk/python-ogre/ThirdParty/ptypes/wshare/mod_about.cxx trunk/python-ogre/ThirdParty/ptypes/wshare/mod_file.cxx trunk/python-ogre/ThirdParty/ptypes/wshare/mod_wstat.cxx trunk/python-ogre/ThirdParty/ptypes/wshare/modules.cxx trunk/python-ogre/ThirdParty/ptypes/wshare/modules.h trunk/python-ogre/ThirdParty/ptypes/wshare/request.cxx trunk/python-ogre/ThirdParty/ptypes/wshare/request.h trunk/python-ogre/ThirdParty/ptypes/wshare/sysutils.cxx trunk/python-ogre/ThirdParty/ptypes/wshare/sysutils.h trunk/python-ogre/ThirdParty/ptypes/wshare/urlutils.cxx trunk/python-ogre/ThirdParty/ptypes/wshare/urlutils.h trunk/python-ogre/ThirdParty/ptypes/wshare/utils.cxx trunk/python-ogre/ThirdParty/ptypes/wshare/utils.h trunk/python-ogre/ThirdParty/ptypes/wshare/wshare.cxx trunk/python-ogre/ThirdParty/quickgui/QuickGUICheckBox.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUICheckBox.h trunk/python-ogre/ThirdParty/quickgui/QuickGUIPrecompiledHeaders.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUIPrecompiledHeaders.h trunk/python-ogre/ThirdParty/quickgui/QuickGUIPrerequisites.h trunk/python-ogre/ThirdParty/quickgui/QuickGUISkinSetManager.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUISkinSetManager.h trunk/python-ogre/ThirdParty/quickgui/QuickGUITextHelper.cpp trunk/python-ogre/ThirdParty/quickgui/QuickGUITextHelper.h Added: trunk/python-ogre/ThirdParty/betagui/old/BetaGUI.h =================================================================== --- trunk/python-ogre/ThirdParty/betagui/old/BetaGUI.h (rev 0) +++ trunk/python-ogre/ThirdParty/betagui/old/BetaGUI.h 2007-12-02 06:20:51 UTC (rev 482) @@ -0,0 +1,638 @@ +#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" + +#include <iostream> + +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: + + 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(); + + 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: + 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: + + + 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 + + std::vector<Button*> mButtons; // Buttons + std::vector<TextInput*> mTextInput; // TextInputs + + Ogre::Overlay *mGuiOverlay; + + void addWidget(const Widget * const w, WindowPlacementType wpt); + Ogre::Vector2 mNextWidgetPos; + WindowActivity mDragType; + + bool mFadeOut; + + }; + //------------------------------------------------------------------------------------------------ + class BetaGUIListener + { + public: + virtual void onButtonPress(Button*, unsigned char) = 0; + }; + //------------------------------------------------------------------------------------------------ + class Callback + { + public: + friend class Window; + friend class Button; + + Callback() { + mCallbackType=0; + } + + Callback( void(*functionPointer)(BetaGUI::Button*, bool) ) { + mCallbackType=1; + fp = functionPointer; + } + + Callback(BetaGUIListener *l){ + mCallbackType = 2; + mListener = l; + } + protected: + 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: + 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() {} + + 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) ; + + 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(){}; + + 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: + unsigned int length; + Ogre::String mValueText;// MaterialName Normal, MaterialName Active + + }; + //------------------------------------------------------------------------------------------------ + class StaticText : public Widget + { + public: + friend class Window; + + StaticText(const Ogre::Vector4 &Dimensions, + const Ogre::String &Value, + Window *parent); + virtual ~StaticText(){} + + 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 + Added: trunk/python-ogre/ThirdParty/betagui/old/BetaGui.cpp =================================================================== --- trunk/python-ogre/ThirdParty/betagui/old/BetaGui.cpp (rev 0) +++ trunk/python-ogre/ThirdParty/betagui/old/BetaGui.cpp 2007-12-02 06:20:51 UTC (rev 482) @@ -0,0 +1,1269 @@ +#include "BetaGUI.h" + +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); + } + + 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; + + { + 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 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); + } + //------------------------------------------------------------------------------------------------ + OverlayContainer* GUI::createOverlay(const String &name, const Vector2 &position, + const Vector2 &dimensions, const String &material, + const String &caption) + { + OverlayContainer* e; + const bool isTextArea = !caption.empty(); + try + { + e = static_cast<OverlayContainer*> + (OverlayManager::getSingleton().getOverlayElement (name)); + } + catch (...) + { + e = static_cast<OverlayContainer*> + (OverlayManager::getSingleton().createOverlayElement( + (isTextArea ? "TextArea" : "Panel" ), + name)); + } + + e->setMetricsMode(Ogre::GMM_PIXELS); + e->setDimensions(dimensions.x, dimensions.y); + e->setPosition(position.x, position.y); + + if (!material.empty()) + e->setMaterialName(material); + + if (isTextArea) + { + e->setCaption(caption); + e->setParameter("font_name", mFont); + e->setParameter("char_height", StringConverter::toString(mFontSize)); + + e->setParameter("colour_top", + StringConverter::toString(ColourValue(0.57, 0.86, 0.68, 1.00))); + e->setParameter("colour_bottom", + StringConverter::toString(ColourValue(0.68, 0.86, 0.68, 1.00))); + } + return e; + } + //------------------------------------------------------------------------------------------------ + OverlayContainer* GUI::createMousePointer(Vector2 d, const String &m) + { + Overlay* o = (Overlay*)OverlayManager::getSingleton().getByName("BetaGUI.MP"); + if (!o) + o = OverlayManager::getSingleton().create("BetaGUI.MP"); + + o->setZOrder(648); + + mMousePointerOverlay = createOverlay("bg.mp", Vector2(0,0), d, m, ""); + + if (mMousePointerOverlay != o->getChild (mMousePointerOverlay->getName ())) + o->add2D(mMousePointerOverlay); + o->show(); + mMousePointerOverlay->show(); + return mMousePointerOverlay; + } + //------------------------------------------------------------------------------------------------ + Window* GUI::createWindow(const Vector4 &Dimensions, const String & Material, WindowFeatureType type, const String &caption) + { + Window* window = new Window(Dimensions, Material, type, caption, this); + mWindows.push_back(window); + return window; + } + //------------------------------------------------------------------------------------------------ + Window *GUI::addMenuWindow(const Vector2 dimensions) + { + assert (mMenuWindow == 0); + mMenuWindow = createWindow(Vector4(0, 0, dimensions.x, dimensions.y), + "bgui.window", WFT_NONE, ""); + + mNextMenuWindowPos.y = 25; + return mMenuWindow; + } + //------------------------------------------------------------------------------------------------ + //------------------------------------------------------------------------------------------------ + //------------------------------------------------------------------------------------------------ + Widget::Widget(const Ogre::Vector4 &Dimension, + const Ogre::String &materialNameNormal, + bool hasOverState, + bool hasActiveState): + mPosX(Dimension.x), + mPosY(Dimension.y), + mWidth(Dimension.z), + mHeight(Dimension.w), + mMainOverlay(0), + mCaptionOverlay(0), + mMaterialName(materialNameNormal), + mHasMaterial(!materialNameNormal.empty()), + mHasOverState(hasOverState && mHasMaterial), + mHasActiveState(hasActiveState && mHasMaterial), + mUnderEffect(false), + mOver(false), + mActive(false) + { + + } + //------------------------------------------------------------------------------------------------ + Widget::~Widget() + { + if (mMainOverlay && mMainOverlay->getParent()) mMainOverlay->getParent()->removeChild(mMainOverlay->getName()); + if (mCaptionOverlay && mCaptionOverlay->getParent()) mCaptionOverlay->getParent()->removeChild(mCaptionOverlay->getName()); + + for(std::vector<Widget*>::iterator i=mChildren.begin();i!=mChildren.end();++i) + delete (*i); + } + //------------------------------------------------------------------------------------------------ + void Widget::over(const bool a) + { + assert(!mUnderEffect); + mOver = a; + if (!a && mHasMaterial && mMainOverlay) + { + mMainOverlay->setMaterialName(mMaterialName); + + if (mCaptionOverlay) + { + mCaptionOverlay->setParameter("colour_top", + Ogre::StringConverter::toString(Ogre::ColourValue(0.57, 0.86, 0.68, 1.0))); + mCaptionOverlay->setParameter("colour_bottom", + Ogre::StringConverter::toString(Ogre::ColourValue(0.68, 0.86, 0.68, 1.00))); + } + } + if (a && mHasActiveState && mMainOverlay) + { + mMainOverlay->setMaterialName(mMaterialName + ".over"); + + if (mCaptionOverlay) + { + mCaptionOverlay->setParameter("colour_top", + Ogre::StringConverter::toString(Ogre::ColourValue(1.0, 0.96, 0.76, 1.0))); + mCaptionOverlay->setParameter("colour_bottom", + Ogre::StringConverter::toString(Ogre::ColourValue(1.0, 0.96, 0.76, 1.00))); + } + } + // propagate ? + //for(std::vector<Widget*>::iterator i=mChildren.begin();i!=mChildren.end();++i) + //{ + // (*i)->over(a); + //} + } + //------------------------------------------------------------------------------------------------ + void Widget::activate(const bool a) + { + assert(!mUnderEffect); + mActive = a; + if (!a && mHasMaterial && mMainOverlay) + { + mMainOverlay->setMaterialName(mMaterialName); + + if (mCaptionOverlay) + { + mCaptionOverlay->setParameter("colour_top", + Ogre::StringConverter::toString(Ogre::ColourValue(0.57, 0.86, 0.68, 1.0))); + mCaptionOverlay->setParameter("colour_bottom", + Ogre::StringConverter::toString(Ogre::ColourValue(0.68, 0.86, 0.68, 1.00))); + } + } + if (a && mHasActiveState && mMainOverlay) + { + mMainOverlay->setMaterialName(mMaterialName + ".active"); + + if (mCaptionOverlay) + { + mCaptionOverlay->setParameter("colour_top", + Ogre::StringConverter::toString(Ogre::ColourValue(1.0, 0.96, 0.76, 1.0))); + mCaptionOverlay->setParameter("colour_bottom", + Ogre::StringConverter::toString(Ogre::ColourValue(1.0, 0.96, 0.76, 1.00))); + } + } + // propagate ? + //for(std::vector<Widget*>::iterator i=mChildren.begin();i!=mChildren.end();++i) + //{ + // (*i)->activate(a); + //} + } + //------------------------------------------------------------------------------------------------ + void Widget::setUnderEffect(const bool effect) + { + if (effect) + { + if (mActive) + activate (false); + if (mOver) + over (false); + } + mUnderEffect = effect; + }; + //------------------------------------------------------------------------------------------------ + void Widget::instantiateMaterial(OverlayContainer * const oc, bool reset) const + { + if (oc->getMaterial ().isNull ()) + return; + + const String matName (oc->getMaterial ()->getName ()); + const bool isInstantied = StringUtil::endsWith(matName, ".GuiInstance", false); + if (reset) + { + if (isInstantied) + oc->setMaterialName ( + matName.substr(0, + matName.length() - (oc->getName ().length() + 12))); + } + else if (!isInstantied) + { + const String newMatName(matName + oc->getName () + ".GuiInstance"); + // need to instantiate a material there... + if (!MaterialManager::getSingleton ().resourceExists (newMatName)) + { + oc->getMaterial ()->clone (newMatName); + } + oc->setMaterialName (newMatName); + } + } + //------------------------------------------------------------------------------------------------ + void Widget::setOverlayAlpha(OverlayContainer * const oc, const Ogre::Real alpha) const + { + if (!oc->getMaterial ().isNull ()) + { + TextureUnitState *t = oc->getMaterial ()->getBestTechnique ()->getPass(0)->getTextureUnitState (0); + if (t) t->setAlphaOperation (LBX_MODULATE, LBS_TEXTURE, LBS_MANUAL, alpha, alpha, alpha); + } + } + //------------------------------------------------------------------------------------------------ + void Widget::setAlpha(const Ogre::Real alpha, const bool isContainer) + { + bool noAlpha = false; + Ogre::Real alphaValue = alpha; + + if (alphaValue - 1.0 > -std::numeric_limits<Real>::epsilon()) + { + noAlpha = true; + if (isContainer) mMainOverlay->show (); + } + else if (alphaValue < std::numeric_limits<Real>::epsilon()) + { + noAlpha = true; + if (isContainer) mMainOverlay->hide (); + } + else if (isContainer) + { + mMainOverlay->show (); + } + if (noAlpha) alphaValue = Ogre::Real(1.0); + + //should save in a boolean the instantiated state... + if (mMainOverlay) + { + instantiateMaterial (mMainOverlay, noAlpha); + if (!noAlpha) setOverlayAlpha (mMainOverlay, alphaValue); + } + if (mCaptionOverlay) + { + instantiateMaterial (mCaptionOverlay, noAlpha); + if (!noAlpha) setOverlayAlpha (mCaptionOverlay, alphaValue); + } + for(std::vector<Widget*>::iterator i=mChildren.begin();i!=mChildren.end();++i) + { + (*i)->setAlpha(alphaValue, false); + } + } + //------------------------------------------------------------------------------------------------ + void Widget::setMaterialBlendFactor(const Ogre::Real blendFactor, const bool isContainer) + { + bool noBlendFactor = false; + Ogre::Real blendFactorValue = blendFactor; + + if (blendFactorValue - 1.0 > -std::numeric_limits<Real>::epsilon()) + { + noBlendFactor = true; + } + else if (blendFactorValue < std::numeric_limits<Real>::epsilon()) + { + noBlendFactor = true; + } + if (noBlendFactor) blendFactorValue = Ogre::Real(1.0); + + //should save in a boolean the instantiated state... + if (mMainOverlay) + { + instantiateMaterial (mMainOverlay, noBlendFactor); + if (!noBlendFactor) setOverlayMaterialBlendFactor (mMainOverlay, blendFactorValue); + } + if (mCaptionOverlay) + { + instantiateMaterial (mCaptionOverlay, noBlendFactor); + if (!noBlendFactor) setOverlayMaterialBlendFactor (mCaptionOverlay, blendFactorValue); + } + for(std::vector<Widget*>::iterator i=mChildren.begin();i!=mChildren.end();++i) + { + (*i)->setMaterialBlendFactor(noBlendFactor, false); + } + } + //------------------------------------------------------------------------------------------------ + void Widget::setOverlayMaterialBlendFactor(OverlayContainer * const oc, const Ogre::Real blendFactor) const + { + if (!oc->getMaterial ().isNull ()) + { + TextureUnitState *t = oc->getMaterial ()->getBestTechnique ()->getPass(0)->getTextureUnitState (1); + if (t) + //t->setAlphaOperation (LBX_MODULATE, LBS_TEXTURE, LBS_MANUAL, blendFactor, blendFactor, blendFactor); + t->setColourOperationEx(LBX_BLEND_MANUAL, LBS_TEXTURE, LBS_CURRENT, ColourValue::White, ColourValue::White, blendFactor); + } + } + //------------------------------------------------------------------------------------------------ + void Widget::adjustSizeToContent() + { + Ogre::Real w = 0; + Ogre::Real h = 0; + for(std::vector<Widget*>::iterator i=mChildren.begin();i!=mChildren.end();++i) + { + const Vector2 pos ((*i)->getPosition()); + const Vector2 size ((*i)->getSize()); + + w = std::max(w, pos.x + size.x); + h = std::max(h, pos.y + size.y); + } + setSize(w, h); + } + //------------------------------------------------------------------------------------------------ + void Widget::setPosition(float X,float Y) + { + setPosition(int(X), int(Y)); + } + void Widget::setPosition(const Ogre::Vector2 &position) + { + setPosition(position.x, position.y); + } + //------------------------------------------------------------------------------------------------ + void Widget::setPosition(int X,int Y) + { + if (mMainOverlay) mMainOverlay->setPosition(mPosX=X,mPosY=Y); + } + //------------------------------------------------------------------------------------------------ + void Widget::setSize(const Ogre::Vector2 &size) + { + setSize(size.x, size.y); + }; + //------------------------------------------------------------------------------------------------ + void Widget::setSize(int X,int Y) + { + if (mMainOverlay) mMainOverlay->setDimensions(mWidth=X, mHeight=Y); + if (mCaptionOverlay) mCaptionOverlay->setDimensions(mWidth, mHeight); + }; + //------------------------------------------------------------------------------------------------ + //------------------------------------------------------------------------------------------------ + //------------------------------------------------------------------------------------------------ + Window::Window(const Vector4 &Dimensions, const String &material, WindowFeatureType t, const String &caption, GUI *gui) + : + Widget(Dimensions, material, true, true), + mGUI(gui), + mTitleBarButton(0), + mCloseButton(0), + mResizerButton(0), + mActiveTextInput(0), + mActiveButton(0), + mNextWidgetPos(0, 0), + mDragType(WA_NONE), + mFadeOut(false) + { + + const String name(gui->mName + ".w" + StringConverter::toString(gui->mWindowCount++)); + mGuiOverlay = (Overlay*)OverlayManager::getSingleton().getByName(name); + if (!mGuiOverlay) + mGuiOverlay = OverlayManager::getSingleton().create(name); + mGuiOverlay->show(); + + + mMainOverlay = gui->createOverlay(name, + Vector2(Dimensions.x, Dimensions.y), + Vector2(Dimensions.z, Dimensions.w), + material); + if (mMainOverlay != mGuiOverlay->getChild (mMainOverlay->getName ())) + mGuiOverlay->add2D(mMainOverlay); + mMainOverlay->show(); + + if (t >= 2) + { + Callback c; + c.mCallbackType=4; + mResizerButton = createButton( + Vector4(Dimensions.z-16, Dimensions.w-16, 16, 16), + material + ".resize", "", c); + } + + if ((t == 1 || t == 3) && !caption.empty()) + { + Callback c; + c.mCallbackType=3; + + mTitleBarButton = createButton(Vector4(0,0,Dimensions.z-22,22), + material + ".titlebar", caption, c); + + mCloseButton = createMenuButton(Vector4(Dimensions.z-22,0,22,22), + material + ".close", "", Callback(), this); + + mNextWidgetPos.x += 12; + mNextWidgetPos.y += 22; + } + } + //------------------------------------------------------------------------------------------------ + Window::~Window() + { + //Widget::~Widget(); + //OverlayManager::getSingleton ().destroy (mGuiOverlay->getName ()); + } + //------------------------------------------------------------------------------------------------ + void Window::addWidget(const Widget * const w, WindowPlacementType wpt) + { + switch(wpt) + { + case WPT_HORIZONTAL: + mNextWidgetPos.x += w->getSize().x; break; + case WPT_VERTICAL: + mNextWidgetPos.y += w->getSize().y; break; + case WPT_NONE: + default: + break; + } + adjustSizeToContent(); + } + //------------------------------------------------------------------------------------------------ + Window *Window::addMenuWindowTab(const String &label, + bool titleBarWin, + WindowPlacementType wpt) + { + const size_t labelVisualSize = label.size()*7; + Window *aWindow = mGUI->createWindow( + Vector4(mGUI->mNextMenuWindowPos.x, mGUI->mNextMenuWindowPos.y, 200, 48), + "bgui.window", + titleBarWin? WFT_RESIZE_AND_MOVE : WFT_NONE, + titleBarWin? label: ""); + + Button *aButton = addMenuButton(aWindow, label, WPT_HORIZONTAL); + + if (wpt != WPT_NONE) + mGUI->mNextMenuWindowPos.y += aWindow->getSize ().y + 25; + return aWindow; + } + //------------------------------------------------------------------------------------------------ + MenuButton *Window::addMenuButton(Window *target, const String &label, + WindowPlacementType... [truncated message content] |