diff --git a/include/eepp/maps/mapeditor/mapeditor.hpp b/include/eepp/maps/mapeditor/mapeditor.hpp index 40f2044d1..3d89d51b5 100644 --- a/include/eepp/maps/mapeditor/mapeditor.hpp +++ b/include/eepp/maps/mapeditor/mapeditor.hpp @@ -43,7 +43,7 @@ class EE_API MapEditor { ~MapEditor(); protected: UIWindow * mUIWindow; - UIControl * mUIContainer; + UINode * mUIContainer; UITheme * mTheme; Private::UIMap * mUIMap; MapEditorCloseCb mCloseCb; diff --git a/include/eepp/ui.hpp b/include/eepp/ui.hpp index 47ced4eb7..618ea7fe8 100644 --- a/include/eepp/ui.hpp +++ b/include/eepp/ui.hpp @@ -13,9 +13,7 @@ #include #include #include -#include -#include -#include +#include #include #include #include diff --git a/include/eepp/ui/tools/textureatlaseditor.hpp b/include/eepp/ui/tools/textureatlaseditor.hpp index 399365b85..77a7b506e 100644 --- a/include/eepp/ui/tools/textureatlaseditor.hpp +++ b/include/eepp/ui/tools/textureatlaseditor.hpp @@ -26,10 +26,10 @@ class EE_API TextureAtlasEditor { UISpinBox * getSpinOffY() const { return mSpinOffY; } protected: - class UITGEUpdater : public UIControl + class UITGEUpdater : public UINode { public: - UITGEUpdater( TextureAtlasEditor * TGEditor ) : UIControl(), mTGEditor( TGEditor ) {} + UITGEUpdater( TextureAtlasEditor * TGEditor ) : UINode(), mTGEditor( TGEditor ) {} virtual void update() { mTGEditor->update(); } protected: @@ -38,7 +38,7 @@ class EE_API TextureAtlasEditor { friend class UITGEUpdater; UIWindow * mUIWindow; - UIControl * mUIContainer; + UINode * mUIContainer; UITheme * mTheme; TGEditorCloseCb mCloseCb; TexturePacker * mTexturePacker; diff --git a/include/eepp/ui/uibackground.hpp b/include/eepp/ui/uibackground.hpp index c5eb1da2e..965b759d3 100644 --- a/include/eepp/ui/uibackground.hpp +++ b/include/eepp/ui/uibackground.hpp @@ -6,13 +6,13 @@ namespace EE { namespace UI { -class UIControl; +class UINode; class EE_API UIBackground { public: - static UIBackground * New( UIControl * control ); + static UIBackground * New( UINode * control ); - UIBackground( UIControl * control ); + UIBackground( UINode * control ); ~UIBackground(); @@ -42,7 +42,7 @@ class EE_API UIBackground { protected: std::vector mColor; - UIControl * mControl; + UINode * mControl; BlendMode mBlendMode; unsigned int mCorners; Drawable * mDrawable; diff --git a/include/eepp/ui/uiborder.hpp b/include/eepp/ui/uiborder.hpp index 52f6eebd2..1633ead95 100644 --- a/include/eepp/ui/uiborder.hpp +++ b/include/eepp/ui/uiborder.hpp @@ -5,13 +5,13 @@ namespace EE { namespace UI { -class UIControl; +class UINode; class EE_API UIBorder { public: - static UIBorder * New( UIControl * control ); + static UIBorder * New( UINode * control ); - UIBorder( UIControl * control ); + UIBorder( UINode * control ); const Color& getColor() const; @@ -23,7 +23,7 @@ class EE_API UIBorder { void draw( Rectf R, const Float& alpha, const int& corners, const bool& clipping ); protected: - UIControl * mControl; + UINode * mControl; Color mColor; unsigned int mWidth; }; diff --git a/include/eepp/ui/uicheckbox.hpp b/include/eepp/ui/uicheckbox.hpp index 01ee6e6e3..db2a8c4bf 100644 --- a/include/eepp/ui/uicheckbox.hpp +++ b/include/eepp/ui/uicheckbox.hpp @@ -24,9 +24,9 @@ class EE_API UICheckBox : public UITextView { void setActive( const bool& active ); - UIControlAnim * getActiveButton() const; + UINode * getActiveButton() const; - UIControlAnim * getInactiveButton() const; + UINode * getInactiveButton() const; Int32 getTextSeparation() const; @@ -34,8 +34,8 @@ class EE_API UICheckBox : public UITextView { virtual void loadFromXmlNode( const pugi::xml_node& node ); protected: - UIControlAnim * mActiveButton; - UIControlAnim * mInactiveButton; + UINode * mActiveButton; + UINode * mInactiveButton; bool mActive; Uint32 mLastTick; Int32 mTextSeparation; diff --git a/include/eepp/ui/uicombobox.hpp b/include/eepp/ui/uicombobox.hpp index 0495e4c3b..aef816f6b 100644 --- a/include/eepp/ui/uicombobox.hpp +++ b/include/eepp/ui/uicombobox.hpp @@ -23,7 +23,7 @@ class EE_API UIComboBox : public UIWidget { UIDropDownList * getDropDownList() const { return mDropDownList; } - UIControlAnim * getButton() const { return mButton; } + UINode * getButton() const { return mButton; } InputTextBuffer * getInputTextBuffer(); @@ -32,7 +32,7 @@ class EE_API UIComboBox : public UIWidget { void loadFromXmlNode(const pugi::xml_node & node); protected: UIDropDownList * mDropDownList; - UIControlAnim * mButton; + UINode * mButton; void onButtonClick( const UIEvent * Event ); diff --git a/include/eepp/ui/uicontrol.hpp b/include/eepp/ui/uicontrol.hpp deleted file mode 100644 index 0e6026574..000000000 --- a/include/eepp/ui/uicontrol.hpp +++ /dev/null @@ -1,458 +0,0 @@ -#ifndef EE_UICUICONTROL_H -#define EE_UICUICONTROL_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -namespace EE { namespace UI { - -class UITheme; -class UIWindow; -class UIManager; - -class EE_API UIControl { - public: - static UIControl * New(); - - typedef cb::Callback1 UIEventCallback; - - UIControl(); - - virtual ~UIControl(); - - void screenToControl( Vector2i& position ) const; - - void controlToScreen( Vector2i& position ) const; - - void worldToControl( Vector2i& pos ) const; - - void controlToWorld( Vector2i& pos ) const; - - virtual Uint32 getType() const; - - virtual bool isType( const Uint32& type ) const; - - virtual void messagePost( const UIMessage * Msg ); - - UIControl * setPosition( const Vector2i& position ); - - UIControl * setPosition( const Int32& x, const Int32& y ); - - void setPixelsPosition( const Vector2i& position ); - - void setPixelsPosition( const Int32& x, const Int32& y ); - - const Vector2i& getPosition() const; - - const Vector2i& getRealPosition() const; - - virtual UIControl * setSize( const Sizei& size ); - - UIControl * setSize( const Int32& Width, const Int32& Height ); - - void setPixelsSize( const Sizei& size ); - - void setPixelsSize( const Int32& x, const Int32& y ); - - const Sizei& getSize(); - - const Sizei& getRealSize(); - - Rect getRect() const; - - UIControl * setVisible( const bool& visible ); - - bool isVisible() const; - - bool isHided() const; - - UIControl * setEnabled( const bool& enabled ); - - bool isEnabled() const; - - bool isDisabled() const; - - UIControl * getParent() const; - - UIControl * setParent( UIControl * parent ); - - void centerHorizontal(); - - void centerVertical(); - - void center(); - - virtual void close(); - - virtual void draw(); - - virtual void update(); - - Uint32 getHorizontalAlign() const; - - UIControl * setHorizontalAlign( Uint32 halign ); - - Uint32 getVerticalAlign() const; - - UIControl * setVerticalAlign( Uint32 valign ); - - UIControl * setGravity( Uint32 hvalign ); - - UIBackground * setBackgroundFillEnabled( bool enabled ); - - UIBorder * setBorderEnabled( bool enabled ); - - UIControl * getNextControl() const; - - UIControl * getPrevControl() const; - - UIControl * getNextControlLoop() const; - - UIControl * setData( const UintPtr& data ); - - const UintPtr& getData() const; - - UIControl * childGetAt( Vector2i CtrlPos, unsigned int RecursiveLevel = 0 ); - - const Uint32& getFlags() const; - - virtual UIControl * setFlags( const Uint32& flags ); - - virtual UIControl * unsetFlags( const Uint32& flags ); - - virtual UIControl * resetFlags( Uint32 newFlags = 0 ); - - UIControl * setBlendMode( const BlendMode& blend ); - - BlendMode getBlendMode(); - - void toFront(); - - void toBack(); - - void toPosition( const Uint32& position ); - - const Uint32& getControlFlags() const; - - /** Use it at your own risk */ - void setControlFlags( const Uint32& flags ); - - Uint32 isAnimated(); - - Uint32 isDragable(); - - Uint32 isWidget(); - - Uint32 isWindow(); - - Uint32 isClipped(); - - Uint32 isRotated(); - - Uint32 isScaled(); - - Uint32 isFrameBuffer(); - - bool isMeOrParentTreeRotated(); - - bool isMeOrParentTreeScaled(); - - bool isMeOrParentTreeScaledOrRotated(); - - bool isMeOrParentTreeScaledOrRotatedOrFrameBuffer(); - - Uint32 addEventListener( const Uint32& EventType, const UIEventCallback& Callback ); - - void removeEventListener( const Uint32& CallbackId ); - - UIBackground * getBackground(); - - UIBorder * getBorder(); - - void setThemeByName( const std::string& Theme ); - - virtual void setTheme( UITheme * Theme ); - - virtual UIControl * setThemeSkin( UITheme * Theme, const std::string& skinName ); - - virtual UIControl * setThemeSkin( const std::string& skinName ); - - void setThemeToChilds( UITheme * Theme ); - - UISkin * getSkin(); - - virtual UIControl * setSkin( const UISkin& Skin ); - - UIControl * setSkin( UISkin * skin ); - - void removeSkin(); - - UIControl * getFirstChild() const; - - UIControl * getLastChild() const; - - bool isMouseOver(); - - bool isMouseOverMeOrChilds(); - - Polygon2f& getPolygon(); - - const Vector2f& getPolygonCenter() const; - - void setSkinState( const Uint32& State ); - - bool hasFocus() const; - - virtual void setFocus(); - - bool isParentOf( UIControl * Ctrl ); - - void sendEvent( const UIEvent * Event ); - - void sendMouseEvent( const Uint32& Event, const Vector2i& position, const Uint32& flags ); - - void sendCommonEvent( const Uint32& Event ); - - Sizei getSkinSize(); - - UIControl * getNextWidget(); - - void applyDefaultTheme(); - - Rect getScreenRect(); - - void childsCloseAll(); - - std::string getId() const; - - UIControl * setId( const std::string & id ); - - Uint32 getIdHash() const; - - UIControl * getWindowContainer(); - - UIControl * find( const std::string& id ); - - template - T * find( const std::string& id ) - { - return reinterpret_cast( find( id ) ); - } - - template - T * bind( const std::string& id, T*& ctrl ) - { - ctrl = find( id ); - return ctrl; - } - - bool isReverseDraw() const; - - void setReverseDraw( bool reverseDraw ); - - UIWindow * getOwnerWindow(); - - void invalidateDraw(); - - void setClipEnabled(); - - void setClipDisabled(); - protected: - typedef std::map< Uint32, std::map > UIEventsMap; - friend class UIManager; - friend class UIWindow; - - std::string mId; - Uint32 mIdHash; - Vector2i mPos; - Vector2i mRealPos; - Vector2i mScreenPos; - Vector2f mScreenPosf; - Sizei mSize; - Sizei mRealSize; - - Uint32 mFlags; - UintPtr mData; - - UIControl * mParentCtrl; - UIWindow * mParentWindowCtrl; - UIControl * mChild; //! Pointer to the first child of the control - UIControl * mChildLast; //! Pointer to the last child added - UIControl * mNext; //! Pointer to the next child of the father - UIControl * mPrev; //! Pointer to the prev child of the father - UISkinState * mSkinState; - - UIBackground * mBackground; - UIBorder * mBorder; - - Uint32 mControlFlags; - BlendMode mBlend; - Uint16 mNumCallBacks; - - Polygon2f mPoly; - Vector2f mCenter; - - UIEventsMap mEvents; - - bool mVisible; - bool mEnabled; - - virtual Uint32 onMessage( const UIMessage * Msg ); - - virtual Uint32 onKeyDown( const UIEventKey& Event ); - - virtual Uint32 onKeyUp( const UIEventKey& Event ); - - virtual Uint32 onMouseMove( const Vector2i& position, const Uint32 flags ); - - virtual Uint32 onMouseDown( const Vector2i& position, const Uint32 flags ); - - virtual Uint32 onMouseClick( const Vector2i& position, const Uint32 flags ); - - virtual Uint32 onMouseDoubleClick( const Vector2i& position, const Uint32 flags ); - - virtual Uint32 onMouseUp( const Vector2i& position, const Uint32 flags ); - - virtual Uint32 onMouseEnter( const Vector2i& position, const Uint32 flags ); - - virtual Uint32 onMouseExit( const Vector2i& position, const Uint32 flags ); - - virtual Uint32 onFocus(); - - virtual Uint32 onFocusLoss(); - - virtual void onClose(); - - virtual Uint32 onValueChange(); - - virtual void onVisibilityChange(); - - virtual void onEnabledChange(); - - virtual void onPositionChange(); - - virtual void onSizeChange(); - - virtual void onParentSizeChange( const Vector2i& SizeChange ); - - virtual void onStateChange(); - - virtual void onParentChange(); - - virtual void onAlignChange(); - - virtual void onWidgetFocusLoss(); - - virtual void drawSkin(); - - virtual void drawBackground(); - - virtual void drawBorder(); - - virtual void updateQuad(); - - virtual void updateCenter(); - - virtual void matrixSet(); - - virtual void matrixUnset(); - - virtual void drawChilds(); - - virtual void onThemeLoaded(); - - virtual void onChildCountChange(); - - virtual UIControl * overFind( const Vector2f& Point ); - - virtual void onParentWindowControlChange(); - - virtual void clipMe(); - - void checkClose(); - - virtual void internalDraw(); - - void childDeleteAll(); - - void childAdd( UIControl * ChildCtrl ); - - void childAddAt( UIControl * ChildCtrl, Uint32 position ); - - void childRemove( UIControl * ChildCtrl ); - - bool isChild( UIControl * ChildCtrl ) const; - - bool inParentTreeOf( UIControl * Child ) const; - - Uint32 childCount() const; - - UIControl * childAt( Uint32 Index ) const; - - UIControl * childPrev( UIControl * Ctrl, bool Loop = false ) const; - - UIControl * childNext( UIControl * Ctrl, bool Loop = false ) const; - - virtual void clipDisable(); - - void setPrevSkinState(); - - virtual void updateScreenPos(); - - void updateChildsScreenPos(); - - void writeCtrlFlag( const Uint32& Flag, const Uint32& Val ); - - void writeFlag( const Uint32& Flag, const Uint32& Val ); - - void sendParentSizeChange( const Vector2i& SizeChange ); - - Time getElapsed(); - - Rect makePadding( bool PadLeft = true, bool PadRight = true, bool PadTop = true, bool PadBottom = true, bool SkipFlags = false ); - - Sizei getSkinSize( UISkin * Skin, const Uint32& State = UISkinState::StateNormal ); - - Rectf getRectf(); - - void drawHighlightFocus(); - - void drawOverControl(); - - void drawDebugData(); - - void drawBox(); - - void setInternalPosition( const Vector2i& Pos ); - - void setInternalSize( const Sizei& size ); - - void setInternalWidth( const Int32& width ); - - void setInternalHeight( const Int32& height ); - - void setInternalPixelsSize( const Sizei& size ); - - void setInternalPixelsWidth( const Int32& width ); - - void setInternalPixelsHeight( const Int32& height ); - - UIControl * findIdHash( const Uint32& idHash ); - - UIWindow * getParentWindow(); -}; - -}} - -#endif diff --git a/include/eepp/ui/uicontrolanim.hpp b/include/eepp/ui/uicontrolanim.hpp deleted file mode 100644 index 1f573e860..000000000 --- a/include/eepp/ui/uicontrolanim.hpp +++ /dev/null @@ -1,139 +0,0 @@ -#ifndef EE_UICUICONTROLANIM_H -#define EE_UICUICONTROLANIM_H - -#include -#include -#include - -namespace EE { namespace UI { - -class EE_API UIControlAnim : public UIDragableControl { - public: - static UIControlAnim * New(); - - UIControlAnim(); - - virtual ~UIControlAnim(); - - virtual Uint32 getType() const; - - virtual bool isType( const Uint32& type ) const; - - virtual void update(); - - const Float& getRotation() const; - - void setRotation( const Float& angle ); - - void setRotation( const Float& angle, const OriginPoint& center ); - - const OriginPoint& getRotationOriginPoint() const; - - void setRotationOriginPoint( const OriginPoint& center ); - - Vector2f getRotationCenter(); - - const Vector2f& getScale() const; - - void setScale( const Vector2f& scale ); - - void setScale( const Vector2f& scale, const OriginPoint& center ); - - void setScale( const Float& scale , const OriginPoint & center = OriginPoint::OriginCenter ); - - const OriginPoint& getScaleOriginPoint() const; - - void setScaleOriginPoint( const OriginPoint& center ); - - Vector2f getScaleCenter(); - - const Float& getAlpha() const; - - virtual void setAlpha( const Float& alpha ); - - virtual void setChildsAlpha( const Float& alpha ); - - bool isAnimating(); - - Interpolation1d * startAlphaAnim( const Float& From, const Float& To, const Time& TotalTime, const bool& alphaChilds = true, const Ease::Interpolation& type = Ease::Linear, Interpolation1d::OnPathEndCallback PathEndCallback = Interpolation1d::OnPathEndCallback() ); - - Interpolation2d * startScaleAnim( const Vector2f& From, const Vector2f& To, const Time& TotalTime, const Ease::Interpolation& type = Ease::Linear, Interpolation2d::OnPathEndCallback PathEndCallback = Interpolation2d::OnPathEndCallback() ); - - Interpolation2d * startScaleAnim( const Float& From, const Float& To, const Time& TotalTime, const Ease::Interpolation& type = Ease::Linear, Interpolation2d::OnPathEndCallback PathEndCallback = Interpolation2d::OnPathEndCallback() ); - - Interpolation2d * startTranslation( const Vector2i& From, const Vector2i& To, const Time& TotalTime, const Ease::Interpolation& type = Ease::Linear, Interpolation2d::OnPathEndCallback PathEndCallback = Interpolation2d::OnPathEndCallback() ); - - Interpolation1d * startRotation( const Float& From, const Float& To, const Time& TotalTime, const Ease::Interpolation& type = Ease::Linear, Interpolation1d::OnPathEndCallback PathEndCallback = Interpolation1d::OnPathEndCallback() ); - - Interpolation1d * startAlphaAnim( const Float& To, const Time& TotalTime, const bool& alphaChilds = true, const Ease::Interpolation& type = Ease::Linear, Interpolation1d::OnPathEndCallback PathEndCallback = Interpolation1d::OnPathEndCallback() ); - - Interpolation2d * startScaleAnim( const Vector2f& To, const Time& TotalTime, const Ease::Interpolation& type = Ease::Linear, Interpolation2d::OnPathEndCallback PathEndCallback = Interpolation2d::OnPathEndCallback() ); - - Interpolation2d * startScaleAnim( const Float& To, const Time& TotalTime, const Ease::Interpolation& type = Ease::Linear, Interpolation2d::OnPathEndCallback PathEndCallback = Interpolation2d::OnPathEndCallback() ); - - Interpolation2d * startTranslation( const Vector2i& To, const Time& TotalTime, const Ease::Interpolation& type = Ease::Linear, Interpolation2d::OnPathEndCallback PathEndCallback = Interpolation2d::OnPathEndCallback() ); - - Interpolation1d * startRotation( const Float& To, const Time& TotalTime, const Ease::Interpolation& type = Ease::Linear, Interpolation1d::OnPathEndCallback PathEndCallback = Interpolation1d::OnPathEndCallback() ); - - Interpolation1d * createFadeIn( const Time& Time, const bool& alphaChilds = true, const Ease::Interpolation& type = Ease::Linear ); - - Interpolation1d * createFadeOut( const Time& Time, const bool& alphaChilds = true, const Ease::Interpolation& type = Ease::Linear ); - - Interpolation1d * closeFadeOut( const Time& Time, const bool& alphaChilds = true, const Ease::Interpolation& type = Ease::Linear ); - - Interpolation1d * disableFadeOut( const Time & Time, const bool& alphaChilds = true, const Ease::Interpolation& type = Ease::Linear ); - - Interpolation1d * getRotationInterpolation(); - - Interpolation2d * getScaleInterpolation(); - - Interpolation1d * getAlphaInterpolation(); - - Interpolation2d * getTranslationInterpolation(); - - virtual void draw(); - - bool isFadingOut(); - protected: - friend class UIManager; - friend class UIControl; - - Float mAngle; - OriginPoint mRotationOriginPoint; - Vector2f mScale; - OriginPoint mScaleOriginPoint; - Float mAlpha; - - Interpolation1d * mAngleAnim; - Interpolation2d * mScaleAnim; - Interpolation1d * mAlphaAnim; - Interpolation2d * mMoveAnim; - - virtual void drawBackground(); - - virtual void drawBorder(); - - virtual void drawSkin(); - - Color getColor( const Color& Col ); - - virtual void updateQuad(); - - virtual void onSizeChange(); - - virtual void onAngleChange(); - - virtual void onScaleChange(); - - virtual void onAlphaChange(); - - virtual void matrixSet(); - - virtual void matrixUnset(); - - void updateOriginPoint(); -}; - -}} - -#endif diff --git a/include/eepp/ui/uidragablecontrol.hpp b/include/eepp/ui/uidragablecontrol.hpp deleted file mode 100644 index 8e5ffae0e..000000000 --- a/include/eepp/ui/uidragablecontrol.hpp +++ /dev/null @@ -1,55 +0,0 @@ -#ifndef EE_UICUIDRAGABLE_H -#define EE_UICUIDRAGABLE_H - -#include - -namespace EE { namespace UI { - -class EE_API UIDragableControl : public UIControl { - public: - static UIDragableControl * New(); - - UIDragableControl(); - - virtual Uint32 getType() const; - - virtual bool isType( const Uint32& type ) const; - - bool isDragging() const; - - void setDragging( const bool& dragging ); - - const Vector2i& getDragPoint() const; - - void setDragPoint( const Vector2i& Point ); - - virtual void update(); - - bool isDragEnabled() const; - - void setDragEnabled( const bool& enable ); - - void setDragButton( const Uint32& Button ); - - const Uint32& getDragButton() const; - protected: - virtual ~UIDragableControl(); - - Vector2i mDragPoint; - Uint32 mDragButton; - - virtual Uint32 onMouseDown( const Vector2i& position, const Uint32 flags ); - - virtual Uint32 onMouseUp( const Vector2i& position, const Uint32 flags ); - - virtual Uint32 onDrag( const Vector2i& position ); - - virtual Uint32 onDragStart( const Vector2i& position ); - - virtual Uint32 onDragStop( const Vector2i& position ); -}; - -}} - -#endif - diff --git a/include/eepp/ui/uidropdownlist.hpp b/include/eepp/ui/uidropdownlist.hpp index 07af2be4a..dc348d3e2 100644 --- a/include/eepp/ui/uidropdownlist.hpp +++ b/include/eepp/ui/uidropdownlist.hpp @@ -44,7 +44,7 @@ class EE_API UIDropDownList : public UITextInput { UIDropDownListStyleConfig mStyleConfig; UIListBox * mListBox; - UIControl * mFriendCtrl; + UINode * mFriendCtrl; void onListBoxFocusLoss( const UIEvent * Event ); @@ -72,7 +72,7 @@ class EE_API UIDropDownList : public UITextInput { virtual void onThemeLoaded(); - void setFriendControl( UIControl * friendCtrl ); + void setFriendControl( UINode * friendCtrl ); void destroyListBox(); }; diff --git a/include/eepp/ui/uievent.hpp b/include/eepp/ui/uievent.hpp index 0decfdf72..8bfff9e61 100644 --- a/include/eepp/ui/uievent.hpp +++ b/include/eepp/ui/uievent.hpp @@ -5,7 +5,7 @@ namespace EE { namespace UI { -class UIControl; +class UINode; class EE_API UIEvent { public: @@ -56,15 +56,15 @@ class EE_API UIEvent { NoEvent = eeINDEX_NOT_FOUND }; - UIEvent( UIControl * control, const Uint32& eventType = NoEvent ); + UIEvent( UINode * control, const Uint32& eventType = NoEvent ); ~UIEvent(); - UIControl * getControl() const; + UINode * getControl() const; const Uint32& getEventType() const; protected: - UIControl * mCtrl; + UINode * mCtrl; Uint32 mEventType; }; diff --git a/include/eepp/ui/uieventkey.hpp b/include/eepp/ui/uieventkey.hpp index 0c4c397c0..d6ec304d1 100644 --- a/include/eepp/ui/uieventkey.hpp +++ b/include/eepp/ui/uieventkey.hpp @@ -6,11 +6,11 @@ namespace EE { namespace UI { -class UIControl; +class UINode; class EE_API UIEventKey : public UIEvent { public: - UIEventKey( UIControl * getControl, const Uint32& EventNum, const Uint32& getKeyCode, const Uint16& getChar, const Uint32& getMod ); + UIEventKey( UINode * getControl, const Uint32& EventNum, const Uint32& getKeyCode, const Uint16& getChar, const Uint32& getMod ); ~UIEventKey(); diff --git a/include/eepp/ui/uieventmouse.hpp b/include/eepp/ui/uieventmouse.hpp index 14eedebcb..d1e94b380 100644 --- a/include/eepp/ui/uieventmouse.hpp +++ b/include/eepp/ui/uieventmouse.hpp @@ -6,11 +6,11 @@ namespace EE { namespace UI { -class UIControl; +class UINode; class EE_API UIEventMouse : public UIEvent { public: - UIEventMouse( UIControl * getControl, const Uint32& EventNum, const Vector2i& getPosition, const Uint32& getFlags ); + UIEventMouse( UINode * getControl, const Uint32& EventNum, const Vector2i& getPosition, const Uint32& getFlags ); ~UIEventMouse(); diff --git a/include/eepp/ui/uihelper.hpp b/include/eepp/ui/uihelper.hpp index 3e1a83fb6..d07e4bff0 100644 --- a/include/eepp/ui/uihelper.hpp +++ b/include/eepp/ui/uihelper.hpp @@ -8,29 +8,27 @@ namespace EE { namespace UI { enum UI_CONTROL_FLAGS_VALUES { UI_CTRL_FLAG_CLOSE = (1<<0), UI_CTRL_FLAG_CLOSE_FO = (1<<1), - UI_CTRL_FLAG_ANIM = (1<<2), - UI_CTRL_FLAG_MOUSEOVER = (1<<3), - UI_CTRL_FLAG_HAS_FOCUS = (1<<4), - UI_CTRL_FLAG_SELECTED = (1<<5), - UI_CTRL_FLAG_DISABLE_FADE_OUT = (1<<6), - UI_CTRL_FLAG_MOUSEOVER_ME_OR_CHILD = (1<<7), - UI_CTRL_FLAG_DRAGGING = (1<<8), - UI_CTRL_FLAG_DRAGABLE = (1<<9), - UI_CTRL_FLAG_WIDGET = (1<<10), - UI_CTRL_FLAG_SKIN_OWNER = (1<<11), - UI_CTRL_FLAG_TOUCH_DRAGGING = (1<<12), - UI_CTRL_FLAG_DISABLED_BY_MODAL_WINDOW = (1<<13), - UI_CTRL_FLAG_SELECTING = (1<<14), - UI_CTRL_FLAG_ROTATED = (1<<15), - UI_CTRL_FLAG_SCALED = (1<<16), - UI_CTRL_FLAG_OWNED_BY_WINDOW = (1<<17), - UI_CTRL_FLAG_DRAWABLE_OWNER = (1<<18), - UI_CTRL_FLAG_REVERSE_DRAW = (1<<19), - UI_CTRL_FLAG_FRAME_BUFFER = (1<<20), - UI_CTRL_FLAG_NEEDS_REDRAW = (1<<21), - UI_CTRL_FLAG_DIRTY_POLY = (1<<22), - UI_CTRL_FLAG_WINDOW = (1<<23), - UI_CTRL_FLAG_FREE_USE = (1<<31) + UI_CTRL_FLAG_MOUSEOVER = (1<<2), + UI_CTRL_FLAG_HAS_FOCUS = (1<<3), + UI_CTRL_FLAG_SELECTED = (1<<4), + UI_CTRL_FLAG_DISABLE_FADE_OUT = (1<<5), + UI_CTRL_FLAG_MOUSEOVER_ME_OR_CHILD = (1<<6), + UI_CTRL_FLAG_DRAGGING = (1<<7), + UI_CTRL_FLAG_WIDGET = (1<<8), + UI_CTRL_FLAG_SKIN_OWNER = (1<<9), + UI_CTRL_FLAG_TOUCH_DRAGGING = (1<<10), + UI_CTRL_FLAG_DISABLED_BY_MODAL_WINDOW = (1<<11), + UI_CTRL_FLAG_SELECTING = (1<<12), + UI_CTRL_FLAG_ROTATED = (1<<13), + UI_CTRL_FLAG_SCALED = (1<<14), + UI_CTRL_FLAG_OWNED_BY_WINDOW = (1<<15), + UI_CTRL_FLAG_DRAWABLE_OWNER = (1<<16), + UI_CTRL_FLAG_REVERSE_DRAW = (1<<17), + UI_CTRL_FLAG_FRAME_BUFFER = (1<<18), + UI_CTRL_FLAG_NEEDS_REDRAW = (1<<19), + UI_CTRL_FLAG_DIRTY_POLY = (1<<20), + UI_CTRL_FLAG_WINDOW = (1<<21), + UI_CTRL_FLAG_FREE_USE = (1<<22) }; #define UI_HALIGN_LEFT TEXT_ALIGN_LEFT @@ -71,9 +69,7 @@ enum UI_FLAGS { }; enum UI_CONTROL_TYPES { - UI_TYPE_CONTROL = 0, - UI_TYPE_CONTROL_DRAGABLE, - UI_TYPE_CONTROL_ANIM, + UI_TYPE_NODE = 0, UI_TYPE_WIDGET, UI_TYPE_IMAGE, UI_TYPE_SUBTEXTURE, diff --git a/include/eepp/ui/uiitemcontainer.hpp b/include/eepp/ui/uiitemcontainer.hpp index 0799d8bef..9211c6cd0 100644 --- a/include/eepp/ui/uiitemcontainer.hpp +++ b/include/eepp/ui/uiitemcontainer.hpp @@ -1,12 +1,12 @@ #ifndef EE_UITUIITEMCONTAINER_HPP #define EE_UITUIITEMCONTAINER_HPP -#include +#include namespace EE { namespace UI { template -class UIItemContainer : public UIControl { +class UIItemContainer : public UINode { public: UIItemContainer(); @@ -16,12 +16,12 @@ class UIItemContainer : public UIControl { void drawChilds(); protected: - UIControl * overFind( const Vector2f& Point ); + UINode * overFind( const Vector2f& Point ); }; template UIItemContainer::UIItemContainer() : - UIControl() + UINode() { } @@ -54,10 +54,10 @@ void UIItemContainer::drawChilds() { } template -UIControl * UIItemContainer::overFind( const Vector2f& Point ) { +UINode * UIItemContainer::overFind( const Vector2f& Point ) { TContainer * tParent = reinterpret_cast ( getParent() ); - UIControl * pOver = NULL; + UINode * pOver = NULL; if ( mEnabled && mVisible && tParent->mItems.size() ) { updateQuad(); @@ -67,7 +67,7 @@ UIControl * UIItemContainer::overFind( const Vector2f& Point ) { for ( Uint32 i = tParent->mVisibleFirst; i <= tParent->mVisibleLast; i++ ) { if ( NULL != tParent->mItems[i] ) { - UIControl * ChildOver = tParent->mItems[i]->overFind( Point ); + UINode * ChildOver = tParent->mItems[i]->overFind( Point ); if ( NULL != ChildOver ) { pOver = ChildOver; @@ -78,7 +78,7 @@ UIControl * UIItemContainer::overFind( const Vector2f& Point ) { } if ( NULL == pOver ) - pOver = const_cast( reinterpret_cast( this ) ); + pOver = const_cast( reinterpret_cast( this ) ); } } diff --git a/include/eepp/ui/uilistbox.hpp b/include/eepp/ui/uilistbox.hpp index a10e4edb7..04c0b2589 100644 --- a/include/eepp/ui/uilistbox.hpp +++ b/include/eepp/ui/uilistbox.hpp @@ -1,7 +1,7 @@ #ifndef EE_UICUILISTBOX_HPP #define EE_UICUILISTBOX_HPP -#include +#include #include #include #include diff --git a/include/eepp/ui/uimanager.hpp b/include/eepp/ui/uimanager.hpp index a2c789ffc..181d64369 100644 --- a/include/eepp/ui/uimanager.hpp +++ b/include/eepp/ui/uimanager.hpp @@ -1,7 +1,7 @@ #ifndef EE_UICUIMANAGER_H #define EE_UICUIMANAGER_H -#include +#include #include #include #include @@ -23,13 +23,13 @@ class EE_API UIManager { UIWindow * getMainControl() const; - UIControl * getFocusControl() const; + UINode * getFocusControl() const; - void setFocusControl( UIControl * Ctrl ); + void setFocusControl( UINode * Ctrl ); - UIControl * getOverControl() const; + UINode * getOverControl() const; - void setOverControl( UIControl * Ctrl ); + void setOverControl( UINode * Ctrl ); void init( Uint32 Flags = 0, EE::Window::Window * window = NULL ); @@ -43,7 +43,7 @@ class EE_API UIManager { void resizeControl( EE::Window::Window * win ); - void sendMsg( UIControl * Ctrl, const Uint32& Msg, const Uint32& Flags = 0 ); + void sendMsg( UINode * Ctrl, const Uint32& Msg, const Uint32& Flags = 0 ); Vector2i getMousePos(); @@ -53,9 +53,9 @@ class EE_API UIManager { const Uint32& getLastPressTrigger() const; - void clipSmartEnable( UIControl * ctrl, const Int32& x, const Int32& y, const Uint32& Width, const Uint32& Height ); + void clipSmartEnable( UINode * ctrl, const Int32& x, const Int32& y, const Uint32& Width, const Uint32& Height ); - void clipSmartDisable( UIControl * ctrl ); + void clipSmartDisable( UINode * ctrl ); void sendKeyUp( const Uint32& KeyCode, const Uint16& Char, const Uint32& Mod ); @@ -105,18 +105,18 @@ class EE_API UIManager { const Color& getHighlightOverColor() const; - void sendMouseClick( UIControl * ToCtrl, const Vector2i& Pos, const Uint32 Flags ); + void sendMouseClick( UINode * ToCtrl, const Vector2i& Pos, const Uint32 Flags ); - void sendMouseUp( UIControl * ToCtrl, const Vector2i& Pos, const Uint32 Flags ); + void sendMouseUp( UINode * ToCtrl, const Vector2i& Pos, const Uint32 Flags ); - void sendMouseDown( UIControl * ToCtrl, const Vector2i& Pos, const Uint32 Flags ); + void sendMouseDown( UINode * ToCtrl, const Vector2i& Pos, const Uint32 Flags ); EE::Window::Window * getWindow() const; /** Control where the mouse click started to be down */ - UIControl * getDownControl() const; + UINode * getDownControl() const; - UIControl * getLossFocusControl() const; + UINode * getLossFocusControl() const; const bool& isShootingDown() const; @@ -134,17 +134,17 @@ class EE_API UIManager { void setCursor( EE_CURSOR_TYPE cursor ); - UIWidget * loadLayoutFromFile( const std::string& layoutPath, UIControl * parent = NULL ); + UIWidget * loadLayoutFromFile( const std::string& layoutPath, UINode * parent = NULL ); - UIWidget * loadLayoutFromString( const std::string& layoutString, UIControl * parent = NULL ); + UIWidget * loadLayoutFromString( const std::string& layoutString, UINode * parent = NULL ); - UIWidget * loadLayoutFromMemory( const void * buffer, Int32 bufferSize, UIControl * parent = NULL ); + UIWidget * loadLayoutFromMemory( const void * buffer, Int32 bufferSize, UINode * parent = NULL ); - UIWidget * loadLayoutFromStream( IOStream& stream, UIControl * parent = NULL ); + UIWidget * loadLayoutFromStream( IOStream& stream, UINode * parent = NULL ); - UIWidget * loadLayoutFromPack( Pack * pack, const std::string& FilePackPath, UIControl * parent = NULL ); + UIWidget * loadLayoutFromPack( Pack * pack, const std::string& FilePackPath, UINode * parent = NULL ); - UIWidget * loadLayoutNodes( pugi::xml_node node, UIControl * parent ); + UIWidget * loadLayoutNodes( pugi::xml_node node, UINode * parent ); void setTranslator( Translator translator ); @@ -153,18 +153,18 @@ class EE_API UIManager { String getTranslatorString( const std::string& str ); protected: - friend class UIControl; + friend class UINode; friend class UIWindow; EE::Window::Window *mWindow; Input * mKM; UIWindow * mControl; - UIControl * mFocusControl; - UIControl * mOverControl; - UIControl * mDownControl; - UIControl * mLossFocusControl; + UINode * mFocusControl; + UINode * mOverControl; + UINode * mDownControl; + UINode * mLossFocusControl; std::list mWindowsList; - std::list mCloseList; + std::list mCloseList; Clock mClock; Time mElapsed; @@ -201,7 +201,7 @@ class EE_API UIManager { bool windowExists( UIWindow * win ); - void addToCloseQueue( UIControl * Ctrl ); + void addToCloseQueue( UINode * Ctrl ); void checkClose(); }; diff --git a/include/eepp/ui/uimenu.hpp b/include/eepp/ui/uimenu.hpp index 0f8ded9ed..9dfffe422 100644 --- a/include/eepp/ui/uimenu.hpp +++ b/include/eepp/ui/uimenu.hpp @@ -1,7 +1,7 @@ #ifndef EE_UICUIMENU_HPP #define EE_UICUIMENU_HPP -#include +#include #include #include #include @@ -26,7 +26,7 @@ class EE_API UIMenu : public UIWidget { Uint32 add( const String& Text, Drawable * Icon = NULL ); - Uint32 add( UIControl * Control ); + Uint32 add( UINode * Control ); Uint32 addSeparator(); @@ -34,23 +34,23 @@ class EE_API UIMenu : public UIWidget { Uint32 addSubMenu( const String& Text, Drawable * Icon = NULL, UIMenu * SubMenu = NULL ); - UIControl * getItem( const Uint32& Index ); + UINode * getItem( const Uint32& Index ); - UIControl * getItem( const String& Text ); + UINode * getItem( const String& Text ); - Uint32 getItemIndex( UIControl * Item ); + Uint32 getItemIndex( UINode * Item ); Uint32 getCount() const; void remove( const Uint32& Index ); - void remove( UIControl * Ctrl ); + void remove( UINode * Ctrl ); void removeAll(); void insert( const String& Text, Drawable * Icon, const Uint32& Index ); - void insert( UIControl * Control, const Uint32& Index ); + void insert( UINode * Control, const Uint32& Index ); virtual void setTheme( UITheme * Theme ); @@ -74,12 +74,12 @@ class EE_API UIMenu : public UIWidget { friend class UIMenuCheckBox; friend class UIMenuSubMenu; - std::deque mItems; + std::deque mItems; UIMenuStyleConfig mStyleConfig; Uint32 mMaxWidth; Uint32 mNextPosY; Uint32 mBiggestIcon; - UIControl * mItemSelected; + UINode * mItemSelected; Uint32 mItemSelectedIndex; bool mClickHide; Uint32 mLastTickMove; @@ -90,7 +90,7 @@ class EE_API UIMenu : public UIWidget { virtual Uint32 onMessage( const UIMessage * Msg ); - void setControlSize( UIControl * Control, const Uint32& position ); + void setControlSize( UINode * Control, const Uint32& position ); void resizeControls(); @@ -106,11 +106,11 @@ class EE_API UIMenu : public UIWidget { void onThemeLoaded(); - bool checkControlSize( UIControl * Control, const bool& Resize = true ); + bool checkControlSize( UINode * Control, const bool& Resize = true ); - bool isSubMenu( UIControl * Ctrl ); + bool isSubMenu( UINode * Ctrl ); - void setItemSelected( UIControl * Item ); + void setItemSelected( UINode * Item ); virtual Uint32 onKeyDown( const UIEventKey& Event ); @@ -118,7 +118,7 @@ class EE_API UIMenu : public UIWidget { void nextSel(); - void trySelect( UIControl * Ctrl, bool Up ); + void trySelect( UINode * Ctrl, bool Up ); }; }} diff --git a/include/eepp/ui/uimenusubmenu.hpp b/include/eepp/ui/uimenusubmenu.hpp index dc556a496..8dd8350da 100644 --- a/include/eepp/ui/uimenusubmenu.hpp +++ b/include/eepp/ui/uimenusubmenu.hpp @@ -25,7 +25,7 @@ class EE_API UIMenuSubMenu : public UIMenuItem { UIMenu * getSubMenu() const; - UIControl * getArrow() const; + UINode * getArrow() const; void showSubMenu(); @@ -37,7 +37,7 @@ class EE_API UIMenuSubMenu : public UIMenuItem { protected: UIMenu * mSubMenu; - UIControlAnim * mArrow; + UINode * mArrow; Float mTimeOver; Float mMaxTime; Uint32 mCbId; diff --git a/include/eepp/ui/uimessage.hpp b/include/eepp/ui/uimessage.hpp index 4acf02ba8..842b120ff 100644 --- a/include/eepp/ui/uimessage.hpp +++ b/include/eepp/ui/uimessage.hpp @@ -5,7 +5,7 @@ namespace EE { namespace UI { -class UIControl; +class UINode; class EE_API UIMessage { public: @@ -29,17 +29,17 @@ class EE_API UIMessage { NoMessage = eeINDEX_NOT_FOUND }; - UIMessage( UIControl * Ctrl, const Uint32& getMsg, const Uint32& getFlags = NoMessage ); + UIMessage( UINode * Ctrl, const Uint32& getMsg, const Uint32& getFlags = NoMessage ); ~UIMessage(); - UIControl * getSender() const; + UINode * getSender() const; const Uint32& getMsg() const; const Uint32& getFlags() const; private: - UIControl * mCtrl; + UINode * mCtrl; Uint32 mMsg; Uint32 mFlags; }; diff --git a/include/eepp/ui/uinode.hpp b/include/eepp/ui/uinode.hpp new file mode 100644 index 000000000..a38ce1d1a --- /dev/null +++ b/include/eepp/ui/uinode.hpp @@ -0,0 +1,572 @@ +#ifndef EE_UIUINODE_HPP +#define EE_UIUINODE_HPP + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace EE { namespace UI { + +class UITheme; +class UIWindow; +class UIManager; + +class EE_API UINode { + public: + static UINode * New(); + + typedef cb::Callback1 UIEventCallback; + + UINode(); + + virtual ~UINode(); + + void screenToControl( Vector2i& position ) const; + + void controlToScreen( Vector2i& position ) const; + + void worldToControl( Vector2i& pos ) const; + + void controlToWorld( Vector2i& pos ) const; + + virtual Uint32 getType() const; + + virtual bool isType( const Uint32& type ) const; + + virtual void messagePost( const UIMessage * Msg ); + + UINode * setPosition( const Vector2i& position ); + + UINode * setPosition( const Int32& x, const Int32& y ); + + void setPixelsPosition( const Vector2i& position ); + + void setPixelsPosition( const Int32& x, const Int32& y ); + + const Vector2i& getPosition() const; + + const Vector2i& getRealPosition() const; + + virtual UINode * setSize( const Sizei& size ); + + UINode * setSize( const Int32& Width, const Int32& Height ); + + void setPixelsSize( const Sizei& size ); + + void setPixelsSize( const Int32& x, const Int32& y ); + + const Sizei& getSize(); + + const Sizei& getRealSize(); + + Rect getRect() const; + + UINode * setVisible( const bool& visible ); + + bool isVisible() const; + + bool isHided() const; + + UINode * setEnabled( const bool& enabled ); + + bool isEnabled() const; + + bool isDisabled() const; + + UINode * getParent() const; + + UINode * setParent( UINode * parent ); + + void centerHorizontal(); + + void centerVertical(); + + void center(); + + virtual void close(); + + virtual void draw(); + + virtual void update(); + + Uint32 getHorizontalAlign() const; + + UINode * setHorizontalAlign( Uint32 halign ); + + Uint32 getVerticalAlign() const; + + UINode * setVerticalAlign( Uint32 valign ); + + UINode * setGravity( Uint32 hvalign ); + + UIBackground * setBackgroundFillEnabled( bool enabled ); + + UIBorder * setBorderEnabled( bool enabled ); + + UINode * getNextControl() const; + + UINode * getPrevControl() const; + + UINode * getNextControlLoop() const; + + UINode * setData( const UintPtr& data ); + + const UintPtr& getData() const; + + UINode * childGetAt( Vector2i CtrlPos, unsigned int RecursiveLevel = 0 ); + + const Uint32& getFlags() const; + + virtual UINode * setFlags( const Uint32& flags ); + + virtual UINode * unsetFlags( const Uint32& flags ); + + virtual UINode * resetFlags( Uint32 newFlags = 0 ); + + UINode * setBlendMode( const BlendMode& blend ); + + BlendMode getBlendMode(); + + void toFront(); + + void toBack(); + + void toPosition( const Uint32& position ); + + const Uint32& getControlFlags() const; + + /** Use it at your own risk */ + void setControlFlags( const Uint32& flags ); + + Uint32 isWidget(); + + Uint32 isWindow(); + + Uint32 isClipped(); + + Uint32 isRotated(); + + Uint32 isScaled(); + + Uint32 isFrameBuffer(); + + bool isMeOrParentTreeRotated(); + + bool isMeOrParentTreeScaled(); + + bool isMeOrParentTreeScaledOrRotated(); + + bool isMeOrParentTreeScaledOrRotatedOrFrameBuffer(); + + Uint32 addEventListener( const Uint32& EventType, const UIEventCallback& Callback ); + + void removeEventListener( const Uint32& CallbackId ); + + UIBackground * getBackground(); + + UIBorder * getBorder(); + + void setThemeByName( const std::string& Theme ); + + virtual void setTheme( UITheme * Theme ); + + virtual UINode * setThemeSkin( UITheme * Theme, const std::string& skinName ); + + virtual UINode * setThemeSkin( const std::string& skinName ); + + void setThemeToChilds( UITheme * Theme ); + + UISkin * getSkin(); + + virtual UINode * setSkin( const UISkin& Skin ); + + UINode * setSkin( UISkin * skin ); + + void removeSkin(); + + UINode * getFirstChild() const; + + UINode * getLastChild() const; + + bool isMouseOver(); + + bool isMouseOverMeOrChilds(); + + Polygon2f& getPolygon(); + + const Vector2f& getPolygonCenter() const; + + void setSkinState( const Uint32& State ); + + bool hasFocus() const; + + virtual void setFocus(); + + bool isParentOf( UINode * Ctrl ); + + void sendEvent( const UIEvent * Event ); + + void sendMouseEvent( const Uint32& Event, const Vector2i& position, const Uint32& flags ); + + void sendCommonEvent( const Uint32& Event ); + + Sizei getSkinSize(); + + UINode * getNextWidget(); + + void applyDefaultTheme(); + + Rect getScreenRect(); + + void childsCloseAll(); + + std::string getId() const; + + UINode * setId( const std::string & id ); + + Uint32 getIdHash() const; + + UINode * getWindowContainer(); + + UINode * find( const std::string& id ); + + template + T * find( const std::string& id ) + { + return reinterpret_cast( find( id ) ); + } + + template + T * bind( const std::string& id, T*& ctrl ) + { + ctrl = find( id ); + return ctrl; + } + + bool isReverseDraw() const; + + void setReverseDraw( bool reverseDraw ); + + UIWindow * getOwnerWindow(); + + void invalidateDraw(); + + void setClipEnabled(); + + void setClipDisabled(); + + bool isDragging() const; + + void setDragging( const bool& dragging ); + + const Vector2i& getDragPoint() const; + + void setDragPoint( const Vector2i& Point ); + + bool isDragEnabled() const; + + void setDragEnabled( const bool& enable ); + + void setDragButton( const Uint32& Button ); + + const Uint32& getDragButton() const; + + const Float& getRotation() const; + + void setRotation( const Float& angle ); + + void setRotation( const Float& angle, const OriginPoint& center ); + + const OriginPoint& getRotationOriginPoint() const; + + void setRotationOriginPoint( const OriginPoint& center ); + + Vector2f getRotationCenter(); + + const Vector2f& getScale() const; + + void setScale( const Vector2f& scale ); + + void setScale( const Vector2f& scale, const OriginPoint& center ); + + void setScale( const Float& scale , const OriginPoint & center = OriginPoint::OriginCenter ); + + const OriginPoint& getScaleOriginPoint() const; + + void setScaleOriginPoint( const OriginPoint& center ); + + Vector2f getScaleCenter(); + + const Float& getAlpha() const; + + virtual void setAlpha( const Float& alpha ); + + virtual void setChildsAlpha( const Float& alpha ); + + bool isAnimating(); + + Interpolation1d * startAlphaAnim( const Float& From, const Float& To, const Time& TotalTime, const bool& alphaChilds = true, const Ease::Interpolation& type = Ease::Linear, Interpolation1d::OnPathEndCallback PathEndCallback = Interpolation1d::OnPathEndCallback() ); + + Interpolation2d * startScaleAnim( const Vector2f& From, const Vector2f& To, const Time& TotalTime, const Ease::Interpolation& type = Ease::Linear, Interpolation2d::OnPathEndCallback PathEndCallback = Interpolation2d::OnPathEndCallback() ); + + Interpolation2d * startScaleAnim( const Float& From, const Float& To, const Time& TotalTime, const Ease::Interpolation& type = Ease::Linear, Interpolation2d::OnPathEndCallback PathEndCallback = Interpolation2d::OnPathEndCallback() ); + + Interpolation2d * startTranslation( const Vector2i& From, const Vector2i& To, const Time& TotalTime, const Ease::Interpolation& type = Ease::Linear, Interpolation2d::OnPathEndCallback PathEndCallback = Interpolation2d::OnPathEndCallback() ); + + Interpolation1d * startRotation( const Float& From, const Float& To, const Time& TotalTime, const Ease::Interpolation& type = Ease::Linear, Interpolation1d::OnPathEndCallback PathEndCallback = Interpolation1d::OnPathEndCallback() ); + + Interpolation1d * startAlphaAnim( const Float& To, const Time& TotalTime, const bool& alphaChilds = true, const Ease::Interpolation& type = Ease::Linear, Interpolation1d::OnPathEndCallback PathEndCallback = Interpolation1d::OnPathEndCallback() ); + + Interpolation2d * startScaleAnim( const Vector2f& To, const Time& TotalTime, const Ease::Interpolation& type = Ease::Linear, Interpolation2d::OnPathEndCallback PathEndCallback = Interpolation2d::OnPathEndCallback() ); + + Interpolation2d * startScaleAnim( const Float& To, const Time& TotalTime, const Ease::Interpolation& type = Ease::Linear, Interpolation2d::OnPathEndCallback PathEndCallback = Interpolation2d::OnPathEndCallback() ); + + Interpolation2d * startTranslation( const Vector2i& To, const Time& TotalTime, const Ease::Interpolation& type = Ease::Linear, Interpolation2d::OnPathEndCallback PathEndCallback = Interpolation2d::OnPathEndCallback() ); + + Interpolation1d * startRotation( const Float& To, const Time& TotalTime, const Ease::Interpolation& type = Ease::Linear, Interpolation1d::OnPathEndCallback PathEndCallback = Interpolation1d::OnPathEndCallback() ); + + Interpolation1d * createFadeIn( const Time& Time, const bool& alphaChilds = true, const Ease::Interpolation& type = Ease::Linear ); + + Interpolation1d * createFadeOut( const Time& Time, const bool& alphaChilds = true, const Ease::Interpolation& type = Ease::Linear ); + + Interpolation1d * closeFadeOut( const Time& Time, const bool& alphaChilds = true, const Ease::Interpolation& type = Ease::Linear ); + + Interpolation1d * disableFadeOut( const Time & Time, const bool& alphaChilds = true, const Ease::Interpolation& type = Ease::Linear ); + + Interpolation1d * getRotationInterpolation(); + + Interpolation2d * getScaleInterpolation(); + + Interpolation1d * getAlphaInterpolation(); + + Interpolation2d * getTranslationInterpolation(); + + bool isFadingOut(); + protected: + typedef std::map< Uint32, std::map > UIEventsMap; + friend class UIManager; + friend class UIWindow; + + std::string mId; + Uint32 mIdHash; + Vector2i mPos; + Vector2i mRealPos; + Vector2i mScreenPos; + Vector2f mScreenPosf; + Sizei mSize; + Sizei mRealSize; + + Uint32 mFlags; + UintPtr mData; + + UINode * mParentCtrl; + UIWindow * mParentWindowCtrl; + UINode * mChild; //! Pointer to the first child of the control + UINode * mChildLast; //! Pointer to the last child added + UINode * mNext; //! Pointer to the next child of the father + UINode * mPrev; //! Pointer to the prev child of the father + UISkinState * mSkinState; + + UIBackground * mBackground; + UIBorder * mBorder; + + Uint32 mControlFlags; + BlendMode mBlend; + Uint16 mNumCallBacks; + + Polygon2f mPoly; + Vector2f mCenter; + + UIEventsMap mEvents; + + bool mVisible; + bool mEnabled; + + Vector2i mDragPoint; + Uint32 mDragButton; + + Float mAngle; + OriginPoint mRotationOriginPoint; + Vector2f mScale; + OriginPoint mScaleOriginPoint; + Float mAlpha; + + Interpolation1d * mAngleAnim; + Interpolation2d * mScaleAnim; + Interpolation1d * mAlphaAnim; + Interpolation2d * mMoveAnim; + + virtual Uint32 onMessage( const UIMessage * Msg ); + + virtual Uint32 onKeyDown( const UIEventKey& Event ); + + virtual Uint32 onKeyUp( const UIEventKey& Event ); + + virtual Uint32 onMouseMove( const Vector2i& position, const Uint32 flags ); + + virtual Uint32 onMouseDown( const Vector2i& position, const Uint32 flags ); + + virtual Uint32 onMouseClick( const Vector2i& position, const Uint32 flags ); + + virtual Uint32 onMouseDoubleClick( const Vector2i& position, const Uint32 flags ); + + virtual Uint32 onMouseUp( const Vector2i& position, const Uint32 flags ); + + virtual Uint32 onMouseEnter( const Vector2i& position, const Uint32 flags ); + + virtual Uint32 onMouseExit( const Vector2i& position, const Uint32 flags ); + + virtual Uint32 onFocus(); + + virtual Uint32 onFocusLoss(); + + virtual void onClose(); + + virtual Uint32 onValueChange(); + + virtual void onVisibilityChange(); + + virtual void onEnabledChange(); + + virtual void onPositionChange(); + + virtual void onSizeChange(); + + virtual void onParentSizeChange( const Vector2i& SizeChange ); + + virtual void onStateChange(); + + virtual void onParentChange(); + + virtual void onAlignChange(); + + virtual void onWidgetFocusLoss(); + + virtual void drawSkin(); + + virtual void drawBackground(); + + virtual void drawBorder(); + + virtual void updateQuad(); + + virtual void updateCenter(); + + virtual void matrixSet(); + + virtual void matrixUnset(); + + virtual void drawChilds(); + + virtual void onThemeLoaded(); + + virtual void onChildCountChange(); + + virtual void onAngleChange(); + + virtual void onScaleChange(); + + virtual void onAlphaChange(); + + virtual UINode * overFind( const Vector2f& Point ); + + virtual void onParentWindowControlChange(); + + virtual void clipMe(); + + virtual Uint32 onDrag( const Vector2i& position ); + + virtual Uint32 onDragStart( const Vector2i& position ); + + virtual Uint32 onDragStop( const Vector2i& position ); + + void checkClose(); + + virtual void internalDraw(); + + void childDeleteAll(); + + void childAdd( UINode * ChildCtrl ); + + void childAddAt( UINode * ChildCtrl, Uint32 position ); + + void childRemove( UINode * ChildCtrl ); + + bool isChild( UINode * ChildCtrl ) const; + + bool inParentTreeOf( UINode * Child ) const; + + Uint32 childCount() const; + + UINode * childAt( Uint32 Index ) const; + + UINode * childPrev( UINode * Ctrl, bool Loop = false ) const; + + UINode * childNext( UINode * Ctrl, bool Loop = false ) const; + + virtual void clipDisable(); + + void setPrevSkinState(); + + virtual void updateScreenPos(); + + void updateChildsScreenPos(); + + void writeCtrlFlag( const Uint32& Flag, const Uint32& Val ); + + void writeFlag( const Uint32& Flag, const Uint32& Val ); + + void sendParentSizeChange( const Vector2i& SizeChange ); + + Time getElapsed(); + + Rect makePadding( bool PadLeft = true, bool PadRight = true, bool PadTop = true, bool PadBottom = true, bool SkipFlags = false ); + + Sizei getSkinSize( UISkin * Skin, const Uint32& State = UISkinState::StateNormal ); + + Rectf getRectf(); + + void drawHighlightFocus(); + + void drawOverControl(); + + void drawDebugData(); + + void drawBox(); + + void setInternalPosition( const Vector2i& Pos ); + + void setInternalSize( const Sizei& size ); + + void setInternalWidth( const Int32& width ); + + void setInternalHeight( const Int32& height ); + + void setInternalPixelsSize( const Sizei& size ); + + void setInternalPixelsWidth( const Int32& width ); + + void setInternalPixelsHeight( const Int32& height ); + + Color getColor( const Color& Col ); + + UINode * findIdHash( const Uint32& idHash ); + + UIWindow * getParentWindow(); + + void updateOriginPoint(); +}; + +}} + +#endif diff --git a/include/eepp/ui/uiprogressbar.hpp b/include/eepp/ui/uiprogressbar.hpp index 7ba609957..5fe85ec71 100644 --- a/include/eepp/ui/uiprogressbar.hpp +++ b/include/eepp/ui/uiprogressbar.hpp @@ -1,7 +1,7 @@ #ifndef EE_UICPROGRESSBAR_HPP #define EE_UICPROGRESSBAR_HPP -#include +#include #include #include diff --git a/include/eepp/ui/uiradiobutton.hpp b/include/eepp/ui/uiradiobutton.hpp index a1950857a..a73b4b272 100644 --- a/include/eepp/ui/uiradiobutton.hpp +++ b/include/eepp/ui/uiradiobutton.hpp @@ -24,9 +24,9 @@ class EE_API UIRadioButton : public UITextView { void setActive( const bool& active ); - UIControlAnim * getActiveButton() const; + UINode * getActiveButton() const; - UIControlAnim * getInactiveButton() const; + UINode * getInactiveButton() const; Int32 getTextSeparation() const; @@ -34,8 +34,8 @@ class EE_API UIRadioButton : public UITextView { virtual void loadFromXmlNode( const pugi::xml_node& node ); protected: - UIControlAnim * mActiveButton; - UIControlAnim * mInactiveButton; + UINode * mActiveButton; + UINode * mInactiveButton; bool mActive; Uint32 mLastTick; Int32 mTextSeparation; diff --git a/include/eepp/ui/uiscrollbar.hpp b/include/eepp/ui/uiscrollbar.hpp index 8d304961e..b07f987bb 100644 --- a/include/eepp/ui/uiscrollbar.hpp +++ b/include/eepp/ui/uiscrollbar.hpp @@ -51,13 +51,13 @@ class EE_API UIScrollBar : public UIWidget { UISlider * getSlider() const; - UIControlAnim * getButtonUp() const; + UINode * getButtonUp() const; - UIControlAnim * getButtonDown() const; + UINode * getButtonDown() const; UI_ORIENTATION getOrientation() const; - UIControl * setOrientation( const UI_ORIENTATION & orientation ); + UINode * setOrientation( const UI_ORIENTATION & orientation ); ScrollBarType getScrollBarType() const; @@ -72,8 +72,8 @@ class EE_API UIScrollBar : public UIWidget { protected: ScrollBarType mScrollBarType; UISlider * mSlider; - UIControlAnim * mBtnUp; - UIControlAnim * mBtnDown; + UINode * mBtnUp; + UINode * mBtnDown; virtual void onSizeChange(); diff --git a/include/eepp/ui/uiscrollview.hpp b/include/eepp/ui/uiscrollview.hpp index 22b2fc26b..147ed525c 100644 --- a/include/eepp/ui/uiscrollview.hpp +++ b/include/eepp/ui/uiscrollview.hpp @@ -38,7 +38,7 @@ class EE_API UIScrollView : public UITouchDragableWidget { UIScrollBar * getHorizontalScrollBar() const; - UIControlAnim * getContainer() const; + UINode * getContainer() const; virtual void loadFromXmlNode( const pugi::xml_node& node ); protected: @@ -47,8 +47,8 @@ class EE_API UIScrollView : public UITouchDragableWidget { UI_SCROLLBAR_MODE mHScrollMode; UIScrollBar * mVScroll; UIScrollBar * mHScroll; - UIControlAnim * mContainer; - UIControl * mScrollView; + UINode * mContainer; + UINode * mScrollView; Uint32 mSizeChangeCb; virtual void onSizeChange(); diff --git a/include/eepp/ui/uiskinstate.hpp b/include/eepp/ui/uiskinstate.hpp index bbf2e3f85..eb0efe039 100644 --- a/include/eepp/ui/uiskinstate.hpp +++ b/include/eepp/ui/uiskinstate.hpp @@ -37,7 +37,7 @@ class EE_API UISkinState { const Uint32& getPrevState() const; protected: - friend class UIControl; + friend class UINode; UISkin * mSkin; Uint32 mCurState; diff --git a/include/eepp/ui/uislider.hpp b/include/eepp/ui/uislider.hpp index 2d7429061..061d87496 100644 --- a/include/eepp/ui/uislider.hpp +++ b/include/eepp/ui/uislider.hpp @@ -40,9 +40,9 @@ class EE_API UISlider : public UIWidget { virtual void update(); - UIControl * getBackSlider() const; + UINode * getBackSlider() const; - UIDragableControl * getSliderButton() const; + UINode * getSliderButton() const; void adjustChilds(); @@ -70,7 +70,7 @@ class EE_API UISlider : public UIWidget { UI_ORIENTATION mOrientation; UISliderStyleConfig mStyleConfig; - UIControlAnim * mBackSlider; + UINode * mBackSlider; Private::UISliderButton * mSlider; Float mMinValue; Float mMaxValue; diff --git a/include/eepp/ui/uispinbox.hpp b/include/eepp/ui/uispinbox.hpp index 4267c7d37..f2ec50ade 100644 --- a/include/eepp/ui/uispinbox.hpp +++ b/include/eepp/ui/uispinbox.hpp @@ -46,9 +46,9 @@ class EE_API UISpinBox : public UIWidget { virtual void update(); - UIControlAnim * getButtonPushUp() const; + UINode * getButtonPushUp() const; - UIControlAnim * getButtonPushDown() const; + UINode * getButtonPushDown() const; UITextInput * getTextInput() const; @@ -59,8 +59,8 @@ class EE_API UISpinBox : public UIWidget { virtual void loadFromXmlNode( const pugi::xml_node& node ); protected: UITextInput * mInput; - UIControlAnim * mPushUp; - UIControlAnim * mPushDown; + UINode * mPushUp; + UINode * mPushDown; Float mMinValue; Float mMaxValue; Float mValue; diff --git a/include/eepp/ui/uitab.hpp b/include/eepp/ui/uitab.hpp index ddb4f0bf7..04fa30643 100644 --- a/include/eepp/ui/uitab.hpp +++ b/include/eepp/ui/uitab.hpp @@ -13,9 +13,9 @@ class EE_API UITab : public UISelectButton { UITab(); - UIControl * getControlOwned() const; + UINode * getControlOwned() const; - void setControlOwned( UIControl * controlOwned ); + void setControlOwned( UINode * controlOwned ); virtual ~UITab(); @@ -33,7 +33,7 @@ class EE_API UITab : public UISelectButton { virtual void loadFromXmlNode( const pugi::xml_node& node ); protected: - UIControl * mControlOwned; + UINode * mControlOwned; std::string mOwnedName; virtual Uint32 onMouseClick( const Vector2i &position, const Uint32 flags ); diff --git a/include/eepp/ui/uitable.hpp b/include/eepp/ui/uitable.hpp index 8cedb105b..3dbee6bbc 100644 --- a/include/eepp/ui/uitable.hpp +++ b/include/eepp/ui/uitable.hpp @@ -1,7 +1,7 @@ #ifndef EE_UICUIGENERICGRID_HPP #define EE_UICUIGENERICGRID_HPP -#include +#include #include #include #include diff --git a/include/eepp/ui/uitablecell.hpp b/include/eepp/ui/uitablecell.hpp index 0f0e6b848..befb3ece2 100644 --- a/include/eepp/ui/uitablecell.hpp +++ b/include/eepp/ui/uitablecell.hpp @@ -18,9 +18,9 @@ class EE_API UITableCell : public UIWidget { virtual void setTheme( UITheme * Theme ); - void setCell( const Uint32& CollumnIndex, UIControl * Ctrl ); + void setCell( const Uint32& CollumnIndex, UINode * Ctrl ); - UIControl * getCell( const Uint32& CollumnIndex ) const; + UINode * getCell( const Uint32& CollumnIndex ) const; virtual void update(); @@ -35,7 +35,7 @@ class EE_API UITableCell : public UIWidget { friend class UIItemContainer; friend class UITable; - std::vector mCells; + std::vector mCells; UITable * gridParent() const; diff --git a/include/eepp/ui/uitabwidget.hpp b/include/eepp/ui/uitabwidget.hpp index a9fe13a97..4879743b3 100644 --- a/include/eepp/ui/uitabwidget.hpp +++ b/include/eepp/ui/uitabwidget.hpp @@ -19,7 +19,7 @@ class EE_API UITabWidget : public UIWidget { virtual bool isType( const Uint32& type ) const; - UITabWidget * add( const String& Text, UIControl * CtrlOwned, Drawable * Icon = NULL ); + UITabWidget * add( const String& Text, UINode * CtrlOwned, Drawable * Icon = NULL ); UITabWidget * add( UITab * Tab ); @@ -37,7 +37,7 @@ class EE_API UITabWidget : public UIWidget { void removeAll(); - void insert( const String& Text, UIControl * CtrlOwned, Drawable * Icon, const Uint32& Index ); + void insert( const String& Text, UINode * CtrlOwned, Drawable * Icon, const Uint32& Index ); void insert( UITab * Tab, const Uint32& Index ); @@ -148,7 +148,7 @@ class EE_API UITabWidget : public UIWidget { void onThemeLoaded(); - UITab * createTab( const String& Text, UIControl * CtrlOwned, Drawable * Icon ); + UITab * createTab( const String& Text, UINode * CtrlOwned, Drawable * Icon ); virtual void onSizeChange(); diff --git a/include/eepp/ui/uitextedit.hpp b/include/eepp/ui/uitextedit.hpp index d38aaae17..5a28521e6 100644 --- a/include/eepp/ui/uitextedit.hpp +++ b/include/eepp/ui/uitextedit.hpp @@ -1,7 +1,7 @@ #ifndef EE_UICUITEXTEDIT_HPP #define EE_UICUITEXTEDIT_HPP -#include +#include #include #include diff --git a/include/eepp/ui/uitextinput.hpp b/include/eepp/ui/uitextinput.hpp index 9f56eb04e..f49d24870 100644 --- a/include/eepp/ui/uitextinput.hpp +++ b/include/eepp/ui/uitextinput.hpp @@ -1,7 +1,7 @@ #ifndef EE_UICUITEXTINPUT_H #define EE_UICUITEXTINPUT_H -#include +#include #include #include diff --git a/include/eepp/ui/uithememanager.hpp b/include/eepp/ui/uithememanager.hpp index 5fa652ee9..129ae9ef2 100644 --- a/include/eepp/ui/uithememanager.hpp +++ b/include/eepp/ui/uithememanager.hpp @@ -6,7 +6,7 @@ namespace EE { namespace UI { -class UIControl; +class UINode; class EE_API UIThemeManager : public ResourceManager { SINGLETON_DECLARE_HEADERS(UIThemeManager) @@ -28,7 +28,7 @@ class EE_API UIThemeManager : public ResourceManager { UITheme * getDefaultTheme() const; - void applyDefaultTheme( UIControl * Control ); + void applyDefaultTheme( UINode * Control ); void setAutoApplyDefaultTheme( const bool& apply ); diff --git a/include/eepp/ui/uitooltip.hpp b/include/eepp/ui/uitooltip.hpp index 3446e8be2..c0d52b1ea 100644 --- a/include/eepp/ui/uitooltip.hpp +++ b/include/eepp/ui/uitooltip.hpp @@ -1,7 +1,7 @@ #ifndef EE_UICUITOOLTIP_HPP #define EE_UICUITOOLTIP_HPP -#include +#include namespace EE { namespace Graphics { class Text; @@ -9,7 +9,7 @@ class Text; namespace EE { namespace UI { -class EE_API UITooltip : public UIControlAnim { +class EE_API UITooltip : public UINode { public: static UITooltip * New(); @@ -71,9 +71,9 @@ class EE_API UITooltip : public UIControlAnim { const Time & getTooltipTime() const; - UIControl * getTooltipOf() const; + UINode * getTooltipOf() const; - void setTooltipOf(UIControl * tooltipOf); + void setTooltipOf(UINode * tooltipOf); UITooltipStyleConfig getStyleConfig() const; @@ -84,7 +84,7 @@ class EE_API UITooltip : public UIControlAnim { Vector2f mAlignOffset; Rect mRealPadding; Time mTooltipTime; - UIControl * mTooltipOf; + UINode * mTooltipOf; virtual void onSizeChange(); diff --git a/include/eepp/ui/uiwidget.hpp b/include/eepp/ui/uiwidget.hpp index 622a11e7e..4991716c8 100644 --- a/include/eepp/ui/uiwidget.hpp +++ b/include/eepp/ui/uiwidget.hpp @@ -1,7 +1,7 @@ #ifndef EE_UIUIWIDGET_HPP #define EE_UIUIWIDGET_HPP -#include +#include #include namespace pugi { @@ -10,7 +10,7 @@ class xml_node; namespace EE { namespace UI { -class EE_API UIWidget : public UIControlAnim { +class EE_API UIWidget : public UINode { public: static UIWidget * New(); @@ -24,21 +24,21 @@ class EE_API UIWidget : public UIControlAnim { virtual void update(); - virtual UIControl * setSize( const Sizei& size ); + virtual UINode * setSize( const Sizei& size ); - virtual UIControl * setFlags( const Uint32& flags ); + virtual UINode * setFlags( const Uint32& flags ); - virtual UIControl * unsetFlags( const Uint32& flags ); + virtual UINode * unsetFlags( const Uint32& flags ); virtual UIWidget * setAnchors( const Uint32& flags ); virtual void setTheme( UITheme * Theme ); - virtual UIControl * setThemeSkin( const std::string& skinName ); + virtual UINode * setThemeSkin( const std::string& skinName ); - virtual UIControl * setThemeSkin( UITheme * Theme, const std::string& skinName ); + virtual UINode * setThemeSkin( UITheme * Theme, const std::string& skinName ); - UIControl * setSize( const Int32& Width, const Int32& Height ); + UINode * setSize( const Int32& Width, const Int32& Height ); const Sizei& getSize(); diff --git a/include/eepp/ui/uiwindow.hpp b/include/eepp/ui/uiwindow.hpp index 2f7bfd8b9..dc6153200 100644 --- a/include/eepp/ui/uiwindow.hpp +++ b/include/eepp/ui/uiwindow.hpp @@ -33,9 +33,9 @@ class EE_API UIWindow : public UIWidget { virtual bool isType( const Uint32& type ) const; - virtual UIControl * setSize( const Sizei& size ); + virtual UINode * setSize( const Sizei& size ); - UIControl * setSize( const Int32& Width, const Int32& Height ); + UINode * setSize( const Int32& Width, const Int32& Height ); UIWindow * setSizeWithDecoration( const Int32& Width, const Int32& Height ); @@ -49,11 +49,11 @@ class EE_API UIWindow : public UIWidget { UIWidget * getContainer() const; - UIControlAnim * getButtonClose() const; + UINode * getButtonClose() const; - UIControlAnim * getButtonMaximize() const; + UINode * getButtonMaximize() const; - UIControlAnim * getButtonMinimize() const; + UINode * getButtonMinimize() const; virtual bool show(); @@ -150,15 +150,15 @@ class EE_API UIWindow : public UIWidget { FrameBuffer * mFrameBuffer; UIWindowStyleConfig mStyleConfig; - UIControlAnim * mWindowDecoration; - UIControlAnim * mBorderLeft; - UIControlAnim * mBorderRight; - UIControlAnim * mBorderBottom; + UINode * mWindowDecoration; + UINode * mBorderLeft; + UINode * mBorderRight; + UINode * mBorderBottom; UIWidget * mContainer; - UIControlAnim * mButtonClose; - UIControlAnim * mButtonMinimize; - UIControlAnim * mButtonMaximize; + UINode * mButtonClose; + UINode * mButtonMinimize; + UINode * mButtonMaximize; UITextView * mTitle; UIWidget * mModalCtrl; @@ -199,7 +199,7 @@ class EE_API UIWindow : public UIWidget { void doResize( const UIMessage * Msg ); - void decideResizeType( UIControl * Control ); + void decideResizeType( UINode * Control ); void tryResize( const UI_RESIZE_TYPE& getType ); diff --git a/include/eepp/ui/uiwinmenu.hpp b/include/eepp/ui/uiwinmenu.hpp index c4a12280f..8851b7625 100644 --- a/include/eepp/ui/uiwinmenu.hpp +++ b/include/eepp/ui/uiwinmenu.hpp @@ -56,7 +56,7 @@ class EE_API UIWinMenu : public UIWidget { UIPopUpMenu * getMenuFromButton( UISelectButton * Button ); - bool isPopUpMenuChild( UIControl * Ctrl ); + bool isPopUpMenuChild( UINode * Ctrl ); void onMenuFocusLoss( const UIEvent * Event ); diff --git a/projects/linux/ee.files b/projects/linux/ee.files index e6d6e8b49..5a0403d16 100644 --- a/projects/linux/ee.files +++ b/projects/linux/ee.files @@ -31,13 +31,13 @@ ../../include/eepp/math/interpolation2d.hpp ../../include/eepp/system/color.hpp ../../include/eepp/system/translator.hpp -../../include/eepp/ui/uidragablecontrol.hpp ../../include/eepp/ui/uieventmouse.hpp ../../include/eepp/ui/uigridlayout.hpp ../../include/eepp/ui/uiimage.hpp ../../include/eepp/ui/uilayout.hpp ../../include/eepp/ui/uilinearlayout.hpp ../../include/eepp/ui/uimenuseparator.hpp +../../include/eepp/ui/uinode.hpp ../../include/eepp/ui/uirelativelayout.hpp ../../include/eepp/ui/uiscrollview.hpp ../../include/eepp/ui/uisubtexture.hpp @@ -81,13 +81,13 @@ ../../src/eepp/math/interpolation2d.cpp ../../src/eepp/system/color.cpp ../../src/eepp/system/translator.cpp -../../src/eepp/ui/uidragablecontrol.cpp ../../src/eepp/ui/uigridlayout.cpp ../../src/eepp/ui/uiimage.cpp ../../src/eepp/ui/uilayout.cpp ../../src/eepp/ui/uilinearlayout.cpp ../../src/eepp/ui/uiloader.cpp ../../src/eepp/ui/uimenuseparator.cpp +../../src/eepp/ui/uinode.cpp ../../src/eepp/ui/uirelativelayout.cpp ../../src/eepp/ui/uiscrollview.cpp ../../src/eepp/ui/uisubtexture.cpp @@ -342,8 +342,6 @@ ../../include/eepp/ui/uieventkey.hpp ../../include/eepp/ui/uievent.hpp ../../include/eepp/ui/uidropdownlist.hpp -../../include/eepp/ui/uicontrolanim.hpp -../../include/eepp/ui/uicontrol.hpp ../../include/eepp/ui/uicommondialog.hpp ../../include/eepp/ui/uicombobox.hpp ../../include/eepp/ui/uicheckbox.hpp @@ -390,8 +388,6 @@ ../../src/eepp/ui/uieventkey.cpp ../../src/eepp/ui/uievent.cpp ../../src/eepp/ui/uidropdownlist.cpp -../../src/eepp/ui/uicontrolanim.cpp -../../src/eepp/ui/uicontrol.cpp ../../src/eepp/ui/uicommondialog.cpp ../../src/eepp/ui/uicombobox.cpp ../../src/eepp/ui/uicheckbox.cpp diff --git a/src/eepp/maps/mapeditor/mapeditor.cpp b/src/eepp/maps/mapeditor/mapeditor.cpp index b35ad054b..dab12d1b7 100644 --- a/src/eepp/maps/mapeditor/mapeditor.cpp +++ b/src/eepp/maps/mapeditor/mapeditor.cpp @@ -29,7 +29,7 @@ using namespace EE::Maps::Private; namespace EE { namespace Maps { -static UITextView * createTextBox( const String& Text = "", UIControl * Parent = NULL, const Sizei& Size = Sizei(), const Vector2i& Pos = Vector2i(), const Uint32& Flags = UI_CONTROL_DEFAULT_FLAGS | UI_AUTO_SIZE, const Uint32& fontStyle = Text::Regular ) { +static UITextView * createTextBox( const String& Text = "", UINode * Parent = NULL, const Sizei& Size = Sizei(), const Vector2i& Pos = Vector2i(), const Uint32& Flags = UI_CONTROL_DEFAULT_FLAGS | UI_AUTO_SIZE, const Uint32& fontStyle = Text::Regular ) { UITextView * Ctrl = UITextView::New(); Ctrl->setFontStyle( fontStyle ); Ctrl->resetFlags( Flags )->setParent( Parent )->setPosition( Pos )->setSize( Size )->setVisible( true )->setEnabled( false ); diff --git a/src/eepp/maps/mapeditor/mapobjectproperties.cpp b/src/eepp/maps/mapeditor/mapobjectproperties.cpp index 6883e7ad8..ff7f876b5 100644 --- a/src/eepp/maps/mapeditor/mapobjectproperties.cpp +++ b/src/eepp/maps/mapeditor/mapobjectproperties.cpp @@ -3,7 +3,7 @@ namespace EE { namespace Maps { namespace Private { -static UITextView * createTextBox( const String& Text = "", UIControl * Parent = NULL, const Sizei& Size = Sizei(), const Vector2i& Pos = Vector2i(), const Uint32& Flags = UI_CONTROL_DEFAULT_FLAGS | UI_AUTO_SIZE, const Uint32& fontStyle = Text::Regular ) { +static UITextView * createTextBox( const String& Text = "", UINode * Parent = NULL, const Sizei& Size = Sizei(), const Vector2i& Pos = Vector2i(), const Uint32& Flags = UI_CONTROL_DEFAULT_FLAGS | UI_AUTO_SIZE, const Uint32& fontStyle = Text::Regular ) { UITextView * Ctrl = UITextView::New(); Ctrl->setFontStyle( fontStyle ); Ctrl->resetFlags( Flags )->setParent( Parent )->setPosition( Pos )->setSize( Size )->setVisible( true )->setEnabled( false ); diff --git a/src/eepp/maps/mapeditor/tilemapproperties.cpp b/src/eepp/maps/mapeditor/tilemapproperties.cpp index 6cab10185..40430c29a 100644 --- a/src/eepp/maps/mapeditor/tilemapproperties.cpp +++ b/src/eepp/maps/mapeditor/tilemapproperties.cpp @@ -2,7 +2,7 @@ namespace EE { namespace Maps { namespace Private { -static UITextView * createTextBox( const String& Text = "", UIControl * Parent = NULL, const Sizei& Size = Sizei(), const Vector2i& Pos = Vector2i(), const Uint32& Flags = UI_CONTROL_DEFAULT_FLAGS | UI_AUTO_SIZE, const Uint32& fontStyle = Text::Regular ) { +static UITextView * createTextBox( const String& Text = "", UINode * Parent = NULL, const Sizei& Size = Sizei(), const Vector2i& Pos = Vector2i(), const Uint32& Flags = UI_CONTROL_DEFAULT_FLAGS | UI_AUTO_SIZE, const Uint32& fontStyle = Text::Regular ) { UITextView * Ctrl = UITextView::New(); Ctrl->setFontStyle( fontStyle ); Ctrl->resetFlags( Flags )->setParent( Parent )->setPosition( Pos )->setSize( Size )->setVisible( true )->setEnabled( false ); diff --git a/src/eepp/maps/mapeditor/uimapnew.cpp b/src/eepp/maps/mapeditor/uimapnew.cpp index 1b4902b1c..611c38432 100644 --- a/src/eepp/maps/mapeditor/uimapnew.cpp +++ b/src/eepp/maps/mapeditor/uimapnew.cpp @@ -2,7 +2,7 @@ namespace EE { namespace Maps { namespace Private { -static UITextView * createTextBox( const String& Text = "", UIControl * Parent = NULL, const Sizei& Size = Sizei(), const Vector2i& Pos = Vector2i(), const Uint32& Flags = UI_CONTROL_DEFAULT_FLAGS | UI_AUTO_SIZE, const Uint32& fontStyle = Text::Regular ) { +static UITextView * createTextBox( const String& Text = "", UINode * Parent = NULL, const Sizei& Size = Sizei(), const Vector2i& Pos = Vector2i(), const Uint32& Flags = UI_CONTROL_DEFAULT_FLAGS | UI_AUTO_SIZE, const Uint32& fontStyle = Text::Regular ) { UITextView * Ctrl = UITextView::New(); Ctrl->setFontStyle( fontStyle ); Ctrl->resetFlags( Flags )->setParent( Parent )->setPosition( Pos )->setSize( Size )->setVisible( true )->setEnabled( false ); diff --git a/src/eepp/ui/tools/textureatlassubtextureeditor.cpp b/src/eepp/ui/tools/textureatlassubtextureeditor.cpp index e6c8a403d..503ceffeb 100644 --- a/src/eepp/ui/tools/textureatlassubtextureeditor.cpp +++ b/src/eepp/ui/tools/textureatlassubtextureeditor.cpp @@ -25,7 +25,7 @@ TextureAtlasSubTextureEditor::TextureAtlasSubTextureEditor( TextureAtlasEditor * mGfx->setVisible( true ); mGfx->setEnabled( true ); - mDrag = UIDragableControl::New(); + mDrag = UINode::New(); mDrag->setParent( this ); mDrag->setSize( 64000, 64000 ); mDrag->setEnabled( true ); diff --git a/src/eepp/ui/tools/textureatlassubtextureeditor.hpp b/src/eepp/ui/tools/textureatlassubtextureeditor.hpp index ed9f4ef77..c9477b361 100644 --- a/src/eepp/ui/tools/textureatlassubtextureeditor.hpp +++ b/src/eepp/ui/tools/textureatlassubtextureeditor.hpp @@ -30,7 +30,7 @@ class EE_API TextureAtlasSubTextureEditor : public UIWidget { protected: UITheme * mTheme; UISubTexture * mGfx; - UIDragableControl * mDrag; + UINode * mDrag; Vector2i mUICenter; TextureAtlasEditor * mEditor; diff --git a/src/eepp/ui/uibackground.cpp b/src/eepp/ui/uibackground.cpp index 4cbaa40d5..4c8cc02ea 100644 --- a/src/eepp/ui/uibackground.cpp +++ b/src/eepp/ui/uibackground.cpp @@ -1,16 +1,16 @@ #include -#include +#include #include using namespace EE::Graphics; namespace EE { namespace UI { -UIBackground * UIBackground::New( UIControl * control ) { +UIBackground * UIBackground::New( UINode * control ) { return eeNew( UIBackground, ( control ) ); } -UIBackground::UIBackground( UIControl * control ) : +UIBackground::UIBackground( UINode * control ) : mControl( control ), mBlendMode( BlendAlpha ), mCorners(0), diff --git a/src/eepp/ui/uiborder.cpp b/src/eepp/ui/uiborder.cpp index a59fd895d..c5e06b326 100644 --- a/src/eepp/ui/uiborder.cpp +++ b/src/eepp/ui/uiborder.cpp @@ -1,16 +1,16 @@ #include -#include +#include #include using namespace EE::Graphics; namespace EE { namespace UI { -UIBorder * UIBorder::New( UIControl * control ) { +UIBorder * UIBorder::New( UINode * control ) { return eeNew( UIBorder, ( control ) ); } -UIBorder::UIBorder( UIControl * control ) : +UIBorder::UIBorder( UINode * control ) : mControl( control ), mColor( Color::Black ), mWidth( 1 ) diff --git a/src/eepp/ui/uicheckbox.cpp b/src/eepp/ui/uicheckbox.cpp index d33e3b9a2..f0009fa10 100644 --- a/src/eepp/ui/uicheckbox.cpp +++ b/src/eepp/ui/uicheckbox.cpp @@ -15,14 +15,14 @@ UICheckBox::UICheckBox() : mActive( false ), mTextSeparation( 4 ) { - mActiveButton = UIControlAnim::New(); + mActiveButton = UINode::New(); mActiveButton->setVisible( false ); mActiveButton->setEnabled( true ); mActiveButton->setParent( this ); mActiveButton->setPosition( 0, 0 ); mActiveButton->setSize( 16, 16 ); - mInactiveButton = UIControlAnim::New(); + mInactiveButton = UINode::New(); mInactiveButton->setVisible( true ); mInactiveButton->setEnabled( true ); mInactiveButton->setParent( this ); @@ -150,11 +150,11 @@ void UICheckBox::onPaddingChange() { mRealPadding.Left = mActiveButton->getRealPosition().x + mActiveButton->getRealSize().getWidth() + PixelDensity::dpToPxI( mTextSeparation ); } -UIControlAnim * UICheckBox::getActiveButton() const { +UINode * UICheckBox::getActiveButton() const { return mActiveButton; } -UIControlAnim * UICheckBox::getInactiveButton() const { +UINode * UICheckBox::getInactiveButton() const { return mInactiveButton; } diff --git a/src/eepp/ui/uicombobox.cpp b/src/eepp/ui/uicombobox.cpp index b07abdd3d..d1b6ebae9 100644 --- a/src/eepp/ui/uicombobox.cpp +++ b/src/eepp/ui/uicombobox.cpp @@ -39,7 +39,7 @@ void UIComboBox::setTheme( UITheme * Theme ) { } if ( NULL == mButton ) { - mButton = UIControlAnim::New(); + mButton = UINode::New(); mButton->setParent( this ); mButton->setVisible( true ); mButton->setEnabled( true ); diff --git a/src/eepp/ui/uicontrolanim.cpp b/src/eepp/ui/uicontrolanim.cpp deleted file mode 100644 index fc534126b..000000000 --- a/src/eepp/ui/uicontrolanim.cpp +++ /dev/null @@ -1,480 +0,0 @@ -#include -#include -#include -#include -#include - -namespace EE { namespace UI { - -UIControlAnim * UIControlAnim::New() { - return eeNew( UIControlAnim, () ); -} - -UIControlAnim::UIControlAnim() : - UIDragableControl(), - mAngle(0.f), - mScale(1.f,1.f), - mAlpha(255.f), - mAngleAnim(NULL), - mScaleAnim(NULL), - mAlphaAnim(NULL), - mMoveAnim(NULL) -{ - mControlFlags |= UI_CTRL_FLAG_ANIM; - - updateOriginPoint(); -} - -UIControlAnim::~UIControlAnim() { - eeSAFE_DELETE( mAlphaAnim ); - eeSAFE_DELETE( mAngleAnim ); - eeSAFE_DELETE( mScaleAnim ); - eeSAFE_DELETE( mMoveAnim ); -} - -Uint32 UIControlAnim::getType() const { - return UI_TYPE_CONTROL_ANIM; -} - -bool UIControlAnim::isType( const Uint32& type ) const { - return UIControlAnim::getType() == type ? true : UIControl::isType( type ); -} - -void UIControlAnim::drawSkin() { - if ( NULL != mSkinState ) { - if ( mFlags & UI_SKIN_KEEP_SIZE_ON_DRAW ) { - Sizei rSize = PixelDensity::dpToPxI( mSkinState->getSkin()->getSize( mSkinState->getState() ) ); - Sizei diff = ( mRealSize - rSize ) / 2; - - mSkinState->draw( mScreenPosf.x + diff.x, mScreenPosf.y + diff.y, (Float)rSize.getWidth(), (Float)rSize.getHeight(), (Uint32)mAlpha ); - } else { - mSkinState->draw( mScreenPosf.x, mScreenPosf.y, (Float)mRealSize.getWidth(), (Float)mRealSize.getHeight(), (Uint32)mAlpha ); - } - } -} - -void UIControlAnim::draw() { - if ( mVisible && 0.f != mAlpha ) { - drawBackground(); - - drawBorder(); - - drawSkin(); - - drawHighlightFocus(); - - drawOverControl(); - - drawDebugData(); - - drawBox(); - } -} - -const Float& UIControlAnim::getRotation() const { - return mAngle; -} - -const OriginPoint& UIControlAnim::getRotationOriginPoint() const { - return mRotationOriginPoint; -} - -void UIControlAnim::setRotationOriginPoint( const OriginPoint & center ) { - mRotationOriginPoint = PixelDensity::dpToPx( center ); - updateOriginPoint(); -} - -Vector2f UIControlAnim::getRotationCenter() { - switch ( mRotationOriginPoint.OriginType ) { - case OriginPoint::OriginCenter: return mCenter; - case OriginPoint::OriginTopLeft: return mScreenPosf; - case OriginPoint::OriginCustom: default: return mScreenPosf + mRotationOriginPoint; - } -} - -void UIControlAnim::setRotation( const Float& angle ) { - mAngle = angle; - - if ( mAngle != 0.f ) { - mControlFlags |= UI_CTRL_FLAG_ROTATED; - } else { - if ( mControlFlags & UI_CTRL_FLAG_ROTATED ) - mControlFlags &= ~UI_CTRL_FLAG_ROTATED; - } - - onAngleChange(); -} - -void UIControlAnim::setRotation( const Float& angle , const OriginPoint & center ) { - mRotationOriginPoint = center; - updateOriginPoint(); - this->setRotation( angle ); -} - -const Vector2f& UIControlAnim::getScale() const { - return mScale; -} - -void UIControlAnim::setScale( const Vector2f & scale ) { - mScale = scale; - - if ( mScale != 1.f ) { - mControlFlags |= UI_CTRL_FLAG_SCALED; - } else { - if ( mControlFlags & UI_CTRL_FLAG_SCALED ) - mControlFlags &= ~UI_CTRL_FLAG_SCALED; - } - - onScaleChange(); -} - -const OriginPoint& UIControlAnim::getScaleOriginPoint() const { - return mScaleOriginPoint; -} - -void UIControlAnim::setScaleOriginPoint( const OriginPoint & center ) { - mScaleOriginPoint = PixelDensity::dpToPx( center ); - updateOriginPoint(); -} - -Vector2f UIControlAnim::getScaleCenter() { - switch ( mScaleOriginPoint.OriginType ) { - case OriginPoint::OriginCenter: return mCenter; - case OriginPoint::OriginTopLeft: return mScreenPosf; - case OriginPoint::OriginCustom: default: return mScreenPosf + mScaleOriginPoint; - } -} - -void UIControlAnim::setScale( const Vector2f& scale, const OriginPoint& center ) { - mScaleOriginPoint = center; - updateOriginPoint(); - this->setScale( scale ); -} - -void UIControlAnim::setScale( const Float& scale, const OriginPoint& center ) { - this->setScale( Vector2f( scale, scale ), center ); -} - -const Float& UIControlAnim::getAlpha() const { - return mAlpha; -} - -void UIControlAnim::setAlpha( const Float& alpha ) { - mAlpha = alpha; - onAlphaChange(); -} - -void UIControlAnim::setChildsAlpha( const Float &alpha ) { - UIControlAnim * AnimChild; - UIControl * CurChild = mChild; - - while ( NULL != CurChild ) { - if ( CurChild->isAnimated() ) { - AnimChild = reinterpret_cast ( CurChild ); - - AnimChild->setAlpha( alpha ); - AnimChild->setChildsAlpha( alpha ); - } - - CurChild = CurChild->getNextControl(); - } -} - -void UIControlAnim::matrixSet() { - if ( mScale != 1.f || mAngle != 0.f ) { - GlobalBatchRenderer::instance()->draw(); - - GLi->pushMatrix(); - - Vector2f scaleCenter = getScaleCenter(); - GLi->translatef( scaleCenter.x , scaleCenter.y, 0.f ); - GLi->scalef( mScale.x, mScale.y, 1.0f ); - GLi->translatef( -scaleCenter.x, -scaleCenter.y, 0.f ); - - Vector2f rotationCenter = getRotationCenter(); - GLi->translatef( rotationCenter.x , rotationCenter.y, 0.f ); - GLi->rotatef( mAngle, 0.0f, 0.0f, 1.0f ); - GLi->translatef( -rotationCenter.x, -rotationCenter.y, 0.f ); - } -} - -void UIControlAnim::matrixUnset() { - if ( mScale != 1.f || mAngle != 0.f ) { - GlobalBatchRenderer::instance()->draw(); - - GLi->popMatrix(); - } -} - -void UIControlAnim::update() { - UIDragableControl::update(); - - if ( NULL != mMoveAnim && mMoveAnim->isEnabled() ) { - mMoveAnim->update( getElapsed() ); - setPosition( (int)mMoveAnim->getPosition().x, (int)mMoveAnim->getPosition().y ); - - if ( mMoveAnim->ended() ) - eeSAFE_DELETE( mMoveAnim ); - } - - if ( NULL != mAlphaAnim && mAlphaAnim->isEnabled() ) { - mAlphaAnim->update( getElapsed() ); - setAlpha( mAlphaAnim->getPosition() ); - - if ( mAlphaAnim->ended() ) { - if ( ( mControlFlags & UI_CTRL_FLAG_CLOSE_FO ) ) - close(); - - if ( ( mControlFlags & UI_CTRL_FLAG_DISABLE_FADE_OUT ) ) { - mControlFlags &= ~UI_CTRL_FLAG_DISABLE_FADE_OUT; - - setVisible( false ); - } - - eeSAFE_DELETE( mAlphaAnim ); - } - } - - if ( NULL != mScaleAnim && mScaleAnim->isEnabled() ) { - mScaleAnim->update( getElapsed() ); - setScale( mScaleAnim->getPosition() ); - - if ( mScaleAnim->ended() ) - eeSAFE_DELETE( mScaleAnim ); - } - - if ( NULL != mAngleAnim && mAngleAnim->isEnabled() ) { - mAngleAnim->update( getElapsed() ); - setRotation( mAngleAnim->getPosition() ); - - if ( mAngleAnim->ended() ) - eeSAFE_DELETE( mAngleAnim ); - } -} - -bool UIControlAnim::isFadingOut() { - return 0 != ( mControlFlags & UI_CTRL_FLAG_DISABLE_FADE_OUT ); -} - -bool UIControlAnim::isAnimating() { - return ( NULL != mAlphaAnim && mAlphaAnim->isEnabled() ) || ( NULL != mAngleAnim && mAngleAnim->isEnabled() ) || ( NULL != mScaleAnim && mScaleAnim->isEnabled() ) || ( NULL != mMoveAnim && mMoveAnim->isEnabled() ); -} - -Interpolation1d * UIControlAnim::startAlphaAnim( const Float& From, const Float& To, const Time& TotalTime, const bool& AlphaChilds, const Ease::Interpolation& Type, Interpolation1d::OnPathEndCallback PathEndCallback ) { - if ( NULL == mAlphaAnim ) - mAlphaAnim = eeNew( Interpolation1d, () ); - - mAlphaAnim->clear().add( From, TotalTime ).add( To ).setType( Type ).start( PathEndCallback ); - - setAlpha( From ); - - if ( AlphaChilds ) { - UIControlAnim * AnimChild; - UIControl * CurChild = mChild; - - while ( NULL != CurChild ) { - if ( CurChild->isAnimated() ) { - AnimChild = reinterpret_cast ( CurChild ); - - AnimChild->startAlphaAnim( From, To, TotalTime, AlphaChilds ); - } - - CurChild = CurChild->getNextControl(); - } - } - - return mAlphaAnim; -} - -Interpolation2d * UIControlAnim::startScaleAnim( const Vector2f& From, const Vector2f& To, const Time& TotalTime, const Ease::Interpolation& Type, Interpolation2d::OnPathEndCallback PathEndCallback ) { - if ( NULL == mScaleAnim ) - mScaleAnim = eeNew( Interpolation2d, () ); - - mScaleAnim->clear().add( From ).add( To ).setDuration( TotalTime ).setType( Type ).start( PathEndCallback ); - - setScale( From ); - - return mScaleAnim; -} - -Interpolation2d * UIControlAnim::startScaleAnim( const Float& From, const Float& To, const Time& TotalTime, const Ease::Interpolation& Type, Interpolation2d::OnPathEndCallback PathEndCallback ) { - return startScaleAnim( Vector2f( From, From ), Vector2f( To, To ), TotalTime, Type, PathEndCallback ); -} - -Interpolation2d * UIControlAnim::startTranslation( const Vector2i& From, const Vector2i& To, const Time& TotalTime, const Ease::Interpolation& Type, Interpolation2d::OnPathEndCallback PathEndCallback ) { - if ( NULL == mMoveAnim ) - mMoveAnim = eeNew( Interpolation2d, () ); - - mMoveAnim->clear().add( Vector2f( (Float)From.x, (Float)From.y ) ).add( Vector2f( (Float)To.x, (Float)To.y ) ).setType( Type ).setDuration( TotalTime ).start( PathEndCallback ); - - setPosition( From ); - - return mMoveAnim; -} - -Interpolation1d * UIControlAnim::startRotation( const Float& From, const Float& To, const Time& TotalTime, const Ease::Interpolation& Type, Interpolation1d::OnPathEndCallback PathEndCallback ) { - if ( NULL == mAngleAnim ) - mAngleAnim = eeNew( Interpolation1d, () ); - - mAngleAnim->clear().add( From ).add( To ).setDuration( TotalTime ).setType( Type ).start( PathEndCallback ); - - setRotation( From ); - - return mAngleAnim; -} - -Interpolation1d * UIControlAnim::startAlphaAnim(const Float & To, const Time & TotalTime, const bool & alphaChilds, const Ease::Interpolation & type, Interpolation1d::OnPathEndCallback PathEndCallback) { - return startAlphaAnim( mAlpha, To, TotalTime, alphaChilds, type, PathEndCallback ); -} - -Interpolation2d * UIControlAnim::startScaleAnim(const Vector2f & To, const Time & TotalTime, const Ease::Interpolation & type, Interpolation2d::OnPathEndCallback PathEndCallback) { - return startScaleAnim( mScale, To, TotalTime, type, PathEndCallback ); -} - -Interpolation2d * UIControlAnim::startScaleAnim(const Float & To, const Time & TotalTime, const Ease::Interpolation & type, Interpolation2d::OnPathEndCallback PathEndCallback) { - return startScaleAnim( mScale, Vector2f(To,To), TotalTime, type, PathEndCallback ); -} - -Interpolation2d * UIControlAnim::startTranslation(const Vector2i & To, const Time & TotalTime, const Ease::Interpolation & type, Interpolation2d::OnPathEndCallback PathEndCallback) { - return startTranslation( mPos, To, TotalTime, type, PathEndCallback ); -} - -Interpolation1d * UIControlAnim::startRotation(const Float & To, const Time & TotalTime, const Ease::Interpolation & type, Interpolation1d::OnPathEndCallback PathEndCallback) { - return startRotation( mAngle, To, TotalTime, type, PathEndCallback ); -} - -Interpolation1d * UIControlAnim::createFadeIn( const Time& time, const bool& AlphaChilds, const Ease::Interpolation& Type ) { - return startAlphaAnim( mAlpha, 255.f, time, AlphaChilds, Type ); -} - -Interpolation1d * UIControlAnim::createFadeOut( const Time& time, const bool& AlphaChilds, const Ease::Interpolation& Type ) { - return startAlphaAnim( 255.f, mAlpha, time, AlphaChilds, Type ); -} - -Interpolation1d * UIControlAnim::closeFadeOut( const Time& time, const bool& AlphaChilds, const Ease::Interpolation& Type ) { - startAlphaAnim ( mAlpha, 0.f, time, AlphaChilds, Type ); - mControlFlags |= UI_CTRL_FLAG_CLOSE_FO; - return mAlphaAnim; -} - -Interpolation1d * UIControlAnim::disableFadeOut( const Time& time, const bool& AlphaChilds, const Ease::Interpolation& Type ) { - setEnabled( false ); - - startAlphaAnim ( mAlpha, 0.f, time, AlphaChilds, Type ); - - mControlFlags |= UI_CTRL_FLAG_DISABLE_FADE_OUT; - - return mAlphaAnim; -} - -void UIControlAnim::drawBackground() { - if ( mFlags & UI_FILL_BACKGROUND ) { - mBackground->draw( getRectf(), mAlpha ); - } -} - -void UIControlAnim::drawBorder() { - if ( mFlags & UI_BORDER ) { - mBorder->draw( getRectf(), mAlpha, mBackground->getCorners(), ( mFlags & UI_CLIP_ENABLE ) != 0 ); - } -} - -Color UIControlAnim::getColor( const Color& Col ) { - return Color( Col.r, Col.g, Col.b, static_cast( (Float)Col.a * ( mAlpha / 255.f ) ) ); -} - -void UIControlAnim::updateQuad() { - mPoly = Polygon2f( Rectf( mScreenPosf.x, mScreenPosf.y, mScreenPosf.x + mRealSize.getWidth(), mScreenPosf.y + mRealSize.getHeight() ) ); - - mPoly.rotate( mAngle, getRotationCenter() ); - mPoly.scale( mScale, getScaleCenter() ); - - UIControl * tParent = getParent(); - - while ( tParent ) { - if ( tParent->isAnimated() ) { - UIControlAnim * tP = reinterpret_cast ( tParent ); - - mPoly.rotate( tP->getRotation(), tP->getRotationCenter() ); - mPoly.scale( tP->getScale(), tP->getScaleCenter() ); - } - - tParent = tParent->getParent(); - }; -} - -void UIControlAnim::onSizeChange() { - UIDragableControl::onSizeChange(); - - updateOriginPoint(); -} - -void UIControlAnim::updateOriginPoint() { - switch ( mRotationOriginPoint.OriginType ) { - case OriginPoint::OriginCenter: - mRotationOriginPoint.x = mRealSize.x * 0.5f; - mRotationOriginPoint.y = mRealSize.y * 0.5f; - break; - case OriginPoint::OriginTopLeft: - mRotationOriginPoint.x = mRotationOriginPoint.y = 0; - break; - default: {} - } - - switch ( mScaleOriginPoint.OriginType ) { - case OriginPoint::OriginCenter: - mScaleOriginPoint.x = mRealSize.x * 0.5f; - mScaleOriginPoint.y = mRealSize.y * 0.5f; - break; - case OriginPoint::OriginTopLeft: - mScaleOriginPoint.x = mScaleOriginPoint.y = 0; - break; - default: {} - } -} - -Interpolation1d * UIControlAnim::getRotationInterpolation() { - if ( NULL == mAngleAnim ) - mAngleAnim = eeNew( Interpolation1d, () ); - - return mAngleAnim; -} - -Interpolation2d * UIControlAnim::getScaleInterpolation() { - if ( NULL == mScaleAnim ) - mScaleAnim = eeNew( Interpolation2d, () ); - - return mScaleAnim; -} - -Interpolation1d * UIControlAnim::getAlphaInterpolation() { - if ( NULL == mAlphaAnim ) - mAlphaAnim = eeNew( Interpolation1d, () ); - - return mAlphaAnim; -} - -Interpolation2d * UIControlAnim::getTranslationInterpolation() { - if ( NULL == mMoveAnim ) - mMoveAnim = eeNew( Interpolation2d, () ); - - return mMoveAnim; -} - -void UIControlAnim::onAngleChange() { - sendCommonEvent( UIEvent::OnAngleChange ); - invalidateDraw(); -} - -void UIControlAnim::onScaleChange() { - sendCommonEvent( UIEvent::OnScaleChange ); - invalidateDraw(); -} - -void UIControlAnim::onAlphaChange() { - sendCommonEvent( UIEvent::OnAlphaChange ); - invalidateDraw(); -} - -}} - diff --git a/src/eepp/ui/uidragablecontrol.cpp b/src/eepp/ui/uidragablecontrol.cpp deleted file mode 100644 index e71d5634f..000000000 --- a/src/eepp/ui/uidragablecontrol.cpp +++ /dev/null @@ -1,140 +0,0 @@ -#include -#include -#include - -namespace EE { namespace UI { - -UIDragableControl * UIDragableControl::New() { - return eeNew( UIDragableControl, () ); -} - -UIDragableControl::UIDragableControl() : - UIControl(), - mDragButton( EE_BUTTON_LMASK ) -{ - mControlFlags |= UI_CTRL_FLAG_DRAGABLE; -} - -UIDragableControl::~UIDragableControl() { -} - -Uint32 UIDragableControl::getType() const { - return UI_TYPE_CONTROL_DRAGABLE; -} - -bool UIDragableControl::isType( const Uint32& type ) const { - return UIDragableControl::getType() == type ? true : UIControl::isType( type ); -} - -Uint32 UIDragableControl::onMouseDown( const Vector2i& Pos, const Uint32 Flags ) { - if ( !( UIManager::instance()->getLastPressTrigger() & mDragButton ) && ( Flags & mDragButton ) && isDragEnabled() && !isDragging() ) { - setDragging( true ); - mDragPoint = Pos; - } - - UIControl::onMouseDown( Pos, Flags ); - return 1; -} - -Uint32 UIDragableControl::onMouseUp( const Vector2i& Pos, const Uint32 Flags ) { - if ( isDragEnabled() && isDragging() && ( Flags & mDragButton ) ) { - setDragging( false ); - } - - UIControl::onMouseUp( Pos, Flags ); - return 1; -} - -const Vector2i& UIDragableControl::getDragPoint() const { - return mDragPoint; -} - -void UIDragableControl::setDragPoint( const Vector2i& Point ) { - mDragPoint = Point; -} - -void UIDragableControl::update() { - UIControl::update(); - - if ( !isDragEnabled() ) - return; - - if ( isDragging() ) { - if ( !( UIManager::instance()->getPressTrigger() & mDragButton ) ) { - setDragging( false ); - UIManager::instance()->setControlDragging( false ); - return; - } - - Vector2i Pos( UIManager::instance()->getMousePos() ); - - if ( mDragPoint != Pos && ( abs( mDragPoint.x - Pos.x ) > PixelDensity::getPixelDensity() || abs( mDragPoint.y - Pos.y ) > PixelDensity::getPixelDensity() ) ) { - if ( onDrag( Pos ) ) { - Sizei dragDiff; - - dragDiff.x = (Int32)( (Float)( mDragPoint.x - Pos.x ) / PixelDensity::getPixelDensity() ); - dragDiff.y = (Int32)( (Float)( mDragPoint.y - Pos.y ) / PixelDensity::getPixelDensity() ); - - setInternalPosition( mPos - dragDiff ); - - mDragPoint = Pos; - - onPositionChange(); - - UIManager::instance()->setControlDragging( true ); - } - } - } -} - -Uint32 UIDragableControl::onDrag( const Vector2i& Pos ) { - return 1; -} - -Uint32 UIDragableControl::onDragStart( const Vector2i& Pos ) { - sendCommonEvent( UIEvent::OnDragStart ); - return 1; -} - -Uint32 UIDragableControl::onDragStop( const Vector2i& Pos ) { - sendCommonEvent( UIEvent::OnDragStop ); - return 1; -} - -bool UIDragableControl::isDragEnabled() const { - return 0 != ( mFlags & UI_DRAG_ENABLE ); -} - -void UIDragableControl::setDragEnabled( const bool& enable ) { - writeFlag( UI_DRAG_ENABLE, true == enable ); -} - -bool UIDragableControl::isDragging() const { - return 0 != ( mControlFlags & UI_CTRL_FLAG_DRAGGING ); -} - -void UIDragableControl::setDragging( const bool& dragging ) { - writeCtrlFlag( UI_CTRL_FLAG_DRAGGING, dragging ); - - if ( dragging ) { - UIMessage tMsg( this, UIMessage::DragStart, 0 ); - messagePost( &tMsg ); - - onDragStart( UIManager::instance()->getMousePos() ); - } else { - UIMessage tMsg( this, UIMessage::DragStop, 0 ); - messagePost( &tMsg ); - - onDragStop( UIManager::instance()->getMousePos() ); - } -} - -void UIDragableControl::setDragButton( const Uint32& Button ) { - mDragButton = Button; -} - -const Uint32& UIDragableControl::getDragButton() const { - return mDragButton; -} - -}} diff --git a/src/eepp/ui/uidropdownlist.cpp b/src/eepp/ui/uidropdownlist.cpp index 492071b35..70999b65e 100644 --- a/src/eepp/ui/uidropdownlist.cpp +++ b/src/eepp/ui/uidropdownlist.cpp @@ -77,7 +77,7 @@ void UIDropDownList::onThemeLoaded() { autoSizeControl(); } -void UIDropDownList::setFriendControl( UIControl * friendCtrl ) { +void UIDropDownList::setFriendControl( UINode * friendCtrl ) { mFriendCtrl = friendCtrl; } @@ -116,8 +116,8 @@ void UIDropDownList::showList() { } else if ( NULL != mFriendCtrl ) { Pos = Vector2i( mFriendCtrl->getPosition().x, mFriendCtrl->getPosition().y + mFriendCtrl->getSize().getHeight() ); } else { - UIControl * ParentLoop = getParent(); - UIControl * rp = getWindowContainer(); + UINode * ParentLoop = getParent(); + UINode * rp = getWindowContainer(); while ( rp != ParentLoop ) { Pos += ParentLoop->getPosition(); ParentLoop = ParentLoop->getParent(); @@ -151,8 +151,8 @@ void UIDropDownList::showList() { } else if ( NULL != mFriendCtrl ) { Pos = Vector2i( mFriendCtrl->getPosition().x, mFriendCtrl->getPosition().y + mFriendCtrl->getSize().getHeight() ); } else { - UIControl * ParentLoop = getParent(); - UIControl * rp = getWindowContainer(); + UINode * ParentLoop = getParent(); + UINode * rp = getWindowContainer(); while ( rp != ParentLoop ) { Pos += ParentLoop->getPosition(); ParentLoop = ParentLoop->getParent(); diff --git a/src/eepp/ui/uievent.cpp b/src/eepp/ui/uievent.cpp index 966ce6a6e..cc7f30bba 100644 --- a/src/eepp/ui/uievent.cpp +++ b/src/eepp/ui/uievent.cpp @@ -1,9 +1,9 @@ #include -#include +#include namespace EE { namespace UI { -UIEvent::UIEvent(UIControl * control, const Uint32& eventType ) : +UIEvent::UIEvent(UINode * control, const Uint32& eventType ) : mCtrl( control ), mEventType( eventType ) { @@ -13,7 +13,7 @@ UIEvent::~UIEvent() { } -UIControl * UIEvent::getControl() const { +UINode * UIEvent::getControl() const { return mCtrl; } diff --git a/src/eepp/ui/uieventkey.cpp b/src/eepp/ui/uieventkey.cpp index 2b68f61a6..e2c6408a6 100644 --- a/src/eepp/ui/uieventkey.cpp +++ b/src/eepp/ui/uieventkey.cpp @@ -1,9 +1,9 @@ #include -#include +#include namespace EE { namespace UI { -UIEventKey::UIEventKey( UIControl * Ctrl, const Uint32& EventNum, const Uint32& KeyCode, const Uint16& Char, const Uint32& Mod ) : +UIEventKey::UIEventKey( UINode * Ctrl, const Uint32& EventNum, const Uint32& KeyCode, const Uint16& Char, const Uint32& Mod ) : UIEvent( Ctrl, EventNum ), mKeyCode( KeyCode ), mChar( Char ), diff --git a/src/eepp/ui/uieventmouse.cpp b/src/eepp/ui/uieventmouse.cpp index 1b1d62497..4cca0ef0b 100644 --- a/src/eepp/ui/uieventmouse.cpp +++ b/src/eepp/ui/uieventmouse.cpp @@ -1,9 +1,9 @@ #include -#include +#include namespace EE { namespace UI { -UIEventMouse::UIEventMouse( UIControl * Ctrl, const Uint32& EventNum, const Vector2i& Pos, const Uint32& Flags ) : +UIEventMouse::UIEventMouse( UINode * Ctrl, const Uint32& EventNum, const Vector2i& Pos, const Uint32& Flags ) : UIEvent( Ctrl, EventNum ), mPos( Pos ), mFlags( Flags ) diff --git a/src/eepp/ui/uigridlayout.cpp b/src/eepp/ui/uigridlayout.cpp index 8d47ec65f..842cc74cf 100644 --- a/src/eepp/ui/uigridlayout.cpp +++ b/src/eepp/ui/uigridlayout.cpp @@ -143,7 +143,7 @@ void UIGridLayout::pack() { setInternalHeight( getParent()->getSize().getHeight() - mLayoutMargin.Top - mLayoutMargin.Bottom ); } - UIControl * ChildLoop = mChild; + UINode * ChildLoop = mChild; Vector2i pos(mPadding.Left,mPadding.Top); Sizei targetSize( getTargetElementSize() ); diff --git a/src/eepp/ui/uiimage.cpp b/src/eepp/ui/uiimage.cpp index aa69e13de..78b351d7d 100644 --- a/src/eepp/ui/uiimage.cpp +++ b/src/eepp/ui/uiimage.cpp @@ -92,7 +92,7 @@ void UIImage::calcDestSize() { } void UIImage::draw() { - UIControlAnim::draw(); + UINode::draw(); if ( mVisible ) { if ( NULL != mDrawable && 0.f != mAlpha ) { @@ -106,7 +106,7 @@ void UIImage::draw() { } void UIImage::setAlpha( const Float& alpha ) { - UIControlAnim::setAlpha( alpha ); + UINode::setAlpha( alpha ); mColor.a = (Uint8)alpha; } diff --git a/src/eepp/ui/uilinearlayout.cpp b/src/eepp/ui/uilinearlayout.cpp index ee717caa6..e6571003b 100644 --- a/src/eepp/ui/uilinearlayout.cpp +++ b/src/eepp/ui/uilinearlayout.cpp @@ -77,7 +77,7 @@ void UILinearLayout::packVertical() { setInternalHeight( getParent()->getSize().getHeight() - mLayoutMargin.Top - mLayoutMargin.Bottom ); } - UIControl * ChildLoop = mChild; + UINode * ChildLoop = mChild; while ( NULL != ChildLoop ) { if ( ChildLoop->isWidget() && ChildLoop->isVisible() ) { @@ -191,7 +191,7 @@ void UILinearLayout::packHorizontal() { setInternalHeight( getParent()->getSize().getHeight() - mLayoutMargin.Top - mLayoutMargin.Bottom ); } - UIControl * ChildLoop = mChild; + UINode * ChildLoop = mChild; while ( NULL != ChildLoop ) { if ( ChildLoop->isWidget() ) { @@ -297,7 +297,7 @@ void UILinearLayout::packHorizontal() { } Sizei UILinearLayout::getTotalUsedSize() { - UIControl * ChildLoop = mChild; + UINode * ChildLoop = mChild; Sizei size( 0, 0 ); while ( NULL != ChildLoop ) { diff --git a/src/eepp/ui/uilistbox.cpp b/src/eepp/ui/uilistbox.cpp index 0ecc93a8e..1a90bd620 100644 --- a/src/eepp/ui/uilistbox.cpp +++ b/src/eepp/ui/uilistbox.cpp @@ -858,7 +858,7 @@ void UIListBox::selectNext() { } Uint32 UIListBox::onKeyDown( const UIEventKey &Event ) { - UIControlAnim::onKeyDown( Event ); + UINode::onKeyDown( Event ); if ( !mSelected.size() || mFlags & UI_MULTI_SELECT ) return 0; @@ -904,7 +904,7 @@ Uint32 UIListBox::onMessage( const UIMessage * Msg ) { switch ( Msg->getMsg() ) { case UIMessage::FocusLoss: { - UIControl * FocusCtrl = UIManager::instance()->getFocusControl(); + UINode * FocusCtrl = UIManager::instance()->getFocusControl(); if ( this != FocusCtrl && !isParentOf( FocusCtrl ) ) { onWidgetFocusLoss(); diff --git a/src/eepp/ui/uilistboxitem.cpp b/src/eepp/ui/uilistboxitem.cpp index 7b1b1a5d3..796349026 100644 --- a/src/eepp/ui/uilistboxitem.cpp +++ b/src/eepp/ui/uilistboxitem.cpp @@ -96,7 +96,7 @@ void UIListBoxItem::update() { } Uint32 UIListBoxItem::onMouseExit( const Vector2i& Pos, const Uint32 Flags ) { - UIControl::onMouseExit( Pos, Flags ); + UINode::onMouseExit( Pos, Flags ); if ( mControlFlags & UI_CTRL_FLAG_SELECTED ) setSkinState( UISkinState::StateSelected ); diff --git a/src/eepp/ui/uimanager.cpp b/src/eepp/ui/uimanager.cpp index 6ce5eb501..c6173ca67 100644 --- a/src/eepp/ui/uimanager.cpp +++ b/src/eepp/ui/uimanager.cpp @@ -146,7 +146,7 @@ void UIManager::resizeControl( EE::Window::Window * win ) { void UIManager::sendKeyUp( const Uint32& KeyCode, const Uint16& Char, const Uint32& Mod ) { UIEventKey KeyEvent = UIEventKey( mFocusControl, UIEvent::KeyUp, KeyCode, Char, Mod ); - UIControl * CtrlLoop = mFocusControl; + UINode * CtrlLoop = mFocusControl; while( NULL != CtrlLoop ) { if ( CtrlLoop->isEnabled() && CtrlLoop->onKeyUp( KeyEvent ) ) @@ -158,7 +158,7 @@ void UIManager::sendKeyUp( const Uint32& KeyCode, const Uint16& Char, const Uint void UIManager::sendKeyDown( const Uint32& KeyCode, const Uint16& Char, const Uint32& Mod ) { UIEventKey KeyEvent = UIEventKey( mFocusControl, UIEvent::KeyDown, KeyCode, Char, Mod ); - UIControl * CtrlLoop = mFocusControl; + UINode * CtrlLoop = mFocusControl; while( NULL != CtrlLoop ) { if ( CtrlLoop->isEnabled() && CtrlLoop->onKeyDown( KeyEvent ) ) @@ -168,15 +168,15 @@ void UIManager::sendKeyDown( const Uint32& KeyCode, const Uint16& Char, const Ui } } -UIControl * UIManager::getFocusControl() const { +UINode * UIManager::getFocusControl() const { return mFocusControl; } -UIControl * UIManager::getLossFocusControl() const { +UINode * UIManager::getLossFocusControl() const { return mLossFocusControl; } -void UIManager::setFocusControl( UIControl * Ctrl ) { +void UIManager::setFocusControl( UINode * Ctrl ) { if ( NULL != mFocusControl && NULL != Ctrl && Ctrl != mFocusControl ) { mLossFocusControl = mFocusControl; @@ -190,15 +190,15 @@ void UIManager::setFocusControl( UIControl * Ctrl ) { } } -UIControl * UIManager::getOverControl() const { +UINode * UIManager::getOverControl() const { return mOverControl; } -void UIManager::setOverControl( UIControl * Ctrl ) { +void UIManager::setOverControl( UINode * Ctrl ) { mOverControl = Ctrl; } -void UIManager::sendMsg( UIControl * Ctrl, const Uint32& Msg, const Uint32& Flags ) { +void UIManager::sendMsg( UINode * Ctrl, const Uint32& Msg, const Uint32& Flags ) { UIMessage tMsg( Ctrl, Msg, Flags ); Ctrl->messagePost( &tMsg ); @@ -211,7 +211,7 @@ void UIManager::update() { mControl->update(); - UIControl * pOver = mControl->overFind( mKM->getMousePosf() ); + UINode * pOver = mControl->overFind( mKM->getMousePosf() ); if ( pOver != mOverControl ) { if ( NULL != mOverControl ) { @@ -271,7 +271,7 @@ void UIManager::update() { checkClose(); } -UIControl * UIManager::getDownControl() const { +UINode * UIManager::getDownControl() const { return mDownControl; } @@ -305,7 +305,7 @@ const Uint32& UIManager::getLastPressTrigger() const { return mKM->getLastPressTrigger(); } -void UIManager::clipSmartEnable(UIControl * ctrl, const Int32 & x, const Int32 & y, const Uint32 & Width, const Uint32 & Height) { +void UIManager::clipSmartEnable(UINode * ctrl, const Int32 & x, const Int32 & y, const Uint32 & Width, const Uint32 & Height) { if ( ctrl->isMeOrParentTreeScaledOrRotatedOrFrameBuffer() ) { GLi->getClippingMask()->clipPlaneEnable( x, y, Width, Height ); } else { @@ -313,7 +313,7 @@ void UIManager::clipSmartEnable(UIControl * ctrl, const Int32 & x, const Int32 & } } -void UIManager::clipSmartDisable(UIControl * ctrl) { +void UIManager::clipSmartDisable(UINode * ctrl) { if ( ctrl->isMeOrParentTreeScaledOrRotatedOrFrameBuffer() ) { GLi->getClippingMask()->clipPlaneDisable(); } else { @@ -413,24 +413,24 @@ void UIManager::checkTabPress( const Uint32& KeyCode ) { eeASSERT( NULL != mFocusControl ); if ( KeyCode == KEY_TAB ) { - UIControl * Ctrl = mFocusControl->getNextWidget(); + UINode * Ctrl = mFocusControl->getNextWidget(); if ( NULL != Ctrl ) Ctrl->setFocus(); } } -void UIManager::sendMouseClick( UIControl * ToCtrl, const Vector2i& Pos, const Uint32 Flags ) { +void UIManager::sendMouseClick( UINode * ToCtrl, const Vector2i& Pos, const Uint32 Flags ) { sendMsg( ToCtrl, UIMessage::Click, Flags ); ToCtrl->onMouseClick( Pos, Flags ); } -void UIManager::sendMouseUp( UIControl * ToCtrl, const Vector2i& Pos, const Uint32 Flags ) { +void UIManager::sendMouseUp( UINode * ToCtrl, const Vector2i& Pos, const Uint32 Flags ) { sendMsg( ToCtrl, UIMessage::MouseUp, Flags ); ToCtrl->onMouseUp( Pos, Flags ); } -void UIManager::sendMouseDown( UIControl * ToCtrl, const Vector2i& Pos, const Uint32 Flags ) { +void UIManager::sendMouseDown( UINode * ToCtrl, const Vector2i& Pos, const Uint32 Flags ) { sendMsg( ToCtrl, UIMessage::MouseDown, Flags ); ToCtrl->onMouseDown( Pos, Flags ); } @@ -473,11 +473,11 @@ const Vector2i &UIManager::getMouseDownPos() const { return mMouseDownPos; } -void UIManager::addToCloseQueue( UIControl * Ctrl ) { +void UIManager::addToCloseQueue( UINode * Ctrl ) { eeASSERT( NULL != Ctrl ); - std::list::iterator it; - UIControl * itCtrl = NULL; + std::list::iterator it; + UINode * itCtrl = NULL; for ( it = mCloseList.begin(); it != mCloseList.end(); it++ ) { itCtrl = *it; @@ -490,7 +490,7 @@ void UIManager::addToCloseQueue( UIControl * Ctrl ) { } } - std::list< std::list::iterator > itEraseList; + std::list< std::list::iterator > itEraseList; for ( it = mCloseList.begin(); it != mCloseList.end(); it++ ) { itCtrl = *it; @@ -507,7 +507,7 @@ void UIManager::addToCloseQueue( UIControl * Ctrl ) { // We delete all the controls that don't need to be deleted // because of the new added control to the queue - std::list< std::list::iterator >::iterator ite; + std::list< std::list::iterator >::iterator ite; for ( ite = itEraseList.begin(); ite != itEraseList.end(); ite++ ) { mCloseList.erase( *ite ); @@ -518,7 +518,7 @@ void UIManager::addToCloseQueue( UIControl * Ctrl ) { void UIManager::checkClose() { if ( !mCloseList.empty() ) { - for ( std::list::iterator it = mCloseList.begin(); it != mCloseList.end(); it++ ) { + for ( std::list::iterator it = mCloseList.begin(); it != mCloseList.end(); it++ ) { eeDelete( *it ); } @@ -571,7 +571,7 @@ void UIManager::setHighlightInvalidationColor(const Color & highlightInvalidatio mHighlightInvalidationColor = highlightInvalidationColor; } -UIWidget * UIManager::loadLayoutNodes( pugi::xml_node node, UIControl * parent ) { +UIWidget * UIManager::loadLayoutNodes( pugi::xml_node node, UINode * parent ) { UIWidget * firstWidget = NULL; if ( NULL == parent ) @@ -599,7 +599,7 @@ UIWidget * UIManager::loadLayoutNodes( pugi::xml_node node, UIControl * parent ) return firstWidget; } -UIWidget * UIManager::loadLayoutFromFile( const std::string& layoutPath, UIControl * parent ) { +UIWidget * UIManager::loadLayoutFromFile( const std::string& layoutPath, UINode * parent ) { if ( FileSystem::fileExists( layoutPath ) ) { pugi::xml_document doc; pugi::xml_parse_result result = doc.load_file( layoutPath.c_str() ); @@ -623,7 +623,7 @@ UIWidget * UIManager::loadLayoutFromFile( const std::string& layoutPath, UIContr return NULL; } -UIWidget * UIManager::loadLayoutFromString( const std::string& layoutString, UIControl * parent ) { +UIWidget * UIManager::loadLayoutFromString( const std::string& layoutString, UINode * parent ) { pugi::xml_document doc; pugi::xml_parse_result result = doc.load_string( layoutString.c_str() ); @@ -638,7 +638,7 @@ UIWidget * UIManager::loadLayoutFromString( const std::string& layoutString, UIC return NULL; } -UIWidget * UIManager::loadLayoutFromMemory( const void * buffer, Int32 bufferSize, UIControl * parent ) { +UIWidget * UIManager::loadLayoutFromMemory( const void * buffer, Int32 bufferSize, UINode * parent ) { pugi::xml_document doc; pugi::xml_parse_result result = doc.load_buffer( buffer, bufferSize); @@ -653,7 +653,7 @@ UIWidget * UIManager::loadLayoutFromMemory( const void * buffer, Int32 bufferSiz return NULL; } -UIWidget * UIManager::loadLayoutFromStream( IOStream& stream, UIControl * parent ) { +UIWidget * UIManager::loadLayoutFromStream( IOStream& stream, UINode * parent ) { if ( !stream.isOpen() ) return NULL; @@ -675,7 +675,7 @@ UIWidget * UIManager::loadLayoutFromStream( IOStream& stream, UIControl * parent return NULL; } -UIWidget * UIManager::loadLayoutFromPack( Pack * pack, const std::string& FilePackPath, UIControl * parent ) { +UIWidget * UIManager::loadLayoutFromPack( Pack * pack, const std::string& FilePackPath, UINode * parent ) { SafeDataPointer PData; if ( pack->isOpen() && pack->extractFileToMemory( FilePackPath, PData ) ) { diff --git a/src/eepp/ui/uimenu.cpp b/src/eepp/ui/uimenu.cpp index e6d9b38ce..b042410fd 100644 --- a/src/eepp/ui/uimenu.cpp +++ b/src/eepp/ui/uimenu.cpp @@ -121,7 +121,7 @@ Uint32 UIMenu::addSubMenu( const String& Text, Drawable * Icon, UIMenu * SubMenu return add( createSubMenu( Text, Icon, SubMenu ) ); } -bool UIMenu::checkControlSize( UIControl * Control, const bool& Resize ) { +bool UIMenu::checkControlSize( UINode * Control, const bool& Resize ) { if ( Control->isType( UI_TYPE_MENUITEM ) ) { UIMenuItem * tItem = reinterpret_cast ( Control ); @@ -161,7 +161,7 @@ bool UIMenu::checkControlSize( UIControl * Control, const bool& Resize ) { return false; } -Uint32 UIMenu::add( UIControl * Control ) { +Uint32 UIMenu::add( UINode * Control ) { if ( this != Control->getParent() ) Control->setParent( this ); @@ -180,7 +180,7 @@ Uint32 UIMenu::add( UIControl * Control ) { return mItems.size() - 1; } -void UIMenu::setControlSize( UIControl * Control, const Uint32& Pos ) { +void UIMenu::setControlSize( UINode * Control, const Uint32& Pos ) { Control->setPixelsSize( mRealSize.getWidth(), Control->getRealSize().getHeight() ); } @@ -199,12 +199,12 @@ Uint32 UIMenu::addSeparator() { return mItems.size() - 1; } -UIControl * UIMenu::getItem( const Uint32& Index ) { +UINode * UIMenu::getItem( const Uint32& Index ) { eeASSERT( Index < mItems.size() ); return mItems[ Index ]; } -UIControl * UIMenu::getItem( const String& Text ) { +UINode * UIMenu::getItem( const String& Text ) { for ( Uint32 i = 0; i < mItems.size(); i++ ) { if ( mItems[i]->isType( UI_TYPE_MENUITEM ) ) { UIMenuItem * tMenuItem = reinterpret_cast( mItems[i] ); @@ -217,7 +217,7 @@ UIControl * UIMenu::getItem( const String& Text ) { return NULL; } -Uint32 UIMenu::getItemIndex( UIControl * Item ) { +Uint32 UIMenu::getItemIndex( UINode * Item ) { for ( Uint32 i = 0; i < mItems.size(); i++ ) { if ( mItems[i] == Item ) return i; @@ -241,7 +241,7 @@ void UIMenu::remove( const Uint32& Index ) { resizeControls(); } -void UIMenu::remove( UIControl * Ctrl ) { +void UIMenu::remove( UINode * Ctrl ) { for ( Uint32 i = 0; i < mItems.size(); i++ ) { if ( mItems[i] == Ctrl ) { remove( i ); @@ -266,7 +266,7 @@ void UIMenu::insert( const String& Text, Drawable * Icon, const Uint32& Index ) insert( createMenuItem( Text, Icon ), Index ); } -void UIMenu::insert( UIControl * Control, const Uint32& Index ) { +void UIMenu::insert( UINode * Control, const Uint32& Index ) { mItems.insert( mItems.begin() + Index, Control ); childAddAt( Control, Index ); @@ -275,7 +275,7 @@ void UIMenu::insert( UIControl * Control, const Uint32& Index ) { resizeControls(); } -bool UIMenu::isSubMenu( UIControl * Ctrl ) { +bool UIMenu::isSubMenu( UINode * Ctrl ) { for ( Uint32 i = 0; i < mItems.size(); i++ ) { if ( mItems[i]->isType( UI_TYPE_MENUSUBMENU ) ) { UIMenuSubMenu * tMenu = reinterpret_cast ( mItems[i] ); @@ -301,7 +301,7 @@ Uint32 UIMenu::onMessage( const UIMessage * Msg ) { } case UIMessage::FocusLoss: { - UIControl * FocusCtrl = UIManager::instance()->getFocusControl(); + UINode * FocusCtrl = UIManager::instance()->getFocusControl(); if ( this != FocusCtrl && !isParentOf( FocusCtrl ) && !isSubMenu( FocusCtrl ) ) { onWidgetFocusLoss(); @@ -350,7 +350,7 @@ void UIMenu::rePosControls() { } for ( i = 0; i < mItems.size(); i++ ) { - UIControl * ctrl = mItems[i]; + UINode * ctrl = mItems[i]; ctrl->setPixelsPosition( PixelDensity::dpToPxI( mStyleConfig.Padding.Left ), PixelDensity::dpToPxI( mStyleConfig.Padding.Top ) + mNextPosY ); @@ -388,7 +388,7 @@ bool UIMenu::hide() { return true; } -void UIMenu::setItemSelected( UIControl * Item ) { +void UIMenu::setItemSelected( UINode * Item ) { if ( NULL != mItemSelected ) { if ( mItemSelected->isType( UI_TYPE_MENUSUBMENU ) ) { UIMenuSubMenu * tMenu = reinterpret_cast ( mItemSelected ); @@ -409,7 +409,7 @@ void UIMenu::setItemSelected( UIControl * Item ) { } } -void UIMenu::trySelect( UIControl * Ctrl, bool Up ) { +void UIMenu::trySelect( UINode * Ctrl, bool Up ) { if ( mItems.size() ) { if ( !Ctrl->isType( UI_TYPE_MENU_SEPARATOR ) ) { setItemSelected( Ctrl ); diff --git a/src/eepp/ui/uimenuseparator.cpp b/src/eepp/ui/uimenuseparator.cpp index 363ba82e2..39059eeb1 100644 --- a/src/eepp/ui/uimenuseparator.cpp +++ b/src/eepp/ui/uimenuseparator.cpp @@ -21,7 +21,7 @@ Uint32 UIMenuSeparator::getType() const { } bool UIMenuSeparator::isType( const Uint32& type ) const { - return UIMenuSeparator::getType() == type ? true : UIControlAnim::isType( type ); + return UIMenuSeparator::getType() == type ? true : UINode::isType( type ); } void UIMenuSeparator::setTheme( UITheme * Theme ) { diff --git a/src/eepp/ui/uimenusubmenu.cpp b/src/eepp/ui/uimenusubmenu.cpp index 6cf37222e..3e51532f8 100644 --- a/src/eepp/ui/uimenusubmenu.cpp +++ b/src/eepp/ui/uimenusubmenu.cpp @@ -17,7 +17,7 @@ UIMenuSubMenu::UIMenuSubMenu() : mCbId( 0 ), mCbId2( 0 ) { - mArrow = UIControlAnim::New(); + mArrow = UINode::New(); mArrow->setParent( this ); mArrow->setFlags( UI_AUTO_SIZE ); mArrow->setVisible( true ); @@ -122,12 +122,12 @@ Uint32 UIMenuSubMenu::onMouseExit( const Vector2i &Pos, const Uint32 Flags ) { return 1; } -UIControl * UIMenuSubMenu::getArrow() const { +UINode * UIMenuSubMenu::getArrow() const { return mArrow; } void UIMenuSubMenu::onSubMenuFocusLoss( const UIEvent * Event ) { - UIControl * FocusCtrl = UIManager::instance()->getFocusControl(); + UINode * FocusCtrl = UIManager::instance()->getFocusControl(); if ( getParent() != FocusCtrl && !getParent()->isParentOf( FocusCtrl ) ) { getParent()->setFocus(); diff --git a/src/eepp/ui/uimessage.cpp b/src/eepp/ui/uimessage.cpp index 14df4f37b..206229943 100644 --- a/src/eepp/ui/uimessage.cpp +++ b/src/eepp/ui/uimessage.cpp @@ -1,9 +1,9 @@ #include -#include +#include namespace EE { namespace UI { -UIMessage::UIMessage( UIControl * Ctrl, const Uint32& Msg, const Uint32& Flags ) : +UIMessage::UIMessage( UINode * Ctrl, const Uint32& Msg, const Uint32& Flags ) : mCtrl( Ctrl ), mMsg( Msg ), mFlags( Flags ) @@ -14,7 +14,7 @@ UIMessage::~UIMessage() { } -UIControl * UIMessage::getSender() const { +UINode * UIMessage::getSender() const { return mCtrl; } diff --git a/src/eepp/ui/uicontrol.cpp b/src/eepp/ui/uinode.cpp similarity index 50% rename from src/eepp/ui/uicontrol.cpp rename to src/eepp/ui/uinode.cpp index 42a3cbfbf..20af1efa4 100644 --- a/src/eepp/ui/uicontrol.cpp +++ b/src/eepp/ui/uinode.cpp @@ -1,20 +1,21 @@ -#include +#include #include #include #include #include #include #include +#include #include #include namespace EE { namespace UI { -UIControl * UIControl::New() { - return eeNew( UIControl, () ); +UINode * UINode::New() { + return eeNew( UINode, () ); } -UIControl::UIControl() : +UINode::UINode() : mIdHash( 0 ), mPos( 0, 0 ), mRealPos( 0, 0 ), @@ -35,7 +36,15 @@ UIControl::UIControl() : mBlend( BlendAlpha ), mNumCallBacks( 0 ), mVisible( true ), - mEnabled( true ) + mEnabled( true ), + mDragButton( EE_BUTTON_LMASK ), + mAngle(0.f), + mScale(1.f,1.f), + mAlpha(255.f), + mAngleAnim(NULL), + mScaleAnim(NULL), + mAlphaAnim(NULL), + mMoveAnim(NULL) { if ( NULL == mParentCtrl && NULL != UIManager::instance()->getMainControl() ) { mParentCtrl = UIManager::instance()->getMainControl(); @@ -47,12 +56,17 @@ UIControl::UIControl() : updateScreenPos(); updateQuad(); + updateOriginPoint(); } -UIControl::~UIControl() { +UINode::~UINode() { removeSkin(); eeSAFE_DELETE( mBackground ); eeSAFE_DELETE( mBorder ); + eeSAFE_DELETE( mAlphaAnim ); + eeSAFE_DELETE( mAngleAnim ); + eeSAFE_DELETE( mScaleAnim ); + eeSAFE_DELETE( mMoveAnim ); childDeleteAll(); @@ -68,8 +82,8 @@ UIControl::~UIControl() { } } -void UIControl::screenToControl( Vector2i& Pos ) const { - UIControl * ParentLoop = mParentCtrl; +void UINode::screenToControl( Vector2i& Pos ) const { + UINode * ParentLoop = mParentCtrl; Pos.x -= mRealPos.x; Pos.y -= mRealPos.y; @@ -84,8 +98,8 @@ void UIControl::screenToControl( Vector2i& Pos ) const { } } -void UIControl::controlToScreen( Vector2i& Pos ) const { - UIControl * ParentLoop = mParentCtrl; +void UINode::controlToScreen( Vector2i& Pos ) const { + UINode * ParentLoop = mParentCtrl; while ( NULL != ParentLoop ) { const Vector2i& ParentPos = ParentLoop->getRealPosition(); @@ -97,16 +111,16 @@ void UIControl::controlToScreen( Vector2i& Pos ) const { } } -Uint32 UIControl::getType() const { - return UI_TYPE_CONTROL; +Uint32 UINode::getType() const { + return UI_TYPE_NODE; } -bool UIControl::isType( const Uint32& type ) const { - return UIControl::getType() == type; +bool UINode::isType( const Uint32& type ) const { + return UINode::getType() == type; } -void UIControl::messagePost( const UIMessage * Msg ) { - UIControl * Ctrl = this; +void UINode::messagePost( const UIMessage * Msg ) { + UINode * Ctrl = this; while( NULL != Ctrl ) { if ( Ctrl->onMessage( Msg ) ) @@ -116,18 +130,18 @@ void UIControl::messagePost( const UIMessage * Msg ) { } } -Uint32 UIControl::onMessage( const UIMessage * Msg ) { +Uint32 UINode::onMessage( const UIMessage * Msg ) { return 0; } -void UIControl::setInternalPosition( const Vector2i& Pos ) { +void UINode::setInternalPosition( const Vector2i& Pos ) { mPos = Pos; mRealPos = Vector2i( Pos.x * PixelDensity::getPixelDensity(), Pos.y * PixelDensity::getPixelDensity() ); updateScreenPos(); updateChildsScreenPos(); } -UIControl * UIControl::setPosition( const Vector2i& Pos ) { +UINode * UINode::setPosition( const Vector2i& Pos ) { if ( Pos != mPos ) { setInternalPosition( Pos ); onPositionChange(); @@ -135,12 +149,12 @@ UIControl * UIControl::setPosition( const Vector2i& Pos ) { return this; } -UIControl * UIControl::setPosition( const Int32& x, const Int32& y ) { +UINode * UINode::setPosition( const Int32& x, const Int32& y ) { setPosition( Vector2i( x, y ) ); return this; } -void UIControl::setPixelsPosition( const Vector2i& Pos ) { +void UINode::setPixelsPosition( const Vector2i& Pos ) { if ( mRealPos != Pos ) { mPos = Vector2i( PixelDensity::pxToDpI( Pos.x ), PixelDensity::pxToDpI( Pos.y ) ); mRealPos = Pos; @@ -150,19 +164,19 @@ void UIControl::setPixelsPosition( const Vector2i& Pos ) { } } -void UIControl::setPixelsPosition( const Int32& x, const Int32& y ) { +void UINode::setPixelsPosition( const Int32& x, const Int32& y ) { setPixelsPosition( Vector2i( x, y ) ); } -const Vector2i& UIControl::getPosition() const { +const Vector2i& UINode::getPosition() const { return mPos; } -const Vector2i &UIControl::getRealPosition() const { +const Vector2i &UINode::getRealPosition() const { return mRealPos; } -void UIControl::setInternalSize( const Sizei& size ) { +void UINode::setInternalSize( const Sizei& size ) { mSize = size; mRealSize = Sizei( size.x * PixelDensity::getPixelDensity(), size.y * PixelDensity::getPixelDensity() ); updateCenter(); @@ -170,7 +184,7 @@ void UIControl::setInternalSize( const Sizei& size ) { invalidateDraw(); } -void UIControl::setInternalPixelsSize( const Sizei& size ) { +void UINode::setInternalPixelsSize( const Sizei& size ) { mSize = PixelDensity::pxToDpI( size ); mRealSize = size; updateCenter(); @@ -178,7 +192,7 @@ void UIControl::setInternalPixelsSize( const Sizei& size ) { invalidateDraw(); } -UIControl * UIControl::setSize( const Sizei& Size ) { +UINode * UINode::setSize( const Sizei& Size ) { if ( Size != mSize ) { Vector2i sizeChange( Size.x - mSize.x, Size.y - mSize.y ); @@ -194,12 +208,12 @@ UIControl * UIControl::setSize( const Sizei& Size ) { return this; } -UIControl * UIControl::setSize( const Int32& Width, const Int32& Height ) { +UINode * UINode::setSize( const Int32& Width, const Int32& Height ) { setSize( Sizei( Width, Height ) ); return this; } -void UIControl::setPixelsSize( const Sizei & size ) { +void UINode::setPixelsSize( const Sizei & size ) { if ( size != mRealSize ) { Vector2i sizeChange( size.x - mRealSize.x, size.y - mRealSize.y ); @@ -213,39 +227,39 @@ void UIControl::setPixelsSize( const Sizei & size ) { } } -void UIControl::setPixelsSize( const Int32& x, const Int32& y ) { +void UINode::setPixelsSize( const Int32& x, const Int32& y ) { setPixelsSize( Sizei( x, y ) ); } -void UIControl::setInternalWidth( const Int32& width ) { +void UINode::setInternalWidth( const Int32& width ) { setInternalSize( Sizei( width, mSize.getHeight() ) ); } -void UIControl::setInternalHeight( const Int32& height ) { +void UINode::setInternalHeight( const Int32& height ) { setInternalSize( Sizei( mSize.getWidth(), height ) ); } -void UIControl::setInternalPixelsWidth( const Int32& width ) { +void UINode::setInternalPixelsWidth( const Int32& width ) { setInternalPixelsSize( Sizei( width, mRealSize.y ) ); } -void UIControl::setInternalPixelsHeight( const Int32& height ) { +void UINode::setInternalPixelsHeight( const Int32& height ) { setInternalPixelsSize( Sizei( mRealSize.x, height ) ); } -Rect UIControl::getRect() const { +Rect UINode::getRect() const { return Rect( mPos, mSize ); } -const Sizei& UIControl::getSize() { +const Sizei& UINode::getSize() { return mSize; } -const Sizei& UIControl::getRealSize() { +const Sizei& UINode::getRealSize() { return mRealSize; } -UIControl * UIControl::setVisible( const bool& visible ) { +UINode * UINode::setVisible( const bool& visible ) { if ( mVisible != visible ) { mVisible = visible; onVisibilityChange(); @@ -253,15 +267,15 @@ UIControl * UIControl::setVisible( const bool& visible ) { return this; } -bool UIControl::isVisible() const { +bool UINode::isVisible() const { return mVisible; } -bool UIControl::isHided() const { +bool UINode::isHided() const { return !mVisible; } -UIControl * UIControl::setEnabled( const bool& enabled ) { +UINode * UINode::setEnabled( const bool& enabled ) { if ( mEnabled != enabled ) { mEnabled = enabled; onEnabledChange(); @@ -269,19 +283,19 @@ UIControl * UIControl::setEnabled( const bool& enabled ) { return this; } -bool UIControl::isEnabled() const { +bool UINode::isEnabled() const { return mEnabled; } -bool UIControl::isDisabled() const { +bool UINode::isDisabled() const { return !mEnabled; } -UIControl * UIControl::getParent() const { +UINode * UINode::getParent() const { return mParentCtrl; } -UIControl * UIControl::setParent( UIControl * parent ) { +UINode * UINode::setParent( UINode * parent ) { if ( parent == mParentCtrl ) return this; @@ -307,10 +321,10 @@ UIControl * UIControl::setParent( UIControl * parent ) { return this; } -bool UIControl::isParentOf( UIControl * Ctrl ) { +bool UINode::isParentOf( UINode * Ctrl ) { eeASSERT( NULL != Ctrl ); - UIControl * tParent = Ctrl->getParent(); + UINode * tParent = Ctrl->getParent(); while ( NULL != tParent ) { if ( this == tParent ) @@ -322,32 +336,32 @@ bool UIControl::isParentOf( UIControl * Ctrl ) { return false; } -void UIControl::centerHorizontal() { - UIControl * Ctrl = getParent(); +void UINode::centerHorizontal() { + UINode * Ctrl = getParent(); if ( NULL != Ctrl ) setPosition( ( Ctrl->getSize().getWidth() - mSize.getWidth() ) / 2, mPos.y ); } -void UIControl::centerVertical(){ - UIControl * Ctrl = getParent(); +void UINode::centerVertical(){ + UINode * Ctrl = getParent(); if ( NULL != Ctrl ) setPosition( mPos.x, ( Ctrl->getSize().getHeight() - mSize.getHeight() ) / 2 ); } -void UIControl::center() { +void UINode::center() { centerHorizontal(); centerVertical(); } -void UIControl::close() { +void UINode::close() { mControlFlags |= UI_CTRL_FLAG_CLOSE; UIManager::instance()->addToCloseQueue( this ); } -void UIControl::drawHighlightFocus() { +void UINode::drawHighlightFocus() { if ( UIManager::instance()->getHighlightFocus() && UIManager::instance()->getFocusControl() == this ) { Primitives P; P.setFillMode( DRAW_LINE ); @@ -358,7 +372,7 @@ void UIControl::drawHighlightFocus() { } } -void UIControl::drawOverControl() { +void UINode::drawOverControl() { if ( UIManager::instance()->getHighlightOver() && UIManager::instance()->getOverControl() == this ) { Primitives P; P.setFillMode( DRAW_LINE ); @@ -369,7 +383,7 @@ void UIControl::drawOverControl() { } } -void UIControl::drawDebugData() { +void UINode::drawDebugData() { if ( UIManager::instance()->getDrawDebugData() ) { if ( isWidget() ) { UIWidget * me = static_cast( this ); @@ -389,7 +403,7 @@ void UIControl::drawDebugData() { } } -void UIControl::drawBox() { +void UINode::drawBox() { if ( UIManager::instance()->getDrawBoxes() ) { Primitives P; P.setFillMode( DRAW_LINE ); @@ -400,39 +414,108 @@ void UIControl::drawBox() { } } -void UIControl::drawSkin() { +void UINode::drawSkin() { if ( NULL != mSkinState ) { if ( mFlags & UI_SKIN_KEEP_SIZE_ON_DRAW ) { Sizei rSize = PixelDensity::dpToPxI( mSkinState->getSkin()->getSize( mSkinState->getState() ) ); Sizei diff = ( mRealSize - rSize ) / 2; - mSkinState->draw( mScreenPosf.x + diff.x, mScreenPosf.y + diff.y, (Float)rSize.getWidth(), (Float)rSize.getHeight(), 255 ); + mSkinState->draw( mScreenPosf.x + diff.x, mScreenPosf.y + diff.y, (Float)rSize.getWidth(), (Float)rSize.getHeight(), (Uint32)mAlpha ); } else { - mSkinState->draw( mScreenPosf.x, mScreenPosf.y, (Float)mRealSize.getWidth(), (Float)mRealSize.getHeight(), 255 ); + mSkinState->draw( mScreenPosf.x, mScreenPosf.y, (Float)mRealSize.getWidth(), (Float)mRealSize.getHeight(), (Uint32)mAlpha ); } } } -void UIControl::draw() { - if ( mVisible ) { +void UINode::draw() { + if ( mVisible && 0.f != mAlpha ) { drawBackground(); drawBorder(); drawSkin(); - drawDebugData(); - - drawBox(); - drawHighlightFocus(); drawOverControl(); + + drawDebugData(); + + drawBox(); } } -void UIControl::update() { - UIControl * ChildLoop = mChild; +void UINode::update() { + if ( NULL != mMoveAnim && mMoveAnim->isEnabled() ) { + mMoveAnim->update( getElapsed() ); + setPosition( (int)mMoveAnim->getPosition().x, (int)mMoveAnim->getPosition().y ); + + if ( mMoveAnim->ended() ) + eeSAFE_DELETE( mMoveAnim ); + } + + if ( NULL != mAlphaAnim && mAlphaAnim->isEnabled() ) { + mAlphaAnim->update( getElapsed() ); + setAlpha( mAlphaAnim->getPosition() ); + + if ( mAlphaAnim->ended() ) { + if ( ( mControlFlags & UI_CTRL_FLAG_CLOSE_FO ) ) + close(); + + if ( ( mControlFlags & UI_CTRL_FLAG_DISABLE_FADE_OUT ) ) { + mControlFlags &= ~UI_CTRL_FLAG_DISABLE_FADE_OUT; + + setVisible( false ); + } + + eeSAFE_DELETE( mAlphaAnim ); + } + } + + if ( NULL != mScaleAnim && mScaleAnim->isEnabled() ) { + mScaleAnim->update( getElapsed() ); + setScale( mScaleAnim->getPosition() ); + + if ( mScaleAnim->ended() ) + eeSAFE_DELETE( mScaleAnim ); + } + + if ( NULL != mAngleAnim && mAngleAnim->isEnabled() ) { + mAngleAnim->update( getElapsed() ); + setRotation( mAngleAnim->getPosition() ); + + if ( mAngleAnim->ended() ) + eeSAFE_DELETE( mAngleAnim ); + } + + if ( isDragEnabled() && isDragging() ) { + if ( !( UIManager::instance()->getPressTrigger() & mDragButton ) ) { + setDragging( false ); + UIManager::instance()->setControlDragging( false ); + return; + } + + Vector2i Pos( UIManager::instance()->getMousePos() ); + + if ( mDragPoint != Pos && ( abs( mDragPoint.x - Pos.x ) > PixelDensity::getPixelDensity() || abs( mDragPoint.y - Pos.y ) > PixelDensity::getPixelDensity() ) ) { + if ( onDrag( Pos ) ) { + Sizei dragDiff; + + dragDiff.x = (Int32)( (Float)( mDragPoint.x - Pos.x ) / PixelDensity::getPixelDensity() ); + dragDiff.y = (Int32)( (Float)( mDragPoint.y - Pos.y ) / PixelDensity::getPixelDensity() ); + + setInternalPosition( mPos - dragDiff ); + + mDragPoint = Pos; + + onPositionChange(); + + UIManager::instance()->setControlDragging( true ); + } + } + } + + UINode * ChildLoop = mChild; while ( NULL != ChildLoop ) { ChildLoop->update(); @@ -443,32 +526,37 @@ void UIControl::update() { writeCtrlFlag( UI_CTRL_FLAG_MOUSEOVER_ME_OR_CHILD, 0 ); } -void UIControl::sendMouseEvent( const Uint32& Event, const Vector2i& Pos, const Uint32& Flags ) { +void UINode::sendMouseEvent( const Uint32& Event, const Vector2i& Pos, const Uint32& Flags ) { UIEventMouse MouseEvent( this, Event, Pos, Flags ); sendEvent( &MouseEvent ); } -void UIControl::sendCommonEvent( const Uint32& Event ) { +void UINode::sendCommonEvent( const Uint32& Event ) { UIEvent CommonEvent( this, Event ); sendEvent( &CommonEvent ); } -Uint32 UIControl::onKeyDown( const UIEventKey& Event ) { +Uint32 UINode::onKeyDown( const UIEventKey& Event ) { sendEvent( &Event ); return 0; } -Uint32 UIControl::onKeyUp( const UIEventKey& Event ) { +Uint32 UINode::onKeyUp( const UIEventKey& Event ) { sendEvent( &Event ); return 0; } -Uint32 UIControl::onMouseMove( const Vector2i& Pos, const Uint32 Flags ) { +Uint32 UINode::onMouseMove( const Vector2i& Pos, const Uint32 Flags ) { sendMouseEvent( UIEvent::MouseMove, Pos, Flags ); return 1; } -Uint32 UIControl::onMouseDown( const Vector2i& Pos, const Uint32 Flags ) { +Uint32 UINode::onMouseDown( const Vector2i& Pos, const Uint32 Flags ) { + if ( !( UIManager::instance()->getLastPressTrigger() & mDragButton ) && ( Flags & mDragButton ) && isDragEnabled() && !isDragging() ) { + setDragging( true ); + mDragPoint = Pos; + } + sendMouseEvent( UIEvent::MouseDown, Pos, Flags ); setSkinState( UISkinState::StateMouseDown ); @@ -476,7 +564,11 @@ Uint32 UIControl::onMouseDown( const Vector2i& Pos, const Uint32 Flags ) { return 1; } -Uint32 UIControl::onMouseUp( const Vector2i& Pos, const Uint32 Flags ) { +Uint32 UINode::onMouseUp( const Vector2i& Pos, const Uint32 Flags ) { + if ( isDragEnabled() && isDragging() && ( Flags & mDragButton ) ) { + setDragging( false ); + } + sendMouseEvent( UIEvent::MouseUp, Pos, Flags ); setPrevSkinState(); @@ -484,25 +576,25 @@ Uint32 UIControl::onMouseUp( const Vector2i& Pos, const Uint32 Flags ) { return 1; } -Uint32 UIControl::onMouseClick( const Vector2i& Pos, const Uint32 Flags ) { +Uint32 UINode::onMouseClick( const Vector2i& Pos, const Uint32 Flags ) { sendMouseEvent( UIEvent::MouseClick, Pos, Flags ); return 1; } -bool UIControl::isMouseOver() { +bool UINode::isMouseOver() { return 0 != ( mControlFlags & UI_CTRL_FLAG_MOUSEOVER ); } -bool UIControl::isMouseOverMeOrChilds() { +bool UINode::isMouseOverMeOrChilds() { return 0 != ( mControlFlags & UI_CTRL_FLAG_MOUSEOVER_ME_OR_CHILD ); } -Uint32 UIControl::onMouseDoubleClick( const Vector2i& Pos, const Uint32 Flags ) { +Uint32 UINode::onMouseDoubleClick( const Vector2i& Pos, const Uint32 Flags ) { sendMouseEvent( UIEvent::MouseDoubleClick, Pos, Flags ); return 1; } -Uint32 UIControl::onMouseEnter( const Vector2i& Pos, const Uint32 Flags ) { +Uint32 UINode::onMouseEnter( const Vector2i& Pos, const Uint32 Flags ) { writeCtrlFlag( UI_CTRL_FLAG_MOUSEOVER, 1 ); sendMouseEvent( UIEvent::MouseEnter, Pos, Flags ); @@ -512,7 +604,7 @@ Uint32 UIControl::onMouseEnter( const Vector2i& Pos, const Uint32 Flags ) { return 1; } -Uint32 UIControl::onMouseExit( const Vector2i& Pos, const Uint32 Flags ) { +Uint32 UINode::onMouseExit( const Vector2i& Pos, const Uint32 Flags ) { writeCtrlFlag( UI_CTRL_FLAG_MOUSEOVER, 0 ); sendMouseEvent( UIEvent::MouseExit, Pos, Flags ); @@ -522,7 +614,7 @@ Uint32 UIControl::onMouseExit( const Vector2i& Pos, const Uint32 Flags ) { return 1; } -Uint32 UIControl::onFocus() { +Uint32 UINode::onFocus() { mControlFlags |= UI_CTRL_FLAG_HAS_FOCUS; sendCommonEvent( UIEvent::OnFocus ); @@ -532,7 +624,7 @@ Uint32 UIControl::onFocus() { return 1; } -Uint32 UIControl::onFocusLoss() { +Uint32 UINode::onFocusLoss() { mControlFlags &= ~UI_CTRL_FLAG_HAS_FOCUS; sendCommonEvent( UIEvent::OnFocusLoss ); @@ -542,32 +634,32 @@ Uint32 UIControl::onFocusLoss() { return 1; } -void UIControl::onWidgetFocusLoss() { +void UINode::onWidgetFocusLoss() { sendCommonEvent( UIEvent::OnWidgetFocusLoss ); invalidateDraw(); } -bool UIControl::hasFocus() const { +bool UINode::hasFocus() const { return 0 != ( mControlFlags & UI_CTRL_FLAG_HAS_FOCUS ); } -Uint32 UIControl::onValueChange() { +Uint32 UINode::onValueChange() { sendCommonEvent( UIEvent::OnValueChange ); invalidateDraw(); return 1; } -void UIControl::onClose() { +void UINode::onClose() { sendCommonEvent( UIEvent::OnClose ); invalidateDraw(); } -Uint32 UIControl::getHorizontalAlign() const { +Uint32 UINode::getHorizontalAlign() const { return mFlags & UI_HALIGN_MASK; } -UIControl * UIControl::setHorizontalAlign( Uint32 halign ) { +UINode * UINode::setHorizontalAlign( Uint32 halign ) { mFlags &= ~UI_HALIGN_MASK; mFlags |= halign & UI_HALIGN_MASK; @@ -575,11 +667,11 @@ UIControl * UIControl::setHorizontalAlign( Uint32 halign ) { return this; } -Uint32 UIControl::getVerticalAlign() const { +Uint32 UINode::getVerticalAlign() const { return mFlags & UI_VALIGN_MASK; } -UIControl * UIControl::setVerticalAlign( Uint32 valign ) { +UINode * UINode::setVerticalAlign( Uint32 valign ) { mFlags &= ~UI_VALIGN_MASK; mFlags |= valign & UI_VALIGN_MASK; @@ -587,7 +679,7 @@ UIControl * UIControl::setVerticalAlign( Uint32 valign ) { return this; } -UIControl * UIControl::setGravity( Uint32 hvalign ) { +UINode * UINode::setGravity( Uint32 hvalign ) { mFlags &= ~( UI_VALIGN_MASK | UI_HALIGN_MASK ); mFlags |= ( hvalign & ( UI_VALIGN_MASK | UI_HALIGN_MASK ) ) ; @@ -595,7 +687,7 @@ UIControl * UIControl::setGravity( Uint32 hvalign ) { return this; } -UIBackground * UIControl::setBackgroundFillEnabled( bool enabled ) { +UIBackground * UINode::setBackgroundFillEnabled( bool enabled ) { writeFlag( UI_FILL_BACKGROUND, enabled ? 1 : 0 ); if ( enabled && NULL == mBackground ) { @@ -607,7 +699,7 @@ UIBackground * UIControl::setBackgroundFillEnabled( bool enabled ) { return mBackground; } -UIBorder * UIControl::setBorderEnabled( bool enabled ) { +UIBorder * UINode::setBorderEnabled( bool enabled ) { writeFlag( UI_BORDER, enabled ? 1 : 0 ); if ( enabled && NULL == mBorder ) { @@ -621,35 +713,35 @@ UIBorder * UIControl::setBorderEnabled( bool enabled ) { return mBorder; } -UIControl * UIControl::getNextControl() const { +UINode * UINode::getNextControl() const { return mNext; } -UIControl * UIControl::getPrevControl() const { +UINode * UINode::getPrevControl() const { return mPrev; } -UIControl * UIControl::getNextControlLoop() const { +UINode * UINode::getNextControlLoop() const { if ( NULL == mNext ) return getParent()->getFirstChild(); else return mNext; } -UIControl * UIControl::setData(const UintPtr& data ) { +UINode * UINode::setData(const UintPtr& data ) { mData = data; return this; } -const UintPtr& UIControl::getData() const { +const UintPtr& UINode::getData() const { return mData; } -const Uint32& UIControl::getFlags() const { +const Uint32& UINode::getFlags() const { return mFlags; } -UIControl * UIControl::setFlags( const Uint32& flags ) { +UINode * UINode::setFlags( const Uint32& flags ) { if ( NULL == mBackground && ( flags & UI_FILL_BACKGROUND ) ) mBackground = UIBackground::New( this ); @@ -665,7 +757,7 @@ UIControl * UIControl::setFlags( const Uint32& flags ) { return this; } -UIControl * UIControl::unsetFlags(const Uint32 & flags) { +UINode * UINode::unsetFlags(const Uint32 & flags) { if ( mFlags & flags ) mFlags &= ~flags; @@ -676,46 +768,46 @@ UIControl * UIControl::unsetFlags(const Uint32 & flags) { return this; } -UIControl *UIControl::resetFlags( Uint32 newFlags ) { +UINode *UINode::resetFlags( Uint32 newFlags ) { mFlags = newFlags; return this; } -UIControl * UIControl::setBlendMode( const BlendMode& blend ) { +UINode * UINode::setBlendMode( const BlendMode& blend ) { mBlend = blend; invalidateDraw(); return this; } -BlendMode UIControl::getBlendMode() { +BlendMode UINode::getBlendMode() { return mBlend; } -void UIControl::toFront() { +void UINode::toFront() { if ( NULL != mParentCtrl && mParentCtrl->mChildLast != this ) { mParentCtrl->childRemove( this ); mParentCtrl->childAdd( this ); } } -void UIControl::toBack() { +void UINode::toBack() { if ( NULL != mParentCtrl ) { mParentCtrl->childAddAt( this, 0 ); } } -void UIControl::toPosition( const Uint32& Pos ) { +void UINode::toPosition( const Uint32& Pos ) { if ( NULL != mParentCtrl ) { mParentCtrl->childAddAt( this, Pos ); } } -void UIControl::onVisibilityChange() { +void UINode::onVisibilityChange() { sendCommonEvent( UIEvent::OnVisibleChange ); invalidateDraw(); } -void UIControl::onEnabledChange() { +void UINode::onEnabledChange() { if ( !isEnabled() && NULL != UIManager::instance()->getFocusControl() ) { if ( isChild( UIManager::instance()->getFocusControl() ) ) { UIManager::instance()->setFocusControl( NULL ); @@ -726,42 +818,44 @@ void UIControl::onEnabledChange() { invalidateDraw(); } -void UIControl::onPositionChange() { +void UINode::onPositionChange() { sendCommonEvent( UIEvent::OnPosChange ); invalidateDraw(); } -void UIControl::onSizeChange() { +void UINode::onSizeChange() { + updateOriginPoint(); + invalidateDraw(); } -Rectf UIControl::getRectf() { +Rectf UINode::getRectf() { return Rectf( mScreenPosf, Sizef( (Float)mRealSize.getWidth(), (Float)mRealSize.getHeight() ) ); } -void UIControl::drawBackground() { +void UINode::drawBackground() { if ( mFlags & UI_FILL_BACKGROUND ) { - mBackground->draw( getRectf(), 255.f ); + mBackground->draw( getRectf(), mAlpha ); } } -void UIControl::drawBorder() { +void UINode::drawBorder() { if ( mFlags & UI_BORDER ) { - mBorder->draw( getRectf(), 255.f, mBackground->getCorners(), ( mFlags & UI_CLIP_ENABLE ) != 0 ); + mBorder->draw( getRectf(), mAlpha, mBackground->getCorners(), ( mFlags & UI_CLIP_ENABLE ) != 0 ); } } -const Uint32& UIControl::getControlFlags() const { +const Uint32& UINode::getControlFlags() const { return mControlFlags; } -void UIControl::setControlFlags( const Uint32& Flags ) { +void UINode::setControlFlags( const Uint32& Flags ) { mControlFlags = Flags; } -void UIControl::drawChilds() { +void UINode::drawChilds() { if ( isReverseDraw() ) { - UIControl * ChildLoop = mChildLast; + UINode * ChildLoop = mChildLast; while ( NULL != ChildLoop ) { if ( ChildLoop->mVisible ) { @@ -771,7 +865,7 @@ void UIControl::drawChilds() { ChildLoop = ChildLoop->mPrev; } } else { - UIControl * ChildLoop = mChild; + UINode * ChildLoop = mChild; while ( NULL != ChildLoop ) { if ( ChildLoop->mVisible ) { @@ -783,7 +877,7 @@ void UIControl::drawChilds() { } } -void UIControl::internalDraw() { +void UINode::internalDraw() { if ( mVisible ) { matrixSet(); @@ -799,7 +893,7 @@ void UIControl::internalDraw() { } } -void UIControl::clipMe() { +void UINode::clipMe() { if ( mVisible && ( mFlags & UI_CLIP_ENABLE ) ) { if ( mFlags & UI_BORDER ) UIManager::instance()->clipSmartEnable( this, mScreenPos.x, mScreenPos.y, mRealSize.getWidth(), mRealSize.getHeight() + 1 ); @@ -808,25 +902,45 @@ void UIControl::clipMe() { } } -void UIControl::clipDisable() { +void UINode::clipDisable() { if ( mVisible && ( mFlags & UI_CLIP_ENABLE ) ) { UIManager::instance()->clipSmartDisable( this ); } } -void UIControl::matrixSet() { +void UINode::matrixSet() { + if ( mScale != 1.f || mAngle != 0.f ) { + GlobalBatchRenderer::instance()->draw(); + + GLi->pushMatrix(); + + Vector2f scaleCenter = getScaleCenter(); + GLi->translatef( scaleCenter.x , scaleCenter.y, 0.f ); + GLi->scalef( mScale.x, mScale.y, 1.0f ); + GLi->translatef( -scaleCenter.x, -scaleCenter.y, 0.f ); + + Vector2f rotationCenter = getRotationCenter(); + GLi->translatef( rotationCenter.x , rotationCenter.y, 0.f ); + GLi->rotatef( mAngle, 0.0f, 0.0f, 1.0f ); + GLi->translatef( -rotationCenter.x, -rotationCenter.y, 0.f ); + } } -void UIControl::matrixUnset() { +void UINode::matrixUnset() { + if ( mScale != 1.f || mAngle != 0.f ) { + GlobalBatchRenderer::instance()->draw(); + + GLi->popMatrix(); + } } -void UIControl::childDeleteAll() { +void UINode::childDeleteAll() { while( NULL != mChild ) { eeDelete( mChild ); } } -void UIControl::childAdd( UIControl * ChildCtrl ) { +void UINode::childAdd( UINode * ChildCtrl ) { if ( NULL == mChild ) { mChild = ChildCtrl; mChildLast = ChildCtrl; @@ -840,10 +954,10 @@ void UIControl::childAdd( UIControl * ChildCtrl ) { onChildCountChange(); } -void UIControl::childAddAt( UIControl * ChildCtrl, Uint32 Pos ) { +void UINode::childAddAt( UINode * ChildCtrl, Uint32 Pos ) { eeASSERT( NULL != ChildCtrl ); - UIControl * ChildLoop = mChild; + UINode * ChildLoop = mChild; ChildCtrl->setParent( this ); @@ -874,7 +988,7 @@ void UIControl::childAddAt( UIControl * ChildCtrl, Uint32 Pos ) { i++; } - UIControl * ChildTmp = ChildLoop->mNext; + UINode * ChildTmp = ChildLoop->mNext; ChildLoop->mNext = ChildCtrl; ChildCtrl->mPrev = ChildLoop; ChildCtrl->mNext = ChildTmp; @@ -890,7 +1004,7 @@ void UIControl::childAddAt( UIControl * ChildCtrl, Uint32 Pos ) { onChildCountChange(); } -void UIControl::childRemove( UIControl * ChildCtrl ) { +void UINode::childRemove( UINode * ChildCtrl ) { if ( ChildCtrl == mChild ) { mChild = mChild->mNext; @@ -919,8 +1033,8 @@ void UIControl::childRemove( UIControl * ChildCtrl ) { onChildCountChange(); } -void UIControl::childsCloseAll() { - UIControl * ChildLoop = mChild; +void UINode::childsCloseAll() { + UINode * ChildLoop = mChild; while ( NULL != ChildLoop ) { ChildLoop->close(); @@ -928,28 +1042,28 @@ void UIControl::childsCloseAll() { } } -std::string UIControl::getId() const { +std::string UINode::getId() const { return mId; } -UIControl * UIControl::setId(const std::string & id) { +UINode * UINode::setId(const std::string & id) { mId = id; mIdHash = String::hash( id ); return this; } -Uint32 UIControl::getIdHash() const { +Uint32 UINode::getIdHash() const { return mIdHash; } -UIControl * UIControl::findIdHash( const Uint32& idHash ) { +UINode * UINode::findIdHash( const Uint32& idHash ) { if ( mIdHash == idHash ) { return this; } else { - UIControl * child = mChild; + UINode * child = mChild; while ( NULL != child ) { - UIControl * foundCtrl = child->findIdHash( idHash ); + UINode * foundCtrl = child->findIdHash( idHash ); if ( NULL != foundCtrl ) return foundCtrl; @@ -961,12 +1075,12 @@ UIControl * UIControl::findIdHash( const Uint32& idHash ) { return NULL; } -UIControl * UIControl::find( const std::string& id ) { +UINode * UINode::find( const std::string& id ) { return findIdHash( String::hash( id ) ); } -bool UIControl::isChild( UIControl * ChildCtrl ) const { - UIControl * ChildLoop = mChild; +bool UINode::isChild( UINode * ChildCtrl ) const { + UINode * ChildLoop = mChild; while ( NULL != ChildLoop ) { if ( ChildCtrl == ChildLoop ) @@ -978,8 +1092,8 @@ bool UIControl::isChild( UIControl * ChildCtrl ) const { return false; } -bool UIControl::inParentTreeOf( UIControl * Child ) const { - UIControl * ParentLoop = Child->mParentCtrl; +bool UINode::inParentTreeOf( UINode * Child ) const { + UINode * ParentLoop = Child->mParentCtrl; while ( NULL != ParentLoop ) { if ( ParentLoop == this ) @@ -991,8 +1105,8 @@ bool UIControl::inParentTreeOf( UIControl * Child ) const { return false; } -Uint32 UIControl::childCount() const { - UIControl * ChildLoop = mChild; +Uint32 UINode::childCount() const { + UINode * ChildLoop = mChild; Uint32 Count = 0; while( NULL != ChildLoop ) { @@ -1003,8 +1117,8 @@ Uint32 UIControl::childCount() const { return Count; } -UIControl * UIControl::childAt( Uint32 Index ) const { - UIControl * ChildLoop = mChild; +UINode * UINode::childAt( Uint32 Index ) const { + UINode * ChildLoop = mChild; while( NULL != ChildLoop && Index ) { ChildLoop = ChildLoop->mNext; @@ -1014,30 +1128,30 @@ UIControl * UIControl::childAt( Uint32 Index ) const { return ChildLoop; } -UIControl * UIControl::childPrev( UIControl * Ctrl, bool Loop ) const { +UINode * UINode::childPrev( UINode * Ctrl, bool Loop ) const { if ( Loop && Ctrl == mChild && NULL != mChild->mNext ) return mChildLast; return Ctrl->mPrev; } -UIControl * UIControl::childNext( UIControl * Ctrl, bool Loop ) const { +UINode * UINode::childNext( UINode * Ctrl, bool Loop ) const { if ( NULL == Ctrl->mNext && Loop ) return mChild; return Ctrl->mNext; } -UIControl * UIControl::getFirstChild() const { +UINode * UINode::getFirstChild() const { return mChild; } -UIControl * UIControl::getLastChild() const { +UINode * UINode::getLastChild() const { return mChildLast; } -UIControl * UIControl::overFind( const Vector2f& Point ) { - UIControl * pOver = NULL; +UINode * UINode::overFind( const Vector2f& Point ) { + UINode * pOver = NULL; if ( mEnabled && mVisible ) { updateQuad(); @@ -1045,10 +1159,10 @@ UIControl * UIControl::overFind( const Vector2f& Point ) { if ( mPoly.pointInside( Point ) ) { writeCtrlFlag( UI_CTRL_FLAG_MOUSEOVER_ME_OR_CHILD, 1 ); - UIControl * ChildLoop = mChildLast; + UINode * ChildLoop = mChildLast; while ( NULL != ChildLoop ) { - UIControl * ChildOver = ChildLoop->overFind( Point ); + UINode * ChildOver = ChildLoop->overFind( Point ); if ( NULL != ChildOver ) { pOver = ChildOver; @@ -1068,10 +1182,10 @@ UIControl * UIControl::overFind( const Vector2f& Point ) { return pOver; } -void UIControl::onParentWindowControlChange() { +void UINode::onParentWindowControlChange() { mParentWindowCtrl = getParentWindow(); - UIControl * ChildLoop = mChild; + UINode * ChildLoop = mChild; while ( NULL != ChildLoop ) { ChildLoop->onParentWindowControlChange(); @@ -1079,10 +1193,10 @@ void UIControl::onParentWindowControlChange() { } } -UIControl * UIControl::childGetAt( Vector2i CtrlPos, unsigned int RecursiveLevel ) { - UIControl * Ctrl = NULL; +UINode * UINode::childGetAt( Vector2i CtrlPos, unsigned int RecursiveLevel ) { + UINode * Ctrl = NULL; - for( UIControl * pLoop = mChild; NULL != pLoop && NULL == Ctrl; pLoop = pLoop->mNext ) + for( UINode * pLoop = mChild; NULL != pLoop && NULL == Ctrl; pLoop = pLoop->mNext ) { if ( !pLoop->isVisible() ) continue; @@ -1099,40 +1213,32 @@ UIControl * UIControl::childGetAt( Vector2i CtrlPos, unsigned int RecursiveLevel return Ctrl; } -Uint32 UIControl::isAnimated() { - return mControlFlags & UI_CTRL_FLAG_ANIM; -} - -Uint32 UIControl::isDragable() { - return mControlFlags & UI_CTRL_FLAG_DRAGABLE; -} - -Uint32 UIControl::isWidget() { +Uint32 UINode::isWidget() { return mControlFlags & UI_CTRL_FLAG_WIDGET; } -Uint32 UIControl::isWindow() { +Uint32 UINode::isWindow() { return mControlFlags & UI_CTRL_FLAG_WINDOW; } -Uint32 UIControl::isClipped() { +Uint32 UINode::isClipped() { return mFlags & UI_CLIP_ENABLE; } -Uint32 UIControl::isRotated() { +Uint32 UINode::isRotated() { return mControlFlags & UI_CTRL_FLAG_ROTATED; } -Uint32 UIControl::isScaled() { +Uint32 UINode::isScaled() { return mControlFlags & UI_CTRL_FLAG_SCALED; } -Uint32 UIControl::isFrameBuffer() { +Uint32 UINode::isFrameBuffer() { return mControlFlags & UI_CTRL_FLAG_FRAME_BUFFER; } -bool UIControl::isMeOrParentTreeRotated() { - UIControl * Ctrl = this; +bool UINode::isMeOrParentTreeRotated() { + UINode * Ctrl = this; while( NULL != Ctrl ) { if ( Ctrl->isRotated() ) @@ -1144,8 +1250,8 @@ bool UIControl::isMeOrParentTreeRotated() { return false; } -bool UIControl::isMeOrParentTreeScaled() { - UIControl * Ctrl = this; +bool UINode::isMeOrParentTreeScaled() { + UINode * Ctrl = this; while( NULL != Ctrl ) { if ( Ctrl->isScaled() ) @@ -1157,8 +1263,8 @@ bool UIControl::isMeOrParentTreeScaled() { return false; } -bool UIControl::isMeOrParentTreeScaledOrRotated() { - UIControl * Ctrl = this; +bool UINode::isMeOrParentTreeScaledOrRotated() { + UINode * Ctrl = this; while( NULL != Ctrl ) { if ( Ctrl->isScaled() || Ctrl->isRotated() ) @@ -1170,8 +1276,8 @@ bool UIControl::isMeOrParentTreeScaledOrRotated() { return false; } -bool UIControl::isMeOrParentTreeScaledOrRotatedOrFrameBuffer() { - UIControl * Ctrl = this; +bool UINode::isMeOrParentTreeScaledOrRotatedOrFrameBuffer() { + UINode * Ctrl = this; while( NULL != Ctrl ) { if ( Ctrl->isScaled() || Ctrl->isRotated() || Ctrl->isFrameBuffer() ) @@ -1183,40 +1289,41 @@ bool UIControl::isMeOrParentTreeScaledOrRotatedOrFrameBuffer() { return false; } -Polygon2f& UIControl::getPolygon() { +Polygon2f& UINode::getPolygon() { return mPoly; } -const Vector2f& UIControl::getPolygonCenter() const { +const Vector2f& UINode::getPolygonCenter() const { return mCenter; } -void UIControl::updateQuad() { - mPoly = Polygon2f( Rectf( mScreenPosf.x, mScreenPosf.y, mScreenPosf.x + mRealSize.getWidth(), mScreenPosf.y + mRealSize.getHeight() ) ); +void UINode::updateQuad() { + mPoly = Polygon2f( Rectf( mScreenPosf.x, mScreenPosf.y, mScreenPosf.x + mRealSize.getWidth(), mScreenPosf.y + mRealSize.getHeight() ) ); - UIControl * tParent = getParent(); + mPoly.rotate( mAngle, getRotationCenter() ); + mPoly.scale( mScale, getScaleCenter() ); + + UINode * tParent = getParent(); while ( tParent ) { - if ( tParent->isAnimated() ) { - UIControlAnim * tP = reinterpret_cast ( tParent ); + UINode * tP = reinterpret_cast ( tParent ); - mPoly.rotate( tP->getRotation(), tP->getRotationCenter() ); - mPoly.scale( tP->getScale(), tP->getScaleCenter() ); - } + mPoly.rotate( tP->getRotation(), tP->getRotationCenter() ); + mPoly.scale( tP->getScale(), tP->getScaleCenter() ); tParent = tParent->getParent(); }; } -void UIControl::updateCenter() { +void UINode::updateCenter() { mCenter = Vector2f( mScreenPosf.x + (Float)mRealSize.getWidth() * 0.5f, mScreenPosf.y + (Float)mRealSize.getHeight() * 0.5f ); } -Time UIControl::getElapsed() { +Time UINode::getElapsed() { return UIManager::instance()->getElapsed(); } -Uint32 UIControl::addEventListener( const Uint32& EventType, const UIEventCallback& Callback ) { +Uint32 UINode::addEventListener( const Uint32& EventType, const UIEventCallback& Callback ) { mNumCallBacks++; mEvents[ EventType ][ mNumCallBacks ] = Callback; @@ -1224,7 +1331,7 @@ Uint32 UIControl::addEventListener( const Uint32& EventType, const UIEventCallba return mNumCallBacks; } -void UIControl::removeEventListener( const Uint32& CallbackId ) { +void UINode::removeEventListener( const Uint32& CallbackId ) { UIEventsMap::iterator it; for ( it = mEvents.begin(); it != mEvents.end(); ++it ) { @@ -1235,7 +1342,7 @@ void UIControl::removeEventListener( const Uint32& CallbackId ) { } } -void UIControl::sendEvent( const UIEvent * Event ) { +void UINode::sendEvent( const UIEvent * Event ) { if ( 0 != mEvents.count( Event->getEventType() ) ) { std::map event = mEvents[ Event->getEventType() ]; std::map::iterator it; @@ -1247,7 +1354,7 @@ void UIControl::sendEvent( const UIEvent * Event ) { } } -UIBackground * UIControl::getBackground() { +UIBackground * UINode::getBackground() { if ( NULL == mBackground ) { mBackground = UIBackground::New( this ); } @@ -1255,7 +1362,7 @@ UIBackground * UIControl::getBackground() { return mBackground; } -UIBorder * UIControl::getBorder() { +UIBorder * UINode::getBorder() { if ( NULL == mBorder ) { mBorder = UIBorder::New( this ); } @@ -1263,19 +1370,19 @@ UIBorder * UIControl::getBorder() { return mBorder; } -void UIControl::setThemeByName( const std::string& Theme ) { +void UINode::setThemeByName( const std::string& Theme ) { setTheme( UIThemeManager::instance()->getByName( Theme ) ); } -void UIControl::setTheme( UITheme * Theme ) { +void UINode::setTheme( UITheme * Theme ) { setThemeSkin( Theme, "control" ); } -UIControl * UIControl::setThemeSkin( const std::string& skinName ) { +UINode * UINode::setThemeSkin( const std::string& skinName ) { return setThemeSkin( UIThemeManager::instance()->getDefaultTheme(), skinName ); } -UIControl * UIControl::setThemeSkin( UITheme * Theme, const std::string& skinName ) { +UINode * UINode::setThemeSkin( UITheme * Theme, const std::string& skinName ) { if ( NULL != Theme ) { UISkin * tSkin = Theme->getSkin( skinName ); @@ -1298,7 +1405,7 @@ UIControl * UIControl::setThemeSkin( UITheme * Theme, const std::string& skinNam return this; } -UIControl * UIControl::setSkin( const UISkin& Skin ) { +UINode * UINode::setSkin( const UISkin& Skin ) { removeSkin(); writeCtrlFlag( UI_CTRL_FLAG_SKIN_OWNER, 1 ); @@ -1312,7 +1419,7 @@ UIControl * UIControl::setSkin( const UISkin& Skin ) { return this; } -UIControl * UIControl::setSkin( UISkin * skin ) { +UINode * UINode::setSkin( UISkin * skin ) { if ( NULL != skin ) { if ( NULL != mSkinState && mSkinState->getSkin() == skin ) return this; @@ -1334,7 +1441,7 @@ UIControl * UIControl::setSkin( UISkin * skin ) { return this; } -void UIControl::removeSkin() { +void UINode::removeSkin() { if ( NULL != mSkinState && ( mControlFlags & UI_CTRL_FLAG_SKIN_OWNER ) ) { UISkin * tSkin = mSkinState->getSkin(); @@ -1344,19 +1451,19 @@ void UIControl::removeSkin() { eeSAFE_DELETE( mSkinState ); } -void UIControl::onStateChange() { +void UINode::onStateChange() { invalidateDraw(); } -void UIControl::onParentChange() { +void UINode::onParentChange() { invalidateDraw(); } -void UIControl::onAlignChange() { +void UINode::onAlignChange() { invalidateDraw(); } -void UIControl::setSkinState( const Uint32& State ) { +void UINode::setSkinState( const Uint32& State ) { if ( NULL != mSkinState ) { mSkinState->setState( State ); @@ -1364,7 +1471,7 @@ void UIControl::setSkinState( const Uint32& State ) { } } -void UIControl::setPrevSkinState() { +void UINode::setPrevSkinState() { if ( NULL != mSkinState ) { mSkinState->setPrevState(); @@ -1372,8 +1479,8 @@ void UIControl::setPrevSkinState() { } } -void UIControl::setThemeToChilds( UITheme * Theme ) { - UIControl * ChildLoop = mChild; +void UINode::setThemeToChilds( UITheme * Theme ) { + UINode * ChildLoop = mChild; while ( NULL != ChildLoop ) { ChildLoop->setThemeToChilds( Theme ); @@ -1383,8 +1490,8 @@ void UIControl::setThemeToChilds( UITheme * Theme ) { } } -void UIControl::updateChildsScreenPos() { - UIControl * ChildLoop = mChild; +void UINode::updateChildsScreenPos() { + UINode * ChildLoop = mChild; while ( NULL != ChildLoop ) { ChildLoop->updateScreenPos(); @@ -1394,7 +1501,7 @@ void UIControl::updateChildsScreenPos() { } } -void UIControl::updateScreenPos() { +void UINode::updateScreenPos() { Vector2i Pos( mRealPos ); controlToScreen( Pos ); @@ -1405,18 +1512,18 @@ void UIControl::updateScreenPos() { updateCenter(); } -UISkin * UIControl::getSkin() { +UISkin * UINode::getSkin() { if ( NULL != mSkinState ) return mSkinState->getSkin(); return NULL; } -void UIControl::writeCtrlFlag( const Uint32& Flag, const Uint32& Val ) { +void UINode::writeCtrlFlag( const Uint32& Flag, const Uint32& Val ) { BitOp::setBitFlagValue( &mControlFlags, Flag, Val ); } -void UIControl::writeFlag( const Uint32& Flag, const Uint32& Val ) { +void UINode::writeFlag( const Uint32& Flag, const Uint32& Val ) { if ( Val ) mFlags |= Flag; else { @@ -1425,15 +1532,15 @@ void UIControl::writeFlag( const Uint32& Flag, const Uint32& Val ) { } } -void UIControl::applyDefaultTheme() { +void UINode::applyDefaultTheme() { UIThemeManager::instance()->applyDefaultTheme( this ); } -Rect UIControl::getScreenRect() { +Rect UINode::getScreenRect() { return Rect( mScreenPos, mRealSize ); } -Rect UIControl::makePadding( bool PadLeft, bool PadRight, bool PadTop, bool PadBottom, bool SkipFlags ) { +Rect UINode::makePadding( bool PadLeft, bool PadRight, bool PadTop, bool PadBottom, bool SkipFlags ) { Rect tPadding( 0, 0, 0, 0 ); if ( mFlags & UI_AUTO_PADDING || SkipFlags ) { @@ -1461,13 +1568,13 @@ Rect UIControl::makePadding( bool PadLeft, bool PadRight, bool PadTop, bool PadB return tPadding; } -void UIControl::setFocus() { +void UINode::setFocus() { UIManager::instance()->setFocusControl( this ); } -void UIControl::sendParentSizeChange( const Vector2i& SizeChange ) { +void UINode::sendParentSizeChange( const Vector2i& SizeChange ) { if ( mFlags & UI_REPORT_SIZE_CHANGE_TO_CHILDS ) { - UIControl * ChildLoop = mChild; + UINode * ChildLoop = mChild; while( NULL != ChildLoop ) { ChildLoop->onParentSizeChange( SizeChange ); @@ -1476,12 +1583,12 @@ void UIControl::sendParentSizeChange( const Vector2i& SizeChange ) { } } -void UIControl::onParentSizeChange( const Vector2i& SizeChange ) { +void UINode::onParentSizeChange( const Vector2i& SizeChange ) { sendCommonEvent( UIEvent::OnParentSizeChange ); invalidateDraw(); } -Sizei UIControl::getSkinSize( UISkin * Skin, const Uint32& State ) { +Sizei UINode::getSkinSize( UISkin * Skin, const Uint32& State ) { if ( NULL != Skin ) { return Skin->getSize( State ); } @@ -1489,7 +1596,7 @@ Sizei UIControl::getSkinSize( UISkin * Skin, const Uint32& State ) { return Sizei::Zero; } -Sizei UIControl::getSkinSize() { +Sizei UINode::getSkinSize() { if ( NULL != getSkin() ) { return getSkin()->getSize(); } @@ -1497,9 +1604,9 @@ Sizei UIControl::getSkinSize() { return Sizei::Zero; } -UIControl * UIControl::getNextWidget() { - UIControl * Found = NULL; - UIControl * ChildLoop = mChild; +UINode * UINode::getNextWidget() { + UINode * Found = NULL; + UINode * ChildLoop = mChild; while( NULL != ChildLoop ) { if ( ChildLoop->isVisible() && ChildLoop->isEnabled() ) { @@ -1542,33 +1649,33 @@ UIControl * UIControl::getNextWidget() { return UIManager::instance()->getMainControl(); } -void UIControl::onThemeLoaded() { +void UINode::onThemeLoaded() { invalidateDraw(); } -void UIControl::onChildCountChange() { +void UINode::onChildCountChange() { invalidateDraw(); } -void UIControl::worldToControl( Vector2i& pos ) const { +void UINode::worldToControl( Vector2i& pos ) const { Vector2f Pos( pos.x, pos.y ); - std::list parents; + std::list parents; - UIControl * ParentLoop = mParentCtrl; + UINode * ParentLoop = mParentCtrl; while ( NULL != ParentLoop ) { parents.push_front( ParentLoop ); ParentLoop = ParentLoop->getParent(); } - parents.push_back( const_cast( reinterpret_cast( this ) ) ); + parents.push_back( const_cast( reinterpret_cast( this ) ) ); Vector2f scale(1,1); - for ( std::list::iterator it = parents.begin(); it != parents.end(); it++ ) { - UIControl * tParent = (*it); - UIControlAnim * tP = tParent->isAnimated() ? reinterpret_cast ( tParent ) : NULL; + for ( std::list::iterator it = parents.begin(); it != parents.end(); it++ ) { + UINode * tParent = (*it); + UINode * tP = reinterpret_cast ( tParent ); Vector2f pPos ( tParent->mRealPos.x * scale.x , tParent->mRealPos.y * scale.y ); Vector2f Center; @@ -1591,41 +1698,38 @@ void UIControl::worldToControl( Vector2i& pos ) const { pos = Vector2i( Pos.x / PixelDensity::getPixelDensity(), Pos.y / PixelDensity::getPixelDensity() ); } -void UIControl::controlToWorld( Vector2i& pos ) const { +void UINode::controlToWorld( Vector2i& pos ) const { Vector2f Pos( (Float)pos.x * PixelDensity::getPixelDensity(), (Float)pos.y * PixelDensity::getPixelDensity() ); - std::list parents; + std::list parents; - UIControl * ParentLoop = mParentCtrl; + UINode * ParentLoop = mParentCtrl; while ( NULL != ParentLoop ) { parents.push_back( ParentLoop ); ParentLoop = ParentLoop->getParent(); } - parents.push_front( const_cast( reinterpret_cast( this ) ) ); + parents.push_front( const_cast( reinterpret_cast( this ) ) ); - for ( std::list::iterator it = parents.begin(); it != parents.end(); it++ ) { - UIControl * tParent = (*it); - UIControlAnim * tP = tParent->isAnimated() ? reinterpret_cast ( tParent ) : NULL; + for ( std::list::iterator it = parents.begin(); it != parents.end(); it++ ) { + UINode * tParent = (*it); Vector2f pPos ( tParent->mRealPos.x , tParent->mRealPos.y ); Pos += pPos; - if ( NULL != tP ) { - Vector2f CenterAngle( pPos.x + tP->mRotationOriginPoint.x, pPos.y + tP->mRotationOriginPoint.y ); - Vector2f CenterScale( pPos.x + tP->mScaleOriginPoint.x, pPos.y + tP->mScaleOriginPoint.y ); + Vector2f CenterAngle( pPos.x + tParent->mRotationOriginPoint.x, pPos.y + tParent->mRotationOriginPoint.y ); + Vector2f CenterScale( pPos.x + tParent->mScaleOriginPoint.x, pPos.y + tParent->mScaleOriginPoint.y ); - Pos.rotate( tP->getRotation(), CenterAngle ); - Pos.scale( tP->getScale(), CenterScale ); - } + Pos.rotate( tParent->getRotation(), CenterAngle ); + Pos.scale( tParent->getScale(), CenterScale ); } pos = Vector2i( eeceil( Pos.x ), eeceil( Pos.y ) ); } -UIControl * UIControl::getWindowContainer() { - UIControl * Ctrl = this; +UINode * UINode::getWindowContainer() { + UINode * Ctrl = this; while ( Ctrl != NULL ) { if ( Ctrl->isType( UI_TYPE_WINDOW ) ) { @@ -1642,8 +1746,8 @@ UIControl * UIControl::getWindowContainer() { return NULL; } -UIWindow * UIControl::getParentWindow() { - UIControl * Ctrl = mParentCtrl; +UIWindow * UINode::getParentWindow() { + UINode * Ctrl = mParentCtrl; while ( Ctrl != NULL ) { if ( Ctrl->isType( UI_TYPE_WINDOW ) ) @@ -1655,16 +1759,16 @@ UIWindow * UIControl::getParentWindow() { return NULL; } -bool UIControl::isReverseDraw() const { +bool UINode::isReverseDraw() const { return 0 != ( mControlFlags & UI_CTRL_FLAG_REVERSE_DRAW ); } -void UIControl::setReverseDraw( bool reverseDraw ) { +void UINode::setReverseDraw( bool reverseDraw ) { writeCtrlFlag( UI_CTRL_FLAG_REVERSE_DRAW, reverseDraw ? 1 : 0 ); invalidateDraw(); } -void UIControl::invalidateDraw() { +void UINode::invalidateDraw() { if ( NULL != mParentWindowCtrl ) { mParentWindowCtrl->invalidate(); } else if ( NULL == mParentCtrl && isWindow() ) { @@ -1672,16 +1776,357 @@ void UIControl::invalidateDraw() { } } -void UIControl::setClipEnabled() { +void UINode::setClipEnabled() { writeFlag( UI_CLIP_ENABLE, 1 ); } -void UIControl::setClipDisabled() { +void UINode::setClipDisabled() { writeFlag( UI_CLIP_ENABLE, 0 ); } -UIWindow * UIControl::getOwnerWindow() { +UIWindow * UINode::getOwnerWindow() { return mParentWindowCtrl; } +const Vector2i& UINode::getDragPoint() const { + return mDragPoint; +} + +void UINode::setDragPoint( const Vector2i& Point ) { + mDragPoint = Point; +} + +Uint32 UINode::onDrag( const Vector2i& Pos ) { + return 1; +} + +Uint32 UINode::onDragStart( const Vector2i& Pos ) { + sendCommonEvent( UIEvent::OnDragStart ); + return 1; +} + +Uint32 UINode::onDragStop( const Vector2i& Pos ) { + sendCommonEvent( UIEvent::OnDragStop ); + return 1; +} + +bool UINode::isDragEnabled() const { + return 0 != ( mFlags & UI_DRAG_ENABLE ); +} + +void UINode::setDragEnabled( const bool& enable ) { + writeFlag( UI_DRAG_ENABLE, true == enable ); +} + +bool UINode::isDragging() const { + return 0 != ( mControlFlags & UI_CTRL_FLAG_DRAGGING ); +} + +void UINode::setDragging( const bool& dragging ) { + writeCtrlFlag( UI_CTRL_FLAG_DRAGGING, dragging ); + + if ( dragging ) { + UIMessage tMsg( this, UIMessage::DragStart, 0 ); + messagePost( &tMsg ); + + onDragStart( UIManager::instance()->getMousePos() ); + } else { + UIMessage tMsg( this, UIMessage::DragStop, 0 ); + messagePost( &tMsg ); + + onDragStop( UIManager::instance()->getMousePos() ); + } +} + +void UINode::setDragButton( const Uint32& Button ) { + mDragButton = Button; +} + +const Uint32& UINode::getDragButton() const { + return mDragButton; +} + +void UINode::updateOriginPoint() { + switch ( mRotationOriginPoint.OriginType ) { + case OriginPoint::OriginCenter: + mRotationOriginPoint.x = mRealSize.x * 0.5f; + mRotationOriginPoint.y = mRealSize.y * 0.5f; + break; + case OriginPoint::OriginTopLeft: + mRotationOriginPoint.x = mRotationOriginPoint.y = 0; + break; + default: {} + } + + switch ( mScaleOriginPoint.OriginType ) { + case OriginPoint::OriginCenter: + mScaleOriginPoint.x = mRealSize.x * 0.5f; + mScaleOriginPoint.y = mRealSize.y * 0.5f; + break; + case OriginPoint::OriginTopLeft: + mScaleOriginPoint.x = mScaleOriginPoint.y = 0; + break; + default: {} + } +} + +Interpolation1d * UINode::getRotationInterpolation() { + if ( NULL == mAngleAnim ) + mAngleAnim = eeNew( Interpolation1d, () ); + + return mAngleAnim; +} + +Interpolation2d * UINode::getScaleInterpolation() { + if ( NULL == mScaleAnim ) + mScaleAnim = eeNew( Interpolation2d, () ); + + return mScaleAnim; +} + +Interpolation1d * UINode::getAlphaInterpolation() { + if ( NULL == mAlphaAnim ) + mAlphaAnim = eeNew( Interpolation1d, () ); + + return mAlphaAnim; +} + +Interpolation2d * UINode::getTranslationInterpolation() { + if ( NULL == mMoveAnim ) + mMoveAnim = eeNew( Interpolation2d, () ); + + return mMoveAnim; +} + +void UINode::onAngleChange() { + sendCommonEvent( UIEvent::OnAngleChange ); + invalidateDraw(); +} + +void UINode::onScaleChange() { + sendCommonEvent( UIEvent::OnScaleChange ); + invalidateDraw(); +} + +void UINode::onAlphaChange() { + sendCommonEvent( UIEvent::OnAlphaChange ); + invalidateDraw(); +} + +Color UINode::getColor( const Color& Col ) { + return Color( Col.r, Col.g, Col.b, static_cast( (Float)Col.a * ( mAlpha / 255.f ) ) ); +} + +bool UINode::isFadingOut() { + return 0 != ( mControlFlags & UI_CTRL_FLAG_DISABLE_FADE_OUT ); +} + +bool UINode::isAnimating() { + return ( NULL != mAlphaAnim && mAlphaAnim->isEnabled() ) || ( NULL != mAngleAnim && mAngleAnim->isEnabled() ) || ( NULL != mScaleAnim && mScaleAnim->isEnabled() ) || ( NULL != mMoveAnim && mMoveAnim->isEnabled() ); +} + +Interpolation1d * UINode::startAlphaAnim( const Float& From, const Float& To, const Time& TotalTime, const bool& AlphaChilds, const Ease::Interpolation& Type, Interpolation1d::OnPathEndCallback PathEndCallback ) { + if ( NULL == mAlphaAnim ) + mAlphaAnim = eeNew( Interpolation1d, () ); + + mAlphaAnim->clear().add( From, TotalTime ).add( To ).setType( Type ).start( PathEndCallback ); + + setAlpha( From ); + + if ( AlphaChilds ) { + UINode * CurChild = mChild; + + while ( NULL != CurChild ) { + CurChild->startAlphaAnim( From, To, TotalTime, AlphaChilds ); + CurChild = CurChild->getNextControl(); + } + } + + return mAlphaAnim; +} + +Interpolation2d * UINode::startScaleAnim( const Vector2f& From, const Vector2f& To, const Time& TotalTime, const Ease::Interpolation& Type, Interpolation2d::OnPathEndCallback PathEndCallback ) { + if ( NULL == mScaleAnim ) + mScaleAnim = eeNew( Interpolation2d, () ); + + mScaleAnim->clear().add( From ).add( To ).setDuration( TotalTime ).setType( Type ).start( PathEndCallback ); + + setScale( From ); + + return mScaleAnim; +} + +Interpolation2d * UINode::startScaleAnim( const Float& From, const Float& To, const Time& TotalTime, const Ease::Interpolation& Type, Interpolation2d::OnPathEndCallback PathEndCallback ) { + return startScaleAnim( Vector2f( From, From ), Vector2f( To, To ), TotalTime, Type, PathEndCallback ); +} + +Interpolation2d * UINode::startTranslation( const Vector2i& From, const Vector2i& To, const Time& TotalTime, const Ease::Interpolation& Type, Interpolation2d::OnPathEndCallback PathEndCallback ) { + if ( NULL == mMoveAnim ) + mMoveAnim = eeNew( Interpolation2d, () ); + + mMoveAnim->clear().add( Vector2f( (Float)From.x, (Float)From.y ) ).add( Vector2f( (Float)To.x, (Float)To.y ) ).setType( Type ).setDuration( TotalTime ).start( PathEndCallback ); + + setPosition( From ); + + return mMoveAnim; +} + +Interpolation1d * UINode::startRotation( const Float& From, const Float& To, const Time& TotalTime, const Ease::Interpolation& Type, Interpolation1d::OnPathEndCallback PathEndCallback ) { + if ( NULL == mAngleAnim ) + mAngleAnim = eeNew( Interpolation1d, () ); + + mAngleAnim->clear().add( From ).add( To ).setDuration( TotalTime ).setType( Type ).start( PathEndCallback ); + + setRotation( From ); + + return mAngleAnim; +} + +Interpolation1d * UINode::startAlphaAnim(const Float & To, const Time & TotalTime, const bool & alphaChilds, const Ease::Interpolation & type, Interpolation1d::OnPathEndCallback PathEndCallback) { + return startAlphaAnim( mAlpha, To, TotalTime, alphaChilds, type, PathEndCallback ); +} + +Interpolation2d * UINode::startScaleAnim(const Vector2f & To, const Time & TotalTime, const Ease::Interpolation & type, Interpolation2d::OnPathEndCallback PathEndCallback) { + return startScaleAnim( mScale, To, TotalTime, type, PathEndCallback ); +} + +Interpolation2d * UINode::startScaleAnim(const Float & To, const Time & TotalTime, const Ease::Interpolation & type, Interpolation2d::OnPathEndCallback PathEndCallback) { + return startScaleAnim( mScale, Vector2f(To,To), TotalTime, type, PathEndCallback ); +} + +Interpolation2d * UINode::startTranslation(const Vector2i & To, const Time & TotalTime, const Ease::Interpolation & type, Interpolation2d::OnPathEndCallback PathEndCallback) { + return startTranslation( mPos, To, TotalTime, type, PathEndCallback ); +} + +Interpolation1d * UINode::startRotation(const Float & To, const Time & TotalTime, const Ease::Interpolation & type, Interpolation1d::OnPathEndCallback PathEndCallback) { + return startRotation( mAngle, To, TotalTime, type, PathEndCallback ); +} + +Interpolation1d * UINode::createFadeIn( const Time& time, const bool& AlphaChilds, const Ease::Interpolation& Type ) { + return startAlphaAnim( mAlpha, 255.f, time, AlphaChilds, Type ); +} + +Interpolation1d * UINode::createFadeOut( const Time& time, const bool& AlphaChilds, const Ease::Interpolation& Type ) { + return startAlphaAnim( 255.f, mAlpha, time, AlphaChilds, Type ); +} + +Interpolation1d * UINode::closeFadeOut( const Time& time, const bool& AlphaChilds, const Ease::Interpolation& Type ) { + startAlphaAnim ( mAlpha, 0.f, time, AlphaChilds, Type ); + mControlFlags |= UI_CTRL_FLAG_CLOSE_FO; + return mAlphaAnim; +} + +Interpolation1d * UINode::disableFadeOut( const Time& time, const bool& AlphaChilds, const Ease::Interpolation& Type ) { + setEnabled( false ); + + startAlphaAnim ( mAlpha, 0.f, time, AlphaChilds, Type ); + + mControlFlags |= UI_CTRL_FLAG_DISABLE_FADE_OUT; + + return mAlphaAnim; +} + +const Float& UINode::getRotation() const { + return mAngle; +} + +const OriginPoint& UINode::getRotationOriginPoint() const { + return mRotationOriginPoint; +} + +void UINode::setRotationOriginPoint( const OriginPoint & center ) { + mRotationOriginPoint = PixelDensity::dpToPx( center ); + updateOriginPoint(); +} + +Vector2f UINode::getRotationCenter() { + switch ( mRotationOriginPoint.OriginType ) { + case OriginPoint::OriginCenter: return mCenter; + case OriginPoint::OriginTopLeft: return mScreenPosf; + case OriginPoint::OriginCustom: default: return mScreenPosf + mRotationOriginPoint; + } +} + +void UINode::setRotation( const Float& angle ) { + mAngle = angle; + + if ( mAngle != 0.f ) { + mControlFlags |= UI_CTRL_FLAG_ROTATED; + } else { + if ( mControlFlags & UI_CTRL_FLAG_ROTATED ) + mControlFlags &= ~UI_CTRL_FLAG_ROTATED; + } + + onAngleChange(); +} + +void UINode::setRotation( const Float& angle , const OriginPoint & center ) { + mRotationOriginPoint = center; + updateOriginPoint(); + this->setRotation( angle ); +} + +const Vector2f& UINode::getScale() const { + return mScale; +} + +void UINode::setScale( const Vector2f & scale ) { + mScale = scale; + + if ( mScale != 1.f ) { + mControlFlags |= UI_CTRL_FLAG_SCALED; + } else { + if ( mControlFlags & UI_CTRL_FLAG_SCALED ) + mControlFlags &= ~UI_CTRL_FLAG_SCALED; + } + + onScaleChange(); +} + +const OriginPoint& UINode::getScaleOriginPoint() const { + return mScaleOriginPoint; +} + +void UINode::setScaleOriginPoint( const OriginPoint & center ) { + mScaleOriginPoint = PixelDensity::dpToPx( center ); + updateOriginPoint(); +} + +Vector2f UINode::getScaleCenter() { + switch ( mScaleOriginPoint.OriginType ) { + case OriginPoint::OriginCenter: return mCenter; + case OriginPoint::OriginTopLeft: return mScreenPosf; + case OriginPoint::OriginCustom: default: return mScreenPosf + mScaleOriginPoint; + } +} + +void UINode::setScale( const Vector2f& scale, const OriginPoint& center ) { + mScaleOriginPoint = center; + updateOriginPoint(); + this->setScale( scale ); +} + +void UINode::setScale( const Float& scale, const OriginPoint& center ) { + this->setScale( Vector2f( scale, scale ), center ); +} + +const Float& UINode::getAlpha() const { + return mAlpha; +} + +void UINode::setAlpha( const Float& alpha ) { + mAlpha = alpha; + onAlphaChange(); +} + +void UINode::setChildsAlpha( const Float &alpha ) { + UINode * CurChild = mChild; + + while ( NULL != CurChild ) { + CurChild->setAlpha( alpha ); + CurChild->setChildsAlpha( alpha ); + CurChild = CurChild->getNextControl(); + } +} + }} diff --git a/src/eepp/ui/uiprogressbar.cpp b/src/eepp/ui/uiprogressbar.cpp index 054240242..afea6e741 100644 --- a/src/eepp/ui/uiprogressbar.cpp +++ b/src/eepp/ui/uiprogressbar.cpp @@ -46,7 +46,7 @@ bool UIProgressBar::isType( const Uint32& type ) const { } void UIProgressBar::draw() { - UIControlAnim::draw(); + UINode::draw(); if ( NULL == mFillerSkin ) return; @@ -78,7 +78,7 @@ void UIProgressBar::draw() { } void UIProgressBar::update() { - UIControlAnim::update(); + UINode::update(); if ( NULL == mFillerSkin ) return; @@ -129,7 +129,7 @@ void UIProgressBar::onThemeLoaded() { } Uint32 UIProgressBar::onValueChange() { - UIControlAnim::onValueChange(); + UINode::onValueChange(); onSizeChange(); @@ -248,7 +248,7 @@ void UIProgressBar::loadFromXmlNode(const pugi::xml_node & node) { } void UIProgressBar::onAlphaChange() { - UIControlAnim::onAlphaChange(); + UINode::onAlphaChange(); mTextBox->setAlpha( mAlpha ); } diff --git a/src/eepp/ui/uiradiobutton.cpp b/src/eepp/ui/uiradiobutton.cpp index a4197ac9c..ab84f52a5 100644 --- a/src/eepp/ui/uiradiobutton.cpp +++ b/src/eepp/ui/uiradiobutton.cpp @@ -17,14 +17,14 @@ UIRadioButton::UIRadioButton() : mActive( false ), mTextSeparation( 4 ) { - mActiveButton = UIControlAnim::New(); + mActiveButton = UINode::New(); mActiveButton->setVisible( false ); mActiveButton->setEnabled( true ); mActiveButton->setParent( this ); mActiveButton->setPosition( 0, 0 ); mActiveButton->setSize( 16, 16 ); - mInactiveButton = UIControlAnim::New(); + mInactiveButton = UINode::New(); mInactiveButton->setVisible( true ); mInactiveButton->setEnabled( true ); mInactiveButton->setParent( this ); @@ -137,7 +137,7 @@ void UIRadioButton::setActive( const bool& active ) { } if ( active && NULL != mParentCtrl ) { - UIControl * tChild = mParentCtrl->getFirstChild(); + UINode * tChild = mParentCtrl->getFirstChild(); while ( NULL != tChild ) { if ( tChild->isType( UI_TYPE_RADIOBUTTON ) ) { @@ -156,7 +156,7 @@ void UIRadioButton::setActive( const bool& active ) { bool UIRadioButton::checkActives() { if ( NULL != mParentCtrl ) { - UIControl * tChild = mParentCtrl->getFirstChild(); + UINode * tChild = mParentCtrl->getFirstChild(); while ( NULL != tChild ) { if ( tChild->isType( UI_TYPE_RADIOBUTTON ) ) { @@ -179,7 +179,7 @@ void UIRadioButton::autoActivate() { eeASSERT( NULL != mParentCtrl ); if ( NULL != mParentCtrl ) { - UIControl * tChild = mParentCtrl->getFirstChild(); + UINode * tChild = mParentCtrl->getFirstChild(); while ( NULL != tChild ) { if ( tChild->isType( UI_TYPE_RADIOBUTTON ) ) { @@ -210,11 +210,11 @@ void UIRadioButton::onPaddingChange() { mRealPadding.Left = mActiveButton->getRealPosition().x + mActiveButton->getRealSize().getWidth() + PixelDensity::dpToPxI( mTextSeparation ); } -UIControlAnim * UIRadioButton::getActiveButton() const { +UINode * UIRadioButton::getActiveButton() const { return mActiveButton; } -UIControlAnim * UIRadioButton::getInactiveButton() const { +UINode * UIRadioButton::getInactiveButton() const { return mInactiveButton; } diff --git a/src/eepp/ui/uirelativelayout.cpp b/src/eepp/ui/uirelativelayout.cpp index 841112a99..edaa57e4b 100644 --- a/src/eepp/ui/uirelativelayout.cpp +++ b/src/eepp/ui/uirelativelayout.cpp @@ -49,7 +49,7 @@ void UIRelativeLayout::fixChilds() { setInternalHeight( getParent()->getSize().getHeight() - mLayoutMargin.Top - mLayoutMargin.Bottom ); } - UIControl * child = mChild; + UINode * child = mChild; while ( NULL != child ) { if ( child->isWidget() ) { diff --git a/src/eepp/ui/uiscrollbar.cpp b/src/eepp/ui/uiscrollbar.cpp index f4e8ce324..6dc144e41 100644 --- a/src/eepp/ui/uiscrollbar.cpp +++ b/src/eepp/ui/uiscrollbar.cpp @@ -18,8 +18,8 @@ UIScrollBar::UIScrollBar( const UI_ORIENTATION& orientation ) : { mFlags |= UI_AUTO_SIZE; - mBtnDown = UIControlAnim::New(); - mBtnUp = UIControlAnim::New(); + mBtnDown = UINode::New(); + mBtnUp = UINode::New(); mBtnUp->setParent( this ); mBtnUp->setSize( 16, 16 ); mBtnDown->setParent( this ); @@ -53,14 +53,14 @@ void UIScrollBar::setTheme( UITheme * Theme ) { UIWidget::setTheme( Theme ); if ( !isVertical() ) { - UIControl::setThemeSkin( Theme, "hscrollbar" ); + UINode::setThemeSkin( Theme, "hscrollbar" ); mSlider->setThemeSkin( Theme, "hscrollbar_slider" ); mSlider->getBackSlider()->setThemeSkin( Theme, "hscrollbar_bg" ); mSlider->getSliderButton()->setThemeSkin( Theme, "hscrollbar_button" ); mBtnUp->setThemeSkin( Theme, "hscrollbar_btnup" ); mBtnDown->setThemeSkin( Theme, "hscrollbar_btndown" ); } else { - UIControl::setThemeSkin( Theme, "vscrollbar" ); + UINode::setThemeSkin( Theme, "vscrollbar" ); mSlider->setThemeSkin( Theme, "vscrollbar_slider" ); mSlider->getBackSlider()->setThemeSkin( Theme, "vscrollbar_bg" ); mSlider->getSliderButton()->setThemeSkin( Theme, "vscrollbar_button" ); @@ -178,7 +178,7 @@ void UIScrollBar::adjustChilds() { } void UIScrollBar::update() { - UIControlAnim::update(); + UINode::update(); if ( mBtnUp->isMouseOver() || mBtnDown->isMouseOver() ) { manageClick( UIManager::instance()->getInput()->getClickTrigger() ); @@ -265,11 +265,11 @@ UISlider * UIScrollBar::getSlider() const { return mSlider; } -UIControlAnim * UIScrollBar::getButtonUp() const { +UINode * UIScrollBar::getButtonUp() const { return mBtnUp; } -UIControlAnim * UIScrollBar::getButtonDown() const { +UINode * UIScrollBar::getButtonDown() const { return mBtnDown; } @@ -309,7 +309,7 @@ UI_ORIENTATION UIScrollBar::getOrientation() const { return mSlider->getOrientation(); } -UIControl * UIScrollBar::setOrientation( const UI_ORIENTATION & orientation ) { +UINode * UIScrollBar::setOrientation( const UI_ORIENTATION & orientation ) { mSlider->setOrientation( orientation ); applyDefaultTheme(); @@ -318,7 +318,7 @@ UIControl * UIScrollBar::setOrientation( const UI_ORIENTATION & orientation ) { } void UIScrollBar::onAlphaChange() { - UIControlAnim::onAlphaChange(); + UINode::onAlphaChange(); mSlider->setAlpha( mAlpha ); mBtnUp->setAlpha( mAlpha ); diff --git a/src/eepp/ui/uiscrollview.cpp b/src/eepp/ui/uiscrollview.cpp index b0cb1f830..095649742 100644 --- a/src/eepp/ui/uiscrollview.cpp +++ b/src/eepp/ui/uiscrollview.cpp @@ -15,7 +15,7 @@ UIScrollView::UIScrollView() : mHScrollMode( UI_SCROLLBAR_AUTO ), mVScroll( UIScrollBar::New( UI_VERTICAL ) ), mHScroll( UIScrollBar::New( UI_HORIZONTAL ) ), - mContainer( UIControlAnim::New() ), + mContainer( UINode::New() ), mScrollView( NULL ), mSizeChangeCb( 0 ) { @@ -51,12 +51,12 @@ void UIScrollView::onAlphaChange() { mHScroll->setAlpha( mAlpha ); mContainer->setAlpha( mAlpha ); - if ( NULL != mScrollView && mScrollView->isAnimated() ) - reinterpret_cast( mScrollView )->setAlpha( mAlpha ); + if ( NULL != mScrollView ) + mScrollView->setAlpha( mAlpha ); } void UIScrollView::onChildCountChange() { - UIControl * child = mChild; + UINode * child = mChild; bool found = false; while ( NULL != child ) { @@ -125,7 +125,7 @@ UIScrollBar * UIScrollView::getHorizontalScrollBar() const { return mHScroll; } -UIControlAnim * UIScrollView::getContainer() const { +UINode * UIScrollView::getContainer() const { return mContainer; } diff --git a/src/eepp/ui/uislider.cpp b/src/eepp/ui/uislider.cpp index 18d9d7b68..d1f68c931 100644 --- a/src/eepp/ui/uislider.cpp +++ b/src/eepp/ui/uislider.cpp @@ -34,7 +34,7 @@ UISlider::UISlider( const UI_ORIENTATION& orientation ) : else bgSize = Sizei( 8, mSize.getHeight() - 16 ); - mBackSlider = UIControlAnim::New(); + mBackSlider = UINode::New(); mBackSlider->setParent( this ); mBackSlider->setVisible( true ); mBackSlider->setEnabled( true ); @@ -282,7 +282,7 @@ bool UISlider::isVertical() const { } void UISlider::update() { - UIControlAnim::update(); + UINode::update(); if ( isMouseOver() || mBackSlider->isMouseOver() || mSlider->isMouseOver() ) { manageClick( UIManager::instance()->getInput()->getClickTrigger() ); @@ -387,16 +387,16 @@ void UISlider::setPageStep(const Float & pageStep) { setValue( mValue ); } -UIControl * UISlider::getBackSlider() const { +UINode * UISlider::getBackSlider() const { return mBackSlider; } -UIDragableControl * UISlider::getSliderButton() const { +UINode * UISlider::getSliderButton() const { return mSlider; } void UISlider::onAlphaChange() { - UIControlAnim::onAlphaChange(); + UINode::onAlphaChange(); mBackSlider->setAlpha( mAlpha ); mSlider->setAlpha( mAlpha ); diff --git a/src/eepp/ui/uispinbox.cpp b/src/eepp/ui/uispinbox.cpp index a8a6d1fe9..a6e392b48 100644 --- a/src/eepp/ui/uispinbox.cpp +++ b/src/eepp/ui/uispinbox.cpp @@ -20,13 +20,13 @@ UISpinBox::UISpinBox() : mInput->setEnabled( true ); mInput->setParent( this ); - mPushUp = UIControlAnim::New(); + mPushUp = UINode::New(); mPushUp->setVisible( true ); mPushUp->setEnabled( true ); mPushUp->setParent( this ); mPushUp->setSize( 16, 16 ); - mPushDown = UIControlAnim::New(); + mPushDown = UINode::New(); mPushDown->setVisible( true ); mPushDown->setEnabled( true ); mPushDown->setParent( this ); @@ -211,7 +211,7 @@ const Float& UISpinBox::getMaxValue() const { void UISpinBox::update() { bool Changed = mInput->getInputTextBuffer()->changedSinceLastUpdate(); - UIControlAnim::update(); + UINode::update(); if ( Changed ) { if ( !mInput->getText().size() ) { @@ -234,11 +234,11 @@ void UISpinBox::update() { } } -UIControlAnim * UISpinBox::getButtonPushUp() const { +UINode * UISpinBox::getButtonPushUp() const { return mPushUp; } -UIControlAnim * UISpinBox::getButtonPushDown() const { +UINode * UISpinBox::getButtonPushDown() const { return mPushDown; } @@ -257,7 +257,7 @@ bool UISpinBox::dotsInNumbersAllowed() { } void UISpinBox::onAlphaChange() { - UIControlAnim::onAlphaChange(); + UINode::onAlphaChange(); mInput->setAlpha( mAlpha ); mPushUp->setAlpha( mAlpha ); diff --git a/src/eepp/ui/uisubtexture.cpp b/src/eepp/ui/uisubtexture.cpp index 5411617f1..fe23f8d5d 100644 --- a/src/eepp/ui/uisubtexture.cpp +++ b/src/eepp/ui/uisubtexture.cpp @@ -59,7 +59,7 @@ void UISubTexture::onAutoSize() { } void UISubTexture::draw() { - UIControlAnim::draw(); + UINode::draw(); if ( mVisible ) { if ( NULL != mSubTexture && 0.f != mAlpha ) { diff --git a/src/eepp/ui/uitab.cpp b/src/eepp/ui/uitab.cpp index 0882f2b23..b2f2fe29d 100644 --- a/src/eepp/ui/uitab.cpp +++ b/src/eepp/ui/uitab.cpp @@ -57,7 +57,7 @@ void UITab::setTheme( UITheme * Theme ) { } } - UIControl::setThemeSkin( Theme, tabPos ); + UINode::setThemeSkin( Theme, tabPos ); onThemeLoaded(); } @@ -195,18 +195,18 @@ void UITab::loadFromXmlNode(const pugi::xml_node & node) { } void UITab::setOwnedControl() { - UIControl * ctrl = getParent()->getParent()->find( mOwnedName ); + UINode * ctrl = getParent()->getParent()->find( mOwnedName ); if ( NULL != ctrl ) { setControlOwned( ctrl ); } } -UIControl * UITab::getControlOwned() const { +UINode * UITab::getControlOwned() const { return mControlOwned; } -void UITab::setControlOwned(UIControl * controlOwned) { +void UITab::setControlOwned(UINode * controlOwned) { mControlOwned = controlOwned; UITabWidget * tTabW = getTabWidget(); diff --git a/src/eepp/ui/uitable.cpp b/src/eepp/ui/uitable.cpp index fb4045559..9828385fe 100644 --- a/src/eepp/ui/uitable.cpp +++ b/src/eepp/ui/uitable.cpp @@ -483,7 +483,7 @@ void UITable::updateCollumnsPos() { } void UITable::onAlphaChange() { - UIControlAnim::onAlphaChange(); + UINode::onAlphaChange(); mVScrollBar->setAlpha( mAlpha ); mHScrollBar->setAlpha( mAlpha ); @@ -561,7 +561,7 @@ Uint32 UITable::onMessage( const UIMessage * Msg ) { switch ( Msg->getMsg() ) { case UIMessage::FocusLoss: { - UIControl * FocusCtrl = UIManager::instance()->getFocusControl(); + UINode * FocusCtrl = UIManager::instance()->getFocusControl(); if ( this != FocusCtrl && !isParentOf( FocusCtrl ) ) { onWidgetFocusLoss(); diff --git a/src/eepp/ui/uitablecell.cpp b/src/eepp/ui/uitablecell.cpp index 6edb32395..163726842 100644 --- a/src/eepp/ui/uitablecell.cpp +++ b/src/eepp/ui/uitablecell.cpp @@ -32,7 +32,7 @@ UITable * UITableCell::gridParent() const { return reinterpret_cast ( mParentCtrl->getParent() ); } -void UITableCell::setCell( const Uint32& CollumnIndex, UIControl * Ctrl ) { +void UITableCell::setCell( const Uint32& CollumnIndex, UINode * Ctrl ) { eeASSERT( CollumnIndex < gridParent()->getCollumnsCount() ); UITable * P = gridParent(); @@ -52,7 +52,7 @@ void UITableCell::setCell( const Uint32& CollumnIndex, UIControl * Ctrl ) { Ctrl->setEnabled( true ); } -UIControl * UITableCell::getCell( const Uint32& CollumnIndex ) const { +UINode * UITableCell::getCell( const Uint32& CollumnIndex ) const { eeASSERT( CollumnIndex < gridParent()->getCollumnsCount() ); return mCells[ CollumnIndex ]; @@ -78,8 +78,8 @@ void UITableCell::update() { setAlpha( MyParent->getAlpha() ); for ( Uint32 i = 0; i < mCells.size(); i++ ) { - if ( NULL != mCells[i] && mCells[i]->isAnimated() ) { - reinterpret_cast( mCells[i] )->setAlpha( MyParent->getAlpha() ); + if ( NULL != mCells[i] ) { + mCells[i]->setAlpha( MyParent->getAlpha() ); } } } @@ -127,7 +127,7 @@ bool UITableCell::isSelected() const { } Uint32 UITableCell::onMouseExit( const Vector2i& Pos, const Uint32 Flags ) { - UIControl::onMouseExit( Pos, Flags ); + UINode::onMouseExit( Pos, Flags ); if ( mControlFlags & UI_CTRL_FLAG_SELECTED ) setSkinState( UISkinState::StateSelected ); diff --git a/src/eepp/ui/uitabwidget.cpp b/src/eepp/ui/uitabwidget.cpp index 9202ac8d1..7c56b7b00 100644 --- a/src/eepp/ui/uitabwidget.cpp +++ b/src/eepp/ui/uitabwidget.cpp @@ -503,7 +503,7 @@ void UITabWidget::orderTabs() { invalidateDraw(); } -UITab * UITabWidget::createTab( const String& Text, UIControl * CtrlOwned, Drawable * Icon ) { +UITab * UITabWidget::createTab( const String& Text, UINode * CtrlOwned, Drawable * Icon ) { UITab * tCtrl = UITab::New(); tCtrl->setParent( mTabContainer ); tCtrl->setFlags( UI_VALIGN_CENTER | UI_HALIGN_CENTER | UI_AUTO_SIZE ); @@ -520,7 +520,7 @@ UITab * UITabWidget::createTab( const String& Text, UIControl * CtrlOwned, Drawa return tCtrl; } -UITabWidget * UITabWidget::add( const String& Text, UIControl * CtrlOwned, Drawable * Icon ) { +UITabWidget * UITabWidget::add( const String& Text, UINode * CtrlOwned, Drawable * Icon ) { return add( createTab( Text, CtrlOwned, Icon ) ); } @@ -619,7 +619,7 @@ void UITabWidget::removeAll() { orderTabs(); } -void UITabWidget::insert( const String& Text, UIControl * CtrlOwned, Drawable * Icon, const Uint32& Index ) { +void UITabWidget::insert( const String& Text, UINode * CtrlOwned, Drawable * Icon, const Uint32& Index ) { insert( createTab( Text, CtrlOwned, Icon ), Index ); } @@ -711,7 +711,7 @@ void UITabWidget::onSizeChange() { } void UITabWidget::onChildCountChange() { - UIControl * child = mChild; + UINode * child = mChild; bool found = false; while ( NULL != child ) { diff --git a/src/eepp/ui/uitextinput.cpp b/src/eepp/ui/uitextinput.cpp index 0307369d2..a9c9025f2 100644 --- a/src/eepp/ui/uitextinput.cpp +++ b/src/eepp/ui/uitextinput.cpp @@ -128,7 +128,7 @@ void UITextInput::draw() { } Uint32 UITextInput::onFocus() { - UIControlAnim::onFocus(); + UINode::onFocus(); if ( mAllowEditing ) { mTextBuffer.setActive( true ); @@ -292,7 +292,7 @@ Uint32 UITextInput::onMouseDoubleClick( const Vector2i& Pos, const Uint32 Flags } Uint32 UITextInput::onMouseExit( const Vector2i& Pos, const Uint32 Flags ) { - UIControl::onMouseExit( Pos, Flags ); + UINode::onMouseExit( Pos, Flags ); UIManager::instance()->setCursor( EE_CURSOR_ARROW ); diff --git a/src/eepp/ui/uitextinputpassword.cpp b/src/eepp/ui/uitextinputpassword.cpp index e6b590817..5c9cb38fb 100644 --- a/src/eepp/ui/uitextinputpassword.cpp +++ b/src/eepp/ui/uitextinputpassword.cpp @@ -25,7 +25,7 @@ UITextInputPassword::~UITextInputPassword() { void UITextInputPassword::draw() { if ( mVisible && 0.f != mAlpha ) { - UIControlAnim::draw(); + UINode::draw(); drawSelection( mPassCache ); diff --git a/src/eepp/ui/uitextview.cpp b/src/eepp/ui/uitextview.cpp index a26a44900..2a4eea79c 100644 --- a/src/eepp/ui/uitextview.cpp +++ b/src/eepp/ui/uitextview.cpp @@ -49,7 +49,7 @@ bool UITextView::isType( const Uint32& type ) const { void UITextView::draw() { if ( mVisible && 0.f != mAlpha ) { - UIControlAnim::draw(); + UINode::draw(); drawSelection( mTextCache ); @@ -223,7 +223,7 @@ UITextView * UITextView::setSelectionBackColor( const Color& color ) { void UITextView::setAlpha( const Float& alpha ) { if ( mAlpha != alpha ) { - UIControlAnim::setAlpha( alpha ); + UINode::setAlpha( alpha ); mFontStyleConfig.FontColor.a = (Uint8)alpha; mFontStyleConfig.ShadowColor.a = (Uint8)alpha; @@ -298,7 +298,7 @@ Uint32 UITextView::onFocusLoss() { void UITextView::onSizeChange() { recalculate(); - UIControlAnim::onSizeChange(); + UINode::onSizeChange(); } void UITextView::onTextChanged() { diff --git a/src/eepp/ui/uithememanager.cpp b/src/eepp/ui/uithememanager.cpp index a44bd8bb5..97117e1fd 100644 --- a/src/eepp/ui/uithememanager.cpp +++ b/src/eepp/ui/uithememanager.cpp @@ -1,5 +1,5 @@ #include -#include +#include #include namespace EE { namespace UI { @@ -45,7 +45,7 @@ void UIThemeManager::setTheme( const std::string& Theme ) { } void UIThemeManager::setTheme( UITheme * Theme ) { - UIControl * MainCtrl = UIManager::instance()->getMainControl(); + UINode * MainCtrl = UIManager::instance()->getMainControl(); if ( NULL != MainCtrl ) { MainCtrl->setThemeToChilds( Theme ); @@ -74,7 +74,7 @@ UITheme * UIThemeManager::getDefaultTheme() const { return mThemeDefault; } -void UIThemeManager::applyDefaultTheme( UIControl * Control ) { +void UIThemeManager::applyDefaultTheme( UINode * Control ) { if ( mAutoApplyDefaultTheme && NULL != mThemeDefault && NULL != Control ) Control->setTheme( mThemeDefault ); } diff --git a/src/eepp/ui/uitooltip.cpp b/src/eepp/ui/uitooltip.cpp index c54d520d5..24c355543 100644 --- a/src/eepp/ui/uitooltip.cpp +++ b/src/eepp/ui/uitooltip.cpp @@ -10,7 +10,7 @@ UITooltip *UITooltip::New() { } UITooltip::UITooltip() : - UIControlAnim(), + UINode(), mAlignOffset( 0.f, 0.f ), mTooltipTime( Time::Zero ), mTooltipOf() @@ -50,7 +50,7 @@ Uint32 UITooltip::getType() const { } bool UITooltip::isType( const Uint32& type ) const { - return UITooltip::getType() == type ? true : UIControlAnim::isType( type ); + return UITooltip::getType() == type ? true : UINode::isType( type ); } void UITooltip::setTheme( UITheme * Theme ) { @@ -91,7 +91,7 @@ void UITooltip::hide() { void UITooltip::draw() { if ( mVisible && 0.f != mAlpha && mTextCache->getString().size() > 0 ) { - UIControlAnim::draw(); + UINode::draw(); if ( mTextCache->getTextWidth() ) { mTextCache->setAlign( getFlags() ); @@ -147,7 +147,7 @@ void UITooltip::setFontShadowColor( const Color& color ) { } void UITooltip::setAlpha( const Float& alpha ) { - UIControlAnim::setAlpha( alpha ); + UINode::setAlpha( alpha ); mStyleConfig.FontColor.a = (Uint8)alpha; mStyleConfig.ShadowColor.a = (Uint8)alpha; @@ -197,7 +197,7 @@ void UITooltip::onSizeChange() { onAutoSize(); autoAlign(); - UIControlAnim::onSizeChange(); + UINode::onSizeChange(); } void UITooltip::onTextChanged() { @@ -249,11 +249,11 @@ const Time& UITooltip::getTooltipTime() const { return mTooltipTime; } -UIControl * UITooltip::getTooltipOf() const { +UINode * UITooltip::getTooltipOf() const { return mTooltipOf; } -void UITooltip::setTooltipOf(UIControl * tooltipOf) { +void UITooltip::setTooltipOf(UINode * tooltipOf) { mTooltipOf = tooltipOf; } diff --git a/src/eepp/ui/uiwidget.cpp b/src/eepp/ui/uiwidget.cpp index 924e4ef2b..3a46397bc 100644 --- a/src/eepp/ui/uiwidget.cpp +++ b/src/eepp/ui/uiwidget.cpp @@ -10,7 +10,7 @@ UIWidget * UIWidget::New() { } UIWidget::UIWidget() : - UIControlAnim(), + UINode(), mTheme( NULL ), mTooltip( NULL ), mMinControlSize(), @@ -36,7 +36,7 @@ Uint32 UIWidget::getType() const { } bool UIWidget::isType( const Uint32& type ) const { - return UIWidget::getType() == type ? true : UIControlAnim::isType( type ); + return UIWidget::getType() == type ? true : UINode::isType( type ); } void UIWidget::updateAnchorsDistances() { @@ -190,7 +190,7 @@ void UIWidget::update() { } } - UIControlAnim::update(); + UINode::update(); } void UIWidget::createTooltip() { @@ -227,7 +227,7 @@ void UIWidget::tooltipRemove() { mTooltip = NULL; } -UIControl * UIWidget::setSize( const Sizei& size ) { +UINode * UIWidget::setSize( const Sizei& size ) { Sizei s( size ); if ( s.x < mMinControlSize.x ) @@ -236,10 +236,10 @@ UIControl * UIWidget::setSize( const Sizei& size ) { if ( s.y < mMinControlSize.y ) s.y = mMinControlSize.y; - return UIControlAnim::setSize( s ); + return UINode::setSize( s ); } -UIControl * UIWidget::setFlags(const Uint32 & flags) { +UINode * UIWidget::setFlags(const Uint32 & flags) { if ( flags & ( UI_ANCHOR_LEFT | UI_ANCHOR_TOP | UI_ANCHOR_RIGHT | UI_ANCHOR_BOTTOM ) ) { updateAnchorsDistances(); } @@ -248,15 +248,15 @@ UIControl * UIWidget::setFlags(const Uint32 & flags) { onAutoSize(); } - return UIControlAnim::setFlags( flags ); + return UINode::setFlags( flags ); } -UIControl * UIWidget::unsetFlags(const Uint32 & flags) { +UINode * UIWidget::unsetFlags(const Uint32 & flags) { if ( flags & ( UI_ANCHOR_LEFT | UI_ANCHOR_TOP | UI_ANCHOR_RIGHT | UI_ANCHOR_BOTTOM ) ) { updateAnchorsDistances(); } - return UIControlAnim::unsetFlags( flags ); + return UINode::unsetFlags( flags ); } UIWidget * UIWidget::setAnchors(const Uint32 & flags) { @@ -271,20 +271,20 @@ void UIWidget::setTheme( UITheme * Theme ) { invalidateDraw(); } -UIControl * UIWidget::setThemeSkin( const std::string& skinName ) { +UINode * UIWidget::setThemeSkin( const std::string& skinName ) { return setThemeSkin( NULL != mTheme ? mTheme : UIThemeManager::instance()->getDefaultTheme(), skinName ); } -UIControl * UIWidget::setThemeSkin( UITheme * Theme, const std::string& skinName ) { - return UIControl::setThemeSkin( Theme, skinName ); +UINode * UIWidget::setThemeSkin( UITheme * Theme, const std::string& skinName ) { + return UINode::setThemeSkin( Theme, skinName ); } -UIControl * UIWidget::setSize( const Int32& Width, const Int32& Height ) { - return UIControlAnim::setSize( Width, Height ); +UINode * UIWidget::setSize( const Int32& Width, const Int32& Height ) { + return UINode::setSize( Width, Height ); } const Sizei& UIWidget::getSize() { - return UIControlAnim::getSize(); + return UINode::getSize(); } UITooltip * UIWidget::getTooltip() { @@ -293,18 +293,18 @@ UITooltip * UIWidget::getTooltip() { void UIWidget::onParentSizeChange( const Vector2i& SizeChange ) { updateAnchors( SizeChange ); - UIControlAnim::onParentSizeChange( SizeChange ); + UINode::onParentSizeChange( SizeChange ); } void UIWidget::onPositionChange() { updateAnchorsDistances(); - UIControlAnim::onPositionChange(); + UINode::onPositionChange(); } void UIWidget::onVisibilityChange() { updateAnchorsDistances(); notifyLayoutAttrChange(); - UIControlAnim::onVisibilityChange(); + UINode::onVisibilityChange(); } void UIWidget::onAutoSize() { @@ -630,7 +630,7 @@ void UIWidget::loadFromXmlNode( const pugi::xml_node& node ) { std::string id = ait->as_string(); - UIControl * control = getParent()->find( id ); + UINode * control = getParent()->find( id ); if ( NULL != control && control->isWidget() ) { UIWidget * widget = static_cast( control ); diff --git a/src/eepp/ui/uiwindow.cpp b/src/eepp/ui/uiwindow.cpp index ae9f4aecb..5cf822ffc 100644 --- a/src/eepp/ui/uiwindow.cpp +++ b/src/eepp/ui/uiwindow.cpp @@ -107,7 +107,7 @@ void UIWindow::updateWinFlags() { if ( !( mStyleConfig.WinFlags & UI_WIN_NO_BORDER ) ) { if ( NULL == mWindowDecoration ) { - mWindowDecoration = UIControlAnim::New(); + mWindowDecoration = UINode::New(); mWindowDecoration->writeCtrlFlag( UI_CTRL_FLAG_OWNED_BY_WINDOW, 1 ); } @@ -116,7 +116,7 @@ void UIWindow::updateWinFlags() { mWindowDecoration->setEnabled( false ); if ( NULL == mBorderLeft ) { - mBorderLeft = UIControlAnim::New(); + mBorderLeft = UINode::New(); mBorderLeft->writeCtrlFlag( UI_CTRL_FLAG_OWNED_BY_WINDOW, 1 ); } @@ -125,7 +125,7 @@ void UIWindow::updateWinFlags() { mBorderLeft->setVisible( true ); if ( NULL == mBorderRight ) { - mBorderRight = UIControlAnim::New(); + mBorderRight = UINode::New(); mBorderRight->writeCtrlFlag( UI_CTRL_FLAG_OWNED_BY_WINDOW, 1 ); } @@ -134,7 +134,7 @@ void UIWindow::updateWinFlags() { mBorderRight->setVisible( true ); if ( NULL == mBorderBottom ) { - mBorderBottom = UIControlAnim::New(); + mBorderBottom = UINode::New(); mBorderBottom->writeCtrlFlag( UI_CTRL_FLAG_OWNED_BY_WINDOW, 1 ); } @@ -144,7 +144,7 @@ void UIWindow::updateWinFlags() { if ( mStyleConfig.WinFlags & UI_WIN_CLOSE_BUTTON ) { if ( NULL == mButtonClose ) { - mButtonClose = UIControlAnim::New(); + mButtonClose = UINode::New(); mButtonClose->writeCtrlFlag( UI_CTRL_FLAG_OWNED_BY_WINDOW, 1 ); needsUpdate = true; } @@ -163,7 +163,7 @@ void UIWindow::updateWinFlags() { if ( isMaximizable() ) { if ( NULL == mButtonMaximize ) { - mButtonMaximize = UIControlAnim::New(); + mButtonMaximize = UINode::New(); mButtonMaximize->writeCtrlFlag( UI_CTRL_FLAG_OWNED_BY_WINDOW, 1 ); needsUpdate = true; } @@ -182,7 +182,7 @@ void UIWindow::updateWinFlags() { if ( mStyleConfig.WinFlags & UI_WIN_MINIMIZE_BUTTON ) { if ( NULL == mButtonMinimize ) { - mButtonMinimize = UIControlAnim::New(); + mButtonMinimize = UINode::New(); mButtonMinimize->writeCtrlFlag( UI_CTRL_FLAG_OWNED_BY_WINDOW, 1 ); needsUpdate = true; } @@ -335,7 +335,7 @@ Sizei UIWindow::getFrameBufferSize() { } void UIWindow::createModalControl() { - UIControl * Ctrl = UIManager::instance()->getMainControl(); + UINode * Ctrl = UIManager::instance()->getMainControl(); if ( NULL == mModalCtrl ) { mModalCtrl = UIWidget::New(); @@ -356,7 +356,7 @@ void UIWindow::createModalControl() { void UIWindow::enableByModal() { if ( isModal() ) { - UIControl * CtrlChild = UIManager::instance()->getMainControl()->getFirstChild(); + UINode * CtrlChild = UIManager::instance()->getMainControl()->getFirstChild(); while ( NULL != CtrlChild ) { @@ -375,7 +375,7 @@ void UIWindow::enableByModal() { void UIWindow::disableByModal() { if ( isModal() ) { - UIControl * CtrlChild = UIManager::instance()->getMainControl()->getFirstChild(); + UINode * CtrlChild = UIManager::instance()->getMainControl()->getFirstChild(); while ( NULL != CtrlChild ) { @@ -551,7 +551,7 @@ void UIWindow::onSizeChange() { } } -UIControl * UIWindow::setSize( const Sizei& Size ) { +UINode * UIWindow::setSize( const Sizei& Size ) { if ( NULL != mWindowDecoration ) { Sizei size = Size; @@ -566,7 +566,7 @@ UIControl * UIWindow::setSize( const Sizei& Size ) { return this; } -UIControl * UIWindow::setSize( const Int32& Width, const Int32& Height ) { +UINode * UIWindow::setSize( const Int32& Width, const Int32& Height ) { setSize( Sizei( Width, Height ) ); return this; } @@ -718,7 +718,7 @@ void UIWindow::doResize ( const UIMessage * Msg ) { decideResizeType( Msg->getSender() ); } -void UIWindow::decideResizeType( UIControl * Control ) { +void UIWindow::decideResizeType( UINode * Control ) { Vector2i Pos = UIManager::instance()->getMousePos(); worldToControl( Pos ); @@ -860,14 +860,14 @@ void UIWindow::updateResize() { case RESIZE_LEFT: { Pos.x -= mResizePos.x; - UIControl::setPixelsPosition( mRealPos.x + Pos.x, mRealPos.y ); + UINode::setPixelsPosition( mRealPos.x + Pos.x, mRealPos.y ); internalSize( mRealSize.getWidth() - Pos.x, mRealSize.getHeight() ); break; } case RESIZE_TOP: { Pos.y -= mResizePos.y; - UIControl::setPixelsPosition( mRealPos.x, mRealPos.y + Pos.y ); + UINode::setPixelsPosition( mRealPos.x, mRealPos.y + Pos.y ); internalSize( mRealSize.getWidth(), mRealSize.getHeight() - Pos.y ); break; } @@ -880,7 +880,7 @@ void UIWindow::updateResize() { case RESIZE_TOPLEFT: { Pos -= mResizePos; - UIControl::setPixelsPosition( mRealPos.x + Pos.x, mRealPos.y + Pos.y ); + UINode::setPixelsPosition( mRealPos.x + Pos.x, mRealPos.y + Pos.y ); internalSize( mRealSize.getWidth() - Pos.x, mRealSize.getHeight() - Pos.y ); break; } @@ -888,7 +888,7 @@ void UIWindow::updateResize() { { Pos.y -= mResizePos.y; Pos.x += mResizePos.x; - UIControl::setPixelsPosition( mRealPos.x, mRealPos.y + Pos.y ); + UINode::setPixelsPosition( mRealPos.x, mRealPos.y + Pos.y ); internalSize( Pos.x, mRealSize.getHeight() - Pos.y ); break; } @@ -896,7 +896,7 @@ void UIWindow::updateResize() { { Pos.x -= mResizePos.x; Pos.y += mResizePos.y; - UIControl::setPixelsPosition( mRealPos.x + Pos.x, mRealPos.y ); + UINode::setPixelsPosition( mRealPos.x + Pos.x, mRealPos.y ); internalSize( mRealSize.getWidth() - Pos.x, Pos.y ); break; } @@ -934,15 +934,15 @@ UIWidget * UIWindow::getContainer() const { return mContainer; } -UIControlAnim * UIWindow::getButtonClose() const { +UINode * UIWindow::getButtonClose() const { return mButtonClose; } -UIControlAnim * UIWindow::getButtonMaximize() const { +UINode * UIWindow::getButtonMaximize() const { return mButtonMaximize; } -UIControlAnim * UIWindow::getButtonMinimize() const { +UINode * UIWindow::getButtonMinimize() const { return mButtonMinimize; } @@ -995,15 +995,10 @@ bool UIWindow::hide() { void UIWindow::onAlphaChange() { if ( mStyleConfig.WinFlags & UI_WIN_SHARE_ALPHA_WITH_CHILDS ) { - UIControlAnim * AnimChild; - UIControl * CurChild = mChild; + UINode * CurChild = mChild; while ( NULL != CurChild ) { - if ( CurChild->isAnimated() ) { - AnimChild = reinterpret_cast ( CurChild ); - AnimChild->setAlpha( mAlpha ); - } - + CurChild->setAlpha( mAlpha ); CurChild = CurChild->getNextControl(); } } @@ -1015,7 +1010,7 @@ void UIWindow::onChildCountChange() { if ( NULL == mContainer || UIManager::instance()->getMainControl() == this ) return; - UIControl * child = mChild; + UINode * child = mChild; bool found = false; while ( NULL != child ) { @@ -1034,7 +1029,7 @@ void UIWindow::onChildCountChange() { void UIWindow::setBaseAlpha( const Uint8& Alpha ) { if ( mAlpha == mStyleConfig.BaseAlpha ) { - UIControlAnim::setAlpha( Alpha ); + UINode::setAlpha( Alpha ); } mStyleConfig.BaseAlpha = Alpha; @@ -1088,7 +1083,7 @@ UITextView * UIWindow::getTitleTextBox() const { } void UIWindow::maximize() { - UIControl * Ctrl = UIManager::instance()->getMainControl(); + UINode * Ctrl = UIManager::instance()->getMainControl(); if ( Ctrl->getSize() == mSize ) { setPixelsPosition( mNonMaxPos ); @@ -1329,7 +1324,7 @@ void UIWindow::resizeCursor() { worldToControl( Pos ); - const UIControl * Control = Man->getOverControl(); + const UINode * Control = Man->getOverControl(); if ( Control == this ) { if ( Pos.x <= mBorderLeft->getSize().getWidth() ) { diff --git a/src/eepp/ui/uiwinmenu.cpp b/src/eepp/ui/uiwinmenu.cpp index f6abb3845..84e3467ff 100644 --- a/src/eepp/ui/uiwinmenu.cpp +++ b/src/eepp/ui/uiwinmenu.cpp @@ -219,7 +219,7 @@ Uint32 UIWinMenu::onMessage( const UIMessage * Msg ) { } case UIMessage::FocusLoss: { - UIControl * FocusCtrl = UIManager::instance()->getFocusControl(); + UINode * FocusCtrl = UIManager::instance()->getFocusControl(); if ( !isParentOf( FocusCtrl ) && !isPopUpMenuChild( FocusCtrl ) ) { onWidgetFocusLoss(); @@ -256,7 +256,7 @@ UIPopUpMenu * UIWinMenu::getMenuFromButton( UISelectButton * Button ) { return NULL; } -bool UIWinMenu::isPopUpMenuChild( UIControl * Ctrl ) { +bool UIWinMenu::isPopUpMenuChild( UINode * Ctrl ) { for ( WinMenuList::iterator it = mButtons.begin(); it != mButtons.end(); it++ ) { if ( it->second == Ctrl || it->second->isParentOf( Ctrl ) ) { return true; @@ -267,7 +267,7 @@ bool UIWinMenu::isPopUpMenuChild( UIControl * Ctrl ) { } void UIWinMenu::onMenuFocusLoss( const UIEvent * Event ) { - UIControl * FocusCtrl = UIManager::instance()->getFocusControl(); + UINode * FocusCtrl = UIManager::instance()->getFocusControl(); if ( !isParentOf( FocusCtrl ) && !isPopUpMenuChild( FocusCtrl ) ) { onWidgetFocusLoss(); diff --git a/src/eepp/window/backend/SDL2/inputsdl2.cpp b/src/eepp/window/backend/SDL2/inputsdl2.cpp index 5f7c91b59..53fa0e532 100644 --- a/src/eepp/window/backend/SDL2/inputsdl2.cpp +++ b/src/eepp/window/backend/SDL2/inputsdl2.cpp @@ -99,11 +99,7 @@ void InputSDL::update() { String txt = String::fromUtf8( SDLEvent.text.text ); EEEvent.Type = InputEvent::TextInput; - #if SDL_VERSION_ATLEAST(2,0,0) EEEvent.text.timestamp = SDLEvent.text.timestamp; - #else - EEEvent.text.timestamp = Sys::getTicks(); - #endif EEEvent.text.text = txt[0]; processEvent( &EEEvent ); diff --git a/src/eepp/window/backend/SDL2/windowsdl2.cpp b/src/eepp/window/backend/SDL2/windowsdl2.cpp index 60c64c2a4..a322ee1e8 100644 --- a/src/eepp/window/backend/SDL2/windowsdl2.cpp +++ b/src/eepp/window/backend/SDL2/windowsdl2.cpp @@ -164,13 +164,11 @@ bool WindowSDL::create( WindowSettings Settings, ContextSettings Context ) { #endif } #else - #if SDL_VERSION_ATLEAST(2,0,0) if ( GLv_3CP == Context.Version ) { SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2); } - #endif #endif #ifdef SDL2_THREADED_GLCONTEXT @@ -390,9 +388,7 @@ void WindowSDL::setSize( Uint32 Width, Uint32 Height, bool Windowed ) { if ( isWindowed() && !Windowed ) { mWinPos = getPosition(); } else { - #if SDL_VERSION_ATLEAST(2,0,0) SDL_SetWindowFullscreen( mSDLWindow, Windowed ? 0 : SDL_WINDOW_FULLSCREEN ); - #endif } SDL_SetWindowSize( mSDLWindow, Width, Height ); @@ -402,9 +398,7 @@ void WindowSDL::setSize( Uint32 Width, Uint32 Height, bool Windowed ) { setGLConfig(); - #if SDL_VERSION_ATLEAST(2,0,0) SDL_SetWindowFullscreen( mSDLWindow, Windowed ? 0 : SDL_WINDOW_FULLSCREEN ); - #endif } if ( isWindowed() && Windowed ) { @@ -576,12 +570,10 @@ Vector2i WindowSDL::getPosition() { } void WindowSDL::updateDesktopResolution() { -#if SDL_VERSION_ATLEAST(2,0,0) SDL_DisplayMode dpm; SDL_GetDesktopDisplayMode( SDL_GetWindowDisplayIndex( mSDLWindow ), &dpm ); mWindow.DesktopResolution = Sizei( dpm.w, dpm.h ); -#endif } const Sizei& WindowSDL::getDesktopResolution() { @@ -598,11 +590,7 @@ void WindowSDL::startTextInput() { } bool WindowSDL::isTextInputActive() { -#if SDL_VERSION_ATLEAST(2,0,0) return SDL_TRUE == SDL_IsTextInputActive(); -#else - return false; -#endif } void WindowSDL::stopTextInput() { @@ -626,19 +614,11 @@ void WindowSDL::setTextInputRect( Rect& rect ) { } bool WindowSDL::hasScreenKeyboardSupport() { -#if SDL_VERSION_ATLEAST(2,0,0) return SDL_TRUE == SDL_HasScreenKeyboardSupport(); -#else - return false; -#endif } bool WindowSDL::isScreenKeyboardShown() { -#if SDL_VERSION_ATLEAST(2,0,0) return SDL_TRUE == SDL_IsScreenKeyboardShown( mSDLWindow ); -#else - return false; -#endif } }}}} diff --git a/src/test/eetest.cpp b/src/test/eetest.cpp index c4b9bd420..45bbfea30 100644 --- a/src/test/eetest.cpp +++ b/src/test/eetest.cpp @@ -312,12 +312,12 @@ void EETest::createShaders() { void EETest::onWinMouseUp( const UIEvent * Event ) { const UIEventMouse * MEvent = reinterpret_cast ( Event ); - UIControlAnim * CtrlAnim; + UINode * CtrlAnim; if ( Event->getControl()->isType( UI_TYPE_WINDOW ) ) { - CtrlAnim = reinterpret_cast( Event->getControl() ); + CtrlAnim = reinterpret_cast( Event->getControl() ); } else { - CtrlAnim = reinterpret_cast( Event->getControl()->getParent() ); + CtrlAnim = reinterpret_cast( Event->getControl()->getParent() ); } if ( MEvent->getFlags() & EE_BUTTON_WUMASK ) { @@ -560,7 +560,7 @@ void EETest::createUI() { genGrid->setCollumnWidth( 1, 24 ); genGrid->setCollumnWidth( 2, 100 ); - C = reinterpret_cast ( C->getParent() ); + C = reinterpret_cast ( C->getParent() ); //createNewUI(); @@ -598,7 +598,7 @@ void EETest::createNewUI() { relLay = UIRelativeLayout::New(); relLay->setLayoutSizeRules( MATCH_PARENT, MATCH_PARENT ); - UIControlAnim * container = UIControlAnim::New(); + UINode * container = UINode::New(); container->setSize( relLay->getSize() - 32 ); UIScrollView * scrollView = UIScrollView::New(); @@ -910,13 +910,13 @@ void EETest::createCommonDialog() { } static void onWinDragStart( const UIEvent * event ) { - UIControl * ctrl = static_cast( event->getControl() ); + UINode * ctrl = static_cast( event->getControl() ); UIWindow * window = ctrl->isType(UI_TYPE_WINDOW) ? static_cast( ctrl ) : static_cast( ctrl->getWindowContainer()->getParent() ); window->startAlphaAnim( window->getAlpha(), 100, Seconds(0.2f) ); } static void onWinDragStop( const UIEvent * event ) { - UIControl * ctrl = static_cast( event->getControl() ); + UINode * ctrl = static_cast( event->getControl() ); UIWindow * window = ctrl->isType(UI_TYPE_WINDOW) ? static_cast( ctrl ) : static_cast( ctrl->getWindowContainer()->getParent() ); window->startAlphaAnim( window->getAlpha(), 255, Seconds(0.2f) ); } diff --git a/src/test/eetest.hpp b/src/test/eetest.hpp index a90a03de9..6d67c39b8 100644 --- a/src/test/eetest.hpp +++ b/src/test/eetest.hpp @@ -159,7 +159,7 @@ class EETest : private Thread { void createDecoratedWindow(); void createUIThemeTextureAtlas(); - UIControlAnim * C; + UINode * C; UIScrollBar * mScrollBar; UITextView * mTextBoxValue; UISlider * mSlider;