mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-05-28 17:16:29 +03:00
More general UI code clean up and documentation.
This commit is contained in:
@@ -22,14 +22,14 @@ TabWidget {
|
||||
tab-separation: -1dp;
|
||||
line-below-tabs: true;
|
||||
line-below-tabs-color: #2f3030;
|
||||
line-below-tabs-y-offset: 0dp;
|
||||
line-below-tabs-y-offset: -1dp;
|
||||
}
|
||||
|
||||
ProgressBar {
|
||||
display-percent: true;
|
||||
vertical-expand: true;
|
||||
filler-padding: 2dp;
|
||||
movement-speed: 32 0;
|
||||
padding: 2dp;
|
||||
}
|
||||
|
||||
WinMenu {
|
||||
|
||||
@@ -10,14 +10,14 @@ TabWidget {
|
||||
tab-separation: -1dp;
|
||||
line-below-tabs: true;
|
||||
line-below-tabs-color: #2f3030;
|
||||
line-below-tabs-y-offset: 0dp;
|
||||
line-below-tabs-y-offset: -1dp;
|
||||
}
|
||||
|
||||
ProgressBar {
|
||||
display-percent: true;
|
||||
vertical-expand: true;
|
||||
filler-padding: 2dp;
|
||||
movement-speed: 32 0;
|
||||
padding: 2dp;
|
||||
}
|
||||
|
||||
WinMenu {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -126,10 +126,6 @@ enum class PropertyId : Uint32 {
|
||||
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" ),
|
||||
|
||||
@@ -18,7 +18,6 @@ enum class ShorthandId : Uint32 {
|
||||
ForegroundPosition = String::hash( "foreground-position" ),
|
||||
LayoutMargin = String::hash( "layout-margin" ),
|
||||
LayoutMarginUnderscore = String::hash( "layout_margin" ),
|
||||
FillerPadding = String::hash( "filler-padding" ),
|
||||
RotationOriginPoint = String::hash( "rotation-origin-point" ),
|
||||
ScaleOriginPoint = String::hash( "scale-origin-point" ),
|
||||
BorderColor = String::hash( "border-color" ),
|
||||
|
||||
@@ -14,7 +14,6 @@ class EE_API UIProgressBar : public UIWidget {
|
||||
bool DisplayPercent = false;
|
||||
bool VerticalExpand = true;
|
||||
Vector2f MovementSpeed = Vector2f( 64.f, 0 );
|
||||
Rectf FillerPadding;
|
||||
};
|
||||
|
||||
static UIProgressBar* New();
|
||||
@@ -49,10 +48,6 @@ class EE_API UIProgressBar : public UIWidget {
|
||||
|
||||
const bool& getVerticalExpand() const;
|
||||
|
||||
void setFillerPadding( const Rectf& padding );
|
||||
|
||||
const Rectf& getFillerPadding() const;
|
||||
|
||||
void setDisplayPercent( const bool& displayPercent );
|
||||
|
||||
const bool& getDisplayPercent() const;
|
||||
|
||||
@@ -267,10 +267,6 @@ void StyleSheetSpecification::registerDefaultProperties() {
|
||||
registerProperty( "total-steps", "" ).setType( PropertyType::NumberInt );
|
||||
registerProperty( "vertical-expand", "" ).setType( PropertyType::Bool );
|
||||
registerProperty( "display-percent", "" ).setType( PropertyType::Bool );
|
||||
registerProperty( "filler-padding-left", "" ).setType( PropertyType::NumberLength );
|
||||
registerProperty( "filler-padding-top", "" ).setType( PropertyType::NumberLength );
|
||||
registerProperty( "filler-padding-right", "" ).setType( PropertyType::NumberLength );
|
||||
registerProperty( "filler-padding-bottom", "" ).setType( PropertyType::NumberLength );
|
||||
registerProperty( "movement-speed", "" ).setType( PropertyType::Vector2 );
|
||||
registerProperty( "min-value", "" ).setType( PropertyType::NumberFloat );
|
||||
registerProperty( "max-value", "" ).setType( PropertyType::NumberFloat );
|
||||
@@ -388,10 +384,6 @@ void StyleSheetSpecification::registerDefaultProperties() {
|
||||
"foreground",
|
||||
{"foreground-color", "foreground-image", "foreground-repeat", "foreground-position"},
|
||||
"background" );
|
||||
registerShorthand( "filler-padding",
|
||||
{"filler-padding-top", "filler-padding-right", "filler-padding-bottom",
|
||||
"filler-padding-left"},
|
||||
"box" );
|
||||
registerShorthand( "box-margin", {"column-margin", "row-margin"}, "single-value-vector" );
|
||||
registerShorthand( "background-position", {"background-position-x", "background-position-y"},
|
||||
"background-position" );
|
||||
|
||||
@@ -13,7 +13,7 @@ UILoader::UILoader() :
|
||||
UIWidget( "loader" ),
|
||||
mRadius( 0 ),
|
||||
mOutlineThickness( PixelDensity::dpToPx( 8 ) ),
|
||||
mColor( Color::Transparent ),
|
||||
mColor( Color::White ),
|
||||
mArcAngle( 0 ),
|
||||
mArcStartAngle( 0 ),
|
||||
mProgress( 0 ),
|
||||
|
||||
@@ -42,8 +42,6 @@ void UIProgressBar::draw() {
|
||||
if ( NULL == mFillerSkin )
|
||||
return;
|
||||
|
||||
Rectf fillerPadding = PixelDensity::dpToPx( mStyleConfig.FillerPadding );
|
||||
|
||||
Float Height = (Float)mSize.getHeight();
|
||||
|
||||
if ( !mStyleConfig.VerticalExpand )
|
||||
@@ -52,22 +50,22 @@ void UIProgressBar::draw() {
|
||||
if ( Height > mSize.getHeight() )
|
||||
Height = mSize.getHeight();
|
||||
|
||||
Sizef fSize( ( ( mSize.getWidth() - fillerPadding.Left - fillerPadding.Right ) * mProgress ) /
|
||||
Sizef fSize( ( ( mSize.getWidth() - mRealPadding.Left - mRealPadding.Right ) * mProgress ) /
|
||||
mTotalSteps,
|
||||
Height - fillerPadding.Top - fillerPadding.Bottom );
|
||||
Height - mRealPadding.Top - mRealPadding.Bottom );
|
||||
Sizei rSize( PixelDensity::dpToPxI( mFillerSkin->getSize() ) );
|
||||
Sizei numTiles( (Int32)eeceil( (Float)fSize.getWidth() / (Float)rSize.getWidth() + 2 ),
|
||||
(Int32)eeceil( (Float)fSize.getHeight() / (Float)rSize.getHeight() ) + 2 );
|
||||
|
||||
clipSmartEnable( mScreenPos.x + fillerPadding.Left, mScreenPos.y + fillerPadding.Top,
|
||||
clipSmartEnable( mScreenPos.x + mRealPadding.Left, mScreenPos.y + mRealPadding.Top,
|
||||
fSize.getWidth(), fSize.getHeight() );
|
||||
|
||||
for ( int y = -1; y < numTiles.y; y++ ) {
|
||||
for ( int x = -1; x < numTiles.x; x++ ) {
|
||||
mFillerSkin->draw(
|
||||
Vector2f( (Int32)mOffset.x + mScreenPosi.x + fillerPadding.Left +
|
||||
Vector2f( (Int32)mOffset.x + mScreenPosi.x + mRealPadding.Left +
|
||||
x * rSize.getWidth(),
|
||||
mOffset.y + mScreenPosi.y + fillerPadding.Top + y * rSize.getHeight() ),
|
||||
mOffset.y + mScreenPosi.y + mRealPadding.Top + y * rSize.getHeight() ),
|
||||
Sizef( rSize.getWidth(), rSize.getHeight() ) );
|
||||
}
|
||||
}
|
||||
@@ -106,7 +104,7 @@ void UIProgressBar::setTheme( UITheme* Theme ) {
|
||||
Float meH = (Float)getSkinSize().getHeight();
|
||||
Float otH = (Float)mFillerSkin->getSize().getHeight();
|
||||
Float res = Math::roundUp( ( meH - otH ) * 0.5f );
|
||||
mStyleConfig.FillerPadding = Rectf( res, res, res, res );
|
||||
setPadding( Rectf( res, res, res, res ) );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -178,17 +176,6 @@ const bool& UIProgressBar::getVerticalExpand() const {
|
||||
return mStyleConfig.VerticalExpand;
|
||||
}
|
||||
|
||||
void UIProgressBar::setFillerPadding( const Rectf& padding ) {
|
||||
mStyleConfig.FillerPadding = padding;
|
||||
|
||||
onPositionChange();
|
||||
onSizeChange();
|
||||
}
|
||||
|
||||
const Rectf& UIProgressBar::getFillerPadding() const {
|
||||
return mStyleConfig.FillerPadding;
|
||||
}
|
||||
|
||||
void UIProgressBar::setDisplayPercent( const bool& DisplayPercent ) {
|
||||
mStyleConfig.DisplayPercent = DisplayPercent;
|
||||
|
||||
@@ -223,14 +210,6 @@ std::string UIProgressBar::getPropertyString( const PropertyDefinition* property
|
||||
return mStyleConfig.VerticalExpand ? "true" : "false";
|
||||
case PropertyId::DisplayPercent:
|
||||
return mStyleConfig.DisplayPercent ? "true" : "false";
|
||||
case PropertyId::FillerPaddingLeft:
|
||||
return String::fromFloat( mStyleConfig.FillerPadding.Left, "dp" );
|
||||
case PropertyId::FillerPaddingTop:
|
||||
return String::fromFloat( mStyleConfig.FillerPadding.Top, "dp" );
|
||||
case PropertyId::FillerPaddingRight:
|
||||
return String::fromFloat( mStyleConfig.FillerPadding.Right, "dp" );
|
||||
case PropertyId::FillerPaddingBottom:
|
||||
return String::fromFloat( mStyleConfig.FillerPadding.Bottom, "dp" );
|
||||
case PropertyId::MovementSpeed:
|
||||
return String::fromFloat( getMovementSpeed().x ) + " " +
|
||||
String::fromFloat( getMovementSpeed().y );
|
||||
@@ -256,26 +235,6 @@ bool UIProgressBar::applyProperty( const StyleSheetProperty& attribute ) {
|
||||
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;
|
||||
|
||||
@@ -348,7 +348,7 @@ bool UIPushButton::applyProperty( const StyleSheetProperty& attribute ) {
|
||||
setIconMinimumSize( attribute.asSizei() );
|
||||
break;
|
||||
case PropertyId::IconHorizontalMargin:
|
||||
setIconHorizontalMargin( attribute.asDpDimensionI() );
|
||||
setIconHorizontalMargin( attribute.asDpDimensionI( this ) );
|
||||
break;
|
||||
case PropertyId::IconAutoMargin:
|
||||
mStyleConfig.IconAutoMargin = attribute.asBool();
|
||||
|
||||
@@ -17,13 +17,13 @@ UITabWidget::UITabWidget() :
|
||||
UIWidget( "tabwidget" ), mTabSelected( NULL ), mTabSelectedIndex( eeINDEX_NOT_FOUND ) {
|
||||
setHorizontalAlign( UI_HALIGN_CENTER );
|
||||
|
||||
mTabContainer = UIWidget::New();
|
||||
mTabContainer = UIWidget::NewWithTag( "tabwidget::tabcontainer" );
|
||||
mTabContainer->setPixelsSize( mSize.getWidth(), mStyleConfig.TabWidgetHeight )
|
||||
->setParent( this )
|
||||
->setPosition( 0, 0 );
|
||||
mTabContainer->clipEnable();
|
||||
|
||||
mCtrlContainer = UIWidget::New();
|
||||
mCtrlContainer = UIWidget::NewWithTag( "tabwidget::container" );
|
||||
mCtrlContainer
|
||||
->setPixelsSize( mSize.getWidth(),
|
||||
mSize.getHeight() - PixelDensity::dpToPx( mStyleConfig.TabWidgetHeight ) )
|
||||
@@ -128,7 +128,6 @@ void UITabWidget::setStyleConfig( const StyleConfig& styleConfig ) {
|
||||
mStyleConfig = styleConfig;
|
||||
mStyleConfig.TabWidgetHeight = tabWidgetHeight;
|
||||
setContainerSize();
|
||||
setTabContainerSize();
|
||||
orderTabs();
|
||||
}
|
||||
|
||||
|
||||
@@ -1291,7 +1291,11 @@ bool UIWidget::applyProperty( const StyleSheetProperty& attribute ) {
|
||||
String::toLowerInPlace( gravity );
|
||||
std::vector<std::string> strings = String::split( gravity, '|' );
|
||||
|
||||
if ( strings.size() ) {
|
||||
if ( strings.empty() ) {
|
||||
strings = String::split( gravity, ' ' );
|
||||
}
|
||||
|
||||
if ( !strings.empty() ) {
|
||||
for ( std::size_t i = 0; i < strings.size(); i++ ) {
|
||||
std::string cur = strings[i];
|
||||
String::toLowerInPlace( cur );
|
||||
@@ -1333,7 +1337,7 @@ bool UIWidget::applyProperty( const StyleSheetProperty& attribute ) {
|
||||
notifyLayoutAttrChange();
|
||||
} else if ( "clip" == cur ) {
|
||||
clipEnable();
|
||||
} else if ( "multi" == cur ) {
|
||||
} else if ( "multiselect" == cur ) {
|
||||
setFlags( UI_MULTI_SELECT );
|
||||
} else if ( "auto_padding" == cur || "autopadding" == cur ) {
|
||||
setFlags( UI_AUTO_PADDING );
|
||||
|
||||
Reference in New Issue
Block a user