Several fixes.

This commit is contained in:
Martín Lucas Golini
2020-04-26 04:56:50 -03:00
parent 3ff44da4af
commit c893e05cde
15 changed files with 124 additions and 70 deletions

View File

@@ -111,7 +111,8 @@ RadioButton::active {
ListBox,
DropDownList::ListBox,
ComboBox::DropDownList::ListBox {
ComboBox::DropDownList::ListBox,
Table {
background-color: var(--list-back);
border-color: var(--button-border);
border-radius: var(--button-radius);
@@ -126,7 +127,8 @@ ListBox::item {
background-position: left bottom, right bottom;
}
ListBox:hover {
ListBox:hover,
Table::hover {
border-color: var(--primary);
}
@@ -217,18 +219,21 @@ SpinBox::btndown {
height: 13dp;
}
TextEdit {
TextEdit::input {
background-color: var(--list-back);
border-color: var(--button-border);
border-radius: var(--button-radius);
border-width: var(--border-width);
}
TextEdit::input {
padding-left: var(--base-horizontal-padding);
padding-right: var(--base-horizontal-padding);
padding-top: var(--base-vertical-padding);
padding-bottom: var(--base-vertical-padding);
transition: all 0.15;
}
TextEdit::input:focus,
TextEdit::input:hover {
border-color: var(--primary);
}
Tooltip {
@@ -576,10 +581,26 @@ Menu::Separator {
height: 3dp;
background-color: var(--button-back);
background-image: rectangle(solid, var(--button-border));
background-size: 100% 1dp;
background-size: 100% 1px;
background-position: center;
}
:root {
Menu::SubMenu::Arrow {
width: 16dp;
height: 16dp;
foreground-image: poly(line, var(--icon), "-7dp -5dp, -2dp 0dp"), poly(line, var(--icon), "-7dp 5dp, -2dp 0dp");
}
Menu::CheckBox::icon {
width: 16dp;
height: 16dp;
foreground-image: none, none;
}
Menu::CheckBox::icon:selected {
foreground-image: poly(line, var(--icon), "10dp 14dp, 12dp 16dp"), poly(line, var(--icon), "12dp 16dp, 16dp 8dp");
}
.appbackground {
background-color: var(--back);
}

View File

@@ -109,6 +109,7 @@ class EE_API UISceneNode : public SceneNode {
std::unordered_set<UIWidget*> mDirtyStyle;
std::unordered_set<UIWidget*> mDirtyStyleState;
std::unordered_map<UIWidget*, bool> mDirtyStyleStateCSSAnimations;
std::vector<std::pair<Float, std::string>> mTimes;
virtual void resizeControl( EE::Window::Window* win );

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 4.11.2, 2020-04-25T00:02:39. -->
<!-- Written by QtCreator 4.11.2, 2020-04-26T04:49:22. -->
<qtcreator>
<data>
<variable>EnvironmentId</variable>
@@ -1531,7 +1531,7 @@
<value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName">eepp-UIEditor-debug</value>
<value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value>
<value type="QString" key="ProjectExplorer.RunConfiguration.BuildKey"></value>
<value type="QString" key="RunConfiguration.Arguments">-x assets/layouts/test.xml -c assets/layouts/test.css -u</value>
<value type="QString" key="RunConfiguration.Arguments">-x assets/layouts/test_widgets.xml -c assets/ui/breeze.css</value>
<value type="bool" key="RunConfiguration.Arguments.multi">false</value>
<value type="QString" key="RunConfiguration.OverrideDebuggerStartup"></value>
<value type="bool" key="RunConfiguration.UseCppDebugger">true</value>

View File

@@ -1,11 +1,4 @@
#include <eepp/maps/mapeditor/mapeditor.hpp>
#include <eepp/maps/mapeditor/maplayerproperties.hpp>
#include <eepp/maps/mapeditor/tilemapproperties.hpp>
#include <eepp/maps/mapeditor/uigotypenew.hpp>
#include <eepp/maps/mapeditor/uimap.hpp>
#include <eepp/maps/mapeditor/uimaplayernew.hpp>
#include <eepp/maps/mapeditor/uimapnew.hpp>
#include <algorithm>
#include <eepp/graphics/globaltextureatlas.hpp>
#include <eepp/graphics/sprite.hpp>
#include <eepp/graphics/textureatlasloader.hpp>
@@ -17,14 +10,18 @@
#include <eepp/maps/gameobjecttextureregion.hpp>
#include <eepp/maps/gameobjecttextureregionex.hpp>
#include <eepp/maps/gameobjectvirtual.hpp>
#include <eepp/maps/mapeditor/mapeditor.hpp>
#include <eepp/maps/mapeditor/maplayerproperties.hpp>
#include <eepp/maps/mapeditor/tilemapproperties.hpp>
#include <eepp/maps/mapeditor/uigotypenew.hpp>
#include <eepp/maps/mapeditor/uimap.hpp>
#include <eepp/maps/mapeditor/uimaplayernew.hpp>
#include <eepp/maps/mapeditor/uimapnew.hpp>
#include <eepp/maps/mapobjectlayer.hpp>
#include <eepp/maps/tilemaplayer.hpp>
#include <eepp/scene/scenemanager.hpp>
#include <eepp/ui/uiscenenode.hpp>
#include <algorithm>
using namespace EE::Graphics;
using namespace EE::Maps::Private;
@@ -107,6 +104,7 @@ bool MapEditor::addShortcut( const Uint32& KeyCode, const Uint32& Mod, UIWidget*
void MapEditor::createWinMenu() {
UIWinMenu* WinMenu = UIWinMenu::New();
WinMenu->setParent( mUIContainer );
WinMenu->getUISceneNode()->updateDirtyStyleStates();
mTileBox =
createTextBox( "", mUIContainer, Sizef(), Vector2f(),

View File

@@ -23,6 +23,10 @@ Drawable* DrawableImageParser::createDrawable( const std::string& value, const S
Drawable* res = NULL;
ownIt = false;
if ( "none" == value ) {
return NULL;
}
if ( !functionType.isEmpty() ) {
if ( exists( functionType.getName() ) ) {
return mFuncs[functionType.getName()]( functionType, size, ownIt, node );

View File

@@ -44,8 +44,10 @@ TextureAtlasEditor::TextureAtlasEditor( UIWindow* attachTo, const TGEditorCloseC
if ( NULL == mUIWindow ) {
mUIContainer = uiSceneNode;
uiSceneNode->getRoot()->addClass( "appbackground" );
} else {
mUIContainer = mUIWindow->getContainer();
mUIWindow->getContainer()->addClass( "appbackground" );
}
std::string layout = R"xml(

View File

@@ -10,6 +10,7 @@ UIMenuCheckBox* UIMenuCheckBox::New() {
UIMenuCheckBox::UIMenuCheckBox() :
UIMenuItem( "menu::checkbox" ), mActive( false ), mSkinActive( NULL ), mSkinInactive( NULL ) {
mIcon->setElementTag( mTag + "::icon" );
applyDefaultTheme();
mIcon->setFlags( UI_SKIN_KEEP_SIZE_ON_DRAW );
}
@@ -45,16 +46,23 @@ void UIMenuCheckBox::setActive( const bool& active ) {
bool oActive = mActive;
mActive = active;
if ( mActive ) {
mIcon->pushState( UIState::StateSelected );
} else {
mIcon->popState( UIState::StateSelected );
}
if ( mActive ) {
if ( NULL != mSkinActive ) {
if ( NULL == mIcon->getSkin() || mIcon->getSkin()->getName() != mSkinActive->getName() )
mIcon->setSkin( mSkinActive );
if ( NULL != mSkinState ) {
if ( mSkinState->getState() & UIState::StateFlagSelected )
if ( mSkinState->getState() & UIState::StateFlagSelected ) {
mIcon->pushState( UIState::StateHover );
else
} else {
mIcon->popState( UIState::StateHover );
}
}
} else {
mIcon->removeSkin();
@@ -66,10 +74,11 @@ void UIMenuCheckBox::setActive( const bool& active ) {
mIcon->setSkin( mSkinInactive );
if ( NULL != mSkinState ) {
if ( mSkinState->getState() & UIState::StateFlagSelected )
if ( mSkinState->getState() & UIState::StateFlagSelected ) {
mIcon->pushState( UIState::StateHover );
else
} else {
mIcon->popState( UIState::StateHover );
}
}
} else {
mIcon->removeSkin();

View File

@@ -24,7 +24,8 @@ UIMessageBox::UIMessageBox( const Type& type, const String& message, const Uint3
UILinearLayout* vlay = UILinearLayout::NewVertical();
vlay->setLayoutSizeRules( LayoutSizeRule::WrapContent, LayoutSizeRule::WrapContent )
->setLayoutMargin( Rect( 8, 8, 8, 8 ) )
->setParent( mLayoutCont );
->setParent( mLayoutCont )
->clipDisable();
mTextBox = UITextView::New();
mTextBox->setText( message )
@@ -35,7 +36,8 @@ UIMessageBox::UIMessageBox( const Type& type, const String& message, const Uint3
hlay->setLayoutMargin( Rect( 0, 8, 0, 0 ) )
->setLayoutSizeRules( LayoutSizeRule::WrapContent, LayoutSizeRule::WrapContent )
->setLayoutGravity( UI_HALIGN_RIGHT | UI_VALIGN_CENTER )
->setParent( vlay );
->setParent( vlay )
->clipDisable();
mButtonOK = UIPushButton::New();
mButtonOK->setSize( 90, 0 )->setParent( hlay );
@@ -74,6 +76,8 @@ UIMessageBox::UIMessageBox( const Type& type, const String& message, const Uint3
}
}
reloadStyle( true, true );
applyDefaultTheme();
}

View File

@@ -384,7 +384,7 @@ void UINodeDrawable::LayerDrawable::setDrawable( Drawable* drawable, const bool&
mOwnsDrawable = ownIt;
invalidate();
if ( mDrawable->isDrawableResource() ) {
if ( NULL != mDrawable && mDrawable->isDrawableResource() ) {
mResourceChangeCbId = reinterpret_cast<DrawableResource*>( mDrawable )
->pushResourceChangeCallback(
[&]( DrawableResource::Event event, DrawableResource* ) {
@@ -402,11 +402,9 @@ void UINodeDrawable::LayerDrawable::setDrawable( const std::string& drawableRef
bool ownIt;
Drawable* drawable = createDrawable( drawableRef, mSize, ownIt );
if ( NULL != drawable ) {
setDrawable( drawable, ownIt );
setDrawable( drawable, ownIt );
mDrawableRef = drawableRef;
}
mDrawableRef = drawableRef;
}
Drawable* UINodeDrawable::LayerDrawable::createDrawable( const std::string& value,

View File

@@ -118,8 +118,6 @@ bool UISceneNode::windowExists( UIWindow* win ) {
return mWindowsList.end() != std::find( mWindowsList.begin(), mWindowsList.end(), win );
}
static std::vector<std::pair<Float, std::string>> times;
std::vector<UIWidget*> UISceneNode::loadNode( pugi::xml_node node, Node* parent ) {
std::vector<UIWidget*> rootWidgets;
@@ -139,7 +137,7 @@ std::vector<UIWidget*> UISceneNode::loadNode( pugi::xml_node node, Node* parent
uiwidget->loadFromXmlNode( widget );
if ( mVerbose ) {
times.push_back( std::make_pair<Float, std::string>(
mTimes.push_back( std::make_pair<Float, std::string>(
clock.getElapsedTime().asMilliseconds(), widget.name() ) );
}
@@ -167,15 +165,15 @@ UIWidget* UISceneNode::loadLayoutNodes( pugi::xml_node node, Node* parent ) {
if ( mVerbose ) {
std::sort(
times.begin(), times.end(),
mTimes.begin(), mTimes.end(),
[]( const std::pair<Float, std::string>& left,
const std::pair<Float, std::string>& right ) { return left.first < right.first; } );
for ( auto& time : times ) {
for ( auto& time : mTimes ) {
eePRINTL( "Widget %s created in %.2f ms", time.second.c_str(), time.first );
}
times.clear();
mTimes.clear();
eePRINTL( "UISceneNode::loadLayoutNodes loaded nodes%s in: %.2f ms",
id.empty() ? "" : std::string( " (id=" + id + ")" ).c_str(),
@@ -242,13 +240,14 @@ bool UISceneNode::hasStyleSheet() {
void UISceneNode::reloadStyle( const bool& disableAnimations ) {
if ( NULL != mChild ) {
Node* ChildLoop = mChild;
Node* child = mChild;
while ( NULL != ChildLoop ) {
if ( ChildLoop->isWidget() )
ChildLoop->asType<UIWidget>()->reloadStyle( true, disableAnimations );
while ( NULL != child ) {
if ( child->isWidget() ) {
child->asType<UIWidget>()->reloadStyle( true, disableAnimations );
}
ChildLoop = ChildLoop->getNextNode();
child = child->getNextNode();
}
}
}

View File

@@ -111,10 +111,10 @@ const bool& UIStyle::isChangingState() const {
}
StyleSheetVariable UIStyle::getVariable( const std::string& variable ) {
if ( NULL != mDefinition ) {
auto it = mDefinition->getVariables().find( String::hash( variable ) );
if ( NULL != mGlobalDefinition ) {
auto it = mGlobalDefinition->getVariables().find( String::hash( variable ) );
if ( it != mDefinition->getVariables().end() ) {
if ( it != mGlobalDefinition->getVariables().end() ) {
return it->second;
}
}
@@ -216,16 +216,18 @@ void UIStyle::onStateChange() {
if ( newDefinition )
changedProperties |= newDefinition->getPropertyIds();
if ( !newDefinition->getPropertyIds().empty() ) {
if ( nullptr != mDefinition ) {
const PropertyIdSet propertiesInBothDefinitions =
( mDefinition->getPropertyIds() & newDefinition->getPropertyIds() );
if ( !mForceReapplyProperties ) {
if ( nullptr != newDefinition && !newDefinition->getPropertyIds().empty() ) {
if ( nullptr != mDefinition ) {
const PropertyIdSet propertiesInBothDefinitions =
( mDefinition->getPropertyIds() & newDefinition->getPropertyIds() );
for ( Uint32 id : propertiesInBothDefinitions ) {
const StyleSheetProperty* p0 = mDefinition->getProperty( id );
const StyleSheetProperty* p1 = newDefinition->getProperty( id );
if ( nullptr != p0 && nullptr != p1 && *p0 == *p1 )
changedProperties.erase( id );
for ( Uint32 id : propertiesInBothDefinitions ) {
const StyleSheetProperty* p0 = mDefinition->getProperty( id );
const StyleSheetProperty* p1 = newDefinition->getProperty( id );
if ( nullptr != p0 && nullptr != p1 && *p0 == *p1 )
changedProperties.erase( id );
}
}
}
}
@@ -238,7 +240,7 @@ void UIStyle::onStateChange() {
updateAnimations();
if ( !mDefinition->getTransitionProperties().empty() ) {
if ( nullptr != mDefinition && !mDefinition->getTransitionProperties().empty() ) {
mTransitions = TransitionDefinition::parseTransitionProperties(
mDefinition->getTransitionProperties() );
}
@@ -253,7 +255,6 @@ void UIStyle::onStateChange() {
if ( property->getPropertyDefinition()->isIndexed() ) {
for ( size_t i = 0; i < property->getPropertyIndexCount(); i++ ) {
applyVarValues( property->getPropertyIndexRef( i ) );
applyStyleSheetProperty( property->getPropertyIndex( i ), prevDefinition );
@@ -663,7 +664,9 @@ void UIStyle::removeAnimation( const PropertyDefinition* propertyDefinition,
}
StyleSheetProperty* UIStyle::getLocalProperty( Uint32 propId ) {
StyleSheetProperty* property = mDefinition->getProperty( propId );
StyleSheetProperty* property = nullptr;
if ( nullptr != mDefinition )
property = mDefinition->getProperty( propId );
if ( nullptr == property )
return mElementStyle->getPropertyById( propId );
return property;

View File

@@ -451,8 +451,10 @@ Node* UIWidget::setSize( const Float& Width, const Float& Height ) {
Node* UIWidget::setId( const std::string& id ) {
Node::setId( id );
if ( !isSceneNodeLoading() && !isLoadingState() )
if ( !isSceneNodeLoading() && !isLoadingState() ) {
getUISceneNode()->invalidateStyle( this );
getUISceneNode()->invalidateStyleState( this );
}
return this;
}
@@ -799,8 +801,10 @@ void UIWidget::addClass( const std::string& cls ) {
if ( !cls.empty() && !hasClass( cls ) ) {
mClasses.push_back( cls );
if ( !isSceneNodeLoading() && !isLoadingState() )
if ( !isSceneNodeLoading() && !isLoadingState() ) {
getUISceneNode()->invalidateStyle( this );
getUISceneNode()->invalidateStyleState( this );
}
onClassChange();
}
@@ -816,8 +820,10 @@ void UIWidget::addClasses( const std::vector<std::string>& classes ) {
}
}
if ( !isSceneNodeLoading() && !isLoadingState() )
if ( !isSceneNodeLoading() && !isLoadingState() ) {
getUISceneNode()->invalidateStyle( this );
getUISceneNode()->invalidateStyleState( this );
}
onClassChange();
}
@@ -827,8 +833,10 @@ void UIWidget::removeClass( const std::string& cls ) {
if ( hasClass( cls ) ) {
mClasses.erase( std::find( mClasses.begin(), mClasses.end(), cls ) );
if ( !isSceneNodeLoading() && !isLoadingState() )
if ( !isSceneNodeLoading() && !isLoadingState() ) {
getUISceneNode()->invalidateStyle( this );
getUISceneNode()->invalidateStyleState( this );
}
onClassChange();
}
@@ -848,8 +856,10 @@ void UIWidget::removeClasses( const std::vector<std::string>& classes ) {
}
}
if ( !isSceneNodeLoading() && !isLoadingState() )
if ( !isSceneNodeLoading() && !isLoadingState() ) {
getUISceneNode()->invalidateStyle( this );
getUISceneNode()->invalidateStyleState( this );
}
onClassChange();
}
@@ -867,8 +877,10 @@ void UIWidget::setElementTag( const std::string& tag ) {
mMinHeightEq = "";
mMinSize = Sizef::Zero;
if ( !isSceneNodeLoading() && !isLoadingState() )
if ( !isSceneNodeLoading() && !isLoadingState() ) {
getUISceneNode()->invalidateStyle( this );
getUISceneNode()->invalidateStyleState( this );
}
onTagChange();
}
@@ -965,6 +977,7 @@ void UIWidget::onThemeLoaded() {}
void UIWidget::onParentChange() {
if ( !isSceneNodeLoading() && !isLoadingState() ) {
getUISceneNode()->invalidateStyle( this );
getUISceneNode()->invalidateStyleState( this, true );
}
}

View File

@@ -59,10 +59,10 @@ UIWindow::UIWindow( UIWindow::WindowBaseContainerType type, const StyleConfig& w
switch ( type ) {
case LINEAR_LAYOUT:
mContainer = UILinearLayout::New();
mContainer = UILinearLayout::NewWithTag( "window::container" );
break;
case RELATIVE_LAYOUT:
mContainer = UIRelativeLayout::New();
mContainer = UIRelativeLayout::NewWithTag( "window::container" );
break;
case SIMPLE_LAYOUT:
default:

View File

@@ -621,8 +621,8 @@ void EETest::createUI() {
eePRINTL( "UIWidget size: %d", sizeof( UIWidget ) );
mTheme = UITheme::load( mThemeName, mThemeName,
MyPath + "ui/" + mThemeName + EE_TEXTURE_ATLAS_EXTENSION, TTF,
MyPath + "ui/uitheme.css" );
MyPath + "ui/" + mThemeName + EE_TEXTURE_ATLAS_EXTENSION, TTF,
MyPath + "ui/uitheme.css" );
/*mTheme = UITheme::load( mThemeName, mThemeName, "", TTF, MyPath + "ui/breeze.css" );*/

View File

@@ -925,6 +925,7 @@ void createAppMenu() {
void setUserDefaultTheme() {
useDefaultTheme = true;
uiSceneNode->getUIThemeManager()->setDefaultTheme( theme );
uiSceneNode->combineStyleSheet( theme->getStyleSheet() );
}
EE_MAIN_FUNC int main( int argc, char* argv[] ) {
@@ -1002,6 +1003,7 @@ EE_MAIN_FUNC int main( int argc, char* argv[] ) {
theme = UITheme::load( "uitheme" + pd, "uitheme" + pd, "assets/ui/uitheme" + pd + ".eta",
font, "assets/ui/uitheme.css" );
/*theme = UITheme::load( "uitheme", "uitheme", "", font, "assets/ui/breeze.css" );*/
uiSceneNode = UISceneNode::New();
uiSceneNode->setId( "uiSceneNode" );
@@ -1015,14 +1017,13 @@ EE_MAIN_FUNC int main( int argc, char* argv[] ) {
appUiSceneNode->enableDrawInvalidation();
uiSceneNode->enableDrawInvalidation();
appUiSceneNode->combineStyleSheet( theme->getStyleSheet() );
appUiSceneNode->setStyleSheet( theme->getStyleSheet() );
appUiSceneNode->getUIThemeManager()
->setDefaultEffectsEnabled( true )
->setDefaultTheme( theme )
->setDefaultFont( font )
->add( theme );
uiSceneNode->combineStyleSheet( theme->getStyleSheet() );
uiSceneNode->getUIThemeManager()->setDefaultFont( font )->setDefaultEffectsEnabled( true );
if ( useAppTheme.Get() ) {
@@ -1038,6 +1039,7 @@ EE_MAIN_FUNC int main( int argc, char* argv[] ) {
uiContainer->setId( "appContainer" )->setSize( uiSceneNode->getSize() );
updateRecentProjects();
updateRecentFiles();
resizeCb( window );