mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-08-13 04:42:12 +03:00
UIState now is an interface. UISkinState implements Skin states.
Some minor fixes. --HG-- branch : dev-stateful-drawable
This commit is contained in:
@@ -5,8 +5,12 @@
|
||||
#include <eepp/ui/uihelper.hpp>
|
||||
#include <eepp/ui/uistate.hpp>
|
||||
#include <eepp/ui/uiskin.hpp>
|
||||
#include <eepp/ui/uiskinstate.hpp>
|
||||
#include <eepp/scene/node.hpp>
|
||||
|
||||
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;
|
||||
|
||||
|
||||
29
include/eepp/ui/uiskinstate.hpp
Normal file
29
include/eepp/ui/uiskinstate.hpp
Normal file
@@ -0,0 +1,29 @@
|
||||
#ifndef EE_UI_UISKINSTATE_HPP
|
||||
#define EE_UI_UISKINSTATE_HPP
|
||||
|
||||
#include <eepp/ui/uistate.hpp>
|
||||
|
||||
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
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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 );
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -8,3 +8,5 @@
|
||||
../../include/eepp/audio
|
||||
/usr/include/freetype2/
|
||||
|
||||
../../include/eepp/ui
|
||||
../../src/eepp/ui
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -19,6 +19,8 @@
|
||||
#include <eepp/scene/actions/move.hpp>
|
||||
#include <eepp/scene/scenemanager.hpp>
|
||||
#include <eepp/ui/uiscenenode.hpp>
|
||||
#include <eepp/ui/uiskin.hpp>
|
||||
#include <eepp/ui/uiskinstate.hpp>
|
||||
|
||||
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<UISkin*>( &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;
|
||||
}
|
||||
|
||||
37
src/eepp/ui/uiskinstate.cpp
Normal file
37
src/eepp/ui/uiskinstate.cpp
Normal file
@@ -0,0 +1,37 @@
|
||||
#include <eepp/ui/uiskinstate.hpp>
|
||||
#include <eepp/ui/uiskin.hpp>
|
||||
|
||||
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 ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}}
|
||||
@@ -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;
|
||||
|
||||
@@ -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() {
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
|
||||
@@ -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 ) {
|
||||
|
||||
Reference in New Issue
Block a user