Fixed UIMenu::remove() and UIMenu::removeAll() crashes.
Fixed UIImage size bugs. Minor improvements in UIEditor. Started implementing the color picker UI. Fix when closing a Scene::Node when mouse was over that Node. --HG-- branch : dev
@@ -0,0 +1,86 @@
|
||||
<style>
|
||||
#color_picker {
|
||||
min-window-size: 320dp, 470dp;
|
||||
}
|
||||
#color_picker .container {
|
||||
margin: 4dp;
|
||||
}
|
||||
#color_picker .container > .header > .current_color {
|
||||
background-color: white;
|
||||
foreground-color: red;
|
||||
}
|
||||
#color_picker .container > .header {
|
||||
margin-bottom: 4dp;
|
||||
}
|
||||
#color_picker .container > .header > .picker_icon {
|
||||
icon: color-picker-white;
|
||||
gravity: center;
|
||||
}
|
||||
#color_picker .container > .pickers > .color_picker {
|
||||
background-image: linear-gradient(white, black);
|
||||
}
|
||||
#color_picker .container > .pickers > .separator,
|
||||
#color_picker .container > .header > .separator {
|
||||
margin: 8dp 0dp 8dp 0dp;
|
||||
}
|
||||
#color_picker .container > .pickers > .separator {
|
||||
background-color: #FFFFFF88;
|
||||
}
|
||||
#color_picker .container > .pickers > .hue_picker {
|
||||
background-image: linear-gradient(white, black);
|
||||
}
|
||||
#color_picker .container > .separator {
|
||||
margin: 0dp 8dp 0dp 4dp;
|
||||
background-color: #FFFFFF88;
|
||||
}
|
||||
#color_picker .container > .slider_container,
|
||||
#color_picker .container > .footer {
|
||||
margin-top: 4dp;
|
||||
}
|
||||
#color_picker .container > .footer > PushButton {
|
||||
padding-left: 8dp;
|
||||
padding-right: 8dp;
|
||||
icon: ok;
|
||||
}
|
||||
</style>
|
||||
<window id="color_picker" layout_width="320dp" layout_height="470dp">
|
||||
<LinearLayout class="container" orientation="vertical" layout_width="match_parent" layout_height="wrap_content">
|
||||
<LinearLayout class="header" orientation="horizontal" layout_width="match_parent" layout_height="28dp">
|
||||
<Widget class="current_color" layout_width="256dp" layout_height="match_parent" />
|
||||
<Widget class="separator" layout_width="1dp" layout_height="256dp" />
|
||||
<Image class="picker_icon" layout_width="0dp" layout_weight="1" layout_height="match_parent" />
|
||||
</LinearLayout>
|
||||
<LinearLayout class="pickers" orientation="horizontal" layout_width="match_parent" layout_height="256dp">
|
||||
<Widget class="color_picker" layout_width="256dp" layout_height="256dp" />
|
||||
<Widget class="separator" layout_width="1dp" layout_height="256dp" />
|
||||
<Widget class="hue_picker" layout_width="0dp" layout_weight="1" layout_height="256dp" />
|
||||
</LinearLayout>
|
||||
<Widget class="separator" layout_width="match_parent" layout_height="1dp" />
|
||||
<LinearLayout class="slider_container" orientation="horizontal" ayout_width="match_parent" layout_height="wrap_content">
|
||||
<TextView layout_width="16dp" layout_height="wrap_content" text="R" layout_gravity="center" />
|
||||
<Slider layout_width="0dp" layout_weight="1" layout_height="wrap_content" orientation="horizontal" layout_gravity="center" />
|
||||
<SpinBox layout_width="48dp" layout_height="wrap_content" />
|
||||
</LinearLayout>
|
||||
<LinearLayout class="slider_container" orientation="horizontal" ayout_width="match_parent" layout_height="wrap_content">
|
||||
<TextView layout_width="16dp" layout_height="wrap_content" text="G" layout_gravity="center" />
|
||||
<Slider layout_width="0dp" layout_weight="1" layout_height="wrap_content" orientation="horizontal" layout_gravity="center" />
|
||||
<SpinBox layout_width="48dp" layout_height="wrap_content" />
|
||||
</LinearLayout>
|
||||
<LinearLayout class="slider_container" orientation="horizontal" ayout_width="match_parent" layout_height="wrap_content">
|
||||
<TextView layout_width="16dp" layout_height="wrap_content" text="B" layout_gravity="center" />
|
||||
<Slider layout_width="0dp" layout_weight="1" layout_height="wrap_content" orientation="horizontal" layout_gravity="center" />
|
||||
<SpinBox layout_width="48dp" layout_height="wrap_content" />
|
||||
</LinearLayout>
|
||||
<LinearLayout class="slider_container" orientation="horizontal" ayout_width="match_parent" layout_height="wrap_content">
|
||||
<TextView layout_width="16dp" layout_height="wrap_content" text="A" layout_gravity="center" />
|
||||
<Slider layout_width="0dp" layout_weight="1" layout_height="wrap_content" orientation="horizontal" layout_gravity="center" />
|
||||
<SpinBox layout_width="48dp" layout_height="wrap_content" />
|
||||
</LinearLayout>
|
||||
<LinearLayout class="footer" orientation="horizontal" ayout_width="match_parent" layout_height="wrap_content">
|
||||
<TextView layout_width="wrap_content" layout_height="wrap_content" text="HTML Notation #" layout_gravity="center" />
|
||||
<TextInput layout_width="120dp" layout_height="wrap_content" />
|
||||
<Widget layout_width="0dp" layout_weight="1" layout_height="match_parent" />
|
||||
<PushButton layout_width="wrap_content" layout_height="wrap_content" text="OK" />
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</window>
|
||||
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
|
After Width: | Height: | Size: 834 B |
|
Before Width: | Height: | Size: 84 KiB After Width: | Height: | Size: 85 KiB |
|
After Width: | Height: | Size: 8.1 KiB |
|
Before Width: | Height: | Size: 143 KiB After Width: | Height: | Size: 145 KiB |
|
After Width: | Height: | Size: 1.5 KiB |
@@ -197,7 +197,7 @@ class EE_API TextureFactory : protected Mutex {
|
||||
|
||||
TextureFactory();
|
||||
|
||||
int mCurrentTexture[ EE_MAX_TEXTURE_UNITS ];
|
||||
std::vector<int> mCurrentTexture;
|
||||
|
||||
std::vector<Texture*> mTextures;
|
||||
|
||||
|
||||
@@ -13,14 +13,13 @@ namespace EE { namespace Graphics {
|
||||
SINGLETON_DECLARE_IMPLEMENTATION(TextureFactory)
|
||||
|
||||
TextureFactory::TextureFactory() :
|
||||
mCurrentTexture(EE_MAX_TEXTURE_UNITS),
|
||||
mMemSize(0),
|
||||
mLastCoordinateType( Texture::CoordinateType::Normalized ),
|
||||
mErasing(false)
|
||||
{
|
||||
mTextures.clear();
|
||||
mTextures.push_back( NULL );
|
||||
|
||||
memset( &mCurrentTexture[0], 0, EE_MAX_TEXTURE_UNITS );
|
||||
}
|
||||
|
||||
const Texture::CoordinateType & TextureFactory::getLastCoordinateType() const {
|
||||
|
||||
@@ -34,12 +34,15 @@ Node::Node() :
|
||||
}
|
||||
|
||||
Node::~Node() {
|
||||
if ( !SceneManager::instance()->isShootingDown() ) {
|
||||
if ( NULL != mSceneNode && mSceneNode != this && NULL != mSceneNode->getActionManager() )
|
||||
if ( !SceneManager::instance()->isShootingDown() && NULL != mSceneNode ) {
|
||||
if ( mSceneNode != this && NULL != mSceneNode->getActionManager() )
|
||||
mSceneNode->getActionManager()->removeAllActionsFromTarget(this);
|
||||
|
||||
if ( NULL != mSceneNode && (mNodeFlags & NODE_FLAG_SCHEDULED_UPDATE) )
|
||||
if ( mNodeFlags & NODE_FLAG_SCHEDULED_UPDATE )
|
||||
mSceneNode->unsubscribeScheduledUpdate(this);
|
||||
|
||||
if ( isMouseOverMeOrChilds() )
|
||||
mSceneNode->removeMouseOverNode( this );
|
||||
}
|
||||
|
||||
childDeleteAll();
|
||||
|
||||
@@ -29,7 +29,7 @@ void StyleSheet::combineStyle( const StyleSheetStyle& node ) {
|
||||
} else {
|
||||
auto& currentNode = nodeIt->second;
|
||||
|
||||
if ( node.getSelector().getSpecificity() > currentNode.getSelector().getSpecificity() ) {
|
||||
if ( node.getSelector().getSpecificity() >= currentNode.getSelector().getSpecificity() ) {
|
||||
for ( auto& pit : node.getProperties() )
|
||||
currentNode.setProperty( pit.second );
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
#include <eepp/graphics/drawable.hpp>
|
||||
#include <eepp/graphics/sprite.hpp>
|
||||
#include <eepp/graphics/drawablesearcher.hpp>
|
||||
#include <eepp/ui/uithememanager.hpp>
|
||||
|
||||
namespace EE { namespace UI {
|
||||
|
||||
@@ -25,6 +26,8 @@ UIImage::UIImage( const std::string& tag ) :
|
||||
mFlags |= UI_AUTO_SIZE;
|
||||
|
||||
onAutoSize();
|
||||
|
||||
applyDefaultTheme();
|
||||
}
|
||||
|
||||
UIImage::UIImage() :
|
||||
@@ -74,11 +77,11 @@ void UIImage::onAutoSize() {
|
||||
}
|
||||
|
||||
if ( mLayoutWidthRules == WRAP_CONTENT ) {
|
||||
setInternalPixelsWidth( (int)mDrawable->getSize().getWidth() + mRealPadding.Left + mRealPadding.Right );
|
||||
setInternalPixelsWidth( (int)PixelDensity::dpToPx( mDrawable->getSize().getWidth() ) + mRealPadding.Left + mRealPadding.Right );
|
||||
}
|
||||
|
||||
if ( mLayoutHeightRules == WRAP_CONTENT ) {
|
||||
setInternalPixelsHeight( (int)mDrawable->getSize().getHeight() + mRealPadding.Top + mRealPadding.Bottom );
|
||||
setInternalPixelsHeight( (int)PixelDensity::dpToPx( mDrawable->getSize().getHeight() ) + mRealPadding.Top + mRealPadding.Bottom );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -106,7 +109,7 @@ void UIImage::calcDestSize() {
|
||||
if ( NULL == mDrawable)
|
||||
return;
|
||||
|
||||
mDestSize = mDrawable->getSize();
|
||||
mDestSize = PixelDensity::dpToPx( mDrawable->getSize() );
|
||||
}
|
||||
|
||||
mDestSize = mDestSize.floor();
|
||||
@@ -220,6 +223,15 @@ bool UIImage::setAttribute( const NodeAttribute& attribute, const Uint32& state
|
||||
|
||||
setDrawable( res );
|
||||
}
|
||||
} else if ( "icon" == name ) {
|
||||
std::string val = attribute.asString();
|
||||
Drawable * icon = NULL;
|
||||
|
||||
if ( NULL != mTheme && NULL != ( icon = mTheme->getIconByName( val ) ) ) {
|
||||
setDrawable( icon );
|
||||
} else if ( NULL != ( icon = DrawableSearcher::searchByName( val ) ) ) {
|
||||
setDrawable( icon );
|
||||
}
|
||||
} else if ( "scale-type" == name || "scaletype" == name ) {
|
||||
std::string val = attribute.asString();
|
||||
String::toLowerInPlace( val );
|
||||
|
||||
@@ -216,7 +216,7 @@ Uint32 UIMenu::getCount() const {
|
||||
void UIMenu::remove( const Uint32& Index ) {
|
||||
eeASSERT( Index < mItems.size() );
|
||||
|
||||
eeSAFE_DELETE( mItems[ Index ] );
|
||||
mItems[ Index ]->close();
|
||||
|
||||
mItems.erase( mItems.begin() + Index );
|
||||
|
||||
@@ -235,7 +235,7 @@ void UIMenu::remove( UINode * Ctrl ) {
|
||||
|
||||
void UIMenu::removeAll() {
|
||||
for ( Uint32 i = 0; i < mItems.size(); i++ ) {
|
||||
eeSAFE_DELETE( mItems[ i ] );
|
||||
mItems[ i ]->close();
|
||||
}
|
||||
|
||||
mItems.clear();
|
||||
|
||||
@@ -4,9 +4,9 @@
|
||||
#include <eepp/window/window.hpp>
|
||||
#include <eepp/system/packmanager.hpp>
|
||||
#include <eepp/system/filesystem.hpp>
|
||||
#include <pugixml/pugixml.hpp>
|
||||
#include <eepp/ui/uiwidgetcreator.hpp>
|
||||
#include <eepp/ui/css/stylesheetparser.hpp>
|
||||
#include <pugixml/pugixml.hpp>
|
||||
#include <algorithm>
|
||||
|
||||
namespace EE { namespace UI {
|
||||
@@ -110,6 +110,8 @@ UIWidget * UISceneNode::loadLayoutNodes( pugi::xml_node node, Node * parent ) {
|
||||
|
||||
uiwidget->reloadStyle( false );
|
||||
uiwidget->onWidgetCreated();
|
||||
} else if ( String::toLower( widget.name() ) == "style" ) {
|
||||
combineStyleSheet( widget.text().as_string() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -80,16 +80,12 @@ void loadConfig() {
|
||||
ini.loadFromFile( path );
|
||||
ini.readFile();
|
||||
|
||||
std::string recent = ini.getValue( "UIEDITOR", "recentfiles", "" );
|
||||
std::vector<std::string> files = String::split( recent, ';' );
|
||||
|
||||
recentProjects = files;
|
||||
std::string recent = ini.getValue( "UIEDITOR", "recentprojects", "" );
|
||||
recentProjects = String::split( recent, ';' );
|
||||
}
|
||||
|
||||
void saveConfig() {
|
||||
std::string files = String::join( recentProjects, ';' );
|
||||
|
||||
ini.setValue( "UIEDITOR", "recentfiles", files );
|
||||
ini.setValue( "UIEDITOR", "recentprojects", String::join( recentProjects, ';' ) );
|
||||
ini.writeFile();
|
||||
}
|
||||
|
||||
@@ -227,6 +223,10 @@ static void loadLayout( std::string file ) {
|
||||
|
||||
static void refreshLayout() {
|
||||
if ( !currentLayout.empty() && FileSystem::fileExists( currentLayout ) && uiContainer != NULL ) {
|
||||
if ( !currentStyleSheet.empty() && FileSystem::fileExists( currentStyleSheet ) && uiContainer != NULL ) {
|
||||
loadStyleSheet( currentStyleSheet );
|
||||
}
|
||||
|
||||
loadLayout( currentLayout );
|
||||
}
|
||||
|
||||
@@ -236,6 +236,10 @@ static void refreshLayout() {
|
||||
static void refreshStyleSheet() {
|
||||
if ( !currentStyleSheet.empty() && FileSystem::fileExists( currentStyleSheet ) && uiContainer != NULL ) {
|
||||
loadStyleSheet( currentStyleSheet );
|
||||
|
||||
if ( !currentLayout.empty() && FileSystem::fileExists( currentLayout ) && uiContainer != NULL ) {
|
||||
loadLayout( currentLayout );
|
||||
}
|
||||
}
|
||||
|
||||
updateStyleSheet = false;
|
||||
@@ -383,7 +387,7 @@ void refreshLayoutList() {
|
||||
|
||||
chk->setActive( currentLayout == it->second );
|
||||
}
|
||||
} else if ( uiWinMenu->getButton( "Layouts" ) == NULL ) {
|
||||
} else if ( uiWinMenu->getButton( "Layouts" ) != NULL ) {
|
||||
uiWinMenu->removeMenuButton( "Layouts" );
|
||||
}
|
||||
|
||||
@@ -534,8 +538,12 @@ void loadProject( std::string projectPath ) {
|
||||
if ( result ) {
|
||||
loadProjectNodes( doc.first_child() );
|
||||
|
||||
if ( recentProjects.size() > 0 && recentProjects[0] == projectPath )
|
||||
return;
|
||||
for ( auto pathIt = recentProjects.begin(); pathIt != recentProjects.end(); pathIt++ ) {
|
||||
if ( *pathIt == projectPath ) {
|
||||
recentProjects.erase(pathIt);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
recentProjects.insert( recentProjects.begin(), projectPath );
|
||||
|
||||
|
||||