mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-10-25 15:53:11 +03:00
Refactorized ResourceManager.
Fixes for dirty layouts updates. Fixed CSS animations issues. Minor layouts refactor and fixes (WIP).
This commit is contained in:
@@ -52,6 +52,7 @@ class EE_API String {
|
||||
typedef StringType::const_iterator ConstIterator; //! Constant iterator type
|
||||
typedef StringType::reverse_iterator ReverseIterator; //! Reverse Iterator type
|
||||
typedef StringType::const_reverse_iterator ConstReverseIterator; //! Constant iterator type
|
||||
typedef Uint32 HashType;
|
||||
|
||||
static const std::size_t InvalidPos; ///< Represents an invalid position in the string
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace EE { namespace Graphics {
|
||||
/** @brief The Texture Atlas Manager is a singleton class that manages all the instances of Texture
|
||||
Atlases instanciated. Releases the Texture Atlases instances automatically. So the user doesn't
|
||||
need to release any Texture Atlas instance. */
|
||||
class EE_API TextureAtlasManager : public ResourceManager<TextureAtlas> {
|
||||
class EE_API TextureAtlasManager : public ResourceManagerMulti<TextureAtlas> {
|
||||
SINGLETON_DECLARE_HEADERS( TextureAtlasManager )
|
||||
|
||||
public:
|
||||
|
||||
@@ -2,62 +2,62 @@
|
||||
#define EE_SYSTEMTRESOURCEMANAGER_HPP
|
||||
|
||||
#include <eepp/core/string.hpp>
|
||||
#include <list>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace EE { namespace System {
|
||||
|
||||
/** @brief A simple resource manager. It keeps a list of the resources, and free the instances of
|
||||
* the resources when the manager is closed. Resources must have getId() and getName() properties.
|
||||
* getId() is the string hash of getName().
|
||||
* the resources when the manager is closed. Resources must implement getId() and getName()
|
||||
* properties getId() is the string hash of getName().
|
||||
*/
|
||||
template <class T> class ResourceManager {
|
||||
public:
|
||||
/** @param UniqueId Indicates if the resources id must be unique */
|
||||
ResourceManager( bool UniqueId = true );
|
||||
ResourceManager();
|
||||
|
||||
/** @brief The destructor will call destroy() and destroy all the resources added to the manager
|
||||
*/
|
||||
virtual ~ResourceManager();
|
||||
|
||||
/** @brief Add the resource to the resource manager
|
||||
** @param Resource The resource to be managed by the manager */
|
||||
virtual T* add( T* Resource );
|
||||
** @param resource The resource to be managed by the manager */
|
||||
virtual T* add( T* resource );
|
||||
|
||||
/** @brief Removes the resource from the manager
|
||||
** @param Resource The resource to remove
|
||||
** @param Delete Indicates if the resource must be destroyed after being removed from the
|
||||
** @param resource The resource to remove
|
||||
** @param remove Indicates if the resource must be destroyed after being removed from the
|
||||
*manager */
|
||||
bool remove( T* Resource, bool Delete = true );
|
||||
bool remove( T* resource, bool remove = true );
|
||||
|
||||
/** @brief Removes the resource by its id
|
||||
** @see remove */
|
||||
bool removeById( const Uint32& Id, bool Delete = true );
|
||||
bool removeById( const String::HashType& id, bool remove = true );
|
||||
|
||||
/** @brief Removes the resource by its name
|
||||
** @see remove */
|
||||
bool removeByName( const std::string& Name, bool Delete = true );
|
||||
bool removeByName( const std::string& name, bool remove = true );
|
||||
|
||||
/** @returns A resource by its name. If not found returns NULL. */
|
||||
T* getByName( const std::string& Name );
|
||||
T* getByName( const std::string& name );
|
||||
|
||||
/** @returns A resource by its id. If not found returns NULL. */
|
||||
T* getById( const Uint32& Id );
|
||||
T* getById( const String::HashType& id );
|
||||
|
||||
/** @returns The number of resources added */
|
||||
Uint32 getCount();
|
||||
|
||||
/** @returns The number of resources that where added with the indicated name. */
|
||||
Uint32 setCount( const std::string& Name );
|
||||
Uint32 getCount( const std::string& name );
|
||||
|
||||
/** @returns The number of resources that where added with the indicated id. */
|
||||
Uint32 setCount( const Uint32& Id );
|
||||
Uint32 getCount( const String::HashType& id );
|
||||
|
||||
/** @returns If the resource name exists in the resources list. */
|
||||
bool exists( const std::string& Name );
|
||||
bool exists( const std::string& name );
|
||||
|
||||
/** @returns If the resource id exists in the resources list. */
|
||||
bool existsId( const Uint32& Id );
|
||||
bool existsId( const String::HashType& id );
|
||||
|
||||
/** @brief Destroy all the resources added ( delete the instances of the resources ) */
|
||||
void destroy();
|
||||
@@ -66,20 +66,17 @@ template <class T> class ResourceManager {
|
||||
void printNames();
|
||||
|
||||
/** @returns A reference to the resources list of the manager. */
|
||||
std::list<T*>& getResources();
|
||||
std::unordered_map<String::HashType, T*>& getResources();
|
||||
|
||||
/** @brief Indicates if the resource manager is destroy the resources. */
|
||||
const bool& isDestroying() const;
|
||||
|
||||
protected:
|
||||
std::list<T*> mResources;
|
||||
bool mUniqueId;
|
||||
std::unordered_map<String::HashType, T*> mResources;
|
||||
bool mIsDestroying;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
ResourceManager<T>::ResourceManager( bool UniqueId ) :
|
||||
mUniqueId( UniqueId ), mIsDestroying( false ) {}
|
||||
template <class T> ResourceManager<T>::ResourceManager() : mIsDestroying( false ) {}
|
||||
|
||||
template <class T> const bool& ResourceManager<T>::isDestroying() const {
|
||||
return mIsDestroying;
|
||||
@@ -90,12 +87,11 @@ template <class T> ResourceManager<T>::~ResourceManager() {
|
||||
}
|
||||
|
||||
template <class T> void ResourceManager<T>::destroy() {
|
||||
typename std::list<T*>::iterator it;
|
||||
|
||||
mIsDestroying = true;
|
||||
|
||||
for ( it = mResources.begin(); it != mResources.end(); it++ ) {
|
||||
eeSAFE_DELETE( ( *it ) );
|
||||
for ( auto& it : mResources ) {
|
||||
T* res = it.second;
|
||||
eeSAFE_DELETE( res );
|
||||
}
|
||||
|
||||
mResources.clear();
|
||||
@@ -103,45 +99,40 @@ template <class T> void ResourceManager<T>::destroy() {
|
||||
mIsDestroying = false;
|
||||
}
|
||||
|
||||
template <class T> std::list<T*>& ResourceManager<T>::getResources() {
|
||||
template <class T> std::unordered_map<String::HashType, T*>& ResourceManager<T>::getResources() {
|
||||
return mResources;
|
||||
}
|
||||
|
||||
template <class T> T* ResourceManager<T>::add( T* Resource ) {
|
||||
if ( NULL != Resource ) {
|
||||
if ( mUniqueId ) {
|
||||
Uint32 c = setCount( Resource->getId() );
|
||||
template <class T> T* ResourceManager<T>::add( T* resource ) {
|
||||
if ( NULL != resource ) {
|
||||
if ( !existsId( resource->getId() ) ) {
|
||||
mResources[resource->getId()] = resource;
|
||||
|
||||
if ( 0 == c ) {
|
||||
mResources.push_back( Resource );
|
||||
|
||||
return Resource;
|
||||
} else {
|
||||
std::string RealName( Resource->getName() );
|
||||
|
||||
while ( setCount( Resource->getId() ) ) {
|
||||
c++;
|
||||
Resource->setName( RealName + String::toStr( c ) );
|
||||
}
|
||||
|
||||
return add( Resource );
|
||||
}
|
||||
return resource;
|
||||
} else {
|
||||
mResources.push_back( Resource );
|
||||
std::string realName( resource->getName() );
|
||||
Uint32 c = 1;
|
||||
|
||||
return Resource;
|
||||
while ( existsId( resource->getId() ) ) {
|
||||
c++;
|
||||
resource->setName( realName + String::toStr( c ) );
|
||||
}
|
||||
|
||||
return add( resource );
|
||||
}
|
||||
}
|
||||
|
||||
mResources[resource->getId()] = resource;
|
||||
return resource;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
template <class T> bool ResourceManager<T>::remove( T* Resource, bool Delete ) {
|
||||
if ( NULL != Resource ) {
|
||||
mResources.remove( Resource );
|
||||
template <class T> bool ResourceManager<T>::remove( T* resource, bool remove ) {
|
||||
if ( NULL != resource ) {
|
||||
mResources.erase( resource->getId() );
|
||||
|
||||
if ( Delete )
|
||||
eeSAFE_DELETE( Resource );
|
||||
if ( remove )
|
||||
eeSAFE_DELETE( resource );
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -149,56 +140,34 @@ template <class T> bool ResourceManager<T>::remove( T* Resource, bool Delete ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
template <class T> bool ResourceManager<T>::removeById( const Uint32& Id, bool Delete ) {
|
||||
return remove( getById( Id ), Delete );
|
||||
template <class T> bool ResourceManager<T>::removeById( const String::HashType& id, bool _remove ) {
|
||||
return remove( getById( id ), _remove );
|
||||
}
|
||||
|
||||
template <class T> bool ResourceManager<T>::removeByName( const std::string& Name, bool Delete ) {
|
||||
return remove( getByName( Name ), Delete );
|
||||
template <class T> bool ResourceManager<T>::removeByName( const std::string& name, bool _remove ) {
|
||||
return remove( getByName( name ), _remove );
|
||||
}
|
||||
|
||||
template <class T> bool ResourceManager<T>::exists( const std::string& Name ) {
|
||||
return existsId( String::hash( Name ) );
|
||||
template <class T> bool ResourceManager<T>::exists( const std::string& name ) {
|
||||
return existsId( String::hash( name ) );
|
||||
}
|
||||
|
||||
template <class T> bool ResourceManager<T>::existsId( const Uint32& Id ) {
|
||||
typename std::list<T*>::iterator it;
|
||||
|
||||
for ( it = mResources.begin(); it != mResources.end(); it++ )
|
||||
if ( ( *it )->getId() == Id )
|
||||
return true;
|
||||
|
||||
return false;
|
||||
template <class T> bool ResourceManager<T>::existsId( const String::HashType& id ) {
|
||||
return mResources.find( id ) != mResources.end();
|
||||
}
|
||||
|
||||
template <class T> T* ResourceManager<T>::getByName( const std::string& Name ) {
|
||||
return getById( String::hash( Name ) );
|
||||
template <class T> T* ResourceManager<T>::getByName( const std::string& name ) {
|
||||
return getById( String::hash( name ) );
|
||||
}
|
||||
|
||||
template <class T> T* ResourceManager<T>::getById( const Uint32& id ) {
|
||||
typename std::list<T*>::reverse_iterator it;
|
||||
|
||||
T* sp = NULL;
|
||||
|
||||
for ( it = mResources.rbegin(); it != mResources.rend(); it++ ) {
|
||||
sp = ( *it );
|
||||
|
||||
if ( id == sp->getId() )
|
||||
return sp;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
template <class T> T* ResourceManager<T>::getById( const String::HashType& id ) {
|
||||
auto it = mResources.find( id );
|
||||
return it != mResources.end() ? it->second : nullptr;
|
||||
}
|
||||
|
||||
template <class T> void ResourceManager<T>::printNames() {
|
||||
typename std::list<T*>::reverse_iterator it;
|
||||
|
||||
T* sp = NULL;
|
||||
|
||||
for ( it = mResources.rbegin(); it != mResources.rend(); it++ ) {
|
||||
sp = ( *it );
|
||||
|
||||
eePRINT( "'%s'\n", sp->getName().c_str() );
|
||||
for ( auto& it : mResources ) {
|
||||
eePRINT( "'%s'\n", it.second->getName().c_str() );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -206,19 +175,175 @@ template <class T> Uint32 ResourceManager<T>::getCount() {
|
||||
return (Uint32)mResources.size();
|
||||
}
|
||||
|
||||
template <class T> Uint32 ResourceManager<T>::setCount( const Uint32& Id ) {
|
||||
typename std::list<T*>::iterator it;
|
||||
Uint32 Count = 0;
|
||||
|
||||
for ( it = mResources.begin(); it != mResources.end(); it++ )
|
||||
if ( ( *it )->getId() == Id )
|
||||
Count++;
|
||||
|
||||
return Count;
|
||||
template <class T> Uint32 ResourceManager<T>::getCount( const String::HashType& id ) {
|
||||
return existsId( id ) ? 1 : 0;
|
||||
}
|
||||
|
||||
template <class T> Uint32 ResourceManager<T>::setCount( const std::string& Name ) {
|
||||
return setCount( String::hash( Name ) );
|
||||
template <class T> Uint32 ResourceManager<T>::getCount( const std::string& name ) {
|
||||
return getCount( String::hash( name ) );
|
||||
}
|
||||
|
||||
/** @brief A simple resource manager. It keeps a list of the resources, and free the instances of
|
||||
* the resources when the manager is closed. Resources must implement getId() and getName()
|
||||
* properties getId() is the string hash of getName(). Allows repeated keys.
|
||||
*/
|
||||
template <class T> class ResourceManagerMulti {
|
||||
public:
|
||||
/** @param UniqueId Indicates if the resources id must be unique */
|
||||
ResourceManagerMulti();
|
||||
|
||||
/** @brief The destructor will call destroy() and destroy all the resources added to the manager
|
||||
*/
|
||||
virtual ~ResourceManagerMulti();
|
||||
|
||||
/** @brief Add the resource to the resource manager
|
||||
** @param resource The resource to be managed by the manager */
|
||||
virtual T* add( T* resource );
|
||||
|
||||
/** @brief Removes the resource from the manager
|
||||
** @param resource The resource to remove
|
||||
** @param remove Indicates if the resource must be destroyed after being removed from the
|
||||
*manager */
|
||||
bool remove( T* resource, bool remove = true );
|
||||
|
||||
/** @brief Removes the resource by its id
|
||||
** @see remove */
|
||||
bool removeById( const String::HashType& id, bool remove = true );
|
||||
|
||||
/** @brief Removes the resource by its name
|
||||
** @see remove */
|
||||
bool removeByName( const std::string& name, bool remove = true );
|
||||
|
||||
/** @returns A resource by its name. If not found returns NULL. */
|
||||
T* getByName( const std::string& name );
|
||||
|
||||
/** @returns A resource by its id. If not found returns NULL. */
|
||||
T* getById( const String::HashType& id );
|
||||
|
||||
/** @returns The number of resources added */
|
||||
Uint32 getCount();
|
||||
|
||||
/** @returns The number of resources that where added with the indicated name. */
|
||||
Uint32 getCount( const std::string& name );
|
||||
|
||||
/** @returns The number of resources that where added with the indicated id. */
|
||||
Uint32 getCount( const String::HashType& id );
|
||||
|
||||
/** @returns If the resource name exists in the resources list. */
|
||||
bool exists( const std::string& name );
|
||||
|
||||
/** @returns If the resource id exists in the resources list. */
|
||||
bool existsId( const String::HashType& id );
|
||||
|
||||
/** @brief Destroy all the resources added ( delete the instances of the resources ) */
|
||||
void destroy();
|
||||
|
||||
/** @brief Prints all the resources names added to the manager. */
|
||||
void printNames();
|
||||
|
||||
/** @returns A reference to the resources list of the manager. */
|
||||
std::unordered_multimap<String::HashType, T*>& getResources();
|
||||
|
||||
/** @brief Indicates if the resource manager is destroy the resources. */
|
||||
const bool& isDestroying() const;
|
||||
|
||||
protected:
|
||||
std::unordered_multimap<String::HashType, T*> mResources;
|
||||
bool mIsDestroying;
|
||||
};
|
||||
|
||||
template <class T> ResourceManagerMulti<T>::ResourceManagerMulti() : mIsDestroying( false ) {}
|
||||
|
||||
template <class T> const bool& ResourceManagerMulti<T>::isDestroying() const {
|
||||
return mIsDestroying;
|
||||
}
|
||||
|
||||
template <class T> ResourceManagerMulti<T>::~ResourceManagerMulti() {
|
||||
destroy();
|
||||
}
|
||||
|
||||
template <class T> void ResourceManagerMulti<T>::destroy() {
|
||||
mIsDestroying = true;
|
||||
|
||||
for ( auto& it : mResources ) {
|
||||
T* res = it.second;
|
||||
eeSAFE_DELETE( res );
|
||||
}
|
||||
|
||||
mResources.clear();
|
||||
|
||||
mIsDestroying = false;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
std::unordered_multimap<String::HashType, T*>& ResourceManagerMulti<T>::getResources() {
|
||||
return mResources;
|
||||
}
|
||||
|
||||
template <class T> T* ResourceManagerMulti<T>::add( T* resource ) {
|
||||
if ( NULL != resource ) {
|
||||
mResources.insert( std::pair<String::HashType, T*>( resource->getId(), resource ) );
|
||||
return resource;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
template <class T> bool ResourceManagerMulti<T>::remove( T* resource, bool remove ) {
|
||||
if ( NULL != resource ) {
|
||||
mResources.erase( resource->getId() );
|
||||
|
||||
if ( remove )
|
||||
eeSAFE_DELETE( resource );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
template <class T>
|
||||
bool ResourceManagerMulti<T>::removeById( const String::HashType& id, bool _remove ) {
|
||||
return remove( getById( id ), _remove );
|
||||
}
|
||||
|
||||
template <class T>
|
||||
bool ResourceManagerMulti<T>::removeByName( const std::string& name, bool _remove ) {
|
||||
return remove( getByName( name ), _remove );
|
||||
}
|
||||
|
||||
template <class T> bool ResourceManagerMulti<T>::exists( const std::string& name ) {
|
||||
return existsId( String::hash( name ) );
|
||||
}
|
||||
|
||||
template <class T> bool ResourceManagerMulti<T>::existsId( const String::HashType& id ) {
|
||||
return mResources.find( id ) != mResources.end();
|
||||
}
|
||||
|
||||
template <class T> T* ResourceManagerMulti<T>::getByName( const std::string& name ) {
|
||||
return getById( String::hash( name ) );
|
||||
}
|
||||
|
||||
template <class T> T* ResourceManagerMulti<T>::getById( const String::HashType& id ) {
|
||||
auto it = mResources.find( id );
|
||||
return it != mResources.end() ? it->second : nullptr;
|
||||
}
|
||||
|
||||
template <class T> void ResourceManagerMulti<T>::printNames() {
|
||||
for ( auto& it : mResources ) {
|
||||
eePRINT( "'%s'\n", it->second->getName().c_str() );
|
||||
}
|
||||
}
|
||||
|
||||
template <class T> Uint32 ResourceManagerMulti<T>::getCount() {
|
||||
return (Uint32)mResources.size();
|
||||
}
|
||||
|
||||
template <class T> Uint32 ResourceManagerMulti<T>::getCount( const String::HashType& id ) {
|
||||
return mResources.count( id );
|
||||
}
|
||||
|
||||
template <class T> Uint32 ResourceManagerMulti<T>::getCount( const std::string& name ) {
|
||||
return getCount( String::hash( name ) );
|
||||
}
|
||||
|
||||
}} // namespace EE::System
|
||||
|
||||
@@ -50,7 +50,8 @@ class EE_API UIGridLayout : public UILayout {
|
||||
|
||||
virtual bool applyProperty( const StyleSheetProperty& attribute );
|
||||
|
||||
virtual void pack();
|
||||
virtual void updateLayout();
|
||||
|
||||
protected:
|
||||
Sizei mBoxMargin;
|
||||
ElementMode mColumnMode;
|
||||
|
||||
@@ -15,15 +15,9 @@ class EE_API UILayout : public UIWidget {
|
||||
|
||||
virtual bool isType( const Uint32& type ) const;
|
||||
|
||||
virtual void pack();
|
||||
|
||||
virtual void setLayoutDirty();
|
||||
|
||||
virtual void packConditional();
|
||||
|
||||
void packLayoutTree();
|
||||
|
||||
protected:
|
||||
friend class UISceneNode;
|
||||
|
||||
UILayout( const std::string& tag );
|
||||
|
||||
virtual void onSizeChange();
|
||||
@@ -36,6 +30,14 @@ class EE_API UILayout : public UIWidget {
|
||||
|
||||
virtual void onLayoutUpdate();
|
||||
|
||||
virtual void tryUpdateLayout();
|
||||
|
||||
virtual void updateLayout();
|
||||
|
||||
virtual void updateLayoutTree();
|
||||
|
||||
void setLayoutDirty();
|
||||
|
||||
std::unordered_set<UILayout*> mLayouts;
|
||||
bool mDirtyLayout;
|
||||
};
|
||||
|
||||
@@ -30,7 +30,7 @@ class EE_API UILinearLayout : public UILayout {
|
||||
virtual std::string getPropertyString( const PropertyDefinition* propertyDef,
|
||||
const Uint32& propertyIndex = 0 );
|
||||
|
||||
void pack();
|
||||
void updateLayout();
|
||||
|
||||
bool isPacking() const;
|
||||
|
||||
|
||||
@@ -17,7 +17,8 @@ class EE_API UIRelativeLayout : public UILayout {
|
||||
|
||||
UIRelativeLayout* add( UIWidget* widget );
|
||||
|
||||
virtual void pack();
|
||||
virtual void updateLayout();
|
||||
|
||||
protected:
|
||||
virtual Uint32 onMessage( const NodeMessage* Msg );
|
||||
|
||||
|
||||
@@ -122,6 +122,10 @@ class EE_API UIStyle : public UIState {
|
||||
const Uint32& propertyIndex );
|
||||
|
||||
CSS::StyleSheetProperty* getLocalProperty( Uint32 propId );
|
||||
|
||||
void addStructurallyVolatileWidgetFromParent();
|
||||
|
||||
void removeStructurallyVolatileWidgetFromParent();
|
||||
};
|
||||
|
||||
}} // namespace EE::UI
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
#define EE_UICUITABWIDGET_HPP
|
||||
|
||||
#include <deque>
|
||||
#include <eepp/ui/uilayout.hpp>
|
||||
#include <eepp/ui/uitab.hpp>
|
||||
#include <eepp/ui/uiwidget.hpp>
|
||||
|
||||
namespace EE { namespace UI {
|
||||
|
||||
class EE_API UITabWidget : public UIWidget {
|
||||
class EE_API UITabWidget : public UILayout {
|
||||
public:
|
||||
class StyleConfig {
|
||||
public:
|
||||
@@ -127,11 +127,9 @@ class EE_API UITabWidget : public UIWidget {
|
||||
|
||||
UITab* createTab( const String& Text, UINode* CtrlOwned, Drawable* Icon );
|
||||
|
||||
virtual void onSizeChange();
|
||||
|
||||
virtual void onChildCountChange( Node* child, const bool& removed );
|
||||
|
||||
virtual void onPaddingChange();
|
||||
virtual void updateLayout();
|
||||
|
||||
void setContainerSize();
|
||||
|
||||
|
||||
@@ -17,12 +17,12 @@ class Drawable;
|
||||
|
||||
namespace EE { namespace UI {
|
||||
|
||||
class EE_API UITheme : protected ResourceManager<UISkin> {
|
||||
class EE_API UITheme : protected ResourceManagerMulti<UISkin> {
|
||||
public:
|
||||
using ResourceManager<UISkin>::getById;
|
||||
using ResourceManager<UISkin>::getByName;
|
||||
using ResourceManager<UISkin>::exists;
|
||||
using ResourceManager<UISkin>::existsId;
|
||||
using ResourceManagerMulti<UISkin>::getById;
|
||||
using ResourceManagerMulti<UISkin>::getByName;
|
||||
using ResourceManagerMulti<UISkin>::exists;
|
||||
using ResourceManagerMulti<UISkin>::existsId;
|
||||
|
||||
static UITheme* New( const std::string& name, const std::string& abbr,
|
||||
Graphics::Font* defaultFont = NULL );
|
||||
|
||||
@@ -7,6 +7,7 @@ SINGLETON_DECLARE_IMPLEMENTATION( GlobalTextureAtlas )
|
||||
|
||||
GlobalTextureAtlas::GlobalTextureAtlas() : TextureAtlas( "global" ) {}
|
||||
|
||||
GlobalTextureAtlas::~GlobalTextureAtlas() {}
|
||||
GlobalTextureAtlas::~GlobalTextureAtlas() {
|
||||
}
|
||||
|
||||
}} // namespace EE::Graphics
|
||||
|
||||
@@ -9,10 +9,8 @@ ShaderProgramManager::ShaderProgramManager() {}
|
||||
ShaderProgramManager::~ShaderProgramManager() {}
|
||||
|
||||
void ShaderProgramManager::reload() {
|
||||
std::list<ShaderProgram*>::iterator it;
|
||||
|
||||
for ( it = mResources.begin(); it != mResources.end(); ++it )
|
||||
( *it )->reload();
|
||||
for ( auto& res : mResources )
|
||||
res.second->reload();
|
||||
}
|
||||
|
||||
}} // namespace EE::Graphics
|
||||
|
||||
@@ -6,7 +6,7 @@ TextureAtlas* TextureAtlas::New( const std::string& name ) {
|
||||
return eeNew( TextureAtlas, ( name ) );
|
||||
}
|
||||
|
||||
TextureAtlas::TextureAtlas( const std::string& name ) : ResourceManager<TextureRegion>( true ) {
|
||||
TextureAtlas::TextureAtlas( const std::string& name ) : ResourceManager<TextureRegion>() {
|
||||
setName( name );
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace EE { namespace Graphics {
|
||||
SINGLETON_DECLARE_IMPLEMENTATION( TextureAtlasManager )
|
||||
|
||||
TextureAtlasManager::TextureAtlasManager() :
|
||||
ResourceManager<TextureAtlas>( false ), mWarnings( false ) {
|
||||
ResourceManagerMulti<TextureAtlas>(), mWarnings( false ) {
|
||||
add( GlobalTextureAtlas::instance() );
|
||||
}
|
||||
|
||||
@@ -57,8 +57,8 @@ TextureRegion* TextureAtlasManager::getTextureRegionById( const Uint32& Id ) {
|
||||
TextureAtlas* tSG = NULL;
|
||||
TextureRegion* tTextureRegion = NULL;
|
||||
|
||||
for ( it = mResources.begin(); it != mResources.end(); ++it ) {
|
||||
tSG = ( *it );
|
||||
for ( auto& it : mResources ) {
|
||||
tSG = it.second;
|
||||
|
||||
tTextureRegion = tSG->getById( Id );
|
||||
|
||||
@@ -70,10 +70,8 @@ TextureRegion* TextureAtlasManager::getTextureRegionById( const Uint32& Id ) {
|
||||
}
|
||||
|
||||
void TextureAtlasManager::printResources() {
|
||||
std::list<TextureAtlas*>::iterator it;
|
||||
|
||||
for ( it = mResources.begin(); it != mResources.end(); ++it )
|
||||
( *it )->printNames();
|
||||
for ( auto& it : mResources )
|
||||
it.second->printNames();
|
||||
}
|
||||
|
||||
std::vector<TextureRegion*>
|
||||
|
||||
@@ -945,7 +945,7 @@ void MapEditor::onNewGOTypeAdded( std::string name, Uint32 hash ) {
|
||||
|
||||
void MapEditor::fillSGCombo() {
|
||||
TextureAtlasManager* SGM = TextureAtlasManager::instance();
|
||||
std::list<TextureAtlas*>& Res = SGM->getResources();
|
||||
auto& res = SGM->getResources();
|
||||
|
||||
mTextureAtlasesList->getListBox()->clear();
|
||||
|
||||
@@ -956,9 +956,9 @@ void MapEditor::fillSGCombo() {
|
||||
if ( NULL != mTheme && NULL != mTheme->getTextureAtlas() )
|
||||
Restricted2 = String::hash( mTheme->getTextureAtlas()->getName() );
|
||||
|
||||
for ( std::list<TextureAtlas*>::iterator it = Res.begin(); it != Res.end(); ++it ) {
|
||||
if ( ( *it )->getId() != Restricted1 && ( *it )->getId() != Restricted2 )
|
||||
items.push_back( ( *it )->getName() );
|
||||
for ( auto& it : res ) {
|
||||
if ( it.second->getId() != Restricted1 && it.second->getId() != Restricted2 )
|
||||
items.push_back( it.second->getName() );
|
||||
}
|
||||
|
||||
if ( items.size() ) {
|
||||
@@ -974,15 +974,15 @@ void MapEditor::fillSGCombo() {
|
||||
void MapEditor::fillTextureRegionList() {
|
||||
TextureAtlasManager* SGM = TextureAtlasManager::instance();
|
||||
mCurSG = SGM->getByName( mTextureAtlasesList->getText() );
|
||||
std::list<TextureRegion*>& Res = mCurSG->getResources();
|
||||
auto& res = mCurSG->getResources();
|
||||
|
||||
mTextureRegionList->clear();
|
||||
|
||||
if ( NULL != mCurSG ) {
|
||||
std::vector<String> items;
|
||||
|
||||
for ( std::list<TextureRegion*>::iterator it = Res.begin(); it != Res.end(); ++it ) {
|
||||
items.push_back( ( *it )->getName() );
|
||||
for ( auto& it : res ) {
|
||||
items.push_back( it.second->getName() );
|
||||
}
|
||||
|
||||
if ( items.size() ) {
|
||||
|
||||
@@ -1435,7 +1435,7 @@ void TileMap::saveToFile( const std::string& path ) {
|
||||
|
||||
std::vector<std::string> TileMap::getTextureAtlases() {
|
||||
TextureAtlasManager* SGM = TextureAtlasManager::instance();
|
||||
std::list<TextureAtlas*>& Res = SGM->getResources();
|
||||
auto& res = SGM->getResources();
|
||||
|
||||
std::vector<std::string> items;
|
||||
|
||||
@@ -1448,9 +1448,9 @@ std::vector<std::string> TileMap::getTextureAtlases() {
|
||||
->getTextureAtlas()
|
||||
->getName() );
|
||||
|
||||
for ( std::list<TextureAtlas*>::iterator it = Res.begin(); it != Res.end(); ++it ) {
|
||||
if ( ( *it )->getId() != Restricted1 && ( *it )->getId() != Restricted2 )
|
||||
items.push_back( ( *it )->getPath() );
|
||||
for ( auto& it : res ) {
|
||||
if ( it.second->getId() != Restricted1 && it.second->getId() != Restricted2 )
|
||||
items.push_back( it.second->getPath() );
|
||||
}
|
||||
|
||||
return items;
|
||||
|
||||
@@ -367,14 +367,14 @@ void TextureAtlasEditor::fillTextureRegionList() {
|
||||
!mTextureAtlasLoader->isLoaded() )
|
||||
return;
|
||||
|
||||
std::list<TextureRegion*>& Res = mTextureAtlasLoader->getTextureAtlas()->getResources();
|
||||
auto& res = mTextureAtlasLoader->getTextureAtlas()->getResources();
|
||||
|
||||
mTextureRegionList->clear();
|
||||
|
||||
std::vector<String> items;
|
||||
|
||||
for ( std::list<TextureRegion*>::iterator it = Res.begin(); it != Res.end(); ++it ) {
|
||||
items.push_back( ( *it )->getName() );
|
||||
for ( auto& it : res ) {
|
||||
items.push_back( it.second->getName() );
|
||||
}
|
||||
|
||||
if ( items.size() ) {
|
||||
@@ -387,11 +387,11 @@ void TextureAtlasEditor::fillTextureRegionList() {
|
||||
mTextureRegionList->getVerticalScrollBar()->setClickStep(
|
||||
8.f / (Float)mTextureRegionList->getCount() );
|
||||
|
||||
if ( !Res.empty() ) {
|
||||
if ( !res.empty() ) {
|
||||
mTextureRegionGrid->childsCloseAll();
|
||||
|
||||
for ( auto it = Res.begin(); it != Res.end(); ++it ) {
|
||||
TextureRegion* tr = ( *it );
|
||||
for ( auto& it : res ) {
|
||||
TextureRegion* tr = it.second;
|
||||
|
||||
UITextureRegion::New()
|
||||
->setTextureRegion( tr )
|
||||
|
||||
@@ -42,7 +42,7 @@ UIGridLayout::ElementMode UIGridLayout::getColumnMode() const {
|
||||
|
||||
UIGridLayout* UIGridLayout::setColumnMode( const UIGridLayout::ElementMode& mode ) {
|
||||
mColumnMode = mode;
|
||||
pack();
|
||||
updateLayout();
|
||||
invalidateDraw();
|
||||
return this;
|
||||
}
|
||||
@@ -53,7 +53,7 @@ UIGridLayout::ElementMode UIGridLayout::getRowMode() const {
|
||||
|
||||
UIGridLayout* UIGridLayout::setRowMode( const UIGridLayout::ElementMode& mode ) {
|
||||
mRowMode = mode;
|
||||
packConditional();
|
||||
tryUpdateLayout();
|
||||
invalidateDraw();
|
||||
return this;
|
||||
}
|
||||
@@ -65,7 +65,7 @@ Float UIGridLayout::getColumnWeight() const {
|
||||
UIGridLayout* UIGridLayout::setColumnWeight( const Float& columnWeight ) {
|
||||
mColumnWeight = columnWeight;
|
||||
if ( mColumnMode == Weight )
|
||||
packConditional();
|
||||
tryUpdateLayout();
|
||||
invalidateDraw();
|
||||
return this;
|
||||
}
|
||||
@@ -77,7 +77,7 @@ int UIGridLayout::getColumnWidth() const {
|
||||
UIGridLayout* UIGridLayout::setColumnWidth( int columnWidth ) {
|
||||
mColumnWidth = columnWidth;
|
||||
if ( mColumnMode == Size )
|
||||
packConditional();
|
||||
tryUpdateLayout();
|
||||
invalidateDraw();
|
||||
return this;
|
||||
}
|
||||
@@ -89,7 +89,7 @@ int UIGridLayout::getRowHeight() const {
|
||||
UIGridLayout* UIGridLayout::setRowHeight( int rowHeight ) {
|
||||
mRowHeight = rowHeight;
|
||||
if ( mRowMode == Size )
|
||||
packConditional();
|
||||
tryUpdateLayout();
|
||||
invalidateDraw();
|
||||
return this;
|
||||
}
|
||||
@@ -101,12 +101,12 @@ Float UIGridLayout::getRowWeight() const {
|
||||
UIGridLayout* UIGridLayout::setRowWeight( const Float& rowWeight ) {
|
||||
mRowWeight = rowWeight;
|
||||
if ( mRowMode == Weight )
|
||||
packConditional();
|
||||
tryUpdateLayout();
|
||||
invalidateDraw();
|
||||
return this;
|
||||
}
|
||||
|
||||
void UIGridLayout::pack() {
|
||||
void UIGridLayout::updateLayout() {
|
||||
Sizef oldSize( getSize() );
|
||||
|
||||
if ( getParent()->isUINode() && !getParent()->asType<UINode>()->ownsChildPosition() ) {
|
||||
@@ -196,8 +196,8 @@ void UIGridLayout::pack() {
|
||||
Uint32 UIGridLayout::onMessage( const NodeMessage* Msg ) {
|
||||
switch ( Msg->getMsg() ) {
|
||||
case NodeMessage::LayoutAttributeChange: {
|
||||
packConditional();
|
||||
break;
|
||||
tryUpdateLayout();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+10
-10
@@ -27,22 +27,22 @@ void UILayout::onChildCountChange( Node* child, const bool& removed ) {
|
||||
}
|
||||
}
|
||||
|
||||
packConditional();
|
||||
tryUpdateLayout();
|
||||
}
|
||||
|
||||
void UILayout::onSizeChange() {
|
||||
UIWidget::onSizeChange();
|
||||
packConditional();
|
||||
tryUpdateLayout();
|
||||
}
|
||||
|
||||
void UILayout::onPaddingChange() {
|
||||
UIWidget::onPaddingChange();
|
||||
packConditional();
|
||||
tryUpdateLayout();
|
||||
}
|
||||
|
||||
void UILayout::onParentSizeChange( const Vector2f& ) {
|
||||
UIWidget::onParentChange();
|
||||
packConditional();
|
||||
tryUpdateLayout();
|
||||
}
|
||||
|
||||
void UILayout::onLayoutUpdate() {
|
||||
@@ -57,7 +57,7 @@ bool UILayout::isType( const Uint32& type ) const {
|
||||
return UILayout::getType() == type ? true : UIWidget::isType( type );
|
||||
}
|
||||
|
||||
void UILayout::pack() {}
|
||||
void UILayout::updateLayout() {}
|
||||
|
||||
void UILayout::setLayoutDirty() {
|
||||
if ( !mDirtyLayout ) {
|
||||
@@ -66,19 +66,19 @@ void UILayout::setLayoutDirty() {
|
||||
}
|
||||
}
|
||||
|
||||
void UILayout::packConditional() {
|
||||
void UILayout::tryUpdateLayout() {
|
||||
if ( mUISceneNode->isUpdatingLayouts() ) {
|
||||
pack();
|
||||
updateLayout();
|
||||
} else if ( !mDirtyLayout ) {
|
||||
setLayoutDirty();
|
||||
}
|
||||
}
|
||||
|
||||
void UILayout::packLayoutTree() {
|
||||
pack();
|
||||
void UILayout::updateLayoutTree() {
|
||||
updateLayout();
|
||||
|
||||
for ( auto layout : mLayouts ) {
|
||||
layout->packLayoutTree();
|
||||
layout->updateLayoutTree();
|
||||
}
|
||||
|
||||
onLayoutUpdate();
|
||||
|
||||
@@ -44,7 +44,7 @@ UILinearLayout* UILinearLayout::add( UIWidget* widget ) {
|
||||
return this;
|
||||
}
|
||||
|
||||
void UILinearLayout::pack() {
|
||||
void UILinearLayout::updateLayout() {
|
||||
if ( mOrientation == UIOrientation::Vertical )
|
||||
packVertical();
|
||||
else
|
||||
@@ -477,8 +477,8 @@ bool UILinearLayout::applyProperty( const StyleSheetProperty& attribute ) {
|
||||
Uint32 UILinearLayout::onMessage( const NodeMessage* Msg ) {
|
||||
switch ( Msg->getMsg() ) {
|
||||
case NodeMessage::LayoutAttributeChange: {
|
||||
packConditional();
|
||||
break;
|
||||
tryUpdateLayout();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ UIRelativeLayout* UIRelativeLayout::add( UIWidget* widget ) {
|
||||
return this;
|
||||
}
|
||||
|
||||
void UIRelativeLayout::pack() {
|
||||
void UIRelativeLayout::updateLayout() {
|
||||
if ( getParent()->isUINode() && !getParent()->asType<UINode>()->ownsChildPosition() ) {
|
||||
setInternalPosition( Vector2f( mLayoutMargin.Left, mLayoutMargin.Top ) );
|
||||
}
|
||||
@@ -170,8 +170,8 @@ void UIRelativeLayout::fixChildSize( UIWidget* widget ) {
|
||||
Uint32 UIRelativeLayout::onMessage( const NodeMessage* Msg ) {
|
||||
switch ( Msg->getMsg() ) {
|
||||
case NodeMessage::LayoutAttributeChange: {
|
||||
packConditional();
|
||||
break;
|
||||
tryUpdateLayout();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -577,16 +577,14 @@ void UISceneNode::setIsLoading( bool isLoading ) {
|
||||
|
||||
void UISceneNode::updateDirtyLayouts() {
|
||||
if ( !mDirtyLayouts.empty() ) {
|
||||
Clock clock;
|
||||
mUpdatingLayouts = true;
|
||||
|
||||
for ( UILayout* layout : mDirtyLayouts ) {
|
||||
layout->packLayoutTree();
|
||||
layout->updateLayoutTree();
|
||||
}
|
||||
|
||||
mDirtyLayouts.clear();
|
||||
mUpdatingLayouts = false;
|
||||
eePRINTL( "Layouts recalculated in %.2f ms", clock.getElapsedTime().asMilliseconds() );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -597,7 +595,9 @@ void UISceneNode::updateDirtyStyles() {
|
||||
node->reloadStyle( true, false, false );
|
||||
}
|
||||
mDirtyStyle.clear();
|
||||
eePRINTL( "CSS Styles Reloaded in %.2f ms", clock.getElapsedTime().asMilliseconds() );
|
||||
|
||||
if ( mVerbose )
|
||||
eePRINTL( "CSS Styles Reloaded in %.2f ms", clock.getElapsedTime().asMilliseconds() );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -609,8 +609,10 @@ void UISceneNode::updateDirtyStyleStates() {
|
||||
}
|
||||
mDirtyStyleState.clear();
|
||||
mDirtyStyleStateCSSAnimations.clear();
|
||||
eePRINTL( "CSS Style State Invalidated, reapplied state in %.2f ms",
|
||||
clock.getElapsedTime().asMilliseconds() );
|
||||
|
||||
if ( mVerbose )
|
||||
eePRINTL( "CSS Style State Invalidated, reapplied state in %.2f ms",
|
||||
clock.getElapsedTime().asMilliseconds() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+22
-19
@@ -28,13 +28,7 @@ UIStyle::UIStyle( UIWidget* widget ) :
|
||||
mDisableAnimations( false ) {}
|
||||
|
||||
UIStyle::~UIStyle() {
|
||||
if ( mGlobalDefinition && mGlobalDefinition->isStructurallyVolatile() && mWidget->getParent() &&
|
||||
mWidget->getParent()->isWidget() &&
|
||||
mWidget->getParent()->asType<UIWidget>()->getUIStyle() ) {
|
||||
mWidget->getParent()->asType<UIWidget>()->getUIStyle()->removeStructurallyVolatileChild(
|
||||
mWidget );
|
||||
}
|
||||
|
||||
removeStructurallyVolatileWidgetFromParent();
|
||||
removeRelatedWidgets();
|
||||
unsubscribeNonCacheableStyles();
|
||||
}
|
||||
@@ -60,12 +54,7 @@ void UIStyle::setStyleSheetProperty( const StyleSheetProperty& property ) {
|
||||
}
|
||||
|
||||
void UIStyle::load() {
|
||||
if ( mGlobalDefinition && mGlobalDefinition->isStructurallyVolatile() && mWidget->getParent() &&
|
||||
mWidget->getParent()->isWidget() &&
|
||||
mWidget->getParent()->asType<UIWidget>()->getUIStyle() ) {
|
||||
mWidget->getParent()->asType<UIWidget>()->getUIStyle()->removeStructurallyVolatileChild(
|
||||
mWidget );
|
||||
}
|
||||
removeStructurallyVolatileWidgetFromParent();
|
||||
|
||||
mGlobalDefinition =
|
||||
mWidget->getUISceneNode()->getStyleSheet().getElementStyles( mWidget, false );
|
||||
@@ -74,12 +63,7 @@ void UIStyle::load() {
|
||||
|
||||
subscribeNonCacheableStyles();
|
||||
|
||||
if ( mGlobalDefinition && mGlobalDefinition->isStructurallyVolatile() && mWidget->getParent() &&
|
||||
mWidget->getParent()->isWidget() &&
|
||||
mWidget->getParent()->asType<UIWidget>()->getUIStyle() ) {
|
||||
mWidget->getParent()->asType<UIWidget>()->getUIStyle()->addStructurallyVolatileChild(
|
||||
mWidget );
|
||||
}
|
||||
addStructurallyVolatileWidgetFromParent();
|
||||
}
|
||||
|
||||
void UIStyle::setStyleSheetProperties( const CSS::StyleSheetProperties& properties ) {
|
||||
@@ -485,6 +469,7 @@ void UIStyle::applyStyleSheetProperty( const StyleSheetProperty& property,
|
||||
} else {
|
||||
elapsed = transitionInfo.getDuration();
|
||||
}
|
||||
startValue = prevTransition->getEndValue();
|
||||
} else if ( startValue == prevTransition->getEndValue() ) {
|
||||
startValue = currentValue;
|
||||
}
|
||||
@@ -706,4 +691,22 @@ StyleSheetProperty* UIStyle::getLocalProperty( Uint32 propId ) {
|
||||
return defProperty ? defProperty : elemProperty;
|
||||
}
|
||||
|
||||
void UIStyle::addStructurallyVolatileWidgetFromParent() {
|
||||
if ( mGlobalDefinition && mGlobalDefinition->isStructurallyVolatile() && mWidget->getParent() &&
|
||||
mWidget->getParent()->isWidget() &&
|
||||
mWidget->getParent()->asType<UIWidget>()->getUIStyle() ) {
|
||||
mWidget->getParent()->asType<UIWidget>()->getUIStyle()->addStructurallyVolatileChild(
|
||||
mWidget );
|
||||
}
|
||||
}
|
||||
|
||||
void UIStyle::removeStructurallyVolatileWidgetFromParent() {
|
||||
if ( mGlobalDefinition && mGlobalDefinition->isStructurallyVolatile() && mWidget->getParent() &&
|
||||
mWidget->getParent()->isWidget() &&
|
||||
mWidget->getParent()->asType<UIWidget>()->getUIStyle() ) {
|
||||
mWidget->getParent()->asType<UIWidget>()->getUIStyle()->removeStructurallyVolatileChild(
|
||||
mWidget );
|
||||
}
|
||||
}
|
||||
|
||||
}} // namespace EE::UI
|
||||
|
||||
+24
-26
@@ -14,7 +14,7 @@ UITabWidget* UITabWidget::New() {
|
||||
}
|
||||
|
||||
UITabWidget::UITabWidget() :
|
||||
UIWidget( "tabwidget" ),
|
||||
UILayout( "tabwidget" ),
|
||||
mCtrlContainer( NULL ),
|
||||
mTabContainer( NULL ),
|
||||
mTabSelected( NULL ),
|
||||
@@ -35,8 +35,6 @@ UITabWidget::UITabWidget() :
|
||||
->setPosition( 0, mStyleConfig.TabHeight );
|
||||
mCtrlContainer->clipEnable();
|
||||
|
||||
onSizeChange();
|
||||
|
||||
applyDefaultTheme();
|
||||
}
|
||||
|
||||
@@ -47,11 +45,11 @@ Uint32 UITabWidget::getType() const {
|
||||
}
|
||||
|
||||
bool UITabWidget::isType( const Uint32& type ) const {
|
||||
return UITabWidget::getType() == type ? true : UIWidget::isType( type );
|
||||
return UITabWidget::getType() == type ? true : UILayout::isType( type );
|
||||
}
|
||||
|
||||
void UITabWidget::setTheme( UITheme* Theme ) {
|
||||
UIWidget::setTheme( Theme );
|
||||
UILayout::setTheme( Theme );
|
||||
|
||||
mTabContainer->setThemeSkin( Theme, "tabwidget" );
|
||||
|
||||
@@ -75,9 +73,9 @@ void UITabWidget::setTheme( UITheme* Theme ) {
|
||||
}
|
||||
|
||||
void UITabWidget::onThemeLoaded() {
|
||||
onSizeChange();
|
||||
tryUpdateLayout();
|
||||
|
||||
UIWidget::onThemeLoaded();
|
||||
UILayout::onThemeLoaded();
|
||||
}
|
||||
|
||||
void UITabWidget::setContainerSize() {
|
||||
@@ -86,8 +84,8 @@ void UITabWidget::setContainerSize() {
|
||||
mTabContainer->setPosition( mPadding.Left, mPadding.Top );
|
||||
mCtrlContainer->setPosition( mPadding.Left, mPadding.Top + mStyleConfig.TabHeight );
|
||||
Sizef s( mSize.getWidth() - mRealPadding.Left - mRealPadding.Right,
|
||||
mSize.getHeight() - PixelDensity::dpToPx( mStyleConfig.TabHeight ) - mRealPadding.Top -
|
||||
mRealPadding.Bottom );
|
||||
mSize.getHeight() - PixelDensity::dpToPx( mStyleConfig.TabHeight ) - mRealPadding.Top -
|
||||
mRealPadding.Bottom );
|
||||
if ( s != mCtrlContainer->getSize() ) {
|
||||
mCtrlContainer->setPixelsSize( s );
|
||||
|
||||
@@ -130,7 +128,7 @@ std::string UITabWidget::getPropertyString( const PropertyDefinition* propertyDe
|
||||
case PropertyId::TabHeight:
|
||||
return String::fromFloat( getTabsHeight(), "dp" );
|
||||
default:
|
||||
return UIWidget::getPropertyString( propertyDef, propertyIndex );
|
||||
return UILayout::getPropertyString( propertyDef, propertyIndex );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -191,7 +189,7 @@ bool UITabWidget::applyProperty( const StyleSheetProperty& attribute ) {
|
||||
setTabsHeight( attribute.asDpDimension( this ) );
|
||||
break;
|
||||
default:
|
||||
return UIWidget::applyProperty( attribute );
|
||||
return UILayout::applyProperty( attribute );
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -576,17 +574,6 @@ Uint32 UITabWidget::getSelectedTabIndex() const {
|
||||
return mTabSelectedIndex;
|
||||
}
|
||||
|
||||
void UITabWidget::onSizeChange() {
|
||||
setContainerSize();
|
||||
posTabs();
|
||||
|
||||
if ( NULL != mTabSelected && NULL != mTabSelected->getOwnedWidget() ) {
|
||||
mTabSelected->getOwnedWidget()->setSize( mCtrlContainer->getSize() );
|
||||
}
|
||||
|
||||
UIWidget::onSizeChange();
|
||||
}
|
||||
|
||||
void UITabWidget::onChildCountChange( Node* child, const bool& removed ) {
|
||||
if ( !removed && child != mTabContainer && child != mCtrlContainer ) {
|
||||
if ( child->isType( UI_TYPE_TAB ) ) {
|
||||
@@ -605,16 +592,27 @@ void UITabWidget::onChildCountChange( Node* child, const bool& removed ) {
|
||||
child->setParent( mCtrlContainer );
|
||||
child->setVisible( false );
|
||||
child->setEnabled( true );
|
||||
|
||||
if ( child->isLayout() ) {
|
||||
mLayouts.insert( child->asType<UILayout>() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
UIWidget::onChildCountChange( child, removed );
|
||||
if ( removed && child->isLayout() ) {
|
||||
mLayouts.erase( child->asType<UILayout>() );
|
||||
}
|
||||
|
||||
tryUpdateLayout();
|
||||
}
|
||||
|
||||
void UITabWidget::onPaddingChange() {
|
||||
onSizeChange();
|
||||
void UITabWidget::updateLayout() {
|
||||
setContainerSize();
|
||||
posTabs();
|
||||
|
||||
UIWidget::onPaddingChange();
|
||||
if ( NULL != mTabSelected && NULL != mTabSelected->getOwnedWidget() ) {
|
||||
mTabSelected->getOwnedWidget()->setSize( mCtrlContainer->getSize() );
|
||||
}
|
||||
}
|
||||
|
||||
void UITabWidget::applyThemeToTabs() {
|
||||
|
||||
@@ -66,13 +66,12 @@ UITheme* UITheme::loadFromTextureAtlas( UITheme* tTheme, Graphics::TextureAtlas*
|
||||
|
||||
tTheme->setTextureAtlas( textureAtlas );
|
||||
|
||||
std::list<TextureRegion*>& resources = textureAtlas->getResources();
|
||||
std::list<TextureRegion*>::iterator it;
|
||||
auto& resources = textureAtlas->getResources();
|
||||
std::string sAbbr( tTheme->getAbbr() + "_" );
|
||||
std::map<std::string, UISkin*> skins;
|
||||
|
||||
for ( it = resources.begin(); it != resources.end(); ++it ) {
|
||||
TextureRegion* textureRegion = *it;
|
||||
for ( auto& it : resources ) {
|
||||
TextureRegion* textureRegion = it.second;
|
||||
|
||||
std::string name( textureRegion->getName() );
|
||||
|
||||
@@ -257,7 +256,7 @@ UITheme* UITheme::loadFromTextureAtlas( Graphics::TextureAtlas* TextureAtlas,
|
||||
}
|
||||
|
||||
UITheme::UITheme( const std::string& name, const std::string& Abbr, Graphics::Font* defaultFont ) :
|
||||
ResourceManager<UISkin>( false ),
|
||||
ResourceManagerMulti<UISkin>(),
|
||||
mName( name ),
|
||||
mNameHash( String::hash( mName ) ),
|
||||
mAbbr( Abbr ),
|
||||
@@ -285,7 +284,7 @@ const std::string& UITheme::getAbbr() const {
|
||||
}
|
||||
|
||||
UISkin* UITheme::add( UISkin* Resource ) {
|
||||
return ResourceManager<UISkin>::add( Resource );
|
||||
return ResourceManagerMulti<UISkin>::add( Resource );
|
||||
}
|
||||
|
||||
Graphics::TextureAtlas* UITheme::getTextureAtlas() const {
|
||||
|
||||
@@ -8,7 +8,7 @@ UIThemeManager* UIThemeManager::New() {
|
||||
}
|
||||
|
||||
UIThemeManager::UIThemeManager() :
|
||||
ResourceManager<UITheme>( true ),
|
||||
ResourceManager<UITheme>(),
|
||||
mFont( NULL ),
|
||||
mFontSize( 12 ),
|
||||
mThemeDefault( NULL ),
|
||||
|
||||
@@ -235,6 +235,9 @@ void UIWidget::onChildCountChange( Node* child, const bool& removed ) {
|
||||
}
|
||||
|
||||
if ( !isSceneNodeLoading() && mUISceneNode != NULL && mStyle != NULL ) {
|
||||
// Childs that are structurally volatile can change states when a new
|
||||
// element is added to the parent. We pre-store them and invalidate its
|
||||
// state if that's the case.
|
||||
auto& svc = mStyle->getStructurallyVolatileChilds();
|
||||
for ( auto& child : svc ) {
|
||||
mUISceneNode->invalidateStyleState( child );
|
||||
|
||||
Reference in New Issue
Block a user