diff --git a/include/eepp/ui/uinode.hpp b/include/eepp/ui/uinode.hpp index 900b46760..d295a6233 100644 --- a/include/eepp/ui/uinode.hpp +++ b/include/eepp/ui/uinode.hpp @@ -5,8 +5,12 @@ #include #include #include +#include #include +namespace EE { namespace Graphics { +class Drawable; +}} namespace EE { namespace Scene { class Action; class ActionManager; @@ -16,6 +20,8 @@ using namespace EE::Scene; namespace EE { namespace UI { class UITheme; +class UISkin; +class UISkinState; class EE_API UINode : public Node { public: @@ -184,10 +190,10 @@ class EE_API UINode : public Node { Vector2f mDpPos; Sizef mDpSize; Uint32 mFlags; - UIState * mSkinState; - UIState * mBackgroundState; - UIState * mForegroundState; - UIState * mBorderState; + UISkinState * mSkinState; + UISkinState * mBackgroundState; + UISkinState * mForegroundState; + UISkinState * mBorderState; Vector2f mDragPoint; Uint32 mDragButton; diff --git a/include/eepp/ui/uiskinstate.hpp b/include/eepp/ui/uiskinstate.hpp new file mode 100644 index 000000000..2770c91e1 --- /dev/null +++ b/include/eepp/ui/uiskinstate.hpp @@ -0,0 +1,29 @@ +#ifndef EE_UI_UISKINSTATE_HPP +#define EE_UI_UISKINSTATE_HPP + +#include + +namespace EE { namespace UI { + +class UISkin; + +class EE_API UISkinState : public UIState { + public: + static UISkinState * New( UISkin * skin ); + + explicit UISkinState( UISkin * Skin ); + + virtual ~UISkinState(); + + UISkin * getSkin() const; + + void draw( const Float& X, const Float& Y, const Float& Width, const Float& Height, const Uint32& Alpha ); + + bool stateExists( const Uint32& State ); + protected: + UISkin * mSkin; +}; + +}} + +#endif diff --git a/include/eepp/ui/uistate.hpp b/include/eepp/ui/uistate.hpp index c13807f61..18accc530 100644 --- a/include/eepp/ui/uistate.hpp +++ b/include/eepp/ui/uistate.hpp @@ -39,11 +39,9 @@ class EE_API UIState { static bool isStateName( const std::string& State ); - static UIState * New( UISkin * skin ); + UIState(); - explicit UIState( UISkin * Skin ); - - ~UIState(); + virtual ~UIState(); const Uint32& getState() const; @@ -53,17 +51,10 @@ class EE_API UIState { void popState( const Uint32& State ); - UISkin * getSkin() const; - - void draw( const Float& X, const Float& Y, const Float& Width, const Float& Height, const Uint32& Alpha ); - - bool stateExists( const Uint32& State ); + virtual bool stateExists( const Uint32& State ) = 0; Uint32 getCurrentState() const; protected: - friend class UINode; - - UISkin * mSkin; Uint32 mState; Uint32 mCurrentState; diff --git a/include/eepp/ui/uitextedit.hpp b/include/eepp/ui/uitextedit.hpp index e5b5ceea8..a53113e8d 100644 --- a/include/eepp/ui/uitextedit.hpp +++ b/include/eepp/ui/uitextedit.hpp @@ -31,8 +31,6 @@ class EE_API UITextEdit : public UIWidget { UIScrollBar * getVScrollBar() const; - virtual void update( const Time& time ); - void setAllowEditing( const bool& allow ); const bool& isEditingAllowed() const; @@ -67,6 +65,8 @@ class EE_API UITextEdit : public UIWidget { virtual void onPaddingChange(); + virtual Uint32 onMessage( const NodeMessage * Msg ); + void onVScrollValueChange( const Event * Event ); void onHScrollValueChange( const Event * Event ); diff --git a/projects/linux/ee.files b/projects/linux/ee.files index fcb18ff40..5268402a4 100644 --- a/projects/linux/ee.files +++ b/projects/linux/ee.files @@ -327,6 +327,7 @@ ../../include/eepp/ui/uiscrollview.hpp ../../include/eepp/ui/uiselectbutton.hpp ../../include/eepp/ui/uiskin.hpp +../../include/eepp/ui/uiskinstate.hpp ../../include/eepp/ui/uisliderbutton.hpp ../../include/eepp/ui/uislider.hpp ../../include/eepp/ui/uispinbox.hpp @@ -725,6 +726,7 @@ ../../src/eepp/ui/uiscrollview.cpp ../../src/eepp/ui/uiselectbutton.cpp ../../src/eepp/ui/uiskin.cpp +../../src/eepp/ui/uiskinstate.cpp ../../src/eepp/ui/uisliderbutton.cpp ../../src/eepp/ui/uislider.cpp ../../src/eepp/ui/uispinbox.cpp diff --git a/projects/linux/ee.includes b/projects/linux/ee.includes index c30b847b4..fd8170a2e 100644 --- a/projects/linux/ee.includes +++ b/projects/linux/ee.includes @@ -8,3 +8,5 @@ ../../include/eepp/audio /usr/include/freetype2/ +../../include/eepp/ui +../../src/eepp/ui diff --git a/src/eepp/scene/node.cpp b/src/eepp/scene/node.cpp index bd61c6a1e..69cde0ac6 100644 --- a/src/eepp/scene/node.cpp +++ b/src/eepp/scene/node.cpp @@ -98,7 +98,7 @@ void Node::messagePost( const NodeMessage * Msg ) { } } -Uint32 Node::onMessage( const NodeMessage * Msg ) { +Uint32 Node::onMessage( const NodeMessage * ) { return 0; } @@ -970,7 +970,7 @@ void Node::writeCtrlFlag( const Uint32& Flag, const Uint32& Val ) { BitOp::setBitFlagValue( &mNodeFlags, Flag, Val ); } -void Node::onParentSizeChange( const Vector2f& SizeChange ) { +void Node::onParentSizeChange( const Vector2f& ) { sendCommonEvent( Event::OnParentSizeChange ); invalidateDraw(); } diff --git a/src/eepp/ui/uinode.cpp b/src/eepp/ui/uinode.cpp index 6f9015e97..8616703a9 100644 --- a/src/eepp/ui/uinode.cpp +++ b/src/eepp/ui/uinode.cpp @@ -19,6 +19,8 @@ #include #include #include +#include +#include namespace EE { namespace UI { @@ -679,7 +681,7 @@ void UINode::internalDraw() { UISkin * UINode::getBackground() { if ( NULL == mBackgroundState ) { - mBackgroundState = UIState::New( UISkin::New() ); + mBackgroundState = UISkinState::New( UISkin::New() ); } return mBackgroundState->getSkin(); @@ -687,7 +689,7 @@ UISkin * UINode::getBackground() { UISkin * UINode::getForeground() { if ( NULL == mForegroundState ) { - mForegroundState = UIState::New( UISkin::New() ); + mForegroundState = UISkinState::New( UISkin::New() ); } return mForegroundState->getSkin(); @@ -695,7 +697,7 @@ UISkin * UINode::getForeground() { UISkin * UINode::getBorder() { if ( NULL == mBorderState ) { - mBorderState = UIState::New( UISkin::New() ); + mBorderState = UISkinState::New( UISkin::New() ); } return mBorderState->getSkin(); @@ -728,7 +730,7 @@ UINode * UINode::setSkin( const UISkin& Skin ) { UISkin * SkinCopy = const_cast( &Skin )->clone(); - mSkinState = UIState::New( SkinCopy ); + mSkinState = UISkinState::New( SkinCopy ); onThemeLoaded(); @@ -748,7 +750,7 @@ UINode * UINode::setSkin( UISkin * skin ) { removeSkin(); - mSkinState = UIState::New( skin ); + mSkinState = UISkinState::New( skin ); mSkinState->setState( InitialState ); onThemeLoaded(); @@ -955,16 +957,16 @@ void UINode::setDragPoint( const Vector2f& Point ) { mDragPoint = Point; } -Uint32 UINode::onDrag( const Vector2f& Pos ) { +Uint32 UINode::onDrag( const Vector2f& ) { return 1; } -Uint32 UINode::onDragStart( const Vector2i& Pos ) { +Uint32 UINode::onDragStart( const Vector2i& ) { sendCommonEvent( Event::OnDragStart ); return 1; } -Uint32 UINode::onDragStop( const Vector2i& Pos ) { +Uint32 UINode::onDragStop( const Vector2i& ) { sendCommonEvent( Event::OnDragStop ); return 1; } diff --git a/src/eepp/ui/uiskinstate.cpp b/src/eepp/ui/uiskinstate.cpp new file mode 100644 index 000000000..217c63f45 --- /dev/null +++ b/src/eepp/ui/uiskinstate.cpp @@ -0,0 +1,37 @@ +#include +#include + +namespace EE { namespace UI { + +UISkinState * UISkinState::New( UISkin * skin ) { + return eeNew( UISkinState, ( skin ) ); +} + +UISkinState::UISkinState( UISkin * Skin ) : + mSkin( Skin ) +{ + eeASSERT( NULL != mSkin ); +} + +UISkinState::~UISkinState() { +} + + +UISkin * UISkinState::getSkin() const { + return mSkin; +} + +bool UISkinState::stateExists( const Uint32& State ) { + return mSkin->hasDrawableState( State ); +} + +void UISkinState::draw( const Float& X, const Float& Y, const Float& Width, const Float& Height, const Uint32& Alpha ) { + if ( NULL != mSkin ) { + mSkin->setState( mCurrentState ); + mSkin->setAlpha( Alpha ); + mSkin->draw( Vector2f( X, Y ), Sizef( Width, Height ) ); + } +} + + +}} diff --git a/src/eepp/ui/uislider.cpp b/src/eepp/ui/uislider.cpp index 21be2da78..8636c6a45 100644 --- a/src/eepp/ui/uislider.cpp +++ b/src/eepp/ui/uislider.cpp @@ -399,10 +399,9 @@ void UISlider::onAlphaChange() { mSlider->setAlpha( mAlpha ); } -Uint32 UISlider::onMessage(const NodeMessage * Msg) -{ +Uint32 UISlider::onMessage(const NodeMessage * Msg) { switch ( Msg->getMsg() ) { - case NodeMessage::Click: + case NodeMessage::MouseUp: { manageClick( Msg->getFlags() ); return 1; diff --git a/src/eepp/ui/uistate.cpp b/src/eepp/ui/uistate.cpp index dfdf301f2..1068bee7c 100644 --- a/src/eepp/ui/uistate.cpp +++ b/src/eepp/ui/uistate.cpp @@ -49,29 +49,15 @@ bool UIState::isStateName( const std::string& State ) { return false; } -UIState * UIState::New( UISkin * skin ) { - return eeNew( UIState, ( skin ) ); -} - -UIState::UIState( UISkin * Skin ) : - mSkin( Skin ), +UIState::UIState() : mState(StateFlagNormal), mCurrentState(StateFlagNormal) { - eeASSERT( NULL != mSkin ); } UIState::~UIState() { } -void UIState::draw( const Float& X, const Float& Y, const Float& Width, const Float& Height, const Uint32& Alpha ) { - if ( NULL != mSkin ) { - mSkin->setState( mCurrentState ); - mSkin->setAlpha( Alpha ); - mSkin->draw( Vector2f( X, Y ), Sizef( Width, Height ) ); - } -} - const Uint32& UIState::getState() const { return mState; } @@ -100,14 +86,6 @@ void UIState::popState(const Uint32 & State) { } } -UISkin * UIState::getSkin() const { - return mSkin; -} - -bool UIState::stateExists( const Uint32& State ) { - return mSkin->hasDrawableState( State ); -} - Uint32 UIState::getCurrentState() const { return mCurrentState; } @@ -126,4 +104,3 @@ void UIState::updateState() { } }} - diff --git a/src/eepp/ui/uitextedit.cpp b/src/eepp/ui/uitextedit.cpp index dc6bc5da6..c17429f3c 100644 --- a/src/eepp/ui/uitextedit.cpp +++ b/src/eepp/ui/uitextedit.cpp @@ -258,12 +258,12 @@ void UITextEdit::autoPadding() { } } -void UITextEdit::onVScrollValueChange( const Event * Event ) { +void UITextEdit::onVScrollValueChange( const Event * ) { if ( !mSkipValueChange ) fixScroll(); } -void UITextEdit::onHScrollValueChange( const Event * Event ) { +void UITextEdit::onHScrollValueChange( const Event * ) { if ( !mSkipValueChange ) fixScroll(); } @@ -347,7 +347,7 @@ void UITextEdit::onInputSizeChange( const Event * Event ) { fixScrollToCursor(); } -void UITextEdit::onCursorPosChange( const Event * Event ) { +void UITextEdit::onCursorPosChange( const Event * ) { fixScrollToCursor(); } @@ -404,15 +404,20 @@ void UITextEdit::shrinkText( const Uint32& Width ) { } } -void UITextEdit::update( const Time& time ) { - UIWidget::update( time ); +Uint32 UITextEdit::onMessage(const NodeMessage * Msg) { + switch ( Msg->getMsg() ) { + case NodeMessage::MouseUp: + { + if ( NULL != getEventDispatcher() && mTextInput->isEnabled() && mTextInput->isVisible() && mTextInput->isMouseOver() && mVScrollBar->isVisible() ) { + if ( Msg->getFlags() & EE_BUTTONS_WUWD ) + mVScrollBar->getSlider()->manageClick( Msg->getFlags() ); + } - if ( NULL != getEventDispatcher() && mTextInput->isEnabled() && mTextInput->isVisible() && mTextInput->isMouseOver() && mVScrollBar->isVisible() ) { - Uint32 Flags = getEventDispatcher()->getClickTrigger(); - - if ( Flags & EE_BUTTONS_WUWD ) - mVScrollBar->getSlider()->manageClick( Flags ); + return 1; + } } + + return 0; } void UITextEdit::setAllowEditing( const bool& allow ) {