mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-08-11 17:17:42 +03:00
Some optimizations on Node::nodeDraw.
UIPushButton will not create the icon node if not required (not sure yet if this is OK).
This commit is contained in:
@@ -533,13 +533,13 @@ class EE_API Node : public Transformable {
|
||||
|
||||
virtual void onSceneChange();
|
||||
|
||||
void clipStart();
|
||||
|
||||
virtual Uint32 onFocus();
|
||||
|
||||
virtual Uint32 onFocusLoss();
|
||||
|
||||
void clipEnd();
|
||||
void clipStart( bool needsClipPlanes );
|
||||
|
||||
void clipEnd(bool needsClipPlanes );
|
||||
|
||||
void updateScreenPos();
|
||||
|
||||
@@ -577,6 +577,11 @@ class EE_API Node : public Transformable {
|
||||
|
||||
void setChildsDirty();
|
||||
|
||||
void clipSmartEnable(const Int32& x, const Int32& y, const Uint32& Width,
|
||||
const Uint32& Height, bool needsClipPlanes );
|
||||
|
||||
void clipSmartDisable( bool needsClipPlanes );
|
||||
|
||||
void clipSmartEnable( const Int32& x, const Int32& y, const Uint32& Width,
|
||||
const Uint32& Height );
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include <eepp/core/core.hpp>
|
||||
#include <eepp/ui/models/modelrole.hpp>
|
||||
#include <eepp/ui/models/variant.hpp>
|
||||
#include <limits>
|
||||
|
||||
namespace EE { namespace UI { namespace Models {
|
||||
|
||||
@@ -69,4 +68,13 @@ class EE_API ModelIndex {
|
||||
|
||||
}}} // namespace EE::UI::Models
|
||||
|
||||
template <> struct std::hash<EE::UI::Models::ModelIndex> {
|
||||
std::size_t operator()( EE::UI::Models::ModelIndex const& modelIndex ) const noexcept {
|
||||
return hashCombine( reinterpret_cast<std::size_t>( modelIndex.model() ), modelIndex.row(),
|
||||
modelIndex.column(),
|
||||
reinterpret_cast<std::size_t>( modelIndex.internalData() ),
|
||||
modelIndex.internalId() );
|
||||
}
|
||||
};
|
||||
|
||||
#endif // EE_UI_MODEL_MODELINDEX_HPP
|
||||
|
||||
@@ -64,7 +64,7 @@ class EE_API SortingProxyModel final : public Model, private Model::Client {
|
||||
ModelIndex sourceParent;
|
||||
};
|
||||
|
||||
using InternalMapIterator = std::map<ModelIndex, std::shared_ptr<Mapping>>::iterator;
|
||||
using InternalMapIterator = UnorderedMap<ModelIndex, std::shared_ptr<Mapping>>::iterator;
|
||||
|
||||
SortingProxyModel( std::shared_ptr<Model> );
|
||||
|
||||
@@ -85,7 +85,7 @@ class EE_API SortingProxyModel final : public Model, private Model::Client {
|
||||
bool isSortingCaseSensitive();
|
||||
|
||||
std::shared_ptr<Model> mSource;
|
||||
std::map<ModelIndex, std::shared_ptr<Mapping>> mMappings;
|
||||
UnorderedMap<ModelIndex, std::shared_ptr<Mapping>> mMappings;
|
||||
int mKeyColumn{ -1 };
|
||||
SortOrder mSortOrder{ SortOrder::Ascending };
|
||||
ModelRole mSortRole{ ModelRole::Sort };
|
||||
|
||||
@@ -421,6 +421,10 @@ class EE_API UINode : public Node {
|
||||
|
||||
virtual void updateOriginPoint();
|
||||
|
||||
void smartClipStart( const ClipType& reqClipType, bool needsClipPlanes );
|
||||
|
||||
void smartClipEnd( const ClipType& reqClipType, bool needsClipPlanes );
|
||||
|
||||
void smartClipStart( const ClipType& reqClipType );
|
||||
|
||||
void smartClipEnd( const ClipType& reqClipType );
|
||||
|
||||
@@ -40,7 +40,9 @@ class EE_API UIPushButton : public UIWidget {
|
||||
|
||||
virtual UIPushButton* setIcon( Drawable* icon, bool ownIt = false );
|
||||
|
||||
virtual UIImage* getIcon() const;
|
||||
virtual UIImage* getIcon();
|
||||
|
||||
bool hasIcon() const;
|
||||
|
||||
virtual UIPushButton* setText( const String& text );
|
||||
|
||||
|
||||
@@ -4,8 +4,6 @@
|
||||
#include <eepp/ui/abstract/uiabstracttableview.hpp>
|
||||
#include <eepp/ui/uiicon.hpp>
|
||||
#include <eepp/ui/uitablerow.hpp>
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
|
||||
using namespace EE::UI::Abstract;
|
||||
|
||||
@@ -19,38 +17,13 @@ class EE_API UITreeViewCell : public UITableCell {
|
||||
|
||||
Uint32 getType() const { return UI_TYPE_TREEVIEW_CELL; }
|
||||
|
||||
bool isType( const Uint32& type ) const {
|
||||
return UITreeViewCell::getType() == type ? true : UITableCell::isType( type );
|
||||
}
|
||||
bool isType( const Uint32& type ) const;
|
||||
|
||||
UIImage* getImage() const { return mImage; }
|
||||
|
||||
Rectf calculatePadding() const {
|
||||
Sizef size;
|
||||
Rectf autoPadding;
|
||||
if ( mFlags & UI_AUTO_PADDING ) {
|
||||
autoPadding = makePadding( true, true, true, true );
|
||||
if ( autoPadding != Rectf() )
|
||||
autoPadding = PixelDensity::dpToPx( autoPadding );
|
||||
}
|
||||
if ( mPaddingPx.Top > autoPadding.Top )
|
||||
autoPadding.Top = mPaddingPx.Top;
|
||||
if ( mPaddingPx.Bottom > autoPadding.Bottom )
|
||||
autoPadding.Bottom = mPaddingPx.Bottom;
|
||||
if ( mPaddingPx.Left > autoPadding.Left )
|
||||
autoPadding.Left = mPaddingPx.Left;
|
||||
if ( mPaddingPx.Right > autoPadding.Right )
|
||||
autoPadding.Right = mPaddingPx.Right;
|
||||
autoPadding.Left += mIndent;
|
||||
return autoPadding;
|
||||
}
|
||||
Rectf calculatePadding() const;
|
||||
|
||||
void setIndentation( const Float& indent ) {
|
||||
if ( mIndent != indent ) {
|
||||
mIndent = indent;
|
||||
updateLayout();
|
||||
}
|
||||
}
|
||||
void setIndentation( const Float& indent );
|
||||
|
||||
const Float& getIndentation() const { return mIndent; }
|
||||
|
||||
@@ -58,26 +31,9 @@ class EE_API UITreeViewCell : public UITableCell {
|
||||
mutable UIImage* mImage{ nullptr };
|
||||
Float mIndent{ 0 };
|
||||
|
||||
UITreeViewCell( const std::function<UITextView*( UIPushButton* )>& newTextViewCb = nullptr ) :
|
||||
UITableCell( "treeview::cell", newTextViewCb ) {
|
||||
mTextBox->setElementTag( mTag + "::text" );
|
||||
mIcon->setElementTag( mTag + "::icon" );
|
||||
mInnerWidgetOrientation = InnerWidgetOrientation::WidgetIconTextBox;
|
||||
auto cb = [this]( const Event* ) { updateLayout(); };
|
||||
mImage = UIImage::NewWithTag( mTag + "::expander" );
|
||||
mImage->setScaleType( UIScaleType::FitInside )
|
||||
->setLayoutSizePolicy( SizePolicy::Fixed, SizePolicy::Fixed )
|
||||
->setFlags( UI_VALIGN_CENTER | UI_HALIGN_CENTER )
|
||||
->setParent( const_cast<UITreeViewCell*>( this ) )
|
||||
->setVisible( false )
|
||||
->setEnabled( false );
|
||||
mImage->addEventListener( Event::OnPaddingChange, cb );
|
||||
mImage->addEventListener( Event::OnMarginChange, cb );
|
||||
mImage->addEventListener( Event::OnSizeChange, cb );
|
||||
mImage->addEventListener( Event::OnVisibleChange, cb );
|
||||
}
|
||||
UITreeViewCell( const std::function<UITextView*( UIPushButton* )>& newTextViewCb = nullptr );
|
||||
|
||||
virtual UIWidget* getExtraInnerWidget() const { return mImage; }
|
||||
virtual UIWidget* getExtraInnerWidget() const;
|
||||
};
|
||||
|
||||
class EE_API UITreeView : public UIAbstractTableView {
|
||||
|
||||
@@ -1172,6 +1172,83 @@
|
||||
../../src/modules/eterm/src/eterm/terminal/wide.hpp
|
||||
../../src/modules/eterm/src/eterm/terminal/windowserrors.hpp
|
||||
../../src/modules/eterm/src/eterm/ui/uiterminal.cpp
|
||||
../../src/modules/physics/include/eepp/physics/arbiter.hpp
|
||||
../../src/modules/physics/include/eepp/physics/area.hpp
|
||||
../../src/modules/physics/include/eepp/physics/base.hpp
|
||||
../../src/modules/physics/include/eepp/physics/body.hpp
|
||||
../../src/modules/physics/include/eepp/physics/constraints/constraint.hpp
|
||||
../../src/modules/physics/include/eepp/physics/constraints/dampedrotaryspring.hpp
|
||||
../../src/modules/physics/include/eepp/physics/constraints/dampedspring.hpp
|
||||
../../src/modules/physics/include/eepp/physics/constraints/gearjoint.hpp
|
||||
../../src/modules/physics/include/eepp/physics/constraints/groovejoint.hpp
|
||||
../../src/modules/physics/include/eepp/physics/constraints/pinjoint.hpp
|
||||
../../src/modules/physics/include/eepp/physics/constraints/pivotjoint.hpp
|
||||
../../src/modules/physics/include/eepp/physics/constraints/ratchetjoint.hpp
|
||||
../../src/modules/physics/include/eepp/physics/constraints/rotarylimitjoint.hpp
|
||||
../../src/modules/physics/include/eepp/physics/constraints/simplemotor.hpp
|
||||
../../src/modules/physics/include/eepp/physics/constraints/slidejoint.hpp
|
||||
../../src/modules/physics/include/eepp/physics/moment.hpp
|
||||
../../src/modules/physics/include/eepp/physics/physics.hpp
|
||||
../../src/modules/physics/include/eepp/physics/physicshelper.hpp
|
||||
../../src/modules/physics/include/eepp/physics/physicsmanager.hpp
|
||||
../../src/modules/physics/include/eepp/physics/settings.hpp
|
||||
../../src/modules/physics/include/eepp/physics/shape.hpp
|
||||
../../src/modules/physics/include/eepp/physics/shapecircle.hpp
|
||||
../../src/modules/physics/include/eepp/physics/shapecirclesprite.hpp
|
||||
../../src/modules/physics/include/eepp/physics/shapepoint.hpp
|
||||
../../src/modules/physics/include/eepp/physics/shapepoly.hpp
|
||||
../../src/modules/physics/include/eepp/physics/shapepolysprite.hpp
|
||||
../../src/modules/physics/include/eepp/physics/shapesegment.hpp
|
||||
../../src/modules/physics/include/eepp/physics/space.hpp
|
||||
../../src/modules/physics/include/eepp/thirdparty/chipmunk/chipmunk.h
|
||||
../../src/modules/physics/include/eepp/thirdparty/chipmunk/chipmunk_ffi.h
|
||||
../../src/modules/physics/include/eepp/thirdparty/chipmunk/chipmunk_private.h
|
||||
../../src/modules/physics/include/eepp/thirdparty/chipmunk/chipmunk_types.h
|
||||
../../src/modules/physics/include/eepp/thirdparty/chipmunk/chipmunk_unsafe.h
|
||||
../../src/modules/physics/include/eepp/thirdparty/chipmunk/constraints/cpConstraint.h
|
||||
../../src/modules/physics/include/eepp/thirdparty/chipmunk/constraints/cpDampedRotarySpring.h
|
||||
../../src/modules/physics/include/eepp/thirdparty/chipmunk/constraints/cpDampedSpring.h
|
||||
../../src/modules/physics/include/eepp/thirdparty/chipmunk/constraints/cpGearJoint.h
|
||||
../../src/modules/physics/include/eepp/thirdparty/chipmunk/constraints/cpGrooveJoint.h
|
||||
../../src/modules/physics/include/eepp/thirdparty/chipmunk/constraints/cpPinJoint.h
|
||||
../../src/modules/physics/include/eepp/thirdparty/chipmunk/constraints/cpPivotJoint.h
|
||||
../../src/modules/physics/include/eepp/thirdparty/chipmunk/constraints/cpRatchetJoint.h
|
||||
../../src/modules/physics/include/eepp/thirdparty/chipmunk/constraints/cpRotaryLimitJoint.h
|
||||
../../src/modules/physics/include/eepp/thirdparty/chipmunk/constraints/cpSimpleMotor.h
|
||||
../../src/modules/physics/include/eepp/thirdparty/chipmunk/constraints/cpSlideJoint.h
|
||||
../../src/modules/physics/include/eepp/thirdparty/chipmunk/constraints/util.h
|
||||
../../src/modules/physics/include/eepp/thirdparty/chipmunk/cpArbiter.h
|
||||
../../src/modules/physics/include/eepp/thirdparty/chipmunk/cpBB.h
|
||||
../../src/modules/physics/include/eepp/thirdparty/chipmunk/cpBody.h
|
||||
../../src/modules/physics/include/eepp/thirdparty/chipmunk/cpPolyShape.h
|
||||
../../src/modules/physics/include/eepp/thirdparty/chipmunk/cpShape.h
|
||||
../../src/modules/physics/include/eepp/thirdparty/chipmunk/cpSpace.h
|
||||
../../src/modules/physics/include/eepp/thirdparty/chipmunk/cpSpatialIndex.h
|
||||
../../src/modules/physics/include/eepp/thirdparty/chipmunk/cpVect.h
|
||||
../../src/modules/physics/src/eepp/physics/arbiter.cpp
|
||||
../../src/modules/physics/src/eepp/physics/area.cpp
|
||||
../../src/modules/physics/src/eepp/physics/body.cpp
|
||||
../../src/modules/physics/src/eepp/physics/constraints/constraint.cpp
|
||||
../../src/modules/physics/src/eepp/physics/constraints/dampedrotaryspring.cpp
|
||||
../../src/modules/physics/src/eepp/physics/constraints/dampedspring.cpp
|
||||
../../src/modules/physics/src/eepp/physics/constraints/gearjoint.cpp
|
||||
../../src/modules/physics/src/eepp/physics/constraints/groovejoint.cpp
|
||||
../../src/modules/physics/src/eepp/physics/constraints/pinjoint.cpp
|
||||
../../src/modules/physics/src/eepp/physics/constraints/pivotjoint.cpp
|
||||
../../src/modules/physics/src/eepp/physics/constraints/ratchetjoint.cpp
|
||||
../../src/modules/physics/src/eepp/physics/constraints/rotarylimitjoint.cpp
|
||||
../../src/modules/physics/src/eepp/physics/constraints/simplemotor.cpp
|
||||
../../src/modules/physics/src/eepp/physics/constraints/slidejoint.cpp
|
||||
../../src/modules/physics/src/eepp/physics/moment.cpp
|
||||
../../src/modules/physics/src/eepp/physics/physicsmanager.cpp
|
||||
../../src/modules/physics/src/eepp/physics/shape.cpp
|
||||
../../src/modules/physics/src/eepp/physics/shapecircle.cpp
|
||||
../../src/modules/physics/src/eepp/physics/shapecirclesprite.cpp
|
||||
../../src/modules/physics/src/eepp/physics/shapepoint.cpp
|
||||
../../src/modules/physics/src/eepp/physics/shapepoly.cpp
|
||||
../../src/modules/physics/src/eepp/physics/shapepolysprite.cpp
|
||||
../../src/modules/physics/src/eepp/physics/shapesegment.cpp
|
||||
../../src/modules/physics/src/eepp/physics/space.cpp
|
||||
../../src/test/eetest.cpp
|
||||
../../src/tests/test_all/test.cpp
|
||||
../../src/tests/test_all/test.hpp
|
||||
|
||||
@@ -541,13 +541,15 @@ void Node::nodeDraw() {
|
||||
|
||||
matrixSet();
|
||||
|
||||
clipStart();
|
||||
bool needsClipPlanes = isMeOrParentTreeScaledOrRotatedOrFrameBuffer();
|
||||
|
||||
clipStart( needsClipPlanes );
|
||||
|
||||
draw();
|
||||
|
||||
drawChilds();
|
||||
|
||||
clipEnd();
|
||||
clipEnd( needsClipPlanes );
|
||||
|
||||
matrixUnset();
|
||||
}
|
||||
@@ -573,15 +575,16 @@ Rectf Node::getScreenRect() const {
|
||||
return Rectf( getScreenPos(), getPixelsSize() );
|
||||
}
|
||||
|
||||
void Node::clipStart() {
|
||||
void Node::clipStart( bool needsClipPlanes ) {
|
||||
if ( mVisible && isClipped() ) {
|
||||
clipSmartEnable( mScreenPos.x, mScreenPos.y, mSize.getWidth(), mSize.getHeight() );
|
||||
clipSmartEnable( mScreenPos.x, mScreenPos.y, mSize.getWidth(), mSize.getHeight(),
|
||||
needsClipPlanes );
|
||||
}
|
||||
}
|
||||
|
||||
void Node::clipEnd() {
|
||||
void Node::clipEnd( bool needsClipPlanes ) {
|
||||
if ( mVisible && isClipped() ) {
|
||||
clipSmartDisable();
|
||||
clipSmartDisable( needsClipPlanes );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1071,7 +1074,7 @@ bool Node::isMeOrParentTreeScaled() const {
|
||||
bool Node::isMeOrParentTreeScaledOrRotated() const {
|
||||
const Node* node = this;
|
||||
while ( NULL != node ) {
|
||||
if ( node->isScaled() || node->isRotated() )
|
||||
if ( node->mNodeFlags & ( NODE_FLAG_SCALED | NODE_FLAG_ROTATED ) )
|
||||
return true;
|
||||
node = node->getParent();
|
||||
}
|
||||
@@ -1081,9 +1084,9 @@ bool Node::isMeOrParentTreeScaledOrRotated() const {
|
||||
bool Node::isMeOrParentTreeScaledOrRotatedOrFrameBuffer() const {
|
||||
const Node* node = this;
|
||||
while ( NULL != node ) {
|
||||
if ( node->isScaled() || node->isRotated() || node->isFrameBuffer() )
|
||||
if ( node->mNodeFlags & ( NODE_FLAG_SCALED | NODE_FLAG_ROTATED | NODE_FLAG_FRAME_BUFFER ) )
|
||||
return true;
|
||||
node = node->getParent();
|
||||
node = node->mParentNode;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -1718,22 +1721,31 @@ Node* Node::clipDisable() {
|
||||
}
|
||||
|
||||
void Node::clipSmartEnable( const Int32& x, const Int32& y, const Uint32& Width,
|
||||
const Uint32& Height ) {
|
||||
if ( isMeOrParentTreeScaledOrRotatedOrFrameBuffer() ) {
|
||||
const Uint32& Height, bool needsClipPlanes ) {
|
||||
if ( needsClipPlanes ) {
|
||||
GLi->getClippingMask()->clipPlaneEnable( x, y, Width, Height );
|
||||
} else {
|
||||
GLi->getClippingMask()->clipEnable( x, y, Width, Height );
|
||||
}
|
||||
}
|
||||
|
||||
void Node::clipSmartDisable() {
|
||||
if ( isMeOrParentTreeScaledOrRotatedOrFrameBuffer() ) {
|
||||
void Node::clipSmartDisable( bool needsClipPlanes ) {
|
||||
if ( needsClipPlanes ) {
|
||||
GLi->getClippingMask()->clipPlaneDisable();
|
||||
} else {
|
||||
GLi->getClippingMask()->clipDisable();
|
||||
}
|
||||
}
|
||||
|
||||
void Node::clipSmartEnable( const Int32& x, const Int32& y, const Uint32& Width,
|
||||
const Uint32& Height ) {
|
||||
clipSmartEnable( x, y, Width, Height, isMeOrParentTreeScaledOrRotatedOrFrameBuffer() );
|
||||
}
|
||||
|
||||
void Node::clipSmartDisable() {
|
||||
clipSmartDisable( isMeOrParentTreeScaledOrRotatedOrFrameBuffer() );
|
||||
}
|
||||
|
||||
Node* Node::getDrawInvalidator() {
|
||||
Node* node = mParentNode;
|
||||
while ( node != NULL ) {
|
||||
|
||||
@@ -106,11 +106,13 @@ void SceneNode::draw() {
|
||||
matrixSet();
|
||||
|
||||
if ( NULL == mFrameBuffer || !usesInvalidation() || invalidated() ) {
|
||||
clipStart();
|
||||
bool needsClipPlanes = isMeOrParentTreeScaledOrRotatedOrFrameBuffer();
|
||||
|
||||
clipStart( needsClipPlanes );
|
||||
|
||||
drawChilds();
|
||||
|
||||
clipEnd();
|
||||
clipEnd( needsClipPlanes );
|
||||
}
|
||||
|
||||
matrixUnset();
|
||||
|
||||
@@ -476,7 +476,6 @@ UITableRow* UIAbstractTableView::createRow() {
|
||||
} else {
|
||||
getSelection().set( index );
|
||||
}
|
||||
|
||||
} );
|
||||
onRowCreated( rowWidget );
|
||||
return rowWidget;
|
||||
@@ -636,7 +635,8 @@ UIWidget* UIAbstractTableView::updateCell( const int& rowIndex, const ModelIndex
|
||||
isVisible = true;
|
||||
cell->setIcon( icon.asIcon()->getSize( mIconSize ) );
|
||||
}
|
||||
cell->getIcon()->setVisible( isVisible );
|
||||
if ( cell->hasIcon() )
|
||||
cell->getIcon()->setVisible( isVisible );
|
||||
|
||||
cell->updateCell( getModel() );
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ SortingProxyModel::buildMapping( const ModelIndex& sourceParent ) {
|
||||
auto sourceGrandParent = sourceParent.parent();
|
||||
buildMapping( sourceGrandParent );
|
||||
}
|
||||
mMappings.insert( std::make_pair( sourceParent, mapping ) );
|
||||
mMappings.insert( { sourceParent, mapping } );
|
||||
return mMappings.find( sourceParent );
|
||||
}
|
||||
|
||||
|
||||
@@ -2204,7 +2204,7 @@ bool UICodeEditor::applyProperty( const StyleSheetProperty& attribute ) {
|
||||
setFontSelectionBackColor( attribute.asColor() );
|
||||
break;
|
||||
case PropertyId::FontFamily: {
|
||||
Font* font = FontManager::instance()->getByName( attribute.asString() );
|
||||
Font* font = FontManager::instance()->getByName( attribute.value() );
|
||||
if ( NULL != font && font->loaded() ) {
|
||||
setFont( font );
|
||||
}
|
||||
|
||||
@@ -178,7 +178,7 @@ bool UIConsole::applyProperty( const StyleSheetProperty& attribute ) {
|
||||
setFontSelectionBackColor( attribute.asColor() );
|
||||
break;
|
||||
case PropertyId::FontFamily: {
|
||||
Font* font = FontManager::instance()->getByName( attribute.asString() );
|
||||
Font* font = FontManager::instance()->getByName( attribute.value() );
|
||||
|
||||
if ( NULL != font && font->loaded() ) {
|
||||
setFont( font );
|
||||
|
||||
@@ -10,7 +10,6 @@ UIMenuCheckBox* UIMenuCheckBox::New() {
|
||||
|
||||
UIMenuCheckBox::UIMenuCheckBox() :
|
||||
UIMenuItem( "menu::checkbox" ), mActive( false ), mSkinActive( NULL ), mSkinInactive( NULL ) {
|
||||
mIcon->setElementTag( mTag + "::icon" );
|
||||
mTextBox->setElementTag( mTag + "::text" );
|
||||
applyDefaultTheme();
|
||||
mIcon->setFlags( UI_SKIN_KEEP_SIZE_ON_DRAW );
|
||||
|
||||
@@ -11,9 +11,9 @@ UIMenuItem* UIMenuItem::New() {
|
||||
}
|
||||
|
||||
UIMenuItem::UIMenuItem( const std::string& tag ) : UIPushButton( tag ), mShortcutView( NULL ) {
|
||||
getIcon();
|
||||
unsetFlags( UI_AUTO_SIZE );
|
||||
setLayoutSizePolicy( SizePolicy::Fixed, SizePolicy::WrapContent );
|
||||
mIcon->setElementTag( mTag + "::icon" );
|
||||
mTextBox->setElementTag( mTag + "::text" );
|
||||
applyDefaultTheme();
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ UIMenuRadioButton::UIMenuRadioButton() :
|
||||
mActive( false ),
|
||||
mSkinActive( NULL ),
|
||||
mSkinInactive( NULL ) {
|
||||
mIcon->setElementTag( mTag + "::icon" );
|
||||
mTextBox->setElementTag( mTag + "::text" );
|
||||
applyDefaultTheme();
|
||||
mIcon->setFlags( UI_SKIN_KEEP_SIZE_ON_DRAW );
|
||||
|
||||
@@ -1006,7 +1006,7 @@ void UINode::drawBorder() {
|
||||
}
|
||||
}
|
||||
|
||||
void UINode::smartClipStart( const ClipType& reqClipType ) {
|
||||
void UINode::smartClipStart( const ClipType& reqClipType, bool needsClipPlanes ) {
|
||||
if ( mClip.getClipType() != reqClipType )
|
||||
return;
|
||||
switch ( mClip.getClipType() ) {
|
||||
@@ -1014,11 +1014,12 @@ void UINode::smartClipStart( const ClipType& reqClipType ) {
|
||||
const Rectf& pd = getPixelsPadding();
|
||||
clipSmartEnable( mScreenPos.x + pd.Left, mScreenPos.y + pd.Top,
|
||||
mSize.getWidth() - pd.Left - pd.Right,
|
||||
mSize.getHeight() - pd.Top - pd.Bottom );
|
||||
mSize.getHeight() - pd.Top - pd.Bottom, needsClipPlanes );
|
||||
break;
|
||||
}
|
||||
case ClipType::ContentBox: {
|
||||
clipSmartEnable( mScreenPos.x, mScreenPos.y, mSize.getWidth(), mSize.getHeight() );
|
||||
clipSmartEnable( mScreenPos.x, mScreenPos.y, mSize.getWidth(), mSize.getHeight(),
|
||||
needsClipPlanes );
|
||||
break;
|
||||
}
|
||||
case ClipType::BorderBox: {
|
||||
@@ -1027,7 +1028,7 @@ void UINode::smartClipStart( const ClipType& reqClipType ) {
|
||||
borderDiff = mBorder->getBorderBoxDiff();
|
||||
clipSmartEnable( mScreenPos.x + borderDiff.Left, mScreenPos.y + borderDiff.Top,
|
||||
mSize.getWidth() + borderDiff.Right,
|
||||
mSize.getHeight() + borderDiff.Bottom );
|
||||
mSize.getHeight() + borderDiff.Bottom, needsClipPlanes );
|
||||
break;
|
||||
}
|
||||
case ClipType::None: {
|
||||
@@ -1036,12 +1037,20 @@ void UINode::smartClipStart( const ClipType& reqClipType ) {
|
||||
}
|
||||
}
|
||||
|
||||
void UINode::smartClipEnd( const ClipType& reqClipType ) {
|
||||
void UINode::smartClipEnd( const ClipType& reqClipType, bool needsClipPlanes ) {
|
||||
if ( mVisible && isClipped() && mClip.getClipType() == reqClipType ) {
|
||||
clipEnd();
|
||||
clipEnd( needsClipPlanes );
|
||||
}
|
||||
}
|
||||
|
||||
void UINode::smartClipStart( const ClipType& reqClipType ) {
|
||||
smartClipStart( reqClipType, isMeOrParentTreeScaledOrRotatedOrFrameBuffer() );
|
||||
}
|
||||
|
||||
void UINode::smartClipEnd( const ClipType& reqClipType ) {
|
||||
smartClipEnd( reqClipType, isMeOrParentTreeScaledOrRotatedOrFrameBuffer() );
|
||||
}
|
||||
|
||||
void UINode::nodeDraw() {
|
||||
if ( mVisible ) {
|
||||
if ( mNodeFlags & NODE_FLAG_POSITION_DIRTY )
|
||||
@@ -1052,10 +1061,14 @@ void UINode::nodeDraw() {
|
||||
|
||||
matrixSet();
|
||||
|
||||
smartClipStart( ClipType::BorderBox );
|
||||
bool needsClipPlanes = isMeOrParentTreeScaledOrRotatedOrFrameBuffer();
|
||||
|
||||
if ( mWorldBounds.intersect( mSceneNode->getWorldBounds() ) ) {
|
||||
smartClipStart( ClipType::ContentBox );
|
||||
smartClipStart( ClipType::BorderBox, needsClipPlanes );
|
||||
|
||||
bool intersected = mWorldBounds.intersect( mSceneNode->getWorldBounds() );
|
||||
|
||||
if ( intersected ) {
|
||||
smartClipStart( ClipType::ContentBox, needsClipPlanes );
|
||||
|
||||
if ( 0.f != mAlpha ) {
|
||||
drawBackground();
|
||||
@@ -1063,36 +1076,39 @@ void UINode::nodeDraw() {
|
||||
drawSkin();
|
||||
}
|
||||
|
||||
smartClipStart( ClipType::PaddingBox );
|
||||
smartClipStart( ClipType::PaddingBox, needsClipPlanes );
|
||||
|
||||
draw();
|
||||
|
||||
drawChilds();
|
||||
|
||||
smartClipEnd( ClipType::PaddingBox );
|
||||
smartClipEnd( ClipType::PaddingBox, needsClipPlanes );
|
||||
|
||||
if ( 0.f != mAlpha )
|
||||
drawForeground();
|
||||
|
||||
smartClipEnd( ClipType::ContentBox );
|
||||
smartClipEnd( ClipType::ContentBox, needsClipPlanes );
|
||||
} else if ( !isClipped() ) {
|
||||
drawChilds();
|
||||
}
|
||||
|
||||
drawBorder();
|
||||
if ( intersected )
|
||||
drawBorder();
|
||||
|
||||
if ( mNodeFlags & NODE_FLAG_DROPPABLE_HOVERING )
|
||||
drawDroppableHovering();
|
||||
|
||||
drawHighlightFocus();
|
||||
if ( intersected ) {
|
||||
drawHighlightFocus();
|
||||
|
||||
drawOverNode();
|
||||
drawOverNode();
|
||||
|
||||
updateDebugData();
|
||||
updateDebugData();
|
||||
|
||||
drawBox();
|
||||
drawBox();
|
||||
}
|
||||
|
||||
smartClipEnd( ClipType::BorderBox );
|
||||
smartClipEnd( ClipType::BorderBox, needsClipPlanes );
|
||||
|
||||
matrixUnset();
|
||||
}
|
||||
|
||||
@@ -65,21 +65,8 @@ UIPushButton::UIPushButton( const std::string& tag,
|
||||
UIWidget( tag ), mIcon( NULL ), mTextBox( NULL ) {
|
||||
mFlags |= ( UI_AUTO_SIZE | UI_VALIGN_CENTER | UI_HALIGN_CENTER );
|
||||
|
||||
mIcon = UIImage::NewWithTag( tag + "::icon" );
|
||||
mIcon->setScaleType( UIScaleType::FitInside )
|
||||
->setLayoutSizePolicy( SizePolicy::Fixed, SizePolicy::Fixed )
|
||||
->setFlags( UI_VALIGN_CENTER | UI_HALIGN_CENTER )
|
||||
->setParent( this )
|
||||
->setVisible( true )
|
||||
->setEnabled( false );
|
||||
|
||||
auto cb = [this]( const Event* ) { onSizeChange(); };
|
||||
|
||||
mIcon->addEventListener( Event::OnPaddingChange, cb );
|
||||
mIcon->addEventListener( Event::OnMarginChange, cb );
|
||||
mIcon->addEventListener( Event::OnSizeChange, cb );
|
||||
mIcon->addEventListener( Event::OnVisibleChange, cb );
|
||||
|
||||
mTextBox = newTextViewCb ? newTextViewCb( this ) : UITextView::NewWithTag( tag + "::text" );
|
||||
mTextBox->setLayoutSizePolicy( SizePolicy::WrapContent, SizePolicy::WrapContent )
|
||||
->setFlags( UI_VALIGN_CENTER | UI_HALIGN_CENTER )
|
||||
@@ -255,18 +242,16 @@ UIWidget* UIPushButton::getFirstInnerItem() const {
|
||||
case InnerWidgetOrientation::WidgetIconTextBox:
|
||||
return getExtraInnerWidget() && getExtraInnerWidget()->isVisible()
|
||||
? getExtraInnerWidget()
|
||||
: mIcon;
|
||||
: ( mIcon && mIcon->isVisible() ? mIcon->asType<UIWidget>()
|
||||
: mTextBox->asType<UIWidget>() );
|
||||
case InnerWidgetOrientation::IconWidgetTextBox:
|
||||
return mIcon->isVisible()
|
||||
return mIcon && mIcon->isVisible()
|
||||
? mIcon
|
||||
: ( getExtraInnerWidget() && getExtraInnerWidget()->isVisible()
|
||||
? getExtraInnerWidget()
|
||||
: mTextBox );
|
||||
case InnerWidgetOrientation::IconTextBoxWidget:
|
||||
if ( mIcon->isVisible() )
|
||||
return mIcon;
|
||||
else
|
||||
return mTextBox;
|
||||
return mIcon && mIcon->isVisible() ? mIcon->asType<UIWidget>() : mTextBox;
|
||||
case InnerWidgetOrientation::WidgetTextBoxIcon:
|
||||
return ( getExtraInnerWidget() && getExtraInnerWidget()->isVisible() )
|
||||
? getExtraInnerWidget()
|
||||
@@ -274,12 +259,14 @@ UIWidget* UIPushButton::getFirstInnerItem() const {
|
||||
case InnerWidgetOrientation::TextBoxIconWidget:
|
||||
if ( mTextBox->isVisible() )
|
||||
return mTextBox;
|
||||
if ( mIcon->isVisible() )
|
||||
if ( mIcon && mIcon->isVisible() )
|
||||
return mIcon;
|
||||
return getExtraInnerWidget();
|
||||
break;
|
||||
case InnerWidgetOrientation::TextBoxWidgetIcon:
|
||||
if ( mTextBox->isVisible() )
|
||||
return mTextBox;
|
||||
|
||||
break;
|
||||
}
|
||||
return mChild->isWidget() ? mChild->asType<UIWidget>() : nullptr;
|
||||
@@ -360,18 +347,46 @@ void UIPushButton::updateTextBox() {
|
||||
}
|
||||
|
||||
UIPushButton* UIPushButton::setIcon( Drawable* icon, bool ownIt ) {
|
||||
if ( mIcon->getDrawable() != icon ) {
|
||||
mIcon->setPixelsSize( icon->getPixelsSize() );
|
||||
mIcon->setDrawable( icon, ownIt );
|
||||
if ( nullptr == mIcon || mIcon->getDrawable() != icon ) {
|
||||
if ( icon )
|
||||
getIcon()->setPixelsSize( icon->getPixelsSize() );
|
||||
if ( icon == nullptr && mIcon == nullptr )
|
||||
return this;
|
||||
getIcon()->setDrawable( icon, ownIt );
|
||||
updateTextBox();
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
UIImage* UIPushButton::getIcon() const {
|
||||
UIImage* UIPushButton::getIcon() {
|
||||
if ( nullptr == mIcon ) {
|
||||
auto cb = [this]( const Event* ) { onSizeChange(); };
|
||||
|
||||
mIcon = UIImage::NewWithTag( mTag + "::icon" );
|
||||
mIcon->setScaleType( UIScaleType::FitInside )
|
||||
->setLayoutSizePolicy( SizePolicy::Fixed, SizePolicy::Fixed )
|
||||
->setFlags( UI_VALIGN_CENTER | UI_HALIGN_CENTER )
|
||||
->setParent( this )
|
||||
->setVisible( true )
|
||||
->setEnabled( false );
|
||||
|
||||
mIcon->addEventListener( Event::OnPaddingChange, cb );
|
||||
mIcon->addEventListener( Event::OnMarginChange, cb );
|
||||
mIcon->addEventListener( Event::OnSizeChange, cb );
|
||||
mIcon->addEventListener( Event::OnVisibleChange, cb );
|
||||
|
||||
if ( mIconMinSize != Sizei::Zero ) {
|
||||
mIconMinSize = Sizei{ -1, -1 }; // force refresh
|
||||
setIconMinimumSize( mIconMinSize );
|
||||
}
|
||||
}
|
||||
return mIcon;
|
||||
}
|
||||
|
||||
bool UIPushButton::hasIcon() const {
|
||||
return mIcon != nullptr;
|
||||
}
|
||||
|
||||
UIPushButton* UIPushButton::setText( const String& text ) {
|
||||
if ( text != mTextBox->getText() ) {
|
||||
mTextBox->setVisible( !text.empty() );
|
||||
@@ -393,7 +408,8 @@ UITextView* UIPushButton::getTextBox() const {
|
||||
void UIPushButton::onAlphaChange() {
|
||||
UIWidget::onAlphaChange();
|
||||
|
||||
mIcon->setAlpha( mAlpha );
|
||||
if ( mIcon )
|
||||
mIcon->setAlpha( mAlpha );
|
||||
mTextBox->setAlpha( mAlpha );
|
||||
|
||||
if ( NULL != getExtraInnerWidget() ) {
|
||||
@@ -437,7 +453,7 @@ void UIPushButton::setIconMinimumSize( const Sizei& minIconSize ) {
|
||||
if ( minIconSize != mIconMinSize ) {
|
||||
mIconMinSize = minIconSize;
|
||||
|
||||
if ( mIconMinSize.x != 0 && mIconMinSize.y != 0 ) {
|
||||
if ( mIcon && mIconMinSize.x != 0 && mIconMinSize.y != 0 ) {
|
||||
mIcon->setMinSizeEq( String::fromFloat( mIconMinSize.x, "dp" ),
|
||||
String::fromFloat( mIconMinSize.y, "dp" ) );
|
||||
}
|
||||
@@ -523,8 +539,11 @@ std::string UIPushButton::getPropertyString( const PropertyDefinition* propertyD
|
||||
: "left" );
|
||||
case PropertyId::TextAsFallback:
|
||||
return mTextAsFallback ? "true" : "false";
|
||||
case PropertyId::Tint:
|
||||
return mIcon->getColor().toHexString();
|
||||
case PropertyId::Tint: {
|
||||
if ( mIcon )
|
||||
return mIcon->getColor().toHexString();
|
||||
return Color::Transparent.toHexString();
|
||||
}
|
||||
case PropertyId::Color:
|
||||
case PropertyId::TextShadowColor:
|
||||
case PropertyId::TextShadowOffset:
|
||||
@@ -580,14 +599,14 @@ bool UIPushButton::applyProperty( const StyleSheetProperty& attribute ) {
|
||||
|
||||
switch ( attribute.getPropertyDefinition()->getPropertyId() ) {
|
||||
case PropertyId::InnerWidgetOrientation:
|
||||
setInnerWidgetOrientation( innerWidgetOrientationFromString( attribute.asString() ) );
|
||||
setInnerWidgetOrientation( innerWidgetOrientationFromString( attribute.value() ) );
|
||||
break;
|
||||
case PropertyId::Text:
|
||||
if ( NULL != mSceneNode && mSceneNode->isUISceneNode() )
|
||||
setText( getUISceneNode()->getTranslatorString( attribute.asString() ) );
|
||||
setText( getUISceneNode()->getTranslatorString( attribute.value() ) );
|
||||
break;
|
||||
case PropertyId::Icon: {
|
||||
std::string val = attribute.asString();
|
||||
const std::string& val = attribute.value();
|
||||
Drawable* icon = NULL;
|
||||
bool ownIt;
|
||||
UIIcon* iconF = getUISceneNode()->findIcon( val );
|
||||
@@ -620,7 +639,8 @@ bool UIPushButton::applyProperty( const StyleSheetProperty& attribute ) {
|
||||
setTextAsFallback( attribute.asBool() );
|
||||
break;
|
||||
case PropertyId::Tint:
|
||||
mIcon->setColor( attribute.asColor() );
|
||||
if ( mIcon )
|
||||
mIcon->setColor( attribute.asColor() );
|
||||
break;
|
||||
case PropertyId::Color:
|
||||
case PropertyId::TextShadowColor:
|
||||
|
||||
@@ -120,7 +120,7 @@ bool UISplitter::applyProperty( const StyleSheetProperty& attribute ) {
|
||||
|
||||
switch ( attribute.getPropertyDefinition()->getPropertyId() ) {
|
||||
case PropertyId::SplitterPartition:
|
||||
setSplitPartition( StyleSheetLength( attribute.asString() ) );
|
||||
setSplitPartition( StyleSheetLength( attribute.value() ) );
|
||||
case PropertyId::SplitterAlwaysShow:
|
||||
setAlwaysShowSplitter( attribute.asBool() );
|
||||
case PropertyId::Orientation: {
|
||||
|
||||
@@ -13,10 +13,8 @@ UITab* UITab::New() {
|
||||
UITab::UITab() :
|
||||
UISelectButton( "tab" ), mOwnedWidget( NULL ), mDragTotalDiff( 0.f ), mTabWidget( NULL ) {
|
||||
mTextBox->setElementTag( mTag + "::text" );
|
||||
mIcon->setElementTag( mTag + "::icon" );
|
||||
auto cb = [this]( const Event* ) { onSizeChange(); };
|
||||
mTextBox->addEventListener( Event::OnSizeChange, cb );
|
||||
mIcon->addEventListener( Event::OnSizeChange, cb );
|
||||
mCloseButton = UIWidget::NewWithTag( mTag + "::close" );
|
||||
mCloseButton->setParent( const_cast<UITab*>( this ) );
|
||||
mCloseButton->setEnabled( false );
|
||||
@@ -303,10 +301,10 @@ bool UITab::applyProperty( const StyleSheetProperty& attribute ) {
|
||||
case PropertyId::Text:
|
||||
if ( NULL != mSceneNode && mSceneNode->isUISceneNode() )
|
||||
setText( static_cast<UISceneNode*>( mSceneNode )
|
||||
->getTranslatorString( attribute.asString() ) );
|
||||
->getTranslatorString( attribute.value() ) );
|
||||
break;
|
||||
case PropertyId::Owns:
|
||||
mOwnedName = attribute.asString();
|
||||
mOwnedName = attribute.value();
|
||||
setOwnedNode();
|
||||
break;
|
||||
default:
|
||||
|
||||
@@ -245,10 +245,10 @@ bool UITabWidget::applyProperty( const StyleSheetProperty& attribute ) {
|
||||
setMaxTextLength( attribute.asUint( 1 ) );
|
||||
break;
|
||||
case PropertyId::MinTabWidth:
|
||||
setMinTabWidth( attribute.asString() );
|
||||
setMinTabWidth( attribute.value() );
|
||||
break;
|
||||
case PropertyId::MaxTabWidth:
|
||||
setMaxTabWidth( attribute.asString() );
|
||||
setMaxTabWidth( attribute.value() );
|
||||
break;
|
||||
case PropertyId::TabClosable:
|
||||
setTabsClosable( attribute.asBool() );
|
||||
|
||||
@@ -104,7 +104,7 @@ bool UITextEdit::applyProperty( const StyleSheetProperty& attribute ) {
|
||||
|
||||
switch ( attribute.getPropertyDefinition()->getPropertyId() ) {
|
||||
case PropertyId::Text:
|
||||
setText( attribute.asString() );
|
||||
setText( attribute.value() );
|
||||
break;
|
||||
default:
|
||||
return UICodeEditor::applyProperty( attribute );
|
||||
|
||||
@@ -511,7 +511,7 @@ bool UITextInput::applyProperty( const StyleSheetProperty& attribute ) {
|
||||
|
||||
switch ( attribute.getPropertyDefinition()->getPropertyId() ) {
|
||||
case PropertyId::Text:
|
||||
setText( getTranslatorString( attribute.asString() ) );
|
||||
setText( getTranslatorString( attribute.value() ) );
|
||||
break;
|
||||
case PropertyId::AllowEditing:
|
||||
setAllowEditing( attribute.asBool() );
|
||||
@@ -526,7 +526,7 @@ bool UITextInput::applyProperty( const StyleSheetProperty& attribute ) {
|
||||
setAllowOnlyNumbers( onlyNumbersAllowed(), attribute.asBool() );
|
||||
break;
|
||||
case PropertyId::Hint:
|
||||
setHint( getTranslatorString( attribute.asString() ) );
|
||||
setHint( getTranslatorString( attribute.value() ) );
|
||||
break;
|
||||
case PropertyId::HintColor:
|
||||
setHintColor( attribute.asColor() );
|
||||
@@ -541,7 +541,7 @@ bool UITextInput::applyProperty( const StyleSheetProperty& attribute ) {
|
||||
setHintFontSize( lengthFromValue( attribute ) );
|
||||
break;
|
||||
case PropertyId::HintFontFamily:
|
||||
setHintFont( FontManager::instance()->getByName( attribute.asString() ) );
|
||||
setHintFont( FontManager::instance()->getByName( attribute.value() ) );
|
||||
break;
|
||||
case PropertyId::HintFontStyle:
|
||||
setHintFontStyle( attribute.asFontStyle() );
|
||||
|
||||
@@ -679,7 +679,7 @@ bool UITextView::applyProperty( const StyleSheetProperty& attribute ) {
|
||||
|
||||
switch ( attribute.getPropertyDefinition()->getPropertyId() ) {
|
||||
case PropertyId::Text:
|
||||
setText( getTranslatorString( attribute.asString() ) );
|
||||
setText( getTranslatorString( attribute.value() ) );
|
||||
break;
|
||||
case PropertyId::TextTransform:
|
||||
setTextTransform( TextTransform::fromString( attribute.asString() ) );
|
||||
@@ -701,7 +701,7 @@ bool UITextView::applyProperty( const StyleSheetProperty& attribute ) {
|
||||
setSelectionBackColor( attribute.asColor() );
|
||||
break;
|
||||
case PropertyId::FontFamily: {
|
||||
Font* font = FontManager::instance()->getByName( attribute.asString() );
|
||||
Font* font = FontManager::instance()->getByName( attribute.value() );
|
||||
|
||||
if ( NULL != font && font->loaded() ) {
|
||||
setFont( font );
|
||||
|
||||
@@ -521,7 +521,7 @@ bool UITooltip::applyProperty( const StyleSheetProperty& attribute ) {
|
||||
setFontShadowOffset( attribute.asVector2f() );
|
||||
break;
|
||||
case PropertyId::FontFamily: {
|
||||
Font* font = FontManager::instance()->getByName( attribute.asString() );
|
||||
Font* font = FontManager::instance()->getByName( attribute.value() );
|
||||
|
||||
if ( !mUsingCustomStyling && NULL != font && font->loaded() )
|
||||
setFont( font );
|
||||
|
||||
@@ -316,7 +316,7 @@ UIWidget* UITreeView::updateCell( const int& rowIndex, const ModelIndex& index,
|
||||
}
|
||||
}
|
||||
|
||||
if ( hasChilds && mExpandersAsIcons && cell->getIcon() ) {
|
||||
if ( hasChilds && mExpandersAsIcons && cell->hasIcon() ) {
|
||||
cell->getIcon()->setVisible( false );
|
||||
return widget;
|
||||
}
|
||||
@@ -330,7 +330,8 @@ UIWidget* UITreeView::updateCell( const int& rowIndex, const ModelIndex& index,
|
||||
isVisible = true;
|
||||
cell->setIcon( icon.asIcon()->getSize( mIconSize ) );
|
||||
}
|
||||
cell->getIcon()->setVisible( isVisible );
|
||||
if ( cell->hasIcon() )
|
||||
cell->getIcon()->setVisible( isVisible );
|
||||
|
||||
cell->updateCell( getModel() );
|
||||
}
|
||||
@@ -862,4 +863,57 @@ void UITreeView::onModelSelectionChange() {
|
||||
mFocusSelectionDirty = true;
|
||||
}
|
||||
|
||||
bool UITreeViewCell::isType( const Uint32& type ) const {
|
||||
return UITreeViewCell::getType() == type ? true : UITableCell::isType( type );
|
||||
}
|
||||
|
||||
Rectf UITreeViewCell::calculatePadding() const {
|
||||
Sizef size;
|
||||
Rectf autoPadding;
|
||||
if ( mFlags & UI_AUTO_PADDING ) {
|
||||
autoPadding = makePadding( true, true, true, true );
|
||||
if ( autoPadding != Rectf() )
|
||||
autoPadding = PixelDensity::dpToPx( autoPadding );
|
||||
}
|
||||
if ( mPaddingPx.Top > autoPadding.Top )
|
||||
autoPadding.Top = mPaddingPx.Top;
|
||||
if ( mPaddingPx.Bottom > autoPadding.Bottom )
|
||||
autoPadding.Bottom = mPaddingPx.Bottom;
|
||||
if ( mPaddingPx.Left > autoPadding.Left )
|
||||
autoPadding.Left = mPaddingPx.Left;
|
||||
if ( mPaddingPx.Right > autoPadding.Right )
|
||||
autoPadding.Right = mPaddingPx.Right;
|
||||
autoPadding.Left += mIndent;
|
||||
return autoPadding;
|
||||
}
|
||||
|
||||
void UITreeViewCell::setIndentation( const Float& indent ) {
|
||||
if ( mIndent != indent ) {
|
||||
mIndent = indent;
|
||||
updateLayout();
|
||||
}
|
||||
}
|
||||
|
||||
UITreeViewCell::UITreeViewCell( const std::function<UITextView*( UIPushButton* )>& newTextViewCb ) :
|
||||
UITableCell( "treeview::cell", newTextViewCb ) {
|
||||
mTextBox->setElementTag( mTag + "::text" );
|
||||
mInnerWidgetOrientation = InnerWidgetOrientation::WidgetIconTextBox;
|
||||
auto cb = [this]( const Event* ) { updateLayout(); };
|
||||
mImage = UIImage::NewWithTag( mTag + "::expander" );
|
||||
mImage->setScaleType( UIScaleType::FitInside )
|
||||
->setLayoutSizePolicy( SizePolicy::Fixed, SizePolicy::Fixed )
|
||||
->setFlags( UI_VALIGN_CENTER | UI_HALIGN_CENTER )
|
||||
->setParent( const_cast<UITreeViewCell*>( this ) )
|
||||
->setVisible( false )
|
||||
->setEnabled( false );
|
||||
mImage->addEventListener( Event::OnPaddingChange, cb );
|
||||
mImage->addEventListener( Event::OnMarginChange, cb );
|
||||
mImage->addEventListener( Event::OnSizeChange, cb );
|
||||
mImage->addEventListener( Event::OnVisibleChange, cb );
|
||||
}
|
||||
|
||||
UIWidget* UITreeViewCell::getExtraInnerWidget() const {
|
||||
return mImage;
|
||||
}
|
||||
|
||||
}} // namespace EE::UI
|
||||
|
||||
@@ -1488,7 +1488,7 @@ bool UIWidget::applyProperty( const StyleSheetProperty& attribute ) {
|
||||
setEnabled( attribute.asBool() );
|
||||
break;
|
||||
case PropertyId::Theme:
|
||||
setThemeByName( attribute.asString() );
|
||||
setThemeByName( attribute.value() );
|
||||
if ( !mSkinName.empty() )
|
||||
setThemeSkin( mSkinName );
|
||||
break;
|
||||
@@ -1580,7 +1580,7 @@ bool UIWidget::applyProperty( const StyleSheetProperty& attribute ) {
|
||||
setLayoutMarginBottom( lengthFromValueAsDp( attribute ) );
|
||||
break;
|
||||
case PropertyId::Tooltip: {
|
||||
String text = getTranslatorString( attribute.asString() );
|
||||
String text = getTranslatorString( attribute.value() );
|
||||
setTooltipText( text );
|
||||
if ( NULL != mTooltip )
|
||||
mTooltip->setStringBuffer( text );
|
||||
@@ -1681,7 +1681,7 @@ bool UIWidget::applyProperty( const StyleSheetProperty& attribute ) {
|
||||
rule = PositionPolicy::TopOf;
|
||||
else if ( layoutId == PropertyId::LayoutToBottomOf )
|
||||
rule = PositionPolicy::BottomOf;
|
||||
std::string id = attribute.asString();
|
||||
const std::string& id = attribute.value();
|
||||
Node* node = getParent()->find( id );
|
||||
if ( NULL != node && node->isWidget() ) {
|
||||
UIWidget* widget = static_cast<UIWidget*>( node );
|
||||
@@ -1772,28 +1772,28 @@ bool UIWidget::applyProperty( const StyleSheetProperty& attribute ) {
|
||||
setBorderEnabled( true )->setColorBottom( attribute.asColor() );
|
||||
break;
|
||||
case PropertyId::BorderLeftWidth:
|
||||
setBorderEnabled( true )->setLeftWidth( attribute.asString() );
|
||||
setBorderEnabled( true )->setLeftWidth( attribute.value() );
|
||||
break;
|
||||
case PropertyId::BorderRightWidth:
|
||||
setBorderEnabled( true )->setRightWidth( attribute.asString() );
|
||||
setBorderEnabled( true )->setRightWidth( attribute.value() );
|
||||
break;
|
||||
case PropertyId::BorderTopWidth:
|
||||
setBorderEnabled( true )->setTopWidth( attribute.asString() );
|
||||
setBorderEnabled( true )->setTopWidth( attribute.value() );
|
||||
break;
|
||||
case PropertyId::BorderBottomWidth:
|
||||
setBorderEnabled( true )->setBottomWidth( attribute.asString() );
|
||||
setBorderEnabled( true )->setBottomWidth( attribute.value() );
|
||||
break;
|
||||
case PropertyId::BorderTopLeftRadius:
|
||||
setTopLeftRadius( attribute.asString() );
|
||||
setTopLeftRadius( attribute.value() );
|
||||
break;
|
||||
case PropertyId::BorderBottomLeftRadius:
|
||||
setBottomLeftRadius( attribute.asString() );
|
||||
setBottomLeftRadius( attribute.value() );
|
||||
break;
|
||||
case PropertyId::BorderTopRightRadius:
|
||||
setTopRightRadius( attribute.asString() );
|
||||
setTopRightRadius( attribute.value() );
|
||||
break;
|
||||
case PropertyId::BorderBottomRightRadius:
|
||||
setBottomRightRadius( attribute.asString() );
|
||||
setBottomRightRadius( attribute.value() );
|
||||
break;
|
||||
case PropertyId::BorderSmooth:
|
||||
setBorderEnabled( true )->setSmooth( attribute.asBool() );
|
||||
|
||||
@@ -696,7 +696,7 @@ bool UIWidgetTable::applyProperty( const StyleSheetProperty& attribute ) {
|
||||
setRowHeight( attribute.asDpDimensionI( this ) );
|
||||
break;
|
||||
case PropertyId::VScrollMode: {
|
||||
std::string val = attribute.asString();
|
||||
const std::string& val = attribute.value();
|
||||
if ( "auto" == val )
|
||||
setVerticalScrollMode( ScrollBarMode::Auto );
|
||||
else if ( "on" == val )
|
||||
@@ -706,7 +706,7 @@ bool UIWidgetTable::applyProperty( const StyleSheetProperty& attribute ) {
|
||||
break;
|
||||
}
|
||||
case PropertyId::HScrollMode: {
|
||||
std::string val = attribute.asString();
|
||||
const std::string& val = attribute.value();
|
||||
if ( "auto" == val )
|
||||
setHorizontalScrollMode( ScrollBarMode::Auto );
|
||||
else if ( "on" == val )
|
||||
|
||||
@@ -1643,7 +1643,7 @@ bool UIWindow::applyProperty( const StyleSheetProperty& attribute ) {
|
||||
setSize( getSize().getWidth(), attribute.asDpDimension( this ) );
|
||||
break;
|
||||
case PropertyId::WindowTitle:
|
||||
setTitle( getUISceneNode()->getTranslatorString( attribute.asString() ) );
|
||||
setTitle( getUISceneNode()->getTranslatorString( attribute.value() ) );
|
||||
break;
|
||||
case PropertyId::WindowOpacity:
|
||||
setWindowOpacity( (Uint8)eemin<Uint32>( (Uint32)attribute.asFloat() * 255.f, 255u ) );
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
#define EE_PHYSICS_PHYSICSMANAGER_HPP
|
||||
|
||||
#include <eepp/physics/base.hpp>
|
||||
#include <list>
|
||||
|
||||
namespace EE { namespace Physics {
|
||||
|
||||
|
||||
@@ -125,25 +125,34 @@ void mainLoop() {
|
||||
uiSceneNode->setDrawDebugData( !uiSceneNode->getDrawDebugData() );
|
||||
}
|
||||
|
||||
if ( win->getInput()->isKeyUp( KEY_F11 ) ) {
|
||||
UIWidgetInspector::create( uiSceneNode );
|
||||
}
|
||||
|
||||
// Update the UI scene.
|
||||
SceneManager::instance()->update();
|
||||
|
||||
// Check if the UI has been invalidated ( needs redraw ).
|
||||
if ( SceneManager::instance()->getUISceneNode()->invalidated() ) {
|
||||
if ( true || SceneManager::instance()->getUISceneNode()->invalidated() ) {
|
||||
win->clear();
|
||||
|
||||
// Redraw the UI scene.
|
||||
SceneManager::instance()->draw();
|
||||
|
||||
Text::draw(
|
||||
String( String::format( "FPS: %d", win->getFPS() ) ), { 16, 16 },
|
||||
SceneManager::instance()->getUISceneNode()->getUIThemeManager()->getDefaultFont(), 12.f,
|
||||
Color::White, 0, 1.f, Color::Black );
|
||||
|
||||
win->display();
|
||||
} else {
|
||||
Sys::sleep( Milliseconds( 8 ) );
|
||||
// win->getInput()->waitEvent( Milliseconds( win->hasFocus() ? 16 : 100 ) );
|
||||
}
|
||||
}
|
||||
|
||||
EE_MAIN_FUNC int main( int, char*[] ) {
|
||||
win = Engine::instance()->createWindow( WindowSettings( 1024, 768, "eepp - UI Perf Test" ),
|
||||
ContextSettings( true ) );
|
||||
win = Engine::instance()->createWindow( WindowSettings( 1366, 768, "eepp - UI Perf Test" ),
|
||||
ContextSettings( false ) );
|
||||
|
||||
if ( win->isOpen() ) {
|
||||
FileSystem::changeWorkingDirectory( Sys::getProcessPath() );
|
||||
@@ -198,72 +207,77 @@ EE_MAIN_FUNC int main( int, char*[] ) {
|
||||
UITableView* view = UITableView::New();
|
||||
// view->setExpanderIconSize( PixelDensity::dpToPx( 20 ) );
|
||||
view->setId( "treeview" );
|
||||
/*view->setExpandedIcon( open );
|
||||
view->setContractedIcon( closed );*/
|
||||
view->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::MatchParent );
|
||||
view->setParent( vlay );
|
||||
view->setModel( SortingProxyModel::New( model ) );
|
||||
// view->setModel( model );
|
||||
Log::notice( "Total time: %.2fms", clock.getElapsedTime().asMilliseconds() );
|
||||
|
||||
UIWindow* uiWin = UIWindow::NewOpt( UIWindow::LINEAR_LAYOUT );
|
||||
uiWin->setMinWindowSize( 500, 400 );
|
||||
uiWin->setWindowFlags( UI_WIN_DEFAULT_FLAGS | UI_WIN_RESIZEABLE | UI_WIN_MAXIMIZE_BUTTON );
|
||||
UITreeView* widgetTree = UITreeView::New();
|
||||
widgetTree->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::MatchParent );
|
||||
widgetTree->setParent( uiWin );
|
||||
widgetTree->setHeadersVisible( false );
|
||||
widgetTree->setAutoExpandOnSingleColumn( true );
|
||||
widgetTree->setExpanderIconSize( PixelDensity::dpToPx( 20 ) );
|
||||
widgetTree->setModel( WidgetTreeModel::New( uiSceneNode ) );
|
||||
|
||||
/* ListBox test *//*
|
||||
std::vector<String> strings;
|
||||
for ( size_t i = 0; i < 10000; i++ )
|
||||
strings.emplace_back( String::format(
|
||||
"This is a very long string number %ld. Cover the full width of the listbox.",
|
||||
i ) );
|
||||
auto* lbox = UIListBox::New();
|
||||
std::cout << "Time New: " << clock.getElapsed().asMilliseconds() << " ms" << std::endl;
|
||||
lbox->setParent( vlay );
|
||||
std::cout << "Time setParent: " << clock.getElapsed().asMilliseconds() << " ms"
|
||||
<< std::endl;
|
||||
lbox->setLayoutMargin( Rectf( 4, 4, 4, 4 ) );
|
||||
std::cout << "Time setLayoutMargin: " << clock.getElapsed().asMilliseconds() << " ms"
|
||||
<< std::endl;
|
||||
lbox->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::MatchParent );
|
||||
std::cout << "Time setLayoutSizePolicy: " << clock.getElapsed().asMilliseconds() << " ms"
|
||||
<< std::endl;
|
||||
for ( size_t i = 0; i < 10; i++ )
|
||||
lbox->addListBoxItem( String::format(
|
||||
/* ListBox test */ /*
|
||||
std::vector<String> strings;
|
||||
for ( size_t i = 0; i < 10000; i++ )
|
||||
strings.emplace_back( String::format(
|
||||
"This is a very long string number %ld. Cover the full width of the listbox.",
|
||||
i ) );
|
||||
std::cout << "Time addListBoxItem: " << clock.getElapsed().asMilliseconds() << " ms"
|
||||
<< std::endl;
|
||||
lbox->addListBoxItems( strings );
|
||||
std::cout << "Time addListBoxItems: " << clock.getElapsed().asMilliseconds() << " ms"
|
||||
<< std::endl;*/
|
||||
auto* lbox = UIListBox::New();
|
||||
std::cout << "Time New: " << clock.getElapsed().asMilliseconds() << " ms" << std::endl;
|
||||
lbox->setParent( vlay );
|
||||
std::cout << "Time setParent: " << clock.getElapsed().asMilliseconds() << " ms"
|
||||
<< std::endl;
|
||||
lbox->setLayoutMargin( Rectf( 4, 4, 4, 4 ) );
|
||||
std::cout << "Time setLayoutMargin: " << clock.getElapsed().asMilliseconds() << " ms"
|
||||
<< std::endl;
|
||||
lbox->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::MatchParent );
|
||||
std::cout << "Time setLayoutSizePolicy: " << clock.getElapsed().asMilliseconds() << " ms"
|
||||
<< std::endl;
|
||||
for ( size_t i = 0; i < 10; i++ )
|
||||
lbox->addListBoxItem( String::format(
|
||||
"This is a very long string number %ld. Cover the full width of the listbox.",
|
||||
i ) );
|
||||
std::cout << "Time addListBoxItem: " << clock.getElapsed().asMilliseconds() << " ms"
|
||||
<< std::endl;
|
||||
lbox->addListBoxItems( strings );
|
||||
std::cout << "Time addListBoxItems: " << clock.getElapsed().asMilliseconds() << " ms"
|
||||
<< std::endl;*/
|
||||
|
||||
/* Create Widget test */
|
||||
Clock total;
|
||||
/*for ( size_t i = 0; i < 10000; i++ ) {
|
||||
UINode::New();
|
||||
}
|
||||
std::cout << "Time UINode total: " << total.getElapsedTime().asMilliseconds() << " ms"
|
||||
<< std::endl;
|
||||
|
||||
std::cout << "Time UINode total: " << total.getElapsedTime().toString() << std::endl;
|
||||
uiSceneNode->getRoot()->childsCloseAll();
|
||||
|
||||
total.restart();
|
||||
for ( size_t i = 0; i < 10000; i++ ) {
|
||||
UIWidget::New();
|
||||
}
|
||||
std::cout << "Time UIWidget total: " << total.getElapsedTime().asMilliseconds() << " ms"
|
||||
<< std::endl;
|
||||
std::cout << "Time UIWidget total: " << total.getElapsedTime().toString() << std::endl;
|
||||
uiSceneNode->getRoot()->childsCloseAll();*/
|
||||
|
||||
uiSceneNode->getRoot()->childsCloseAll();
|
||||
/*auto* rl = UIRelativeLayout::New();
|
||||
rl->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::MatchParent );
|
||||
|
||||
SceneManager::instance()->update();*/
|
||||
auto* sv = UIScrollView::New();
|
||||
sv->setParent( rl );
|
||||
sv->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::MatchParent );
|
||||
auto* parent = UILinearLayout::NewVertical();
|
||||
parent->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::WrapContent );
|
||||
parent->setParent( sv );
|
||||
|
||||
total.restart();
|
||||
for ( size_t i = 0; i < 10000; i++ ) {
|
||||
auto* but = UIPushButton::New();
|
||||
but->setText( String::format( "Button %zu", i ) );
|
||||
but->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::WrapContent );
|
||||
but->setParent( parent )->clipEnable();
|
||||
}
|
||||
std::cout << "Time UIPushButton total: " << total.getElapsedTime().toString() << std::endl;
|
||||
|
||||
// uiSceneNode->getRoot()->childsCloseAll();
|
||||
total.restart();
|
||||
SceneManager::instance()->update();
|
||||
std::cout << "SceneManager::instance()->update(): " << total.getElapsedTime().toString()
|
||||
<< std::endl;*/
|
||||
|
||||
/*total.restart();
|
||||
for ( size_t i = 0; i < 100000; i++ ) {
|
||||
|
||||
Reference in New Issue
Block a user