mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-05-28 17:16:29 +03:00
Implemented UIIconTeme and UIIconThemeManager, now the icon searches are using these new classes.
This commit is contained in:
4
TODO.md
4
TODO.md
@@ -1,10 +1,6 @@
|
||||
|
||||
# TODO - Short and mid term plans.
|
||||
|
||||
## UIIconTheme and UIIconThemeManager
|
||||
|
||||
Implement icon themes separated from the `UITheme` and customizable from a CSS file.
|
||||
|
||||
## UICodeEditor
|
||||
|
||||
* Add show white spaces.
|
||||
|
||||
@@ -58,7 +58,8 @@ TextInput,
|
||||
TextInputPassword,
|
||||
TextView,
|
||||
Tooltip,
|
||||
MenuBar::button {
|
||||
MenuBar::button,
|
||||
Window::title {
|
||||
color: var(--font);
|
||||
font-size: 11dp;
|
||||
}
|
||||
|
||||
@@ -77,7 +77,8 @@ class EE_API Font {
|
||||
/** @return The glyph drawable that represents the glyph in a texture. The glyph drawable
|
||||
* allocation is managed by the font. */
|
||||
virtual GlyphDrawable* getGlyphDrawable( Uint32 codePoint, unsigned int characterSize,
|
||||
bool bold, Float outlineThickness = 0 ) const = 0;
|
||||
bool bold = false,
|
||||
Float outlineThickness = 0 ) const = 0;
|
||||
|
||||
virtual Float getKerning( Uint32 first, Uint32 second, unsigned int characterSize ) const = 0;
|
||||
|
||||
|
||||
@@ -35,8 +35,8 @@ class EE_API FontBMFont : public Font {
|
||||
const Glyph& getGlyph( Uint32 codePoint, unsigned int characterSize, bool bold,
|
||||
Float outlineThickness = 0 ) const;
|
||||
|
||||
GlyphDrawable* getGlyphDrawable( Uint32 codePoint, unsigned int characterSize, bool bold,
|
||||
Float outlineThickness = 0 ) const;
|
||||
GlyphDrawable* getGlyphDrawable( Uint32 codePoint, unsigned int characterSize,
|
||||
bool bold = false, Float outlineThickness = 0 ) const;
|
||||
|
||||
Float getKerning( Uint32 first, Uint32 second, unsigned int characterSize ) const;
|
||||
|
||||
|
||||
@@ -39,8 +39,8 @@ class EE_API FontSprite : public Font {
|
||||
const Glyph& getGlyph( Uint32 codePoint, unsigned int characterSize, bool bold,
|
||||
Float outlineThickness = 0 ) const;
|
||||
|
||||
GlyphDrawable* getGlyphDrawable( Uint32 codePoint, unsigned int characterSize, bool bold,
|
||||
Float outlineThickness = 0 ) const;
|
||||
GlyphDrawable* getGlyphDrawable( Uint32 codePoint, unsigned int characterSize,
|
||||
bool bold = false, Float outlineThickness = 0 ) const;
|
||||
|
||||
Float getKerning( Uint32 first, Uint32 second, unsigned int characterSize ) const;
|
||||
|
||||
|
||||
@@ -33,8 +33,8 @@ class EE_API FontTrueType : public Font {
|
||||
const Glyph& getGlyph( Uint32 codePoint, unsigned int characterSize, bool bold,
|
||||
Float outlineThickness = 0 ) const;
|
||||
|
||||
GlyphDrawable* getGlyphDrawable( Uint32 codePoint, unsigned int characterSize, bool bold,
|
||||
Float outlineThickness = 0 ) const;
|
||||
GlyphDrawable* getGlyphDrawable( Uint32 codePoint, unsigned int characterSize,
|
||||
bool bold = false, Float outlineThickness = 0 ) const;
|
||||
|
||||
Float getKerning( Uint32 first, Uint32 second, unsigned int characterSize ) const;
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <eepp/ui/uidropdownlist.hpp>
|
||||
#include <eepp/ui/uifiledialog.hpp>
|
||||
#include <eepp/ui/uigridlayout.hpp>
|
||||
#include <eepp/ui/uiiconthememanager.hpp>
|
||||
#include <eepp/ui/uiimage.hpp>
|
||||
#include <eepp/ui/uilinearlayout.hpp>
|
||||
#include <eepp/ui/uilistbox.hpp>
|
||||
|
||||
32
include/eepp/ui/uiicontheme.hpp
Normal file
32
include/eepp/ui/uiicontheme.hpp
Normal file
@@ -0,0 +1,32 @@
|
||||
#ifndef EE_UI_UIICONTHEME_HPP
|
||||
#define EE_UI_UIICONTHEME_HPP
|
||||
|
||||
#include <eepp/graphics/drawable.hpp>
|
||||
#include <unordered_map>
|
||||
|
||||
using namespace EE::Graphics;
|
||||
|
||||
namespace EE { namespace UI {
|
||||
|
||||
class EE_API UIIconTheme {
|
||||
public:
|
||||
static UIIconTheme* New( const std::string& name );
|
||||
|
||||
UIIconTheme* add( const std::string& name, Drawable* drawable );
|
||||
|
||||
UIIconTheme* add( const std::unordered_map<std::string, Drawable*>& icons );
|
||||
|
||||
const std::string& getName() const;
|
||||
|
||||
Drawable* getIcon( const std::string& name ) const;
|
||||
|
||||
protected:
|
||||
std::string mName;
|
||||
std::unordered_map<std::string, Drawable*> mIcons;
|
||||
|
||||
UIIconTheme( const std::string& name );
|
||||
};
|
||||
|
||||
}} // namespace EE::UI
|
||||
|
||||
#endif // EE_UI_UIICONTHEME_HPP
|
||||
48
include/eepp/ui/uiiconthememanager.hpp
Normal file
48
include/eepp/ui/uiiconthememanager.hpp
Normal file
@@ -0,0 +1,48 @@
|
||||
#ifndef EE_UI_UIICONTHEMEMANAGER_HPP
|
||||
#define EE_UI_UIICONTHEMEMANAGER_HPP
|
||||
|
||||
#include <eepp/ui/uiicontheme.hpp>
|
||||
#include <vector>
|
||||
|
||||
namespace EE { namespace UI {
|
||||
|
||||
class UIThemeManager;
|
||||
|
||||
class EE_API UIIconThemeManager {
|
||||
public:
|
||||
static UIIconThemeManager* New();
|
||||
|
||||
~UIIconThemeManager();
|
||||
|
||||
UIIconThemeManager* add( UIIconTheme* iconTheme );
|
||||
|
||||
UIIconTheme* getCurrentTheme() const;
|
||||
|
||||
UIIconThemeManager* setCurrentTheme( UIIconTheme* currentTheme );
|
||||
|
||||
UIIconTheme* getFallbackTheme() const;
|
||||
|
||||
UIIconThemeManager* setFallbackTheme( UIIconTheme* fallbackTheme );
|
||||
|
||||
Drawable* findIcon( const std::string& name );
|
||||
|
||||
UIThemeManager* getFallbackThemeManager() const;
|
||||
|
||||
UIIconThemeManager* setFallbackThemeManager( UIThemeManager* fallbackThemeManager );
|
||||
|
||||
void remove( UIIconTheme* iconTheme );
|
||||
|
||||
protected:
|
||||
std::vector<UIIconTheme*> mIconThemes;
|
||||
UIIconTheme* mCurrentTheme{nullptr};
|
||||
UIIconTheme* mFallbackTheme{nullptr};
|
||||
UIThemeManager* mFallbackThemeManager{nullptr};
|
||||
|
||||
UIIconThemeManager();
|
||||
|
||||
bool isPresent( UIIconTheme* iconTheme );
|
||||
};
|
||||
|
||||
}} // namespace EE::UI
|
||||
|
||||
#endif // EE_UI_UIICONTHEMEMANAGER_HPP
|
||||
@@ -26,7 +26,7 @@ class EE_API UIMessageBox : public UIWindow {
|
||||
|
||||
virtual Uint32 onMessage( const NodeMessage* Msg );
|
||||
|
||||
virtual void setTheme( UITheme* Theme );
|
||||
virtual void setTheme( UITheme* theme );
|
||||
|
||||
UITextView* getTextBox() const;
|
||||
|
||||
@@ -36,9 +36,9 @@ class EE_API UIMessageBox : public UIWindow {
|
||||
|
||||
virtual bool show();
|
||||
|
||||
const Uint32& getCloseWithKey() const;
|
||||
const KeyBindings::Shortcut& getCloseWithKey() const;
|
||||
|
||||
void setCloseWithKey( const Uint32& closeWithKey );
|
||||
void setCloseWithKey( const KeyBindings::Shortcut& closeWithKey );
|
||||
|
||||
UITextInput* getTextInput() const;
|
||||
|
||||
@@ -48,12 +48,12 @@ class EE_API UIMessageBox : public UIWindow {
|
||||
UIPushButton* mButtonOK;
|
||||
UIPushButton* mButtonCancel;
|
||||
UITextInput* mTextInput;
|
||||
Uint32 mCloseWithKey;
|
||||
KeyBindings::Shortcut mCloseWithKey;
|
||||
UIWidget* mLayoutCont;
|
||||
|
||||
virtual void onWindowReady();
|
||||
|
||||
virtual Uint32 onKeyUp( const KeyEvent& Event );
|
||||
virtual Uint32 onKeyUp( const KeyEvent& event );
|
||||
};
|
||||
|
||||
}} // namespace EE::UI
|
||||
|
||||
@@ -14,6 +14,7 @@ class Font;
|
||||
namespace EE { namespace UI {
|
||||
|
||||
class UIThemeManager;
|
||||
class UIIconThemeManager;
|
||||
class UIWidget;
|
||||
class UIWindow;
|
||||
class UIWidget;
|
||||
@@ -104,6 +105,10 @@ class EE_API UISceneNode : public SceneNode {
|
||||
|
||||
const bool& isUpdatingLayouts() const;
|
||||
|
||||
UIIconThemeManager* getUIIconThemeManager() const;
|
||||
|
||||
Drawable* findIcon( const std::string& iconName );
|
||||
|
||||
protected:
|
||||
friend class EE::UI::UIWindow;
|
||||
friend class EE::UI::UIWidget;
|
||||
@@ -117,6 +122,7 @@ class EE_API UISceneNode : public SceneNode {
|
||||
bool mVerbose;
|
||||
bool mUpdatingLayouts;
|
||||
UIThemeManager* mUIThemeManager;
|
||||
UIIconThemeManager* mUIIconThemeManager;
|
||||
std::vector<Font*> mFontFaces;
|
||||
UIKeyboardShortcuts mKbShortcuts;
|
||||
std::unordered_set<UIWidget*> mDirtyStyle;
|
||||
|
||||
@@ -342,6 +342,8 @@
|
||||
../../include/eepp/ui/uifontstyleconfig.hpp
|
||||
../../include/eepp/ui/uigridlayout.hpp
|
||||
../../include/eepp/ui/uihelper.hpp
|
||||
../../include/eepp/ui/uiicontheme.hpp
|
||||
../../include/eepp/ui/uiiconthememanager.hpp
|
||||
../../include/eepp/ui/uiimage.hpp
|
||||
../../include/eepp/ui/uiitemcontainer.hpp
|
||||
../../include/eepp/ui/uilayout.hpp
|
||||
@@ -794,6 +796,8 @@
|
||||
../../src/eepp/ui/uieventdispatcher.cpp
|
||||
../../src/eepp/ui/uifiledialog.cpp
|
||||
../../src/eepp/ui/uigridlayout.cpp
|
||||
../../src/eepp/ui/uiicontheme.cpp
|
||||
../../src/eepp/ui/uiiconthememanager.cpp
|
||||
../../src/eepp/ui/uiimage.cpp
|
||||
../../src/eepp/ui/uilayout.cpp
|
||||
../../src/eepp/ui/uilinearlayout.cpp
|
||||
|
||||
@@ -9,3 +9,5 @@
|
||||
../../docs/articles
|
||||
../../include/eepp/ui/doc
|
||||
../../src/eepp/ui/doc
|
||||
../../include/eepp/ui
|
||||
../../src/eepp/ui
|
||||
|
||||
@@ -117,16 +117,17 @@ void MapEditor::createMenuBar() {
|
||||
mTileBox->updateAnchorsDistances();
|
||||
|
||||
UIPopUpMenu* PU1 = UIPopUpMenu::New();
|
||||
|
||||
PU1->setParent( mUIContainer );
|
||||
PU1->add( "New...", mTheme->getIconByName( "document-new" ) );
|
||||
PU1->add( "Open...", mTheme->getIconByName( "document-open" ) );
|
||||
PU1->add( "New...", PU1->getUISceneNode()->findIcon( "document-new" ) );
|
||||
PU1->add( "Open...", PU1->getUISceneNode()->findIcon( "document-open" ) );
|
||||
PU1->addSeparator();
|
||||
PU1->add( "Save", mTheme->getIconByName( "document-save" ) );
|
||||
PU1->add( "Save As...", mTheme->getIconByName( "document-save-as" ) );
|
||||
PU1->add( "Save", PU1->getUISceneNode()->findIcon( "document-save" ) );
|
||||
PU1->add( "Save As...", PU1->getUISceneNode()->findIcon( "document-save-as" ) );
|
||||
PU1->addSeparator();
|
||||
PU1->add( "Close", mTheme->getIconByName( "document-close" ) );
|
||||
PU1->add( "Close", PU1->getUISceneNode()->findIcon( "document-close" ) );
|
||||
PU1->addSeparator();
|
||||
PU1->add( "Quit", mTheme->getIconByName( "quit" ) );
|
||||
PU1->add( "Quit", PU1->getUISceneNode()->findIcon( "quit" ) );
|
||||
|
||||
PU1->addEventListener( Event::OnItemClicked, cb::Make1( this, &MapEditor::fileMenuClick ) );
|
||||
MenuBar->addMenuButton( "File", PU1 );
|
||||
@@ -142,11 +143,11 @@ void MapEditor::createMenuBar() {
|
||||
PU3->addSeparator();
|
||||
|
||||
addShortcut( KEY_KP_PLUS, KEYMOD_CTRL,
|
||||
PU3->add( "Zoom In", mTheme->getIconByName( "zoom-in" ) ) );
|
||||
PU3->add( "Zoom In", PU3->getUISceneNode()->findIcon( "zoom-in" ) ) );
|
||||
addShortcut( KEY_KP_MINUS, KEYMOD_CTRL,
|
||||
PU3->add( "Zoom Out", mTheme->getIconByName( "zoom-out" ) ) );
|
||||
PU3->add( "Zoom Out", PU3->getUISceneNode()->findIcon( "zoom-out" ) ) );
|
||||
addShortcut( KEY_0, KEYMOD_CTRL,
|
||||
PU3->add( "Normal Size", mTheme->getIconByName( "zoom-original" ) ) );
|
||||
PU3->add( "Normal Size", PU3->getUISceneNode()->findIcon( "zoom-original" ) ) );
|
||||
PU3->addSeparator();
|
||||
|
||||
PU3->addEventListener( Event::OnItemClicked, cb::Make1( this, &MapEditor::viewMenuClick ) );
|
||||
@@ -304,7 +305,7 @@ void MapEditor::createTextureRegionContainer( Int32 Width ) {
|
||||
->setSize( 24, mGOTypeList->getSize().getHeight() )
|
||||
->setPosition( mGOTypeList->getPosition().x + mGOTypeList->getSize().getWidth() + 2,
|
||||
mGOTypeList->getPosition().y );
|
||||
mBtnGOTypeAdd->setIcon( mTheme->getIconByName( "add" ) )
|
||||
mBtnGOTypeAdd->setIcon( mBtnGOTypeAdd->getUISceneNode()->findIcon( "add" ) )
|
||||
->setAnchors( UI_ANCHOR_RIGHT | UI_ANCHOR_TOP );
|
||||
mBtnGOTypeAdd->setTooltipText( "Adds a new game object type\nunknown by the map editor." );
|
||||
mBtnGOTypeAdd->addEventListener( Event::MouseClick,
|
||||
|
||||
@@ -15,7 +15,9 @@ MapLayerProperties::MapLayerProperties( MapLayer* Map, RefreshLayerListCb Cb ) :
|
||||
if ( SceneManager::instance()->getUISceneNode() == NULL )
|
||||
return;
|
||||
|
||||
mUITheme = SceneManager::instance()->getUISceneNode()->getUIThemeManager()->getDefaultTheme();
|
||||
UISceneNode* sceneNode = SceneManager::instance()->getUISceneNode();
|
||||
|
||||
mUITheme = sceneNode->getUIThemeManager()->getDefaultTheme();
|
||||
|
||||
if ( NULL == mUITheme )
|
||||
return;
|
||||
@@ -65,7 +67,7 @@ MapLayerProperties::MapLayerProperties( MapLayer* Map, RefreshLayerListCb Cb ) :
|
||||
|
||||
UIPushButton* OKButton = UIPushButton::New();
|
||||
OKButton->setSize( 80, 0 )->setParent( mUIWindow->getContainer() );
|
||||
OKButton->setIcon( mUITheme->getIconByName( "ok" ) );
|
||||
OKButton->setIcon( sceneNode->findIcon( "ok" ) );
|
||||
OKButton->setPosition(
|
||||
mUIWindow->getContainer()->getSize().getWidth() - OKButton->getSize().getWidth() - 4,
|
||||
mUIWindow->getContainer()->getSize().getHeight() - OKButton->getSize().getHeight() - 4 );
|
||||
@@ -79,7 +81,7 @@ MapLayerProperties::MapLayerProperties( MapLayer* Map, RefreshLayerListCb Cb ) :
|
||||
->setSize( OKButton->getSize() )
|
||||
->setPosition( OKButton->getPosition().x - OKButton->getSize().getWidth() - 4,
|
||||
OKButton->getPosition().y );
|
||||
CancelButton->setIcon( mUITheme->getIconByName( "cancel" ) );
|
||||
CancelButton->setIcon( sceneNode->findIcon( "cancel" ) );
|
||||
CancelButton->addEventListener( Event::MouseClick,
|
||||
cb::Make1( this, &MapLayerProperties::onCancelClick ) );
|
||||
CancelButton->setText( "Cancel" );
|
||||
@@ -102,7 +104,7 @@ MapLayerProperties::MapLayerProperties( MapLayer* Map, RefreshLayerListCb Cb ) :
|
||||
|
||||
UIPushButton* AddButton = UIPushButton::New();
|
||||
AddButton->setParent( mUIWindow->getContainer() )->setSize( 24, 0 )->setPosition( Pos );
|
||||
AddButton->setIcon( mUITheme->getIconByName( "add" ) );
|
||||
AddButton->setIcon( sceneNode->findIcon( "add" ) );
|
||||
AddButton->setAnchors( UI_ANCHOR_RIGHT | UI_ANCHOR_TOP );
|
||||
AddButton->addEventListener( Event::MouseClick,
|
||||
cb::Make1( this, &MapLayerProperties::onAddCellClick ) );
|
||||
@@ -114,7 +116,7 @@ MapLayerProperties::MapLayerProperties( MapLayer* Map, RefreshLayerListCb Cb ) :
|
||||
|
||||
UIPushButton* RemoveButton = UIPushButton::New();
|
||||
RemoveButton->setParent( mUIWindow->getContainer() )->setSize( 24, 0 )->setPosition( Pos );
|
||||
RemoveButton->setIcon( mUITheme->getIconByName( "remove" ) );
|
||||
RemoveButton->setIcon( sceneNode->findIcon( "remove" ) );
|
||||
RemoveButton->setAnchors( UI_ANCHOR_RIGHT | UI_ANCHOR_TOP );
|
||||
RemoveButton->addEventListener( Event::MouseClick,
|
||||
cb::Make1( this, &MapLayerProperties::onRemoveCellClick ) );
|
||||
|
||||
@@ -31,7 +31,8 @@ MapObjectProperties::MapObjectProperties( GameObjectObject* Obj ) :
|
||||
if ( SceneManager::instance()->getUISceneNode() == NULL )
|
||||
return;
|
||||
|
||||
mUITheme = SceneManager::instance()->getUISceneNode()->getUIThemeManager()->getDefaultTheme();
|
||||
UISceneNode* sceneNode = SceneManager::instance()->getUISceneNode();
|
||||
mUITheme = sceneNode->getUIThemeManager()->getDefaultTheme();
|
||||
|
||||
if ( NULL == mUITheme )
|
||||
return;
|
||||
@@ -84,7 +85,7 @@ MapObjectProperties::MapObjectProperties( GameObjectObject* Obj ) :
|
||||
|
||||
UIPushButton* OKButton = UIPushButton::New();
|
||||
OKButton->setParent( mUIWindow->getContainer() )->setSize( 80, 0 );
|
||||
OKButton->setIcon( mUITheme->getIconByName( "ok" ) );
|
||||
OKButton->setIcon( sceneNode->findIcon( "ok" ) );
|
||||
OKButton->setPosition(
|
||||
mUIWindow->getContainer()->getSize().getWidth() - OKButton->getSize().getWidth() - 4,
|
||||
mUIWindow->getContainer()->getSize().getHeight() - OKButton->getSize().getHeight() - 4 );
|
||||
@@ -98,7 +99,7 @@ MapObjectProperties::MapObjectProperties( GameObjectObject* Obj ) :
|
||||
->setSize( OKButton->getSize() )
|
||||
->setPosition( OKButton->getPosition().x - OKButton->getSize().getWidth() - 4,
|
||||
OKButton->getPosition().y );
|
||||
CancelButton->setIcon( mUITheme->getIconByName( "cancel" ) );
|
||||
CancelButton->setIcon( sceneNode->findIcon( "cancel" ) );
|
||||
CancelButton->addEventListener( Event::MouseClick,
|
||||
cb::Make1( this, &MapObjectProperties::onCancelClick ) );
|
||||
CancelButton->setText( "Cancel" );
|
||||
@@ -121,7 +122,7 @@ MapObjectProperties::MapObjectProperties( GameObjectObject* Obj ) :
|
||||
|
||||
UIPushButton* AddButton = UIPushButton::New();
|
||||
AddButton->setParent( mUIWindow->getContainer() )->setSize( 24, 0 )->setPosition( Pos );
|
||||
AddButton->setIcon( mUITheme->getIconByName( "add" ) );
|
||||
AddButton->setIcon( sceneNode->findIcon( "add" ) );
|
||||
AddButton->setAnchors( UI_ANCHOR_RIGHT | UI_ANCHOR_TOP );
|
||||
AddButton->addEventListener( Event::MouseClick,
|
||||
cb::Make1( this, &MapObjectProperties::onAddCellClick ) );
|
||||
@@ -133,7 +134,7 @@ MapObjectProperties::MapObjectProperties( GameObjectObject* Obj ) :
|
||||
|
||||
UIPushButton* RemoveButton = UIPushButton::New();
|
||||
RemoveButton->setParent( mUIWindow->getContainer() )->setSize( 24, 0 )->setPosition( Pos );
|
||||
RemoveButton->setIcon( mUITheme->getIconByName( "remove" ) );
|
||||
RemoveButton->setIcon( sceneNode->findIcon( "remove" ) );
|
||||
RemoveButton->setAnchors( UI_ANCHOR_RIGHT | UI_ANCHOR_TOP );
|
||||
RemoveButton->addEventListener( Event::MouseClick,
|
||||
cb::Make1( this, &MapObjectProperties::onRemoveCellClick ) );
|
||||
|
||||
@@ -31,7 +31,8 @@ TileMapProperties::TileMapProperties( TileMap* Map ) :
|
||||
if ( SceneManager::instance()->getUISceneNode() == NULL )
|
||||
return;
|
||||
|
||||
mUITheme = SceneManager::instance()->getUISceneNode()->getUIThemeManager()->getDefaultTheme();
|
||||
UISceneNode* sceneNode = SceneManager::instance()->getUISceneNode();
|
||||
mUITheme = sceneNode->getUIThemeManager()->getDefaultTheme();
|
||||
|
||||
if ( NULL == mUITheme )
|
||||
return;
|
||||
@@ -135,7 +136,7 @@ TileMapProperties::TileMapProperties( TileMap* Map ) :
|
||||
|
||||
UIPushButton* OKButton = UIPushButton::New();
|
||||
OKButton->setSize( 80, 0 )->setParent( mUIWindow->getContainer() );
|
||||
OKButton->setIcon( mUITheme->getIconByName( "ok" ) );
|
||||
OKButton->setIcon( sceneNode->findIcon( "ok" ) );
|
||||
OKButton->setPosition(
|
||||
mUIWindow->getContainer()->getSize().getWidth() - OKButton->getSize().getWidth() - 4,
|
||||
mUIWindow->getContainer()->getSize().getHeight() - OKButton->getSize().getHeight() - 4 );
|
||||
@@ -149,7 +150,7 @@ TileMapProperties::TileMapProperties( TileMap* Map ) :
|
||||
->setSize( OKButton->getSize() )
|
||||
->setPosition( OKButton->getPosition().x - OKButton->getSize().getWidth() - 4,
|
||||
OKButton->getPosition().y );
|
||||
CancelButton->setIcon( mUITheme->getIconByName( "cancel" ) );
|
||||
CancelButton->setIcon( sceneNode->findIcon( "cancel" ) );
|
||||
CancelButton->addEventListener( Event::MouseClick,
|
||||
cb::Make1( this, &TileMapProperties::onCancelClick ) );
|
||||
CancelButton->setText( "Cancel" );
|
||||
@@ -172,7 +173,7 @@ TileMapProperties::TileMapProperties( TileMap* Map ) :
|
||||
|
||||
UIPushButton* AddButton = UIPushButton::New();
|
||||
AddButton->setSize( 24, 0 )->setParent( mUIWindow->getContainer() )->setPosition( Pos );
|
||||
AddButton->setIcon( mUITheme->getIconByName( "add" ) );
|
||||
AddButton->setIcon( sceneNode->findIcon( "add" ) );
|
||||
AddButton->setAnchors( UI_ANCHOR_RIGHT | UI_ANCHOR_TOP );
|
||||
AddButton->addEventListener( Event::MouseClick,
|
||||
cb::Make1( this, &TileMapProperties::onAddCellClick ) );
|
||||
@@ -184,7 +185,7 @@ TileMapProperties::TileMapProperties( TileMap* Map ) :
|
||||
|
||||
UIPushButton* RemoveButton = UIPushButton::New();
|
||||
RemoveButton->setSize( 24, 0 )->setParent( mUIWindow->getContainer() )->setPosition( Pos );
|
||||
RemoveButton->setIcon( mUITheme->getIconByName( "remove" ) );
|
||||
RemoveButton->setIcon( sceneNode->findIcon( "remove" ) );
|
||||
RemoveButton->setAnchors( UI_ANCHOR_RIGHT | UI_ANCHOR_TOP );
|
||||
RemoveButton->addEventListener( Event::MouseClick,
|
||||
cb::Make1( this, &TileMapProperties::onRemoveCellClick ) );
|
||||
|
||||
@@ -10,7 +10,8 @@ UIGOTypeNew::UIGOTypeNew( std::function<void( std::string, Uint32 )> Cb ) :
|
||||
if ( SceneManager::instance()->getUISceneNode() == NULL )
|
||||
return;
|
||||
|
||||
mUITheme = SceneManager::instance()->getUISceneNode()->getUIThemeManager()->getDefaultTheme();
|
||||
UISceneNode* sceneNode = SceneManager::instance()->getUISceneNode();
|
||||
mUITheme = sceneNode->getUIThemeManager()->getDefaultTheme();
|
||||
|
||||
if ( NULL == mUITheme )
|
||||
return;
|
||||
@@ -41,7 +42,7 @@ UIGOTypeNew::UIGOTypeNew( std::function<void( std::string, Uint32 )> Cb ) :
|
||||
|
||||
UIPushButton* OKButton = UIPushButton::New();
|
||||
OKButton->setSize( 80, 0 )->setParent( mUIWindow->getContainer() );
|
||||
OKButton->setIcon( mUITheme->getIconByName( "add" ) );
|
||||
OKButton->setIcon( sceneNode->findIcon( "add" ) );
|
||||
OKButton->setPosition(
|
||||
mUIWindow->getContainer()->getSize().getWidth() - OKButton->getSize().getWidth() - 4,
|
||||
mUIWindow->getContainer()->getSize().getHeight() - OKButton->getSize().getHeight() - 4 );
|
||||
@@ -55,7 +56,7 @@ UIGOTypeNew::UIGOTypeNew( std::function<void( std::string, Uint32 )> Cb ) :
|
||||
->setSize( OKButton->getSize() )
|
||||
->setPosition( OKButton->getPosition().x - OKButton->getSize().getWidth() - 4,
|
||||
OKButton->getPosition().y );
|
||||
CancelButton->setIcon( mUITheme->getIconByName( "cancel" ) );
|
||||
CancelButton->setIcon( sceneNode->findIcon( "cancel" ) );
|
||||
CancelButton->addEventListener( Event::MouseClick,
|
||||
cb::Make1( this, &UIGOTypeNew::onCancelClick ) );
|
||||
CancelButton->setText( "Cancel" );
|
||||
|
||||
@@ -15,7 +15,8 @@ UIMapLayerNew::UIMapLayerNew( UIMap* Map, EE_LAYER_TYPE Type, NewLayerCb newLaye
|
||||
if ( SceneManager::instance()->getUISceneNode() == NULL )
|
||||
return;
|
||||
|
||||
mTheme = SceneManager::instance()->getUISceneNode()->getUIThemeManager()->getDefaultTheme();
|
||||
UISceneNode* sceneNode = SceneManager::instance()->getUISceneNode();
|
||||
mTheme = sceneNode->getUIThemeManager()->getDefaultTheme();
|
||||
|
||||
if ( NULL == mTheme )
|
||||
return;
|
||||
@@ -51,7 +52,7 @@ UIMapLayerNew::UIMapLayerNew( UIMap* Map, EE_LAYER_TYPE Type, NewLayerCb newLaye
|
||||
|
||||
UIPushButton* OKButton = UIPushButton::New();
|
||||
OKButton->setSize( 80, 0 )->setParent( mUIWindow->getContainer() );
|
||||
OKButton->setIcon( mTheme->getIconByName( "add" ) );
|
||||
OKButton->setIcon( sceneNode->findIcon( "add" ) );
|
||||
OKButton->setPosition(
|
||||
mUIWindow->getContainer()->getSize().getWidth() - OKButton->getSize().getWidth() - 4,
|
||||
mUIWindow->getContainer()->getSize().getHeight() - OKButton->getSize().getHeight() - 4 );
|
||||
@@ -66,7 +67,7 @@ UIMapLayerNew::UIMapLayerNew( UIMap* Map, EE_LAYER_TYPE Type, NewLayerCb newLaye
|
||||
->setSize( OKButton->getSize() )
|
||||
->setPosition( OKButton->getPosition().x - OKButton->getSize().getWidth() - 4,
|
||||
OKButton->getPosition().y );
|
||||
CancelButton->setIcon( mTheme->getIconByName( "cancel" ) );
|
||||
CancelButton->setIcon( sceneNode->findIcon( "cancel" ) );
|
||||
CancelButton->addEventListener( Event::MouseClick,
|
||||
cb::Make1( this, &UIMapLayerNew::onCancelClick ) );
|
||||
CancelButton->setText( "Cancel" );
|
||||
|
||||
@@ -30,7 +30,8 @@ UIMapNew::UIMapNew( UIMap* Map, std::function<void()> NewMapCb, bool ResizeMap )
|
||||
if ( SceneManager::instance()->getUISceneNode() == NULL )
|
||||
return;
|
||||
|
||||
mTheme = SceneManager::instance()->getUISceneNode()->getUIThemeManager()->getDefaultTheme();
|
||||
UISceneNode* sceneNode = SceneManager::instance()->getUISceneNode();
|
||||
mTheme = sceneNode->getUIThemeManager()->getDefaultTheme();
|
||||
|
||||
if ( NULL == mTheme )
|
||||
return;
|
||||
@@ -280,7 +281,7 @@ UIMapNew::UIMapNew( UIMap* Map, std::function<void()> NewMapCb, bool ResizeMap )
|
||||
|
||||
UIPushButton* OKButton = UIPushButton::New();
|
||||
OKButton->setParent( mUIWindow->getContainer() )->setSize( 80, 0 );
|
||||
OKButton->setIcon( mTheme->getIconByName( "ok" ) );
|
||||
OKButton->setIcon( sceneNode->findIcon( "ok" ) );
|
||||
OKButton->setPosition(
|
||||
mUIWindow->getContainer()->getSize().getWidth() - OKButton->getSize().getWidth() - 4,
|
||||
mUIWindow->getContainer()->getSize().getHeight() - OKButton->getSize().getHeight() - 4 );
|
||||
@@ -292,7 +293,7 @@ UIMapNew::UIMapNew( UIMap* Map, std::function<void()> NewMapCb, bool ResizeMap )
|
||||
->setSize( OKButton->getSize() )
|
||||
->setPosition( OKButton->getPosition().x - OKButton->getSize().getWidth() - 4,
|
||||
OKButton->getPosition().y );
|
||||
CancelButton->setIcon( mTheme->getIconByName( "cancel" ) );
|
||||
CancelButton->setIcon( sceneNode->findIcon( "cancel" ) );
|
||||
CancelButton->addEventListener( Event::MouseClick,
|
||||
cb::Make1( this, &UIMapNew::onCancelClick ) );
|
||||
CancelButton->setText( "Cancel" );
|
||||
|
||||
@@ -77,6 +77,7 @@ UIFileDialog::UIFileDialog( Uint32 dialogFlags, std::string defaultFilePattern,
|
||||
|
||||
mButtonUp = UIPushButton::New();
|
||||
mButtonUp->setText( "Up" )
|
||||
->setLayoutMarginLeft( 4 )
|
||||
->setLayoutSizePolicy( SizePolicy::WrapContent, SizePolicy::MatchParent )
|
||||
->setParent( hLayout );
|
||||
|
||||
@@ -182,11 +183,11 @@ void UIFileDialog::setTheme( UITheme* Theme ) {
|
||||
mFile->setTheme( Theme );
|
||||
mFiletype->setTheme( Theme );
|
||||
|
||||
Drawable* Icon = Theme->getIconByName( "go-up" );
|
||||
Drawable* icon = getUISceneNode()->findIcon( "go-up" );
|
||||
|
||||
if ( NULL != Icon ) {
|
||||
if ( NULL != icon ) {
|
||||
mButtonUp->setText( "" );
|
||||
mButtonUp->setIcon( Icon );
|
||||
mButtonUp->setIcon( icon );
|
||||
}
|
||||
|
||||
onThemeLoaded();
|
||||
|
||||
31
src/eepp/ui/uiicontheme.cpp
Normal file
31
src/eepp/ui/uiicontheme.cpp
Normal file
@@ -0,0 +1,31 @@
|
||||
#include <eepp/core/core.hpp>
|
||||
#include <eepp/ui/uiicontheme.hpp>
|
||||
|
||||
namespace EE { namespace UI {
|
||||
|
||||
UIIconTheme* UIIconTheme::New( const std::string& name ) {
|
||||
return eeNew( UIIconTheme, ( name ) );
|
||||
}
|
||||
|
||||
UIIconTheme::UIIconTheme( const std::string& name ) : mName( name ) {}
|
||||
|
||||
UIIconTheme* UIIconTheme::add( const std::string& name, Drawable* drawable ) {
|
||||
mIcons[name] = drawable;
|
||||
return this;
|
||||
}
|
||||
|
||||
UIIconTheme* UIIconTheme::add( const std::unordered_map<std::string, Drawable*>& icons ) {
|
||||
mIcons.insert( icons.begin(), icons.end() );
|
||||
return this;
|
||||
}
|
||||
|
||||
const std::string& UIIconTheme::getName() const {
|
||||
return mName;
|
||||
}
|
||||
|
||||
Drawable* UIIconTheme::getIcon( const std::string& name ) const {
|
||||
auto it = mIcons.find( name );
|
||||
return it != mIcons.end() ? it->second : nullptr;
|
||||
}
|
||||
|
||||
}} // namespace EE::UI
|
||||
96
src/eepp/ui/uiiconthememanager.cpp
Normal file
96
src/eepp/ui/uiiconthememanager.cpp
Normal file
@@ -0,0 +1,96 @@
|
||||
#include <algorithm>
|
||||
#include <eepp/ui/uiiconthememanager.hpp>
|
||||
#include <eepp/ui/uithememanager.hpp>
|
||||
|
||||
namespace EE { namespace UI {
|
||||
|
||||
UIIconThemeManager* UIIconThemeManager::New() {
|
||||
return eeNew( UIIconThemeManager, () );
|
||||
}
|
||||
|
||||
UIIconThemeManager::~UIIconThemeManager() {
|
||||
for ( UIIconTheme* theme : mIconThemes )
|
||||
eeDelete( theme );
|
||||
}
|
||||
|
||||
UIIconThemeManager::UIIconThemeManager() {}
|
||||
|
||||
UIIconThemeManager* UIIconThemeManager::add( UIIconTheme* iconTheme ) {
|
||||
if ( !isPresent( iconTheme ) ) {
|
||||
mIconThemes.push_back( iconTheme );
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
UIIconTheme* UIIconThemeManager::getCurrentTheme() const {
|
||||
return mCurrentTheme;
|
||||
}
|
||||
|
||||
UIIconThemeManager* UIIconThemeManager::setCurrentTheme( UIIconTheme* currentTheme ) {
|
||||
if ( currentTheme != mCurrentTheme && currentTheme != mFallbackTheme ) {
|
||||
if ( !isPresent( currentTheme ) )
|
||||
add( currentTheme );
|
||||
mCurrentTheme = currentTheme;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
UIIconTheme* UIIconThemeManager::getFallbackTheme() const {
|
||||
return mFallbackTheme;
|
||||
}
|
||||
|
||||
UIIconThemeManager* UIIconThemeManager::setFallbackTheme( UIIconTheme* fallbackTheme ) {
|
||||
if ( fallbackTheme != mFallbackTheme && fallbackTheme != mCurrentTheme ) {
|
||||
if ( !isPresent( fallbackTheme ) )
|
||||
add( fallbackTheme );
|
||||
mFallbackTheme = fallbackTheme;
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
Drawable* UIIconThemeManager::findIcon( const std::string& name ) {
|
||||
Drawable* icon = nullptr;
|
||||
if ( mCurrentTheme ) {
|
||||
icon = mCurrentTheme->getIcon( name );
|
||||
if ( icon )
|
||||
return icon;
|
||||
}
|
||||
if ( mFallbackTheme ) {
|
||||
icon = mFallbackTheme->getIcon( name );
|
||||
if ( icon )
|
||||
return icon;
|
||||
}
|
||||
if ( mFallbackThemeManager && mFallbackThemeManager->getDefaultTheme() ) {
|
||||
return mFallbackThemeManager->getDefaultTheme()->getIconByName( name );
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
UIThemeManager* UIIconThemeManager::getFallbackThemeManager() const {
|
||||
return mFallbackThemeManager;
|
||||
}
|
||||
|
||||
UIIconThemeManager*
|
||||
UIIconThemeManager::setFallbackThemeManager( UIThemeManager* fallbackThemeManager ) {
|
||||
mFallbackThemeManager = fallbackThemeManager;
|
||||
return this;
|
||||
}
|
||||
|
||||
void UIIconThemeManager::remove( UIIconTheme* iconTheme ) {
|
||||
auto pos = std::find( mIconThemes.begin(), mIconThemes.end(), iconTheme );
|
||||
if ( pos != mIconThemes.end() ) {
|
||||
if ( *pos == mCurrentTheme ) {
|
||||
mCurrentTheme = mFallbackTheme;
|
||||
mFallbackTheme = nullptr;
|
||||
} else if ( *pos == mFallbackTheme ) {
|
||||
mFallbackTheme = nullptr;
|
||||
}
|
||||
mIconThemes.erase( pos );
|
||||
}
|
||||
}
|
||||
|
||||
bool UIIconThemeManager::isPresent( UIIconTheme* iconTheme ) {
|
||||
return std::find( mIconThemes.begin(), mIconThemes.end(), iconTheme ) != mIconThemes.end();
|
||||
}
|
||||
|
||||
}} // namespace EE::UI
|
||||
@@ -3,7 +3,7 @@
|
||||
#include <eepp/graphics/sprite.hpp>
|
||||
#include <eepp/ui/css/propertydefinition.hpp>
|
||||
#include <eepp/ui/uiimage.hpp>
|
||||
#include <eepp/ui/uithememanager.hpp>
|
||||
#include <eepp/ui/uiscenenode.hpp>
|
||||
|
||||
namespace EE { namespace UI {
|
||||
|
||||
@@ -260,7 +260,7 @@ bool UIImage::applyProperty( const StyleSheetProperty& attribute ) {
|
||||
case PropertyId::Icon: {
|
||||
std::string val = attribute.asString();
|
||||
Drawable* icon = NULL;
|
||||
if ( NULL != mTheme && NULL != ( icon = mTheme->getIconByName( val ) ) ) {
|
||||
if ( NULL != ( icon = getUISceneNode()->findIcon( val ) ) ) {
|
||||
setDrawable( icon );
|
||||
} else if ( NULL != ( icon = DrawableSearcher::searchByName( val ) ) ) {
|
||||
setDrawable( icon );
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include <eepp/graphics/drawablesearcher.hpp>
|
||||
#include <eepp/graphics/font.hpp>
|
||||
#include <eepp/ui/css/propertydefinition.hpp>
|
||||
#include <eepp/ui/uiiconthememanager.hpp>
|
||||
#include <eepp/ui/uimenu.hpp>
|
||||
#include <eepp/ui/uipopupmenu.hpp>
|
||||
#include <eepp/ui/uiscenenode.hpp>
|
||||
@@ -542,11 +543,11 @@ Uint32 UIMenu::onKeyDown( const KeyEvent& Event ) {
|
||||
return UIWidget::onKeyDown( Event );
|
||||
}
|
||||
|
||||
static Drawable* getIconDrawable( const std::string& name, UITheme* theme ) {
|
||||
static Drawable* getIconDrawable( const std::string& name, UIIconThemeManager* iconThemeManager ) {
|
||||
Drawable* iconDrawable = NULL;
|
||||
|
||||
if ( NULL != theme )
|
||||
iconDrawable = theme->getIconByName( name );
|
||||
if ( NULL != iconThemeManager )
|
||||
iconDrawable = iconThemeManager->findIcon( name );
|
||||
|
||||
if ( NULL == iconDrawable )
|
||||
iconDrawable = DrawableSearcher::searchByName( name );
|
||||
@@ -569,8 +570,7 @@ void UIMenu::loadFromXmlNode( const pugi::xml_node& node ) {
|
||||
|
||||
if ( NULL != mSceneNode && mSceneNode->isUISceneNode() )
|
||||
add( static_cast<UISceneNode*>( mSceneNode )->getTranslatorString( text ),
|
||||
getIconDrawable( icon,
|
||||
getUISceneNode()->getUIThemeManager()->getDefaultTheme() ) );
|
||||
getIconDrawable( icon, getUISceneNode()->getUIIconThemeManager() ) );
|
||||
} else if ( name == "menuseparator" || name == "separator" ) {
|
||||
addSeparator();
|
||||
} else if ( name == "menucheckbox" || name == "checkbox" ) {
|
||||
@@ -593,8 +593,7 @@ void UIMenu::loadFromXmlNode( const pugi::xml_node& node ) {
|
||||
|
||||
if ( NULL != mSceneNode && mSceneNode->isUISceneNode() )
|
||||
addSubMenu( static_cast<UISceneNode*>( mSceneNode )->getTranslatorString( text ),
|
||||
getIconDrawable(
|
||||
icon, getUISceneNode()->getUIThemeManager()->getDefaultTheme() ),
|
||||
getIconDrawable( icon, getUISceneNode()->getUIIconThemeManager() ),
|
||||
subMenu );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -94,23 +94,23 @@ UIMessageBox::UIMessageBox( const Type& type, const String& message, const Uint3
|
||||
|
||||
UIMessageBox::~UIMessageBox() {}
|
||||
|
||||
void UIMessageBox::setTheme( UITheme* Theme ) {
|
||||
UIWindow::setTheme( Theme );
|
||||
void UIMessageBox::setTheme( UITheme* theme ) {
|
||||
UIWindow::setTheme( theme );
|
||||
|
||||
mTextBox->setTheme( Theme );
|
||||
mButtonOK->setTheme( Theme );
|
||||
mButtonCancel->setTheme( Theme );
|
||||
mTextBox->setTheme( theme );
|
||||
mButtonOK->setTheme( theme );
|
||||
mButtonCancel->setTheme( theme );
|
||||
|
||||
if ( "Retry" != mButtonOK->getText() ) {
|
||||
Drawable* OKIcon = Theme->getIconByName( "ok" );
|
||||
Drawable* CancelIcon = Theme->getIconByName( "cancel" );
|
||||
Drawable* okIcon = getUISceneNode()->findIcon( "ok" );
|
||||
Drawable* cancelIcon = getUISceneNode()->findIcon( "cancel" );
|
||||
|
||||
if ( NULL != OKIcon ) {
|
||||
mButtonOK->setIcon( OKIcon );
|
||||
if ( NULL != okIcon ) {
|
||||
mButtonOK->setIcon( okIcon );
|
||||
}
|
||||
|
||||
if ( NULL != CancelIcon ) {
|
||||
mButtonCancel->setIcon( CancelIcon );
|
||||
if ( NULL != cancelIcon ) {
|
||||
mButtonCancel->setIcon( cancelIcon );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,8 +149,9 @@ UIPushButton* UIMessageBox::getButtonCancel() const {
|
||||
return mButtonCancel;
|
||||
}
|
||||
|
||||
Uint32 UIMessageBox::onKeyUp( const KeyEvent& Event ) {
|
||||
if ( mCloseWithKey && Event.getKeyCode() == mCloseWithKey ) {
|
||||
Uint32 UIMessageBox::onKeyUp( const KeyEvent& event ) {
|
||||
if ( mCloseWithKey && event.getKeyCode() == mCloseWithKey &&
|
||||
( event.getMod() & mCloseWithKey.mod ) ) {
|
||||
sendCommonEvent( Event::MsgBoxCancelClick );
|
||||
closeWindow();
|
||||
}
|
||||
@@ -168,11 +169,11 @@ bool UIMessageBox::show() {
|
||||
return b;
|
||||
}
|
||||
|
||||
const Uint32& UIMessageBox::getCloseWithKey() const {
|
||||
const KeyBindings::Shortcut& UIMessageBox::getCloseWithKey() const {
|
||||
return mCloseWithKey;
|
||||
}
|
||||
|
||||
void UIMessageBox::setCloseWithKey( const Uint32& closeWithKey ) {
|
||||
void UIMessageBox::setCloseWithKey( const KeyBindings::Shortcut& closeWithKey ) {
|
||||
mCloseWithKey = closeWithKey;
|
||||
}
|
||||
|
||||
|
||||
@@ -366,7 +366,7 @@ bool UIPushButton::applyProperty( const StyleSheetProperty& attribute ) {
|
||||
std::string val = attribute.asString();
|
||||
Drawable* icon = NULL;
|
||||
|
||||
if ( NULL != mTheme && NULL != ( icon = mTheme->getIconByName( val ) ) ) {
|
||||
if ( NULL != mTheme && NULL != ( icon = getUISceneNode()->findIcon( val ) ) ) {
|
||||
setIcon( icon );
|
||||
} else if ( NULL != ( icon = DrawableSearcher::searchByName( val ) ) ) {
|
||||
setIcon( icon );
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include <eepp/ui/css/mediaquery.hpp>
|
||||
#include <eepp/ui/css/stylesheetparser.hpp>
|
||||
#include <eepp/ui/uieventdispatcher.hpp>
|
||||
#include <eepp/ui/uiiconthememanager.hpp>
|
||||
#include <eepp/ui/uilayout.hpp>
|
||||
#include <eepp/ui/uiscenenode.hpp>
|
||||
#include <eepp/ui/uithememanager.hpp>
|
||||
@@ -35,7 +36,8 @@ UISceneNode::UISceneNode( EE::Window::Window* window ) :
|
||||
mIsLoading( false ),
|
||||
mVerbose( false ),
|
||||
mUpdatingLayouts( false ),
|
||||
mUIThemeManager( UIThemeManager::New() ) {
|
||||
mUIThemeManager( UIThemeManager::New() ),
|
||||
mUIIconThemeManager( UIIconThemeManager::New()->setFallbackThemeManager( mUIThemeManager ) ) {
|
||||
// Reset size since the SceneNode already set it but needs to set the size from zero to emmit
|
||||
// the required events to its childs.
|
||||
mSize = Sizef();
|
||||
@@ -57,6 +59,7 @@ UISceneNode::UISceneNode( EE::Window::Window* window ) :
|
||||
|
||||
UISceneNode::~UISceneNode() {
|
||||
eeSAFE_DELETE( mUIThemeManager );
|
||||
eeSAFE_DELETE( mUIIconThemeManager );
|
||||
|
||||
for ( auto& font : mFontFaces ) {
|
||||
FontManager::instance()->remove( font );
|
||||
@@ -669,6 +672,14 @@ const bool& UISceneNode::isUpdatingLayouts() const {
|
||||
return mUpdatingLayouts;
|
||||
}
|
||||
|
||||
UIIconThemeManager* UISceneNode::getUIIconThemeManager() const {
|
||||
return mUIIconThemeManager;
|
||||
}
|
||||
|
||||
Drawable* UISceneNode::findIcon( const std::string& iconName ) {
|
||||
return getUIIconThemeManager()->findIcon( iconName );
|
||||
}
|
||||
|
||||
bool UISceneNode::onMediaChanged() {
|
||||
if ( !mStyleSheet.isMediaQueryListEmpty() ) {
|
||||
MediaFeatures media;
|
||||
|
||||
@@ -391,7 +391,7 @@ void EETest::createBaseUI() {
|
||||
|
||||
UIPushButton* Button = UIPushButton::New();
|
||||
Button->setParent( C )->setPosition( 225, 215 )->setSize( 90, 0 );
|
||||
Button->setIcon( mTheme->getIconByName( "ok" ) );
|
||||
Button->setIcon( mSceneNode->findIcon( "ok" ) );
|
||||
Button->setText( "Click Me" );
|
||||
Button->addEventListener( Event::MouseClick, cb::Make1( this, &EETest::onButtonClick ) );
|
||||
Button->setTooltipText( "Click and see what happens..." );
|
||||
@@ -490,7 +490,7 @@ void EETest::createBaseUI() {
|
||||
Cell->setParent( genGrid->getContainer() );
|
||||
|
||||
TxtGfx->setVerticalAlign( UI_VALIGN_CENTER );
|
||||
TxtGfx->setDrawable( mTheme->getIconByName( "ok" ) );
|
||||
TxtGfx->setDrawable( mSceneNode->findIcon( "ok" ) );
|
||||
TxtBox->setText( "Test " + String::toString( i + 1 ) );
|
||||
|
||||
Cell->setCell( 0, TxtBox );
|
||||
@@ -514,9 +514,9 @@ void EETest::createBaseUI() {
|
||||
C = C->getParent()->asType<UINode>();
|
||||
|
||||
Menu = UIPopUpMenu::New();
|
||||
Menu->add( "New", mTheme->getIconByName( "document-new" ) );
|
||||
Menu->add( "New", mSceneNode->findIcon( "document-new" ) );
|
||||
|
||||
Menu->add( "Open...", mTheme->getIconByName( "document-open" ) );
|
||||
Menu->add( "Open...", mSceneNode->findIcon( "document-open" ) );
|
||||
Menu->addSeparator();
|
||||
Menu->add( "Map Editor" );
|
||||
Menu->add( "Texture Atlas Editor" );
|
||||
@@ -600,23 +600,23 @@ void EETest::createUI() {
|
||||
|
||||
eePRINTL( "Texture Atlas Loading Time: %4.3f ms.", TE.getElapsed().asMilliseconds() );
|
||||
|
||||
UISceneNode* sceneNode = UISceneNode::New();
|
||||
mSceneNode = UISceneNode::New();
|
||||
|
||||
sceneNode->enableDrawInvalidation();
|
||||
sceneNode->enableFrameBuffer();
|
||||
sceneNode->setVerbose( true );
|
||||
mSceneNode->enableDrawInvalidation();
|
||||
mSceneNode->enableFrameBuffer();
|
||||
mSceneNode->setVerbose( true );
|
||||
|
||||
if ( mDebugUI ) {
|
||||
sceneNode->setDrawBoxes( true );
|
||||
sceneNode->setDrawDebugData( true );
|
||||
sceneNode->setHighlightFocus( true );
|
||||
sceneNode->setHighlightOver( true );
|
||||
sceneNode->setHighlightInvalidation( true );
|
||||
mSceneNode->setDrawBoxes( true );
|
||||
mSceneNode->setDrawDebugData( true );
|
||||
mSceneNode->setHighlightFocus( true );
|
||||
mSceneNode->setHighlightOver( true );
|
||||
mSceneNode->setHighlightInvalidation( true );
|
||||
}
|
||||
|
||||
sceneNode->setTranslator( mTranslator );
|
||||
mSceneNode->setTranslator( mTranslator );
|
||||
|
||||
SceneManager::instance()->add( sceneNode );
|
||||
SceneManager::instance()->add( mSceneNode );
|
||||
|
||||
eePRINTL( "Node size: %d", sizeof( Node ) );
|
||||
eePRINTL( "UINode size: %d", sizeof( UINode ) );
|
||||
@@ -628,9 +628,9 @@ void EETest::createUI() {
|
||||
|
||||
/*mTheme = UITheme::load( mThemeName, mThemeName, "", TTF, MyPath + "ui/breeze.css" );*/
|
||||
|
||||
sceneNode->combineStyleSheet( mTheme->getStyleSheet() );
|
||||
mSceneNode->combineStyleSheet( mTheme->getStyleSheet() );
|
||||
|
||||
UIThemeManager* uiThemeManager = sceneNode->getUIThemeManager();
|
||||
UIThemeManager* uiThemeManager = mSceneNode->getUIThemeManager();
|
||||
uiThemeManager->add( mTheme );
|
||||
uiThemeManager->setDefaultEffectsEnabled( true )->setDefaultFont( TTF )->setDefaultTheme(
|
||||
mThemeName );
|
||||
@@ -699,7 +699,7 @@ void EETest::createNewUI() {
|
||||
UIImage* gfx = UIImage::New();
|
||||
gfx->setPosition( 50, 140 )->setSize( 16, 16 )->setParent( container );
|
||||
gfx->setBackgroundColor( 0x33333333 );
|
||||
gfx->setDrawable( mTheme->getIconByName( "ok" ) );
|
||||
gfx->setDrawable( mSceneNode->findIcon( "ok" ) );
|
||||
|
||||
UISlider* slider = UISlider::New();
|
||||
slider->setOrientation( UIOrientation::Horizontal )
|
||||
@@ -733,7 +733,7 @@ void EETest::createNewUI() {
|
||||
UIPushButton* pushButton = UIPushButton::New();
|
||||
pushButton->setPosition( 50, 560 )->setSize( 200, 0 )->setParent( container );
|
||||
pushButton->setText( "PushButton" );
|
||||
pushButton->setIcon( mTheme->getIconByName( "ok" ) );
|
||||
pushButton->setIcon( mSceneNode->findIcon( "ok" ) );
|
||||
pushButton->addEventListener( Event::MouseClick, [&, pushButton]( const Event* event ) {
|
||||
if ( static_cast<const MouseEvent*>( event )->getFlags() & EE_BUTTON_LMASK )
|
||||
createColorPicker( pushButton );
|
||||
@@ -798,7 +798,7 @@ void EETest::createNewUI() {
|
||||
Cell->setCell( 1, TxtGfx );
|
||||
Cell->setCell( 2, TxtInput );
|
||||
|
||||
TxtGfx->setDrawable( mTheme->getIconByName( "ok" ) );
|
||||
TxtGfx->setDrawable( mSceneNode->findIcon( "ok" ) );
|
||||
TxtBox->setText( "Test " + String::toString( i + 1 ) );
|
||||
|
||||
genGrid->add( Cell );
|
||||
@@ -808,11 +808,11 @@ void EETest::createNewUI() {
|
||||
TabWidget->setPosition( 350, 530 )->setSize( 200, 64 )->setParent( container );
|
||||
|
||||
TabWidget->add( "Tab 1", UIWidget::New()->setThemeSkin( "winback" ),
|
||||
mTheme->getIconByName( "ok" ) );
|
||||
mSceneNode->findIcon( "ok" ) );
|
||||
TabWidget->add( "Tab 2", UIWidget::New()->setThemeSkin( "winback" ),
|
||||
mTheme->getIconByName( "go-up" ) );
|
||||
mSceneNode->findIcon( "go-up" ) );
|
||||
TabWidget->add( "Tab 3", UIWidget::New()->setThemeSkin( "winback" ),
|
||||
mTheme->getIconByName( "add" ) );
|
||||
mSceneNode->findIcon( "add" ) );
|
||||
|
||||
UIWindow* MenuCont = UIWindow::New();
|
||||
MenuCont->setPosition( 350, 390 )->setSize( 200, 115 );
|
||||
@@ -1291,7 +1291,7 @@ void EETest::onButtonClick( const Event* event ) {
|
||||
|
||||
if ( mouseEvent->getFlags() & EE_BUTTONS_LRM ) {
|
||||
UIImage* Gfx = UIImage::New();
|
||||
Gfx->setDrawable( mTheme->getIconByName( "ok" ) );
|
||||
Gfx->setDrawable( mSceneNode->findIcon( "ok" ) );
|
||||
Gfx->setEnabled( false );
|
||||
|
||||
Gfx->runAction( Spawn::New(
|
||||
|
||||
@@ -224,6 +224,7 @@ class EETest : private Thread {
|
||||
Sprite* mCircleSprite;
|
||||
|
||||
UITheme* mTheme;
|
||||
UISceneNode* mSceneNode;
|
||||
|
||||
bool mTerrainUp;
|
||||
UIPushButton* mShowMenu;
|
||||
|
||||
@@ -732,6 +732,8 @@ void App::showFindView() {
|
||||
if ( !text.empty() ) {
|
||||
findInput->setText( text );
|
||||
findInput->getDocument().selectAll();
|
||||
} else if ( !findInput->getText().empty() ) {
|
||||
findInput->getDocument().selectAll();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -806,18 +808,18 @@ App::~App() {
|
||||
|
||||
void App::createSettingsMenu() {
|
||||
mSettingsMenu = UIPopUpMenu::New();
|
||||
mSettingsMenu->add( "New", NULL, "Ctrl+T" );
|
||||
mSettingsMenu->add( "Open...", NULL, "Ctrl+O" );
|
||||
mSettingsMenu->add( "New", mUISceneNode->findIcon( "document-new" ), "Ctrl+T" );
|
||||
mSettingsMenu->add( "Open...", mUISceneNode->findIcon( "document-open" ), "Ctrl+O" );
|
||||
mSettingsMenu->addSeparator();
|
||||
mSettingsMenu->add( "Save", NULL, "Ctrl+S" );
|
||||
mSettingsMenu->add( "Save as..." );
|
||||
mSettingsMenu->add( "Save", mUISceneNode->findIcon( "document-save" ), "Ctrl+S" );
|
||||
mSettingsMenu->add( "Save as...", mUISceneNode->findIcon( "document-save-as" ) );
|
||||
mSettingsMenu->addSeparator();
|
||||
mSettingsMenu->addSubMenu( "Filetype", NULL, createFiletypeMenu() );
|
||||
mSettingsMenu->addSubMenu( "Color Scheme", NULL, createColorSchemeMenu() );
|
||||
mSettingsMenu->addSeparator();
|
||||
mSettingsMenu->add( "Close", NULL, "Ctrl+W" );
|
||||
mSettingsMenu->add( "Close", mUISceneNode->findIcon( "document-close" ), "Ctrl+W" );
|
||||
mSettingsMenu->addSeparator();
|
||||
mSettingsMenu->add( "Quit", NULL, "Ctrl+Q" );
|
||||
mSettingsMenu->add( "Quit", mUISceneNode->findIcon( "quit" ), "Ctrl+Q" );
|
||||
mSettingsButton = mUISceneNode->find<UITextView>( "settings" );
|
||||
mSettingsButton->addEventListener( Event::MouseClick, [&]( const Event* ) {
|
||||
Vector2f pos( mSettingsButton->getPixelsPosition() );
|
||||
@@ -945,7 +947,7 @@ void App::init( const std::string& file, const Float& pidelDensity ) {
|
||||
Font* fontMono =
|
||||
FontTrueType::New( "monospace", resPath + "assets/fonts/DejaVuSansMono.ttf" );
|
||||
|
||||
FontTrueType::New( "icon", resPath + "assets/fonts/remixicon.ttf" );
|
||||
Font* iconFont = FontTrueType::New( "icon", resPath + "assets/fonts/remixicon.ttf" );
|
||||
|
||||
SceneManager::instance()->add( mUISceneNode );
|
||||
|
||||
@@ -1046,6 +1048,23 @@ void App::init( const std::string& file, const Float& pidelDensity ) {
|
||||
mUISceneNode->bind( "code_container", mBaseLayout );
|
||||
mUISceneNode->bind( "search_bar", mSearchBarLayout );
|
||||
mSearchBarLayout->setVisible( false )->setEnabled( false );
|
||||
UIIconTheme* iconTheme = UIIconTheme::New( "remixicon" );
|
||||
auto addIcon = [iconTheme, iconFont]( const std::string& name, const Uint32& codePoint,
|
||||
const Uint32& size ) {
|
||||
iconTheme->add( name,
|
||||
iconFont->getGlyphDrawable( codePoint, PixelDensity::dpToPx( size ) ) );
|
||||
};
|
||||
addIcon( "go-up", 0xea78, 16 );
|
||||
addIcon( "ok", 0xeb7a, 16 );
|
||||
addIcon( "cancel", 0xeb98, 16 );
|
||||
addIcon( "document-new", 0xecc3, 12 );
|
||||
addIcon( "document-open", 0xed70, 12 );
|
||||
addIcon( "document-save", 0xf0b3, 12 );
|
||||
addIcon( "document-save-as", 0xf0b3, 12 );
|
||||
addIcon( "document-close", 0xeb99, 12 );
|
||||
addIcon( "quit", 0xeb97, 12 );
|
||||
|
||||
mUISceneNode->getUIIconThemeManager()->setCurrentTheme( iconTheme );
|
||||
initSearchBar();
|
||||
|
||||
createSettingsMenu();
|
||||
|
||||
@@ -894,25 +894,26 @@ void createAppMenu() {
|
||||
uiMenuBar = UIMenuBar::New();
|
||||
|
||||
UIPopUpMenu* uiPopMenu = UIPopUpMenu::New();
|
||||
uiPopMenu->add( "Open project...", theme->getIconByName( "document-open" ) );
|
||||
uiPopMenu->add( "Open project...", appUiSceneNode->findIcon( "document-open" ) );
|
||||
uiPopMenu->addSeparator();
|
||||
uiPopMenu->add( "Open layout...", theme->getIconByName( "document-open" ) );
|
||||
uiPopMenu->add( "Open layout...", appUiSceneNode->findIcon( "document-open" ) );
|
||||
uiPopMenu->addSeparator();
|
||||
uiPopMenu->addSubMenu( "Recent files", NULL, UIPopUpMenu::New() );
|
||||
uiPopMenu->addSubMenu( "Recent projects", NULL, UIPopUpMenu::New() );
|
||||
uiPopMenu->addSeparator();
|
||||
uiPopMenu->add( "Close", theme->getIconByName( "document-close" ) );
|
||||
uiPopMenu->add( "Close", appUiSceneNode->findIcon( "document-close" ) );
|
||||
uiPopMenu->addSeparator();
|
||||
uiPopMenu->add( "Quit", theme->getIconByName( "quit" ) );
|
||||
uiPopMenu->add( "Quit", appUiSceneNode->findIcon( "quit" ) );
|
||||
uiMenuBar->addMenuButton( "File", uiPopMenu );
|
||||
uiPopMenu->addEventListener( Event::OnItemClicked, cb::Make1( fileMenuClick ) );
|
||||
|
||||
UIPopUpMenu* uiResourceMenu = UIPopUpMenu::New();
|
||||
uiResourceMenu->add( "Load images from path...", theme->getIconByName( "document-open" ) );
|
||||
uiResourceMenu->add( "Load images from path...", appUiSceneNode->findIcon( "document-open" ) );
|
||||
uiResourceMenu->addSeparator();
|
||||
uiResourceMenu->add( "Load fonts from path...", theme->getIconByName( "document-open" ) );
|
||||
uiResourceMenu->add( "Load fonts from path...", appUiSceneNode->findIcon( "document-open" ) );
|
||||
uiResourceMenu->addSeparator();
|
||||
uiResourceMenu->add( "Load style sheet from path...", theme->getIconByName( "document-open" ) );
|
||||
uiResourceMenu->add( "Load style sheet from path...",
|
||||
appUiSceneNode->findIcon( "document-open" ) );
|
||||
uiMenuBar->addMenuButton( "Resources", uiResourceMenu );
|
||||
uiResourceMenu->addEventListener( Event::OnItemClicked, cb::Make1( fileMenuClick ) );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user