More WIP.

--HG--
branch : dev-css-refactor
This commit is contained in:
Martín Lucas Golini
2019-11-29 01:22:38 -03:00
parent f20f4beba4
commit 15c03441c7
30 changed files with 903 additions and 523 deletions

View File

@@ -96,14 +96,90 @@ enum class PropertyId : Uint32 {
Src = String::hash( "src" ),
ScaleType = String::hash( "scale-type" ),
Tint = String::hash( "tint" ),
// Possible shorthand
Background = String::hash( "background" ),
Foreground = String::hash( "foreground" ),
Padding = String::hash( "padding" ),
BackgroundPosition = String::hash( "background-position" ),
ForegroundPosition = String::hash( "foreground-position" ),
RotationOriginPoint = String::hash( "rotation-origin-point" ),
ScaleOriginPoint = String::hash( "scale-origin-point" )
ScaleOriginPoint = String::hash( "scale-origin-point" ),
MaxTextLength = String::hash( "max-text-length" ),
MinTabWidth = String::hash( "min-tab-width" ),
MaxTabWidth = String::hash( "max-tab-width" ),
TabClosable = String::hash( "tab-closable" ),
SpecialBorderTabs = String::hash( "special-border-tabs" ),
LineBelowTabs = String::hash( "line-below-tabs" ),
LineBelowTabsColor = String::hash( "line-below-tabs-color" ),
LineBelowTabsYOffset = String::hash( "line-below-tabs-y-offset" ),
TabSeparation = String::hash( "tax-separation" ),
Selected = String::hash( "selected" ),
PopUpToMainControl = String::hash( "popup-to-main-control" ),
MaxVisibleItems = String::hash( "max-visible-items" ),
SelectedIndex = String::hash( "selected-index" ),
SelectedText = String::hash( "selected-text" ),
ScrollBarType = String::hash( "scrollbar-type" ),
RowHeight = String::hash( "row-height" ),
VScrollMode = String::hash( "vscroll-mode" ),
HScrollMode = String::hash( "hscroll-mode" ),
ColumnSpan = String::hash( "column-span" ),
RowSpan = String::hash( "row-span" ),
Span = String::hash( "span" ),
ColumnMode = String::hash( "column-mode" ),
RowMode = String::hash( "row-mode" ),
ColumnWeight = String::hash( "column-weight" ),
ColumnHeight = String::hash( "column-height" ),
ColumnWidth = String::hash( "column-width" ),
RowWeight = String::hash( "row-weight" ),
ReverseDraw = String::hash( "reverse-draw" ),
Orientation = String::hash( "orientation" ),
Indeterminate = String::hash( "indeterminate" ),
MaxProgress = String::hash( "max-progress" ),
Progress = String::hash( "progress" ),
FillColor = String::hash( "fill-color" ),
Radius = String::hash( "radius" ),
OutlineThickness = String::hash( "outline-thickness" ),
AnimationSpeed = String::hash( "animation-speed" ),
ArcStartAngle = String::hash( "arc-start-angle" ),
MinWidth = String::hash( "min-width" ),
MinMarginRight = String::hash( "min-margin-right" ),
MinIconSpace = String::hash( "min-icon-space" ),
TotalSteps = String::hash( "total-steps" ),
VerticalExpand = String::hash( "vertical-expand" ),
DisplayPercent = String::hash( "display-percent" ),
FillerPaddingLeft = String::hash( "filler-padding-left" ),
FillerPaddingTop = String::hash( "filler-padding-top" ),
FillerPaddingRight = String::hash( "filler-padding-right" ),
FillerPaddingBottom = String::hash( "filler-padding-bottom" ),
MovementSpeed = String::hash( "movement-speed" ),
MinValue = String::hash( "min-value" ),
MaxValue = String::hash( "max-value" ),
Value = String::hash( "value" ),
ClickStep = String::hash( "click-step" ),
PageStep = String::hash( "page-step" ),
BackgroundExpand = String::hash( "background-expand" ),
ScrollBarMode = String::hash( "scrollbar-mode" ),
HalfSlider = String::hash( "half-slider" ),
Name = String::hash( "name" ),
Owns = String::hash( "owns" ),
AllowEditing = String::hash( "allow-editing" ),
MaxLength = String::hash( "max-length" ),
FreeEditing = String::hash( "free-editing" ),
OnlyNumbers = String::hash( "only-numbers" ),
AllowDot = String::hash( "allow-dot" ),
TouchDrag = String::hash( "touch-drag" ),
TouchDragDeceleration = String::hash( "touch-drag-deceleration" ),
Title = String::hash( "title" ),
BaseAlpha = String::hash( "base-alpha" ),
ButtonsPositionOffset = String::hash( "buttons-position-offset" ),
WindowFlags = String::hash( "window-flags" ),
DecorationSize = String::hash( "decoration-size" ),
BorderSize = String::hash( "border-size" ),
MinWindowSize = String::hash( "min-window-size" ),
ButtonsSeparation = String::hash( "buttons-separation" ),
MinCornerDistance = String::hash( "min-corner-distance" ),
DecorationAutoSize = String::hash( "decoration-auto-size" ),
BorderAutoSize = String::hash( "border-auto-size" ),
MarginBetweenButtons = String::hash( "margin-between-buttons" ),
ButtonMargin = String::hash( "button-margin" ),
MenuHeight = String::hash( "menu-height" ),
FirstButtonMarginLeft = String::hash( "first-button-margin-left" )
};
class EE_API PropertyDefinition {

View File

@@ -264,6 +264,8 @@ class EE_API UIWidget : public UINode, public CSS::StyleSheetElement {
UIWidget * querySelector( const CSS::StyleSheetSelector& selector );
std::vector<UIWidget*> querySelectorAll( const CSS::StyleSheetSelector& selector );
bool checkPropertyDefinition( const StyleSheetProperty& property );
};
}}

View File

@@ -135,13 +135,96 @@ void StyleSheetSpecification::registerDefaultProperties() {
registerProperty( "scale-type", "", false );
registerProperty( "tint", "", false );
registerProperty( "rotation-origin-point", "", false );
registerProperty( "max-text-length", "", false );
registerProperty( "min-tab-width", "", false );
registerProperty( "max-tab-width", "", false );
registerProperty( "tab-closable", "", false );
registerProperty( "special-border-tabs", "", false );
registerProperty( "line-below-tabs", "", false );
registerProperty( "line-below-tabs-color", "", false );
registerProperty( "line-below-tabs-y-offset", "", false );
registerProperty( "tab-separation", "", false );
registerProperty( "selected", "", false ).addAlias( "active" );
registerProperty( "popup-to-main-control", "", false );
registerProperty( "max-visible-items", "", false );
registerProperty( "selected-index", "", false );
registerProperty( "selected-text", "", false );
registerProperty( "scrollbar-type", "", false );
registerProperty( "row-height", "", false );
registerProperty( "vscroll-mode", "", false );
registerProperty( "hscroll-mode", "", false );
registerProperty( "column-span", "", false );
registerProperty( "row-span", "", false );
registerProperty( "span", "", false );
registerProperty( "column-mode", "", false );
registerProperty( "row-mode", "", false );
registerProperty( "column-weight", "", false );
registerProperty( "column-width", "", false );
registerProperty( "row-weight", "", false );
registerProperty( "reverse-draw", "", false );
registerProperty( "orientation", "", false );
registerProperty( "indeterminate", "", false );
registerProperty( "max-progress", "", false );
registerProperty( "progress", "", false );
registerProperty( "fill-color", "", false );
registerProperty( "radius", "", false );
registerProperty( "outline-thickness", "", false );
registerProperty( "animation-speed", "", false );
registerProperty( "arc-start-angle", "", false );
registerProperty( "min-width", "", false );
registerProperty( "min-margin-right", "", false );
registerProperty( "min-icon-space", "", false );
registerProperty( "total-steps", "", false );
registerProperty( "vertical-expand", "", false );
registerProperty( "display-percent", "", false );
registerProperty( "filler-padding-left", "", false );
registerProperty( "filler-padding-top", "", false );
registerProperty( "filler-padding-right", "", false );
registerProperty( "filler-padding-bottom", "", false );
registerProperty( "movement-speed", "", false );
registerProperty( "min-value", "", false );
registerProperty( "max-value", "", false );
registerProperty( "value", "", false );
registerProperty( "click-step", "", false );
registerProperty( "page-step", "", false );
registerProperty( "background-expand", "", false );
registerProperty( "scrollbar-mode", "", false );
registerProperty( "half-slider", "", false );
registerProperty( "name", "", false );
registerProperty( "owns", "", false );
registerProperty( "allow-editing", "", false );
registerProperty( "max-length", "", false );
registerProperty( "free-editing", "", false );
registerProperty( "only-numbers", "", false );
registerProperty( "allow-dot", "", false );
registerProperty( "touch-drag", "", false );
registerProperty( "touch-drag-deceleration", "", false );
registerProperty( "base-alpha", "", false );
registerProperty( "buttons-position-offset", "", false );
registerProperty( "window-flags", "", false );
registerProperty( "decoration-size", "", false );
registerProperty( "border-size", "", false );
registerProperty( "min-window-size", "", false );
registerProperty( "buttons-separation", "", false );
registerProperty( "min-corner-distance", "", false );
registerProperty( "decoration-auto-size", "", false );
registerProperty( "border-auto-size", "", false );
registerProperty( "margin-between-buttons", "", false );
registerProperty( "button-margin", "", false );
registerProperty( "menu-height", "", false );
registerProperty( "first-button-margin-left", "", false );
registerProperty( "scale-origin-point", "", false );
// Shorthands
registerProperty( "background-position", "", false );
registerProperty( "transition", "", false );
//registerProperty( "background", "", false );
//registerProperty( "padding", "", false );
registerShorthand( "margin", {"margin-left", "margin-top", "margin-right", "margin-bottom"},
ShorthandDefinition::ShorthandType::Box );
registerShorthand( "padding",
@@ -151,9 +234,13 @@ void StyleSheetSpecification::registerDefaultProperties() {
ShorthandDefinition::ShorthandType::Background );
registerShorthand( "foreground", {"foreground-color", "foreground-image"},
ShorthandDefinition::ShorthandType::Background );
/*registerShorthand( "rotation-origin-point", {"rotation-origin-point-x", "rotation-origin-point-y"},
ShorthandDefinition::ShorthandType::Vector2 );
registerShorthand( "scale-origin-point", {"scale-origin-point-x", "scale-origin-point-y"},
registerShorthand( "filler-padding",
{"filler-padding-left", "filler-padding-top", "filler-padding-right",
"filler-padding-bottom"},
ShorthandDefinition::ShorthandType::Box );
/*registerShorthand( "rotation-origin-point", {"rotation-origin-point-x",
"rotation-origin-point-y"}, ShorthandDefinition::ShorthandType::Vector2 ); registerShorthand(
"scale-origin-point", {"scale-origin-point-x", "scale-origin-point-y"},
ShorthandDefinition::ShorthandType::Vector2 );*/
}

View File

@@ -1,4 +1,5 @@
#include <eepp/ui/uicheckbox.hpp>
#include <eepp/ui/css/propertydefinition.hpp>
#include <eepp/graphics/textureregion.hpp>
#include <eepp/graphics/text.hpp>
@@ -195,12 +196,14 @@ void UICheckBox::setTextSeparation(const Int32 & textSeparation) {
}
bool UICheckBox::applyProperty( const StyleSheetProperty& attribute, const Uint32& state ) {
const std::string& name = attribute.getName();
if ( !checkPropertyDefinition( attribute ) ) return false;
if ( "selected" == name || "active" == name ) {
setActive( attribute.asBool() );
} else {
return UITextView::applyProperty( attribute, state );
switch ( attribute.getPropertyDefinition()->getPropertyId() ) {
case PropertyId::Selected:
setActive( attribute.asBool() );
break;
default:
return UITextView::applyProperty( attribute, state );
}
return true;

View File

@@ -1,5 +1,6 @@
#include <eepp/ui/uidropdownlist.hpp>
#include <eepp/ui/uithememanager.hpp>
#include <eepp/ui/css/propertydefinition.hpp>
#include <eepp/scene/scenemanager.hpp>
#include <eepp/scene/scenenode.hpp>
#include <eepp/scene/actions/actions.hpp>
@@ -261,21 +262,24 @@ void UIDropDownList::destroyListBox() {
}
bool UIDropDownList::applyProperty( const StyleSheetProperty& attribute, const Uint32& state ) {
const std::string& name = attribute.getName();
if ( !checkPropertyDefinition( attribute ) ) return false;
if ( "popup-to-main-control" == name || "popuptomaincontrol" == name ) {
setPopUpToMainControl( attribute.asBool() );
} else if ( "max-visible-items" == name || "maxvisibleitems" == name ) {
setMaxNumVisibleItems( attribute.asUint() );
} else if ( "selected-index" == name || "selected-text" == name ||
"scrollbar-type" == name || "row-height" == name ||
"vscroll-mode" == name || "hscroll-mode" == name ||
"selectedindex" == name || "selectedtext" == name ||
"scrollbartype" == name || "rowheight" == name ||
"vscrollmode" == name || "hscrollmode" == name) {
mListBox->applyProperty( attribute, state );
} else {
return UITextInput::applyProperty( attribute, state );
switch ( attribute.getPropertyDefinition()->getPropertyId() ) {
case PropertyId::PopUpToMainControl:
setPopUpToMainControl( attribute.asBool() );
break;
case PropertyId::MaxVisibleItems:
setMaxNumVisibleItems( attribute.asUint() );
break;
case PropertyId::SelectedIndex:
case PropertyId::SelectedText:
case PropertyId::ScrollBarType:
case PropertyId::RowHeight:
case PropertyId::VScrollMode:
case PropertyId::HScrollMode:
return mListBox->applyProperty( attribute, state );
default:
return UITextInput::applyProperty( attribute, state );
}
return true;

View File

@@ -1,4 +1,5 @@
#include <eepp/ui/uigridlayout.hpp>
#include <eepp/ui/css/propertydefinition.hpp>
namespace EE { namespace UI {
@@ -205,34 +206,49 @@ Sizef UIGridLayout::getTargetElementSize() const {
}
bool UIGridLayout::applyProperty( const StyleSheetProperty& attribute, const Uint32& state ) {
const std::string& name = attribute.getName();
if ( !checkPropertyDefinition( attribute ) ) return false;
if ( "column-span" == name || "columnspan" == name ) {
setSpan( Sizei( attribute.asDpDimensionI(), mSpan.y ) );
} else if ( "row-span" == name || "rowspan" == name ) {
setSpan( Sizei( mSpan.x, attribute.asDpDimensionI() ) );
} else if ( "span" == name ) {
setSpan( Sizei( attribute.asDpDimension(), attribute.asDpDimensionI() ) );
} else if ( "column-mode" == name || "columnmode" == name ) {
std::string val( attribute.asString() );
String::toLowerInPlace( val );
setColumnMode( "size" == val ? Size : Weight );
} else if ( "row-mode" == name || "rowmode" == name ) {
std::string val( attribute.asString() );
String::toLowerInPlace( val );
setRowMode( "size" == val ? Size : Weight );
} else if ( "column-weight" == name || "columnweight" == name ) {
setColumnWeight( attribute.asFloat() );
} else if ( "column-width" == name || "columnwidth" == name ) {
setColumnWidth( attribute.asDpDimensionI() );
} else if ( "row-weight" == name || "rowweight" == name ) {
setRowWeight( attribute.asDpDimension() );
} else if ( "row-height" == name || "rowheight" == name ) {
setRowHeight( attribute.asDpDimensionI() );
} else if ( "reverse-draw" == name || "reversedraw" == name ) {
setReverseDraw( attribute.asBool() );
} else {
return UILayout::applyProperty( attribute, state );
switch ( attribute.getPropertyDefinition()->getPropertyId() ) {
case PropertyId::ColumnSpan:
setSpan( Sizei( attribute.asDpDimensionI(), mSpan.y ) );
break;
case PropertyId::RowSpan:
setSpan( Sizei( mSpan.x, attribute.asDpDimensionI() ) );
break;
case PropertyId::Span:
setSpan( Sizei( attribute.asDpDimension(), attribute.asDpDimensionI() ) );
break;
case PropertyId::ColumnMode:
{
std::string val( attribute.asString() );
String::toLowerInPlace( val );
setColumnMode( "size" == val ? Size : Weight );
break;
}
case PropertyId::RowMode:
{
std::string val( attribute.asString() );
String::toLowerInPlace( val );
setRowMode( "size" == val ? Size : Weight );
break;
}
case PropertyId::ColumnWeight:
setColumnWeight( attribute.asFloat() );
break;
case PropertyId::ColumnWidth:
setColumnWidth( attribute.asDpDimensionI() );
break;
case PropertyId::RowWeight:
setRowWeight( attribute.asDpDimension() );
break;
case PropertyId::RowHeight:
setRowHeight( attribute.asDpDimensionI() );
break;
case PropertyId::ReverseDraw:
setReverseDraw( attribute.asBool() );
break;
default:
return UILayout::applyProperty( attribute, state );
}
return true;

View File

@@ -1,4 +1,5 @@
#include <eepp/ui/uiimage.hpp>
#include <eepp/ui/css/propertydefinition.hpp>
#include <eepp/graphics/drawable.hpp>
#include <eepp/graphics/sprite.hpp>
#include <eepp/graphics/drawablesearcher.hpp>
@@ -210,41 +211,49 @@ const Vector2f& UIImage::getAlignOffset() const {
}
bool UIImage::applyProperty( const StyleSheetProperty& attribute, const Uint32& state ) {
const std::string& name = attribute.getName();
if ( !checkPropertyDefinition( attribute ) ) return false;
if ( "src" == name ) {
Drawable * res = NULL;
switch ( attribute.getPropertyDefinition()->getPropertyId() ) {
case PropertyId::Src:
{
Drawable * res = NULL;
if ( NULL != ( res = DrawableSearcher::searchByName( attribute.asString() ) ) ) {
if ( res->getDrawableType() == Drawable::SPRITE )
mDrawableOwner = true;
if ( NULL != ( res = DrawableSearcher::searchByName( attribute.asString() ) ) ) {
if ( res->getDrawableType() == Drawable::SPRITE )
mDrawableOwner = true;
setDrawable( res );
setDrawable( res );
}
break;
}
} else if ( "icon" == name ) {
std::string val = attribute.asString();
Drawable * icon = NULL;
if ( NULL != mTheme && NULL != ( icon = mTheme->getIconByName( val ) ) ) {
setDrawable( icon );
} else if ( NULL != ( icon = DrawableSearcher::searchByName( val ) ) ) {
setDrawable( icon );
case PropertyId::Icon:
{
std::string val = attribute.asString();
Drawable * icon = NULL;
if ( NULL != mTheme && NULL != ( icon = mTheme->getIconByName( val ) ) ) {
setDrawable( icon );
} else if ( NULL != ( icon = DrawableSearcher::searchByName( val ) ) ) {
setDrawable( icon );
}
break;
}
} else if ( "scale-type" == name || "scaletype" == name ) {
std::string val = attribute.asString();
String::toLowerInPlace( val );
if ( "expand" == val ) {
setScaleType( UIScaleType::Expand );
} else if ( "fit-inside" == val || "fit_inside" == val || "fitinside" == val ) {
setScaleType( UIScaleType::FitInside );
} else if ( "none" == val ) {
setScaleType( UIScaleType::None );
case PropertyId::ScaleType:
{
std::string val = attribute.asString();
String::toLowerInPlace( val );
if ( "expand" == val ) {
setScaleType( UIScaleType::Expand );
} else if ( "fit-inside" == val || "fit_inside" == val || "fitinside" == val ) {
setScaleType( UIScaleType::FitInside );
} else if ( "none" == val ) {
setScaleType( UIScaleType::None );
}
break;
}
} else if ( "tint" == name ) {
setColor( attribute.asColor() );
} else {
return UIWidget::applyProperty( attribute, state );
case PropertyId::Tint:
setColor( attribute.asColor() );
break;
default:
return UIWidget::applyProperty( attribute, state );
}
return true;

View File

@@ -1,4 +1,5 @@
#include <eepp/ui/uilinearlayout.hpp>
#include <eepp/ui/css/propertydefinition.hpp>
namespace EE { namespace UI {
@@ -408,18 +409,22 @@ Sizei UILinearLayout::getTotalUsedSize() {
}
bool UILinearLayout::applyProperty( const StyleSheetProperty& attribute, const Uint32& state ) {
const std::string& name = attribute.getName();
if ( !checkPropertyDefinition( attribute ) ) return false;
if ( "orientation" == name ) {
std::string val = attribute.asString();
String::toLowerInPlace( val );
switch ( attribute.getPropertyDefinition()->getPropertyId() ) {
case PropertyId::Orientation:
{
std::string val = attribute.asString();
String::toLowerInPlace( val );
if ( "horizontal" == val )
setOrientation( UI_HORIZONTAL );
else if ( "vertical" == val )
setOrientation( UI_VERTICAL );
} else {
return UILayout::applyProperty( attribute, state );
if ( "horizontal" == val )
setOrientation( UI_HORIZONTAL );
else if ( "vertical" == val )
setOrientation( UI_VERTICAL );
break;
}
default:
return UILayout::applyProperty( attribute, state );
}
return true;

View File

@@ -9,6 +9,7 @@
#include <eepp/window/input.hpp>
#include <eepp/ui/uiscenenode.hpp>
#include <eepp/ui/uistyle.hpp>
#include <eepp/ui/css/propertydefinition.hpp>
namespace EE { namespace UI {
@@ -966,37 +967,50 @@ const UI_SCROLLBAR_MODE& UIListBox::getHorizontalScrollMode() {
}
bool UIListBox::applyProperty( const StyleSheetProperty& attribute, const Uint32& state ) {
const std::string& name = attribute.getName();
if ( !checkPropertyDefinition( attribute ) ) return false;
if ( "row-height" == name || "rowheight" == name ) {
setRowHeight( attribute.asDpDimensionI() );
} else if ( "vscroll-mode" == 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 ( "hscroll-mode" == 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 ( "selected-index" == name || "selectedindex" == name ) {
setSelected( attribute.asUint() );
} else if ( "selected-text" == name || "selectedtext" == name ) {
setSelected( attribute.asString() );
} else if ( "scrollbar-type" == name || "scrollbartype" == name ) {
std::string val( attribute.asString() );
String::toLowerInPlace( val );
if ( "no-buttons" == val || "nobuttons" == val ) {
mVScrollBar->setScrollBarType( UIScrollBar::NoButtons );
mHScrollBar->setScrollBarType( UIScrollBar::NoButtons );
} else if ( "two-buttons" == val || "twobuttons" == val ) {
mVScrollBar->setScrollBarType( UIScrollBar::TwoButtons );
mHScrollBar->setScrollBarType( UIScrollBar::NoButtons );
switch ( attribute.getPropertyDefinition()->getPropertyId() ) {
case PropertyId::RowHeight:
setRowHeight( attribute.asDpDimensionI() );
break;
case PropertyId::VScrollMode:
{
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 );
break;
}
} else {
return UITouchDragableWidget::applyProperty( attribute, state );
case PropertyId::HScrollMode:
{
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 );
break;
}
case PropertyId::SelectedIndex:
setSelected( attribute.asUint() );
break;
case PropertyId::SelectedText:
setSelected( attribute.asString() );
break;
case PropertyId::ScrollBarType:
{
std::string val( attribute.asString() );
String::toLowerInPlace( val );
if ( "no-buttons" == val || "nobuttons" == val ) {
mVScrollBar->setScrollBarType( UIScrollBar::NoButtons );
mHScrollBar->setScrollBarType( UIScrollBar::NoButtons );
} else if ( "two-buttons" == val || "twobuttons" == val ) {
mVScrollBar->setScrollBarType( UIScrollBar::TwoButtons );
mHScrollBar->setScrollBarType( UIScrollBar::NoButtons );
}
break;
}
default:
return UITouchDragableWidget::applyProperty( attribute, state );
}
return true;

View File

@@ -1,6 +1,7 @@
#include <eepp/ui/uiloader.hpp>
#include <eepp/graphics/renderer/renderer.hpp>
#include <eepp/scene/scenenode.hpp>
#include <eepp/ui/css/propertydefinition.hpp>
namespace EE { namespace UI {
@@ -221,26 +222,35 @@ UILoader * UILoader::setAnimationSpeed( const Float& animationSpeed ) {
}
bool UILoader::applyProperty( const StyleSheetProperty& attribute, const Uint32& state ) {
std::string name = attribute.getName();
if ( !checkPropertyDefinition( attribute ) ) return false;
if ( "indeterminate" == name ) {
setIndeterminate( attribute.asBool() );
} else if ( "max-progress" == name || "maxprogress" == name ) {
setMaxProgress( attribute.asFloat() );
} else if ( "progress" == name ) {
setProgress( attribute.asFloat() );
} else if ( "fill-color" == name || "fillcolor" == name ) {
setFillColor( attribute.asColor() );
} else if ( "radius" == name ) {
setRadius( attribute.asDpDimension() );
} else if ( "outline-thickness" == name || "outlinethickness" == name ) {
setOutlineThickness( attribute.asDpDimension() );
} else if ( "animation-speed" == name || "animationspeed" == name ) {
setAnimationSpeed( attribute.asFloat() );
} else if ( "arc-start-angle" == name || "arcstartangle" == name ) {
setArcStartAngle( attribute.asFloat() );
} else {
return UIWidget::applyProperty( attribute, state );
switch ( attribute.getPropertyDefinition()->getPropertyId() ) {
case PropertyId::Indeterminate:
setIndeterminate( attribute.asBool() );
break;
case PropertyId::MaxProgress:
setMaxProgress( attribute.asFloat() );
break;
case PropertyId::Progress:
setProgress( attribute.asFloat() );
break;
case PropertyId::FillColor:
setFillColor( attribute.asColor() );
break;
case PropertyId::Radius:
setRadius( attribute.asDpDimension() );
break;
case PropertyId::OutlineThickness:
setOutlineThickness( attribute.asDpDimension() );
break;
case PropertyId::AnimationSpeed:
setAnimationSpeed( attribute.asFloat() );
break;
case PropertyId::ArcStartAngle:
setArcStartAngle( attribute.asFloat() );
break;
default:
return UIWidget::applyProperty( attribute, state );
}
return true;

View File

@@ -5,6 +5,7 @@
#include <eepp/ui/uipopupmenu.hpp>
#include <eepp/ui/uithememanager.hpp>
#include <eepp/ui/uiscenenode.hpp>
#include <eepp/ui/css/propertydefinition.hpp>
namespace EE { namespace UI {
@@ -571,17 +572,21 @@ void UIMenu::loadFromXmlNode( const pugi::xml_node& node ) {
}
bool UIMenu::applyProperty(const StyleSheetProperty & attribute, const Uint32 & state) {
const std::string& name = attribute.getName();
if ( !checkPropertyDefinition( attribute ) ) return false;
if ( "min-width" == name || "minwidth" == name ) {
mStyleConfig.MinWidth = attribute.asInt();
onSizeChange();
} else if ( "min-margin-right" == name || "minmarginright" == name ) {
setMinRightMargin( attribute.asDpDimensionUint() );
} else if ( "min-icon-space" == name || "miniconspace" == name ) {
setMinSpaceForIcons( attribute.asDpDimensionUint() );
} else {
return UIWidget::applyProperty( attribute, state );
switch ( attribute.getPropertyDefinition()->getPropertyId() ) {
case PropertyId::MinWidth:
mStyleConfig.MinWidth = attribute.asInt();
onSizeChange();
break;
case PropertyId::MinMarginRight:
setMinRightMargin( attribute.asDpDimensionUint() );
break;
case PropertyId::MinIconSpace:
setMinSpaceForIcons( attribute.asDpDimensionUint() );
break;
default:
return UIWidget::applyProperty( attribute, state );
}
return true;

View File

@@ -1,5 +1,6 @@
#include <eepp/ui/uiprogressbar.hpp>
#include <eepp/ui/uithememanager.hpp>
#include <eepp/ui/css/propertydefinition.hpp>
#include <eepp/scene/scenenode.hpp>
#include <eepp/graphics/globaltextureatlas.hpp>
@@ -207,31 +208,38 @@ UITextView * UIProgressBar::getTextBox() const {
}
bool UIProgressBar::applyProperty( const StyleSheetProperty& attribute, const Uint32& state ) {
const std::string& name = attribute.getName();
if ( !checkPropertyDefinition( attribute ) ) return false;
if ( "total-steps" == name || "totalsteps" == name ) {
setTotalSteps( attribute.asFloat() );
} else if ( "progress" == name ) {
setProgress( attribute.asFloat() );
} else if ( "vertical-expand" == name || "verticalexpand" == name ) {
setVerticalExpand( attribute.asBool() );
} else if ( "display-percent" == name || "displaypercent" == name ) {
setDisplayPercent( attribute.asBool() );
} else if ( "filler-padding" == name || "fillerpadding" == name ) {
Float val = attribute.asDpDimension();
setFillerPadding( Rectf( val, val, val, val ) );
} else if ( "filler-padding-left" == name || "fillerpaddingleft" == name ) {
setFillerPadding( Rectf( attribute.asDpDimension(), mStyleConfig.FillerPadding.Top, mStyleConfig.FillerPadding.Right, mStyleConfig.FillerPadding.Bottom ) );
} else if ( "filler-padding-right" == name || "fillerpaddingright" == name ) {
setFillerPadding( Rectf( mStyleConfig.FillerPadding.Left, mStyleConfig.FillerPadding.Top, attribute.asDpDimension(), mStyleConfig.FillerPadding.Bottom ) );
} else if ( "filler-padding-top" == name || "fillerpaddingtop" == name ) {
setFillerPadding( Rectf( mStyleConfig.FillerPadding.Left, attribute.asDpDimension(), mStyleConfig.FillerPadding.Right, mStyleConfig.FillerPadding.Bottom ) );
} else if ( "filler-padding-bottom" == name || "fillerpaddingbottom" == name ) {
setFillerPadding( Rectf( mStyleConfig.FillerPadding.Left, mStyleConfig.FillerPadding.Top, mStyleConfig.FillerPadding.Right, attribute.asDpDimension() ) );
} else if ( "movement-speed" == name || "movementspeed" == name ) {
setMovementSpeed( attribute.asVector2f() );
} else {
return UIWidget::applyProperty( attribute, state );
switch ( attribute.getPropertyDefinition()->getPropertyId() ) {
case PropertyId::TotalSteps:
setTotalSteps( attribute.asFloat() );
break;
case PropertyId::Progress:
setProgress( attribute.asFloat() );
break;
case PropertyId::VerticalExpand:
setVerticalExpand( attribute.asBool() );
break;
case PropertyId::DisplayPercent:
setDisplayPercent( attribute.asBool() );
break;
case PropertyId::FillerPaddingLeft:
setFillerPadding( Rectf( attribute.asDpDimension(), mStyleConfig.FillerPadding.Top, mStyleConfig.FillerPadding.Right, mStyleConfig.FillerPadding.Bottom ) );
break;
case PropertyId::FillerPaddingTop:
setFillerPadding( Rectf( mStyleConfig.FillerPadding.Left, attribute.asDpDimension(), mStyleConfig.FillerPadding.Right, mStyleConfig.FillerPadding.Bottom ) );
break;
case PropertyId::FillerPaddingRight:
setFillerPadding( Rectf( mStyleConfig.FillerPadding.Left, mStyleConfig.FillerPadding.Top, attribute.asDpDimension(), mStyleConfig.FillerPadding.Bottom ) );
break;
case PropertyId::FillerPaddingBottom:
setFillerPadding( Rectf( mStyleConfig.FillerPadding.Left, mStyleConfig.FillerPadding.Top, mStyleConfig.FillerPadding.Right, attribute.asDpDimension() ) );
break;
case PropertyId::MovementSpeed:
setMovementSpeed( attribute.asVector2f() );
break;
default:
return UIWidget::applyProperty( attribute, state );
}
return true;

View File

@@ -1,4 +1,5 @@
#include <eepp/ui/uiradiobutton.hpp>
#include <eepp/ui/css/propertydefinition.hpp>
#include <eepp/graphics/textureregion.hpp>
#include <eepp/graphics/text.hpp>
@@ -264,12 +265,14 @@ void UIRadioButton::setTextSeparation(const Int32 & textSeparation) {
}
bool UIRadioButton::applyProperty( const StyleSheetProperty& attribute, const Uint32& state ) {
const std::string& name = attribute.getName();
if ( !checkPropertyDefinition( attribute ) ) return false;
if ( "selected" == name || "active" == name ) {
setActive( attribute.asBool() );
} else {
return UITextView::applyProperty( attribute, state );
switch ( attribute.getPropertyDefinition()->getPropertyId() ) {
case PropertyId::Selected:
setActive( attribute.asBool() );
break;
default:
return UITextView::applyProperty( attribute, state );
}
return true;

View File

@@ -1,4 +1,5 @@
#include <eepp/ui/uiscrollbar.hpp>
#include <eepp/ui/css/propertydefinition.hpp>
#include <eepp/graphics/textureregion.hpp>
namespace EE { namespace UI {
@@ -305,39 +306,52 @@ void UIScrollBar::setExpandBackground( bool expandBackground ) {
}
bool UIScrollBar::applyProperty( const StyleSheetProperty& attribute, const Uint32& state ) {
const std::string& name = attribute.getName();
if ( !checkPropertyDefinition( attribute ) ) return false;
if ( "orientation" == name ) {
std::string val = attribute.asString();
String::toLowerInPlace( val );
switch ( attribute.getPropertyDefinition()->getPropertyId() ) {
case PropertyId::Orientation:
{
std::string val = attribute.asString();
String::toLowerInPlace( val );
if ( "horizontal" == val )
setOrientation( UI_HORIZONTAL );
else if ( "vertical" == val )
setOrientation( UI_VERTICAL );
} else if ( "min-value" == name || "minvalue" == name ) {
setMinValue( attribute.asFloat() );
} else if ( "max-value" == name || "maxvalue" == name ) {
setMaxValue( attribute.asFloat() );
} else if ( "value" == name ) {
setValue( attribute.asFloat() );
} else if ( "click-step" == name || "clickstep" == name ) {
setClickStep( attribute.asFloat() );
} else if ( "page-step" == name || "pagestep" == name ) {
setPageStep( attribute.asFloat() );
} else if ( "scrollbar-type" == name || "scrollbartype" == name ) {
std::string val = attribute.asString();
String::toLowerInPlace( val );
if ( "no-buttons" == val || "nobuttons" == val ) {
setScrollBarType( NoButtons );
} else if ( "two-buttons" == val || "twobuttons" == val ) {
setScrollBarType( TwoButtons );
if ( "horizontal" == val )
setOrientation( UI_HORIZONTAL );
else if ( "vertical" == val )
setOrientation( UI_VERTICAL );
break;
}
} else if ( "background-expand" == name || "backgroundexpand" == name ) {
setExpandBackground( attribute.asBool() );
} else {
return UIWidget::applyProperty( attribute, state );
case PropertyId::MinValue:
setMinValue( attribute.asFloat() );
break;
case PropertyId::MaxValue:
setMaxValue( attribute.asFloat() );
break;
case PropertyId::Value:
setValue( attribute.asFloat() );
break;
case PropertyId::ClickStep:
setClickStep( attribute.asFloat() );
break;
case PropertyId::PageStep:
setPageStep( attribute.asFloat() );
break;
case PropertyId::ScrollBarType:
{
std::string val = attribute.asString();
String::toLowerInPlace( val );
if ( "no-buttons" == val || "nobuttons" == val ) {
setScrollBarType( NoButtons );
} else if ( "two-buttons" == val || "twobuttons" == val ) {
setScrollBarType( TwoButtons );
}
break;
}
case PropertyId::BackgroundExpand:
setExpandBackground( attribute.asBool() );
break;
default:
return UIWidget::applyProperty( attribute, state );
}
return true;

View File

@@ -1,5 +1,6 @@
#include <eepp/ui/uiscrollview.hpp>
#include <eepp/ui/uiscrollbar.hpp>
#include <eepp/ui/css/propertydefinition.hpp>
namespace EE { namespace UI {
@@ -241,41 +242,53 @@ bool UIScrollView::isTouchOverAllowedChilds() {
}
bool UIScrollView::applyProperty( const StyleSheetProperty& attribute, const Uint32& state ) {
const std::string& name = attribute.getName();
if ( !checkPropertyDefinition( attribute ) ) return false;
if ( "type" == 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 || "vscrollmode" == 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 || "hscrollmode" == name ) {
std::string val( attribute.asString() );
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 ( "scrollbar-type" == name || "scrollbartype" == name ) {
std::string val( attribute.asString() );
String::toLowerInPlace( val );
if ( "no-buttons" == val || "nobuttons" == val ) {
mVScroll->setScrollBarType( UIScrollBar::NoButtons );
mHScroll->setScrollBarType( UIScrollBar::NoButtons );
} else if ( "two-buttons" == val || "twobuttons" == val ) {
mVScroll->setScrollBarType( UIScrollBar::TwoButtons );
mHScroll->setScrollBarType( UIScrollBar::NoButtons );
switch ( attribute.getPropertyDefinition()->getPropertyId() ) {
case PropertyId::ScrollBarMode:
{
std::string val( attribute.asString() );
String::toLowerInPlace( val );
if ( "inclusive" == val ) setViewType( Inclusive );
else if ( "exclusive" == val ) setViewType( Exclusive );
break;
}
} else {
return UITouchDragableWidget::applyProperty( attribute, state );
case PropertyId::VScrollMode:
{
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 );
break;
}
case PropertyId::HScrollMode:
{
std::string val( attribute.asString() );
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 );
break;
}
case PropertyId::ScrollBarType:
{
std::string val( attribute.asString() );
String::toLowerInPlace( val );
if ( "no-buttons" == val || "nobuttons" == val ) {
mVScroll->setScrollBarType( UIScrollBar::NoButtons );
mHScroll->setScrollBarType( UIScrollBar::NoButtons );
} else if ( "two-buttons" == val || "twobuttons" == val ) {
mVScroll->setScrollBarType( UIScrollBar::TwoButtons );
mHScroll->setScrollBarType( UIScrollBar::NoButtons );
}
break;
}
default:
return UITouchDragableWidget::applyProperty( attribute, state );
}
return true;

View File

@@ -1,5 +1,6 @@
#include <eepp/ui/uislider.hpp>
#include <eepp/ui/uithememanager.hpp>
#include <eepp/ui/css/propertydefinition.hpp>
#include <eepp/graphics/textureregion.hpp>
namespace EE { namespace UI {
@@ -436,32 +437,43 @@ Uint32 UISlider::onMessage(const NodeMessage * Msg) {
}
bool UISlider::applyProperty( const StyleSheetProperty& attribute, const Uint32& state ) {
const std::string& name = attribute.getName();
if ( !checkPropertyDefinition( attribute ) ) return false;
if ( "orientation" == name ) {
std::string val = attribute.asString();
String::toLowerInPlace( val );
switch ( attribute.getPropertyDefinition()->getPropertyId() ) {
case PropertyId::Orientation:
{
std::string val = attribute.asString();
String::toLowerInPlace( val );
if ( "horizontal" == val )
setOrientation( UI_HORIZONTAL );
else if ( "vertical" == val )
setOrientation( UI_VERTICAL );
} else if ( "min-value" == name || "minvalue" == name ) {
setMinValue( attribute.asFloat() );
} else if ( "max-value" == name || "maxvalue" == name ) {
setMaxValue( attribute.asFloat() );
} else if ( "value" == name ) {
setValue( attribute.asFloat() );
} else if ( "click-step" == name || "clickstep" == name ) {
setClickStep( attribute.asFloat() );
} else if ( "page-step" == name || "pagestep" == name ) {
setPageStep( attribute.asFloat() );
} else if ( "half-slider" == name || "halfslider" == name ) {
setAllowHalfSliderOut( attribute.asBool() );
} else if ( "background-expand" == name || "backgroundexpand" == name ) {
setExpandBackground( attribute.asBool() );
} else {
return UIWidget::applyProperty( attribute, state );
if ( "horizontal" == val )
setOrientation( UI_HORIZONTAL );
else if ( "vertical" == val )
setOrientation( UI_VERTICAL );
break;
}
case PropertyId::MinValue:
setMinValue( attribute.asFloat() );
break;
case PropertyId::MaxValue:
setMaxValue( attribute.asFloat() );
break;
case PropertyId::Value:
setValue( attribute.asFloat() );
break;
case PropertyId::ClickStep:
setClickStep( attribute.asFloat() );
break;
case PropertyId::PageStep:
setPageStep( attribute.asFloat() );
break;
case PropertyId::BackgroundExpand:
setExpandBackground( attribute.asBool() );
break;
case PropertyId::HalfSlider:
setAllowHalfSliderOut( attribute.asBool() );
break;
default:
return UIWidget::applyProperty( attribute, state );
}
return true;

View File

@@ -1,4 +1,5 @@
#include <eepp/ui/uispinbox.hpp>
#include <eepp/ui/css/propertydefinition.hpp>
#include <eepp/graphics/textureregion.hpp>
#include <eepp/scene/scenenode.hpp>
@@ -270,20 +271,26 @@ void UISpinBox::onPaddingChange() {
}
bool UISpinBox::applyProperty( const StyleSheetProperty& attribute, const Uint32& state ) {
const std::string& name = attribute.getName();
if ( !checkPropertyDefinition( attribute ) ) return false;
bool attributeSet = true;
if ( "min-value" == name || "minvalue" == name ) {
setMinValue(attribute.asFloat() );
} else if ( "max-value" == name || "maxvalue" == name ) {
setMaxValue(attribute.asFloat() );
} else if ( "value" == name ) {
setValue(attribute.asFloat() );
} else if ( "click-step" == name || "clickstep" == name ) {
setClickStep(attribute.asFloat() );
} else {
attributeSet = UIWidget::applyProperty( attribute, state );
switch ( attribute.getPropertyDefinition()->getPropertyId() ) {
case PropertyId::MinValue:
setMinValue(attribute.asFloat() );
break;
case PropertyId::MaxValue:
setMaxValue(attribute.asFloat() );
break;
case PropertyId::Value:
setValue(attribute.asFloat() );
break;
case PropertyId::ClickStep:
setClickStep(attribute.asFloat() );
break;
default:
attributeSet = UIWidget::applyProperty( attribute, state );
break;
}
mInput->applyProperty( attribute );

View File

@@ -1,4 +1,5 @@
#include <eepp/ui/uisprite.hpp>
#include <eepp/ui/css/propertydefinition.hpp>
#include <eepp/graphics/sprite.hpp>
#include <eepp/scene/scenenode.hpp>
#include <eepp/graphics/globaltextureatlas.hpp>
@@ -185,17 +186,21 @@ void UISprite::onSizeChange() {
}
bool UISprite::applyProperty( const StyleSheetProperty& attribute, const Uint32& state ) {
const std::string& name = attribute.getName();
if ( !checkPropertyDefinition( attribute ) ) return false;
if ( "src" == name ) {
std::string val = attribute.asString();
switch ( attribute.getPropertyDefinition()->getPropertyId() ) {
case PropertyId::Src:
{
std::string val = attribute.asString();
if ( val.size() ) {
setIsSpriteOwner( true );
setSprite( Sprite::New( val ) );
if ( val.size() ) {
setIsSpriteOwner( true );
setSprite( Sprite::New( val ) );
}
break;
}
} else {
return UIWidget::applyProperty( attribute, state );
default:
return UIWidget::applyProperty( attribute, state );
}
return true;

View File

@@ -1,6 +1,7 @@
#include <eepp/ui/uitab.hpp>
#include <eepp/ui/uitabwidget.hpp>
#include <eepp/ui/uiscenenode.hpp>
#include <eepp/ui/css/propertydefinition.hpp>
namespace EE { namespace UI {
@@ -144,16 +145,20 @@ void UITab::onAutoSize() {
}
bool UITab::applyProperty( const StyleSheetProperty& attribute, const Uint32& state ) {
std::string name = attribute.getName();
if ( !checkPropertyDefinition( attribute ) ) return false;
if ( "name" == name || "text" == name ) {
if ( NULL != mSceneNode && mSceneNode->isUISceneNode() )
setText( static_cast<UISceneNode*>( mSceneNode )->getTranslatorString( attribute.asString() ) );
} else if ( "owns" == name ) {
mOwnedName = attribute.asString();
setOwnedControl();
} else {
return UISelectButton::applyProperty( attribute, state );
switch ( attribute.getPropertyDefinition()->getPropertyId() ) {
case PropertyId::Text:
case PropertyId::Name:
if ( NULL != mSceneNode && mSceneNode->isUISceneNode() )
setText( static_cast<UISceneNode*>( mSceneNode )->getTranslatorString( attribute.asString() ) );
break;
case PropertyId::Owns:
mOwnedName = attribute.asString();
setOwnedControl();
break;
default:
return UISelectButton::applyProperty( attribute, state );
}
return true;

View File

@@ -1,4 +1,5 @@
#include <eepp/ui/uitable.hpp>
#include <eepp/ui/css/propertydefinition.hpp>
#include <pugixml/pugixml.hpp>
namespace EE { namespace UI {
@@ -623,33 +624,44 @@ bool UITable::isTouchOverAllowedChilds() {
}
bool UITable::applyProperty( const StyleSheetProperty& attribute, const Uint32& state ) {
const std::string& name = attribute.getName();
if ( !checkPropertyDefinition( attribute ) ) return false;
if ( "row-height" == name || "rowheight" == name ) {
setRowHeight( attribute.asDpDimensionI() );
} else if ( "vscroll-mode" == 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 ( "hscroll-mode" == 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 ( "scrollbar-type" == name || "scrollbartype" == name ) {
std::string val( attribute.asString() );
String::toLowerInPlace( val );
if ( "no-buttons" == val || "nobuttons" == val ) {
mVScrollBar->setScrollBarType( UIScrollBar::NoButtons );
mHScrollBar->setScrollBarType( UIScrollBar::NoButtons );
} else if ( "two-buttons" == val || "twobuttons" == val ) {
mVScrollBar->setScrollBarType( UIScrollBar::TwoButtons );
mHScrollBar->setScrollBarType( UIScrollBar::NoButtons );
switch ( attribute.getPropertyDefinition()->getPropertyId() ) {
case PropertyId::RowHeight:
setRowHeight( attribute.asDpDimensionI() );
break;
case PropertyId::VScrollMode:
{
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 );
break;
}
} else {
return UITouchDragableWidget::applyProperty( attribute, state );
case PropertyId::HScrollMode:
{
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 );
break;
}
case PropertyId::ScrollBarType:
{
std::string val( attribute.asString() );
String::toLowerInPlace( val );
if ( "no-buttons" == val || "nobuttons" == val ) {
mVScrollBar->setScrollBarType( UIScrollBar::NoButtons );
mHScrollBar->setScrollBarType( UIScrollBar::NoButtons );
} else if ( "two-buttons" == val || "twobuttons" == val ) {
mVScrollBar->setScrollBarType( UIScrollBar::TwoButtons );
mHScrollBar->setScrollBarType( UIScrollBar::NoButtons );
}
break;
}
default:
return UITouchDragableWidget::applyProperty( attribute, state );
}
return true;

View File

@@ -4,6 +4,7 @@
#include <eepp/graphics/primitives.hpp>
#include <eepp/graphics/fontmanager.hpp>
#include <eepp/ui/uistyle.hpp>
#include <eepp/ui/css/propertydefinition.hpp>
namespace EE { namespace UI {
@@ -119,28 +120,41 @@ void UITabWidget::setStyleConfig(const StyleConfig & styleConfig) {
}
bool UITabWidget::applyProperty( const StyleSheetProperty& attribute, const Uint32& state ) {
const std::string& name = attribute.getName();
if ( attribute.getPropertyDefinition() == NULL ) {
eePRINTL( "applyProperty: Property %s not defined!", attribute.getName().c_str() );
return false;
}
if ( "max-text-length" == name || "maxtextlength" == name ) {
setMaxTextLength( attribute.asUint(1) );
} else if ( "min-tab-width" == name || "mintabwidth" == name ) {
setMinTabWidth( attribute.asUint(1) );
} else if ( "max-tab-width" == name || "maxtabwidth" == name ) {
setMaxTabWidth( attribute.asUint() );
} else if ( "tab-closable" == name || "tabclosable" == name ) {
setTabsClosable( attribute.asBool() );
} else if ( "special-border-tabs" == name || "specialbordertabs" == name ) {
setSpecialBorderTabs( attribute.asBool() );
} else if ( "line-below-tabs" == name || "linebelowtabs" == name ) {
setDrawLineBelowTabs( attribute.asBool() );
} else if ( "line-below-tabs-color" == name || "linebelowtabscolor" == name ) {
setLineBelowTabsColor( attribute.asColor() );
} else if ( "line-below-tabs-y-offset" == name || "linebelowtabsyoffset" == name ) {
setLineBelowTabsYOffset( attribute.asDpDimensionI() );
} else if ( "tab-separation" == name || "tabseparation" == name ) {
setTabSeparation( attribute.asDpDimensionI() );
} else {
return UIWidget::applyProperty( attribute, state );
switch ( attribute.getPropertyDefinition()->getPropertyId() ) {
case PropertyId::MaxTextLength:
setMaxTextLength( attribute.asUint(1) );
break;
case PropertyId::MinTabWidth:
setMinTabWidth( attribute.asUint(1) );
break;
case PropertyId::MaxTabWidth:
setMaxTabWidth( attribute.asUint() );
break;
case PropertyId::TabClosable:
setTabsClosable( attribute.asBool() );
break;
case PropertyId::SpecialBorderTabs:
setSpecialBorderTabs( attribute.asBool() );
break;
case PropertyId::LineBelowTabs:
setDrawLineBelowTabs( attribute.asBool() );
break;
case PropertyId::LineBelowTabsColor:
setLineBelowTabsColor( attribute.asColor() );
break;
case PropertyId::LineBelowTabsYOffset:
setLineBelowTabsYOffset( attribute.asDpDimensionI() );
break;
case PropertyId::TabSeparation:
setTabSeparation( attribute.asDpDimensionI() );
break;
default:
return UIWidget::applyProperty( attribute, state );
}
return true;

View File

@@ -1,5 +1,6 @@
#include <eepp/ui/uitextedit.hpp>
#include <eepp/ui/uiscenenode.hpp>
#include <eepp/ui/css/propertydefinition.hpp>
#include <eepp/ui/uiscrollbar.hpp>
#include <eepp/graphics/text.hpp>
#include <eepp/graphics/font.hpp>
@@ -474,31 +475,40 @@ UIFontStyleConfig UITextEdit::getFontStyleConfig() const {
}
bool UITextEdit::applyProperty( const StyleSheetProperty& attribute, const Uint32& state ) {
const std::string& name = attribute.getName();
if ( !checkPropertyDefinition( attribute ) ) return false;
bool attributeSet = true;
if ( "text" == name ) {
if ( NULL != mSceneNode && mSceneNode->isUISceneNode() ) {
setText( static_cast<UISceneNode*>( mSceneNode )->getTranslatorString( attribute.asString() ) );
switch ( attribute.getPropertyDefinition()->getPropertyId() ) {
case PropertyId::Text:
if ( NULL != mSceneNode && mSceneNode->isUISceneNode() ) {
setText( static_cast<UISceneNode*>( mSceneNode )->getTranslatorString( attribute.asString() ) );
}
break;
case PropertyId::AllowEditing:
setAllowEditing( attribute.asBool() );
break;
case PropertyId::VScrollMode:
{
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 );
break;
}
} else if ( "allow-editing" == name || "allowediting" == name ) {
setAllowEditing( attribute.asBool() );
} else if ( "vscroll-mode" == 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 ( "hscroll-mode" == 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 {
attributeSet = UIWidget::applyProperty( attribute, state );
case PropertyId::HScrollMode:
{
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 );
break;
}
default:
attributeSet = UIWidget::applyProperty( attribute, state );
}
if ( !attributeSet && ( String::startsWith( name, "text" ) || String::startsWith( name, "font" ) ) )
if ( !attributeSet && ( String::startsWith( attribute.getName(), "text" ) || String::startsWith( attribute.getName(), "font" ) ) )
mTextInput->applyProperty( attribute, state );
return attributeSet;

View File

@@ -6,6 +6,7 @@
#include <eepp/graphics/text.hpp>
#include <pugixml/pugixml.hpp>
#include <eepp/ui/uiscenenode.hpp>
#include <eepp/ui/css/propertydefinition.hpp>
namespace EE { namespace UI {
@@ -393,24 +394,31 @@ bool UITextInput::isFreeEditingEnabled() {
}
bool UITextInput::applyProperty( const StyleSheetProperty& attribute, const Uint32& state ) {
const std::string& name = attribute.getName();
if ( !checkPropertyDefinition( attribute ) ) return false;
if ( "text" == name ) {
if ( NULL != mSceneNode && mSceneNode->isUISceneNode() ) {
setText( static_cast<UISceneNode*>( mSceneNode )->getTranslatorString( attribute.asString() ) );
}
} else if ( "allow-editing" == name || "allowediting" == name ) {
setAllowEditing( attribute.asBool() );
} else if ( "max-length" == name || "maxlength" == name ) {
setMaxLength( attribute.asUint() );
} else if ( "free-editing" == name || "freeediting" == name ) {
setFreeEditing( attribute.asBool() );
} else if ( "only-numbers" == name || "onlynumbers" == name ) {
getInputTextBuffer()->setAllowOnlyNumbers( attribute.asBool(), getInputTextBuffer()->dotsInNumbersAllowed() );
} else if ( "allow-dot" == name || "allowdot" == name ) {
getInputTextBuffer()->setAllowOnlyNumbers( getInputTextBuffer()->onlyNumbersAllowed(), attribute.asBool() );
} else {
return UITextView::applyProperty( attribute, state );
switch ( attribute.getPropertyDefinition()->getPropertyId() ) {
case PropertyId::Text:
if ( NULL != mSceneNode && mSceneNode->isUISceneNode() ) {
setText( static_cast<UISceneNode*>( mSceneNode )->getTranslatorString( attribute.asString() ) );
}
break;
case PropertyId::AllowEditing:
setAllowEditing( attribute.asBool() );
break;
case PropertyId::MaxLength:
setMaxLength( attribute.asUint() );
break;
case PropertyId::FreeEditing:
setFreeEditing( attribute.asBool() );
break;
case PropertyId::OnlyNumbers:
getInputTextBuffer()->setAllowOnlyNumbers( attribute.asBool(), getInputTextBuffer()->dotsInNumbersAllowed() );
break;
case PropertyId::AllowDot:
getInputTextBuffer()->setAllowOnlyNumbers( getInputTextBuffer()->onlyNumbersAllowed(), attribute.asBool() );
break;
default:
return UITextView::applyProperty( attribute, state );
}
return true;

View File

@@ -1,4 +1,5 @@
#include <eepp/ui/uitextureregion.hpp>
#include <eepp/ui/css/propertydefinition.hpp>
#include <eepp/graphics/textureregion.hpp>
#include <eepp/graphics/globaltextureatlas.hpp>
#include <eepp/graphics/textureatlasmanager.hpp>
@@ -197,29 +198,37 @@ const Vector2f& UITextureRegion::getAlignOffset() const {
}
bool UITextureRegion::applyProperty( const StyleSheetProperty& attribute, const Uint32& state ) {
const std::string& name = attribute.getName();
if ( !checkPropertyDefinition( attribute ) ) return false;
if ( "src" == name ) {
Drawable * res = NULL;
switch ( attribute.getPropertyDefinition()->getPropertyId() ) {
case PropertyId::Src:
{
Drawable * res = NULL;
if ( NULL != ( res = TextureAtlasManager::instance()->getTextureRegionByName( attribute.asString() ) ) && res->getDrawableType() == Drawable::TEXTUREREGION ) {
setTextureRegion( static_cast<TextureRegion*>( res ) );
if ( NULL != ( res = TextureAtlasManager::instance()->getTextureRegionByName( attribute.asString() ) ) && res->getDrawableType() == Drawable::TEXTUREREGION ) {
setTextureRegion( static_cast<TextureRegion*>( res ) );
}
break;
}
} else if ( "scale-type" == name || "scaletype" == name ) {
std::string val = attribute.asString();
String::toLowerInPlace( val );
case PropertyId::ScaleType:
{
std::string val = attribute.asString();
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 );
if ( "expand" == val ) {
setScaleType( UIScaleType::Expand );
} else if ( "fit_inside" == val || "fitinside" == val ) {
setScaleType( UIScaleType::FitInside );
} else if ( "none" == val ) {
setScaleType( UIScaleType::None );
}
break;
}
} else if ( "tint" == name ) {
setColor( attribute.asColor() );
} else {
return UIWidget::applyProperty( attribute, state );
case PropertyId::Tint:
setColor( attribute.asColor() );
break;
default:
return UIWidget::applyProperty( attribute, state );
}
return true;

View File

@@ -568,10 +568,7 @@ void UITextView::resetSelCache() {
}
bool UITextView::applyProperty( const StyleSheetProperty& attribute, const Uint32& state ) {
if ( attribute.getPropertyDefinition() == NULL ) {
eePRINTL( "applyProperty: Property %s not defined!", attribute.getName().c_str() );
return false;
}
if ( !checkPropertyDefinition( attribute ) ) return false;
switch ( attribute.getPropertyDefinition()->getPropertyId() ) {
case PropertyId::Text:

View File

@@ -1,8 +1,9 @@
#include <eepp/ui/uitooltip.hpp>
#include <eepp/ui/uiwidget.hpp>
#include <eepp/graphics/text.hpp>
#include <eepp/ui/uithememanager.hpp>
#include <eepp/ui/css/propertydefinition.hpp>
#include <eepp/scene/actions/actions.hpp>
#include <eepp/graphics/text.hpp>
#include <eepp/graphics/fontmanager.hpp>
namespace EE { namespace UI {
@@ -328,24 +329,40 @@ void UITooltip::setFontStyleConfig(const UIFontStyleConfig & styleConfig) {
}
bool UITooltip::applyProperty( const StyleSheetProperty& attribute, const Uint32& state ) {
const std::string& name = attribute.getName();
if ( !checkPropertyDefinition( attribute ) ) return false;
if ( "color" == name ) {
setFontColor( attribute.asColor() );
} else if ( "shadow-color" == name || "textshadowcolor" == name ) {
setFontShadowColor( attribute.asColor() );
} else if ( "font-family" == name || "font-name" == name || "fontfamily" == name || "fontname" == name ) {
setFont( FontManager::instance()->getByName( attribute.asString() ) );
} else if ( "font-size" == name || "textsize" == name || "fontsize" == name ) {
setCharacterSize( attribute.asDpDimensionI() );
} else if ( "font-style" == name || "textstyle" == name || "fontstyle" == name ) {
setFontStyle( attribute.asFontStyle() );
} else if ( "text-stroke-width" == name || "fontoutlinethickness" == name ) {
setOutlineThickness( attribute.asDpDimension() );
} else if ( "text-stroke-color" == name || "fontoutlinecolor" == name ) {
setOutlineColor( attribute.asColor() );
} else {
return UIWidget::applyProperty( attribute, state );
switch ( attribute.getPropertyDefinition()->getPropertyId() ) {
case PropertyId::Color:
setFontColor( attribute.asColor() );
break;
case PropertyId::ShadowColor:
setFontShadowColor( attribute.asColor() );
break;
case PropertyId::FontFamily:
setFont( FontManager::instance()->getByName( attribute.asString() ) );
break;
case PropertyId::FontSize:
setCharacterSize( attribute.asDpDimensionI() );
break;
case PropertyId::FontStyle:
setFontStyle( attribute.asFontStyle() );
break;
case PropertyId::TextStrokeWidth:
setOutlineThickness( PixelDensity::dpToPx( attribute.asDpDimension() ) );
break;
case PropertyId::TextStrokeColor:
setOutlineColor( attribute.asColor() );
break;
case PropertyId::TextAlign:
{
std::string align = String::toLower( attribute.value() );
if ( align == "center" ) setFlags( UI_HALIGN_CENTER );
else if ( align == "left" ) setFlags( UI_HALIGN_LEFT );
else if ( align == "right" ) setFlags( UI_HALIGN_RIGHT );
break;
}
default:
return UIWidget::applyProperty( attribute, state );
}
return true;

View File

@@ -1,4 +1,5 @@
#include <eepp/ui/uitouchdragablewidget.hpp>
#include <eepp/ui/css/propertydefinition.hpp>
#include <eepp/scene/scenenode.hpp>
namespace EE { namespace UI {
@@ -146,14 +147,17 @@ void UITouchDragableWidget::scheduledUpdate( const Time& time ) {
}
bool UITouchDragableWidget::applyProperty( const StyleSheetProperty& attribute, const Uint32& state ) {
const std::string& name = attribute.getName();
if ( !checkPropertyDefinition( attribute ) ) return false;
if ( "touch-drag" == name || "touchdrag" == name ) {
setTouchDragEnabled( attribute.asBool() );
} else if ( "touchdrag-deceleration" == name || "touchdragdeceleration" == name ) {
setTouchDragDeceleration( Vector2f( attribute.asFloat(), attribute.asFloat() ) );
} else {
return UIWidget::applyProperty( attribute, state );
switch ( attribute.getPropertyDefinition()->getPropertyId() ) {
case PropertyId::TouchDrag:
setTouchDragEnabled( attribute.asBool() );
break;
case PropertyId::TouchDragDeceleration:
setTouchDragDeceleration( attribute.asVector2f() );
break;
default:
return UIWidget::applyProperty( attribute, state );
}
return true;

View File

@@ -895,6 +895,14 @@ std::vector<UIWidget*> UIWidget::querySelectorAll( const CSS::StyleSheetSelector
return widgets;
}
bool UIWidget::checkPropertyDefinition( const StyleSheetProperty& property ) {
if ( property.getPropertyDefinition() == NULL ) {
eePRINTL( "applyProperty: Property %s not defined!", property.getName().c_str() );
return false;
}
return true;
}
UIWidget* UIWidget::querySelector( const std::string& selector ) {
return querySelector( CSS::StyleSheetSelector( selector ) );
}
@@ -917,13 +925,9 @@ void UIWidget::setStyleSheetProperty( const std::string& name, const std::string
}
bool UIWidget::applyProperty( const StyleSheetProperty& attribute, const Uint32& state ) {
if ( !checkPropertyDefinition( attribute ) ) return false;
bool attributeSet = true;
if ( attribute.getPropertyDefinition() == NULL ) {
eePRINTL( "applyProperty: Property %s not defined!", attribute.getName().c_str() );
return false;
}
switch ( static_cast<PropertyId>( attribute.getPropertyDefinition()->getId() ) ) {
case PropertyId::Id:
setId( attribute.value() );
@@ -1256,20 +1260,6 @@ bool UIWidget::applyProperty( const StyleSheetProperty& attribute, const Uint32&
SAVE_NORMAL_STATE_ATTR( getForeground()->getLayer(0)->getPositionEq() );
setForegroundPosition( attribute.value(), 0 );
break;
case PropertyId::Background:
if ( Color::isColorString( attribute.getValue() ) ) {
applyProperty( StyleSheetProperty( "background-color", attribute.getValue() ) );
} else {
applyProperty( StyleSheetProperty( "background-image", attribute.getValue() ) );
}
break;
case PropertyId::Foreground:
if ( Color::isColorString( attribute.getValue() ) ) {
applyProperty( StyleSheetProperty( "foreground-color", attribute.getValue() ) );
} else {
applyProperty( StyleSheetProperty( "foreground-image", attribute.getValue() ) );
}
break;
case PropertyId::RotationOriginPoint:
SAVE_NORMAL_STATE_ATTR( getRotationOriginPoint().toString() );
setRotationOriginPoint( attribute.asOriginPoint() );

View File

@@ -1,18 +1,19 @@
#include <eepp/ui/uiwindow.hpp>
#include <eepp/ui/uithememanager.hpp>
#include <eepp/ui/uilinearlayout.hpp>
#include <eepp/ui/uirelativelayout.hpp>
#include <eepp/ui/uiscenenode.hpp>
#include <eepp/ui/css/propertydefinition.hpp>
#include <eepp/graphics/primitives.hpp>
#include <eepp/graphics/text.hpp>
#include <eepp/graphics/framebuffer.hpp>
#include <eepp/graphics/renderer/renderer.hpp>
#include <eepp/graphics/textureregion.hpp>
#include <eepp/graphics/globalbatchrenderer.hpp>
#include <eepp/ui/uilinearlayout.hpp>
#include <eepp/ui/uirelativelayout.hpp>
#include <eepp/scene/scenenode.hpp>
#include <eepp/ui/uiscenenode.hpp>
#include <pugixml/pugixml.hpp>
#include <eepp/scene/scenemanager.hpp>
#include <eepp/scene/actions/actions.hpp>
#include <pugixml/pugixml.hpp>
namespace EE { namespace UI {
@@ -1379,72 +1380,86 @@ void UIWindow::resizeCursor() {
}
bool UIWindow::applyProperty( const StyleSheetProperty& attribute, const Uint32& state ) {
const std::string& name = attribute.getName();
if ( !checkPropertyDefinition( attribute ) ) return false;
if ( "width" == name ) {
setSize( attribute.asDpDimension(), getSize().getHeight() );
} else if ( "height" == name ) {
setSize( getSize().getWidth(), attribute.asDpDimension() );
} else if ( "title" == name ) {
setTitle( attribute.asString() );
} else if ( "base-alpha" == name || "basealpha" == name ) {
unsigned int val = attribute.asUint();
if ( val <= 255 )
setBaseAlpha( (Uint8)val );
} else if ( "buttons-position-offset" == name || "buttonspositionoffset" == name ) {
mStyleConfig.ButtonsPositionFixer = attribute.asVector2i();
fixChildsSize();
} else if ( "window-flags" == name || "winflags" == name ) {
std::string flagsStr = attribute.asString();
String::toLowerInPlace( flagsStr );
std::vector<std::string> strings = String::split( flagsStr, '|' );
Uint32 winflags = 0;
switch ( attribute.getPropertyDefinition()->getPropertyId() ) {
case PropertyId::Width:
setSize( attribute.asDpDimension(), getSize().getHeight() );
break;
case PropertyId::Height:
setSize( getSize().getWidth(), attribute.asDpDimension() );
break;
case PropertyId::Title:
setTitle( attribute.asString() );
break;
case PropertyId::BaseAlpha:
setBaseAlpha( (Uint8)eemin( attribute.asUint(), 255u ) );
break;
case PropertyId::ButtonsPositionOffset:
mStyleConfig.ButtonsPositionFixer = attribute.asVector2i();
fixChildsSize();
break;
case PropertyId::WindowFlags:
{
std::string flagsStr = attribute.asString();
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 ( 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_DECORATION;
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;
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_DECORATION;
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;
}
/// TODO: WinFlags should replace old winFlags
mStyleConfig.WinFlags |= winflags;
updateWinFlags();
}
/// TODO: WinFlags should replace old winFlags
mStyleConfig.WinFlags |= winflags;
updateWinFlags();
break;
}
} else if ( "decoration-size" == name || "decorationsize" == name ) {
mStyleConfig.DecorationSize = attribute.asSizei();
fixChildsSize();
} else if ( "border-size" == name || "bordersize" == name ) {
mStyleConfig.BorderSize = attribute.asSizei();
fixChildsSize();
} else if ( "min-window-size" == name || "minwindowsize" == name ) {
mStyleConfig.MinWindowSize = attribute.asSizef();
fixChildsSize();
} else if ( "buttons-separation" == name || "buttonsseparation" == name ) {
mStyleConfig.ButtonsSeparation = attribute.asDpDimensionUint();
fixChildsSize();
} else if ( "min-corner-distance" == name || "mincornerdistance" == name ) {
mStyleConfig.MinCornerDistance = attribute.asDpDimensionI();
} else if ( "decoration-auto-size" == name || "decorationautosize" == name ) {
mStyleConfig.DecorationAutoSize = attribute.asBool();
fixChildsSize();
} else if ( "border-auto-size" == name || "borderautosize" == name ) {
mStyleConfig.BorderAutoSize = attribute.asBool();
fixChildsSize();
} else {
return UIWidget::applyProperty( attribute, state );
case PropertyId::DecorationSize:
mStyleConfig.DecorationSize = attribute.asSizei();
fixChildsSize();
break;
case PropertyId::BorderSize:
mStyleConfig.BorderSize = attribute.asSizei();
fixChildsSize();
break;
case PropertyId::MinWindowSize:
mStyleConfig.MinWindowSize = attribute.asSizef();
fixChildsSize();
break;
case PropertyId::ButtonsSeparation:
mStyleConfig.ButtonsSeparation = attribute.asDpDimensionUint();
fixChildsSize();
break;
case PropertyId::MinCornerDistance:
mStyleConfig.MinCornerDistance = attribute.asDpDimensionI();
break;
case PropertyId::DecorationAutoSize:
mStyleConfig.DecorationAutoSize = attribute.asBool();
fixChildsSize();
break;
case PropertyId::BorderAutoSize:
mStyleConfig.BorderAutoSize = attribute.asBool();
fixChildsSize();
break;
default:
return UIWidget::applyProperty( attribute, state );
}
return true;

View File

@@ -1,8 +1,9 @@
#include <eepp/ui/uiwinmenu.hpp>
#include <eepp/ui/uithememanager.hpp>
#include <eepp/ui/uiscenenode.hpp>
#include <eepp/ui/css/propertydefinition.hpp>
#include <eepp/graphics/textureregion.hpp>
#include <eepp/scene/scenemanager.hpp>
#include <eepp/ui/uiscenenode.hpp>
#include <pugixml/pugixml.hpp>
namespace EE { namespace UI {
@@ -159,18 +160,23 @@ void UIWinMenu::setFirstButtonMargin( const Uint32& buttonMargin ) {
}
bool UIWinMenu::applyProperty( const StyleSheetProperty& attribute, const Uint32 & state ) {
const std::string& name = attribute.getName();
if ( !checkPropertyDefinition( attribute ) ) return false;
if ( "margin-between-buttons" == name || "marginbetweenbuttons" == name ) {
setMarginBetweenButtons( attribute.asDpDimensionUint() );
} else if ( "button-margin" == name || "buttonmargin" == name ) {
setButtonMargin( attribute.asDpDimensionUint() );
} else if ( "menu-height" == name || "menuheight" == name ) {
setMenuHeight( attribute.asDpDimensionUint() );
} else if ( "first-button-margin-left" == name || "firstbuttonmarginleft" == name ) {
setFirstButtonMargin( attribute.asDpDimensionUint() );
} else {
return UIWidget::applyProperty( attribute, state );
switch ( attribute.getPropertyDefinition()->getPropertyId() ) {
case PropertyId::MarginBetweenButtons:
setMarginBetweenButtons( attribute.asDpDimensionUint() );
break;
case PropertyId::ButtonMargin:
setButtonMargin( attribute.asDpDimensionUint() );
break;
case PropertyId::MenuHeight:
setMenuHeight( attribute.asDpDimensionUint() );
break;
case PropertyId::FirstButtonMarginLeft:
setFirstButtonMargin( attribute.asDpDimensionUint() );
break;
default:
return UIWidget::applyProperty( attribute, state );
}
return true;