mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-05-30 18:16:31 +03:00
Crash fix on DisplayManager.
UINodeDrawable clean ups. Added Node::removeAction(), Node:removeActionByTag(), Node::clearActions(). Store display DPI on scene node creation. --HG-- branch : dev
This commit is contained in:
@@ -290,6 +290,7 @@ TabWidget {
|
||||
background-size: auto;
|
||||
background-position: bottom right;
|
||||
padding: 24dp;
|
||||
transition: all 1s;
|
||||
}
|
||||
|
||||
#rrl:hover {
|
||||
@@ -297,10 +298,27 @@ TabWidget {
|
||||
background-position: top left;
|
||||
}
|
||||
|
||||
#rrl > .real_back {
|
||||
background-color: #333;
|
||||
}
|
||||
|
||||
#rrl > .back {
|
||||
width: 250dp;
|
||||
height: 40dp;
|
||||
layout-gravity: center;
|
||||
background-color: #333;
|
||||
transition: all 0.5s;
|
||||
}
|
||||
|
||||
#rrl:hover > .back {
|
||||
width: 300dp;
|
||||
height: 300dp;
|
||||
background-color: black;
|
||||
}
|
||||
|
||||
#rrl > #tmap {
|
||||
font-size: 24dp;
|
||||
padding: 12dp;
|
||||
background-color: #333;
|
||||
}
|
||||
|
||||
.eltv {
|
||||
|
||||
@@ -30,6 +30,8 @@
|
||||
</vbox>
|
||||
<vbox id="rvbox" layout_width="match_parent" layout_weight="0.5" layout_height="match_parent">
|
||||
<RelativeLayout id="rrl" layout_width="match_parent" layout_height="match_parent">
|
||||
<Widget class="real_back" layout_width="match_parent" layout_height="match_parent" />
|
||||
<Widget class="back" />
|
||||
<TextView id="tmap" layout_width="match_parent" layout_height="match_parent" text="testing match_parent" gravity="center" />
|
||||
<TextView class="eltv" id="el1" layout_width="wrap_content" layout_height="wrap_content" text="testing padding" />
|
||||
<TextView class="eltv" id="el2" layout_width="wrap_content" layout_height="wrap_content" text="testing margin" layout_gravity="top|right" />
|
||||
|
||||
@@ -274,6 +274,12 @@ class EE_API Node : public Transformable {
|
||||
|
||||
Node * runAction( Action * action );
|
||||
|
||||
void removeAction( Action * action );
|
||||
|
||||
void removeActionByTag( const Uint32& tag );
|
||||
|
||||
void clearActions();
|
||||
|
||||
Transform getLocalTransform() const;
|
||||
|
||||
Transform getGlobalTransform() const;
|
||||
|
||||
@@ -112,6 +112,8 @@ class EE_API SceneNode : public Node {
|
||||
const bool& getUpdateAllChilds() const;
|
||||
|
||||
void setUpdateAllChilds( const bool& updateAllChilds );
|
||||
|
||||
const Float& getDPI() const;
|
||||
protected:
|
||||
friend class Node;
|
||||
typedef std::list<Node*> CloseList;
|
||||
@@ -138,6 +140,7 @@ class EE_API SceneNode : public Node {
|
||||
std::list<Node*> mScheduledUpdate;
|
||||
std::list<Node*> mScheduledUpdateRemove;
|
||||
std::list<Node*> mMouseOverNodes;
|
||||
Float mDPI;
|
||||
|
||||
virtual void onSizeChange();
|
||||
|
||||
|
||||
@@ -51,8 +51,12 @@ class EE_API UINodeDrawable : public Drawable {
|
||||
|
||||
void setPositionEq( const std::string& offset );
|
||||
|
||||
const std::string& getPositionEq() const { return mPositionEq; }
|
||||
|
||||
void setSizeEq( const std::string& size );
|
||||
|
||||
const std::string& getSizeEq() const { return mDrawableSizeEq; }
|
||||
|
||||
const Repeat& getRepeat() const;
|
||||
|
||||
void setRepeat( const Repeat& repeat );
|
||||
@@ -62,6 +66,10 @@ class EE_API UINodeDrawable : public Drawable {
|
||||
const Sizef& getDrawableSize() const;
|
||||
|
||||
void setDrawableSize( const Sizef& drawableSize );
|
||||
|
||||
Sizef calcDrawableSize( const std::string& drawableSizeEq );
|
||||
|
||||
Vector2f calcPosition( const std::string& positionEq );
|
||||
protected:
|
||||
UINodeDrawable * mContainer;
|
||||
Sizef mSize;
|
||||
@@ -70,7 +78,6 @@ class EE_API UINodeDrawable : public Drawable {
|
||||
std::string mPositionEq;
|
||||
std::string mDrawableSizeEq;
|
||||
bool mNeedsUpdate;
|
||||
bool mUpdatePosEq;
|
||||
bool mOwnsDrawable;
|
||||
Drawable * mDrawable;
|
||||
Uint32 mResourceChangeCbId;
|
||||
@@ -107,6 +114,8 @@ class EE_API UINodeDrawable : public Drawable {
|
||||
|
||||
Uint32 getBorderRadius() const;
|
||||
|
||||
bool layerExists( int index );
|
||||
|
||||
LayerDrawable * getLayer( int index );
|
||||
|
||||
void setDrawable( int index, Drawable * drawable, bool ownIt );
|
||||
@@ -132,8 +141,6 @@ class EE_API UINodeDrawable : public Drawable {
|
||||
UINode * mOwner;
|
||||
RectangleDrawable mBackgroundColor;
|
||||
std::map<int,LayerDrawable*> mGroup;
|
||||
std::map<int,std::string> mPosEq;
|
||||
std::map<int,std::string> mSizeEq;
|
||||
Sizef mSize;
|
||||
bool mNeedsUpdate;
|
||||
bool mClipEnabled;
|
||||
|
||||
@@ -1288,6 +1288,18 @@ Node * Node::runAction( Action * action ) {
|
||||
return this;
|
||||
}
|
||||
|
||||
void Node::removeAction( Action * action ) {
|
||||
getActionManager()->removeAction( action );
|
||||
}
|
||||
|
||||
void Node::removeActionByTag( const Uint32& tag ) {
|
||||
getActionManager()->removeActionByTag( tag );
|
||||
}
|
||||
|
||||
void Node::clearActions() {
|
||||
getActionManager()->removeAllActionsFromTarget( this );
|
||||
}
|
||||
|
||||
void Node::runOnMainThread( Actions::Runnable::RunnableFunc runnable, const Time& delay ) {
|
||||
runAction( Actions::Runnable::New( runnable, delay ) );
|
||||
}
|
||||
|
||||
@@ -46,6 +46,11 @@ SceneNode::SceneNode( EE::Window::Window * window ) :
|
||||
|
||||
mResizeCb = mWindow->pushResizeCallback( cb::Make1( this, &SceneNode::resizeControl ) );
|
||||
|
||||
DisplayManager * displayManager = Engine::instance()->getDisplayManager();
|
||||
int currentDisplayIndex = getWindow()->getCurrentDisplayIndex();
|
||||
Display * currentDisplay = displayManager->getDisplayIndex( currentDisplayIndex );
|
||||
mDPI = currentDisplay->getDPI();
|
||||
|
||||
resizeControl( window );
|
||||
}
|
||||
|
||||
@@ -448,4 +453,8 @@ void SceneNode::setUpdateAllChilds( const bool& updateAllChilds ) {
|
||||
mUpdateAllChilds = updateAllChilds;
|
||||
}
|
||||
|
||||
const Float& SceneNode::getDPI() const {
|
||||
return mDPI;
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
@@ -991,12 +991,7 @@ Float UINode::lengthAsPixels( const CSS::StyleSheetLength& length, const Sizef&
|
||||
percentAsWidth ? getParent()->getPixelsSize().getWidth() - drawableSize.getWidth() :
|
||||
getParent()->getPixelsSize().getHeight() - drawableSize.getHeight(),
|
||||
getSceneNode()->getPixelsSize(),
|
||||
Engine::instance()->getDisplayManager()->getDisplayIndex(
|
||||
getSceneNode()->getWindow()->getCurrentDisplayIndex()
|
||||
)->getDPI(),
|
||||
12,
|
||||
12
|
||||
);
|
||||
getSceneNode()->getDPI(), 12, 12 );
|
||||
}
|
||||
|
||||
Float UINode::lengthAsDp( const CSS::StyleSheetLength& length, const Sizef& drawableSize, const bool& percentAsWidth ) {
|
||||
|
||||
@@ -48,6 +48,10 @@ Uint32 UINodeDrawable::getBorderRadius() const {
|
||||
return mBackgroundColor.getCorners();
|
||||
}
|
||||
|
||||
bool UINodeDrawable::layerExists( int index ) {
|
||||
return mGroup.find( index ) != mGroup.end();
|
||||
}
|
||||
|
||||
UINodeDrawable::LayerDrawable* UINodeDrawable::getLayer( int index ) {
|
||||
auto it = mGroup.find(index);
|
||||
|
||||
@@ -60,15 +64,11 @@ UINodeDrawable::LayerDrawable* UINodeDrawable::getLayer( int index ) {
|
||||
void UINodeDrawable::setDrawable( int index, Drawable* drawable, bool ownIt ) {
|
||||
if ( drawable != getLayer( index )->getDrawable() ) {
|
||||
getLayer( index )->setDrawable( drawable, ownIt );
|
||||
mNeedsUpdate = true;
|
||||
}
|
||||
}
|
||||
|
||||
void UINodeDrawable::setDrawablePosition( int index, const std::string& positionEq ) {
|
||||
if ( mPosEq[index] != positionEq ) {
|
||||
mPosEq[index] = positionEq;
|
||||
mNeedsUpdate = true;
|
||||
}
|
||||
getLayer( index )->setPositionEq( positionEq );
|
||||
}
|
||||
|
||||
void UINodeDrawable::setDrawableRepeat( int index, const std::string& repeatRule ) {
|
||||
@@ -76,10 +76,7 @@ void UINodeDrawable::setDrawableRepeat( int index, const std::string& repeatRule
|
||||
}
|
||||
|
||||
void UINodeDrawable::setDrawableSize( int index, const std::string& sizeEq ) {
|
||||
if ( mSizeEq[index] != sizeEq ) {
|
||||
mSizeEq[index] = sizeEq;
|
||||
mNeedsUpdate = true;
|
||||
}
|
||||
getLayer( index )->setSizeEq( sizeEq );
|
||||
}
|
||||
|
||||
void UINodeDrawable::setBackgroundColor(const Color& color) {
|
||||
@@ -182,15 +179,6 @@ void UINodeDrawable::onSizeChange() {
|
||||
void UINodeDrawable::update() {
|
||||
mBackgroundColor.setPosition( mPosition );
|
||||
mBackgroundColor.setSize( mSize );
|
||||
|
||||
for ( size_t i = 0; i < mGroup.size(); i++ ) {
|
||||
UINodeDrawable::LayerDrawable * drawable = mGroup[i];
|
||||
drawable->setPosition( mPosition );
|
||||
drawable->setSizeEq( mSizeEq[i].empty() ? "auto" : mSizeEq[i] );
|
||||
drawable->setPositionEq( mPosEq[i] );
|
||||
drawable->setSize( mSize );
|
||||
}
|
||||
|
||||
mNeedsUpdate = false;
|
||||
}
|
||||
|
||||
@@ -203,9 +191,9 @@ UINodeDrawable::LayerDrawable * UINodeDrawable::LayerDrawable::New( UINodeDrawab
|
||||
UINodeDrawable::LayerDrawable::LayerDrawable( UINodeDrawable * container ) :
|
||||
Drawable(UINODEDRAWABLE_LAYERDRAWABLE),
|
||||
mContainer(container),
|
||||
mPositionEq("0px 0px"),
|
||||
mDrawableSizeEq("auto"),
|
||||
mNeedsUpdate(false),
|
||||
mUpdatePosEq(false),
|
||||
mOwnsDrawable(false),
|
||||
mDrawable(NULL),
|
||||
mResourceChangeCbId(0)
|
||||
@@ -321,7 +309,6 @@ void UINodeDrawable::LayerDrawable::setRepeat( const UINodeDrawable::Repeat& rep
|
||||
|
||||
void UINodeDrawable::LayerDrawable::invalidate() {
|
||||
mNeedsUpdate = true;
|
||||
mUpdatePosEq = true;
|
||||
}
|
||||
|
||||
const Sizef& UINodeDrawable::LayerDrawable::getDrawableSize() const {
|
||||
@@ -332,40 +319,35 @@ void UINodeDrawable::LayerDrawable::setDrawableSize( const Sizef& drawableSize )
|
||||
mDrawableSize = drawableSize;
|
||||
}
|
||||
|
||||
void UINodeDrawable::LayerDrawable::onPositionChange() {
|
||||
invalidate();
|
||||
}
|
||||
Sizef UINodeDrawable::LayerDrawable::calcDrawableSize( const std::string& drawableSizeEq ) {
|
||||
Sizef size;
|
||||
|
||||
void UINodeDrawable::LayerDrawable::update() {
|
||||
if ( mDrawable == NULL )
|
||||
return;
|
||||
|
||||
if ( mDrawableSizeEq == "auto" ) {
|
||||
if ( drawableSizeEq == "auto" ) {
|
||||
if ( mDrawable->getDrawableType() == Drawable::RECTANGLE ) {
|
||||
mDrawableSize = mSize;
|
||||
size = mSize;
|
||||
} else {
|
||||
mDrawableSize = mDrawable->getSize();
|
||||
size = mDrawable->getSize();
|
||||
}
|
||||
} else if ( mDrawableSizeEq == "expand" ) {
|
||||
mDrawableSize = mSize;
|
||||
} else if ( mDrawableSizeEq == "contain" ) {
|
||||
} else if ( drawableSizeEq == "expand" ) {
|
||||
size = mSize;
|
||||
} else if ( drawableSizeEq == "contain" ) {
|
||||
Sizef drawableSize( mDrawable->getSize() );
|
||||
Float Scale1 = mSize.getWidth() / drawableSize.getWidth();
|
||||
Float Scale2 = mSize.getHeight() / drawableSize.getHeight();
|
||||
if ( Scale1 < 1 || Scale2 < 1 ) {
|
||||
Scale1 = eemin( Scale1, Scale2 );
|
||||
mDrawableSize = Sizef( drawableSize.getWidth() * Scale1, drawableSize.getHeight() * Scale1 );
|
||||
size = Sizef( drawableSize.getWidth() * Scale1, drawableSize.getHeight() * Scale1 );
|
||||
} else {
|
||||
mDrawableSize = drawableSize;
|
||||
size = drawableSize;
|
||||
}
|
||||
} else if ( mDrawableSizeEq == "cover" ) {
|
||||
} else if ( drawableSizeEq == "cover" ) {
|
||||
Sizef drawableSize( mDrawable->getSize() );
|
||||
Float Scale1 = mSize.getWidth() / drawableSize.getWidth();
|
||||
Float Scale2 = mSize.getHeight() / drawableSize.getHeight();
|
||||
Scale1 = eemax( Scale1, Scale2 );
|
||||
mDrawableSize = Sizef( drawableSize.getWidth() * Scale1, drawableSize.getHeight() * Scale1 );
|
||||
size = Sizef( drawableSize.getWidth() * Scale1, drawableSize.getHeight() * Scale1 );
|
||||
} else {
|
||||
std::vector<std::string> sizePart = String::split( mDrawableSizeEq, ' ' );
|
||||
std::vector<std::string> sizePart = String::split( drawableSizeEq, ' ' );
|
||||
|
||||
if ( sizePart.size() == 1 ) {
|
||||
sizePart.push_back( "auto" );
|
||||
@@ -374,75 +356,89 @@ void UINodeDrawable::LayerDrawable::update() {
|
||||
if ( sizePart.size() == 2 ) {
|
||||
if ( sizePart[0] == "auto" && sizePart[1] == "auto" ) {
|
||||
if ( mDrawable->getDrawableType() == Drawable::RECTANGLE ) {
|
||||
mDrawableSize = mSize;
|
||||
size = mSize;
|
||||
} else {
|
||||
mDrawableSize = mDrawable->getSize();
|
||||
size = mDrawable->getSize();
|
||||
}
|
||||
} else if ( sizePart[0] != "auto" ) {
|
||||
CSS::StyleSheetLength wl( CSS::StyleSheetLength::fromString( sizePart[0] ) );
|
||||
mDrawableSize.x = mContainer->getOwner()->lengthAsPixels( wl, Sizef::Zero, true );
|
||||
size.x = mContainer->getOwner()->lengthAsPixels( wl, Sizef::Zero, true );
|
||||
|
||||
if ( sizePart[1] == "auto" ) {
|
||||
Sizef drawableSize( mDrawable->getSize() );
|
||||
mDrawableSize.y = drawableSize.getHeight() * ( mDrawableSize.getWidth() / drawableSize.getWidth() );
|
||||
size.y = drawableSize.getHeight() * ( size.getWidth() / drawableSize.getWidth() );
|
||||
} else {
|
||||
CSS::StyleSheetLength hl( CSS::StyleSheetLength::fromString( sizePart[1] ) );
|
||||
mDrawableSize.y = mContainer->getOwner()->lengthAsPixels( hl, Sizef::Zero, false );
|
||||
size.y = mContainer->getOwner()->lengthAsPixels( hl, Sizef::Zero, false );
|
||||
}
|
||||
} else {
|
||||
CSS::StyleSheetLength hl( CSS::StyleSheetLength::fromString( sizePart[1] ) );
|
||||
mDrawableSize.y = mContainer->getOwner()->lengthAsPixels( hl, Sizef::Zero, false );
|
||||
size.y = mContainer->getOwner()->lengthAsPixels( hl, Sizef::Zero, false );
|
||||
|
||||
Sizef drawableSize( mDrawable->getSize() );
|
||||
mDrawableSize.x = drawableSize.getWidth() * ( mDrawableSize.getHeight() / drawableSize.getHeight() );
|
||||
size.x = drawableSize.getWidth() * ( size.getHeight() / drawableSize.getHeight() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( mUpdatePosEq ) {
|
||||
std::vector<std::string> pos = String::split( mPositionEq, ' ' );
|
||||
return size;
|
||||
}
|
||||
|
||||
if ( pos.size() == 1 ) {
|
||||
pos.push_back( "center" );
|
||||
Vector2f UINodeDrawable::LayerDrawable::calcPosition( const std::string& positionEq ) {
|
||||
Vector2f position( Vector2f::Zero );
|
||||
std::vector<std::string> pos = String::split( positionEq, ' ' );
|
||||
|
||||
if ( pos.size() == 1 )
|
||||
pos.push_back( "center" );
|
||||
|
||||
if ( pos.size() == 2 ) {
|
||||
CSS::StyleSheetLength xl( CSS::StyleSheetLength::fromString( pos[0] ) );
|
||||
CSS::StyleSheetLength yl( CSS::StyleSheetLength::fromString( pos[1] ) );
|
||||
position.x = mContainer->getOwner()->lengthAsPixels( xl, mDrawableSize, true );
|
||||
position.y = mContainer->getOwner()->lengthAsPixels( yl, mDrawableSize, false );
|
||||
} else if ( pos.size() > 2 ) {
|
||||
if ( pos.size() == 3 ) {
|
||||
pos.push_back( "0dp" );
|
||||
}
|
||||
|
||||
if ( pos.size() == 2 ) {
|
||||
CSS::StyleSheetLength xl( CSS::StyleSheetLength::fromString( pos[0] ) );
|
||||
CSS::StyleSheetLength yl( CSS::StyleSheetLength::fromString( pos[1] ) );
|
||||
mOffset.x = mContainer->getOwner()->lengthAsPixels( xl, mDrawableSize, true );
|
||||
mOffset.y = mContainer->getOwner()->lengthAsPixels( yl, mDrawableSize, false );
|
||||
} else if ( pos.size() > 2 ) {
|
||||
if ( pos.size() == 3 ) {
|
||||
pos.push_back( "0dp" );
|
||||
}
|
||||
int xFloatIndex = 0;
|
||||
int yFloatIndex = 2;
|
||||
|
||||
int xFloatIndex = 0;
|
||||
int yFloatIndex = 2;
|
||||
|
||||
if ( "bottom" == pos[0] || "top" == pos[0] ) {
|
||||
xFloatIndex = 2;
|
||||
yFloatIndex = 0;
|
||||
}
|
||||
|
||||
CSS::StyleSheetLength xl1( CSS::StyleSheetLength::fromString( pos[xFloatIndex] ) );
|
||||
CSS::StyleSheetLength xl2( CSS::StyleSheetLength::fromString( pos[xFloatIndex+1] ) );
|
||||
CSS::StyleSheetLength yl1( CSS::StyleSheetLength::fromString( pos[yFloatIndex] ) );
|
||||
CSS::StyleSheetLength yl2( CSS::StyleSheetLength::fromString( pos[yFloatIndex+1] ) );
|
||||
|
||||
mOffset.x = mContainer->getOwner()->lengthAsPixels( xl1, mDrawableSize, true );
|
||||
|
||||
Float xl2Val = mContainer->getOwner()->lengthAsPixels( xl2, mDrawableSize, true );
|
||||
mOffset.x += ( pos[xFloatIndex] == "right" ) ? -xl2Val : xl2Val;
|
||||
|
||||
mOffset.y = mContainer->getOwner()->lengthAsPixels( yl1, mDrawableSize, false );
|
||||
|
||||
Float yl2Val = mContainer->getOwner()->lengthAsPixels( yl2, mDrawableSize, false );
|
||||
mOffset.y += ( pos[yFloatIndex] == "bottom" ) ? -yl2Val : yl2Val;
|
||||
if ( "bottom" == pos[0] || "top" == pos[0] ) {
|
||||
xFloatIndex = 2;
|
||||
yFloatIndex = 0;
|
||||
}
|
||||
|
||||
mUpdatePosEq = false;
|
||||
CSS::StyleSheetLength xl1( CSS::StyleSheetLength::fromString( pos[xFloatIndex] ) );
|
||||
CSS::StyleSheetLength xl2( CSS::StyleSheetLength::fromString( pos[xFloatIndex+1] ) );
|
||||
CSS::StyleSheetLength yl1( CSS::StyleSheetLength::fromString( pos[yFloatIndex] ) );
|
||||
CSS::StyleSheetLength yl2( CSS::StyleSheetLength::fromString( pos[yFloatIndex+1] ) );
|
||||
|
||||
position.x = mContainer->getOwner()->lengthAsPixels( xl1, mDrawableSize, true );
|
||||
|
||||
Float xl2Val = mContainer->getOwner()->lengthAsPixels( xl2, mDrawableSize, true );
|
||||
position.x += ( pos[xFloatIndex] == "right" ) ? -xl2Val : xl2Val;
|
||||
|
||||
position.y = mContainer->getOwner()->lengthAsPixels( yl1, mDrawableSize, false );
|
||||
|
||||
Float yl2Val = mContainer->getOwner()->lengthAsPixels( yl2, mDrawableSize, false );
|
||||
position.y += ( pos[yFloatIndex] == "bottom" ) ? -yl2Val : yl2Val;
|
||||
}
|
||||
|
||||
return position;
|
||||
}
|
||||
|
||||
void UINodeDrawable::LayerDrawable::onPositionChange() {
|
||||
invalidate();
|
||||
}
|
||||
|
||||
void UINodeDrawable::LayerDrawable::update() {
|
||||
if ( mDrawable == NULL )
|
||||
return;
|
||||
|
||||
mDrawableSize = calcDrawableSize( mDrawableSizeEq );
|
||||
mOffset = calcPosition( mPositionEq );
|
||||
|
||||
mNeedsUpdate = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <eepp/ui/uistyle.hpp>
|
||||
#include <eepp/ui/uitooltip.hpp>
|
||||
#include <eepp/ui/uiscenenode.hpp>
|
||||
#include <eepp/ui/uinodedrawable.hpp>
|
||||
#include <eepp/ui/css/stylesheetproperty.hpp>
|
||||
#include <eepp/ui/css/stylesheetselector.hpp>
|
||||
#include <eepp/graphics/drawablesearcher.hpp>
|
||||
@@ -886,12 +887,15 @@ bool UIWidget::setAttribute( const NodeAttribute& attribute, const Uint32& state
|
||||
|
||||
if ( !isSceneNodeLoading() && NULL != mStyle && mStyle->hasTransition( attribute.getName() ) ) {
|
||||
UIStyle::TransitionInfo transitionInfo( mStyle->getTransition( attribute.getName() ) );
|
||||
Uint32 tag = String::hash("width");
|
||||
|
||||
Action * action = Actions::ResizeWidth::New( getSize().getWidth(), newWidth, transitionInfo.duration, transitionInfo.timingFunction );
|
||||
|
||||
if ( Time::Zero != transitionInfo.delay )
|
||||
action = Actions::Sequence::New( Actions::Delay::New( transitionInfo.delay ), action );
|
||||
|
||||
action->setTag( tag );
|
||||
removeActionByTag( tag );
|
||||
runAction( action );
|
||||
} else {
|
||||
setInternalWidth( newWidth );
|
||||
@@ -905,6 +909,7 @@ bool UIWidget::setAttribute( const NodeAttribute& attribute, const Uint32& state
|
||||
Float newHeight = attribute.asDpDimensionI();
|
||||
|
||||
if ( !isSceneNodeLoading() && NULL != mStyle && mStyle->hasTransition( attribute.getName() ) ) {
|
||||
Uint32 tag = String::hash("height");
|
||||
UIStyle::TransitionInfo transitionInfo( mStyle->getTransition( attribute.getName() ) );
|
||||
|
||||
Action * action = Actions::ResizeHeight::New( getSize().getHeight(), newHeight, transitionInfo.duration, transitionInfo.timingFunction );
|
||||
@@ -912,6 +917,8 @@ bool UIWidget::setAttribute( const NodeAttribute& attribute, const Uint32& state
|
||||
if ( Time::Zero != transitionInfo.delay )
|
||||
action = Actions::Sequence::New( Actions::Delay::New( transitionInfo.delay ), action );
|
||||
|
||||
action->setTag( tag );
|
||||
removeActionByTag( tag );
|
||||
runAction( action );
|
||||
} else {
|
||||
setInternalHeight( newHeight );
|
||||
@@ -946,10 +953,14 @@ bool UIWidget::setAttribute( const NodeAttribute& attribute, const Uint32& state
|
||||
setBackgroundDrawable( drawable, ownIt, index );
|
||||
} );
|
||||
} else if ( "background-position" == name || "backgroundposition" == name ) {
|
||||
SAVE_NORMAL_STATE_ATTR( getBackground()->getLayer(0)->getPositionEq() );
|
||||
|
||||
setBackgroundPosition( attribute.value(), 0 );
|
||||
} else if ( "background-repeat" == name || "backgroundrepeat" == name ) {
|
||||
setBackgroundRepeat( attribute.value(), 0 );
|
||||
} else if ( "background-size" == name || "backgroundsize" == name ) {
|
||||
SAVE_NORMAL_STATE_ATTR( getBackground()->getLayer(0)->getSizeEq() );
|
||||
|
||||
setBackgroundSize( attribute.value(), 0 );
|
||||
} else if ( "foreground" == name ) {
|
||||
if ( Color::isColorString( attribute.getValue() ) ) {
|
||||
@@ -983,6 +994,8 @@ bool UIWidget::setAttribute( const NodeAttribute& attribute, const Uint32& state
|
||||
SAVE_NORMAL_STATE_ATTR( String::toStr( getForegroundRadius() ) );
|
||||
|
||||
setForegroundRadius( attribute.asUint() );
|
||||
} else if ( "foreground-position" == name || "foregroundposition" == name ) {
|
||||
setForegroundPosition( attribute.value(), 0 );
|
||||
} else if ( "foreground-size" == name || "foregroundsize" == name ) {
|
||||
setForegroundSize( attribute.value(), 0 );
|
||||
} else if ( "border-color" == name || "bordercolor" == name ) {
|
||||
|
||||
@@ -34,28 +34,28 @@ const int& DisplaySDL2::getIndex() const {
|
||||
const std::vector<DisplayMode>& DisplaySDL2::getModes() const {
|
||||
if ( displayModes.empty() ) {
|
||||
int count = SDL_GetNumDisplayModes( index );
|
||||
|
||||
|
||||
if ( count > 0 ) {
|
||||
for ( int mode_index = 0; mode_index < count; mode_index++ ) {
|
||||
SDL_DisplayMode mode;
|
||||
|
||||
|
||||
if ( SDL_GetDisplayMode( index, mode_index, &mode ) == 0 ) {
|
||||
displayModes.push_back( DisplayMode( mode.w, mode.h, mode.refresh_rate, index ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return displayModes;
|
||||
}
|
||||
|
||||
DisplayMode DisplaySDL2::getCurrentMode() {
|
||||
SDL_DisplayMode mode;
|
||||
|
||||
|
||||
if ( SDL_GetCurrentDisplayMode(index, &mode) == 0 ) {
|
||||
return DisplayMode( mode.w, mode.h, mode.refresh_rate, index );
|
||||
}
|
||||
|
||||
|
||||
return DisplayMode(0,0,0,0);
|
||||
}
|
||||
|
||||
@@ -67,11 +67,11 @@ DisplayMode DisplaySDL2::getClosestDisplayMode( DisplayMode wantedMode ) {
|
||||
target.format = 0;
|
||||
target.refresh_rate = wantedMode.RefreshRate;
|
||||
target.driverdata = 0;
|
||||
|
||||
|
||||
if ( SDL_GetClosestDisplayMode(0, &target, &mode) != NULL ) {
|
||||
return DisplayMode( mode.w, mode.h, mode.refresh_rate, index );
|
||||
}
|
||||
|
||||
|
||||
return DisplayMode(0,0,0,0);
|
||||
}
|
||||
|
||||
@@ -85,13 +85,11 @@ Rect DisplaySDL2::getUsableBounds() {
|
||||
}
|
||||
|
||||
int DisplayManagerSDL2::getDisplayCount() {
|
||||
SDL_Init(SDL_INIT_VIDEO);
|
||||
if ( !SDL_WasInit(SDL_INIT_VIDEO) ) SDL_Init(SDL_INIT_VIDEO);
|
||||
return SDL_GetNumVideoDisplays();
|
||||
}
|
||||
|
||||
Display * DisplayManagerSDL2::getDisplayIndex( int index ) {
|
||||
SDL_Init(SDL_INIT_VIDEO);
|
||||
|
||||
if ( displays.empty() ) {
|
||||
int count = getDisplayCount();
|
||||
|
||||
|
||||
@@ -253,7 +253,14 @@ void WindowSDL::unsetGLContextThread() {
|
||||
}
|
||||
|
||||
int WindowSDL::getCurrentDisplayIndex() {
|
||||
return SDL_GetWindowDisplayIndex( mSDLWindow );
|
||||
int index = SDL_GetWindowDisplayIndex( mSDLWindow );
|
||||
|
||||
if ( index < 0 ) {
|
||||
eePRINTL( SDL_GetError() );
|
||||
return 0;
|
||||
}
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
std::string WindowSDL::getVersion() {
|
||||
@@ -407,7 +414,7 @@ void WindowSDL::setSize( Uint32 Width, Uint32 Height, bool Windowed ) {
|
||||
sendVideoResizeCb();
|
||||
}
|
||||
|
||||
void WindowSDL::swapBuffers() {
|
||||
void WindowSDL::swapBuffers() {
|
||||
SDL_GL_SwapWindow( mSDLWindow );
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user