mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-09-29 17:54:09 +03:00
Added NodeAttribute, now UIWidgets can setAttribute from attribute name and value.
--HG-- branch : dev
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
#ifndef EE_NODEATTRIBUTE_HPP
|
||||
#define EE_NODEATTRIBUTE_HPP
|
||||
|
||||
#include <string>
|
||||
#include <eepp/core/string.hpp>
|
||||
|
||||
namespace EE { namespace Scene {
|
||||
|
||||
class NodeAttribute {
|
||||
public:
|
||||
NodeAttribute( std::string name, std::string value );
|
||||
|
||||
std::string getName() const;
|
||||
|
||||
void setName(const std::string & name);
|
||||
|
||||
const std::string& getValue() const;
|
||||
|
||||
const std::string& value() const;
|
||||
|
||||
void setValue(const std::string & value);
|
||||
|
||||
std::string asString( const std::string& defaultValue = "" ) const;
|
||||
|
||||
template<typename Type>
|
||||
Type asType( Type defaultValue ) const {
|
||||
Type val = defaultValue;
|
||||
return String::fromString<Type>( val, mValue ) ? val : defaultValue;
|
||||
}
|
||||
|
||||
int asInt( int defaultValue = 0 ) const;
|
||||
|
||||
unsigned int asUint( unsigned int defaultValue = 0 ) const;
|
||||
|
||||
double asDouble( double defaultValue = 0 ) const;
|
||||
|
||||
float asFloat( float defaultValue = 0 ) const;
|
||||
|
||||
long long asLlong( long long defaultValue = 0) const;
|
||||
|
||||
unsigned long long asUllong( unsigned long long defaultValue = 0 ) const;
|
||||
|
||||
bool asBool( bool defaultValue = false ) const;
|
||||
|
||||
protected:
|
||||
std::string mName;
|
||||
std::string mValue;
|
||||
};
|
||||
|
||||
}}
|
||||
|
||||
#endif
|
||||
@@ -32,7 +32,7 @@ class EE_API UICheckBox : public UITextView {
|
||||
|
||||
void setTextSeparation(const Int32 & textSeparation);
|
||||
|
||||
virtual void loadFromXmlNode( const pugi::xml_node& node );
|
||||
virtual void setAttribute( const NodeAttribute& attribute );
|
||||
protected:
|
||||
UINode * mActiveButton;
|
||||
UINode * mInactiveButton;
|
||||
|
||||
@@ -38,7 +38,9 @@ class EE_API UIDropDownList : public UITextInput {
|
||||
|
||||
void setStyleConfig(const UIDropDownListStyleConfig & styleConfig);
|
||||
|
||||
void loadFromXmlNode(const pugi::xml_node & node);
|
||||
virtual void setAttribute( const NodeAttribute& attribute );
|
||||
|
||||
virtual void loadFromXmlNode(const pugi::xml_node & node);
|
||||
protected:
|
||||
friend class UIComboBox;
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ class EE_API UIGridLayout : public UILayout {
|
||||
|
||||
void setPadding(const Rect & padding);
|
||||
|
||||
virtual void loadFromXmlNode( const pugi::xml_node& node );
|
||||
virtual void setAttribute( const NodeAttribute& attribute );
|
||||
protected:
|
||||
Rect mPadding;
|
||||
Sizei mSpan;
|
||||
|
||||
@@ -31,7 +31,7 @@ class EE_API UIImage : public UIWidget {
|
||||
|
||||
const Vector2f& getAlignOffset() const;
|
||||
|
||||
virtual void loadFromXmlNode( const pugi::xml_node& node );
|
||||
virtual void setAttribute( const NodeAttribute& attribute );
|
||||
|
||||
Uint32 getScaleType() const;
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ class EE_API UILinearLayout : public UILayout {
|
||||
|
||||
UILinearLayout * add( UIWidget * widget );
|
||||
|
||||
virtual void loadFromXmlNode( const pugi::xml_node& node );
|
||||
virtual void setAttribute( const NodeAttribute& attribute );
|
||||
protected:
|
||||
UI_ORIENTATION mOrientation;
|
||||
|
||||
|
||||
@@ -112,6 +112,8 @@ class EE_API UIListBox : public UITouchDragableWidget {
|
||||
void setFontStyleConfig(const UIFontStyleConfig & fontStyleConfig);
|
||||
|
||||
void loadFromXmlNode(const pugi::xml_node & node);
|
||||
|
||||
virtual void setAttribute( const NodeAttribute& attribute );
|
||||
protected:
|
||||
friend class UIListBoxItem;
|
||||
friend class UIItemContainer<UIListBox>;
|
||||
|
||||
@@ -49,7 +49,7 @@ class EE_API UILoader : public UIWidget {
|
||||
|
||||
UILoader * setAnimationSpeed( const Float& animationSpeed );
|
||||
|
||||
virtual void loadFromXmlNode( const pugi::xml_node& node);
|
||||
virtual void setAttribute( const NodeAttribute& attribute );
|
||||
|
||||
Float getArcStartAngle() const;
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ class EE_API UIProgressBar : public UIWidget {
|
||||
|
||||
UITextView * getTextBox() const;
|
||||
|
||||
virtual void loadFromXmlNode( const pugi::xml_node& node );
|
||||
virtual void setAttribute( const NodeAttribute& attribute );
|
||||
protected:
|
||||
UIProgressBarStyleConfig mStyleConfig;
|
||||
Float mProgress;
|
||||
|
||||
@@ -75,7 +75,7 @@ class EE_API UIPushButton : public UIWidget {
|
||||
|
||||
void setStyleConfig(const UIPushButtonStyleConfig & styleConfig);
|
||||
|
||||
virtual void loadFromXmlNode( const pugi::xml_node& node );
|
||||
virtual void setAttribute( const NodeAttribute& attribute );
|
||||
protected:
|
||||
UIPushButtonStyleConfig mStyleConfig;
|
||||
UIImage * mIcon;
|
||||
|
||||
@@ -32,7 +32,7 @@ class EE_API UIRadioButton : public UITextView {
|
||||
|
||||
void setTextSeparation(const Int32 & textSeparation);
|
||||
|
||||
virtual void loadFromXmlNode( const pugi::xml_node& node );
|
||||
virtual void setAttribute( const NodeAttribute& attribute );
|
||||
protected:
|
||||
UINode * mActiveButton;
|
||||
UINode * mInactiveButton;
|
||||
|
||||
@@ -67,8 +67,7 @@ class EE_API UIScrollBar : public UIWidget {
|
||||
|
||||
void setExpandBackground( bool expandBackground );
|
||||
|
||||
virtual void loadFromXmlNode( const pugi::xml_node& node );
|
||||
|
||||
virtual void setAttribute( const NodeAttribute& attribute );
|
||||
protected:
|
||||
ScrollBarType mScrollBarType;
|
||||
UISlider * mSlider;
|
||||
|
||||
@@ -40,7 +40,7 @@ class EE_API UIScrollView : public UITouchDragableWidget {
|
||||
|
||||
UINode * getContainer() const;
|
||||
|
||||
virtual void loadFromXmlNode( const pugi::xml_node& node );
|
||||
virtual void setAttribute( const NodeAttribute& attribute );
|
||||
protected:
|
||||
ScrollViewType mViewType;
|
||||
UI_SCROLLBAR_MODE mVScrollMode;
|
||||
|
||||
@@ -27,7 +27,7 @@ class EE_API UISelectButton : public UIPushButton {
|
||||
|
||||
const Color& getFontSelectedColor() const;
|
||||
|
||||
virtual void loadFromXmlNode( const pugi::xml_node& node );
|
||||
virtual void setAttribute( const NodeAttribute& attribute );
|
||||
protected:
|
||||
virtual void onStateChange();
|
||||
};
|
||||
|
||||
@@ -64,7 +64,7 @@ class EE_API UISlider : public UIWidget {
|
||||
|
||||
void setPageStep( const Float & pageStep );
|
||||
|
||||
virtual void loadFromXmlNode( const pugi::xml_node& node );
|
||||
virtual void setAttribute( const NodeAttribute& attribute );
|
||||
protected:
|
||||
friend class Private::UISliderButton;
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ class EE_API UISpinBox : public UIWidget {
|
||||
|
||||
bool dotsInNumbersAllowed();
|
||||
|
||||
virtual void loadFromXmlNode( const pugi::xml_node& node );
|
||||
virtual void setAttribute( const NodeAttribute& attribute );
|
||||
protected:
|
||||
UITextInput * mInput;
|
||||
UINode * mPushUp;
|
||||
|
||||
@@ -46,7 +46,7 @@ class EE_API UISprite : public UIWidget {
|
||||
|
||||
bool getDeallocSprite();
|
||||
|
||||
virtual void loadFromXmlNode( const pugi::xml_node& node );
|
||||
virtual void setAttribute( const NodeAttribute& attribute );
|
||||
protected:
|
||||
Graphics::Sprite * mSprite;
|
||||
RenderMode mRender;
|
||||
|
||||
@@ -31,7 +31,7 @@ class EE_API UITab : public UISelectButton {
|
||||
|
||||
virtual void update( const Time& time );
|
||||
|
||||
virtual void loadFromXmlNode( const pugi::xml_node& node );
|
||||
virtual void setAttribute( const NodeAttribute& attribute );
|
||||
protected:
|
||||
Node * mControlOwned;
|
||||
std::string mOwnedName;
|
||||
|
||||
@@ -79,7 +79,7 @@ class EE_API UITable : public UITouchDragableWidget {
|
||||
|
||||
void setContainerPadding( const Rectf& containerPadding );
|
||||
|
||||
void loadFromXmlNode(const pugi::xml_node & node);
|
||||
virtual void setAttribute( const NodeAttribute& attribute );
|
||||
protected:
|
||||
friend class UIItemContainer<UITable>;
|
||||
friend class UITableCell;
|
||||
|
||||
@@ -135,7 +135,7 @@ class EE_API UITabWidget : public UIWidget {
|
||||
|
||||
void setStyleConfig(const UITabWidgetStyleConfig & styleConfig);
|
||||
|
||||
virtual void loadFromXmlNode( const pugi::xml_node& node );
|
||||
virtual void setAttribute( const NodeAttribute& attribute );
|
||||
protected:
|
||||
friend class UITab;
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ class EE_API UITextEdit : public UIWidget {
|
||||
|
||||
void setFontStyleConfig(const UIFontStyleConfig & fontStyleConfig);
|
||||
|
||||
virtual void loadFromXmlNode( const pugi::xml_node& node );
|
||||
virtual void setAttribute( const NodeAttribute& attribute );
|
||||
protected:
|
||||
UITextInput * mTextInput;
|
||||
UIScrollBar * mHScrollBar;
|
||||
|
||||
@@ -47,7 +47,7 @@ class EE_API UITextInput : public UITextView {
|
||||
|
||||
bool isFreeEditingEnabled();
|
||||
|
||||
virtual void loadFromXmlNode( const pugi::xml_node& node );
|
||||
virtual void setAttribute( const NodeAttribute& attribute );
|
||||
protected:
|
||||
InputTextBuffer mTextBuffer;
|
||||
Float mWaitCursorTime;
|
||||
|
||||
@@ -39,11 +39,11 @@ class EE_API UITextureRegion : public UIWidget {
|
||||
|
||||
const Vector2f& getAlignOffset() const;
|
||||
|
||||
virtual void loadFromXmlNode( const pugi::xml_node& node );
|
||||
|
||||
Uint32 getScaleType() const;
|
||||
|
||||
UITextureRegion * setScaleType(const Uint32 & scaleType);
|
||||
|
||||
virtual void setAttribute( const NodeAttribute& attribute );
|
||||
protected:
|
||||
Uint32 mScaleType;
|
||||
Graphics::TextureRegion * mTextureRegion;
|
||||
|
||||
@@ -80,7 +80,7 @@ class EE_API UITextView : public UIWidget {
|
||||
|
||||
UITextView * setPadding(const Rectf& padding);
|
||||
|
||||
virtual void loadFromXmlNode( const pugi::xml_node& node );
|
||||
virtual void setAttribute( const NodeAttribute& attribute );
|
||||
protected:
|
||||
Text * mTextCache;
|
||||
String mString;
|
||||
|
||||
@@ -29,7 +29,7 @@ class EE_API UITouchDragableWidget : public UIWidget {
|
||||
|
||||
UITouchDragableWidget * setTouchDragDeceleration( const Vector2f& touchDragDeceleration );
|
||||
|
||||
virtual void loadFromXmlNode( const pugi::xml_node& node );
|
||||
virtual void setAttribute( const NodeAttribute& attribute );
|
||||
protected:
|
||||
Vector2f mTouchDragPoint;
|
||||
Vector2f mTouchDragAcceleration;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#ifndef EE_UIUIWIDGET_HPP
|
||||
#define EE_UIUIWIDGET_HPP
|
||||
|
||||
#include <eepp/scene/nodeattribute.hpp>
|
||||
#include <eepp/ui/uinode.hpp>
|
||||
#include <eepp/ui/uitooltip.hpp>
|
||||
|
||||
@@ -85,6 +86,10 @@ class EE_API UIWidget : public UINode {
|
||||
void notifyLayoutAttrChange();
|
||||
|
||||
void notifyLayoutAttrChangeParent();
|
||||
|
||||
void setAttribute( const std::string& name, const std::string& value );
|
||||
|
||||
virtual void setAttribute( const NodeAttribute& attribute );
|
||||
protected:
|
||||
friend class UIManager;
|
||||
friend class UISceneNode;
|
||||
@@ -101,7 +106,8 @@ class EE_API UIWidget : public UINode {
|
||||
LayoutSizeRules mLayoutHeightRules;
|
||||
LayoutPositionRules mLayoutPositionRule;
|
||||
UIWidget * mLayoutPositionRuleWidget;
|
||||
int mPropertiesTransactionCount;
|
||||
int mAttributesTransactionCount;
|
||||
std::string mSkinName;
|
||||
|
||||
void createTooltip();
|
||||
|
||||
@@ -115,9 +121,9 @@ class EE_API UIWidget : public UINode {
|
||||
|
||||
virtual void onWidgetCreated();
|
||||
|
||||
void beginPropertiesTransaction();
|
||||
void beginAttributesTransaction();
|
||||
|
||||
void endPropertiesTransaction();
|
||||
void endAttributesTransaction();
|
||||
|
||||
void updateAnchors( const Vector2f & SizeChange );
|
||||
|
||||
|
||||
@@ -109,6 +109,8 @@ class EE_API UIWindow : public UIWidget {
|
||||
|
||||
virtual void loadFromXmlNode( const pugi::xml_node& node );
|
||||
|
||||
virtual void setAttribute( const NodeAttribute& attribute );
|
||||
|
||||
virtual void internalDraw();
|
||||
|
||||
void invalidate();
|
||||
|
||||
@@ -216,6 +216,7 @@
|
||||
../../include/eepp/scene/keyevent.hpp
|
||||
../../include/eepp/scene/mouseevent.hpp
|
||||
../../include/eepp/scene/node.hpp
|
||||
../../include/eepp/scene/nodeattribute.hpp
|
||||
../../include/eepp/scene/nodemessage.hpp
|
||||
../../include/eepp/scene/scenemanager.hpp
|
||||
../../include/eepp/scene/scenenode.hpp
|
||||
@@ -625,6 +626,7 @@
|
||||
../../src/eepp/scene/keyevent.cpp
|
||||
../../src/eepp/scene/mouseevent.cpp
|
||||
../../src/eepp/scene/node.cpp
|
||||
../../src/eepp/scene/nodeattribute.cpp
|
||||
../../src/eepp/scene/nodemessage.cpp
|
||||
../../src/eepp/scene/scenemanager.cpp
|
||||
../../src/eepp/scene/scenenode.cpp
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
#include <eepp/scene/nodeattribute.hpp>
|
||||
|
||||
namespace EE { namespace Scene {
|
||||
|
||||
NodeAttribute::NodeAttribute( std::string name, std::string value ) :
|
||||
mName( String::toLower( name ) ),
|
||||
mValue( value )
|
||||
{}
|
||||
|
||||
std::string NodeAttribute::getName() const {
|
||||
return mName;
|
||||
}
|
||||
|
||||
void NodeAttribute::setName( const std::string& name ) {
|
||||
mName = name;
|
||||
}
|
||||
|
||||
const std::string& NodeAttribute::getValue() const {
|
||||
return mValue;
|
||||
}
|
||||
|
||||
const std::string& NodeAttribute::value() const {
|
||||
return mValue;
|
||||
}
|
||||
|
||||
void NodeAttribute::setValue( const std::string& value ) {
|
||||
mValue = value;
|
||||
}
|
||||
|
||||
std::string NodeAttribute::asString( const std::string& defaultValue ) const {
|
||||
return mValue.empty() ? defaultValue : mValue;
|
||||
}
|
||||
|
||||
int NodeAttribute::asInt( int defaultValue ) const {
|
||||
return asType<int>( defaultValue );
|
||||
}
|
||||
|
||||
unsigned int NodeAttribute::asUint( unsigned int defaultValue ) const {
|
||||
return asType<unsigned int>( defaultValue );
|
||||
}
|
||||
|
||||
double NodeAttribute::asDouble( double defaultValue ) const {
|
||||
return asType<double>( defaultValue );
|
||||
}
|
||||
|
||||
float NodeAttribute::asFloat(float defaultValue) const {
|
||||
return asType<float>( defaultValue );
|
||||
}
|
||||
|
||||
long long NodeAttribute::asLlong(long long defaultValue) const {
|
||||
return asType<long long>( defaultValue );
|
||||
}
|
||||
|
||||
unsigned long long NodeAttribute::asUllong(unsigned long long defaultValue) const {
|
||||
return asType<unsigned long long>( defaultValue );
|
||||
}
|
||||
|
||||
bool NodeAttribute::asBool( bool defaultValue ) const {
|
||||
if ( mValue.empty() )
|
||||
return defaultValue;
|
||||
|
||||
// only look at first char
|
||||
char first = mValue[0];
|
||||
|
||||
// 1*, t* (true), T* (True), y* (yes), Y* (YES)
|
||||
return (first == '1' || first == 't' || first == 'T' || first == 'y' || first == 'Y');
|
||||
}
|
||||
|
||||
}}
|
||||
@@ -167,21 +167,14 @@ void UICheckBox::setTextSeparation(const Int32 & textSeparation) {
|
||||
setPadding( getPadding() );
|
||||
}
|
||||
|
||||
void UICheckBox::loadFromXmlNode(const pugi::xml_node & node) {
|
||||
beginPropertiesTransaction();
|
||||
void UICheckBox::setAttribute( const NodeAttribute& attribute ) {
|
||||
const std::string& name = attribute.getName();
|
||||
|
||||
UIWidget::loadFromXmlNode( node );
|
||||
|
||||
for (pugi::xml_attribute_iterator ait = node.attributes_begin(); ait != node.attributes_end(); ++ait) {
|
||||
std::string name = ait->name();
|
||||
String::toLowerInPlace( name );
|
||||
|
||||
if ( "selected" == name || "active" == name ) {
|
||||
setActive( ait->as_bool() );
|
||||
}
|
||||
if ( "selected" == name || "active" == name ) {
|
||||
setActive( attribute.asBool() );
|
||||
} else {
|
||||
UITextView::setAttribute( attribute );
|
||||
}
|
||||
|
||||
endPropertiesTransaction();
|
||||
}
|
||||
|
||||
Uint32 UICheckBox::onKeyDown( const KeyEvent& Event ) {
|
||||
|
||||
@@ -74,13 +74,13 @@ const String& UIComboBox::getText() {
|
||||
}
|
||||
|
||||
void UIComboBox::loadFromXmlNode(const pugi::xml_node& node) {
|
||||
beginPropertiesTransaction();
|
||||
beginAttributesTransaction();
|
||||
|
||||
UIWidget::loadFromXmlNode( node );
|
||||
|
||||
mDropDownList->loadFromXmlNode( node );
|
||||
|
||||
endPropertiesTransaction();
|
||||
endAttributesTransaction();
|
||||
}
|
||||
|
||||
Uint32 UIComboBox::onMessage( const NodeMessage * Msg ) {
|
||||
|
||||
@@ -265,25 +265,28 @@ void UIDropDownList::destroyListBox() {
|
||||
}
|
||||
}
|
||||
|
||||
void UIDropDownList::setAttribute( const NodeAttribute& attribute ) {
|
||||
const std::string& name = attribute.getName();
|
||||
|
||||
if ( "popuptomaincontrol" == name ) {
|
||||
setPopUpToMainControl( attribute.asBool() );
|
||||
} else if ( "maxnumvisibleitems" == name ) {
|
||||
setMaxNumVisibleItems( attribute.asUint() );
|
||||
} else {
|
||||
UITextInput::setAttribute( attribute );
|
||||
}
|
||||
|
||||
mListBox->setAttribute( attribute );
|
||||
}
|
||||
|
||||
void UIDropDownList::loadFromXmlNode(const pugi::xml_node & node) {
|
||||
beginPropertiesTransaction();
|
||||
beginAttributesTransaction();
|
||||
|
||||
UITextInput::loadFromXmlNode( node );
|
||||
|
||||
mListBox->loadFromXmlNode( node );
|
||||
|
||||
for (pugi::xml_attribute_iterator ait = node.attributes_begin(); ait != node.attributes_end(); ++ait) {
|
||||
std::string name = ait->name();
|
||||
String::toLowerInPlace( name );
|
||||
|
||||
if ( "popuptomaincontrol" == name ) {
|
||||
setPopUpToMainControl( ait->as_bool() );
|
||||
} else if ( "maxnumvisibleitems" == name ) {
|
||||
setMaxNumVisibleItems( ait->as_uint() );
|
||||
}
|
||||
}
|
||||
|
||||
endPropertiesTransaction();
|
||||
endAttributesTransaction();
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
@@ -206,54 +206,47 @@ Sizef UIGridLayout::getTargetElementSize() {
|
||||
mRowMode == Size ? mRowHeight : ( ( getLayoutHeightRules() == WRAP_CONTENT ? getParent()->getSize().getHeight() : mDpSize.getHeight() ) - mPadding.Top - mPadding.Bottom ) * mRowWeight );
|
||||
}
|
||||
|
||||
void UIGridLayout::loadFromXmlNode(const pugi::xml_node & node) {
|
||||
beginPropertiesTransaction();
|
||||
void UIGridLayout::setAttribute( const NodeAttribute &attribute ) {
|
||||
const std::string& name = attribute.getName();
|
||||
|
||||
UIWidget::loadFromXmlNode( node );
|
||||
|
||||
for (pugi::xml_attribute_iterator ait = node.attributes_begin(); ait != node.attributes_end(); ++ait) {
|
||||
std::string name = ait->name();
|
||||
String::toLowerInPlace( name );
|
||||
|
||||
if ( "columnspan" == name ) {
|
||||
setSpan( Sizei( ait->as_int(), mSpan.y ) );
|
||||
} else if ( "rowspan" == name ) {
|
||||
setSpan( Sizei( mSpan.x, ait->as_int() ) );
|
||||
} else if ( "span" == name ) {
|
||||
setSpan( Sizei( ait->as_int(), ait->as_int() ) );
|
||||
} else if ( "columnmode" == name ) {
|
||||
std::string val( ait->as_string() );
|
||||
String::toLowerInPlace( val );
|
||||
setColumnMode( "size" == val ? Size : Weight );
|
||||
} else if ( "rowmode" == name ) {
|
||||
std::string val( ait->as_string() );
|
||||
String::toLowerInPlace( val );
|
||||
setRowMode( "size" == val ? Size : Weight );
|
||||
} else if ( "columnweight" == name ) {
|
||||
setColumnWeight( ait->as_float() );
|
||||
} else if ( "columnwidth" == name ) {
|
||||
setColumnWidth( ait->as_int() );
|
||||
} else if ( "rowweight" == name ) {
|
||||
setRowWeight( ait->as_float() );
|
||||
} else if ( "rowheight" == name ) {
|
||||
setRowHeight( ait->as_int() );
|
||||
} else if ( "padding" == name ) {
|
||||
int val = PixelDensity::toDpFromStringI( ait->as_string() );
|
||||
setPadding( Rect( val, val, val, val ) );
|
||||
} else if ( "paddingleft" == name ) {
|
||||
setPadding( Rect( PixelDensity::toDpFromStringI( ait->as_string() ), mPadding.Top, mPadding.Right, mPadding.Bottom ) );
|
||||
} else if ( "paddingright" == name ) {
|
||||
setPadding( Rect( mPadding.Left, mPadding.Top, PixelDensity::toDpFromStringI( ait->as_string() ), mPadding.Bottom ) );
|
||||
} else if ( "paddingtop" == name ) {
|
||||
setPadding( Rect( mPadding.Left, PixelDensity::toDpFromStringI( ait->as_string() ), mPadding.Right, mPadding.Bottom ) );
|
||||
} else if ( "paddingbottom" == name ) {
|
||||
setPadding( Rect( mPadding.Left, mPadding.Top, mPadding.Right, PixelDensity::toDpFromStringI( ait->as_string() ) ) );
|
||||
} else if ( "reversedraw" == name ) {
|
||||
setReverseDraw( ait->as_bool() );
|
||||
}
|
||||
if ( "columnspan" == name ) {
|
||||
setSpan( Sizei( attribute.asInt(), mSpan.y ) );
|
||||
} else if ( "rowspan" == name ) {
|
||||
setSpan( Sizei( mSpan.x, attribute.asInt() ) );
|
||||
} else if ( "span" == name ) {
|
||||
setSpan( Sizei( attribute.asInt(), attribute.asInt() ) );
|
||||
} else if ( "columnmode" == name ) {
|
||||
std::string val( attribute.asString() );
|
||||
String::toLowerInPlace( val );
|
||||
setColumnMode( "size" == val ? Size : Weight );
|
||||
} else if ( "rowmode" == name ) {
|
||||
std::string val( attribute.asString() );
|
||||
String::toLowerInPlace( val );
|
||||
setRowMode( "size" == val ? Size : Weight );
|
||||
} else if ( "columnweight" == name ) {
|
||||
setColumnWeight( attribute.asFloat() );
|
||||
} else if ( "columnwidth" == name ) {
|
||||
setColumnWidth( attribute.asInt() );
|
||||
} else if ( "rowweight" == name ) {
|
||||
setRowWeight( attribute.asFloat() );
|
||||
} else if ( "rowheight" == name ) {
|
||||
setRowHeight( attribute.asInt() );
|
||||
} else if ( "padding" == name ) {
|
||||
int val = PixelDensity::toDpFromStringI( attribute.asString() );
|
||||
setPadding( Rect( val, val, val, val ) );
|
||||
} else if ( "paddingleft" == name ) {
|
||||
setPadding( Rect( PixelDensity::toDpFromStringI( attribute.asString() ), mPadding.Top, mPadding.Right, mPadding.Bottom ) );
|
||||
} else if ( "paddingright" == name ) {
|
||||
setPadding( Rect( mPadding.Left, mPadding.Top, PixelDensity::toDpFromStringI( attribute.asString() ), mPadding.Bottom ) );
|
||||
} else if ( "paddingtop" == name ) {
|
||||
setPadding( Rect( mPadding.Left, PixelDensity::toDpFromStringI( attribute.asString() ), mPadding.Right, mPadding.Bottom ) );
|
||||
} else if ( "paddingbottom" == name ) {
|
||||
setPadding( Rect( mPadding.Left, mPadding.Top, mPadding.Right, PixelDensity::toDpFromStringI( attribute.asString() ) ) );
|
||||
} else if ( "reversedraw" == name ) {
|
||||
setReverseDraw( attribute.asBool() );
|
||||
} else {
|
||||
UILayout::setAttribute( attribute );
|
||||
}
|
||||
|
||||
endPropertiesTransaction();
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
+23
-30
@@ -175,41 +175,34 @@ const Vector2f& UIImage::getAlignOffset() const {
|
||||
return mAlignOffset;
|
||||
}
|
||||
|
||||
void UIImage::loadFromXmlNode(const pugi::xml_node & node) {
|
||||
beginPropertiesTransaction();
|
||||
void UIImage::setAttribute( const NodeAttribute& attribute ) {
|
||||
const std::string& name = attribute.getName();
|
||||
|
||||
UIWidget::loadFromXmlNode( node );
|
||||
if ( "src" == name ) {
|
||||
Drawable * res = NULL;
|
||||
|
||||
for (pugi::xml_attribute_iterator ait = node.attributes_begin(); ait != node.attributes_end(); ++ait) {
|
||||
std::string name = ait->name();
|
||||
String::toLowerInPlace( name );
|
||||
if ( NULL != ( res = DrawableSearcher::searchByName( attribute.asString() ) ) ) {
|
||||
if ( res->getDrawableType() == Drawable::SPRITE )
|
||||
mDrawableOwner = true;
|
||||
|
||||
if ( "src" == name ) {
|
||||
Drawable * res = NULL;
|
||||
|
||||
if ( NULL != ( res = DrawableSearcher::searchByName( ait->as_string() ) ) ) {
|
||||
if ( res->getDrawableType() == Drawable::SPRITE )
|
||||
mDrawableOwner = true;
|
||||
|
||||
setDrawable( res );
|
||||
}
|
||||
} else if ( "scaletype" == name ) {
|
||||
std::string val = ait->as_string();
|
||||
String::toLowerInPlace( val );
|
||||
|
||||
if ( "expand" == val ) {
|
||||
setScaleType( UIScaleType::Expand );
|
||||
} else if ( "fit_inside" == val || "fitinside" == val ) {
|
||||
setScaleType( UIScaleType::FitInside );
|
||||
} else if ( "none" == val ) {
|
||||
setScaleType( UIScaleType::None );
|
||||
}
|
||||
} else if ( "tint" == name ) {
|
||||
setColor( Color::fromString( ait->as_string() ) );
|
||||
setDrawable( res );
|
||||
}
|
||||
}
|
||||
} else if ( "scaletype" == name ) {
|
||||
std::string val = attribute.asString();
|
||||
String::toLowerInPlace( val );
|
||||
|
||||
endPropertiesTransaction();
|
||||
if ( "expand" == val ) {
|
||||
setScaleType( UIScaleType::Expand );
|
||||
} else if ( "fit_inside" == val || "fitinside" == val ) {
|
||||
setScaleType( UIScaleType::FitInside );
|
||||
} else if ( "none" == val ) {
|
||||
setScaleType( UIScaleType::None );
|
||||
}
|
||||
} else if ( "tint" == name ) {
|
||||
setColor( Color::fromString( attribute.asString() ) );
|
||||
} else {
|
||||
UIWidget::setAttribute( attribute );
|
||||
}
|
||||
}
|
||||
|
||||
Uint32 UIImage::getScaleType() const {
|
||||
|
||||
@@ -328,27 +328,20 @@ Sizei UILinearLayout::getTotalUsedSize() {
|
||||
return size;
|
||||
}
|
||||
|
||||
void UILinearLayout::loadFromXmlNode(const pugi::xml_node & node) {
|
||||
beginPropertiesTransaction();
|
||||
void UILinearLayout::setAttribute( const NodeAttribute& attribute ) {
|
||||
const std::string& name = attribute.getName();
|
||||
|
||||
UIWidget::loadFromXmlNode( node );
|
||||
if ( "orientation" == name ) {
|
||||
std::string val = attribute.asString();
|
||||
String::toLowerInPlace( val );
|
||||
|
||||
for (pugi::xml_attribute_iterator ait = node.attributes_begin(); ait != node.attributes_end(); ++ait) {
|
||||
std::string name = ait->name();
|
||||
String::toLowerInPlace( name );
|
||||
|
||||
if ( "orientation" == name ) {
|
||||
std::string val = ait->as_string();
|
||||
String::toLowerInPlace( val );
|
||||
|
||||
if ( "horizontal" == val )
|
||||
setOrientation( UI_HORIZONTAL );
|
||||
else if ( "vertical" == val )
|
||||
setOrientation( UI_VERTICAL );
|
||||
}
|
||||
if ( "horizontal" == val )
|
||||
setOrientation( UI_HORIZONTAL );
|
||||
else if ( "vertical" == val )
|
||||
setOrientation( UI_VERTICAL );
|
||||
} else {
|
||||
UILayout::setAttribute( attribute );
|
||||
}
|
||||
|
||||
endPropertiesTransaction();
|
||||
}
|
||||
|
||||
Uint32 UILinearLayout::onMessage(const NodeMessage * Msg) {
|
||||
|
||||
+63
-62
@@ -985,8 +985,69 @@ void UIListBox::setFontStyleConfig(const UIFontStyleConfig & fontStyleConfig) {
|
||||
setFontColor( mFontStyleConfig.FontColor );
|
||||
}
|
||||
|
||||
void UIListBox::setAttribute( const NodeAttribute& attribute ) {
|
||||
const std::string& name = attribute.getName();
|
||||
|
||||
if ( "rowheight" == name ) {
|
||||
setRowHeight( attribute.asInt() );
|
||||
} else if ( "textcolor" == name ) {
|
||||
setFontColor( Color::fromString( attribute.asString() ) );
|
||||
} else if ( "textshadowcolor" == name ) {
|
||||
mFontStyleConfig.ShadowColor = ( Color::fromString( attribute.asString() ) );
|
||||
} else if ( "textovercolor" == name ) {
|
||||
setFontOverColor( Color::fromString( attribute.asString() ) );
|
||||
} else if ( "textselectedcolor" == name ) {
|
||||
setFontSelectedColor( Color::fromString( attribute.asString() ) );
|
||||
} else if ( "textselectionbackcolor" == name ) {
|
||||
mFontStyleConfig.FontSelectionBackColor = ( Color::fromString( attribute.asString() ) );
|
||||
} else if ( "fontfamily" == name || "fontname" == name ) {
|
||||
Font * font = FontManager::instance()->getByName( attribute.asString() );
|
||||
|
||||
if ( NULL != font )
|
||||
setFont( font );
|
||||
} else if ( "padding" == name ) {
|
||||
int val = attribute.asInt();
|
||||
setContainerPadding( Rectf( val, val, val, val ) );
|
||||
} else if ( "paddingleft" == name ) {
|
||||
setContainerPadding( Rectf( attribute.asInt(), mContainerPadding.Top, mContainerPadding.Right, mContainerPadding.Bottom ) );
|
||||
} else if ( "paddingright" == name ) {
|
||||
setContainerPadding( Rectf( mContainerPadding.Left, mContainerPadding.Top, attribute.asInt(), mContainerPadding.Bottom ) );
|
||||
} else if ( "paddingtop" == name ) {
|
||||
setContainerPadding( Rectf( mContainerPadding.Left, attribute.asInt(), mContainerPadding.Right, mContainerPadding.Bottom ) );
|
||||
} else if ( "paddingbottom" == name ) {
|
||||
setContainerPadding( Rectf( mContainerPadding.Left, mContainerPadding.Top, mContainerPadding.Right, attribute.asInt() ) );
|
||||
} else if ( "verticalscrollmode" == name || "vscrollmode" == name ) {
|
||||
std::string val = attribute.asString();
|
||||
if ( "auto" == val ) setVerticalScrollMode( UI_SCROLLBAR_AUTO );
|
||||
else if ( "on" == val ) setVerticalScrollMode( UI_SCROLLBAR_ALWAYS_ON );
|
||||
else if ( "off" == val ) setVerticalScrollMode( UI_SCROLLBAR_ALWAYS_OFF );
|
||||
} else if ( "horizontalscrollmode" == name || "hscrollmode" == name ) {
|
||||
std::string val = attribute.asString();
|
||||
if ( "auto" == val ) setHorizontalScrollMode( UI_SCROLLBAR_AUTO );
|
||||
else if ( "on" == val ) setHorizontalScrollMode( UI_SCROLLBAR_ALWAYS_ON );
|
||||
else if ( "off" == val ) setHorizontalScrollMode( UI_SCROLLBAR_ALWAYS_OFF );
|
||||
} else if ( "selectedindex" == name ) {
|
||||
setSelected( attribute.asUint() );
|
||||
} else if ( "selectedtext" == name ) {
|
||||
setSelected( attribute.asString() );
|
||||
} else if ( "scrollbartype" == name ) {
|
||||
std::string val( attribute.asString() );
|
||||
String::toLowerInPlace( val );
|
||||
|
||||
if ( "nobuttons" == val ) {
|
||||
mVScrollBar->setScrollBarType( UIScrollBar::NoButtons );
|
||||
mHScrollBar->setScrollBarType( UIScrollBar::NoButtons );
|
||||
} else if ( "twobuttons" == val ) {
|
||||
mVScrollBar->setScrollBarType( UIScrollBar::TwoButtons );
|
||||
mHScrollBar->setScrollBarType( UIScrollBar::NoButtons );
|
||||
}
|
||||
} else {
|
||||
UITouchDragableWidget::setAttribute( attribute );
|
||||
}
|
||||
}
|
||||
|
||||
void UIListBox::loadFromXmlNode(const pugi::xml_node & node) {
|
||||
beginPropertiesTransaction();
|
||||
beginAttributesTransaction();
|
||||
|
||||
UITouchDragableWidget::loadFromXmlNode( node );
|
||||
|
||||
@@ -1004,67 +1065,7 @@ void UIListBox::loadFromXmlNode(const pugi::xml_node & node) {
|
||||
addListBoxItems( items );
|
||||
}
|
||||
|
||||
for (pugi::xml_attribute_iterator ait = node.attributes_begin(); ait != node.attributes_end(); ++ait) {
|
||||
std::string name = ait->name();
|
||||
String::toLowerInPlace( name );
|
||||
|
||||
if ( "rowheight" == name ) {
|
||||
setRowHeight( ait->as_int() );
|
||||
} else if ( "textcolor" == name ) {
|
||||
setFontColor( Color::fromString( ait->as_string() ) );
|
||||
} else if ( "textshadowcolor" == name ) {
|
||||
mFontStyleConfig.ShadowColor = ( Color::fromString( ait->as_string() ) );
|
||||
} else if ( "textovercolor" == name ) {
|
||||
setFontOverColor( Color::fromString( ait->as_string() ) );
|
||||
} else if ( "textselectedcolor" == name ) {
|
||||
setFontSelectedColor( Color::fromString( ait->as_string() ) );
|
||||
} else if ( "textselectionbackcolor" == name ) {
|
||||
mFontStyleConfig.FontSelectionBackColor = ( Color::fromString( ait->as_string() ) );
|
||||
} else if ( "fontfamily" == name || "fontname" == name ) {
|
||||
Font * font = FontManager::instance()->getByName( ait->as_string() );
|
||||
|
||||
if ( NULL != font )
|
||||
setFont( font );
|
||||
} else if ( "padding" == name ) {
|
||||
int val = ait->as_int();
|
||||
setContainerPadding( Rectf( val, val, val, val ) );
|
||||
} else if ( "paddingleft" == name ) {
|
||||
setContainerPadding( Rectf( ait->as_int(), mContainerPadding.Top, mContainerPadding.Right, mContainerPadding.Bottom ) );
|
||||
} else if ( "paddingright" == name ) {
|
||||
setContainerPadding( Rectf( mContainerPadding.Left, mContainerPadding.Top, ait->as_int(), mContainerPadding.Bottom ) );
|
||||
} else if ( "paddingtop" == name ) {
|
||||
setContainerPadding( Rectf( mContainerPadding.Left, ait->as_int(), mContainerPadding.Right, mContainerPadding.Bottom ) );
|
||||
} else if ( "paddingbottom" == name ) {
|
||||
setContainerPadding( Rectf( mContainerPadding.Left, mContainerPadding.Top, mContainerPadding.Right, ait->as_int() ) );
|
||||
} else if ( "verticalscrollmode" == name || "vscrollmode" == name ) {
|
||||
std::string val = ait->as_string();
|
||||
if ( "auto" == val ) setVerticalScrollMode( UI_SCROLLBAR_AUTO );
|
||||
else if ( "on" == val ) setVerticalScrollMode( UI_SCROLLBAR_ALWAYS_ON );
|
||||
else if ( "off" == val ) setVerticalScrollMode( UI_SCROLLBAR_ALWAYS_OFF );
|
||||
} else if ( "horizontalscrollmode" == name || "hscrollmode" == name ) {
|
||||
std::string val = ait->as_string();
|
||||
if ( "auto" == val ) setHorizontalScrollMode( UI_SCROLLBAR_AUTO );
|
||||
else if ( "on" == val ) setHorizontalScrollMode( UI_SCROLLBAR_ALWAYS_ON );
|
||||
else if ( "off" == val ) setHorizontalScrollMode( UI_SCROLLBAR_ALWAYS_OFF );
|
||||
} else if ( "selectedindex" == name ) {
|
||||
setSelected( ait->as_uint() );
|
||||
} else if ( "selectedtext" == name ) {
|
||||
setSelected( ait->as_string() );
|
||||
} else if ( "scrollbartype" == name ) {
|
||||
std::string val( ait->as_string() );
|
||||
String::toLowerInPlace( val );
|
||||
|
||||
if ( "nobuttons" == val ) {
|
||||
mVScrollBar->setScrollBarType( UIScrollBar::NoButtons );
|
||||
mHScrollBar->setScrollBarType( UIScrollBar::NoButtons );
|
||||
} else if ( "twobuttons" == val ) {
|
||||
mVScrollBar->setScrollBarType( UIScrollBar::TwoButtons );
|
||||
mHScrollBar->setScrollBarType( UIScrollBar::NoButtons );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
endPropertiesTransaction();
|
||||
endAttributesTransaction();
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
+24
-31
@@ -154,6 +154,30 @@ UILoader * UILoader::setAnimationSpeed( const Float& animationSpeed ) {
|
||||
return this;
|
||||
}
|
||||
|
||||
void UILoader::setAttribute( const NodeAttribute& attribute ) {
|
||||
std::string name = attribute.getName();
|
||||
|
||||
if ( "indeterminate" == name ) {
|
||||
setIndeterminate( attribute.asBool() );
|
||||
} else if ( "maxprogress" == name ) {
|
||||
setMaxProgress( attribute.asFloat() );
|
||||
} else if ( "progress" == name ) {
|
||||
setProgress( attribute.asFloat() );
|
||||
} else if ( "fillcolor" == name ) {
|
||||
setFillColor( Color::fromString( attribute.asString() ) );
|
||||
} else if ( "radius" == name ) {
|
||||
setRadius( attribute.asFloat() );
|
||||
} else if ( "outlinethickness" == name ) {
|
||||
setOutlineThickness( attribute.asFloat() );
|
||||
} else if ( "animationspeed" == name ) {
|
||||
setAnimationSpeed( attribute.asFloat() );
|
||||
} else if ( "arcstartangle" == name ) {
|
||||
setArcStartAngle( attribute.asFloat() );
|
||||
} else {
|
||||
UIWidget::setAttribute( attribute );
|
||||
}
|
||||
}
|
||||
|
||||
Float UILoader::getArcStartAngle() const {
|
||||
return mArcStartAngle;
|
||||
}
|
||||
@@ -163,35 +187,4 @@ UILoader * UILoader::setArcStartAngle( const Float& arcStartAngle ) {
|
||||
return this;
|
||||
}
|
||||
|
||||
void UILoader::loadFromXmlNode(const pugi::xml_node & node) {
|
||||
beginPropertiesTransaction();
|
||||
|
||||
UIWidget::loadFromXmlNode( node );
|
||||
|
||||
for (pugi::xml_attribute_iterator ait = node.attributes_begin(); ait != node.attributes_end(); ++ait) {
|
||||
std::string name = ait->name();
|
||||
String::toLowerInPlace( name );
|
||||
|
||||
if ( "indeterminate" == name ) {
|
||||
setIndeterminate( ait->as_bool() );
|
||||
} else if ( "maxprogress" == name ) {
|
||||
setMaxProgress( ait->as_float() );
|
||||
} else if ( "progress" == name ) {
|
||||
setProgress( ait->as_float() );
|
||||
} else if ( "fillcolor" == name ) {
|
||||
setFillColor( Color::fromString( ait->as_string() ) );
|
||||
} else if ( "radius" == name ) {
|
||||
setRadius( ait->as_float() );
|
||||
} else if ( "outlinethickness" == name ) {
|
||||
setOutlineThickness( ait->as_float() );
|
||||
} else if ( "animationspeed" == name ) {
|
||||
setAnimationSpeed( ait->as_float() );
|
||||
} else if ( "arcstartangle" == name ) {
|
||||
setArcStartAngle( ait->as_float() );
|
||||
}
|
||||
}
|
||||
|
||||
endPropertiesTransaction();
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
@@ -552,7 +552,7 @@ static Drawable * getIconDrawable( const std::string& name ) {
|
||||
}
|
||||
|
||||
void UIMenu::loadFromXmlNode( const pugi::xml_node& node ) {
|
||||
beginPropertiesTransaction();
|
||||
beginAttributesTransaction();
|
||||
|
||||
UIWidget::loadFromXmlNode( node );
|
||||
|
||||
@@ -590,7 +590,7 @@ void UIMenu::loadFromXmlNode( const pugi::xml_node& node ) {
|
||||
}
|
||||
}
|
||||
|
||||
endPropertiesTransaction();
|
||||
endAttributesTransaction();
|
||||
}
|
||||
|
||||
void UIMenu::fixMenuPos( Vector2f& Pos, UIMenu * Menu, UIMenu * Parent, UIMenuSubMenu * SubMenu ) {
|
||||
|
||||
@@ -213,38 +213,31 @@ UITextView * UIProgressBar::getTextBox() const {
|
||||
return mTextBox;
|
||||
}
|
||||
|
||||
void UIProgressBar::loadFromXmlNode(const pugi::xml_node & node) {
|
||||
beginPropertiesTransaction();
|
||||
void UIProgressBar::setAttribute( const NodeAttribute& attribute ) {
|
||||
const std::string& name = attribute.getName();
|
||||
|
||||
UIWidget::loadFromXmlNode( node );
|
||||
|
||||
for (pugi::xml_attribute_iterator ait = node.attributes_begin(); ait != node.attributes_end(); ++ait) {
|
||||
std::string name = ait->name();
|
||||
String::toLowerInPlace( name );
|
||||
|
||||
if ( "totalsteps" == name ) {
|
||||
setTotalSteps( ait->as_float() );
|
||||
} else if ( "progress" == name ) {
|
||||
setProgress( ait->as_float() );
|
||||
} else if ( "verticalexpand" == name ) {
|
||||
setVerticalExpand( ait->as_bool() );
|
||||
} else if ( "displaypercent" == name ) {
|
||||
setDisplayPercent( ait->as_bool() );
|
||||
} else if ( "fillerpadding" == name ) {
|
||||
Float val = PixelDensity::toDpFromString( ait->as_string() );
|
||||
setFillerPadding( Rectf( val, val, val, val ) );
|
||||
} else if ( "fillerpaddingleft" == name ) {
|
||||
setFillerPadding( Rectf( PixelDensity::toDpFromString( ait->as_string() ), mStyleConfig.FillerPadding.Top, mStyleConfig.FillerPadding.Right, mStyleConfig.FillerPadding.Bottom ) );
|
||||
} else if ( "fillerpaddingright" == name ) {
|
||||
setFillerPadding( Rectf( mStyleConfig.FillerPadding.Left, mStyleConfig.FillerPadding.Top, PixelDensity::toDpFromString( ait->as_string() ), mStyleConfig.FillerPadding.Bottom ) );
|
||||
} else if ( "fillerpaddingtop" == name ) {
|
||||
setFillerPadding( Rectf( mStyleConfig.FillerPadding.Left, PixelDensity::toDpFromString( ait->as_string() ), mStyleConfig.FillerPadding.Right, mStyleConfig.FillerPadding.Bottom ) );
|
||||
} else if ( "fillerpaddingbottom" == name ) {
|
||||
setFillerPadding( Rectf( mStyleConfig.FillerPadding.Left, mStyleConfig.FillerPadding.Top, mStyleConfig.FillerPadding.Right, PixelDensity::toDpFromString( ait->as_string() ) ) );
|
||||
}
|
||||
if ( "totalsteps" == name ) {
|
||||
setTotalSteps( attribute.asFloat() );
|
||||
} else if ( "progress" == name ) {
|
||||
setProgress( attribute.asFloat() );
|
||||
} else if ( "verticalexpand" == name ) {
|
||||
setVerticalExpand( attribute.asBool() );
|
||||
} else if ( "displaypercent" == name ) {
|
||||
setDisplayPercent( attribute.asBool() );
|
||||
} else if ( "fillerpadding" == name ) {
|
||||
Float val = PixelDensity::toDpFromString( attribute.asString() );
|
||||
setFillerPadding( Rectf( val, val, val, val ) );
|
||||
} else if ( "fillerpaddingleft" == name ) {
|
||||
setFillerPadding( Rectf( PixelDensity::toDpFromString( attribute.asString() ), mStyleConfig.FillerPadding.Top, mStyleConfig.FillerPadding.Right, mStyleConfig.FillerPadding.Bottom ) );
|
||||
} else if ( "fillerpaddingright" == name ) {
|
||||
setFillerPadding( Rectf( mStyleConfig.FillerPadding.Left, mStyleConfig.FillerPadding.Top, PixelDensity::toDpFromString( attribute.asString() ), mStyleConfig.FillerPadding.Bottom ) );
|
||||
} else if ( "fillerpaddingtop" == name ) {
|
||||
setFillerPadding( Rectf( mStyleConfig.FillerPadding.Left, PixelDensity::toDpFromString( attribute.asString() ), mStyleConfig.FillerPadding.Right, mStyleConfig.FillerPadding.Bottom ) );
|
||||
} else if ( "fillerpaddingbottom" == name ) {
|
||||
setFillerPadding( Rectf( mStyleConfig.FillerPadding.Left, mStyleConfig.FillerPadding.Top, mStyleConfig.FillerPadding.Right, PixelDensity::toDpFromString( attribute.asString() ) ) );
|
||||
} else {
|
||||
UIWidget::setAttribute( attribute );
|
||||
}
|
||||
|
||||
endPropertiesTransaction();
|
||||
}
|
||||
|
||||
void UIProgressBar::onAlphaChange() {
|
||||
|
||||
@@ -344,36 +344,29 @@ void UIPushButton::setStyleConfig(const UIPushButtonStyleConfig & styleConfig) {
|
||||
onStateChange();
|
||||
}
|
||||
|
||||
void UIPushButton::loadFromXmlNode(const pugi::xml_node & node) {
|
||||
beginPropertiesTransaction();
|
||||
void UIPushButton::setAttribute( const NodeAttribute& attribute ) {
|
||||
const std::string& name = attribute.getName();
|
||||
|
||||
UIWidget::loadFromXmlNode( node );
|
||||
if ( "text" == name ) {
|
||||
if ( NULL != mSceneNode && mSceneNode->isUISceneNode() )
|
||||
setText( static_cast<UISceneNode*>( mSceneNode )->getTranslatorString( attribute.asString() ) );
|
||||
} else if ( "textovercolor" == name ) {
|
||||
setFontOverColor( Color::fromString( attribute.asString() ) );
|
||||
} else if ( "icon" == name ) {
|
||||
std::string val = attribute.asString();
|
||||
Drawable * icon = NULL;
|
||||
|
||||
mTextBox->loadFromXmlNode( node );
|
||||
mTextBox->setLayoutSizeRules( FIXED, FIXED );
|
||||
|
||||
for (pugi::xml_attribute_iterator ait = node.attributes_begin(); ait != node.attributes_end(); ++ait) {
|
||||
std::string name = ait->name();
|
||||
String::toLowerInPlace( name );
|
||||
|
||||
if ( "text" == name ) {
|
||||
if ( NULL != mSceneNode )
|
||||
setText( static_cast<UISceneNode*>( mSceneNode )->getTranslatorString( ait->as_string() ) );
|
||||
} else if ( "textovercolor" == name ) {
|
||||
setFontOverColor( Color::fromString( ait->as_string() ) );
|
||||
} else if ( "icon" == name ) {
|
||||
std::string val = ait->as_string();
|
||||
Drawable * icon = NULL;
|
||||
|
||||
if ( NULL != mTheme && NULL != ( icon = mTheme->getIconByName( val ) ) ) {
|
||||
setIcon( icon );
|
||||
} else if ( NULL != ( icon = GlobalTextureAtlas::instance()->getByName( val ) ) ) {
|
||||
setIcon( icon );
|
||||
}
|
||||
if ( NULL != mTheme && NULL != ( icon = mTheme->getIconByName( val ) ) ) {
|
||||
setIcon( icon );
|
||||
} else if ( NULL != ( icon = GlobalTextureAtlas::instance()->getByName( val ) ) ) {
|
||||
setIcon( icon );
|
||||
}
|
||||
} else {
|
||||
UIWidget::setAttribute( attribute );
|
||||
}
|
||||
|
||||
endPropertiesTransaction();
|
||||
mTextBox->setAttribute( attribute );
|
||||
mTextBox->setLayoutSizeRules( FIXED, FIXED );
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
@@ -229,21 +229,14 @@ void UIRadioButton::setTextSeparation(const Int32 & textSeparation) {
|
||||
setPadding( getPadding() );
|
||||
}
|
||||
|
||||
void UIRadioButton::loadFromXmlNode(const pugi::xml_node & node) {
|
||||
beginPropertiesTransaction();
|
||||
void UIRadioButton::setAttribute( const NodeAttribute& attribute ) {
|
||||
const std::string& name = attribute.getName();
|
||||
|
||||
UITextView::loadFromXmlNode( node );
|
||||
|
||||
for (pugi::xml_attribute_iterator ait = node.attributes_begin(); ait != node.attributes_end(); ++ait) {
|
||||
std::string name = ait->name();
|
||||
String::toLowerInPlace( name );
|
||||
|
||||
if ( "selected" == name || "active" == name ) {
|
||||
setActive( ait->as_bool() );
|
||||
}
|
||||
if ( "selected" == name || "active" == name ) {
|
||||
setActive( attribute.asBool() );
|
||||
} else {
|
||||
UITextView::setAttribute( attribute );
|
||||
}
|
||||
|
||||
endPropertiesTransaction();
|
||||
}
|
||||
|
||||
Uint32 UIRadioButton::onKeyDown( const KeyEvent& Event ) {
|
||||
|
||||
@@ -282,14 +282,10 @@ void UIScrollBar::setExpandBackground( bool expandBackground ) {
|
||||
adjustChilds();
|
||||
}
|
||||
|
||||
void UIScrollBar::loadFromXmlNode(const pugi::xml_node & node) {
|
||||
beginPropertiesTransaction();
|
||||
void UIScrollBar::setAttribute(const NodeAttribute & attribute) {
|
||||
UIScrollBar::setAttribute( attribute );
|
||||
|
||||
UIWidget::loadFromXmlNode( node );
|
||||
|
||||
mSlider->loadFromXmlNode( node );
|
||||
|
||||
endPropertiesTransaction();
|
||||
mSlider->setAttribute( attribute );
|
||||
}
|
||||
|
||||
UIScrollBar::ScrollBarType UIScrollBar::getScrollBarType() const {
|
||||
|
||||
@@ -222,50 +222,43 @@ bool UIScrollView::isTouchOverAllowedChilds() {
|
||||
return isMouseOverMeOrChilds() && mScrollView->isMouseOverMeOrChilds() && ret;
|
||||
}
|
||||
|
||||
void UIScrollView::loadFromXmlNode( const pugi::xml_node& node ) {
|
||||
beginPropertiesTransaction();
|
||||
void UIScrollView::setAttribute( const NodeAttribute& attribute ) {
|
||||
const std::string& name = attribute.getName();
|
||||
|
||||
UITouchDragableWidget::loadFromXmlNode( node );
|
||||
if ( "type" == name ) {
|
||||
std::string val( attribute.asString() );
|
||||
String::toLowerInPlace( val );
|
||||
|
||||
for (pugi::xml_attribute_iterator ait = node.attributes_begin(); ait != node.attributes_end(); ++ait) {
|
||||
std::string name = ait->name();
|
||||
String::toLowerInPlace( name );
|
||||
if ( "inclusive" == val ) setViewType( Inclusive );
|
||||
else if ( "exclusive" == val ) setViewType( Exclusive );
|
||||
} else if ( "vscroll_mode" == name ) {
|
||||
std::string val( attribute.asString() );
|
||||
String::toLowerInPlace( val );
|
||||
|
||||
if ( "type" == name ) {
|
||||
std::string val( ait->as_string() );
|
||||
String::toLowerInPlace( val );
|
||||
if ( "on" == val ) setVerticalScrollMode( UI_SCROLLBAR_ALWAYS_ON );
|
||||
else if ( "off" == val ) setVerticalScrollMode( UI_SCROLLBAR_ALWAYS_ON );
|
||||
else if ( "auto" == val ) setVerticalScrollMode( UI_SCROLLBAR_AUTO );
|
||||
} else if ( "hscroll_mode" == name ) {
|
||||
std::string val( attribute.asString() );
|
||||
String::toLowerInPlace( val );
|
||||
|
||||
if ( "inclusive" == val ) setViewType( Inclusive );
|
||||
else if ( "exclusive" == val ) setViewType( Exclusive );
|
||||
} else if ( "vscroll_mode" == name ) {
|
||||
std::string val( ait->as_string() );
|
||||
String::toLowerInPlace( val );
|
||||
if ( "on" == val ) setHorizontalScrollMode( UI_SCROLLBAR_ALWAYS_ON );
|
||||
else if ( "off" == val ) setHorizontalScrollMode( UI_SCROLLBAR_ALWAYS_ON );
|
||||
else if ( "auto" == val ) setHorizontalScrollMode( UI_SCROLLBAR_AUTO );
|
||||
} else if ( "scrollbartype" == name ) {
|
||||
std::string val( attribute.asString() );
|
||||
String::toLowerInPlace( val );
|
||||
|
||||
if ( "on" == val ) setVerticalScrollMode( UI_SCROLLBAR_ALWAYS_ON );
|
||||
else if ( "off" == val ) setVerticalScrollMode( UI_SCROLLBAR_ALWAYS_ON );
|
||||
else if ( "auto" == val ) setVerticalScrollMode( UI_SCROLLBAR_AUTO );
|
||||
} else if ( "hscroll_mode" == name ) {
|
||||
std::string val( ait->as_string() );
|
||||
String::toLowerInPlace( val );
|
||||
|
||||
if ( "on" == val ) setHorizontalScrollMode( UI_SCROLLBAR_ALWAYS_ON );
|
||||
else if ( "off" == val ) setHorizontalScrollMode( UI_SCROLLBAR_ALWAYS_ON );
|
||||
else if ( "auto" == val ) setHorizontalScrollMode( UI_SCROLLBAR_AUTO );
|
||||
} else if ( "scrollbartype" == name ) {
|
||||
std::string val( ait->as_string() );
|
||||
String::toLowerInPlace( val );
|
||||
|
||||
if ( "nobuttons" == val ) {
|
||||
mVScroll->setScrollBarType( UIScrollBar::NoButtons );
|
||||
mHScroll->setScrollBarType( UIScrollBar::NoButtons );
|
||||
} else if ( "twobuttons" == val ) {
|
||||
mVScroll->setScrollBarType( UIScrollBar::TwoButtons );
|
||||
mHScroll->setScrollBarType( UIScrollBar::NoButtons );
|
||||
}
|
||||
if ( "nobuttons" == val ) {
|
||||
mVScroll->setScrollBarType( UIScrollBar::NoButtons );
|
||||
mHScroll->setScrollBarType( UIScrollBar::NoButtons );
|
||||
} else if ( "twobuttons" == val ) {
|
||||
mVScroll->setScrollBarType( UIScrollBar::TwoButtons );
|
||||
mHScroll->setScrollBarType( UIScrollBar::NoButtons );
|
||||
}
|
||||
} else {
|
||||
UITouchDragableWidget::setAttribute( attribute );
|
||||
}
|
||||
|
||||
endPropertiesTransaction();
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
@@ -89,21 +89,14 @@ const Color &UISelectButton::getFontSelectedColor() const {
|
||||
return mStyleConfig.FontSelectedColor;
|
||||
}
|
||||
|
||||
void UISelectButton::loadFromXmlNode(const pugi::xml_node & node) {
|
||||
beginPropertiesTransaction();
|
||||
void UISelectButton::setAttribute( const NodeAttribute& attribute ) {
|
||||
const std::string& name = attribute.getName();
|
||||
|
||||
UIPushButton::loadFromXmlNode( node );
|
||||
|
||||
for (pugi::xml_attribute_iterator ait = node.attributes_begin(); ait != node.attributes_end(); ++ait) {
|
||||
std::string name = ait->name();
|
||||
String::toLowerInPlace( name );
|
||||
|
||||
if ( "textselectedcolor" == name ) {
|
||||
setFontSelectedColor( Color::fromString( ait->as_string() ) );
|
||||
}
|
||||
if ( "textselectedcolor" == name ) {
|
||||
setFontSelectedColor( Color::fromString( attribute.asString() ) );
|
||||
} else {
|
||||
UIPushButton::setAttribute( attribute );
|
||||
}
|
||||
|
||||
endPropertiesTransaction();
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
+21
-28
@@ -402,37 +402,30 @@ void UISlider::onAlphaChange() {
|
||||
mSlider->setAlpha( mAlpha );
|
||||
}
|
||||
|
||||
void UISlider::loadFromXmlNode(const pugi::xml_node & node) {
|
||||
beginPropertiesTransaction();
|
||||
void UISlider::setAttribute( const NodeAttribute& attribute ) {
|
||||
const std::string& name = attribute.getName();
|
||||
|
||||
UIWidget::loadFromXmlNode( node );
|
||||
if ( "orientation" == name ) {
|
||||
std::string val = attribute.asString();
|
||||
String::toLowerInPlace( val );
|
||||
|
||||
for (pugi::xml_attribute_iterator ait = node.attributes_begin(); ait != node.attributes_end(); ++ait) {
|
||||
std::string name = ait->name();
|
||||
String::toLowerInPlace( name );
|
||||
|
||||
if ( "orientation" == name ) {
|
||||
std::string val = ait->as_string();
|
||||
String::toLowerInPlace( val );
|
||||
|
||||
if ( "horizontal" == val )
|
||||
setOrientation( UI_HORIZONTAL );
|
||||
else if ( "vertical" == val )
|
||||
setOrientation( UI_VERTICAL );
|
||||
} else if ( "minvalue" == name ) {
|
||||
setMinValue( ait->as_float() );
|
||||
} else if ( "maxvalue" == name ) {
|
||||
setMaxValue( ait->as_float() );
|
||||
} else if ( "value" == name ) {
|
||||
setValue( ait->as_float() );
|
||||
} else if ( "clickstep" == name ) {
|
||||
setClickStep( ait->as_float() );
|
||||
} else if ( "pagestep" == name ) {
|
||||
setPageStep( ait->as_float() );
|
||||
}
|
||||
if ( "horizontal" == val )
|
||||
setOrientation( UI_HORIZONTAL );
|
||||
else if ( "vertical" == val )
|
||||
setOrientation( UI_VERTICAL );
|
||||
} else if ( "minvalue" == name ) {
|
||||
setMinValue( attribute.asFloat() );
|
||||
} else if ( "maxvalue" == name ) {
|
||||
setMaxValue( attribute.asFloat() );
|
||||
} else if ( "value" == name ) {
|
||||
setValue( attribute.asFloat() );
|
||||
} else if ( "clickstep" == name ) {
|
||||
setClickStep( attribute.asFloat() );
|
||||
} else if ( "pagestep" == name ) {
|
||||
setPageStep( attribute.asFloat() );
|
||||
} else {
|
||||
UIWidget::setAttribute( attribute );
|
||||
}
|
||||
|
||||
endPropertiesTransaction();
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
+13
-20
@@ -264,29 +264,22 @@ void UISpinBox::onAlphaChange() {
|
||||
mPushDown->setAlpha( mAlpha );
|
||||
}
|
||||
|
||||
void UISpinBox::loadFromXmlNode(const pugi::xml_node & node) {
|
||||
beginPropertiesTransaction();
|
||||
void UISpinBox::setAttribute( const NodeAttribute& attribute ) {
|
||||
const std::string& name = attribute.getName();
|
||||
|
||||
UIWidget::loadFromXmlNode( node );
|
||||
|
||||
mInput->loadFromXmlNode( node );
|
||||
|
||||
for (pugi::xml_attribute_iterator ait = node.attributes_begin(); ait != node.attributes_end(); ++ait) {
|
||||
std::string name = ait->name();
|
||||
String::toLowerInPlace( name );
|
||||
|
||||
if ( "minvalue" == name ) {
|
||||
setMinValue( ait->as_float() );
|
||||
} else if ( "maxvalue" == name ) {
|
||||
setMaxValue( ait->as_float() );
|
||||
} else if ( "value" == name ) {
|
||||
setValue( ait->as_float() );
|
||||
} else if ( "clickstep" == name ) {
|
||||
setClickStep( ait->as_float() );
|
||||
}
|
||||
if ( "minvalue" == name ) {
|
||||
setMinValue(attribute.asFloat() );
|
||||
} else if ( "maxvalue" == name ) {
|
||||
setMaxValue(attribute.asFloat() );
|
||||
} else if ( "value" == name ) {
|
||||
setValue(attribute.asFloat() );
|
||||
} else if ( "clickstep" == name ) {
|
||||
setClickStep(attribute.asFloat() );
|
||||
} else {
|
||||
UIWidget::setAttribute( attribute );
|
||||
}
|
||||
|
||||
endPropertiesTransaction();
|
||||
mInput->setAttribute( attribute );
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
@@ -175,26 +175,19 @@ void UISprite::onSizeChange() {
|
||||
UIWidget::onSizeChange();
|
||||
}
|
||||
|
||||
void UISprite::loadFromXmlNode(const pugi::xml_node & node) {
|
||||
beginPropertiesTransaction();
|
||||
void UISprite::setAttribute( const NodeAttribute& attribute ) {
|
||||
const std::string& name = attribute.getName();
|
||||
|
||||
UIWidget::loadFromXmlNode( node );
|
||||
if ( "src" == name ) {
|
||||
std::string val = attribute.asString();
|
||||
|
||||
for (pugi::xml_attribute_iterator ait = node.attributes_begin(); ait != node.attributes_end(); ++ait) {
|
||||
std::string name = ait->name();
|
||||
String::toLowerInPlace( name );
|
||||
|
||||
if ( "src" == name ) {
|
||||
std::string val = ait->as_string();
|
||||
|
||||
if ( val.size() ) {
|
||||
setDeallocSprite( true );
|
||||
setSprite( eeNew( Sprite, ( val ) ) );
|
||||
}
|
||||
if ( val.size() ) {
|
||||
setDeallocSprite( true );
|
||||
setSprite( eeNew( Sprite, ( val ) ) );
|
||||
}
|
||||
} else {
|
||||
UIWidget::setAttribute( attribute );
|
||||
}
|
||||
|
||||
endPropertiesTransaction();
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
+11
-16
@@ -1,5 +1,6 @@
|
||||
#include <eepp/ui/uitab.hpp>
|
||||
#include <eepp/ui/uitabwidget.hpp>
|
||||
#include <eepp/ui/uiscenenode.hpp>
|
||||
#include <pugixml/pugixml.hpp>
|
||||
|
||||
namespace EE { namespace UI {
|
||||
@@ -175,24 +176,18 @@ void UITab::update( const Time& time ) {
|
||||
}
|
||||
}
|
||||
|
||||
void UITab::loadFromXmlNode(const pugi::xml_node & node) {
|
||||
beginPropertiesTransaction();
|
||||
void UITab::setAttribute( const NodeAttribute& attribute ) {
|
||||
std::string name = attribute.getName();
|
||||
|
||||
UISelectButton::loadFromXmlNode( node );
|
||||
|
||||
for (pugi::xml_attribute_iterator ait = node.attributes_begin(); ait != node.attributes_end(); ++ait) {
|
||||
std::string name = ait->name();
|
||||
String::toLowerInPlace( name );
|
||||
|
||||
if ( "name" == name || "text" == name ) {
|
||||
setText( ait->as_string() );
|
||||
} else if ( "controlowned" == name || "owns" == name ) {
|
||||
mOwnedName = ait->as_string();
|
||||
setOwnedControl();
|
||||
}
|
||||
if ( "name" == name || "text" == name ) {
|
||||
if ( NULL != mSceneNode && mSceneNode->isUISceneNode() )
|
||||
setText( static_cast<UISceneNode*>( mSceneNode )->getTranslatorString( attribute.asString() ) );
|
||||
} else if ( "controlowned" == name || "owns" == name ) {
|
||||
mOwnedName = attribute.asString();
|
||||
setOwnedControl();
|
||||
} else {
|
||||
UISelectButton::setAttribute( attribute );
|
||||
}
|
||||
|
||||
endPropertiesTransaction();
|
||||
}
|
||||
|
||||
void UITab::setOwnedControl() {
|
||||
|
||||
+36
-43
@@ -618,53 +618,46 @@ bool UITable::isTouchOverAllowedChilds() {
|
||||
return isMouseOverMeOrChilds() && !mVScrollBar->isMouseOverMeOrChilds() && !mHScrollBar->isMouseOverMeOrChilds();
|
||||
}
|
||||
|
||||
void UITable::loadFromXmlNode(const pugi::xml_node & node) {
|
||||
beginPropertiesTransaction();
|
||||
void UITable::setAttribute( const NodeAttribute& attribute ) {
|
||||
const std::string& name = attribute.getName();
|
||||
|
||||
UITouchDragableWidget::loadFromXmlNode( node );
|
||||
if ( "rowheight" == name ) {
|
||||
setRowHeight( attribute.asInt() );
|
||||
} else if ( "padding" == name ) {
|
||||
int val = attribute.asInt();
|
||||
setContainerPadding( Rectf( val, val, val, val ) );
|
||||
} else if ( "paddingleft" == name ) {
|
||||
setContainerPadding( Rectf( attribute.asInt(), mContainerPadding.Top, mContainerPadding.Right, mContainerPadding.Bottom ) );
|
||||
} else if ( "paddingright" == name ) {
|
||||
setContainerPadding( Rectf( mContainerPadding.Left, mContainerPadding.Top, attribute.asInt(), mContainerPadding.Bottom ) );
|
||||
} else if ( "paddingtop" == name ) {
|
||||
setContainerPadding( Rectf( mContainerPadding.Left, attribute.asInt(), mContainerPadding.Right, mContainerPadding.Bottom ) );
|
||||
} else if ( "paddingbottom" == name ) {
|
||||
setContainerPadding( Rectf( mContainerPadding.Left, mContainerPadding.Top, mContainerPadding.Right, attribute.asInt() ) );
|
||||
} else if ( "verticalscrollmode" == name || "vscrollmode" == name ) {
|
||||
std::string val = attribute.asString();
|
||||
if ( "auto" == val ) setVerticalScrollMode( UI_SCROLLBAR_AUTO );
|
||||
else if ( "on" == val ) setVerticalScrollMode( UI_SCROLLBAR_ALWAYS_ON );
|
||||
else if ( "off" == val ) setVerticalScrollMode( UI_SCROLLBAR_ALWAYS_OFF );
|
||||
} else if ( "horizontalscrollmode" == name || "hscrollmode" == name ) {
|
||||
std::string val = attribute.asString();
|
||||
if ( "auto" == val ) setHorizontalScrollMode( UI_SCROLLBAR_AUTO );
|
||||
else if ( "on" == val ) setHorizontalScrollMode( UI_SCROLLBAR_ALWAYS_ON );
|
||||
else if ( "off" == val ) setHorizontalScrollMode( UI_SCROLLBAR_ALWAYS_OFF );
|
||||
} else if ( "scrollbartype" == name ) {
|
||||
std::string val( attribute.asString() );
|
||||
String::toLowerInPlace( val );
|
||||
|
||||
for (pugi::xml_attribute_iterator ait = node.attributes_begin(); ait != node.attributes_end(); ++ait) {
|
||||
std::string name = ait->name();
|
||||
String::toLowerInPlace( name );
|
||||
|
||||
if ( "rowheight" == name ) {
|
||||
setRowHeight( ait->as_int() );
|
||||
} else if ( "padding" == name ) {
|
||||
int val = ait->as_int();
|
||||
setContainerPadding( Rectf( val, val, val, val ) );
|
||||
} else if ( "paddingleft" == name ) {
|
||||
setContainerPadding( Rectf( ait->as_int(), mContainerPadding.Top, mContainerPadding.Right, mContainerPadding.Bottom ) );
|
||||
} else if ( "paddingright" == name ) {
|
||||
setContainerPadding( Rectf( mContainerPadding.Left, mContainerPadding.Top, ait->as_int(), mContainerPadding.Bottom ) );
|
||||
} else if ( "paddingtop" == name ) {
|
||||
setContainerPadding( Rectf( mContainerPadding.Left, ait->as_int(), mContainerPadding.Right, mContainerPadding.Bottom ) );
|
||||
} else if ( "paddingbottom" == name ) {
|
||||
setContainerPadding( Rectf( mContainerPadding.Left, mContainerPadding.Top, mContainerPadding.Right, ait->as_int() ) );
|
||||
} else if ( "verticalscrollmode" == name || "vscrollmode" == name ) {
|
||||
std::string val = ait->as_string();
|
||||
if ( "auto" == val ) setVerticalScrollMode( UI_SCROLLBAR_AUTO );
|
||||
else if ( "on" == val ) setVerticalScrollMode( UI_SCROLLBAR_ALWAYS_ON );
|
||||
else if ( "off" == val ) setVerticalScrollMode( UI_SCROLLBAR_ALWAYS_OFF );
|
||||
} else if ( "horizontalscrollmode" == name || "hscrollmode" == name ) {
|
||||
std::string val = ait->as_string();
|
||||
if ( "auto" == val ) setHorizontalScrollMode( UI_SCROLLBAR_AUTO );
|
||||
else if ( "on" == val ) setHorizontalScrollMode( UI_SCROLLBAR_ALWAYS_ON );
|
||||
else if ( "off" == val ) setHorizontalScrollMode( UI_SCROLLBAR_ALWAYS_OFF );
|
||||
} else if ( "scrollbartype" == name ) {
|
||||
std::string val( ait->as_string() );
|
||||
String::toLowerInPlace( val );
|
||||
|
||||
if ( "nobuttons" == val ) {
|
||||
mVScrollBar->setScrollBarType( UIScrollBar::NoButtons );
|
||||
mHScrollBar->setScrollBarType( UIScrollBar::NoButtons );
|
||||
} else if ( "twobuttons" == val ) {
|
||||
mVScrollBar->setScrollBarType( UIScrollBar::TwoButtons );
|
||||
mHScrollBar->setScrollBarType( UIScrollBar::NoButtons );
|
||||
}
|
||||
if ( "nobuttons" == val ) {
|
||||
mVScrollBar->setScrollBarType( UIScrollBar::NoButtons );
|
||||
mHScrollBar->setScrollBarType( UIScrollBar::NoButtons );
|
||||
} else if ( "twobuttons" == val ) {
|
||||
mVScrollBar->setScrollBarType( UIScrollBar::TwoButtons );
|
||||
mHScrollBar->setScrollBarType( UIScrollBar::NoButtons );
|
||||
}
|
||||
} else {
|
||||
UITouchDragableWidget::setAttribute( attribute );
|
||||
}
|
||||
|
||||
endPropertiesTransaction();
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
+60
-67
@@ -185,79 +185,72 @@ void UITabWidget::setStyleConfig(const UITabWidgetStyleConfig & styleConfig) {
|
||||
orderTabs();
|
||||
}
|
||||
|
||||
void UITabWidget::loadFromXmlNode(const pugi::xml_node & node) {
|
||||
beginPropertiesTransaction();
|
||||
void UITabWidget::setAttribute( const NodeAttribute& attribute ) {
|
||||
const std::string& name = attribute.getName();
|
||||
|
||||
UIWidget::loadFromXmlNode( node );
|
||||
if ( "textcolor" == name ) {
|
||||
setFontColor( Color::fromString( attribute.asString() ) );
|
||||
} else if ( "textshadowcolor" == name ) {
|
||||
setFontShadowColor( Color::fromString( attribute.asString() ) );
|
||||
} else if ( "textovercolor" == name ) {
|
||||
setFontOverColor( Color::fromString( attribute.asString() ) );
|
||||
} else if ( "textselectedcolor" == name ) {
|
||||
setFontSelectedColor( Color::fromString( attribute.asString() ) );
|
||||
} else if ( "fontfamily" == name || "fontname" == name ) {
|
||||
Font * font = FontManager::instance()->getByName( attribute.asString() );
|
||||
|
||||
for (pugi::xml_attribute_iterator ait = node.attributes_begin(); ait != node.attributes_end(); ++ait) {
|
||||
std::string name = ait->name();
|
||||
String::toLowerInPlace( name );
|
||||
if ( NULL != font )
|
||||
setFont( font );
|
||||
} else if ( "textsize" == name || "fontsize" == name || "charactersize" == name ) {
|
||||
setCharacterSize( PixelDensity::toDpFromStringI( attribute.asString() ) );
|
||||
} else if ( "textstyle" == name || "fontstyle" == name ) {
|
||||
std::string valStr = attribute.asString();
|
||||
String::toLowerInPlace( valStr );
|
||||
std::vector<std::string> strings = String::split( valStr, '|' );
|
||||
Uint32 flags = Text::Regular;
|
||||
|
||||
if ( "textcolor" == name ) {
|
||||
setFontColor( Color::fromString( ait->as_string() ) );
|
||||
} else if ( "textshadowcolor" == name ) {
|
||||
setFontShadowColor( Color::fromString( ait->as_string() ) );
|
||||
} else if ( "textovercolor" == name ) {
|
||||
setFontOverColor( Color::fromString( ait->as_string() ) );
|
||||
} else if ( "textselectedcolor" == name ) {
|
||||
setFontSelectedColor( Color::fromString( ait->as_string() ) );
|
||||
} else if ( "fontfamily" == name || "fontname" == name ) {
|
||||
Font * font = FontManager::instance()->getByName( ait->as_string() );
|
||||
if ( strings.size() ) {
|
||||
for ( std::size_t i = 0; i < strings.size(); i++ ) {
|
||||
std::string cur = strings[i];
|
||||
String::toLowerInPlace( cur );
|
||||
|
||||
if ( NULL != font )
|
||||
setFont( font );
|
||||
} else if ( "textsize" == name || "fontsize" == name || "charactersize" == name ) {
|
||||
setCharacterSize( PixelDensity::toDpFromStringI( ait->as_string() ) );
|
||||
} else if ( "textstyle" == name || "fontstyle" == name ) {
|
||||
std::string valStr = ait->as_string();
|
||||
String::toLowerInPlace( valStr );
|
||||
std::vector<std::string> strings = String::split( valStr, '|' );
|
||||
Uint32 flags = Text::Regular;
|
||||
|
||||
if ( strings.size() ) {
|
||||
for ( std::size_t i = 0; i < strings.size(); i++ ) {
|
||||
std::string cur = strings[i];
|
||||
String::toLowerInPlace( cur );
|
||||
|
||||
if ( "underlined" == cur || "underline" == cur )
|
||||
flags |= Text::Underlined;
|
||||
else if ( "bold" == cur )
|
||||
flags |= Text::Bold;
|
||||
else if ( "italic" == cur )
|
||||
flags |= Text::Italic;
|
||||
else if ( "strikethrough" == cur )
|
||||
flags |= Text::StrikeThrough;
|
||||
else if ( "shadowed" == cur || "shadow" == cur )
|
||||
flags |= Text::Shadow;
|
||||
}
|
||||
|
||||
setFontStyle( flags );
|
||||
if ( "underlined" == cur || "underline" == cur )
|
||||
flags |= Text::Underlined;
|
||||
else if ( "bold" == cur )
|
||||
flags |= Text::Bold;
|
||||
else if ( "italic" == cur )
|
||||
flags |= Text::Italic;
|
||||
else if ( "strikethrough" == cur )
|
||||
flags |= Text::StrikeThrough;
|
||||
else if ( "shadowed" == cur || "shadow" == cur )
|
||||
flags |= Text::Shadow;
|
||||
}
|
||||
} else if ( "fontoutlinethickness" == name ) {
|
||||
setOutlineThickness( PixelDensity::toDpFromString( ait->as_string() ) );
|
||||
} else if ( "fontoutlinecolor" == name ) {
|
||||
setOutlineColor( Color::fromString( ait->as_string() ) );
|
||||
} else if ( "maxtextlength" == name ) {
|
||||
setMaxTextLength( ait->as_uint(1) );
|
||||
} else if ( "mintabwidth" == name ) {
|
||||
setMinTabWidth( ait->as_uint(1) );
|
||||
} else if ( "maxtabwidth" == name ) {
|
||||
setMaxTabWidth( ait->as_uint() );
|
||||
} else if ( "tabclosable" == name ) {
|
||||
setTabsClosable( ait->as_bool() );
|
||||
} else if ( "specialbordertabs" == name ) {
|
||||
setSpecialBorderTabs( ait->as_bool() );
|
||||
} else if ( "drawlinebelowtabs" == name ) {
|
||||
setDrawLineBelowTabs( ait->as_bool() );
|
||||
} else if ( "linebelowtabscolor" == name ) {
|
||||
setLineBelowTabsColor( Color::fromString( ait->as_string() ) );
|
||||
} else if ( "linebelowtabsyoffset" == name ) {
|
||||
setLineBelowTabsYOffset( ait->as_int() );
|
||||
}
|
||||
}
|
||||
|
||||
endPropertiesTransaction();
|
||||
setFontStyle( flags );
|
||||
}
|
||||
} else if ( "fontoutlinethickness" == name ) {
|
||||
setOutlineThickness( PixelDensity::toDpFromString( attribute.asString() ) );
|
||||
} else if ( "fontoutlinecolor" == name ) {
|
||||
setOutlineColor( Color::fromString( attribute.asString() ) );
|
||||
} else if ( "maxtextlength" == name ) {
|
||||
setMaxTextLength( attribute.asUint(1) );
|
||||
} else if ( "mintabwidth" == name ) {
|
||||
setMinTabWidth( attribute.asUint(1) );
|
||||
} else if ( "maxtabwidth" == name ) {
|
||||
setMaxTabWidth( attribute.asUint() );
|
||||
} else if ( "tabclosable" == name ) {
|
||||
setTabsClosable( attribute.asBool() );
|
||||
} else if ( "specialbordertabs" == name ) {
|
||||
setSpecialBorderTabs( attribute.asBool() );
|
||||
} else if ( "drawlinebelowtabs" == name ) {
|
||||
setDrawLineBelowTabs( attribute.asBool() );
|
||||
} else if ( "linebelowtabscolor" == name ) {
|
||||
setLineBelowTabsColor( Color::fromString( attribute.asString() ) );
|
||||
} else if ( "linebelowtabsyoffset" == name ) {
|
||||
setLineBelowTabsYOffset( attribute.asInt() );
|
||||
} else {
|
||||
UIWidget::setAttribute( attribute );
|
||||
}
|
||||
}
|
||||
|
||||
Font * UITabWidget::getFont() const {
|
||||
|
||||
+20
-27
@@ -447,37 +447,30 @@ void UITextEdit::setFontStyleConfig(const UIFontStyleConfig & fontStyleConfig) {
|
||||
}
|
||||
}
|
||||
|
||||
void UITextEdit::loadFromXmlNode(const pugi::xml_node & node) {
|
||||
beginPropertiesTransaction();
|
||||
void UITextEdit::setAttribute( const NodeAttribute &attribute ) {
|
||||
const std::string& name = attribute.getName();
|
||||
|
||||
UIWidget::loadFromXmlNode( node );
|
||||
|
||||
mTextInput->loadFromXmlNode( node );
|
||||
|
||||
for (pugi::xml_attribute_iterator ait = node.attributes_begin(); ait != node.attributes_end(); ++ait) {
|
||||
std::string name = ait->name();
|
||||
String::toLowerInPlace( name );
|
||||
|
||||
if ( "text" == name ) {
|
||||
if ( NULL != mSceneNode && mSceneNode->isUISceneNode() ) {
|
||||
setText( static_cast<UISceneNode*>( mSceneNode )->getTranslatorString( ait->as_string() ) );
|
||||
}
|
||||
} else if ( "allowediting" == name ) {
|
||||
setAllowEditing( ait->as_bool() );
|
||||
} else if ( "verticalscrollmode" == name || "vscrollmode" == name ) {
|
||||
std::string val = ait->as_string();
|
||||
if ( "auto" == val ) setVerticalScrollMode( UI_SCROLLBAR_AUTO );
|
||||
else if ( "on" == val ) setVerticalScrollMode( UI_SCROLLBAR_ALWAYS_ON );
|
||||
else if ( "off" == val ) setVerticalScrollMode( UI_SCROLLBAR_ALWAYS_OFF );
|
||||
} else if ( "horizontalscrollmode" == name || "hscrollmode" == name ) {
|
||||
std::string val = ait->as_string();
|
||||
if ( "auto" == val ) setHorizontalScrollMode( UI_SCROLLBAR_AUTO );
|
||||
else if ( "on" == val ) setHorizontalScrollMode( UI_SCROLLBAR_ALWAYS_ON );
|
||||
else if ( "off" == val ) setHorizontalScrollMode( UI_SCROLLBAR_ALWAYS_OFF );
|
||||
if ( "text" == name ) {
|
||||
if ( NULL != mSceneNode && mSceneNode->isUISceneNode() ) {
|
||||
setText( static_cast<UISceneNode*>( mSceneNode )->getTranslatorString( attribute.asString() ) );
|
||||
}
|
||||
} else if ( "allowediting" == name ) {
|
||||
setAllowEditing( attribute.asBool() );
|
||||
} else if ( "verticalscrollmode" == name || "vscrollmode" == name ) {
|
||||
std::string val = attribute.asString();
|
||||
if ( "auto" == val ) setVerticalScrollMode( UI_SCROLLBAR_AUTO );
|
||||
else if ( "on" == val ) setVerticalScrollMode( UI_SCROLLBAR_ALWAYS_ON );
|
||||
else if ( "off" == val ) setVerticalScrollMode( UI_SCROLLBAR_ALWAYS_OFF );
|
||||
} else if ( "horizontalscrollmode" == name || "hscrollmode" == name ) {
|
||||
std::string val = attribute.asString();
|
||||
if ( "auto" == val ) setHorizontalScrollMode( UI_SCROLLBAR_AUTO );
|
||||
else if ( "on" == val ) setHorizontalScrollMode( UI_SCROLLBAR_ALWAYS_ON );
|
||||
else if ( "off" == val ) setHorizontalScrollMode( UI_SCROLLBAR_ALWAYS_OFF );
|
||||
} else {
|
||||
UIWidget::setAttribute( attribute );
|
||||
}
|
||||
|
||||
endPropertiesTransaction();
|
||||
mTextInput->setAttribute( attribute );
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
+17
-24
@@ -339,33 +339,26 @@ bool UITextInput::isFreeEditingEnabled() {
|
||||
return mTextBuffer.isFreeEditingEnabled();
|
||||
}
|
||||
|
||||
void UITextInput::loadFromXmlNode(const pugi::xml_node & node) {
|
||||
beginPropertiesTransaction();
|
||||
void UITextInput::setAttribute( const NodeAttribute& attribute ) {
|
||||
const std::string& name = attribute.getName();
|
||||
|
||||
UITextView::loadFromXmlNode( node );
|
||||
|
||||
for (pugi::xml_attribute_iterator ait = node.attributes_begin(); ait != node.attributes_end(); ++ait) {
|
||||
std::string name = ait->name();
|
||||
String::toLowerInPlace( name );
|
||||
|
||||
if ( "text" == name ) {
|
||||
if ( NULL != mSceneNode && mSceneNode->isUISceneNode() ) {
|
||||
setText( static_cast<UISceneNode*>( mSceneNode )->getTranslatorString( ait->as_string() ) );
|
||||
}
|
||||
} else if ( "allowediting" == name ) {
|
||||
setAllowEditing( ait->as_bool() );
|
||||
} else if ( "maxlength" == name ) {
|
||||
setMaxLength( ait->as_uint() );
|
||||
} else if ( "freeediting" == name ) {
|
||||
setFreeEditing( ait->as_bool() );
|
||||
} else if ( "onlynumbers" == name ) {
|
||||
getInputTextBuffer()->setAllowOnlyNumbers( ait->as_bool(), getInputTextBuffer()->dotsInNumbersAllowed() );
|
||||
} else if ( "allowdot" == name ) {
|
||||
getInputTextBuffer()->setAllowOnlyNumbers( getInputTextBuffer()->onlyNumbersAllowed(), ait->as_bool() );
|
||||
if ( "text" == name ) {
|
||||
if ( NULL != mSceneNode && mSceneNode->isUISceneNode() ) {
|
||||
setText( static_cast<UISceneNode*>( mSceneNode )->getTranslatorString( attribute.asString() ) );
|
||||
}
|
||||
} else if ( "allowediting" == name ) {
|
||||
setAllowEditing( attribute.asBool() );
|
||||
} else if ( "maxlength" == name ) {
|
||||
setMaxLength( attribute.asUint() );
|
||||
} else if ( "freeediting" == name ) {
|
||||
setFreeEditing( attribute.asBool() );
|
||||
} else if ( "onlynumbers" == name ) {
|
||||
getInputTextBuffer()->setAllowOnlyNumbers( attribute.asBool(), getInputTextBuffer()->dotsInNumbersAllowed() );
|
||||
} else if ( "allowdot" == name ) {
|
||||
getInputTextBuffer()->setAllowOnlyNumbers( getInputTextBuffer()->onlyNumbersAllowed(), attribute.asBool() );
|
||||
} else {
|
||||
UITextView::setAttribute( attribute );
|
||||
}
|
||||
|
||||
endPropertiesTransaction();
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
@@ -183,38 +183,31 @@ const Vector2f& UITextureRegion::getAlignOffset() const {
|
||||
return mAlignOffset;
|
||||
}
|
||||
|
||||
void UITextureRegion::loadFromXmlNode(const pugi::xml_node & node) {
|
||||
beginPropertiesTransaction();
|
||||
void UITextureRegion::setAttribute( const NodeAttribute& attribute ) {
|
||||
const std::string& name = attribute.getName();
|
||||
|
||||
UIWidget::loadFromXmlNode( node );
|
||||
if ( "src" == name || "textureregion" == name || "subtexture" == name ) {
|
||||
DrawableResource * res = NULL;
|
||||
|
||||
for (pugi::xml_attribute_iterator ait = node.attributes_begin(); ait != node.attributes_end(); ++ait) {
|
||||
std::string name = ait->name();
|
||||
String::toLowerInPlace( name );
|
||||
|
||||
if ( "src" == name || "textureregion" == name || "subtexture" == name ) {
|
||||
DrawableResource * res = NULL;
|
||||
|
||||
if ( NULL != ( res = GlobalTextureAtlas::instance()->getByName( ait->as_string() ) ) && res->getDrawableType() == Drawable::TEXTUREREGION ) {
|
||||
setTextureRegion( static_cast<TextureRegion*>( res ) );
|
||||
}
|
||||
} else if ( "scaletype" == name ) {
|
||||
std::string val = ait->as_string();
|
||||
String::toLowerInPlace( val );
|
||||
|
||||
if ( "expand" == val ) {
|
||||
setScaleType( UIScaleType::Expand );
|
||||
} else if ( "fit_inside" == val || "fitinside" == val ) {
|
||||
setScaleType( UIScaleType::FitInside );
|
||||
} else if ( "none" == val ) {
|
||||
setScaleType( UIScaleType::None );
|
||||
}
|
||||
} else if ( "tint" == name ) {
|
||||
setColor( Color::fromString( ait->as_string() ) );
|
||||
if ( NULL != ( res = GlobalTextureAtlas::instance()->getByName( attribute.asString() ) ) && res->getDrawableType() == Drawable::TEXTUREREGION ) {
|
||||
setTextureRegion( static_cast<TextureRegion*>( res ) );
|
||||
}
|
||||
}
|
||||
} else if ( "scaletype" == name ) {
|
||||
std::string val = attribute.asString();
|
||||
String::toLowerInPlace( val );
|
||||
|
||||
endPropertiesTransaction();
|
||||
if ( "expand" == val ) {
|
||||
setScaleType( UIScaleType::Expand );
|
||||
} else if ( "fit_inside" == val || "fitinside" == val ) {
|
||||
setScaleType( UIScaleType::FitInside );
|
||||
} else if ( "none" == val ) {
|
||||
setScaleType( UIScaleType::None );
|
||||
}
|
||||
} else if ( "tint" == name ) {
|
||||
setColor( Color::fromString( attribute.asString() ) );
|
||||
} else {
|
||||
UIWidget::setAttribute( attribute );
|
||||
}
|
||||
}
|
||||
|
||||
Uint32 UITextureRegion::getScaleType() const {
|
||||
|
||||
+63
-70
@@ -524,83 +524,76 @@ void UITextView::onPaddingChange() {
|
||||
invalidateDraw();
|
||||
}
|
||||
|
||||
void UITextView::loadFromXmlNode(const pugi::xml_node & node) {
|
||||
beginPropertiesTransaction();
|
||||
void UITextView::setAttribute( const NodeAttribute& attribute ) {
|
||||
const std::string& name = attribute.getName();
|
||||
|
||||
UIWidget::loadFromXmlNode( node );
|
||||
if ( "text" == name ) {
|
||||
if ( NULL != mSceneNode && mSceneNode->isUISceneNode() )
|
||||
setText( static_cast<UISceneNode*>( mSceneNode )->getTranslatorString( attribute.asString() ) );
|
||||
} else if ( "textcolor" == name ) {
|
||||
setFontColor( Color::fromString( attribute.asString() ) );
|
||||
} else if ( "textshadowcolor" == name ) {
|
||||
setFontShadowColor( Color::fromString( attribute.asString() ) );
|
||||
} else if ( "textovercolor" == name ) {
|
||||
mFontStyleConfig.FontOverColor = Color::fromString( attribute.asString() );
|
||||
} else if ( "textselectedcolor" == name ) {
|
||||
mFontStyleConfig.FontSelectedColor = Color::fromString( attribute.asString() );
|
||||
} else if ( "textselectionbackcolor" == name ) {
|
||||
setSelectionBackColor( Color::fromString( attribute.asString() ) );
|
||||
} else if ( "fontfamily" == name || "fontname" == name ) {
|
||||
Font * font = FontManager::instance()->getByName( attribute.asString() );
|
||||
|
||||
for (pugi::xml_attribute_iterator ait = node.attributes_begin(); ait != node.attributes_end(); ++ait) {
|
||||
std::string name = ait->name();
|
||||
String::toLowerInPlace( name );
|
||||
if ( NULL != font )
|
||||
setFont( font );
|
||||
} else if ( "textsize" == name || "fontsize" == name || "charactersize" == name ) {
|
||||
setCharacterSize( PixelDensity::toDpFromStringI( attribute.asString() ) );
|
||||
} else if ( "textstyle" == name || "fontstyle" == name ) {
|
||||
std::string valStr = attribute.asString();
|
||||
String::toLowerInPlace( valStr );
|
||||
std::vector<std::string> strings = String::split( valStr, '|' );
|
||||
Uint32 flags = Text::Regular;
|
||||
|
||||
if ( "text" == name ) {
|
||||
if ( NULL != mSceneNode && mSceneNode->isUISceneNode() )
|
||||
setText( static_cast<UISceneNode*>( mSceneNode )->getTranslatorString( ait->as_string() ) );
|
||||
} else if ( "textcolor" == name ) {
|
||||
setFontColor( Color::fromString( ait->as_string() ) );
|
||||
} else if ( "textshadowcolor" == name ) {
|
||||
setFontShadowColor( Color::fromString( ait->as_string() ) );
|
||||
} else if ( "textovercolor" == name ) {
|
||||
mFontStyleConfig.FontOverColor = Color::fromString( ait->as_string() );
|
||||
} else if ( "textselectedcolor" == name ) {
|
||||
mFontStyleConfig.FontSelectedColor = Color::fromString( ait->as_string() );
|
||||
} else if ( "textselectionbackcolor" == name ) {
|
||||
setSelectionBackColor( Color::fromString( ait->as_string() ) );
|
||||
} else if ( "fontfamily" == name || "fontname" == name ) {
|
||||
Font * font = FontManager::instance()->getByName( ait->as_string() );
|
||||
if ( strings.size() ) {
|
||||
for ( std::size_t i = 0; i < strings.size(); i++ ) {
|
||||
std::string cur = strings[i];
|
||||
String::toLowerInPlace( cur );
|
||||
|
||||
if ( NULL != font )
|
||||
setFont( font );
|
||||
} else if ( "textsize" == name || "fontsize" == name || "charactersize" == name ) {
|
||||
setCharacterSize( PixelDensity::toDpFromStringI( ait->as_string() ) );
|
||||
} else if ( "textstyle" == name || "fontstyle" == name ) {
|
||||
std::string valStr = ait->as_string();
|
||||
String::toLowerInPlace( valStr );
|
||||
std::vector<std::string> strings = String::split( valStr, '|' );
|
||||
Uint32 flags = Text::Regular;
|
||||
|
||||
if ( strings.size() ) {
|
||||
for ( std::size_t i = 0; i < strings.size(); i++ ) {
|
||||
std::string cur = strings[i];
|
||||
String::toLowerInPlace( cur );
|
||||
|
||||
if ( "underlined" == cur || "underline" == cur )
|
||||
flags |= Text::Underlined;
|
||||
else if ( "bold" == cur )
|
||||
flags |= Text::Bold;
|
||||
else if ( "italic" == cur )
|
||||
flags |= Text::Italic;
|
||||
else if ( "strikethrough" == cur )
|
||||
flags |= Text::StrikeThrough;
|
||||
else if ( "shadowed" == cur || "shadow" == cur )
|
||||
flags |= Text::Shadow;
|
||||
else if ( "wordwrap" == cur ) {
|
||||
mFlags |= UI_WORD_WRAP;
|
||||
autoShrink();
|
||||
}
|
||||
if ( "underlined" == cur || "underline" == cur )
|
||||
flags |= Text::Underlined;
|
||||
else if ( "bold" == cur )
|
||||
flags |= Text::Bold;
|
||||
else if ( "italic" == cur )
|
||||
flags |= Text::Italic;
|
||||
else if ( "strikethrough" == cur )
|
||||
flags |= Text::StrikeThrough;
|
||||
else if ( "shadowed" == cur || "shadow" == cur )
|
||||
flags |= Text::Shadow;
|
||||
else if ( "wordwrap" == cur ) {
|
||||
mFlags |= UI_WORD_WRAP;
|
||||
autoShrink();
|
||||
}
|
||||
|
||||
setFontStyle( flags );
|
||||
}
|
||||
} else if ( "fontoutlinethickness" == name ) {
|
||||
setOutlineThickness( PixelDensity::toDpFromString( ait->as_string() ) );
|
||||
} else if ( "fontoutlinecolor" == name ) {
|
||||
setOutlineColor( Color::fromString( ait->as_string() ) );
|
||||
} else if ( "padding" == name ) {
|
||||
int val = PixelDensity::toDpFromStringI( ait->as_string() );
|
||||
setPadding( Rectf( val, val, val, val ) );
|
||||
} else if ( "paddingleft" == name ) {
|
||||
setPadding( Rectf( PixelDensity::toDpFromString( ait->as_string() ), mPadding.Top, mPadding.Right, mPadding.Bottom ) );
|
||||
} else if ( "paddingright" == name ) {
|
||||
setPadding( Rectf( mPadding.Left, mPadding.Top, PixelDensity::toDpFromString( ait->as_string() ), mPadding.Bottom ) );
|
||||
} else if ( "paddingtop" == name ) {
|
||||
setPadding( Rectf( mPadding.Left, PixelDensity::toDpFromString( ait->as_string() ), mPadding.Right, mPadding.Bottom ) );
|
||||
} else if ( "paddingbottom" == name ) {
|
||||
setPadding( Rectf( mPadding.Left, mPadding.Top, mPadding.Right, PixelDensity::toDpFromString( ait->as_string() ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
endPropertiesTransaction();
|
||||
setFontStyle( flags );
|
||||
}
|
||||
} else if ( "fontoutlinethickness" == name ) {
|
||||
setOutlineThickness( PixelDensity::toDpFromString( attribute.asString() ) );
|
||||
} else if ( "fontoutlinecolor" == name ) {
|
||||
setOutlineColor( Color::fromString( attribute.asString() ) );
|
||||
} else if ( "padding" == name ) {
|
||||
int val = PixelDensity::toDpFromStringI( attribute.asString() );
|
||||
setPadding( Rectf( val, val, val, val ) );
|
||||
} else if ( "paddingleft" == name ) {
|
||||
setPadding( Rectf( PixelDensity::toDpFromString( attribute.asString() ), mPadding.Top, mPadding.Right, mPadding.Bottom ) );
|
||||
} else if ( "paddingright" == name ) {
|
||||
setPadding( Rectf( mPadding.Left, mPadding.Top, PixelDensity::toDpFromString( attribute.asString() ), mPadding.Bottom ) );
|
||||
} else if ( "paddingtop" == name ) {
|
||||
setPadding( Rectf( mPadding.Left, PixelDensity::toDpFromString( attribute.asString() ), mPadding.Right, mPadding.Bottom ) );
|
||||
} else if ( "paddingbottom" == name ) {
|
||||
setPadding( Rectf( mPadding.Left, mPadding.Top, mPadding.Right, PixelDensity::toDpFromString( attribute.asString() ) ) );
|
||||
} else {
|
||||
UIWidget::setAttribute( attribute );
|
||||
}
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
@@ -135,23 +135,16 @@ bool UITouchDragableWidget::isTouchOverAllowedChilds() {
|
||||
return isMouseOverMeOrChilds();
|
||||
}
|
||||
|
||||
void UITouchDragableWidget::loadFromXmlNode(const pugi::xml_node & node) {
|
||||
beginPropertiesTransaction();
|
||||
void UITouchDragableWidget::setAttribute( const NodeAttribute& attribute ) {
|
||||
const std::string& name = attribute.getName();
|
||||
|
||||
UIWidget::loadFromXmlNode( node );
|
||||
|
||||
for (pugi::xml_attribute_iterator ait = node.attributes_begin(); ait != node.attributes_end(); ++ait) {
|
||||
std::string name = ait->name();
|
||||
String::toLowerInPlace( name );
|
||||
|
||||
if ( "touchdrag" == name ) {
|
||||
setTouchDragEnabled( ait->as_bool() );
|
||||
} else if ( "touchdragdeceleration" == name ) {
|
||||
setTouchDragDeceleration( Vector2f( ait->as_float(), ait->as_float() ) );
|
||||
}
|
||||
if ( "touchdrag" == name ) {
|
||||
setTouchDragEnabled( attribute.asBool() );
|
||||
} else if ( "touchdragdeceleration" == name ) {
|
||||
setTouchDragDeceleration( Vector2f( attribute.asFloat(), attribute.asFloat() ) );
|
||||
} else {
|
||||
UIWidget::setAttribute( attribute );
|
||||
}
|
||||
|
||||
endPropertiesTransaction();
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
+228
-223
@@ -21,7 +21,7 @@ UIWidget::UIWidget() :
|
||||
mLayoutHeightRules(WRAP_CONTENT),
|
||||
mLayoutPositionRule(NONE),
|
||||
mLayoutPositionRuleWidget(NULL),
|
||||
mPropertiesTransactionCount(0)
|
||||
mAttributesTransactionCount(0)
|
||||
{
|
||||
mNodeFlags |= NODE_FLAG_WIDGET;
|
||||
|
||||
@@ -319,14 +319,14 @@ void UIWidget::onWidgetCreated() {
|
||||
}
|
||||
|
||||
void UIWidget::notifyLayoutAttrChange() {
|
||||
if ( 0 == mPropertiesTransactionCount ) {
|
||||
if ( 0 == mAttributesTransactionCount ) {
|
||||
NodeMessage msg( this, NodeMessage::LayoutAttributeChange );
|
||||
messagePost( &msg );
|
||||
}
|
||||
}
|
||||
|
||||
void UIWidget::notifyLayoutAttrChangeParent() {
|
||||
if ( 0 == mPropertiesTransactionCount && NULL != mParentCtrl ) {
|
||||
if ( 0 == mAttributesTransactionCount && NULL != mParentCtrl ) {
|
||||
NodeMessage msg( this, NodeMessage::LayoutAttributeChange );
|
||||
mParentCtrl->messagePost( &msg );
|
||||
}
|
||||
@@ -398,14 +398,14 @@ void UIWidget::alignAgainstLayout() {
|
||||
setInternalPosition( pos );
|
||||
}
|
||||
|
||||
void UIWidget::beginPropertiesTransaction() {
|
||||
mPropertiesTransactionCount++;
|
||||
void UIWidget::beginAttributesTransaction() {
|
||||
mAttributesTransactionCount++;
|
||||
}
|
||||
|
||||
void UIWidget::endPropertiesTransaction() {
|
||||
mPropertiesTransactionCount--;
|
||||
void UIWidget::endAttributesTransaction() {
|
||||
mAttributesTransactionCount--;
|
||||
|
||||
if ( 0 == mPropertiesTransactionCount ) {
|
||||
if ( 0 == mAttributesTransactionCount ) {
|
||||
notifyLayoutAttrChange();
|
||||
}
|
||||
}
|
||||
@@ -449,226 +449,231 @@ static BlendMode toBlendMode( std::string val ) {
|
||||
return blendMode;
|
||||
}
|
||||
|
||||
void UIWidget::loadFromXmlNode( const pugi::xml_node& node ) {
|
||||
beginPropertiesTransaction();
|
||||
void UIWidget::setAttribute( const std::string& name, const std::string& value ) {
|
||||
setAttribute( NodeAttribute( name, value ) );
|
||||
}
|
||||
|
||||
std::string skinName;
|
||||
void UIWidget::setAttribute(const NodeAttribute & attribute) {
|
||||
std::string name = attribute.getName();
|
||||
|
||||
if ( "id" == name ) {
|
||||
setId( attribute.value() );
|
||||
} else if ( "x" == name ) {
|
||||
setInternalPosition( Vector2f( PixelDensity::toDpFromString( attribute.asString() ), mDpPos.y ) );
|
||||
} else if ( "y" == name ) {
|
||||
setInternalPosition( Vector2f( mDpPos.x, PixelDensity::toDpFromString( attribute.asString() ) ) );
|
||||
} else if ( "width" == name ) {
|
||||
setInternalWidth( PixelDensity::toDpFromStringI( attribute.asString() ) );
|
||||
notifyLayoutAttrChange();
|
||||
} else if ( "height" == name ) {
|
||||
setInternalHeight( PixelDensity::toDpFromStringI( attribute.asString() ) );
|
||||
notifyLayoutAttrChange();
|
||||
} else if ( "backgroundcolor" == name ) {
|
||||
setBackgroundColor( Color::fromString( attribute.asString() ) );
|
||||
} else if ( "bordercolor" == name ) {
|
||||
setBorderColor( Color::fromString( attribute.asString() ) );
|
||||
} else if ( "borderwidth" == name ) {
|
||||
setBorderWidth( PixelDensity::toDpFromStringI( attribute.asString("1") ) );
|
||||
} else if ( "bordercorners" == name || "backgroundcorners" == name ) {
|
||||
setBackgroundCorners( attribute.asUint() );
|
||||
} else if ( "background" == name ) {
|
||||
Drawable * res = NULL;
|
||||
|
||||
if ( NULL != ( res = DrawableSearcher::searchByName( attribute.asString() ) ) ) {
|
||||
setBackgroundDrawable( res, res->getDrawableType() == Drawable::SPRITE );
|
||||
}
|
||||
} else if ( "visible" == name ) {
|
||||
setVisible( attribute.asBool() );
|
||||
} else if ( "enabled" == name ) {
|
||||
setEnabled( attribute.asBool() );
|
||||
} else if ( "theme" == name ) {
|
||||
setThemeByName( attribute.asString() );
|
||||
|
||||
if ( !mSkinName.empty() )
|
||||
setThemeSkin( mSkinName );
|
||||
} else if ( "skin" == name ) {
|
||||
mSkinName = attribute.asString();
|
||||
setThemeSkin( mSkinName );
|
||||
} else if ( "gravity" == name ) {
|
||||
std::string gravity = attribute.asString();
|
||||
String::toLowerInPlace( gravity );
|
||||
std::vector<std::string> strings = String::split( gravity, '|' );
|
||||
|
||||
if ( strings.size() ) {
|
||||
for ( std::size_t i = 0; i < strings.size(); i++ ) {
|
||||
std::string cur = strings[i];
|
||||
String::toLowerInPlace( cur );
|
||||
|
||||
if ( "left" == cur )
|
||||
setHorizontalAlign( UI_HALIGN_LEFT );
|
||||
else if ( "right" == cur )
|
||||
setHorizontalAlign( UI_HALIGN_RIGHT );
|
||||
else if ( "center_horizontal" == cur )
|
||||
setHorizontalAlign( UI_HALIGN_CENTER );
|
||||
else if ( "top" == cur )
|
||||
setVerticalAlign( UI_VALIGN_TOP );
|
||||
else if ( "bottom" == cur )
|
||||
setVerticalAlign( UI_VALIGN_BOTTOM );
|
||||
else if ( "center_vertical" == cur ) {
|
||||
setVerticalAlign( UI_VALIGN_CENTER );
|
||||
} else if ( "center" == cur ) {
|
||||
setHorizontalAlign( UI_HALIGN_CENTER );
|
||||
setVerticalAlign( UI_VALIGN_CENTER );
|
||||
}
|
||||
}
|
||||
|
||||
notifyLayoutAttrChange();
|
||||
}
|
||||
} else if ( "flags" == name ) {
|
||||
std::string flags = attribute.asString();
|
||||
String::toLowerInPlace( flags );
|
||||
std::vector<std::string> strings = String::split( flags, '|' );
|
||||
|
||||
if ( strings.size() ) {
|
||||
for ( std::size_t i = 0; i < strings.size(); i++ ) {
|
||||
std::string cur = strings[i];
|
||||
String::toLowerInPlace( cur );
|
||||
|
||||
if ( "auto_size" == cur || "autosize" == cur ) {
|
||||
setFlags( UI_AUTO_SIZE );
|
||||
notifyLayoutAttrChange();
|
||||
} else if ( "clip" == cur ) {
|
||||
clipEnable();
|
||||
} else if ( "word_wrap" == cur || "wordwrap" == cur ) {
|
||||
setFlags( UI_WORD_WRAP );
|
||||
} else if ( "multi" == cur ) {
|
||||
setFlags( UI_MULTI_SELECT );
|
||||
} else if ( "auto_padding" == cur || "autopadding" == cur ) {
|
||||
setFlags( UI_AUTO_PADDING );
|
||||
notifyLayoutAttrChange();
|
||||
} else if ( "reportsizechangetochilds" == cur || "report_size_change_to_childs" == cur ) {
|
||||
enableReportSizeChangeToChilds();
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if ( "layout_margin" == name ) {
|
||||
int val = PixelDensity::toDpFromStringI( attribute.asString() );
|
||||
setLayoutMargin( Rect( val, val, val, val ) );
|
||||
} else if ( "layout_marginleft" == name ) {
|
||||
setLayoutMargin( Rect( PixelDensity::toDpFromStringI( attribute.asString() ), mLayoutMargin.Top, mLayoutMargin.Right, mLayoutMargin.Bottom ) );
|
||||
} else if ( "layout_marginright" == name ) {
|
||||
setLayoutMargin( Rect( mLayoutMargin.Left, mLayoutMargin.Top, PixelDensity::toDpFromStringI( attribute.asString() ), mLayoutMargin.Bottom ) );
|
||||
} else if ( "layout_margintop" == name ) {
|
||||
setLayoutMargin( Rect( mLayoutMargin.Left, PixelDensity::toDpFromStringI( attribute.asString() ), mLayoutMargin.Right, mLayoutMargin.Bottom ) );
|
||||
} else if ( "layout_marginbottom" == name ) {
|
||||
setLayoutMargin( Rect( mLayoutMargin.Left, mLayoutMargin.Top, mLayoutMargin.Right, PixelDensity::toDpFromStringI( attribute.asString() ) ) );
|
||||
} else if ( "tooltip" == name ) {
|
||||
setTooltipText( attribute.asString() );
|
||||
} else if ( "layout_weight" == name ) {
|
||||
setLayoutWeight( attribute.asFloat() );
|
||||
} else if ( "layout_gravity" == name ) {
|
||||
std::string gravityStr = attribute.asString();
|
||||
String::toLowerInPlace( gravityStr );
|
||||
std::vector<std::string> strings = String::split( gravityStr, '|' );
|
||||
Uint32 gravity = 0;
|
||||
|
||||
if ( strings.size() ) {
|
||||
for ( std::size_t i = 0; i < strings.size(); i++ ) {
|
||||
std::string cur = strings[i];
|
||||
String::toLowerInPlace( cur );
|
||||
|
||||
if ( "left" == cur )
|
||||
gravity |= UI_HALIGN_LEFT;
|
||||
else if ( "right" == cur )
|
||||
gravity |= UI_HALIGN_RIGHT;
|
||||
else if ( "center_horizontal" == cur )
|
||||
gravity |= UI_HALIGN_CENTER;
|
||||
else if ( "top" == cur )
|
||||
gravity |= UI_VALIGN_TOP;
|
||||
else if ( "bottom" == cur )
|
||||
gravity |= UI_VALIGN_BOTTOM;
|
||||
else if ( "center_vertical" == cur ) {
|
||||
gravity |= UI_VALIGN_CENTER;
|
||||
} else if ( "center" == cur ) {
|
||||
gravity |= UI_VALIGN_CENTER | UI_HALIGN_CENTER;
|
||||
}
|
||||
}
|
||||
|
||||
setLayoutGravity( gravity );
|
||||
}
|
||||
} else if ( "layout_width" == name ) {
|
||||
std::string val = attribute.asString();
|
||||
String::toLowerInPlace( val );
|
||||
|
||||
if ( "match_parent" == val ) {
|
||||
setLayoutWidthRules( MATCH_PARENT );
|
||||
} else if ( "wrap_content" == val ) {
|
||||
setLayoutWidthRules( WRAP_CONTENT );
|
||||
} else if ( "fixed" == val ) {
|
||||
setLayoutWidthRules( FIXED );
|
||||
unsetFlags( UI_AUTO_SIZE );
|
||||
} else {
|
||||
unsetFlags( UI_AUTO_SIZE );
|
||||
setLayoutWidthRules( FIXED );
|
||||
setInternalWidth( PixelDensity::toDpFromStringI( val ) );
|
||||
onSizeChange();
|
||||
}
|
||||
} else if ( "layout_height" == name ) {
|
||||
std::string val = attribute.asString();
|
||||
String::toLowerInPlace( val );
|
||||
|
||||
if ( "match_parent" == val ) {
|
||||
setLayoutHeightRules( MATCH_PARENT );
|
||||
} else if ( "wrap_content" == val ) {
|
||||
setLayoutHeightRules( WRAP_CONTENT );
|
||||
} else if ( "fixed" == val ) {
|
||||
setLayoutHeightRules( FIXED );
|
||||
unsetFlags( UI_AUTO_SIZE );
|
||||
} else {
|
||||
unsetFlags( UI_AUTO_SIZE );
|
||||
setLayoutHeightRules( FIXED );
|
||||
setInternalHeight( PixelDensity::toDpFromStringI( val ) );
|
||||
onSizeChange();
|
||||
}
|
||||
} else if ( String::startsWith( name, "layout_to_" ) || String::startsWith( name, "layoutto" ) ) {
|
||||
LayoutPositionRules rule = NONE;
|
||||
if ( "layout_to_left_of" == name || "layouttoleftof" == name ) rule = LEFT_OF;
|
||||
else if ( "layout_to_right_of" == name || "layouttorightof" == name ) rule = RIGHT_OF;
|
||||
else if ( "layout_to_top_of" == name || "layouttotopof" == name ) rule = TOP_OF;
|
||||
else if ( "layout_to_bottom_of" == name || "layouttobottomof" == name ) rule = BOTTOM_OF;
|
||||
|
||||
std::string id = attribute.asString();
|
||||
|
||||
Node * control = getParent()->find( id );
|
||||
|
||||
if ( NULL != control && control->isWidget() ) {
|
||||
UIWidget * widget = static_cast<UIWidget*>( control );
|
||||
|
||||
setLayoutPositionRule( rule, widget );
|
||||
}
|
||||
} else if ( "clip" == name ) {
|
||||
if ( attribute.asBool() )
|
||||
clipEnable();
|
||||
else
|
||||
clipDisable();
|
||||
} else if ( "rotation" == name ) {
|
||||
setRotation( attribute.asFloat() );
|
||||
} else if ( "scale" == name ) {
|
||||
setScale( attribute.asFloat() );
|
||||
} else if ( "rotationoriginpoint" == name ) {
|
||||
setRotationOriginPoint( toOriginPoint( attribute.asString() ) );
|
||||
} else if ( "scaleoriginpoint" == name ) {
|
||||
setScaleOriginPoint( toOriginPoint( attribute.asString() ) );
|
||||
} else if ( "blendmode" == name ) {
|
||||
setBlendMode( toBlendMode( attribute.asString() ) );
|
||||
} else if ( "backgroundblendmode" == name ) {
|
||||
setBackgroundBlendMode( toBlendMode( attribute.asString() ) );
|
||||
}
|
||||
}
|
||||
|
||||
void UIWidget::loadFromXmlNode( const pugi::xml_node& node ) {
|
||||
beginAttributesTransaction();
|
||||
|
||||
for (pugi::xml_attribute_iterator ait = node.attributes_begin(); ait != node.attributes_end(); ++ait) {
|
||||
std::string name = ait->name();
|
||||
String::toLowerInPlace( name );
|
||||
|
||||
if ( "id" == name ) {
|
||||
setId( ait->value() );
|
||||
} else if ( "x" == name ) {
|
||||
setInternalPosition( Vector2f( PixelDensity::toDpFromString( ait->as_string() ), mDpPos.y ) );
|
||||
} else if ( "y" == name ) {
|
||||
setInternalPosition( Vector2f( mDpPos.x, PixelDensity::toDpFromString( ait->as_string() ) ) );
|
||||
} else if ( "width" == name ) {
|
||||
setInternalWidth( PixelDensity::toDpFromStringI( ait->as_string() ) );
|
||||
notifyLayoutAttrChange();
|
||||
} else if ( "height" == name ) {
|
||||
setInternalHeight( PixelDensity::toDpFromStringI( ait->as_string() ) );
|
||||
notifyLayoutAttrChange();
|
||||
} else if ( "backgroundcolor" == name ) {
|
||||
setBackgroundColor( Color::fromString( ait->as_string() ) );
|
||||
} else if ( "bordercolor" == name ) {
|
||||
setBorderColor( Color::fromString( ait->as_string() ) );
|
||||
} else if ( "borderwidth" == name ) {
|
||||
setBorderWidth( PixelDensity::toDpFromStringI( ait->as_string("1") ) );
|
||||
} else if ( "bordercorners" == name || "backgroundcorners" == name ) {
|
||||
setBackgroundCorners( ait->as_uint() );
|
||||
} else if ( "background" == name ) {
|
||||
Drawable * res = NULL;
|
||||
|
||||
if ( NULL != ( res = DrawableSearcher::searchByName( ait->as_string() ) ) ) {
|
||||
setBackgroundDrawable( res, res->getDrawableType() == Drawable::SPRITE );
|
||||
}
|
||||
} else if ( "visible" == name ) {
|
||||
setVisible( ait->as_bool() );
|
||||
} else if ( "enabled" == name ) {
|
||||
setEnabled( ait->as_bool() );
|
||||
} else if ( "theme" == name ) {
|
||||
setThemeByName( ait->as_string() );
|
||||
|
||||
if ( !skinName.empty() )
|
||||
setThemeSkin( skinName );
|
||||
} else if ( "skin" == name ) {
|
||||
skinName = ait->as_string();
|
||||
setThemeSkin( skinName );
|
||||
} else if ( "gravity" == name ) {
|
||||
std::string gravity = ait->as_string();
|
||||
String::toLowerInPlace( gravity );
|
||||
std::vector<std::string> strings = String::split( gravity, '|' );
|
||||
|
||||
if ( strings.size() ) {
|
||||
for ( std::size_t i = 0; i < strings.size(); i++ ) {
|
||||
std::string cur = strings[i];
|
||||
String::toLowerInPlace( cur );
|
||||
|
||||
if ( "left" == cur )
|
||||
setHorizontalAlign( UI_HALIGN_LEFT );
|
||||
else if ( "right" == cur )
|
||||
setHorizontalAlign( UI_HALIGN_RIGHT );
|
||||
else if ( "center_horizontal" == cur )
|
||||
setHorizontalAlign( UI_HALIGN_CENTER );
|
||||
else if ( "top" == cur )
|
||||
setVerticalAlign( UI_VALIGN_TOP );
|
||||
else if ( "bottom" == cur )
|
||||
setVerticalAlign( UI_VALIGN_BOTTOM );
|
||||
else if ( "center_vertical" == cur ) {
|
||||
setVerticalAlign( UI_VALIGN_CENTER );
|
||||
} else if ( "center" == cur ) {
|
||||
setHorizontalAlign( UI_HALIGN_CENTER );
|
||||
setVerticalAlign( UI_VALIGN_CENTER );
|
||||
}
|
||||
}
|
||||
|
||||
notifyLayoutAttrChange();
|
||||
}
|
||||
} else if ( "flags" == name ) {
|
||||
std::string flags = ait->as_string();
|
||||
String::toLowerInPlace( flags );
|
||||
std::vector<std::string> strings = String::split( flags, '|' );
|
||||
|
||||
if ( strings.size() ) {
|
||||
for ( std::size_t i = 0; i < strings.size(); i++ ) {
|
||||
std::string cur = strings[i];
|
||||
String::toLowerInPlace( cur );
|
||||
|
||||
if ( "auto_size" == cur || "autosize" == cur ) {
|
||||
setFlags( UI_AUTO_SIZE );
|
||||
notifyLayoutAttrChange();
|
||||
} else if ( "clip" == cur ) {
|
||||
clipEnable();
|
||||
} else if ( "word_wrap" == cur || "wordwrap" == cur ) {
|
||||
setFlags( UI_WORD_WRAP );
|
||||
} else if ( "multi" == cur ) {
|
||||
setFlags( UI_MULTI_SELECT );
|
||||
} else if ( "auto_padding" == cur || "autopadding" == cur ) {
|
||||
setFlags( UI_AUTO_PADDING );
|
||||
notifyLayoutAttrChange();
|
||||
} else if ( "reportsizechangetochilds" == cur || "report_size_change_to_childs" == cur ) {
|
||||
enableReportSizeChangeToChilds();
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if ( "layout_margin" == name ) {
|
||||
int val = PixelDensity::toDpFromStringI( ait->as_string() );
|
||||
setLayoutMargin( Rect( val, val, val, val ) );
|
||||
} else if ( "layout_marginleft" == name ) {
|
||||
setLayoutMargin( Rect( PixelDensity::toDpFromStringI( ait->as_string() ), mLayoutMargin.Top, mLayoutMargin.Right, mLayoutMargin.Bottom ) );
|
||||
} else if ( "layout_marginright" == name ) {
|
||||
setLayoutMargin( Rect( mLayoutMargin.Left, mLayoutMargin.Top, PixelDensity::toDpFromStringI( ait->as_string() ), mLayoutMargin.Bottom ) );
|
||||
} else if ( "layout_margintop" == name ) {
|
||||
setLayoutMargin( Rect( mLayoutMargin.Left, PixelDensity::toDpFromStringI( ait->as_string() ), mLayoutMargin.Right, mLayoutMargin.Bottom ) );
|
||||
} else if ( "layout_marginbottom" == name ) {
|
||||
setLayoutMargin( Rect( mLayoutMargin.Left, mLayoutMargin.Top, mLayoutMargin.Right, PixelDensity::toDpFromStringI( ait->as_string() ) ) );
|
||||
} else if ( "tooltip" == name ) {
|
||||
setTooltipText( ait->as_string() );
|
||||
} else if ( "layout_weight" == name ) {
|
||||
setLayoutWeight( ait->as_float() );
|
||||
} else if ( "layout_gravity" == name ) {
|
||||
std::string gravityStr = ait->as_string();
|
||||
String::toLowerInPlace( gravityStr );
|
||||
std::vector<std::string> strings = String::split( gravityStr, '|' );
|
||||
Uint32 gravity = 0;
|
||||
|
||||
if ( strings.size() ) {
|
||||
for ( std::size_t i = 0; i < strings.size(); i++ ) {
|
||||
std::string cur = strings[i];
|
||||
String::toLowerInPlace( cur );
|
||||
|
||||
if ( "left" == cur )
|
||||
gravity |= UI_HALIGN_LEFT;
|
||||
else if ( "right" == cur )
|
||||
gravity |= UI_HALIGN_RIGHT;
|
||||
else if ( "center_horizontal" == cur )
|
||||
gravity |= UI_HALIGN_CENTER;
|
||||
else if ( "top" == cur )
|
||||
gravity |= UI_VALIGN_TOP;
|
||||
else if ( "bottom" == cur )
|
||||
gravity |= UI_VALIGN_BOTTOM;
|
||||
else if ( "center_vertical" == cur ) {
|
||||
gravity |= UI_VALIGN_CENTER;
|
||||
} else if ( "center" == cur ) {
|
||||
gravity |= UI_VALIGN_CENTER | UI_HALIGN_CENTER;
|
||||
}
|
||||
}
|
||||
|
||||
setLayoutGravity( gravity );
|
||||
}
|
||||
} else if ( "layout_width" == name ) {
|
||||
std::string val = ait->as_string();
|
||||
String::toLowerInPlace( val );
|
||||
|
||||
if ( "match_parent" == val ) {
|
||||
setLayoutWidthRules( MATCH_PARENT );
|
||||
} else if ( "wrap_content" == val ) {
|
||||
setLayoutWidthRules( WRAP_CONTENT );
|
||||
} else if ( "fixed" == val ) {
|
||||
setLayoutWidthRules( FIXED );
|
||||
unsetFlags( UI_AUTO_SIZE );
|
||||
} else {
|
||||
unsetFlags( UI_AUTO_SIZE );
|
||||
setLayoutWidthRules( FIXED );
|
||||
setInternalWidth( PixelDensity::toDpFromStringI( val ) );
|
||||
onSizeChange();
|
||||
}
|
||||
} else if ( "layout_height" == name ) {
|
||||
std::string val = ait->as_string();
|
||||
String::toLowerInPlace( val );
|
||||
|
||||
if ( "match_parent" == val ) {
|
||||
setLayoutHeightRules( MATCH_PARENT );
|
||||
} else if ( "wrap_content" == val ) {
|
||||
setLayoutHeightRules( WRAP_CONTENT );
|
||||
} else if ( "fixed" == val ) {
|
||||
setLayoutHeightRules( FIXED );
|
||||
unsetFlags( UI_AUTO_SIZE );
|
||||
} else {
|
||||
unsetFlags( UI_AUTO_SIZE );
|
||||
setLayoutHeightRules( FIXED );
|
||||
setInternalHeight( PixelDensity::toDpFromStringI( val ) );
|
||||
onSizeChange();
|
||||
}
|
||||
} else if ( String::startsWith( name, "layout_to_" ) || String::startsWith( name, "layoutto" ) ) {
|
||||
LayoutPositionRules rule = NONE;
|
||||
if ( "layout_to_left_of" == name || "layouttoleftof" == name ) rule = LEFT_OF;
|
||||
else if ( "layout_to_right_of" == name || "layouttorightof" == name ) rule = RIGHT_OF;
|
||||
else if ( "layout_to_top_of" == name || "layouttotopof" == name ) rule = TOP_OF;
|
||||
else if ( "layout_to_bottom_of" == name || "layouttobottomof" == name ) rule = BOTTOM_OF;
|
||||
|
||||
std::string id = ait->as_string();
|
||||
|
||||
Node * control = getParent()->find( id );
|
||||
|
||||
if ( NULL != control && control->isWidget() ) {
|
||||
UIWidget * widget = static_cast<UIWidget*>( control );
|
||||
|
||||
setLayoutPositionRule( rule, widget );
|
||||
}
|
||||
} else if ( "clip" == name ) {
|
||||
if ( ait->as_bool() )
|
||||
clipEnable();
|
||||
else
|
||||
clipDisable();
|
||||
} else if ( "rotation" == name ) {
|
||||
setRotation( ait->as_float() );
|
||||
} else if ( "scale" == name ) {
|
||||
setScale( ait->as_float() );
|
||||
} else if ( "rotationoriginpoint" == name ) {
|
||||
setRotationOriginPoint( toOriginPoint( ait->as_string() ) );
|
||||
} else if ( "scaleoriginpoint" == name ) {
|
||||
setScaleOriginPoint( toOriginPoint( ait->as_string() ) );
|
||||
} else if ( "blendmode" == name ) {
|
||||
setBlendMode( toBlendMode( ait->as_string() ) );
|
||||
} else if ( "backgroundblendmode" == name ) {
|
||||
setBackgroundBlendMode( toBlendMode( ait->as_string() ) );
|
||||
}
|
||||
setAttribute( ait->name(), ait->value() );
|
||||
}
|
||||
|
||||
endPropertiesTransaction();
|
||||
endAttributesTransaction();
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
+42
-45
@@ -1397,56 +1397,53 @@ void UIWindow::resizeCursor() {
|
||||
}
|
||||
}
|
||||
|
||||
void UIWindow::loadFromXmlNode(const pugi::xml_node & node) {
|
||||
beginPropertiesTransaction();
|
||||
void UIWindow::setAttribute( const NodeAttribute& attribute ) {
|
||||
const std::string& name = attribute.getName();
|
||||
|
||||
UIWidget::loadFromXmlNode( node );
|
||||
if ( "width" == name ) {
|
||||
setSize( attribute.asInt(), mDpSize.getHeight() );
|
||||
} else if ( "height" == name ) {
|
||||
setSize( mDpSize.getWidth(), attribute.asInt() );
|
||||
} else if ( "title" == name ) {
|
||||
setTitle( attribute.asString() );
|
||||
} else if ( "basealpha" == name ) {
|
||||
unsigned int val = attribute.asUint();
|
||||
if ( val <= 255 )
|
||||
setBaseAlpha( (Uint8)val );
|
||||
} else if ( "winflags" == name ) {
|
||||
std::string flagsStr = attribute.asString();
|
||||
String::toLowerInPlace( flagsStr );
|
||||
std::vector<std::string> strings = String::split( flagsStr, '|' );
|
||||
Uint32 winflags = 0;
|
||||
|
||||
for (pugi::xml_attribute_iterator ait = node.attributes_begin(); ait != node.attributes_end(); ++ait) {
|
||||
std::string name = ait->name();
|
||||
String::toLowerInPlace( name );
|
||||
if ( strings.size() ) {
|
||||
for ( std::size_t i = 0; i < strings.size(); i++ ) {
|
||||
std::string cur = strings[i];
|
||||
|
||||
if ( "width" == name ) {
|
||||
setSize( ait->as_int(), mDpSize.getHeight() );
|
||||
} else if ( "height" == name ) {
|
||||
setSize( mDpSize.getWidth(), ait->as_int() );
|
||||
} else if ( "title" == name ) {
|
||||
setTitle( ait->as_string() );
|
||||
} else if ( "basealpha" == name ) {
|
||||
unsigned int val = ait->as_uint();
|
||||
if ( val <= 255 )
|
||||
setBaseAlpha( (Uint8)val );
|
||||
} else if ( "winflags" == name ) {
|
||||
std::string flagsStr = ait->as_string();
|
||||
String::toLowerInPlace( flagsStr );
|
||||
std::vector<std::string> strings = String::split( flagsStr, '|' );
|
||||
Uint32 winflags = 0;
|
||||
|
||||
if ( strings.size() ) {
|
||||
for ( std::size_t i = 0; i < strings.size(); i++ ) {
|
||||
std::string cur = strings[i];
|
||||
|
||||
if ( "default" == cur ) winflags |= UI_WIN_DEFAULT_FLAGS;
|
||||
else if ( "close" == cur ) winflags |= UI_WIN_CLOSE_BUTTON;
|
||||
else if ( "maximize" == cur ) winflags |= UI_WIN_MAXIMIZE_BUTTON;
|
||||
else if ( "minimize" == cur ) winflags |= UI_WIN_MINIMIZE_BUTTON;
|
||||
else if ( "dragable" == cur ) winflags |= UI_WIN_DRAGABLE_CONTAINER;
|
||||
else if ( "shadow" == cur ) winflags |= UI_WIN_SHADOW;
|
||||
else if ( "modal" == cur ) winflags |= UI_WIN_MODAL;
|
||||
else if ( "noborder" == cur || "borderless" == cur ) winflags |= UI_WIN_NO_BORDER;
|
||||
else if ( "resizeable" == cur ) winflags |= UI_WIN_RESIZEABLE;
|
||||
else if ( "sharealpha" == cur ) winflags |= UI_WIN_SHARE_ALPHA_WITH_CHILDS;
|
||||
else if ( "buttonactions" == cur ) winflags |= UI_WIN_USE_DEFAULT_BUTTONS_ACTIONS;
|
||||
else if ( "framebuffer"== cur ) winflags |= UI_WIN_FRAME_BUFFER;
|
||||
else if ( "colorbuffer"== cur ) winflags |= UI_WIN_COLOR_BUFFER;
|
||||
}
|
||||
|
||||
setWinFlags( winflags );
|
||||
if ( "default" == cur ) winflags |= UI_WIN_DEFAULT_FLAGS;
|
||||
else if ( "close" == cur ) winflags |= UI_WIN_CLOSE_BUTTON;
|
||||
else if ( "maximize" == cur ) winflags |= UI_WIN_MAXIMIZE_BUTTON;
|
||||
else if ( "minimize" == cur ) winflags |= UI_WIN_MINIMIZE_BUTTON;
|
||||
else if ( "dragable" == cur ) winflags |= UI_WIN_DRAGABLE_CONTAINER;
|
||||
else if ( "shadow" == cur ) winflags |= UI_WIN_SHADOW;
|
||||
else if ( "modal" == cur ) winflags |= UI_WIN_MODAL;
|
||||
else if ( "noborder" == cur || "borderless" == cur ) winflags |= UI_WIN_NO_BORDER;
|
||||
else if ( "resizeable" == cur ) winflags |= UI_WIN_RESIZEABLE;
|
||||
else if ( "sharealpha" == cur ) winflags |= UI_WIN_SHARE_ALPHA_WITH_CHILDS;
|
||||
else if ( "buttonactions" == cur ) winflags |= UI_WIN_USE_DEFAULT_BUTTONS_ACTIONS;
|
||||
else if ( "framebuffer"== cur ) winflags |= UI_WIN_FRAME_BUFFER;
|
||||
else if ( "colorbuffer"== cur ) winflags |= UI_WIN_COLOR_BUFFER;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
endPropertiesTransaction();
|
||||
setWinFlags( winflags );
|
||||
}
|
||||
} else {
|
||||
UIWidget::setAttribute( attribute );
|
||||
}
|
||||
}
|
||||
|
||||
void UIWindow::loadFromXmlNode(const pugi::xml_node & node) {
|
||||
UIWidget::loadFromXmlNode( node );
|
||||
|
||||
show();
|
||||
}
|
||||
|
||||
@@ -302,7 +302,7 @@ void UIWinMenu::destroyMenues() {
|
||||
}
|
||||
|
||||
void UIWinMenu::loadFromXmlNode( const pugi::xml_node& node ) {
|
||||
beginPropertiesTransaction();
|
||||
beginAttributesTransaction();
|
||||
|
||||
UIWidget::loadFromXmlNode( node );
|
||||
|
||||
@@ -325,7 +325,7 @@ void UIWinMenu::loadFromXmlNode( const pugi::xml_node& node ) {
|
||||
}
|
||||
}
|
||||
|
||||
endPropertiesTransaction();
|
||||
endAttributesTransaction();
|
||||
}
|
||||
|
||||
}}
|
||||
|
||||
Reference in New Issue
Block a user