mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-08-13 04:42:12 +03:00
UI Scene Node now uses scheduled update by default.
--HG-- branch : dev
This commit is contained in:
@@ -29,6 +29,7 @@ using namespace EE::Scene;
|
||||
namespace EE { namespace Scene {
|
||||
|
||||
enum NODE_FLAGS_VALUES {
|
||||
NODE_FLAG_SCHEDULED_UPDATE = (1<<0),
|
||||
NODE_FLAG_VIEW_DIRTY = (1<<1),
|
||||
NODE_FLAG_POSITION_DIRTY = (1<<2),
|
||||
NODE_FLAG_POLYGON_DIRTY = (1<<3),
|
||||
@@ -469,6 +470,12 @@ class EE_API Node : public Transformable {
|
||||
SceneNode * findSceneNode();
|
||||
|
||||
void updateDrawInvalidator( bool force = false );
|
||||
|
||||
void subscribeScheduledUpdate();
|
||||
|
||||
void unsubscribeScheduledUpdate();
|
||||
|
||||
bool isSubscribedForScheduledUpdate();
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
@@ -103,6 +103,14 @@ class EE_API SceneNode : public Node {
|
||||
void unsubscribeScheduledUpdate( Node * node );
|
||||
|
||||
bool isSubscribedForScheduledUpdate( Node * node );
|
||||
|
||||
void addMouseOverNode( Node * node );
|
||||
|
||||
void removeMouseOverNode( Node * node );
|
||||
|
||||
const bool& getUpdateAllChilds() const;
|
||||
|
||||
void setUpdateAllChilds( const bool& updateAllChilds );
|
||||
protected:
|
||||
friend class Node;
|
||||
typedef std::list<Node*> CloseList;
|
||||
@@ -115,6 +123,7 @@ class EE_API SceneNode : public Node {
|
||||
bool mFrameBufferBound;
|
||||
bool mUseInvalidation;
|
||||
bool mUseGlobalCursors;
|
||||
bool mUpdateAllChilds;
|
||||
Int32 mResizeCb;
|
||||
bool mDrawDebugData;
|
||||
bool mDrawBoxes;
|
||||
@@ -127,6 +136,7 @@ class EE_API SceneNode : public Node {
|
||||
Time mElapsed;
|
||||
std::list<Node*> mScheduledUpdate;
|
||||
std::list<Node*> mScheduledUpdateRemove;
|
||||
std::list<Node*> mMouseOverNodes;
|
||||
|
||||
virtual void onSizeChange();
|
||||
|
||||
|
||||
@@ -40,11 +40,10 @@ class EE_API TextureAtlasEditor {
|
||||
UINode(),
|
||||
mTGEditor( TGEditor )
|
||||
{
|
||||
getSceneNode()->subscribeScheduledUpdate( this );
|
||||
subscribeScheduledUpdate();
|
||||
}
|
||||
|
||||
~UITGEUpdater() {
|
||||
getSceneNode()->unsubscribeScheduledUpdate( this );
|
||||
}
|
||||
|
||||
virtual void scheduledUpdate( const Time& ) { mTGEditor->update(); }
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#define EE_UITUIITEMCONTAINER_HPP
|
||||
|
||||
#include <eepp/ui/uinode.hpp>
|
||||
#include <eepp/scene/scenenode.hpp>
|
||||
|
||||
namespace EE { namespace UI {
|
||||
|
||||
@@ -64,6 +65,7 @@ Node * UIItemContainer<TContainer>::overFind( const Vector2f& Point ) {
|
||||
|
||||
if ( mWorldBounds.contains( Point ) && mPoly.pointInside( Point ) ) {
|
||||
writeNodeFlag( NODE_FLAG_MOUSEOVER_ME_OR_CHILD, 1 );
|
||||
mSceneNode->addMouseOverNode( this );
|
||||
|
||||
for ( Uint32 i = tParent->mVisibleFirst; i <= tParent->mVisibleLast; i++ ) {
|
||||
if ( NULL != tParent->mItems[i] ) {
|
||||
|
||||
@@ -29,6 +29,8 @@ UIMap::UIMap( UITheme * Theme, TileMap * Map ) :
|
||||
mSelPoint( false ),
|
||||
mTileBox( NULL )
|
||||
{
|
||||
subscribeScheduledUpdate();
|
||||
|
||||
if ( NULL == Map ) {
|
||||
mMap = eeNew( TileMap, () );
|
||||
}
|
||||
@@ -99,8 +101,8 @@ void UIMap::updateScreenPos() {
|
||||
}
|
||||
}
|
||||
|
||||
void UIMap::update( const Time& time ) {
|
||||
UIWindow::update( time );
|
||||
void UIMap::scheduledUpdate( const Time& time ) {
|
||||
UIWindow::scheduledUpdate( time );
|
||||
|
||||
if ( NULL != mMap ) {
|
||||
invalidate();
|
||||
|
||||
@@ -43,7 +43,7 @@ class EE_API UIMap : public UIWindow {
|
||||
|
||||
virtual void draw();
|
||||
|
||||
virtual void update( const Time& time );
|
||||
virtual void scheduledUpdate( const Time& time );
|
||||
|
||||
TileMap * Map() const;
|
||||
|
||||
|
||||
@@ -35,6 +35,9 @@ Node::~Node() {
|
||||
if ( NULL != mSceneNode && mSceneNode != this && NULL != mSceneNode->getActionManager() )
|
||||
mSceneNode->getActionManager()->removeAllActionsFromTarget( this );
|
||||
|
||||
if ( NULL != mSceneNode && ( mNodeFlags & NODE_FLAG_SCHEDULED_UPDATE ) )
|
||||
mSceneNode->unsubscribeScheduledUpdate( this );
|
||||
|
||||
childDeleteAll();
|
||||
|
||||
if ( NULL != mParentCtrl )
|
||||
@@ -211,6 +214,24 @@ void Node::updateDrawInvalidator( bool force ) {
|
||||
}
|
||||
}
|
||||
|
||||
void Node::subscribeScheduledUpdate() {
|
||||
if ( NULL != mSceneNode ) {
|
||||
mSceneNode->subscribeScheduledUpdate( this );
|
||||
writeNodeFlag( NODE_FLAG_SCHEDULED_UPDATE, 1 );
|
||||
}
|
||||
}
|
||||
|
||||
void Node::unsubscribeScheduledUpdate() {
|
||||
if ( NULL != mSceneNode ) {
|
||||
mSceneNode->unsubscribeScheduledUpdate( this );
|
||||
writeNodeFlag( NODE_FLAG_SCHEDULED_UPDATE, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
bool Node::isSubscribedForScheduledUpdate() {
|
||||
return 0 != ( mNodeFlags & NODE_FLAG_SCHEDULED_UPDATE );
|
||||
}
|
||||
|
||||
Node * Node::setParent( Node * parent ) {
|
||||
eeASSERT( NULL != parent );
|
||||
|
||||
@@ -755,6 +776,7 @@ Node * Node::overFind( const Vector2f& Point ) {
|
||||
|
||||
if ( mWorldBounds.contains( Point ) && mPoly.pointInside( Point ) ) {
|
||||
writeNodeFlag( NODE_FLAG_MOUSEOVER_ME_OR_CHILD, 1 );
|
||||
mSceneNode->addMouseOverNode( this );
|
||||
|
||||
Node * ChildLoop = mChildLast;
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ SceneNode::SceneNode( EE::Window::Window * window ) :
|
||||
mFrameBufferBound( false ),
|
||||
mUseInvalidation( false ),
|
||||
mUseGlobalCursors( true ),
|
||||
mUpdateAllChilds( true ),
|
||||
mResizeCb( -1 ),
|
||||
mDrawDebugData( false ),
|
||||
mDrawBoxes( false ),
|
||||
@@ -143,7 +144,14 @@ void SceneNode::update( const Time& time ) {
|
||||
(*it)->scheduledUpdate( time );
|
||||
}
|
||||
|
||||
Node::update( time );
|
||||
if ( mUpdateAllChilds ) {
|
||||
Node::update( time );
|
||||
} else {
|
||||
for ( auto it = mMouseOverNodes.begin(); it != mMouseOverNodes.end(); ++it )
|
||||
(*it)->writeNodeFlag( NODE_FLAG_MOUSEOVER_ME_OR_CHILD, 0 );
|
||||
}
|
||||
|
||||
mMouseOverNodes.clear();
|
||||
}
|
||||
|
||||
void SceneNode::onSizeChange() {
|
||||
@@ -424,4 +432,20 @@ bool SceneNode::isSubscribedForScheduledUpdate( Node * node ) {
|
||||
return std::find( mScheduledUpdate.begin(), mScheduledUpdate.end(), node ) != mScheduledUpdate.end();
|
||||
}
|
||||
|
||||
void SceneNode::addMouseOverNode( Node * node ) {
|
||||
mMouseOverNodes.push_back( node );
|
||||
}
|
||||
|
||||
void SceneNode::removeMouseOverNode(Node * node) {
|
||||
mMouseOverNodes.remove( node );
|
||||
}
|
||||
|
||||
const bool& SceneNode::getUpdateAllChilds() const {
|
||||
return mUpdateAllChilds;
|
||||
}
|
||||
|
||||
void SceneNode::setUpdateAllChilds( const bool& updateAllChilds ) {
|
||||
mUpdateAllChilds = updateAllChilds;
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
@@ -19,8 +19,7 @@ TextureAtlasTextureRegionEditor::TextureAtlasTextureRegionEditor( TextureAtlasEd
|
||||
return;
|
||||
}
|
||||
|
||||
if ( NULL != mSceneNode )
|
||||
mSceneNode->subscribeScheduledUpdate( this );
|
||||
subscribeScheduledUpdate();
|
||||
|
||||
mTheme = UIThemeManager::instance()->getDefaultTheme();
|
||||
|
||||
@@ -41,8 +40,6 @@ TextureAtlasTextureRegionEditor::TextureAtlasTextureRegionEditor( TextureAtlasEd
|
||||
}
|
||||
|
||||
TextureAtlasTextureRegionEditor::~TextureAtlasTextureRegionEditor() {
|
||||
if ( NULL != mSceneNode )
|
||||
mSceneNode->unsubscribeScheduledUpdate( this );
|
||||
}
|
||||
|
||||
void TextureAtlasTextureRegionEditor::draw() {
|
||||
|
||||
@@ -22,8 +22,7 @@ UILoader::UILoader() :
|
||||
mOp(1),
|
||||
mIndeterminate(true)
|
||||
{
|
||||
if ( NULL != mSceneNode )
|
||||
mSceneNode->subscribeScheduledUpdate( this );
|
||||
subscribeScheduledUpdate();
|
||||
|
||||
mArc.setFillMode( DRAW_FILL );
|
||||
mCircle.setFillMode( DRAW_FILL );
|
||||
@@ -31,8 +30,6 @@ UILoader::UILoader() :
|
||||
}
|
||||
|
||||
UILoader::~UILoader() {
|
||||
if ( NULL != mSceneNode )
|
||||
mSceneNode->unsubscribeScheduledUpdate( this );
|
||||
}
|
||||
|
||||
Uint32 UILoader::getType() const {
|
||||
|
||||
@@ -16,8 +16,7 @@ UIProgressBar::UIProgressBar() :
|
||||
mTotalSteps( 100.f ),
|
||||
mFillerSkin( NULL )
|
||||
{
|
||||
if ( NULL != mSceneNode )
|
||||
mSceneNode->subscribeScheduledUpdate( this );
|
||||
subscribeScheduledUpdate();
|
||||
|
||||
setFlags( UI_AUTO_PADDING | UI_AUTO_SIZE );
|
||||
|
||||
@@ -32,8 +31,6 @@ UIProgressBar::UIProgressBar() :
|
||||
}
|
||||
|
||||
UIProgressBar::~UIProgressBar() {
|
||||
if ( NULL != mSceneNode )
|
||||
mSceneNode->unsubscribeScheduledUpdate( this );
|
||||
}
|
||||
|
||||
Uint32 UIProgressBar::getType() const {
|
||||
|
||||
@@ -18,6 +18,9 @@ UISceneNode::UISceneNode( EE::Window::Window * window ) :
|
||||
SceneNode( window ),
|
||||
mIsLoading( false )
|
||||
{
|
||||
// Update only UI elements that requires it.
|
||||
setUpdateAllChilds( false );
|
||||
|
||||
mNodeFlags |= NODE_FLAG_UISCENENODE | NODE_FLAG_OVER_FIND_ALLOWED;
|
||||
|
||||
setEventDispatcher( UIEventDispatcher::New( this ) );
|
||||
|
||||
@@ -16,8 +16,7 @@ UISpinBox::UISpinBox() :
|
||||
mValue( 0 ),
|
||||
mClickStep( 1.f )
|
||||
{
|
||||
if ( NULL != mSceneNode )
|
||||
mSceneNode->subscribeScheduledUpdate( this );
|
||||
subscribeScheduledUpdate();
|
||||
|
||||
mInput = UITextInput::NewWithTag( "spinbox::input" );
|
||||
mInput->setVisible( true );
|
||||
@@ -46,8 +45,6 @@ UISpinBox::UISpinBox() :
|
||||
}
|
||||
|
||||
UISpinBox::~UISpinBox() {
|
||||
if ( NULL != mSceneNode )
|
||||
mSceneNode->unsubscribeScheduledUpdate( this );
|
||||
}
|
||||
|
||||
Uint32 UISpinBox::getType() const {
|
||||
|
||||
@@ -17,14 +17,10 @@ UISprite::UISprite() :
|
||||
mAlignOffset(0,0),
|
||||
mTextureRegionLast(NULL)
|
||||
{
|
||||
if ( NULL != mSceneNode )
|
||||
mSceneNode->subscribeScheduledUpdate( this );
|
||||
subscribeScheduledUpdate();
|
||||
}
|
||||
|
||||
UISprite::~UISprite() {
|
||||
if ( NULL != mSceneNode )
|
||||
mSceneNode->unsubscribeScheduledUpdate( this );
|
||||
|
||||
if ( deallocSprite() )
|
||||
eeSAFE_DELETE( mSprite );
|
||||
}
|
||||
|
||||
@@ -23,8 +23,7 @@ UITextInput::UITextInput( const std::string& tag ) :
|
||||
mAllowEditing( true ),
|
||||
mShowingWait( true )
|
||||
{
|
||||
if ( NULL != mSceneNode )
|
||||
mSceneNode->subscribeScheduledUpdate( this );
|
||||
subscribeScheduledUpdate();
|
||||
|
||||
setFlags( UI_AUTO_PADDING | UI_AUTO_SIZE | UI_TEXT_SELECTION_ENABLED );
|
||||
clipEnable();
|
||||
@@ -43,8 +42,6 @@ UITextInput::UITextInput() :
|
||||
{}
|
||||
|
||||
UITextInput::~UITextInput() {
|
||||
if ( NULL != mSceneNode )
|
||||
mSceneNode->unsubscribeScheduledUpdate( this );
|
||||
}
|
||||
|
||||
Uint32 UITextInput::getType() const {
|
||||
|
||||
@@ -12,8 +12,7 @@ UITouchDragableWidget::UITouchDragableWidget( const std::string& tag ) :
|
||||
UIWidget( tag ),
|
||||
mTouchDragDeceleration( 5.f, 5.f )
|
||||
{
|
||||
if ( NULL != mSceneNode )
|
||||
mSceneNode->subscribeScheduledUpdate( this );
|
||||
subscribeScheduledUpdate();
|
||||
}
|
||||
|
||||
UITouchDragableWidget::UITouchDragableWidget() :
|
||||
@@ -21,8 +20,6 @@ UITouchDragableWidget::UITouchDragableWidget() :
|
||||
{}
|
||||
|
||||
UITouchDragableWidget::~UITouchDragableWidget() {
|
||||
if ( NULL != mSceneNode )
|
||||
mSceneNode->unsubscribeScheduledUpdate( this );
|
||||
}
|
||||
|
||||
Uint32 UITouchDragableWidget::getType() const {
|
||||
|
||||
@@ -44,8 +44,7 @@ UIWindow::UIWindow( UIWindow::WindowBaseContainerType type, const StyleConfig& w
|
||||
mResizeType( RESIZE_NONE ),
|
||||
mFrameBufferBound( false )
|
||||
{
|
||||
if ( NULL != mSceneNode )
|
||||
mSceneNode->subscribeScheduledUpdate( this );
|
||||
subscribeScheduledUpdate();
|
||||
|
||||
mNodeFlags |= NODE_FLAG_WINDOW | NODE_FLAG_VIEW_DIRTY;
|
||||
|
||||
@@ -83,9 +82,6 @@ UIWindow::UIWindow( UIWindow::WindowBaseContainerType type, const StyleConfig& w
|
||||
}
|
||||
|
||||
UIWindow::~UIWindow() {
|
||||
if ( NULL != mSceneNode )
|
||||
mSceneNode->unsubscribeScheduledUpdate( this );
|
||||
|
||||
if ( NULL != getUISceneNode() && !SceneManager::instance()->isShootingDown() ) {
|
||||
getUISceneNode()->windowRemove( this );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user