mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-08-11 17:17:42 +03:00
More implementations of getPropertyString.
--HG-- branch : dev-css-refactor
This commit is contained in:
@@ -89,6 +89,14 @@ class EE_API StyleSheetProperty {
|
||||
|
||||
BlendMode asBlendMode() const;
|
||||
|
||||
Vector2f asDpDimensionVector2f( const Vector2f& defaultValue = Vector2f::Zero ) const;
|
||||
|
||||
Vector2i asDpDimensionVector2i( const Vector2i& defaultValue = Vector2i::Zero ) const;
|
||||
|
||||
Vector2f asDpDimensionSizef( const Sizef& defaultValue = Sizef::Zero ) const;
|
||||
|
||||
Vector2i asDpDimensionSizei( const Sizei& defaultValue = Sizei::Zero ) const;
|
||||
|
||||
Vector2f asVector2f( const Vector2f& defaultValue = Vector2f::Zero ) const;
|
||||
|
||||
Vector2i asVector2i( const Vector2i& defaultValue = Vector2i::Zero ) const;
|
||||
|
||||
@@ -49,6 +49,8 @@ class EE_API UIPushButton : public UIWidget {
|
||||
void setStyleConfig(const StyleConfig & styleConfig);
|
||||
|
||||
virtual bool applyProperty( const StyleSheetProperty& attribute );
|
||||
|
||||
virtual std::string getPropertyString(const PropertyDefinition* propertyDef);
|
||||
protected:
|
||||
StyleConfig mStyleConfig;
|
||||
UIImage * mIcon;
|
||||
|
||||
@@ -33,6 +33,8 @@ class EE_API UIRadioButton : public UITextView {
|
||||
void setTextSeparation(const Int32 & textSeparation);
|
||||
|
||||
virtual bool applyProperty( const StyleSheetProperty& attribute );
|
||||
|
||||
virtual std::string getPropertyString(const PropertyDefinition* propertyDef);
|
||||
protected:
|
||||
UINode * mActiveButton;
|
||||
UINode * mInactiveButton;
|
||||
|
||||
@@ -70,6 +70,8 @@ class EE_API UIScrollBar : public UIWidget {
|
||||
void setExpandBackground( bool expandBackground );
|
||||
|
||||
virtual bool applyProperty( const StyleSheetProperty& attribute );
|
||||
|
||||
virtual std::string getPropertyString(const PropertyDefinition* propertyDef);
|
||||
protected:
|
||||
ScrollBarType mScrollBarType;
|
||||
UISlider * mSlider;
|
||||
|
||||
@@ -41,6 +41,8 @@ class EE_API UIScrollView : public UITouchDragableWidget {
|
||||
UIWidget * getContainer() const;
|
||||
|
||||
virtual bool applyProperty( const StyleSheetProperty& attribute );
|
||||
|
||||
virtual std::string getPropertyString(const PropertyDefinition* propertyDef);
|
||||
protected:
|
||||
ScrollViewType mViewType;
|
||||
UI_SCROLLBAR_MODE mVScrollMode;
|
||||
|
||||
@@ -67,6 +67,8 @@ class EE_API UISlider : public UIWidget {
|
||||
|
||||
virtual bool applyProperty( const StyleSheetProperty& attribute );
|
||||
|
||||
virtual std::string getPropertyString(const PropertyDefinition* propertyDef);
|
||||
|
||||
Sizef getMinimumSize();
|
||||
protected:
|
||||
UI_ORIENTATION mOrientation;
|
||||
|
||||
@@ -55,6 +55,8 @@ class EE_API UISpinBox : public UIWidget {
|
||||
bool dotsInNumbersAllowed();
|
||||
|
||||
virtual bool applyProperty( const StyleSheetProperty& attribute );
|
||||
|
||||
virtual std::string getPropertyString(const PropertyDefinition* propertyDef);
|
||||
protected:
|
||||
UITextInput * mInput;
|
||||
UINode * mPushUp;
|
||||
|
||||
@@ -47,6 +47,8 @@ class EE_API UISprite : public UIWidget {
|
||||
bool getDeallocSprite();
|
||||
|
||||
virtual bool applyProperty( const StyleSheetProperty& attribute );
|
||||
|
||||
virtual std::string getPropertyString(const PropertyDefinition* propertyDef);
|
||||
protected:
|
||||
Graphics::Sprite * mSprite;
|
||||
RenderMode mRender;
|
||||
|
||||
@@ -30,6 +30,8 @@ class EE_API UITab : public UISelectButton {
|
||||
virtual UIPushButton * setText( const String& text );
|
||||
|
||||
virtual bool applyProperty( const StyleSheetProperty& attribute );
|
||||
|
||||
virtual std::string getPropertyString( const PropertyDefinition* propertyDef );
|
||||
protected:
|
||||
Node * mControlOwned;
|
||||
std::string mOwnedName;
|
||||
|
||||
@@ -78,6 +78,8 @@ class EE_API UITable : public UITouchDragableWidget {
|
||||
Rectf getContainerPadding() const;
|
||||
|
||||
virtual bool applyProperty( const StyleSheetProperty& attribute );
|
||||
|
||||
virtual std::string getPropertyString(const PropertyDefinition* propertyDef);
|
||||
protected:
|
||||
friend class UIItemContainer<UITable>;
|
||||
friend class UITableCell;
|
||||
|
||||
@@ -111,6 +111,8 @@ class EE_API UITabWidget : public UIWidget {
|
||||
void setStyleConfig(const StyleConfig & styleConfig);
|
||||
|
||||
virtual bool applyProperty( const StyleSheetProperty& attribute );
|
||||
|
||||
virtual std::string getPropertyString(const PropertyDefinition* propertyDef);
|
||||
protected:
|
||||
friend class UITab;
|
||||
|
||||
|
||||
@@ -46,6 +46,8 @@ class EE_API UITextEdit : public UIWidget {
|
||||
UIFontStyleConfig getFontStyleConfig() const;
|
||||
|
||||
virtual bool applyProperty( const StyleSheetProperty& attribute );
|
||||
|
||||
virtual std::string getPropertyString(const PropertyDefinition* propertyDef);
|
||||
protected:
|
||||
UITextInput * mTextInput;
|
||||
UIScrollBar * mHScrollBar;
|
||||
|
||||
@@ -35,7 +35,7 @@ class EE_API UITextInput : public UITextView {
|
||||
|
||||
UITextInput * setAllowEditing( const bool& allow );
|
||||
|
||||
const bool& getAllowEditing() const;
|
||||
const bool& isEditingAllowed() const;
|
||||
|
||||
virtual const String& getText();
|
||||
|
||||
@@ -53,6 +53,8 @@ class EE_API UITextInput : public UITextView {
|
||||
|
||||
virtual bool applyProperty( const StyleSheetProperty& attribute );
|
||||
|
||||
virtual std::string getPropertyString(const PropertyDefinition* propertyDef);
|
||||
|
||||
virtual UIWidget * setPadding(const Rectf& padding);
|
||||
protected:
|
||||
InputTextBuffer mTextBuffer;
|
||||
|
||||
@@ -44,6 +44,8 @@ class EE_API UITextureRegion : public UIWidget {
|
||||
UITextureRegion * setScaleType(const Uint32 & scaleType);
|
||||
|
||||
virtual bool applyProperty( const StyleSheetProperty& attribute );
|
||||
|
||||
virtual std::string getPropertyString(const PropertyDefinition* propertyDef);
|
||||
protected:
|
||||
Uint32 mScaleType;
|
||||
Graphics::TextureRegion * mTextureRegion;
|
||||
|
||||
@@ -92,6 +92,8 @@ class EE_API UITooltip : public UIWidget {
|
||||
UITooltip * setOutlineColor( const Color& outlineColor );
|
||||
|
||||
virtual bool applyProperty( const StyleSheetProperty& attribute );
|
||||
|
||||
virtual std::string getPropertyString(const PropertyDefinition* propertyDef);
|
||||
protected:
|
||||
Text * mTextCache;
|
||||
UIFontStyleConfig mStyleConfig;
|
||||
|
||||
@@ -8,7 +8,7 @@ namespace EE { namespace UI {
|
||||
class EE_API UITouchDragableWidget : public UIWidget {
|
||||
public:
|
||||
static UITouchDragableWidget * New();
|
||||
|
||||
|
||||
UITouchDragableWidget();
|
||||
|
||||
~UITouchDragableWidget();
|
||||
@@ -30,6 +30,8 @@ class EE_API UITouchDragableWidget : public UIWidget {
|
||||
UITouchDragableWidget * setTouchDragDeceleration( const Vector2f& touchDragDeceleration );
|
||||
|
||||
virtual bool applyProperty( const StyleSheetProperty& attribute );
|
||||
|
||||
virtual std::string getPropertyString(const PropertyDefinition* propertyDef);
|
||||
protected:
|
||||
Vector2f mTouchDragPoint;
|
||||
Vector2f mTouchDragAcceleration;
|
||||
|
||||
@@ -140,6 +140,10 @@ class EE_API UIWindow : public UIWidget {
|
||||
FrameBuffer * getFrameBuffer() const;
|
||||
|
||||
virtual bool isDrawInvalidator() const;
|
||||
|
||||
virtual std::string getPropertyString(const PropertyDefinition* propertyDef);
|
||||
|
||||
std::string getWindowFlagsString();
|
||||
protected:
|
||||
class KeyboardShortcut {
|
||||
public:
|
||||
|
||||
@@ -61,6 +61,8 @@ class EE_API UIWinMenu : public UIWidget {
|
||||
virtual bool applyProperty( const StyleSheetProperty& attribute );
|
||||
|
||||
virtual void loadFromXmlNode( const pugi::xml_node& node );
|
||||
|
||||
virtual std::string getPropertyString(const PropertyDefinition* propertyDef);
|
||||
protected:
|
||||
typedef std::list< std::pair< UISelectButton *, UIPopUpMenu * > > WinMenuList;
|
||||
|
||||
|
||||
@@ -237,6 +237,39 @@ BlendMode StyleSheetProperty::asBlendMode() const {
|
||||
return toBlendMode( mValue );
|
||||
}
|
||||
|
||||
Vector2f StyleSheetProperty::asDpDimensionVector2f( const Vector2f& defaultValue ) const {
|
||||
if ( !mValue.empty() ) {
|
||||
Vector2f vector;
|
||||
auto xySplit = String::split( mValue, ',', true );
|
||||
|
||||
if ( xySplit.size() == 2 ) {
|
||||
vector.x = PixelDensity::toDpFromString("0");
|
||||
vector.y = PixelDensity::toDpFromString("0");
|
||||
return vector;
|
||||
} else if ( xySplit.size() == 1 ) {
|
||||
vector.x = vector.y = PixelDensity::toDpFromString("0");
|
||||
return vector;
|
||||
}
|
||||
}
|
||||
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
Vector2i StyleSheetProperty::asDpDimensionVector2i( const Vector2i& defaultValue ) const {
|
||||
Vector2f v( asDpDimensionVector2f( Vector2f( defaultValue.x, defaultValue.y ) ) );
|
||||
return Vector2i( v.x, v.y );
|
||||
}
|
||||
|
||||
Vector2f StyleSheetProperty::asDpDimensionSizef( const Sizef& defaultValue ) const {
|
||||
Vector2f v( asDpDimensionVector2f( defaultValue ) );
|
||||
return Sizef( v.x, v.y );
|
||||
}
|
||||
|
||||
Vector2i StyleSheetProperty::asDpDimensionSizei( const Sizei& defaultValue ) const {
|
||||
Vector2i v( asDpDimensionVector2i( defaultValue ) );
|
||||
return Sizei( v.x, v.y );
|
||||
}
|
||||
|
||||
Vector2f StyleSheetProperty::asVector2f( const Vector2f& defaultValue ) const {
|
||||
if ( !mValue.empty() ) {
|
||||
Vector2f vector;
|
||||
|
||||
@@ -218,8 +218,13 @@ std::string UIImage::getPropertyString( const PropertyDefinition* propertyDef )
|
||||
if ( NULL == propertyDef )
|
||||
return "";
|
||||
|
||||
// TODO: Implement src and icon.
|
||||
switch ( propertyDef->getPropertyId() ) {
|
||||
case PropertyId::Src:
|
||||
// TODO: Implement src.
|
||||
return "";
|
||||
case PropertyId::Icon:
|
||||
// TODO: Implement icon.
|
||||
return "";
|
||||
case PropertyId::ScaleType:
|
||||
return getScaleType() == UIScaleType::FitInside
|
||||
? "fit-inside"
|
||||
|
||||
@@ -284,6 +284,27 @@ void UIPushButton::setStyleConfig(const StyleConfig & styleConfig) {
|
||||
onStateChange();
|
||||
}
|
||||
|
||||
std::string UIPushButton::getPropertyString( const PropertyDefinition* propertyDef ) {
|
||||
if ( NULL == propertyDef ) return "";
|
||||
|
||||
switch ( propertyDef->getPropertyId() ) {
|
||||
case PropertyId::Text:
|
||||
return getText().toUtf8();
|
||||
case PropertyId::Icon:
|
||||
// TODO: Implement icon
|
||||
return "";
|
||||
case PropertyId::MinIconSize:
|
||||
return String::format( "%ddp", mStyleConfig.IconMinSize.getWidth() ) + ", " +
|
||||
String::format( "%ddp", mStyleConfig.IconMinSize.getHeight() );
|
||||
case PropertyId::IconHorizontalMargin:
|
||||
return String::format( "%ddp", mStyleConfig.IconHorizontalMargin );
|
||||
case PropertyId::IconAutoMargin:
|
||||
return mStyleConfig.IconAutoMargin ? "true" : "false";
|
||||
default:
|
||||
return UIWidget::getPropertyString( propertyDef );
|
||||
}
|
||||
}
|
||||
|
||||
bool UIPushButton::applyProperty( const StyleSheetProperty& attribute ) {
|
||||
bool attributeSet = true;
|
||||
|
||||
|
||||
@@ -264,6 +264,18 @@ void UIRadioButton::setTextSeparation(const Int32 & textSeparation) {
|
||||
setPadding( getPadding() );
|
||||
}
|
||||
|
||||
std::string UIRadioButton::getPropertyString( const PropertyDefinition* propertyDef ) {
|
||||
if ( NULL == propertyDef ) return "";
|
||||
|
||||
switch ( propertyDef->getPropertyId() ) {
|
||||
case PropertyId::Selected:
|
||||
return isActive() ? "true" : "false";
|
||||
break;
|
||||
default:
|
||||
return UITextView::getPropertyString( propertyDef );
|
||||
}
|
||||
}
|
||||
|
||||
bool UIRadioButton::applyProperty( const StyleSheetProperty& attribute ) {
|
||||
if ( !checkPropertyDefinition( attribute ) ) return false;
|
||||
|
||||
|
||||
@@ -305,6 +305,31 @@ void UIScrollBar::setExpandBackground( bool expandBackground ) {
|
||||
}
|
||||
}
|
||||
|
||||
std::string UIScrollBar::getPropertyString( const PropertyDefinition* propertyDef ) {
|
||||
if ( NULL == propertyDef ) return "";
|
||||
|
||||
switch ( propertyDef->getPropertyId() ) {
|
||||
case PropertyId::Orientation:
|
||||
return getOrientation() == UI_HORIZONTAL ? "horizontal" : "vertical";
|
||||
case PropertyId::MinValue:
|
||||
return String::fromFloat( getMinValue() );
|
||||
case PropertyId::MaxValue:
|
||||
return String::fromFloat( getMaxValue() );
|
||||
case PropertyId::Value:
|
||||
return String::fromFloat( getValue() );
|
||||
case PropertyId::ClickStep:
|
||||
return String::fromFloat( getClickStep() );
|
||||
case PropertyId::PageStep:
|
||||
return String::fromFloat( getPageStep() );
|
||||
case PropertyId::ScrollBarType:
|
||||
return getScrollBarType() == NoButtons ? "no-buttons" : "two-buttons";
|
||||
case PropertyId::BackgroundExpand:
|
||||
return getExpandBackground() ? "true" : "false";
|
||||
default:
|
||||
return UIWidget::getPropertyString( propertyDef );
|
||||
}
|
||||
}
|
||||
|
||||
bool UIScrollBar::applyProperty( const StyleSheetProperty& attribute ) {
|
||||
if ( !checkPropertyDefinition( attribute ) ) return false;
|
||||
|
||||
|
||||
@@ -241,6 +241,28 @@ bool UIScrollView::isTouchOverAllowedChilds() {
|
||||
return isMouseOverMeOrChilds() && mScrollView->isMouseOverMeOrChilds() && ret;
|
||||
}
|
||||
|
||||
std::string UIScrollView::getPropertyString( const PropertyDefinition* propertyDef ) {
|
||||
if ( NULL == propertyDef ) return "";
|
||||
|
||||
switch ( propertyDef->getPropertyId() ) {
|
||||
case PropertyId::VScrollMode:
|
||||
return getVerticalScrollMode() == UI_SCROLLBAR_AUTO ? "auto" : (
|
||||
getVerticalScrollMode() == UI_SCROLLBAR_ALWAYS_ON ? "on" : "off"
|
||||
);
|
||||
case PropertyId::HScrollMode:
|
||||
return getHorizontalScrollMode() == UI_SCROLLBAR_AUTO ? "auto" : (
|
||||
getHorizontalScrollMode() == UI_SCROLLBAR_ALWAYS_ON ? "on" : "off"
|
||||
);
|
||||
case PropertyId::ScrollBarType:
|
||||
return mVScroll->getScrollBarType() == UIScrollBar::NoButtons ? "no-buttons" :
|
||||
"two-buttons";
|
||||
case PropertyId::ScrollBarMode:
|
||||
return getViewType() == Inclusive ? "inclusive" : "exclusive";
|
||||
default:
|
||||
return UITouchDragableWidget::getPropertyString( propertyDef );
|
||||
}
|
||||
}
|
||||
|
||||
bool UIScrollView::applyProperty( const StyleSheetProperty& attribute ) {
|
||||
if ( !checkPropertyDefinition( attribute ) ) return false;
|
||||
|
||||
|
||||
@@ -436,6 +436,31 @@ Uint32 UISlider::onMessage(const NodeMessage * Msg) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
std::string UISlider::getPropertyString( const PropertyDefinition* propertyDef ) {
|
||||
if ( NULL == propertyDef ) return "";
|
||||
|
||||
switch ( propertyDef->getPropertyId() ) {
|
||||
case PropertyId::Orientation:
|
||||
return getOrientation() == UI_HORIZONTAL ? "horizontal" : "vertical";
|
||||
case PropertyId::MinValue:
|
||||
return String::fromFloat( getMinValue() );
|
||||
case PropertyId::MaxValue:
|
||||
return String::fromFloat( getMaxValue() );
|
||||
case PropertyId::Value:
|
||||
return String::fromFloat( getValue() );
|
||||
case PropertyId::ClickStep:
|
||||
return String::fromFloat( getClickStep() );
|
||||
case PropertyId::PageStep:
|
||||
return String::fromFloat( getPageStep() );
|
||||
case PropertyId::HalfSlider:
|
||||
return getAllowHalfSliderOut() ? "true" : "false";
|
||||
case PropertyId::BackgroundExpand:
|
||||
return getExpandBackground() ? "true" : "false";
|
||||
default:
|
||||
return UIWidget::getPropertyString( propertyDef );
|
||||
}
|
||||
}
|
||||
|
||||
bool UISlider::applyProperty( const StyleSheetProperty& attribute ) {
|
||||
if ( !checkPropertyDefinition( attribute ) ) return false;
|
||||
|
||||
|
||||
@@ -270,6 +270,23 @@ void UISpinBox::onPaddingChange() {
|
||||
UIWidget::onPaddingChange();
|
||||
}
|
||||
|
||||
std::string UISpinBox::getPropertyString( const PropertyDefinition* propertyDef ) {
|
||||
if ( NULL == propertyDef ) return "";
|
||||
|
||||
switch ( propertyDef->getPropertyId() ) {
|
||||
case PropertyId::MinValue:
|
||||
return String::fromFloat( getMinValue() );
|
||||
case PropertyId::MaxValue:
|
||||
return String::fromFloat( getMaxValue() );
|
||||
case PropertyId::Value:
|
||||
return String::fromFloat( getValue() );
|
||||
case PropertyId::ClickStep:
|
||||
return String::fromFloat( getClickStep() );
|
||||
default:
|
||||
return UIWidget::getPropertyString( propertyDef );
|
||||
}
|
||||
}
|
||||
|
||||
bool UISpinBox::applyProperty( const StyleSheetProperty& attribute ) {
|
||||
if ( !checkPropertyDefinition( attribute ) ) return false;
|
||||
|
||||
|
||||
@@ -185,6 +185,18 @@ void UISprite::onSizeChange() {
|
||||
UIWidget::onSizeChange();
|
||||
}
|
||||
|
||||
std::string UISprite::getPropertyString( const PropertyDefinition* propertyDef ) {
|
||||
if ( NULL == propertyDef ) return "";
|
||||
|
||||
switch ( propertyDef->getPropertyId() ) {
|
||||
case PropertyId::Src:
|
||||
// TODO: Implement src
|
||||
return "";
|
||||
default:
|
||||
return UIWidget::getPropertyString( propertyDef );
|
||||
}
|
||||
}
|
||||
|
||||
bool UISprite::applyProperty( const StyleSheetProperty& attribute ) {
|
||||
if ( !checkPropertyDefinition( attribute ) ) return false;
|
||||
|
||||
|
||||
@@ -144,6 +144,20 @@ void UITab::onAutoSize() {
|
||||
}
|
||||
}
|
||||
|
||||
std::string UITab::getPropertyString( const PropertyDefinition* propertyDef ) {
|
||||
if ( NULL == propertyDef ) return "";
|
||||
|
||||
switch ( propertyDef->getPropertyId() ) {
|
||||
case PropertyId::Text:
|
||||
case PropertyId::Name:
|
||||
return getText().toUtf8();
|
||||
case PropertyId::Owns:
|
||||
return mOwnedName;
|
||||
default:
|
||||
return UISelectButton::getPropertyString( propertyDef );
|
||||
}
|
||||
}
|
||||
|
||||
bool UITab::applyProperty( const StyleSheetProperty& attribute ) {
|
||||
if ( !checkPropertyDefinition( attribute ) ) return false;
|
||||
|
||||
|
||||
@@ -623,6 +623,28 @@ bool UITable::isTouchOverAllowedChilds() {
|
||||
return isMouseOverMeOrChilds() && !mVScrollBar->isMouseOverMeOrChilds() && !mHScrollBar->isMouseOverMeOrChilds();
|
||||
}
|
||||
|
||||
std::string UITable::getPropertyString( const PropertyDefinition* propertyDef ) {
|
||||
if ( NULL == propertyDef ) return "";
|
||||
|
||||
switch ( propertyDef->getPropertyId() ) {
|
||||
case PropertyId::RowHeight:
|
||||
return String::format( "%ddp", getRowHeight() );
|
||||
case PropertyId::VScrollMode:
|
||||
return getVerticalScrollMode() == UI_SCROLLBAR_AUTO ? "auto" : (
|
||||
getVerticalScrollMode() == UI_SCROLLBAR_ALWAYS_ON ? "on" : "off"
|
||||
);
|
||||
case PropertyId::HScrollMode:
|
||||
return getHorizontalScrollMode() == UI_SCROLLBAR_AUTO ? "auto" : (
|
||||
getHorizontalScrollMode() == UI_SCROLLBAR_ALWAYS_ON ? "on" : "off"
|
||||
);
|
||||
case PropertyId::ScrollBarType:
|
||||
return mVScrollBar->getScrollBarType() == UIScrollBar::NoButtons ? "no-buttons" :
|
||||
"two-buttons";
|
||||
default:
|
||||
return UITouchDragableWidget::getPropertyString( propertyDef );
|
||||
}
|
||||
}
|
||||
|
||||
bool UITable::applyProperty( const StyleSheetProperty& attribute ) {
|
||||
if ( !checkPropertyDefinition( attribute ) ) return false;
|
||||
|
||||
|
||||
@@ -119,21 +119,45 @@ void UITabWidget::setStyleConfig(const StyleConfig & styleConfig) {
|
||||
orderTabs();
|
||||
}
|
||||
|
||||
bool UITabWidget::applyProperty( const StyleSheetProperty& attribute ) {
|
||||
if ( attribute.getPropertyDefinition() == NULL ) {
|
||||
eePRINTL( "applyProperty: Property %s not defined!", attribute.getName().c_str() );
|
||||
return false;
|
||||
std::string UITabWidget::getPropertyString( const PropertyDefinition* propertyDef ) {
|
||||
if ( NULL == propertyDef ) return "";
|
||||
|
||||
switch ( propertyDef->getPropertyId() ) {
|
||||
case PropertyId::MaxTextLength:
|
||||
return String::toStr( getMaxTextLength() );
|
||||
case PropertyId::MinTabWidth:
|
||||
return String::format( "%ddp", getMinTabWidth() );
|
||||
case PropertyId::MaxTabWidth:
|
||||
return String::format( "%ddp", getMaxTabWidth() );
|
||||
case PropertyId::TabClosable:
|
||||
return getTabsClosable() ? "true" : "false";
|
||||
case PropertyId::SpecialBorderTabs:
|
||||
return getSpecialBorderTabs() ? "true" : "false";
|
||||
case PropertyId::LineBelowTabs:
|
||||
return getDrawLineBelowTabs() ? "true" : "false";
|
||||
case PropertyId::LineBelowTabsColor:
|
||||
return getLineBelowTabsColor().toHexString();
|
||||
case PropertyId::LineBelowTabsYOffset:
|
||||
return String::format( "%ddp", getLineBelowTabsYOffset() );
|
||||
case PropertyId::TabSeparation:
|
||||
return String::format( "%ddp", getTabSeparation() );
|
||||
default:
|
||||
return UIWidget::getPropertyString( propertyDef );
|
||||
}
|
||||
}
|
||||
|
||||
bool UITabWidget::applyProperty( const StyleSheetProperty& attribute ) {
|
||||
if ( !checkPropertyDefinition( attribute ) ) return false;
|
||||
|
||||
switch ( attribute.getPropertyDefinition()->getPropertyId() ) {
|
||||
case PropertyId::MaxTextLength:
|
||||
setMaxTextLength( attribute.asUint(1) );
|
||||
break;
|
||||
case PropertyId::MinTabWidth:
|
||||
setMinTabWidth( attribute.asUint(1) );
|
||||
setMinTabWidth( attribute.asDpDimensionUint("1") );
|
||||
break;
|
||||
case PropertyId::MaxTabWidth:
|
||||
setMaxTabWidth( attribute.asUint() );
|
||||
setMaxTabWidth( attribute.asDpDimensionUint() );
|
||||
break;
|
||||
case PropertyId::TabClosable:
|
||||
setTabsClosable( attribute.asBool() );
|
||||
|
||||
@@ -443,7 +443,7 @@ void UITextEdit::setAllowEditing( const bool& allow ) {
|
||||
}
|
||||
|
||||
const bool& UITextEdit::isEditingAllowed() const {
|
||||
return mTextInput->getAllowEditing();
|
||||
return mTextInput->isEditingAllowed();
|
||||
}
|
||||
|
||||
void UITextEdit::setVerticalScrollMode( const UI_SCROLLBAR_MODE& Mode ) {
|
||||
@@ -474,6 +474,27 @@ UIFontStyleConfig UITextEdit::getFontStyleConfig() const {
|
||||
return mTextInput->getFontStyleConfig();
|
||||
}
|
||||
|
||||
std::string UITextEdit::getPropertyString( const PropertyDefinition* propertyDef ) {
|
||||
if ( NULL == propertyDef ) return "";
|
||||
|
||||
switch ( propertyDef->getPropertyId() ) {
|
||||
case PropertyId::Text:
|
||||
return getText().toUtf8();
|
||||
case PropertyId::AllowEditing:
|
||||
return isEditingAllowed() ? "true" : "false";
|
||||
case PropertyId::VScrollMode:
|
||||
return getVerticalScrollMode() == UI_SCROLLBAR_AUTO ? "auto" : (
|
||||
getVerticalScrollMode() == UI_SCROLLBAR_ALWAYS_ON ? "on" : "off"
|
||||
);
|
||||
case PropertyId::HScrollMode:
|
||||
return getHorizontalScrollMode() == UI_SCROLLBAR_AUTO ? "auto" : (
|
||||
getHorizontalScrollMode() == UI_SCROLLBAR_ALWAYS_ON ? "on" : "off"
|
||||
);
|
||||
default:
|
||||
return UIWidget::getPropertyString( propertyDef );
|
||||
}
|
||||
}
|
||||
|
||||
bool UITextEdit::applyProperty( const StyleSheetProperty& attribute ) {
|
||||
if ( !checkPropertyDefinition( attribute ) ) return false;
|
||||
|
||||
|
||||
@@ -220,7 +220,7 @@ UITextInput * UITextInput::setAllowEditing( const bool& allow ) {
|
||||
return this;
|
||||
}
|
||||
|
||||
const bool& UITextInput::getAllowEditing() const {
|
||||
const bool& UITextInput::isEditingAllowed() const {
|
||||
return mAllowEditing;
|
||||
}
|
||||
|
||||
@@ -393,6 +393,27 @@ bool UITextInput::isFreeEditingEnabled() {
|
||||
return mTextBuffer.isFreeEditingEnabled();
|
||||
}
|
||||
|
||||
std::string UITextInput::getPropertyString( const PropertyDefinition* propertyDef ) {
|
||||
if ( NULL == propertyDef ) return "";
|
||||
|
||||
switch ( propertyDef->getPropertyId() ) {
|
||||
case PropertyId::Text:
|
||||
return getText().toUtf8();
|
||||
case PropertyId::AllowEditing:
|
||||
return isEditingAllowed() ? "true" : "false";
|
||||
case PropertyId::MaxLength:
|
||||
return String::toStr( getMaxLength() );
|
||||
case PropertyId::FreeEditing:
|
||||
return isFreeEditingEnabled() ? "true" : "false";
|
||||
case PropertyId::OnlyNumbers:
|
||||
return getInputTextBuffer()->onlyNumbersAllowed() ? "true" : "false";
|
||||
case PropertyId::AllowDot:
|
||||
return getInputTextBuffer()->dotsInNumbersAllowed() ? "true" : "false";
|
||||
default:
|
||||
return UITextView::getPropertyString( propertyDef );
|
||||
}
|
||||
}
|
||||
|
||||
bool UITextInput::applyProperty( const StyleSheetProperty& attribute ) {
|
||||
if ( !checkPropertyDefinition( attribute ) ) return false;
|
||||
|
||||
|
||||
@@ -197,6 +197,25 @@ const Vector2f& UITextureRegion::getAlignOffset() const {
|
||||
return mAlignOffset;
|
||||
}
|
||||
|
||||
std::string UITextureRegion::getPropertyString( const PropertyDefinition* propertyDef ) {
|
||||
if ( NULL == propertyDef )
|
||||
return "";
|
||||
|
||||
switch ( propertyDef->getPropertyId() ) {
|
||||
case PropertyId::Src:
|
||||
// TODO: Implement src.
|
||||
return "";
|
||||
case PropertyId::ScaleType:
|
||||
return getScaleType() == UIScaleType::FitInside
|
||||
? "fit-inside"
|
||||
: ( getScaleType() == UIScaleType::Expand ? "expand" : "none" );
|
||||
case PropertyId::Tint:
|
||||
return getColor().toHexString();
|
||||
default:
|
||||
return UIWidget::getPropertyString( propertyDef );
|
||||
}
|
||||
}
|
||||
|
||||
bool UITextureRegion::applyProperty( const StyleSheetProperty& attribute ) {
|
||||
if ( !checkPropertyDefinition( attribute ) ) return false;
|
||||
|
||||
|
||||
@@ -633,6 +633,8 @@ std::string UITextView::getPropertyString( const PropertyDefinition* propertyDef
|
||||
if ( NULL == propertyDef ) return "";
|
||||
|
||||
switch ( propertyDef->getPropertyId() ) {
|
||||
case PropertyId::Text:
|
||||
return getText().toUtf8();
|
||||
case PropertyId::Color:
|
||||
return getFontColor().toHexString();
|
||||
case PropertyId::ShadowColor:
|
||||
@@ -651,6 +653,14 @@ std::string UITextView::getPropertyString( const PropertyDefinition* propertyDef
|
||||
return String::toStr( PixelDensity::dpToPx( getOutlineThickness() ) );
|
||||
case PropertyId::TextStrokeColor:
|
||||
return getOutlineColor().toHexString();
|
||||
case PropertyId::Wordwrap:
|
||||
return mFlags & UI_WORD_WRAP ? "true" : "false";
|
||||
case PropertyId::TextSelection:
|
||||
return isTextSelectionEnabled() ? "true" : "false";
|
||||
case PropertyId::TextAlign:
|
||||
return fontHAlignGet( getFlags() ) == UI_HALIGN_CENTER ? "center" : (
|
||||
fontHAlignGet( getFlags() ) == UI_HALIGN_RIGHT ? "right" : "left"
|
||||
);
|
||||
default:
|
||||
return UIWidget::getPropertyString( propertyDef );
|
||||
}
|
||||
|
||||
@@ -328,6 +328,33 @@ void UITooltip::setFontStyleConfig(const UIFontStyleConfig & styleConfig) {
|
||||
mTextCache->setOutlineColor( mStyleConfig.OutlineColor );
|
||||
}
|
||||
|
||||
std::string UITooltip::getPropertyString( const PropertyDefinition* propertyDef ) {
|
||||
if ( NULL == propertyDef ) return "";
|
||||
|
||||
switch ( propertyDef->getPropertyId() ) {
|
||||
case PropertyId::Color:
|
||||
return getFontColor().toHexString();
|
||||
case PropertyId::ShadowColor:
|
||||
return getFontShadowColor().toHexString();
|
||||
case PropertyId::FontFamily:
|
||||
return NULL != getFont() ? getFont()->getName() : "";
|
||||
case PropertyId::FontSize:
|
||||
return String::format( "%ddp", getCharacterSize() );
|
||||
case PropertyId::FontStyle:
|
||||
return Text::styleFlagToString( getFontStyle() );
|
||||
case PropertyId::TextStrokeWidth:
|
||||
return String::toStr( PixelDensity::dpToPx( getOutlineThickness() ) );
|
||||
case PropertyId::TextStrokeColor:
|
||||
return getOutlineColor().toHexString();
|
||||
case PropertyId::TextAlign:
|
||||
return fontHAlignGet( getFlags() ) == UI_HALIGN_CENTER ? "center" : (
|
||||
fontHAlignGet( getFlags() ) == UI_HALIGN_RIGHT ? "right" : "left"
|
||||
);
|
||||
default:
|
||||
return UIWidget::getPropertyString( propertyDef );
|
||||
}
|
||||
}
|
||||
|
||||
bool UITooltip::applyProperty( const StyleSheetProperty& attribute ) {
|
||||
if ( !checkPropertyDefinition( attribute ) ) return false;
|
||||
|
||||
|
||||
@@ -146,6 +146,20 @@ void UITouchDragableWidget::scheduledUpdate( const Time& time ) {
|
||||
}
|
||||
}
|
||||
|
||||
std::string UITouchDragableWidget::getPropertyString( const PropertyDefinition* propertyDef ) {
|
||||
if ( NULL == propertyDef ) return "";
|
||||
|
||||
switch ( propertyDef->getPropertyId() ) {
|
||||
case PropertyId::TouchDrag:
|
||||
return isTouchDragEnabled() ? "true" : "false";
|
||||
case PropertyId::TouchDragDeceleration:
|
||||
return String::fromFloat( getTouchDragDeceleration().x ) + ", " +
|
||||
String::fromFloat( getTouchDragDeceleration().y );
|
||||
default:
|
||||
return UIWidget::getPropertyString( propertyDef );
|
||||
}
|
||||
}
|
||||
|
||||
bool UITouchDragableWidget::applyProperty( const StyleSheetProperty& attribute ) {
|
||||
if ( !checkPropertyDefinition( attribute ) ) return false;
|
||||
|
||||
|
||||
@@ -1379,6 +1379,62 @@ void UIWindow::resizeCursor() {
|
||||
}
|
||||
}
|
||||
|
||||
std::string UIWindow::getWindowFlagsString() {
|
||||
std::vector<std::string> flags;
|
||||
if ( getWinFlags() & UI_WIN_DEFAULT_FLAGS) flags.push_back( "default" );
|
||||
if ( getWinFlags() & UI_WIN_CLOSE_BUTTON ) flags.push_back( "close" );
|
||||
if ( getWinFlags() & UI_WIN_MAXIMIZE_BUTTON ) flags.push_back( "maximize" );
|
||||
if ( getWinFlags() & UI_WIN_DRAGABLE_CONTAINER ) flags.push_back( "dragable" );
|
||||
if ( getWinFlags() & UI_WIN_SHADOW ) flags.push_back( "shadow" );
|
||||
if ( getWinFlags() & UI_WIN_MODAL ) flags.push_back( "modal" );
|
||||
if ( getWinFlags() & UI_WIN_NO_DECORATION ) flags.push_back( "borderless" );
|
||||
if ( getWinFlags() & UI_WIN_RESIZEABLE ) flags.push_back( "resizeable" );
|
||||
if ( getWinFlags() & UI_WIN_SHARE_ALPHA_WITH_CHILDS ) flags.push_back( "sharealpha" );
|
||||
if ( getWinFlags() & UI_WIN_USE_DEFAULT_BUTTONS_ACTIONS ) flags.push_back( "buttonactions" );
|
||||
if ( getWinFlags() & UI_WIN_FRAME_BUFFER ) flags.push_back( "framebuffer" );
|
||||
if ( getWinFlags() & UI_WIN_COLOR_BUFFER ) flags.push_back( "colorbuffer" );
|
||||
return String::join( flags, '|' );
|
||||
}
|
||||
|
||||
std::string UIWindow::getPropertyString( const PropertyDefinition* propertyDef ) {
|
||||
if ( NULL == propertyDef ) return "";
|
||||
|
||||
switch ( propertyDef->getPropertyId() ) {
|
||||
case PropertyId::Width:
|
||||
return String::fromFloat( getSize().getWidth(), "dp" );
|
||||
case PropertyId::Height:
|
||||
return String::fromFloat( getSize().getHeight(), "dp" );
|
||||
case PropertyId::Title:
|
||||
return getTitle().toUtf8();
|
||||
case PropertyId::BaseAlpha:
|
||||
return String::toStr( getBaseAlpha() );
|
||||
case PropertyId::ButtonsPositionOffset:
|
||||
return String::format( "%ddp", mStyleConfig.ButtonsPositionFixer.x ) + ", " +
|
||||
String::format( "%ddp", mStyleConfig.ButtonsPositionFixer.y );
|
||||
case PropertyId::WindowFlags:
|
||||
return getWindowFlagsString();
|
||||
case PropertyId::DecorationSize:
|
||||
return String::format( "%ddp", mStyleConfig.DecorationSize.x ) + ", " +
|
||||
String::format( "%ddp", mStyleConfig.DecorationSize.y );
|
||||
case PropertyId::BorderSize:
|
||||
return String::format( "%ddp", mStyleConfig.BorderSize.x ) + ", " +
|
||||
String::format( "%ddp", mStyleConfig.BorderSize.y );
|
||||
case PropertyId::MinWindowSize:
|
||||
return String::fromFloat( mStyleConfig.MinWindowSize.x, "dp" ) + ", " +
|
||||
String::fromFloat( mStyleConfig.MinWindowSize.y, "dp" );
|
||||
case PropertyId::ButtonsSeparation:
|
||||
return String::format( "%ddp", mStyleConfig.ButtonsSeparation );
|
||||
case PropertyId::MinCornerDistance:
|
||||
return String::format( "%ddp", mStyleConfig.MinCornerDistance );
|
||||
case PropertyId::DecorationAutoSize:
|
||||
return mStyleConfig.DecorationAutoSize ? "true" : "false";
|
||||
case PropertyId::BorderAutoSize:
|
||||
return mStyleConfig.BorderAutoSize ? "true" : "false";
|
||||
default:
|
||||
return UIWidget::getPropertyString( propertyDef );
|
||||
}
|
||||
}
|
||||
|
||||
bool UIWindow::applyProperty( const StyleSheetProperty& attribute ) {
|
||||
if ( !checkPropertyDefinition( attribute ) ) return false;
|
||||
|
||||
@@ -1396,7 +1452,7 @@ bool UIWindow::applyProperty( const StyleSheetProperty& attribute ) {
|
||||
setBaseAlpha( (Uint8)eemin( attribute.asUint(), 255u ) );
|
||||
break;
|
||||
case PropertyId::ButtonsPositionOffset:
|
||||
mStyleConfig.ButtonsPositionFixer = attribute.asVector2i();
|
||||
mStyleConfig.ButtonsPositionFixer = attribute.asDpDimensionVector2i();
|
||||
fixChildsSize();
|
||||
break;
|
||||
case PropertyId::WindowFlags:
|
||||
@@ -1432,15 +1488,15 @@ bool UIWindow::applyProperty( const StyleSheetProperty& attribute ) {
|
||||
break;
|
||||
}
|
||||
case PropertyId::DecorationSize:
|
||||
mStyleConfig.DecorationSize = attribute.asSizei();
|
||||
mStyleConfig.DecorationSize = attribute.asDpDimensionSizei();
|
||||
fixChildsSize();
|
||||
break;
|
||||
case PropertyId::BorderSize:
|
||||
mStyleConfig.BorderSize = attribute.asSizei();
|
||||
mStyleConfig.BorderSize = attribute.asDpDimensionSizei();
|
||||
fixChildsSize();
|
||||
break;
|
||||
case PropertyId::MinWindowSize:
|
||||
mStyleConfig.MinWindowSize = attribute.asSizef();
|
||||
mStyleConfig.MinWindowSize = attribute.asDpDimensionSizef();
|
||||
fixChildsSize();
|
||||
break;
|
||||
case PropertyId::ButtonsSeparation:
|
||||
|
||||
@@ -159,6 +159,23 @@ void UIWinMenu::setFirstButtonMargin( const Uint32& buttonMargin ) {
|
||||
refreshButtons();
|
||||
}
|
||||
|
||||
std::string UIWinMenu::getPropertyString( const PropertyDefinition* propertyDef ) {
|
||||
if ( NULL == propertyDef ) return "";
|
||||
|
||||
switch ( propertyDef->getPropertyId() ) {
|
||||
case PropertyId::MarginBetweenButtons:
|
||||
return String::format( "%ddp", getMarginBetweenButtons() );
|
||||
case PropertyId::ButtonMargin:
|
||||
return String::format( "%ddp", getButtonMargin() );
|
||||
case PropertyId::MenuHeight:
|
||||
return String::format( "%ddp", getMenuHeight() );
|
||||
case PropertyId::FirstButtonMarginLeft:
|
||||
return String::format( "%ddp", getFirstButtonMargin() );
|
||||
default:
|
||||
return UIWidget::getPropertyString( propertyDef );
|
||||
}
|
||||
}
|
||||
|
||||
bool UIWinMenu::applyProperty( const StyleSheetProperty& attribute ) {
|
||||
if ( !checkPropertyDefinition( attribute ) ) return false;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user