From 8da12353879e831f0cb8b80d9207202cbbaa7fff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Lucas=20Golini?= Date: Sun, 26 Jul 2020 15:41:03 -0300 Subject: [PATCH] UILinearLayout now uses all pixels unit (for coordinates and sizes). Some minor improvements in UITableView and UITreeView. --- include/eepp/ui/uicodeeditor.hpp | 2 + include/eepp/ui/uiwidget.hpp | 11 +- src/eepp/scene/actions/marginmove.cpp | 16 +- src/eepp/ui/tools/uicolorpicker.cpp | 17 +-- src/eepp/ui/uicheckbox.cpp | 14 +- src/eepp/ui/uicodeeditor.cpp | 16 +- src/eepp/ui/uidropdownlist.cpp | 2 +- src/eepp/ui/uifiledialog.cpp | 14 +- src/eepp/ui/uiimage.cpp | 16 +- src/eepp/ui/uilinearlayout.cpp | 211 ++++++++++++++------------ src/eepp/ui/uilistbox.cpp | 2 +- src/eepp/ui/uimenu.cpp | 12 +- src/eepp/ui/uimessagebox.cpp | 8 +- src/eepp/ui/uinode.cpp | 7 +- src/eepp/ui/uiprogressbar.cpp | 6 +- src/eepp/ui/uipushbutton.cpp | 20 +-- src/eepp/ui/uiradiobutton.cpp | 18 +-- src/eepp/ui/uiscrollablewidget.cpp | 16 +- src/eepp/ui/uiscrollbar.cpp | 2 +- src/eepp/ui/uisplitter.cpp | 74 ++++----- src/eepp/ui/uisprite.cpp | 14 +- src/eepp/ui/uitable.cpp | 4 +- src/eepp/ui/uitableview.cpp | 18 +-- src/eepp/ui/uitabwidget.cpp | 10 +- src/eepp/ui/uitextinput.cpp | 36 ++--- src/eepp/ui/uitextinputpassword.cpp | 28 ++-- src/eepp/ui/uitextureregion.cpp | 22 +-- src/eepp/ui/uitextview.cpp | 38 ++--- src/eepp/ui/uitooltip.cpp | 20 +-- src/eepp/ui/uitreeview.cpp | 46 +++--- src/eepp/ui/uiwidget.cpp | 33 ++-- src/eepp/ui/uiwindow.cpp | 12 +- src/tests/test_all/test.cpp | 30 ++-- src/tools/codeeditor/codeeditor.cpp | 37 +++-- 34 files changed, 439 insertions(+), 393 deletions(-) diff --git a/include/eepp/ui/uicodeeditor.hpp b/include/eepp/ui/uicodeeditor.hpp index 9567a6835..de237b217 100644 --- a/include/eepp/ui/uicodeeditor.hpp +++ b/include/eepp/ui/uicodeeditor.hpp @@ -252,6 +252,8 @@ class EE_API UICodeEditor : public UIWidget, public TextDocument::Client { void addUnlockedCommands( const std::vector& commands ); + bool isUnlockedCommand( const std::string& command ); + virtual bool applyProperty( const StyleSheetProperty& attribute ); virtual std::string getPropertyString( const PropertyDefinition* propertyDef, diff --git a/include/eepp/ui/uiwidget.hpp b/include/eepp/ui/uiwidget.hpp index 659cac510..9238816b9 100644 --- a/include/eepp/ui/uiwidget.hpp +++ b/include/eepp/ui/uiwidget.hpp @@ -65,9 +65,11 @@ class EE_API UIWidget : public UINode { void updateAnchorsDistances(); - const Rect& getLayoutMargin() const; + const Rectf& getLayoutMargin() const; - UIWidget* setLayoutMargin( const Rect& margin ); + const Rectf& getLayoutPixelsMargin() const; + + UIWidget* setLayoutMargin( const Rectf& margin ); UIWidget* setLayoutMarginLeft( const Float& marginLeft ); @@ -249,9 +251,10 @@ class EE_API UIWidget : public UINode { UIStyle* mStyle; UITooltip* mTooltip; Rect mDistToBorder; - Rect mLayoutMargin; + Rectf mLayoutMargin; + Rectf mLayoutMarginPx; Rectf mPadding; - Rectf mRealPadding; + Rectf mPaddingPx; Float mLayoutWeight; Uint32 mLayoutGravity; SizePolicy mWidthPolicy; diff --git a/src/eepp/scene/actions/marginmove.cpp b/src/eepp/scene/actions/marginmove.cpp index ed7a4ec6d..b51108fc7 100644 --- a/src/eepp/scene/actions/marginmove.cpp +++ b/src/eepp/scene/actions/marginmove.cpp @@ -132,14 +132,14 @@ void MarginMove::onUpdate( const Time& ) { UIWidget* widget = static_cast( mNode ); widget->setLayoutMargin( - Rect( ( mFlags & InterpolateFlag::Left ) ? mInterpolationLeft.getPosition() - : widget->getLayoutMargin().Left, - ( mFlags & InterpolateFlag::Top ) ? mInterpolationTop.getPosition() - : widget->getLayoutMargin().Top, - ( mFlags & InterpolateFlag::Right ) ? mInterpolationRight.getPosition() - : widget->getLayoutMargin().Right, - ( mFlags & InterpolateFlag::Bottom ) ? mInterpolationBottom.getPosition() - : widget->getLayoutMargin().Bottom ) ); + Rectf( ( mFlags & InterpolateFlag::Left ) ? mInterpolationLeft.getPosition() + : widget->getLayoutMargin().Left, + ( mFlags & InterpolateFlag::Top ) ? mInterpolationTop.getPosition() + : widget->getLayoutMargin().Top, + ( mFlags & InterpolateFlag::Right ) ? mInterpolationRight.getPosition() + : widget->getLayoutMargin().Right, + ( mFlags & InterpolateFlag::Bottom ) ? mInterpolationBottom.getPosition() + : widget->getLayoutMargin().Bottom ) ); } } diff --git a/src/eepp/ui/tools/uicolorpicker.cpp b/src/eepp/ui/tools/uicolorpicker.cpp index 08625b7c3..400891596 100644 --- a/src/eepp/ui/tools/uicolorpicker.cpp +++ b/src/eepp/ui/tools/uicolorpicker.cpp @@ -369,9 +369,8 @@ Texture* UIColorPicker::createHueTexture( const Sizef& size ) { } TextureFactory* TF = TextureFactory::instance(); - Uint32 texId = - TF->loadFromPixels( image.getPixelsPtr(), image.getWidth(), image.getHeight(), - image.getChannels() ); + Uint32 texId = TF->loadFromPixels( image.getPixelsPtr(), image.getWidth(), image.getHeight(), + image.getChannels() ); return TF->getTexture( texId ); } @@ -424,14 +423,14 @@ void UIColorPicker::updateColorPicker() { void UIColorPicker::updateGuideLines() { mVerticalLine->setLayoutMargin( - Rect( mColorPicker->getSize().getWidth() * mHsv.hsv.s, 0.f, 0.f, 0.f ) ); - mHorizontalLine->setLayoutMargin( Rect( + Rectf( mColorPicker->getSize().getWidth() * mHsv.hsv.s, 0.f, 0.f, 0.f ) ); + mHorizontalLine->setLayoutMargin( Rectf( 0.f, mColorPicker->getSize().getHeight() - mColorPicker->getSize().getHeight() * mHsv.hsv.v, 0.f, 0.f ) ); - mHueLine->setLayoutMargin( Rect( 0.f, - mHuePicker->getSize().getHeight() - - mHsv.hsv.h / 360.f * mHuePicker->getSize().getHeight(), - 0.f, 0.f ) ); + mHueLine->setLayoutMargin( Rectf( 0.f, + mHuePicker->getSize().getHeight() - + mHsv.hsv.h / 360.f * mHuePicker->getSize().getHeight(), + 0.f, 0.f ) ); mCurrentColor->setForegroundColor( Color::fromHsv( mHsv ) ); } diff --git a/src/eepp/ui/uicheckbox.cpp b/src/eepp/ui/uicheckbox.cpp index 57e177db1..6f9670ddf 100644 --- a/src/eepp/ui/uicheckbox.cpp +++ b/src/eepp/ui/uicheckbox.cpp @@ -77,7 +77,7 @@ void UICheckBox::onAutoSize() { if ( getSize().getWidth() == 0 ) { setInternalPixelsWidth( (int)mTextCache->getTextWidth() + mActiveButton->getPixelsSize().getWidth() + mTextSeparation + - mRealPadding.Left + mRealPadding.Right ); + mPaddingPx.Left + mPaddingPx.Right ); } if ( getSize().getHeight() == 0 ) { @@ -87,14 +87,14 @@ void UICheckBox::onAutoSize() { } if ( mWidthPolicy == SizePolicy::WrapContent ) { - setInternalPixelsWidth( (int)mTextCache->getTextWidth() + mRealPadding.Left + - mRealPadding.Right + mActiveButton->getPixelsSize().getWidth() + + setInternalPixelsWidth( (int)mTextCache->getTextWidth() + mPaddingPx.Left + + mPaddingPx.Right + mActiveButton->getPixelsSize().getWidth() + PixelDensity::dpToPx( mTextSeparation ) ); } if ( mHeightPolicy == SizePolicy::WrapContent ) { - setInternalPixelsHeight( (int)mTextCache->getTextHeight() + mRealPadding.Top + - mRealPadding.Bottom ); + setInternalPixelsHeight( (int)mTextCache->getTextHeight() + mPaddingPx.Top + + mPaddingPx.Bottom ); } alignFix(); @@ -171,7 +171,7 @@ void UICheckBox::alignFix() { switch ( Font::getHorizontalAlign( getFlags() ) ) { case UI_HALIGN_CENTER: mRealAlignOffset.x = - ( Float )( ( Int32 )( ( mSize.x - mRealPadding.Left - mRealPadding.Right - + ( Float )( ( Int32 )( ( mSize.x - mPaddingPx.Left - mPaddingPx.Right - mTextCache->getTextWidth() - mActiveButton->getPixelsSize().getWidth() + PixelDensity::dpToPx( mTextSeparation ) ) / @@ -179,7 +179,7 @@ void UICheckBox::alignFix() { mActiveButton->getPixelsSize().getWidth() + PixelDensity::dpToPx( mTextSeparation ); break; case UI_HALIGN_RIGHT: - mRealAlignOffset.x = ( (Float)mSize.x - mRealPadding.Left - mRealPadding.Right - + mRealAlignOffset.x = ( (Float)mSize.x - mPaddingPx.Left - mPaddingPx.Right - (Float)mTextCache->getTextWidth() ); break; case UI_HALIGN_LEFT: diff --git a/src/eepp/ui/uicodeeditor.cpp b/src/eepp/ui/uicodeeditor.cpp index 56fef665e..6f03de652 100644 --- a/src/eepp/ui/uicodeeditor.cpp +++ b/src/eepp/ui/uicodeeditor.cpp @@ -203,8 +203,8 @@ void UICodeEditor::draw() { Float lineHeight = getLineHeight(); int lineNumberDigits = getLineNumberDigits(); Float lineNumberWidth = mShowLineNumber ? getLineNumberWidth() : 0.f; - Vector2f screenStart( eefloor( mScreenPos.x + mRealPadding.Left ), - eefloor( mScreenPos.y + mRealPadding.Top ) ); + Vector2f screenStart( eefloor( mScreenPos.x + mPaddingPx.Left ), + eefloor( mScreenPos.y + mPaddingPx.Top ) ); Vector2f start( screenStart.x + lineNumberWidth, screenStart.y ); Vector2f startScroll( start - mScroll ); Primitives primitives; @@ -392,7 +392,7 @@ void UICodeEditor::disableEditorFeatures() { Float UICodeEditor::getViewportWidth( const bool& forceVScroll ) const { Float vScrollWidth = mVScrollBar->isVisible() || forceVScroll ? mVScrollBar->getPixelsSize().getWidth() : 0.f; - Float viewWidth = eefloor( mSize.getWidth() - mRealPadding.Left - mRealPadding.Right - + Float viewWidth = eefloor( mSize.getWidth() - mPaddingPx.Left - mPaddingPx.Right - getLineNumberWidth() - vScrollWidth ); return viewWidth; } @@ -693,8 +693,8 @@ Uint32 UICodeEditor::onKeyUp( const KeyEvent& event ) { TextPosition UICodeEditor::resolveScreenPosition( const Vector2f& position ) const { Vector2f localPos( convertToNodeSpace( position ) ); localPos += mScroll; - localPos.x -= mRealPadding.Left + ( mShowLineNumber ? getLineNumberWidth() : 0.f ); - localPos.y -= mRealPadding.Top; + localPos.x -= mPaddingPx.Left + ( mShowLineNumber ? getLineNumberWidth() : 0.f ); + localPos.y -= mPaddingPx.Top; Int64 line = eeclamp( (Int64)eefloor( localPos.y / getLineHeight() ), 0, ( Int64 )( mDoc->linesCount() - 1 ) ); return TextPosition( line, getColFromXOffset( line, localPos.x ) ); @@ -703,7 +703,7 @@ TextPosition UICodeEditor::resolveScreenPosition( const Vector2f& position ) con Vector2f UICodeEditor::getViewPortLineCount() const { return Vector2f( eefloor( getViewportWidth() / getGlyphWidth() ), - eefloor( ( mSize.getHeight() - mRealPadding.Top - + eefloor( ( mSize.getHeight() - mPaddingPx.Top - ( mHScrollBar->isVisible() ? mHScrollBar->getPixelsSize().getHeight() : 0.f ) ) / getLineHeight() ) ); } @@ -1203,6 +1203,10 @@ void UICodeEditor::addUnlockedCommands( const std::vector& commands mUnlockedCmd.insert( commands.begin(), commands.end() ); } +bool UICodeEditor::isUnlockedCommand( const std::string& command ) { + return mUnlockedCmd.find( command ) != mUnlockedCmd.end(); +} + UICodeEditor* UICodeEditor::setFontShadowColor( const Color& color ) { if ( mFontStyleConfig.ShadowColor != color ) { mFontStyleConfig.ShadowColor = color; diff --git a/src/eepp/ui/uidropdownlist.cpp b/src/eepp/ui/uidropdownlist.cpp index 6ad4a89e9..d0eeded20 100644 --- a/src/eepp/ui/uidropdownlist.cpp +++ b/src/eepp/ui/uidropdownlist.cpp @@ -89,7 +89,7 @@ void UIDropDownList::onAutoSize() { mTextCache->getLineSpacing() ); if ( mHeightPolicy == SizePolicy::WrapContent ) { - setInternalPixelsHeight( eeceil( max + mRealPadding.Top + mRealPadding.Bottom ) ); + setInternalPixelsHeight( eeceil( max + mPaddingPx.Top + mPaddingPx.Bottom ) ); } else if ( ( ( mFlags & UI_AUTO_SIZE ) || 0 == getSize().getHeight() ) && max > 0 ) { setInternalPixelsHeight( eeceil( max ) ); } diff --git a/src/eepp/ui/uifiledialog.cpp b/src/eepp/ui/uifiledialog.cpp index dbd1b7372..d6bcf7109 100644 --- a/src/eepp/ui/uifiledialog.cpp +++ b/src/eepp/ui/uifiledialog.cpp @@ -52,19 +52,19 @@ UIFileDialog::UIFileDialog( Uint32 dialogFlags, const std::string& defaultFilePa UILinearLayout* linearLayout = UILinearLayout::NewVertical(); linearLayout->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::MatchParent ) - ->setLayoutMargin( Rect( 4, 2, 4, 2 ) ) + ->setLayoutMargin( Rectf( 4, 2, 4, 2 ) ) ->setParent( getContainer() ); UILinearLayout* hLayout = UILinearLayout::NewHorizontal(); hLayout->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::WrapContent ) - ->setLayoutMargin( Rect( 0, 0, 0, 4 ) ) + ->setLayoutMargin( Rectf( 0, 0, 0, 4 ) ) ->setParent( linearLayout ) ->setId( "lay1" ); UITextView::New() ->setText( "Look in:" ) ->setLayoutSizePolicy( SizePolicy::WrapContent, SizePolicy::MatchParent ) - ->setLayoutMargin( Rect( 0, 0, 4, 0 ) ) + ->setLayoutMargin( Rectf( 0, 0, 4, 0 ) ) ->setParent( hLayout ) ->setEnabled( false ); @@ -87,7 +87,7 @@ UIFileDialog::UIFileDialog( Uint32 dialogFlags, const std::string& defaultFilePa mList->setParent( linearLayout ); mList->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::WrapContent ) ->setLayoutWeight( 1 ) - ->setLayoutMargin( Rect( 0, 0, 0, 4 ) ); + ->setLayoutMargin( Rectf( 0, 0, 0, 4 ) ); mList->addEventListener( Event::KeyDown, [&]( const Event* event ) { const KeyEvent* KEvent = reinterpret_cast( event ); if ( KEvent->getKeyCode() == KEY_BACKSPACE ) { @@ -105,7 +105,7 @@ UIFileDialog::UIFileDialog( Uint32 dialogFlags, const std::string& defaultFilePa hLayout = UILinearLayout::NewHorizontal(); hLayout->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::WrapContent ) - ->setLayoutMargin( Rect( 0, 0, 0, 4 ) ) + ->setLayoutMargin( Rectf( 0, 0, 0, 4 ) ) ->setParent( linearLayout ); UITextView::New() @@ -119,7 +119,7 @@ UIFileDialog::UIFileDialog( Uint32 dialogFlags, const std::string& defaultFilePa mFile->setLayoutSizePolicy( SizePolicy::WrapContent, SizePolicy::MatchParent ) ->setLayoutWeight( 1 ) ->setParent( hLayout ); - mFile->setLayoutMargin( Rect( 0, 0, 4, 0 ) ); + mFile->setLayoutMargin( Rectf( 0, 0, 4, 0 ) ); mFile->addEventListener( Event::OnPressEnter, cb::Make1( this, &UIFileDialog::onPressFileEnter ) ); @@ -147,7 +147,7 @@ UIFileDialog::UIFileDialog( Uint32 dialogFlags, const std::string& defaultFilePa mFiletype->setPopUpToRoot( true ); mFiletype->getListBox()->addListBoxItem( defaultFilePattern ); mFiletype->getListBox()->setSelected( 0 ); - mFiletype->setLayoutMargin( Rect( 0, 0, 4, 0 ) ); + mFiletype->setLayoutMargin( Rectf( 0, 0, 4, 0 ) ); mButtonCancel = UIPushButton::New(); mButtonCancel->setText( "Cancel" ) diff --git a/src/eepp/ui/uiimage.cpp b/src/eepp/ui/uiimage.cpp index 279c01ab7..38f8ea613 100644 --- a/src/eepp/ui/uiimage.cpp +++ b/src/eepp/ui/uiimage.cpp @@ -88,15 +88,15 @@ void UIImage::onAutoSize() { void UIImage::calcDestSize() { if ( mScaleType == UIScaleType::Expand ) { - mDestSize = Sizef( mSize.x - mRealPadding.Left - mRealPadding.Right, - mSize.y - mRealPadding.Top - mRealPadding.Bottom ); + mDestSize = Sizef( mSize.x - mPaddingPx.Left - mPaddingPx.Right, + mSize.y - mPaddingPx.Top - mPaddingPx.Bottom ); } else if ( mScaleType == UIScaleType::FitInside ) { if ( NULL == mDrawable ) return; Sizef pxSize( mDrawable->getPixelsSize() ); - Float Scale1 = ( mSize.x - mRealPadding.Left - mRealPadding.Right ) / pxSize.x; - Float Scale2 = ( mSize.y - mRealPadding.Top - mRealPadding.Bottom ) / pxSize.y; + Float Scale1 = ( mSize.x - mPaddingPx.Left - mPaddingPx.Right ) / pxSize.x; + Float Scale2 = ( mSize.y - mPaddingPx.Top - mPaddingPx.Bottom ) / pxSize.y; if ( Scale1 < 1 || Scale2 < 1 ) { if ( Scale2 < Scale1 ) @@ -157,17 +157,17 @@ void UIImage::autoAlign() { if ( Font::getHorizontalAlign( mFlags ) == UI_HALIGN_CENTER ) { mAlignOffset.x = ( mSize.getWidth() - mDestSize.x ) / 2; } else if ( Font::getHorizontalAlign( mFlags ) == UI_HALIGN_RIGHT ) { - mAlignOffset.x = mSize.getWidth() - mDestSize.x - mRealPadding.Right; + mAlignOffset.x = mSize.getWidth() - mDestSize.x - mPaddingPx.Right; } else { - mAlignOffset.x = mRealPadding.Left; + mAlignOffset.x = mPaddingPx.Left; } if ( Font::getVerticalAlign( mFlags ) == UI_VALIGN_CENTER ) { mAlignOffset.y = ( mSize.getHeight() - mDestSize.y ) / 2; } else if ( Font::getVerticalAlign( mFlags ) == UI_VALIGN_BOTTOM ) { - mAlignOffset.y = mSize.getHeight() - mDestSize.y - mRealPadding.Bottom; + mAlignOffset.y = mSize.getHeight() - mDestSize.y - mPaddingPx.Bottom; } else { - mAlignOffset.y = mRealPadding.Top; + mAlignOffset.y = mPaddingPx.Top; } } diff --git a/src/eepp/ui/uilinearlayout.cpp b/src/eepp/ui/uilinearlayout.cpp index 347497740..0997f7299 100644 --- a/src/eepp/ui/uilinearlayout.cpp +++ b/src/eepp/ui/uilinearlayout.cpp @@ -72,17 +72,18 @@ void UILinearLayout::packVertical() { return; mPacking = true; bool sizeChanged = false; - Sizef size( getSize() ); + Sizef size( getPixelsSize() ); if ( getLayoutWidthPolicy() == SizePolicy::MatchParent && 0 == getLayoutWeight() ) { - Float w = getParent()->getSize().getWidth() - mLayoutMargin.Left - mLayoutMargin.Right; + Float w = + getParent()->getPixelsSize().getWidth() - mLayoutMarginPx.Left - mLayoutMarginPx.Right; if ( getParent()->isType( UI_TYPE_LAYOUT ) ) { UILayout* pLay = static_cast( getParent() ); - w = w - pLay->getPadding().Left - pLay->getPadding().Right; + w = w - pLay->getPixelsPadding().Left - pLay->getPixelsPadding().Right; } - if ( (int)w != (int)getSize().getWidth() ) { + if ( (int)w != (int)getPixelsSize().getWidth() ) { sizeChanged = true; size.setWidth( w ); @@ -90,14 +91,15 @@ void UILinearLayout::packVertical() { } if ( getLayoutHeightPolicy() == SizePolicy::MatchParent ) { - Float h = getParent()->getSize().getHeight() - mLayoutMargin.Top - mLayoutMargin.Bottom; + Float h = + getParent()->getPixelsSize().getHeight() - mLayoutMarginPx.Top - mLayoutMarginPx.Bottom; if ( getParent()->isType( UI_TYPE_LAYOUT ) ) { UILayout* pLay = static_cast( getParent() ); - h = h - pLay->getPadding().Top - pLay->getPadding().Bottom; + h = h - pLay->getPixelsPadding().Top - pLay->getPixelsPadding().Bottom; } - if ( (int)h != (int)getSize().getHeight() ) { + if ( (int)h != (int)getPixelsSize().getHeight() ) { sizeChanged = true; size.setHeight( h ); @@ -105,7 +107,7 @@ void UILinearLayout::packVertical() { } if ( sizeChanged ) { - setInternalSize( size ); + setInternalPixelsSize( size ); } Node* child = mChild; @@ -124,11 +126,12 @@ void UILinearLayout::packVertical() { break; } case SizePolicy::MatchParent: { - int w = getSize().getWidth() - widget->getLayoutMargin().Left - - widget->getLayoutMargin().Right - mPadding.Left - mPadding.Right; + int w = getPixelsSize().getWidth() - widget->getLayoutPixelsMargin().Left - + widget->getLayoutPixelsMargin().Right - mPaddingPx.Left - + mPaddingPx.Right; - if ( (int)widget->getSize().getWidth() != w && w > 0 ) - widget->setSize( w, widget->getSize().getHeight() ); + if ( (int)widget->getPixelsSize().getWidth() != w && w > 0 ) + widget->setPixelsSize( w, widget->getPixelsSize().getHeight() ); break; } @@ -139,20 +142,22 @@ void UILinearLayout::packVertical() { if ( widget->getLayoutHeightPolicy() == SizePolicy::MatchParent && widget->getLayoutWeight() == 0 && - widget->getSize().getHeight() != - getSize().getHeight() - widget->getLayoutMargin().Top - - widget->getLayoutMargin().Bottom - mPadding.Top - mPadding.Bottom ) { - widget->setSize( widget->getSize().getWidth(), - getSize().getHeight() - widget->getLayoutMargin().Top - - widget->getLayoutMargin().Bottom - mPadding.Top - - mPadding.Bottom ); + widget->getPixelsSize().getHeight() != getPixelsSize().getHeight() - + widget->getLayoutPixelsMargin().Top - + widget->getLayoutPixelsMargin().Bottom - + mPaddingPx.Top - mPaddingPx.Bottom ) { + widget->setPixelsSize( widget->getPixelsSize().getWidth(), + getPixelsSize().getHeight() - + widget->getLayoutPixelsMargin().Top - + widget->getLayoutPixelsMargin().Bottom - mPaddingPx.Top - + mPaddingPx.Bottom ); } } child = child->getNextNode(); } - Float curY = mPadding.Top; + Float curY = mPaddingPx.Top; Float maxX = 0; Sizei freeSize = getTotalUsedSize(); @@ -161,77 +166,80 @@ void UILinearLayout::packVertical() { while ( NULL != child ) { if ( child->isWidget() && child->isVisible() ) { UIWidget* widget = child->asType(); - Rect margin = widget->getLayoutMargin(); + Rectf margin = widget->getLayoutPixelsMargin(); curY += eeceil( margin.Top ); - Vector2f pos( mPadding.Left, curY ); + Vector2f pos( mPaddingPx.Left, curY ); if ( widget->getLayoutWeight() != 0 ) { - Int32 totSize = ( getLayoutHeightPolicy() == SizePolicy::MatchParent ) - ? getSize().getHeight() - mPadding.Top - mPadding.Bottom - : getParent()->getSize().getHeight() - mLayoutMargin.Bottom - - mLayoutMargin.Top - mPadding.Top - mPadding.Bottom; + Int32 totSize = + ( getLayoutHeightPolicy() == SizePolicy::MatchParent ) + ? getPixelsSize().getHeight() - mPaddingPx.Top - mPaddingPx.Bottom + : getParent()->getPixelsSize().getHeight() - mLayoutMarginPx.Bottom - + mLayoutMarginPx.Top - mPaddingPx.Top - mPaddingPx.Bottom; Float size = ( Float )( totSize - freeSize.getHeight() ) * widget->getLayoutWeight(); - widget->setSize( widget->getSize().getWidth(), (Int32)size ); + widget->setPixelsSize( widget->getPixelsSize().getWidth(), (Int32)size ); } switch ( Font::getHorizontalAlign( widget->getLayoutGravity() ) ) { case UI_HALIGN_CENTER: - pos.x = ( getSize().getWidth() - mPadding.Left - mPadding.Right - - widget->getSize().getWidth() ) / + pos.x = ( getPixelsSize().getWidth() - mPaddingPx.Left - mPaddingPx.Right - + widget->getPixelsSize().getWidth() ) / 2; break; case UI_HALIGN_RIGHT: - pos.x = getSize().getWidth() - mPadding.Left - mPadding.Right - - widget->getSize().getWidth() - widget->getLayoutMargin().Right; + pos.x = getPixelsSize().getWidth() - mPaddingPx.Left - mPaddingPx.Right - + widget->getPixelsSize().getWidth() - + widget->getLayoutPixelsMargin().Right; break; case UI_HALIGN_LEFT: default: - pos.x = widget->getLayoutMargin().Left + mPadding.Left; + pos.x = widget->getLayoutPixelsMargin().Left + mPaddingPx.Left; break; } - widget->setPosition( pos ); + widget->setPixelsPosition( pos ); - curY += eeceil( widget->getSize().getHeight() + margin.Bottom ); + curY += eeceil( widget->getPixelsSize().getHeight() + margin.Bottom ); - maxX = eeceil( - eemax( maxX, ( widget->getSize().getWidth() + widget->getLayoutMargin().Left + - widget->getLayoutMargin().Right ) ) ); + maxX = eeceil( eemax( maxX, ( widget->getPixelsSize().getWidth() + + widget->getLayoutPixelsMargin().Left + + widget->getLayoutPixelsMargin().Right ) ) ); } child = child->getNextNode(); } - maxX += mPadding.Left + mPadding.Right; + maxX += mPaddingPx.Left + mPaddingPx.Right; if ( getLayoutHeightPolicy() == SizePolicy::WrapContent ) { - curY += mPadding.Bottom; + curY += mPaddingPx.Bottom; - if ( curY != (int)getSize().getHeight() ) { - setInternalHeight( curY ); + if ( curY != (int)getPixelsSize().getHeight() ) { + setInternalPixelsHeight( curY ); notifyLayoutAttrChangeParent(); } } else if ( getLayoutHeightPolicy() == SizePolicy::MatchParent ) { - int h = getParent()->getSize().getHeight() - mLayoutMargin.Top - mLayoutMargin.Bottom; + int h = + getParent()->getPixelsSize().getHeight() - mLayoutMarginPx.Top - mLayoutMarginPx.Bottom; if ( getParent()->isType( UI_TYPE_LAYOUT ) ) { UILayout* pLay = static_cast( getParent() ); - h = h - pLay->getPadding().Top - pLay->getPadding().Bottom; + h = h - pLay->getPixelsPadding().Top - pLay->getPixelsPadding().Bottom; } - if ( h != (int)getSize().getHeight() ) - setInternalHeight( h ); + if ( h != (int)getPixelsSize().getHeight() ) + setInternalPixelsHeight( h ); } - if ( getLayoutWidthPolicy() == SizePolicy::WrapContent && getSize().getWidth() != maxX ) { + if ( getLayoutWidthPolicy() == SizePolicy::WrapContent && getPixelsSize().getWidth() != maxX ) { if ( !( 0 != getLayoutWeight() && getParent()->isType( UI_TYPE_LINEAR_LAYOUT ) && getParent()->asType()->getOrientation() == UIOrientation::Horizontal ) ) { - setInternalWidth( maxX ); + setInternalPixelsWidth( maxX ); mPacking = false; packVertical(); notifyLayoutAttrChangeParent(); @@ -249,17 +257,18 @@ void UILinearLayout::packHorizontal() { return; mPacking = true; bool sizeChanged = false; - Sizef size( getSize() ); + Sizef size( getPixelsSize() ); if ( getLayoutWidthPolicy() == SizePolicy::MatchParent ) { - Float w = getParent()->getSize().getWidth() - mLayoutMargin.Left - mLayoutMargin.Right; + Float w = + getParent()->getPixelsSize().getWidth() - mLayoutMarginPx.Left - mLayoutMarginPx.Right; if ( getParent()->isType( UI_TYPE_LAYOUT ) ) { UILayout* pLay = static_cast( getParent() ); - w = w - pLay->getPadding().Left - pLay->getPadding().Right; + w = w - pLay->getPixelsPadding().Left - pLay->getPixelsPadding().Right; } - if ( (int)w != (int)getSize().getWidth() ) { + if ( (int)w != (int)getPixelsSize().getWidth() ) { sizeChanged = true; size.setWidth( w ); @@ -267,14 +276,15 @@ void UILinearLayout::packHorizontal() { } if ( getLayoutHeightPolicy() == SizePolicy::MatchParent && 0 == getLayoutWeight() ) { - Float h = getParent()->getSize().getHeight() - mLayoutMargin.Top - mLayoutMargin.Bottom; + Float h = + getParent()->getPixelsSize().getHeight() - mLayoutMarginPx.Top - mLayoutMarginPx.Bottom; if ( getParent()->isType( UI_TYPE_LAYOUT ) ) { UILayout* pLay = static_cast( getParent() ); - h = h - pLay->getPadding().Top - pLay->getPadding().Bottom; + h = h - pLay->getPixelsPadding().Top - pLay->getPixelsPadding().Bottom; } - if ( (int)h != (int)getSize().getHeight() ) { + if ( (int)h != (int)getPixelsSize().getHeight() ) { sizeChanged = true; size.setHeight( h ); @@ -282,7 +292,7 @@ void UILinearLayout::packHorizontal() { } if ( sizeChanged ) { - setInternalSize( size ); + setInternalPixelsSize( size ); } Node* child = mChild; @@ -301,11 +311,12 @@ void UILinearLayout::packHorizontal() { break; } case SizePolicy::MatchParent: { - int h = getSize().getHeight() - widget->getLayoutMargin().Top - - widget->getLayoutMargin().Bottom - mPadding.Top - mPadding.Bottom; + int h = getPixelsSize().getHeight() - widget->getLayoutPixelsMargin().Top - + widget->getLayoutPixelsMargin().Bottom - mPaddingPx.Top - + mPaddingPx.Bottom; - if ( h != (int)widget->getSize().getHeight() && h > 0 ) - widget->setSize( widget->getSize().getWidth(), h ); + if ( h != (int)widget->getPixelsSize().getHeight() && h > 0 ) + widget->setPixelsSize( widget->getPixelsSize().getWidth(), h ); break; } @@ -316,20 +327,21 @@ void UILinearLayout::packHorizontal() { if ( widget->getLayoutWidthPolicy() == SizePolicy::MatchParent && widget->getLayoutWeight() == 0 && - widget->getSize().getWidth() != - getSize().getWidth() - widget->getLayoutMargin().Left - - widget->getLayoutMargin().Right - mPadding.Left - mPadding.Right ) { - widget->setSize( getSize().getWidth() - widget->getLayoutMargin().Left - - widget->getLayoutMargin().Right - mPadding.Left - - mPadding.Right, - widget->getSize().getHeight() ); + widget->getPixelsSize().getWidth() != getPixelsSize().getWidth() - + widget->getLayoutPixelsMargin().Left - + widget->getLayoutPixelsMargin().Right - + mPaddingPx.Left - mPaddingPx.Right ) { + widget->setPixelsSize( + getPixelsSize().getWidth() - widget->getLayoutPixelsMargin().Left - + widget->getLayoutPixelsMargin().Right - mPaddingPx.Left - mPaddingPx.Right, + widget->getPixelsSize().getHeight() ); } } child = child->getNextNode(); } - Float curX = mPadding.Left; + Float curX = mPaddingPx.Left; Float maxY = 0; Sizei freeSize = getTotalUsedSize(); @@ -338,76 +350,80 @@ void UILinearLayout::packHorizontal() { while ( NULL != child ) { if ( child->isWidget() && child->isVisible() ) { UIWidget* widget = static_cast( child ); - Rect margin = widget->getLayoutMargin(); + Rectf margin = widget->getLayoutPixelsMargin(); curX += eeceil( margin.Left ); - Vector2f pos( curX, mPadding.Top ); + Vector2f pos( curX, mPaddingPx.Top ); if ( widget->getLayoutWeight() != 0 ) { - Int32 totSize = ( getLayoutWidthPolicy() == SizePolicy::MatchParent ) - ? getSize().getWidth() - mPadding.Left - mPadding.Right - : getParent()->getSize().getWidth() - mLayoutMargin.Right - - mLayoutMargin.Left - mPadding.Left - mPadding.Right; + Int32 totSize = + ( getLayoutWidthPolicy() == SizePolicy::MatchParent ) + ? getPixelsSize().getWidth() - mPaddingPx.Left - mPaddingPx.Right + : getParent()->getPixelsSize().getWidth() - mLayoutMarginPx.Right - + mLayoutMarginPx.Left - mPaddingPx.Left - mPaddingPx.Right; Float size = ( Float )( totSize - freeSize.getWidth() ) * widget->getLayoutWeight(); - widget->setSize( (Int32)size, widget->getSize().getHeight() ); + widget->setPixelsSize( (Int32)size, widget->getPixelsSize().getHeight() ); } switch ( Font::getVerticalAlign( widget->getLayoutGravity() ) ) { case UI_VALIGN_CENTER: - pos.y = ( getSize().getHeight() - mPadding.Top - mPadding.Bottom - - widget->getSize().getHeight() ) / + pos.y = ( getPixelsSize().getHeight() - mPaddingPx.Top - mPaddingPx.Bottom - + widget->getPixelsSize().getHeight() ) / 2; break; case UI_VALIGN_BOTTOM: - pos.y = getSize().getHeight() - mPadding.Top - mPadding.Bottom - - widget->getSize().getHeight() - widget->getLayoutMargin().Bottom; + pos.y = getPixelsSize().getHeight() - mPaddingPx.Top - mPaddingPx.Bottom - + widget->getPixelsSize().getHeight() - + widget->getLayoutPixelsMargin().Bottom; break; case UI_VALIGN_TOP: default: - pos.y = widget->getLayoutMargin().Top + mPadding.Top; + pos.y = widget->getLayoutPixelsMargin().Top + mPaddingPx.Top; break; } - widget->setPosition( pos ); + widget->setPixelsPosition( pos ); - curX += eeceil( widget->getSize().getWidth() + margin.Right ); + curX += eeceil( widget->getPixelsSize().getWidth() + margin.Right ); - maxY = eeceil( - eemax( maxY, ( widget->getSize().getHeight() + widget->getLayoutMargin().Top + - widget->getLayoutMargin().Bottom ) ) ); + maxY = eeceil( eemax( maxY, ( widget->getPixelsSize().getHeight() + + widget->getLayoutPixelsMargin().Top + + widget->getLayoutPixelsMargin().Bottom ) ) ); } child = child->getNextNode(); } - maxY += mPadding.Top + mPadding.Bottom; + maxY += mPaddingPx.Top + mPaddingPx.Bottom; if ( getLayoutWidthPolicy() == SizePolicy::WrapContent ) { - curX += mPadding.Right; + curX += mPaddingPx.Right; - if ( curX != (int)getSize().getWidth() ) { - setInternalWidth( curX ); + if ( curX != (int)getPixelsSize().getWidth() ) { + setInternalPixelsWidth( curX ); notifyLayoutAttrChangeParent(); } } else if ( getLayoutWidthPolicy() == SizePolicy::MatchParent ) { - int w = getParent()->getSize().getWidth() - mLayoutMargin.Left - mLayoutMargin.Right; + int w = + getParent()->getPixelsSize().getWidth() - mLayoutMarginPx.Left - mLayoutMarginPx.Right; if ( getParent()->isType( UI_TYPE_LAYOUT ) ) { UILayout* pLay = static_cast( getParent() ); - w = w - pLay->getPadding().Left - pLay->getPadding().Right; + w = w - pLay->getPixelsPadding().Left - pLay->getPixelsPadding().Right; } - if ( w != (int)getSize().getWidth() ) - setInternalWidth( w ); + if ( w != (int)getPixelsSize().getWidth() ) + setInternalPixelsWidth( w ); } - if ( getLayoutHeightPolicy() == SizePolicy::WrapContent && getSize().getHeight() != maxY ) { + if ( getLayoutHeightPolicy() == SizePolicy::WrapContent && + getPixelsSize().getHeight() != maxY ) { if ( !( 0 != getLayoutWeight() && getParent()->isType( UI_TYPE_LINEAR_LAYOUT ) && getParent()->asType()->getOrientation() == UIOrientation::Vertical ) ) { - setInternalHeight( maxY ); + setInternalPixelsHeight( maxY ); mPacking = false; packHorizontal(); notifyLayoutAttrChangeParent(); @@ -417,6 +433,7 @@ void UILinearLayout::packHorizontal() { if ( getParent()->isUINode() && !getParent()->asType()->ownsChildPosition() ) { alignAgainstLayout(); } + mPacking = false; } @@ -427,7 +444,7 @@ Sizei UILinearLayout::getTotalUsedSize() { while ( NULL != child ) { if ( child->isWidget() && child->isVisible() ) { UIWidget* widget = static_cast( child ); - Rect margin = widget->getLayoutMargin(); + Rectf margin = widget->getLayoutPixelsMargin(); size.x += margin.Left + margin.Right; @@ -436,14 +453,14 @@ Sizei UILinearLayout::getTotalUsedSize() { if ( widget->getLayoutWidthPolicy() == SizePolicy::Fixed || widget->getLayoutWidthPolicy() == SizePolicy::WrapContent ) { if ( 0 == widget->getLayoutWeight() && mOrientation == UIOrientation::Horizontal ) { - size.x += widget->getSize().getWidth(); + size.x += widget->getPixelsSize().getWidth(); } } if ( widget->getLayoutHeightPolicy() == SizePolicy::Fixed || widget->getLayoutHeightPolicy() == SizePolicy::WrapContent ) { if ( 0 == widget->getLayoutWeight() && mOrientation == UIOrientation::Vertical ) { - size.y += widget->getSize().getHeight(); + size.y += widget->getPixelsSize().getHeight(); } } } diff --git a/src/eepp/ui/uilistbox.cpp b/src/eepp/ui/uilistbox.cpp index 68ae2f256..744dd0bd4 100644 --- a/src/eepp/ui/uilistbox.cpp +++ b/src/eepp/ui/uilistbox.cpp @@ -420,7 +420,7 @@ void UIListBox::itemUpdateSize( UIListBoxItem* Item ) { } void UIListBox::containerResize() { - Rectf padding = mContainerPadding + mRealPadding; + Rectf padding = mContainerPadding + mPaddingPx; mContainer->setPixelsPosition( padding.Left, padding.Top ); diff --git a/src/eepp/ui/uimenu.cpp b/src/eepp/ui/uimenu.cpp index 3e7717acf..ddf284da6 100644 --- a/src/eepp/ui/uimenu.cpp +++ b/src/eepp/ui/uimenu.cpp @@ -155,7 +155,7 @@ UIWidget* UIMenu::add( UIWidget* widget ) { widget->setParent( this ); widgetCheckSize( widget ); setWidgetSize( widget ); - widget->setPixelsPosition( mRealPadding.Left, mRealPadding.Top + mNextPosY ); + widget->setPixelsPosition( mPaddingPx.Left, mPaddingPx.Top + mNextPosY ); mNextPosY += widget->getPixelsSize().getHeight(); mItems.push_back( widget ); widget->addEventListener( Event::OnSizeChange, [&]( const Event* ) { @@ -177,8 +177,8 @@ void UIMenu::setWidgetSize( UIWidget* widget ) { UIMenuSeparator* UIMenu::addSeparator() { UIMenuSeparator* separator = UIMenuSeparator::New(); separator->setParent( this ); - separator->setPixelsPosition( mRealPadding.Left, mRealPadding.Top + mNextPosY ); - separator->setPixelsSize( mSize.getWidth() - mRealPadding.Left - mRealPadding.Right, + separator->setPixelsPosition( mPaddingPx.Left, mPaddingPx.Top + mNextPosY ); + separator->setPixelsSize( mSize.getWidth() - mPaddingPx.Left - mPaddingPx.Right, PixelDensity::dpToPxI( separator->getSkinSize().getHeight() ) ); mNextPosY += separator->getPixelsSize().getHeight(); mItems.push_back( separator ); @@ -350,7 +350,7 @@ void UIMenu::widgetsSetPos() { for ( i = 0; i < mItems.size(); i++ ) { UIWidget* widget = mItems[i]; - widget->setPixelsPosition( mRealPadding.Left, mRealPadding.Top + mNextPosY ); + widget->setPixelsPosition( mPaddingPx.Left, mPaddingPx.Top + mNextPosY ); mNextPosY += widget->getPixelsSize().getHeight(); } @@ -360,9 +360,9 @@ void UIMenu::widgetsSetPos() { void UIMenu::resizeMe() { if ( mFlags & UI_AUTO_SIZE ) { - setPixelsSize( mMaxWidth, mNextPosY + mRealPadding.Top + mRealPadding.Bottom ); + setPixelsSize( mMaxWidth, mNextPosY + mPaddingPx.Top + mPaddingPx.Bottom ); } else { - setPixelsSize( mSize.getWidth(), mNextPosY + mRealPadding.Top + mRealPadding.Bottom ); + setPixelsSize( mSize.getWidth(), mNextPosY + mPaddingPx.Top + mPaddingPx.Bottom ); } } diff --git a/src/eepp/ui/uimessagebox.cpp b/src/eepp/ui/uimessagebox.cpp index a01091341..3a3220728 100644 --- a/src/eepp/ui/uimessagebox.cpp +++ b/src/eepp/ui/uimessagebox.cpp @@ -23,7 +23,7 @@ UIMessageBox::UIMessageBox( const Type& type, const String& message, const Uint3 UILinearLayout* vlay = UILinearLayout::NewVertical(); vlay->setLayoutSizePolicy( SizePolicy::WrapContent, SizePolicy::WrapContent ) - ->setLayoutMargin( Rect( 8, 8, 8, 8 ) ) + ->setLayoutMargin( Rectf( 8, 8, 8, 8 ) ) ->setParent( mLayoutCont ) ->clipDisable(); @@ -35,7 +35,7 @@ UIMessageBox::UIMessageBox( const Type& type, const String& message, const Uint3 if ( mMsgBoxType == INPUT ) { mTextInput = UITextInput::New(); mTextInput->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::WrapContent ) - ->setLayoutMargin( Rect( 0, 4, 0, 4 ) ) + ->setLayoutMargin( Rectf( 0, 4, 0, 4 ) ) ->setParent( vlay ) ->addEventListener( Event::OnPressEnter, [&]( const Event* ) { sendCommonEvent( Event::MsgBoxConfirmClick ); @@ -43,7 +43,7 @@ UIMessageBox::UIMessageBox( const Type& type, const String& message, const Uint3 } UILinearLayout* hlay = UILinearLayout::NewHorizontal(); - hlay->setLayoutMargin( Rect( 0, 8, 0, 0 ) ) + hlay->setLayoutMargin( Rectf( 0, 8, 0, 0 ) ) ->setLayoutSizePolicy( SizePolicy::WrapContent, SizePolicy::WrapContent ) ->setLayoutGravity( UI_HALIGN_RIGHT | UI_VALIGN_CENTER ) ->setParent( vlay ) @@ -53,7 +53,7 @@ UIMessageBox::UIMessageBox( const Type& type, const String& message, const Uint3 mButtonOK->setSize( 90, 0 )->setParent( hlay ); mButtonCancel = UIPushButton::New(); - mButtonCancel->setLayoutMargin( Rect( 8, 0, 0, 0 ) )->setSize( 90, 0 )->setParent( hlay ); + mButtonCancel->setLayoutMargin( Rectf( 8, 0, 0, 0 ) )->setSize( 90, 0 )->setParent( hlay ); switch ( mMsgBoxType ) { case UIMessageBox::INPUT: diff --git a/src/eepp/ui/uinode.cpp b/src/eepp/ui/uinode.cpp index 545e9ce58..e0b6bd4d2 100644 --- a/src/eepp/ui/uinode.cpp +++ b/src/eepp/ui/uinode.cpp @@ -353,9 +353,10 @@ void UINode::updateDebugData() { p.Left ); } - if ( widget->getLayoutMargin() != Rect( 0, 0, 0, 0 ) ) { - Rect m( widget->getLayoutMargin() ); - text += String::format( "\nmargin: %d %d %d %d", m.Top, m.Right, m.Bottom, m.Left ); + if ( widget->getLayoutMargin() != Rectf( 0, 0, 0, 0 ) ) { + Rectf m( widget->getLayoutMargin() ); + text += + String::format( "\nmargin: %.2f %.2f %.2f %.2f", m.Top, m.Right, m.Bottom, m.Left ); } widget->setTooltipText( text ); diff --git a/src/eepp/ui/uiprogressbar.cpp b/src/eepp/ui/uiprogressbar.cpp index 20216d37a..47f733dbc 100644 --- a/src/eepp/ui/uiprogressbar.cpp +++ b/src/eepp/ui/uiprogressbar.cpp @@ -144,11 +144,11 @@ Uint32 UIProgressBar::onValueChange() { } void UIProgressBar::onSizeChange() { - Sizef fSize( ( ( mSize.getWidth() - mRealPadding.Left - mRealPadding.Right ) * getProgress() ) / + Sizef fSize( ( ( mSize.getWidth() - mPaddingPx.Left - mPaddingPx.Right ) * getProgress() ) / getTotalSteps(), - mSize.getHeight() - mRealPadding.Top - mRealPadding.Bottom ); + mSize.getHeight() - mPaddingPx.Top - mPaddingPx.Bottom ); mFiller->setPixelsSize( fSize ); - mFiller->setPixelsPosition( mRealPadding.Left, mRealPadding.Top ); + mFiller->setPixelsPosition( mPaddingPx.Left, mPaddingPx.Top ); updateTextBox(); } diff --git a/src/eepp/ui/uipushbutton.cpp b/src/eepp/ui/uipushbutton.cpp index 4a6eb8ce1..4e5afca13 100644 --- a/src/eepp/ui/uipushbutton.cpp +++ b/src/eepp/ui/uipushbutton.cpp @@ -70,7 +70,7 @@ void UIPushButton::onAutoSize() { Float tH = mTextBox->getPixelsSize().getHeight(); Float eH = getExtraInnerWidget() ? getExtraInnerWidget()->getPixelsSize().getHeight() : 0; Float h = eemax( eemax( PixelDensity::dpToPx( eemax( sH, sHS ) ), tH ), eH ); - setInternalPixelsHeight( h + mRealPadding.Top + mRealPadding.Bottom ); + setInternalPixelsHeight( h + mPaddingPx.Top + mPaddingPx.Bottom ); } else if ( ( mFlags & UI_AUTO_SIZE ) && NULL != getSkin() ) { setInternalHeight( getSkinSize().getHeight() ); } @@ -170,14 +170,14 @@ void UIPushButton::updateLayout() { if ( autoPadding != Rectf() ) autoPadding = PixelDensity::dpToPx( autoPadding ); } - if ( mRealPadding.Top > autoPadding.Top ) - autoPadding.Top = mRealPadding.Top; - if ( mRealPadding.Bottom > autoPadding.Bottom ) - autoPadding.Bottom = mRealPadding.Bottom; - if ( mRealPadding.Left > autoPadding.Left ) - autoPadding.Left = mRealPadding.Left; - if ( mRealPadding.Right > autoPadding.Right ) - autoPadding.Right = mRealPadding.Right; + if ( mPaddingPx.Top > autoPadding.Top ) + autoPadding.Top = mPaddingPx.Top; + if ( mPaddingPx.Bottom > autoPadding.Bottom ) + autoPadding.Bottom = mPaddingPx.Bottom; + if ( mPaddingPx.Left > autoPadding.Left ) + autoPadding.Left = mPaddingPx.Left; + if ( mPaddingPx.Right > autoPadding.Right ) + autoPadding.Right = mPaddingPx.Right; switch ( mInnerWidgetOrientation ) { case InnerWidgetOrientation::Left: @@ -334,7 +334,7 @@ Sizef UIPushButton::getContentSize() const { eWidget->getLayoutMargin().Left + eWidget->getLayoutMargin().Right ) : 0; - Int32 minWidth = txtW + iconSize + eWidgetSize + mRealPadding.Left + mRealPadding.Right + + Int32 minWidth = txtW + iconSize + eWidgetSize + mPaddingPx.Left + mPaddingPx.Right + ( NULL != getSkin() ? PixelDensity::dpToPxI( getSkin()->getBorderSize().Left + getSkin()->getBorderSize().Right ) : 0 ); diff --git a/src/eepp/ui/uiradiobutton.cpp b/src/eepp/ui/uiradiobutton.cpp index 308e70404..37249d0fa 100644 --- a/src/eepp/ui/uiradiobutton.cpp +++ b/src/eepp/ui/uiradiobutton.cpp @@ -81,24 +81,24 @@ void UIRadioButton::onAutoSize() { if ( getSize().getWidth() == 0 ) { setInternalPixelsWidth( (int)mTextCache->getTextWidth() + mActiveButton->getPixelsSize().getWidth() + - PixelDensity::dpToPx( mTextSeparation ) + mRealPadding.Left + mRealPadding.Right ); + PixelDensity::dpToPx( mTextSeparation ) + mPaddingPx.Left + mPaddingPx.Right ); } if ( getSize().getHeight() == 0 ) { - setInternalHeight( mActiveButton->getSize().getHeight() + mRealPadding.Top + - mRealPadding.Bottom ); + setInternalHeight( mActiveButton->getSize().getHeight() + mPaddingPx.Top + + mPaddingPx.Bottom ); } } if ( mWidthPolicy == SizePolicy::WrapContent ) { - setInternalPixelsWidth( (int)mTextCache->getTextWidth() + mRealPadding.Left + - mRealPadding.Right + mActiveButton->getPixelsSize().getWidth() + + setInternalPixelsWidth( (int)mTextCache->getTextWidth() + mPaddingPx.Left + + mPaddingPx.Right + mActiveButton->getPixelsSize().getWidth() + PixelDensity::dpToPx( mTextSeparation ) ); } if ( mHeightPolicy == SizePolicy::WrapContent ) { - setInternalPixelsHeight( (int)mTextCache->getTextHeight() + mRealPadding.Top + - mRealPadding.Bottom ); + setInternalPixelsHeight( (int)mTextCache->getTextHeight() + mPaddingPx.Top + + mPaddingPx.Bottom ); } alignFix(); @@ -237,7 +237,7 @@ void UIRadioButton::alignFix() { switch ( Font::getHorizontalAlign( getFlags() ) ) { case UI_HALIGN_CENTER: mRealAlignOffset.x = - ( Float )( ( Int32 )( ( mSize.x - mRealPadding.Left - mRealPadding.Right - + ( Float )( ( Int32 )( ( mSize.x - mPaddingPx.Left - mPaddingPx.Right - mTextCache->getTextWidth() - mActiveButton->getPixelsSize().getWidth() + PixelDensity::dpToPx( mTextSeparation ) ) / @@ -245,7 +245,7 @@ void UIRadioButton::alignFix() { mActiveButton->getPixelsSize().getWidth() + PixelDensity::dpToPx( mTextSeparation ); break; case UI_HALIGN_RIGHT: - mRealAlignOffset.x = ( (Float)mSize.x - mRealPadding.Left - mRealPadding.Right - + mRealAlignOffset.x = ( (Float)mSize.x - mPaddingPx.Left - mPaddingPx.Right - (Float)mTextCache->getTextWidth() ); break; case UI_HALIGN_LEFT: diff --git a/src/eepp/ui/uiscrollablewidget.cpp b/src/eepp/ui/uiscrollablewidget.cpp index 946a493f3..df69126d6 100644 --- a/src/eepp/ui/uiscrollablewidget.cpp +++ b/src/eepp/ui/uiscrollablewidget.cpp @@ -137,7 +137,7 @@ void UIScrollableWidget::onContentSizeChange() { mHScroll->setEnabled( visible ); } - Sizef size = getPixelsSize() - mRealPadding; + Sizef size = getPixelsSize() - mPaddingPx; if ( Exclusive == mViewType ) { if ( mVScroll->isVisible() ) @@ -148,17 +148,17 @@ void UIScrollableWidget::onContentSizeChange() { } mVScroll->setPixelsPosition( getPixelsSize().getWidth() - mVScroll->getPixelsSize().getWidth() - - mRealPadding.Right, - mRealPadding.Top ); - mHScroll->setPixelsPosition( mRealPadding.Left, getPixelsSize().getHeight() - + mPaddingPx.Right, + mPaddingPx.Top ); + mHScroll->setPixelsPosition( mPaddingPx.Left, getPixelsSize().getHeight() - mHScroll->getPixelsSize().getHeight() - - mRealPadding.Bottom ); + mPaddingPx.Bottom ); mVScroll->setPixelsSize( mVScroll->getPixelsSize().getWidth(), - getPixelsSize().getHeight() - mRealPadding.Top - mRealPadding.Bottom ); + getPixelsSize().getHeight() - mPaddingPx.Top - mPaddingPx.Bottom ); mHScroll->setPixelsSize( - getPixelsSize().getWidth() - mRealPadding.Left - mRealPadding.Right - + getPixelsSize().getWidth() - mPaddingPx.Left - mPaddingPx.Right - ( mVScroll->isVisible() ? mVScroll->getPixelsSize().getWidth() : 0 ), mHScroll->getPixelsSize().getHeight() ); @@ -177,7 +177,7 @@ Sizef UIScrollableWidget::getScrollableArea() const { } Sizef UIScrollableWidget::getVisibleArea() const { - Sizef size = getPixelsSize() - mRealPadding; + Sizef size = getPixelsSize() - mPaddingPx; if ( mVScroll->isVisible() ) size.x -= mVScroll->getPixelsSize().getWidth(); if ( mHScroll->isVisible() ) diff --git a/src/eepp/ui/uiscrollbar.cpp b/src/eepp/ui/uiscrollbar.cpp index 721f0caae..b44a0a059 100644 --- a/src/eepp/ui/uiscrollbar.cpp +++ b/src/eepp/ui/uiscrollbar.cpp @@ -146,7 +146,7 @@ void UIScrollBar::onAutoSize() { } if ( mWidthPolicy == SizePolicy::WrapContent || mHeightPolicy == SizePolicy::WrapContent ) { - size = PixelDensity::dpToPx( mSlider->getSize() ) + mRealPadding; + size = PixelDensity::dpToPx( mSlider->getSize() ) + mPaddingPx; if ( mScrollBarStyle == TwoButtons ) { if ( mSlider->isVertical() ) { diff --git a/src/eepp/ui/uisplitter.cpp b/src/eepp/ui/uisplitter.cpp index 98e31e248..4708945fb 100644 --- a/src/eepp/ui/uisplitter.cpp +++ b/src/eepp/ui/uisplitter.cpp @@ -184,8 +184,8 @@ void UISplitter::updateFromDrag() { mSplitter->setVisible( !mAlwaysShowSplitter && !mLastWidget ? false : true ); mSplitter->setEnabled( mSplitter->isVisible() ); Float totalSpace = mOrientation == UIOrientation::Horizontal - ? mSize.getWidth() - mRealPadding.Left - mRealPadding.Right - : mSize.getHeight() - mRealPadding.Top - mRealPadding.Bottom; + ? mSize.getWidth() - mPaddingPx.Left - mPaddingPx.Right + : mSize.getHeight() - mPaddingPx.Top - mPaddingPx.Bottom; if ( mSplitter->isVisible() ) { totalSpace -= UIOrientation::Horizontal == mOrientation ? mSplitter->getPixelsSize().getWidth() @@ -209,7 +209,7 @@ void UISplitter::updateFromDrag() { } mSplitter->setPixelsSize( mSplitter->getPixelsSize().getWidth(), - mSize.getHeight() - mRealPadding.Top - mRealPadding.Bottom ); + mSize.getHeight() - mPaddingPx.Top - mPaddingPx.Bottom ); } else { Float fMinSize = mFirstWidget ? mFirstWidget->getCurrentMinSize().getHeight() : 0.f; @@ -226,19 +226,19 @@ void UISplitter::updateFromDrag() { mSplitter->getSize().getHeight() ); } - mSplitter->setPixelsSize( mSize.getWidth() - mRealPadding.Left - mRealPadding.Right, + mSplitter->setPixelsSize( mSize.getWidth() - mPaddingPx.Left - mPaddingPx.Right, mSplitter->getPixelsSize().getHeight() ); } if ( mFirstWidget ) { - mFirstWidget->setPixelsPosition( mRealPadding.Left, mRealPadding.Top ); + mFirstWidget->setPixelsPosition( mPaddingPx.Left, mPaddingPx.Top ); if ( UIOrientation::Horizontal == mOrientation ) { - mFirstWidget->setPixelsSize( mSplitter->getPixelsPosition().x - mRealPadding.Left, - mSize.getHeight() - mRealPadding.Top - - mRealPadding.Bottom ); + mFirstWidget->setPixelsSize( mSplitter->getPixelsPosition().x - mPaddingPx.Left, + mSize.getHeight() - mPaddingPx.Top - + mPaddingPx.Bottom ); } else { - mFirstWidget->setPixelsSize( mSize.getWidth() - mRealPadding.Left - mRealPadding.Right, - mSplitter->getPixelsPosition().y - mRealPadding.Top ); + mFirstWidget->setPixelsSize( mSize.getWidth() - mPaddingPx.Left - mPaddingPx.Right, + mSplitter->getPixelsPosition().y - mPaddingPx.Top ); } } @@ -246,17 +246,17 @@ void UISplitter::updateFromDrag() { if ( UIOrientation::Horizontal == mOrientation ) { mLastWidget->setPixelsPosition( mSplitter->getPixelsPosition().x + mSplitter->getPixelsSize().getWidth(), - mRealPadding.Top ); + mPaddingPx.Top ); mLastWidget->setPixelsSize( - mSize.getWidth() - mRealPadding.Right - mSplitter->getPixelsPosition().x - + mSize.getWidth() - mPaddingPx.Right - mSplitter->getPixelsPosition().x - mSplitter->getPixelsSize().getWidth(), - mSize.getHeight() - mRealPadding.Top - mRealPadding.Bottom ); + mSize.getHeight() - mPaddingPx.Top - mPaddingPx.Bottom ); } else { - mLastWidget->setPixelsPosition( mRealPadding.Left, + mLastWidget->setPixelsPosition( mPaddingPx.Left, mSplitter->getPixelsPosition().y + mSplitter->getPixelsSize().getHeight() ); - mLastWidget->setPixelsSize( mSize.getWidth() - mRealPadding.Left - mRealPadding.Right, - mSize.getHeight() - mRealPadding.Bottom - + mLastWidget->setPixelsSize( mSize.getWidth() - mPaddingPx.Left - mPaddingPx.Right, + mSize.getHeight() - mPaddingPx.Bottom - mSplitter->getPixelsPosition().y - mSplitter->getPixelsSize().getHeight() ); } @@ -266,14 +266,14 @@ void UISplitter::updateFromDrag() { mSplitPartition = StyleSheetLength( eeclamp( ( mSplitter->getPixelsPosition().x + mSplitter->getPixelsSize().getWidth() ) / - ( mSize.getWidth() - mRealPadding.Left - mRealPadding.Right ) * 100, + ( mSize.getWidth() - mPaddingPx.Left - mPaddingPx.Right ) * 100, 0, 100 ), StyleSheetLength::Percentage ); } else { mSplitPartition = StyleSheetLength( eeclamp( ( mSplitter->getPixelsPosition().y + mSplitter->getPixelsSize().getHeight() ) / - ( mSize.getHeight() - mRealPadding.Top - mRealPadding.Bottom ) * 100, + ( mSize.getHeight() - mPaddingPx.Top - mPaddingPx.Bottom ) * 100, 0, 100 ), StyleSheetLength::Percentage ); } @@ -325,10 +325,10 @@ void UISplitter::updateLayout() { mSplitter->setVisible( false )->setEnabled( false ); if ( mFirstWidget ) { - mFirstWidget->setPixelsPosition( mRealPadding.Left, mRealPadding.Top ); - mFirstWidget->setPixelsSize( mSize.getWidth() - mRealPadding.Left - mRealPadding.Right, - mSize.getHeight() - mRealPadding.Top - - mRealPadding.Bottom ); + mFirstWidget->setPixelsPosition( mPaddingPx.Left, mPaddingPx.Top ); + mFirstWidget->setPixelsSize( mSize.getWidth() - mPaddingPx.Left - mPaddingPx.Right, + mSize.getHeight() - mPaddingPx.Top - + mPaddingPx.Bottom ); } mDirtyLayout = false; @@ -338,8 +338,8 @@ void UISplitter::updateLayout() { mSplitter->setVisible( !mAlwaysShowSplitter && !mLastWidget ? false : true ); mSplitter->setEnabled( mSplitter->isVisible() ); Float totalSpace = mOrientation == UIOrientation::Horizontal - ? mSize.getWidth() - mRealPadding.Left - mRealPadding.Right - : mSize.getHeight() - mRealPadding.Top - mRealPadding.Bottom; + ? mSize.getWidth() - mPaddingPx.Left - mPaddingPx.Right + : mSize.getHeight() - mPaddingPx.Top - mPaddingPx.Bottom; if ( mSplitter->isVisible() ) { totalSpace -= UIOrientation::Horizontal == mOrientation ? mSplitter->getPixelsSize().getWidth() @@ -350,7 +350,7 @@ void UISplitter::updateLayout() { Float secondSplit = totalSpace - firstSplit; if ( mFirstWidget ) { - mFirstWidget->setPixelsPosition( mRealPadding.Left, mRealPadding.Top ); + mFirstWidget->setPixelsPosition( mPaddingPx.Left, mPaddingPx.Top ); if ( UIOrientation::Horizontal == mOrientation ) { Float fMinSize = mFirstWidget ? mFirstWidget->getCurrentMinSize().getWidth() : 0.f; @@ -358,14 +358,14 @@ void UISplitter::updateLayout() { firstSplit = eemax( firstSplit, fMinSize ); secondSplit = totalSpace - firstSplit; - mFirstWidget->setPixelsSize( firstSplit, mSize.getHeight() - mRealPadding.Top - - mRealPadding.Bottom ); + mFirstWidget->setPixelsSize( firstSplit, mSize.getHeight() - mPaddingPx.Top - + mPaddingPx.Bottom ); mSplitter->setPixelsPosition( mFirstWidget->getPixelsPosition().x + mFirstWidget->getPixelsSize().getWidth(), - mRealPadding.Top ); + mPaddingPx.Top ); mSplitter->setPixelsSize( mSplitter->getPixelsSize().getWidth(), - mSize.getHeight() - mRealPadding.Top - mRealPadding.Bottom ); + mSize.getHeight() - mPaddingPx.Top - mPaddingPx.Bottom ); } else { Float fMinSize = mFirstWidget ? mFirstWidget->getCurrentMinSize().getHeight() : 0.f; @@ -373,13 +373,13 @@ void UISplitter::updateLayout() { firstSplit = eemax( firstSplit, fMinSize ); secondSplit = totalSpace - firstSplit; - mFirstWidget->setPixelsSize( mSize.getWidth() - mRealPadding.Left - mRealPadding.Right, + mFirstWidget->setPixelsSize( mSize.getWidth() - mPaddingPx.Left - mPaddingPx.Right, firstSplit ); - mSplitter->setPixelsPosition( mRealPadding.Left, + mSplitter->setPixelsPosition( mPaddingPx.Left, mFirstWidget->getPixelsPosition().y + mFirstWidget->getPixelsSize().getHeight() ); - mSplitter->setPixelsSize( mSize.getWidth() - mRealPadding.Left - mRealPadding.Right, + mSplitter->setPixelsSize( mSize.getWidth() - mPaddingPx.Left - mPaddingPx.Right, mSplitter->getPixelsSize().getHeight() ); } } @@ -388,14 +388,14 @@ void UISplitter::updateLayout() { if ( UIOrientation::Horizontal == mOrientation ) { mLastWidget->setPixelsPosition( mSplitter->getPixelsPosition().x + mSplitter->getPixelsSize().getWidth(), - mRealPadding.Top ); - mLastWidget->setPixelsSize( secondSplit, mSize.getHeight() - mRealPadding.Top - - mRealPadding.Bottom ); + mPaddingPx.Top ); + mLastWidget->setPixelsSize( secondSplit, mSize.getHeight() - mPaddingPx.Top - + mPaddingPx.Bottom ); } else { - mLastWidget->setPixelsPosition( mRealPadding.Left, + mLastWidget->setPixelsPosition( mPaddingPx.Left, mSplitter->getPixelsPosition().y + mSplitter->getPixelsSize().getHeight() ); - mLastWidget->setPixelsSize( mSize.getWidth() - mRealPadding.Left - mRealPadding.Right, + mLastWidget->setPixelsSize( mSize.getWidth() - mPaddingPx.Left - mPaddingPx.Right, secondSplit ); } } diff --git a/src/eepp/ui/uisprite.cpp b/src/eepp/ui/uisprite.cpp index 83a8c26be..245e813ef 100644 --- a/src/eepp/ui/uisprite.cpp +++ b/src/eepp/ui/uisprite.cpp @@ -138,13 +138,13 @@ void UISprite::updateSize() { if ( NULL != mSprite->getCurrentTextureRegion() ) { if ( mWidthPolicy == SizePolicy::WrapContent ) { setInternalPixelsWidth( mSprite->getCurrentTextureRegion()->getPixelsSize().getWidth() + - mRealPadding.Left + mRealPadding.Right ); + mPaddingPx.Left + mPaddingPx.Right ); } if ( mHeightPolicy == SizePolicy::WrapContent ) { setInternalPixelsHeight( - mSprite->getCurrentTextureRegion()->getPixelsSize().getHeight() + mRealPadding.Top + - mRealPadding.Bottom ); + mSprite->getCurrentTextureRegion()->getPixelsSize().getHeight() + mPaddingPx.Top + + mPaddingPx.Bottom ); } } } @@ -160,18 +160,18 @@ void UISprite::autoAlign() { mAlignOffset.x = ( mSize.getWidth() - tTextureRegion->getPixelsSize().getWidth() ) / 2; } else if ( Font::getHorizontalAlign( mFlags ) == UI_HALIGN_RIGHT ) { mAlignOffset.x = - mSize.getWidth() - tTextureRegion->getPixelsSize().getWidth() - mRealPadding.Right; + mSize.getWidth() - tTextureRegion->getPixelsSize().getWidth() - mPaddingPx.Right; } else { - mAlignOffset.x = mRealPadding.Left; + mAlignOffset.x = mPaddingPx.Left; } if ( Font::getVerticalAlign( mFlags ) == UI_VALIGN_CENTER ) { mAlignOffset.y = ( mSize.getHeight() - tTextureRegion->getPixelsSize().getHeight() ) / 2; } else if ( Font::getVerticalAlign( mFlags ) == UI_VALIGN_BOTTOM ) { mAlignOffset.y = - mSize.getHeight() - tTextureRegion->getPixelsSize().getHeight() - mRealPadding.Bottom; + mSize.getHeight() - tTextureRegion->getPixelsSize().getHeight() - mPaddingPx.Bottom; } else { - mAlignOffset.y = mRealPadding.Top; + mAlignOffset.y = mPaddingPx.Top; } } diff --git a/src/eepp/ui/uitable.cpp b/src/eepp/ui/uitable.cpp index bd29fbf58..fe5ff34fe 100644 --- a/src/eepp/ui/uitable.cpp +++ b/src/eepp/ui/uitable.cpp @@ -135,7 +135,7 @@ void UITable::onSizeChange() { } void UITable::containerResize() { - Rectf padding = mContainerPadding + mRealPadding; + Rectf padding = mContainerPadding + mPaddingPx; mContainer->setPosition( padding.Left, padding.Top ); @@ -627,7 +627,7 @@ UITable* UITable::setSmoothScroll( bool smoothScroll ) { } Rectf UITable::getContainerPadding() const { - return PixelDensity::pxToDp( mContainerPadding + mRealPadding ); + return PixelDensity::pxToDp( mContainerPadding + mPaddingPx ); } void UITable::onPaddingChange() { diff --git a/src/eepp/ui/uitableview.cpp b/src/eepp/ui/uitableview.cpp index fe315892a..e2619cf81 100644 --- a/src/eepp/ui/uitableview.cpp +++ b/src/eepp/ui/uitableview.cpp @@ -142,7 +142,7 @@ void UITableView::onColumnSizeChange( const size_t& ) { Uint32 UITableView::onKeyDown( const KeyEvent& event ) { if ( event.getMod() != 0 ) - return 0; + return UIAbstractTableView::onKeyDown( event ); auto curIndex = getSelection().first(); int pageSize = eefloor( getVisibleArea().getHeight() / getRowHeight() ) - 1; @@ -155,7 +155,7 @@ Uint32 UITableView::onKeyDown( const KeyEvent& event ) { } else { moveSelection( -pageSize ); } - break; + return 1; } case KEY_PAGEDOWN: { if ( curIndex.row() + pageSize >= (Int64)getModel()->rowCount() ) { @@ -164,36 +164,36 @@ Uint32 UITableView::onKeyDown( const KeyEvent& event ) { } else { moveSelection( pageSize ); } - break; + return 1; } case KEY_UP: { moveSelection( -1 ); - break; + return 1; } case KEY_DOWN: { moveSelection( 1 ); - break; + return 1; } case KEY_END: { scrollToBottom(); getSelection().set( getModel()->index( getItemCount() - 1 ) ); - break; + return 1; } case KEY_HOME: { scrollToTop(); getSelection().set( getModel()->index( 0, 0 ) ); - break; + return 1; } case KEY_RETURN: case KEY_KP_ENTER: { if ( curIndex.isValid() ) onOpenModelIndex( curIndex ); - break; + return 1; } default: break; } - return 0; + return UIAbstractTableView::onKeyDown( event ); } }} // namespace EE::UI diff --git a/src/eepp/ui/uitabwidget.cpp b/src/eepp/ui/uitabwidget.cpp index 50ef98af4..913b290ec 100644 --- a/src/eepp/ui/uitabwidget.cpp +++ b/src/eepp/ui/uitabwidget.cpp @@ -89,8 +89,8 @@ void UITabWidget::setContainerSize() { mTabBar->setVisible( false ); mTabBar->setEnabled( false ); mNodeContainer->setPosition( mPadding.Left, mPadding.Top ); - Sizef s( mSize.getWidth() - mRealPadding.Left - mRealPadding.Right, - mSize.getHeight() - mRealPadding.Top - mRealPadding.Bottom ); + Sizef s( mSize.getWidth() - mPaddingPx.Left - mPaddingPx.Right, + mSize.getHeight() - mPaddingPx.Top - mPaddingPx.Bottom ); if ( s != mNodeContainer->getPixelsSize() ) { mNodeContainer->setPixelsSize( s ); @@ -101,13 +101,13 @@ void UITabWidget::setContainerSize() { } else { mTabBar->setVisible( true ); mTabBar->setEnabled( true ); - mTabBar->setPixelsSize( mSize.getWidth() - mRealPadding.Left - mRealPadding.Right, + mTabBar->setPixelsSize( mSize.getWidth() - mPaddingPx.Left - mPaddingPx.Right, PixelDensity::dpToPx( mStyleConfig.TabHeight ) ); mTabBar->setPosition( mPadding.Left, mPadding.Top ); mNodeContainer->setPosition( mPadding.Left, mPadding.Top + mStyleConfig.TabHeight ); - Sizef s( mSize.getWidth() - mRealPadding.Left - mRealPadding.Right, + Sizef s( mSize.getWidth() - mPaddingPx.Left - mPaddingPx.Right, mSize.getHeight() - PixelDensity::dpToPx( mStyleConfig.TabHeight ) - - mRealPadding.Top - mRealPadding.Bottom ); + mPaddingPx.Top - mPaddingPx.Bottom ); if ( s != mNodeContainer->getPixelsSize() ) { mNodeContainer->setPixelsSize( s ); diff --git a/src/eepp/ui/uitextinput.cpp b/src/eepp/ui/uitextinput.cpp index 1baffa075..7843a8cea 100644 --- a/src/eepp/ui/uitextinput.cpp +++ b/src/eepp/ui/uitextinput.cpp @@ -101,8 +101,8 @@ void UITextInput::onCursorPosChange() { void UITextInput::drawWaitingCursor() { if ( mVisible && hasFocus() && mShowingWait && mAllowEditing ) { Vector2f cursor( - eefloor( mScreenPos.x + mRealAlignOffset.x + mCurPos.x + mRealPadding.Left ), - mScreenPos.y + mRealAlignOffset.y + mCurPos.y + mRealPadding.Top ); + eefloor( mScreenPos.x + mRealAlignOffset.x + mCurPos.x + mPaddingPx.Left ), + mScreenPos.y + mRealAlignOffset.y + mCurPos.y + mPaddingPx.Top ); Primitives primitives; primitives.setColor( Color( mFontStyleConfig.FontColor ).blendAlpha( mAlpha ) ); @@ -132,16 +132,16 @@ void UITextInput::draw() { drawSelection( mTextCache ); if ( isClipped() ) { - clipSmartEnable( mScreenPos.x + mRealPadding.Left, mScreenPos.y + mRealPadding.Top, - mSize.getWidth() - mRealPadding.Left - mRealPadding.Right, - mSize.getHeight() - mRealPadding.Top - mRealPadding.Bottom ); + clipSmartEnable( mScreenPos.x + mPaddingPx.Left, mScreenPos.y + mPaddingPx.Top, + mSize.getWidth() - mPaddingPx.Left - mPaddingPx.Right, + mSize.getHeight() - mPaddingPx.Top - mPaddingPx.Bottom ); } mTextCache->setAlign( getFlags() ); mTextCache->draw( (Float)mScreenPosi.x + (int)mRealAlignOffset.x + - (int)mRealPadding.Left, + (int)mPaddingPx.Left, mFontLineCenter + (Float)mScreenPosi.y + (int)mRealAlignOffset.y + - (int)mRealPadding.Top, + (int)mPaddingPx.Top, Vector2f::One, 0.f, getBlendMode() ); if ( isClipped() ) { @@ -149,15 +149,15 @@ void UITextInput::draw() { } } else if ( !mHintCache->getString().empty() ) { if ( isClipped() ) { - clipSmartEnable( mScreenPos.x + mRealPadding.Left, mScreenPos.y + mRealPadding.Top, - mSize.getWidth() - mRealPadding.Left - mRealPadding.Right, - mSize.getHeight() - mRealPadding.Top - mRealPadding.Bottom ); + clipSmartEnable( mScreenPos.x + mPaddingPx.Left, mScreenPos.y + mPaddingPx.Top, + mSize.getWidth() - mPaddingPx.Left - mPaddingPx.Right, + mSize.getHeight() - mPaddingPx.Top - mPaddingPx.Bottom ); } mHintCache->draw( (Float)mScreenPosi.x + (int)mRealAlignOffset.x + - (int)mRealPadding.Left, + (int)mPaddingPx.Left, mFontLineCenter + (Float)mScreenPosi.y + (int)mRealAlignOffset.y + - (int)mRealPadding.Top, + (int)mPaddingPx.Top, Vector2f::One, 0.f, getBlendMode() ); if ( isClipped() ) { @@ -203,13 +203,13 @@ void UITextInput::alignFix() { switch ( Font::getVerticalAlign( getFlags() ) ) { case UI_VALIGN_CENTER: mRealAlignOffset.y = - ( Float )( ( Int32 )( ( mSize.y - mRealPadding.Top - mRealPadding.Bottom ) / 2 - + ( Float )( ( Int32 )( ( mSize.y - mPaddingPx.Top - mPaddingPx.Bottom ) / 2 - mTextCache->getLineSpacing() / 2 ) ) - 1; break; case UI_VALIGN_BOTTOM: mRealAlignOffset.y = - mSize.y - mRealPadding.Top - mRealPadding.Bottom - mTextCache->getLineSpacing(); + mSize.y - mPaddingPx.Top - mPaddingPx.Bottom - mTextCache->getLineSpacing(); break; case UI_VALIGN_TOP: mRealAlignOffset.y = 0; @@ -227,8 +227,8 @@ void UITextInput::alignFix() { if ( tX < 0.f ) { mRealAlignOffset.x = -( mRealAlignOffset.x + ( tW - mRealAlignOffset.x ) ); - } else if ( tX > mSize.getWidth() - mRealPadding.Left - mRealPadding.Right ) { - mRealAlignOffset.x = mSize.getWidth() - mRealPadding.Left - mRealPadding.Right - + } else if ( tX > mSize.getWidth() - mPaddingPx.Left - mPaddingPx.Right ) { + mRealAlignOffset.x = mSize.getWidth() - mPaddingPx.Left - mPaddingPx.Right - ( mRealAlignOffset.x + ( tW - mRealAlignOffset.x ) ); } } @@ -258,10 +258,10 @@ void UITextInput::onAutoSize() { if ( mHeightPolicy == SizePolicy::WrapContent ) { int minHeight = eemax( mTextCache->getLineSpacing(), PixelDensity::dpToPxI( getSkinSize().getHeight() ) ); - setInternalPixelsHeight( minHeight + mRealPadding.Top + mRealPadding.Bottom ); + setInternalPixelsHeight( minHeight + mPaddingPx.Top + mPaddingPx.Bottom ); } else if ( ( mFlags & UI_AUTO_SIZE ) && 0 == getSize().getHeight() ) { setInternalPixelsHeight( PixelDensity::dpToPxI( getSkinSize().getHeight() ) + - mRealPadding.Top + mRealPadding.Bottom ); + mPaddingPx.Top + mPaddingPx.Bottom ); } } diff --git a/src/eepp/ui/uitextinputpassword.cpp b/src/eepp/ui/uitextinputpassword.cpp index d95041793..b42483b00 100644 --- a/src/eepp/ui/uitextinputpassword.cpp +++ b/src/eepp/ui/uitextinputpassword.cpp @@ -30,15 +30,15 @@ void UITextInputPassword::draw() { drawSelection( mPassCache ); if ( isClipped() ) { - clipSmartEnable( mScreenPos.x + mRealPadding.Left, mScreenPos.y + mRealPadding.Top, - mSize.getWidth() - mRealPadding.Left - mRealPadding.Right, - mSize.getHeight() - mRealPadding.Top - mRealPadding.Bottom ); + clipSmartEnable( mScreenPos.x + mPaddingPx.Left, mScreenPos.y + mPaddingPx.Top, + mSize.getWidth() - mPaddingPx.Left - mPaddingPx.Right, + mSize.getHeight() - mPaddingPx.Top - mPaddingPx.Bottom ); } mPassCache->setAlign( getFlags() ); mPassCache->draw( - (Float)mScreenPosi.x + (int)mRealAlignOffset.x + (int)mRealPadding.Left, - (Float)mScreenPosi.y + (int)mRealAlignOffset.y + (int)mRealPadding.Top, + (Float)mScreenPosi.x + (int)mRealAlignOffset.x + (int)mPaddingPx.Left, + (Float)mScreenPosi.y + (int)mRealAlignOffset.y + (int)mPaddingPx.Top, Vector2f::One, 0.f, getBlendMode() ); if ( isClipped() ) { @@ -46,15 +46,15 @@ void UITextInputPassword::draw() { } } else if ( !mHintCache->getString().empty() ) { if ( isClipped() ) { - clipSmartEnable( mScreenPos.x + mRealPadding.Left, mScreenPos.y + mRealPadding.Top, - mSize.getWidth() - mRealPadding.Left - mRealPadding.Right, - mSize.getHeight() - mRealPadding.Top - mRealPadding.Bottom ); + clipSmartEnable( mScreenPos.x + mPaddingPx.Left, mScreenPos.y + mPaddingPx.Top, + mSize.getWidth() - mPaddingPx.Left - mPaddingPx.Right, + mSize.getHeight() - mPaddingPx.Top - mPaddingPx.Bottom ); } mHintCache->draw( (Float)mScreenPosi.x + (int)mHintAlignOffset.x + - (int)mRealPadding.Left, + (int)mPaddingPx.Left, mFontLineCenter + (Float)mScreenPosi.y + (int)mHintAlignOffset.y + - (int)mRealPadding.Top, + (int)mPaddingPx.Top, Vector2f::One, 0.f, getBlendMode() ); if ( isClipped() ) { @@ -85,12 +85,12 @@ void UITextInputPassword::alignFix() { switch ( Font::getVerticalAlign( getFlags() ) ) { case UI_VALIGN_CENTER: mRealAlignOffset.y = - ( Float )( ( ( Int32 )( mSize.y - mRealPadding.Top - mRealPadding.Bottom - + ( Float )( ( ( Int32 )( mSize.y - mPaddingPx.Top - mPaddingPx.Bottom - mPassCache->getTextHeight() ) ) / 2.f ) - 1; mHintAlignOffset.y = - ( Float )( ( ( Int32 )( mSize.y - mRealPadding.Top - mRealPadding.Bottom - + ( Float )( ( ( Int32 )( mSize.y - mPaddingPx.Top - mPaddingPx.Bottom - mHintCache->getTextHeight() ) ) / 2.f ) - 1; @@ -114,8 +114,8 @@ void UITextInputPassword::alignFix() { if ( tX < 0.f ) { mRealAlignOffset.x = -( mRealAlignOffset.x + ( tW - mRealAlignOffset.x ) ); - } else if ( tX > mSize.getWidth() - mRealPadding.Left - mRealPadding.Right ) { - mRealAlignOffset.x = mSize.getWidth() - mRealPadding.Left - mRealPadding.Right - + } else if ( tX > mSize.getWidth() - mPaddingPx.Left - mPaddingPx.Right ) { + mRealAlignOffset.x = mSize.getWidth() - mPaddingPx.Left - mPaddingPx.Right - ( mRealAlignOffset.x + ( tW - mRealAlignOffset.x ) ); } } diff --git a/src/eepp/ui/uitextureregion.cpp b/src/eepp/ui/uitextureregion.cpp index e0068d255..ca9389fff 100644 --- a/src/eepp/ui/uitextureregion.cpp +++ b/src/eepp/ui/uitextureregion.cpp @@ -56,13 +56,13 @@ void UITextureRegion::onAutoSize() { if ( mWidthPolicy == SizePolicy::WrapContent || mHeightPolicy == SizePolicy::WrapContent ) { if ( mWidthPolicy == SizePolicy::WrapContent ) { - setInternalPixelsWidth( mTextureRegion->getPixelsSize().getWidth() + mRealPadding.Left + - mRealPadding.Right ); + setInternalPixelsWidth( mTextureRegion->getPixelsSize().getWidth() + mPaddingPx.Left + + mPaddingPx.Right ); } if ( mHeightPolicy == SizePolicy::WrapContent ) { setInternalPixelsHeight( mTextureRegion->getPixelsSize().getHeight() + - mRealPadding.Top + mRealPadding.Bottom ); + mPaddingPx.Top + mPaddingPx.Bottom ); } autoAlign(); @@ -81,8 +81,8 @@ void UITextureRegion::draw() { if ( mScaleType == UIScaleType::Expand ) { mTextureRegion->setOffset( Vector2i( 0, 0 ) ); mTextureRegion->setDestSize( - Vector2f( (int)mSize.x - mRealPadding.Left - mRealPadding.Right, - (int)mSize.y - mRealPadding.Top - mRealPadding.Bottom ) ); + Vector2f( (int)mSize.x - mPaddingPx.Left - mPaddingPx.Right, + (int)mSize.y - mPaddingPx.Top - mPaddingPx.Bottom ) ); autoAlign(); @@ -93,9 +93,9 @@ void UITextureRegion::draw() { Sizef pxSize = mTextureRegion->getPixelsSize(); Float Scale1 = - ( mSize.x - mRealPadding.Left - mRealPadding.Right ) / (Float)pxSize.x; + ( mSize.x - mPaddingPx.Left - mPaddingPx.Right ) / (Float)pxSize.x; Float Scale2 = - ( mSize.y - mRealPadding.Top - mRealPadding.Bottom ) / (Float)pxSize.y; + ( mSize.y - mPaddingPx.Top - mPaddingPx.Bottom ) / (Float)pxSize.y; if ( Scale1 < 1 || Scale2 < 1 ) { if ( Scale2 < Scale1 ) @@ -175,17 +175,17 @@ void UITextureRegion::autoAlign() { if ( Font::getHorizontalAlign( mFlags ) == UI_HALIGN_CENTER ) { mAlignOffset.x = ( mSize.getWidth() - mTextureRegion->getDestSize().x ) / 2; } else if ( Font::getHorizontalAlign( mFlags ) == UI_HALIGN_RIGHT ) { - mAlignOffset.x = mSize.getWidth() - mTextureRegion->getDestSize().x - mRealPadding.Right; + mAlignOffset.x = mSize.getWidth() - mTextureRegion->getDestSize().x - mPaddingPx.Right; } else { - mAlignOffset.x = mRealPadding.Left; + mAlignOffset.x = mPaddingPx.Left; } if ( Font::getVerticalAlign( mFlags ) == UI_VALIGN_CENTER ) { mAlignOffset.y = ( mSize.getHeight() - mTextureRegion->getDestSize().y ) / 2; } else if ( Font::getVerticalAlign( mFlags ) == UI_VALIGN_BOTTOM ) { - mAlignOffset.y = mSize.getHeight() - mTextureRegion->getDestSize().y - mRealPadding.Bottom; + mAlignOffset.y = mSize.getHeight() - mTextureRegion->getDestSize().y - mPaddingPx.Bottom; } else { - mAlignOffset.y = mRealPadding.Top; + mAlignOffset.y = mPaddingPx.Top; } } diff --git a/src/eepp/ui/uitextview.cpp b/src/eepp/ui/uitextview.cpp index 5254ad421..4ea469db9 100644 --- a/src/eepp/ui/uitextview.cpp +++ b/src/eepp/ui/uitextview.cpp @@ -78,16 +78,16 @@ void UITextView::draw() { drawSelection( mTextCache ); if ( isClipped() ) { - clipSmartEnable( mScreenPos.x + mRealPadding.Left, mScreenPos.y + mRealPadding.Top, - mSize.getWidth() - mRealPadding.Left - mRealPadding.Right, - mSize.getHeight() - mRealPadding.Top - mRealPadding.Bottom ); + clipSmartEnable( mScreenPos.x + mPaddingPx.Left, mScreenPos.y + mPaddingPx.Top, + mSize.getWidth() - mPaddingPx.Left - mPaddingPx.Right, + mSize.getHeight() - mPaddingPx.Top - mPaddingPx.Bottom ); } mTextCache->setAlign( getFlags() ); mTextCache->draw( (Float)mScreenPosi.x + (int)mRealAlignOffset.x + - (int)mRealPadding.Left, + (int)mPaddingPx.Left, mFontLineCenter + (Float)mScreenPosi.y + (int)mRealAlignOffset.y + - (int)mRealPadding.Top, + (int)mPaddingPx.Top, Vector2f::One, 0.f, getBlendMode() ); if ( isClipped() ) { @@ -268,13 +268,13 @@ void UITextView::onAutoSize() { } if ( mWidthPolicy == SizePolicy::WrapContent ) { - setInternalPixelsWidth( (int)mTextCache->getTextWidth() + mRealPadding.Left + - mRealPadding.Right ); + setInternalPixelsWidth( (int)mTextCache->getTextWidth() + mPaddingPx.Left + + mPaddingPx.Right ); } if ( mHeightPolicy == SizePolicy::WrapContent ) { - setInternalPixelsHeight( (int)mTextCache->getTextHeight() + mRealPadding.Top + - mRealPadding.Bottom ); + setInternalPixelsHeight( (int)mTextCache->getTextHeight() + mPaddingPx.Top + + mPaddingPx.Bottom ); } } @@ -282,11 +282,11 @@ void UITextView::alignFix() { switch ( Font::getHorizontalAlign( getFlags() ) ) { case UI_HALIGN_CENTER: mRealAlignOffset.x = - ( Float )( ( Int32 )( ( mSize.x - mRealPadding.Left - mRealPadding.Right ) / 2 - + ( Float )( ( Int32 )( ( mSize.x - mPaddingPx.Left - mPaddingPx.Right ) / 2 - mTextCache->getTextWidth() / 2 ) ); break; case UI_HALIGN_RIGHT: - mRealAlignOffset.x = ( (Float)mSize.x - mRealPadding.Left - mRealPadding.Right - + mRealAlignOffset.x = ( (Float)mSize.x - mPaddingPx.Left - mPaddingPx.Right - (Float)mTextCache->getTextWidth() ); break; case UI_HALIGN_LEFT: @@ -297,12 +297,12 @@ void UITextView::alignFix() { switch ( Font::getVerticalAlign( getFlags() ) ) { case UI_VALIGN_CENTER: mRealAlignOffset.y = - ( Float )( ( Int32 )( ( mSize.y - mRealPadding.Top - mRealPadding.Bottom ) / 2 - + ( Float )( ( Int32 )( ( mSize.y - mPaddingPx.Top - mPaddingPx.Bottom ) / 2 - mTextCache->getTextHeight() / 2 ) ) - 1; break; case UI_VALIGN_BOTTOM: - mRealAlignOffset.y = ( (Float)mSize.y - mRealPadding.Top - mRealPadding.Bottom - + mRealAlignOffset.y = ( (Float)mSize.y - mPaddingPx.Top - mPaddingPx.Bottom - (Float)mTextCache->getTextHeight() ); break; case UI_VALIGN_TOP: @@ -383,7 +383,7 @@ Uint32 UITextView::onMouseDoubleClick( const Vector2i& Pos, const Uint32& Flags Vector2f nodePos( Vector2f( Pos.x, Pos.y ) ); worldToNode( nodePos ); nodePos = PixelDensity::dpToPx( nodePos ) - mRealAlignOffset - - Vector2f( mRealPadding.Left, mRealPadding.Top ); + Vector2f( mPaddingPx.Left, mPaddingPx.Top ); nodePos.x = eemax( 0.f, nodePos.x ); nodePos.y = eemax( 0.f, nodePos.y ); @@ -419,7 +419,7 @@ Uint32 UITextView::onMouseDown( const Vector2i& Pos, const Uint32& Flags ) { Vector2f nodePos( Vector2f( Pos.x, Pos.y ) ); worldToNode( nodePos ); nodePos = PixelDensity::dpToPx( nodePos ) - mRealAlignOffset - - Vector2f( mRealPadding.Left, mRealPadding.Top ); + Vector2f( mPaddingPx.Left, mPaddingPx.Top ); nodePos.x = eemax( 0.f, nodePos.x ); nodePos.y = eemax( 0.f, nodePos.y ); @@ -485,10 +485,10 @@ void UITextView::drawSelection( Text* textCache ) { endPos = mSelPosCache[i].endPos; P.drawRectangle( Rectf( - mScreenPos.x + initPos.x + mRealAlignOffset.x + mRealPadding.Left, - mScreenPos.y + initPos.y + mRealAlignOffset.y + mRealPadding.Top, - mScreenPos.x + endPos.x + mRealAlignOffset.x + mRealPadding.Left, - mScreenPos.y + endPos.y + vspace + mRealAlignOffset.y + mRealPadding.Top ) ); + mScreenPos.x + initPos.x + mRealAlignOffset.x + mPaddingPx.Left, + mScreenPos.y + initPos.y + mRealAlignOffset.y + mPaddingPx.Top, + mScreenPos.x + endPos.x + mRealAlignOffset.x + mPaddingPx.Left, + mScreenPos.y + endPos.y + vspace + mRealAlignOffset.y + mPaddingPx.Top ) ); } } } diff --git a/src/eepp/ui/uitooltip.cpp b/src/eepp/ui/uitooltip.cpp index 7283c8d5e..decc1df27 100644 --- a/src/eepp/ui/uitooltip.cpp +++ b/src/eepp/ui/uitooltip.cpp @@ -173,42 +173,42 @@ void UITooltip::setFontShadowColor( const Color& color ) { void UITooltip::onAutoSize() { if ( mFlags & UI_AUTO_SIZE ) { setInternalPixelsSize( - Sizef( (int)mTextCache->getTextWidth() + mRealPadding.Left + mRealPadding.Right, - (int)mTextCache->getTextHeight() + mRealPadding.Top + mRealPadding.Bottom ) ); + Sizef( (int)mTextCache->getTextWidth() + mPaddingPx.Left + mPaddingPx.Right, + (int)mTextCache->getTextHeight() + mPaddingPx.Top + mPaddingPx.Bottom ) ); autoAlign(); } } void UITooltip::autoAlign() { - Uint32 Width = mSize.getWidth() - mRealPadding.Left - mRealPadding.Right; - Uint32 Height = mSize.getHeight() - mRealPadding.Top - mRealPadding.Bottom; + Uint32 Width = mSize.getWidth() - mPaddingPx.Left - mPaddingPx.Right; + Uint32 Height = mSize.getHeight() - mPaddingPx.Top - mPaddingPx.Bottom; switch ( Font::getHorizontalAlign( getFlags() ) ) { case UI_HALIGN_CENTER: - mAlignOffset.x = mRealPadding.Left + + mAlignOffset.x = mPaddingPx.Left + ( Float )( ( Int32 )( Width - mTextCache->getTextWidth() ) / 2 ); break; case UI_HALIGN_RIGHT: mAlignOffset.x = - ( (Float)Width - (Float)mTextCache->getTextWidth() ) - mRealPadding.Right; + ( (Float)Width - (Float)mTextCache->getTextWidth() ) - mPaddingPx.Right; break; case UI_HALIGN_LEFT: - mAlignOffset.x = mRealPadding.Left; + mAlignOffset.x = mPaddingPx.Left; break; } switch ( Font::getVerticalAlign( getFlags() ) ) { case UI_VALIGN_CENTER: - mAlignOffset.y = mRealPadding.Top + + mAlignOffset.y = mPaddingPx.Top + ( Float )( ( ( Int32 )( Height - mTextCache->getTextHeight() ) ) / 2 ); break; case UI_VALIGN_BOTTOM: mAlignOffset.y = - ( (Float)Height - (Float)mTextCache->getTextHeight() ) - mRealPadding.Bottom; + ( (Float)Height - (Float)mTextCache->getTextHeight() ) - mPaddingPx.Bottom; break; case UI_VALIGN_TOP: - mAlignOffset.y = mRealPadding.Top; + mAlignOffset.y = mPaddingPx.Top; break; } } diff --git a/src/eepp/ui/uitreeview.cpp b/src/eepp/ui/uitreeview.cpp index 14eb4d28d..7167e5364 100644 --- a/src/eepp/ui/uitreeview.cpp +++ b/src/eepp/ui/uitreeview.cpp @@ -125,14 +125,14 @@ class UITreeViewCell : public UIPushButton { if ( autoPadding != Rectf() ) autoPadding = PixelDensity::dpToPx( autoPadding ); } - if ( mRealPadding.Top > autoPadding.Top ) - autoPadding.Top = mRealPadding.Top; - if ( mRealPadding.Bottom > autoPadding.Bottom ) - autoPadding.Bottom = mRealPadding.Bottom; - if ( mRealPadding.Left > autoPadding.Left ) - autoPadding.Left = mRealPadding.Left; - if ( mRealPadding.Right > autoPadding.Right ) - autoPadding.Right = mRealPadding.Right; + if ( mPaddingPx.Top > autoPadding.Top ) + autoPadding.Top = mPaddingPx.Top; + if ( mPaddingPx.Bottom > autoPadding.Bottom ) + autoPadding.Bottom = mPaddingPx.Bottom; + if ( mPaddingPx.Left > autoPadding.Left ) + autoPadding.Left = mPaddingPx.Left; + if ( mPaddingPx.Right > autoPadding.Right ) + autoPadding.Right = mPaddingPx.Right; autoPadding.Left += mIndent; switch ( mInnerWidgetOrientation ) { case InnerWidgetOrientation::Left: @@ -441,7 +441,7 @@ Float UITreeView::getMaxColumnContentWidth( const size_t& colIndex ) { Uint32 UITreeView::onKeyDown( const KeyEvent& event ) { if ( event.getMod() != 0 ) - return 0; + return UIAbstractTableView::onKeyDown( event ); auto curIndex = getSelection().first(); @@ -464,7 +464,7 @@ Uint32 UITreeView::onKeyDown( const KeyEvent& event ) { scrollToPosition( {{mScrollOffset.x, curY}, {columnData( deque.front().first.column() ).width, getRowHeight()}} ); - break; + return 1; } case KEY_PAGEDOWN: { int pageSize = eefloor( getVisibleArea().getHeight() / getRowHeight() ) - 1; @@ -500,7 +500,7 @@ Uint32 UITreeView::onKeyDown( const KeyEvent& event ) { getSelection().set( foundIndex ); scrollToPosition( {{mScrollOffset.x, curY}, {columnData( foundIndex.column() ).width, getRowHeight()}} ); - break; + return 1; } case KEY_UP: { ModelIndex prevIndex; @@ -519,14 +519,14 @@ Uint32 UITreeView::onKeyDown( const KeyEvent& event ) { if ( foundIndex.isValid() ) { getSelection().set( foundIndex ); if ( curY < mScrollOffset.y + getHeaderHeight() + getRowHeight() || - curY > mScrollOffset.y + getPixelsSize().getHeight() - mRealPadding.Top - - mRealPadding.Bottom - getRowHeight() ) { + curY > mScrollOffset.y + getPixelsSize().getHeight() - mPaddingPx.Top - + mPaddingPx.Bottom - getRowHeight() ) { curY -= getHeaderHeight() + getRowHeight(); mVScroll->setValue( eemin( 1.f, eemax( 0.f, curY / getScrollableArea().getHeight() ) ) ); } } - break; + return 1; } case KEY_DOWN: { ModelIndex prevIndex; @@ -545,8 +545,8 @@ Uint32 UITreeView::onKeyDown( const KeyEvent& event ) { if ( foundIndex.isValid() ) { getSelection().set( foundIndex ); if ( curY < mScrollOffset.y || - curY > mScrollOffset.y + getPixelsSize().getHeight() - mRealPadding.Top - - mRealPadding.Bottom - getRowHeight() ) { + curY > mScrollOffset.y + getPixelsSize().getHeight() - mPaddingPx.Top - + mPaddingPx.Bottom - getRowHeight() ) { curY -= eefloor( getVisibleArea().getHeight() / getRowHeight() ) * getRowHeight() - getRowHeight(); @@ -554,7 +554,7 @@ Uint32 UITreeView::onKeyDown( const KeyEvent& event ) { eemin( 1.f, curY / getScrollableArea().getHeight() ) ); } } - break; + return 1; } case KEY_END: { scrollToBottom(); @@ -564,12 +564,12 @@ Uint32 UITreeView::onKeyDown( const KeyEvent& event ) { return IterationDecision::Continue; } ); getSelection().set( lastIndex ); - break; + return 1; } case KEY_HOME: { scrollToTop(); getSelection().set( getModel()->index( 0, 0 ) ); - break; + return 1; } case KEY_RIGHT: { if ( curIndex.isValid() && getModel()->rowCount( curIndex ) ) { @@ -581,7 +581,7 @@ Uint32 UITreeView::onKeyDown( const KeyEvent& event ) { } getSelection().set( getModel()->index( 0, getModel()->treeColumn(), curIndex ) ); } - break; + return 1; } case KEY_LEFT: { if ( curIndex.isValid() && getModel()->rowCount( curIndex ) ) { @@ -596,7 +596,7 @@ Uint32 UITreeView::onKeyDown( const KeyEvent& event ) { getSelection().set( curIndex.parent() ); return 0; } - break; + return 1; } case KEY_RETURN: case KEY_SPACE: { @@ -609,12 +609,12 @@ Uint32 UITreeView::onKeyDown( const KeyEvent& event ) { onOpenModelIndex( curIndex ); } } - break; + return 1; } default: break; } - return 0; + return UIAbstractTableView::onKeyDown( event ); } void UITreeView::onOpenTreeModelIndex( const ModelIndex& index, bool open ) { diff --git a/src/eepp/ui/uiwidget.cpp b/src/eepp/ui/uiwidget.cpp index b7278daa4..5433c4946 100644 --- a/src/eepp/ui/uiwidget.cpp +++ b/src/eepp/ui/uiwidget.cpp @@ -80,13 +80,18 @@ void UIWidget::updateAnchorsDistances() { } } -const Rect& UIWidget::getLayoutMargin() const { +const Rectf& UIWidget::getLayoutMargin() const { return mLayoutMargin; } -UIWidget* UIWidget::setLayoutMargin( const Rect& margin ) { +const Rectf& UIWidget::getLayoutPixelsMargin() const { + return mLayoutMarginPx; +} + +UIWidget* UIWidget::setLayoutMargin( const Rectf& margin ) { if ( mLayoutMargin != margin ) { mLayoutMargin = margin; + mLayoutMarginPx = PixelDensity::dpToPx( mLayoutMargin ); onMarginChange(); notifyLayoutAttrChange(); } @@ -97,6 +102,7 @@ UIWidget* UIWidget::setLayoutMargin( const Rect& margin ) { UIWidget* UIWidget::setLayoutMarginLeft( const Float& marginLeft ) { if ( mLayoutMargin.Left != marginLeft ) { mLayoutMargin.Left = marginLeft; + mLayoutMarginPx.Left = PixelDensity::dpToPx( mLayoutMargin.Left ); onMarginChange(); notifyLayoutAttrChange(); } @@ -107,6 +113,7 @@ UIWidget* UIWidget::setLayoutMarginLeft( const Float& marginLeft ) { UIWidget* UIWidget::setLayoutMarginRight( const Float& marginRight ) { if ( mLayoutMargin.Right != marginRight ) { mLayoutMargin.Right = marginRight; + mLayoutMarginPx.Right = PixelDensity::dpToPx( mLayoutMargin.Right ); onMarginChange(); notifyLayoutAttrChange(); } @@ -117,6 +124,7 @@ UIWidget* UIWidget::setLayoutMarginRight( const Float& marginRight ) { UIWidget* UIWidget::setLayoutMarginTop( const Float& marginTop ) { if ( mLayoutMargin.Top != marginTop ) { mLayoutMargin.Top = marginTop; + mLayoutMarginPx.Top = PixelDensity::dpToPx( mLayoutMargin.Top ); onMarginChange(); notifyLayoutAttrChange(); } @@ -127,6 +135,7 @@ UIWidget* UIWidget::setLayoutMarginTop( const Float& marginTop ) { UIWidget* UIWidget::setLayoutMarginBottom( const Float& marginBottom ) { if ( mLayoutMargin.Bottom != marginBottom ) { mLayoutMargin.Bottom = marginBottom; + mLayoutMarginPx.Bottom = PixelDensity::dpToPx( mLayoutMargin.Bottom ); onMarginChange(); notifyLayoutAttrChange(); } @@ -734,13 +743,13 @@ const Rectf& UIWidget::getPadding() const { } const Rectf& UIWidget::getPixelsPadding() const { - return mRealPadding; + return mPaddingPx; } UIWidget* UIWidget::setPadding( const Rectf& padding ) { if ( padding != mPadding ) { mPadding = padding; - mRealPadding = PixelDensity::dpToPx( mPadding ); + mPaddingPx = PixelDensity::dpToPx( mPadding ); onAutoSize(); onPaddingChange(); notifyLayoutAttrChange(); @@ -752,7 +761,7 @@ UIWidget* UIWidget::setPadding( const Rectf& padding ) { UIWidget* UIWidget::setPaddingLeft( const Float& paddingLeft ) { if ( paddingLeft != mPadding.Left ) { mPadding.Left = paddingLeft; - mRealPadding.Left = PixelDensity::dpToPx( mPadding.Left ); + mPaddingPx.Left = PixelDensity::dpToPx( mPadding.Left ); onAutoSize(); onPaddingChange(); notifyLayoutAttrChange(); @@ -764,7 +773,7 @@ UIWidget* UIWidget::setPaddingLeft( const Float& paddingLeft ) { UIWidget* UIWidget::setPaddingRight( const Float& paddingRight ) { if ( paddingRight != mPadding.Right ) { mPadding.Right = paddingRight; - mRealPadding.Right = PixelDensity::dpToPx( mPadding.Right ); + mPaddingPx.Right = PixelDensity::dpToPx( mPadding.Right ); onAutoSize(); onPaddingChange(); notifyLayoutAttrChange(); @@ -776,7 +785,7 @@ UIWidget* UIWidget::setPaddingRight( const Float& paddingRight ) { UIWidget* UIWidget::setPaddingTop( const Float& paddingTop ) { if ( paddingTop != mPadding.Top ) { mPadding.Top = paddingTop; - mRealPadding.Top = PixelDensity::dpToPx( mPadding.Top ); + mPaddingPx.Top = PixelDensity::dpToPx( mPadding.Top ); onAutoSize(); onPaddingChange(); notifyLayoutAttrChange(); @@ -788,7 +797,7 @@ UIWidget* UIWidget::setPaddingTop( const Float& paddingTop ) { UIWidget* UIWidget::setPaddingBottom( const Float& paddingBottom ) { if ( paddingBottom != mPadding.Bottom ) { mPadding.Bottom = paddingBottom; - mRealPadding.Bottom = PixelDensity::dpToPx( mPadding.Bottom ); + mPaddingPx.Bottom = PixelDensity::dpToPx( mPadding.Bottom ); onAutoSize(); onPaddingChange(); notifyLayoutAttrChange(); @@ -1241,13 +1250,13 @@ std::string UIWidget::getPropertyString( const PropertyDefinition* propertyDef, case PropertyId::Height: return String::fromFloat( getSize().getHeight(), "dp" ); case PropertyId::MarginLeft: - return String::format( "%ddp", getLayoutMargin().Left ); + return String::format( "%.2fdp", getLayoutMargin().Left ); case PropertyId::MarginTop: - return String::format( "%ddp", getLayoutMargin().Top ); + return String::format( "%.2fdp", getLayoutMargin().Top ); case PropertyId::MarginRight: - return String::format( "%ddp", getLayoutMargin().Right ); + return String::format( "%.2fdp", getLayoutMargin().Right ); case PropertyId::MarginBottom: - return String::format( "%ddp", getLayoutMargin().Bottom ); + return String::format( "%.2fdp", getLayoutMargin().Bottom ); case PropertyId::PaddingLeft: return String::fromFloat( getPadding().Left, "dp" ); case PropertyId::PaddingTop: diff --git a/src/eepp/ui/uiwindow.cpp b/src/eepp/ui/uiwindow.cpp index ea86cee55..a63acef12 100644 --- a/src/eepp/ui/uiwindow.cpp +++ b/src/eepp/ui/uiwindow.cpp @@ -646,8 +646,8 @@ void UIWindow::fixChildsSize() { } if ( NULL == mWindowDecoration && NULL != mContainer ) { - mContainer->setPixelsSize( mSize - mRealPadding ); - mContainer->setPosition( mRealPadding.Left, mRealPadding.Top ); + mContainer->setPixelsSize( mSize - mPaddingPx ); + mContainer->setPosition( mPaddingPx.Left, mPaddingPx.Top ); return; } @@ -690,14 +690,14 @@ void UIWindow::fixChildsSize() { mBorderBottom->setPixelsPosition( 0, mWindowDecoration->getPixelsSize().getHeight() + mBorderLeft->getPixelsSize().getHeight() ); - mContainer->setPixelsPosition( mBorderLeft->getPixelsSize().getWidth() + mRealPadding.Left, + mContainer->setPixelsPosition( mBorderLeft->getPixelsSize().getWidth() + mPaddingPx.Left, mWindowDecoration->getPixelsSize().getHeight() + - mRealPadding.Top ); + mPaddingPx.Top ); mContainer->setPixelsSize( mSize.getWidth() - mBorderLeft->getPixelsSize().getWidth() - - mBorderRight->getPixelsSize().getWidth() - mRealPadding.Left - mRealPadding.Right, + mBorderRight->getPixelsSize().getWidth() - mPaddingPx.Left - mPaddingPx.Right, mSize.getHeight() - mWindowDecoration->getPixelsSize().getHeight() - - mBorderBottom->getPixelsSize().getHeight() - mRealPadding.Top - mRealPadding.Bottom ); + mBorderBottom->getPixelsSize().getHeight() - mPaddingPx.Top - mPaddingPx.Bottom ); Uint32 yPos; Vector2f posFix( PixelDensity::dpToPx( diff --git a/src/tests/test_all/test.cpp b/src/tests/test_all/test.cpp index 89386a23d..565be1f48 100644 --- a/src/tests/test_all/test.cpp +++ b/src/tests/test_all/test.cpp @@ -845,7 +845,7 @@ void EETest::createNewUI() { UILinearLayout* layPar = UILinearLayout::NewHorizontal(); layPar->setParent( layWin ); - layPar->setLayoutMargin( Rect( 10, 10, 10, 10 ) ); + layPar->setLayoutMargin( Rectf( 10, 10, 10, 10 ) ); layPar->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::WrapContent ); layPar->setLayoutGravity( UI_VALIGN_CENTER | UI_HALIGN_CENTER ); layPar->setBackgroundColor( 0x999999FF ); @@ -858,31 +858,31 @@ void EETest::createNewUI() { UITextView::New() ->setText( "Text on test 1" ) - ->setLayoutMargin( Rect( 10, 10, 10, 10 ) ) + ->setLayoutMargin( Rectf( 10, 10, 10, 10 ) ) ->setLayoutSizePolicy( SizePolicy::WrapContent, SizePolicy::WrapContent ) ->setParent( lay ); UITextView::New() ->setText( "Text on test 2" ) - ->setLayoutMargin( Rect( 10, 10, 10, 10 ) ) + ->setLayoutMargin( Rectf( 10, 10, 10, 10 ) ) ->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::WrapContent ) ->setParent( lay ); UICheckBox::New() ->setText( "Checkbox" ) - ->setLayoutMargin( Rect( 10, 10, 10, 10 ) ) + ->setLayoutMargin( Rectf( 10, 10, 10, 10 ) ) ->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::WrapContent ) ->setParent( lay ); UITextView::New() ->setText( "Text on test 3" ) - ->setLayoutMargin( Rect( 10, 10, 10, 10 ) ) + ->setLayoutMargin( Rectf( 10, 10, 10, 10 ) ) ->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::WrapContent ) ->setParent( lay ); UITextView::New() ->setText( "Text on test 4" ) - ->setLayoutMargin( Rect( 10, 10, 10, 10 ) ) + ->setLayoutMargin( Rectf( 10, 10, 10, 10 ) ) ->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::WrapContent ) ->setParent( lay ); UITextInput::New() - ->setLayoutMargin( Rect( 10, 10, 10, 10 ) ) + ->setLayoutMargin( Rectf( 10, 10, 10, 10 ) ) ->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::WrapContent ) ->setParent( lay ); @@ -894,12 +894,12 @@ void EETest::createNewUI() { UIPushButton::New() ->setText( "PushButton" ) - ->setLayoutMargin( Rect( 10, 10, 10, 10 ) ) + ->setLayoutMargin( Rectf( 10, 10, 10, 10 ) ) ->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::WrapContent ) ->setLayoutGravity( UI_VALIGN_CENTER ) ->setParent( lay2 ); UIListBox* lbox = UIListBox::New(); - lbox->setLayoutMargin( Rect( 10, 10, 10, 10 ) ) + lbox->setLayoutMargin( Rectf( 10, 10, 10, 10 ) ) ->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::Fixed ) ->setSize( 0, 105 ) ->setParent( lay2 ); @@ -908,7 +908,7 @@ void EETest::createNewUI() { lay->setParent( layPar ); UIDropDownList* drop = UIDropDownList::New(); - drop->setLayoutMargin( Rect( 10, 10, 10, 10 ) ) + drop->setLayoutMargin( Rectf( 10, 10, 10, 10 ) ) ->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::WrapContent ) ->setParent( layWin ); drop->getListBox()->addListBoxItems( {"Car", "Bus", "Plane", "Submarine"} ); @@ -922,19 +922,19 @@ void EETest::createNewUI() { UIRelativeLayout* rlay = UIRelativeLayout::New(); rlay->setParent( win2 ); rlay->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::MatchParent ); - rlay->setLayoutMargin( Rect( 16, 16, 16, 16 ) ); + rlay->setLayoutMargin( Rectf( 16, 16, 16, 16 ) ); rlay->setBackgroundColor( 0x333333CC ); UIPushButton* ofBut = UIPushButton::New(); ofBut->setText( "OK" ) ->setLayoutGravity( UI_VALIGN_BOTTOM | UI_HALIGN_RIGHT ) - ->setLayoutMargin( Rect( 0, 0, 16, 16 ) ) + ->setLayoutMargin( Rectf( 0, 0, 16, 16 ) ) ->setParent( rlay ); UIPushButton::New() ->setText( "Cancel" ) ->setLayoutGravity( UI_VALIGN_BOTTOM | UI_HALIGN_RIGHT ) - ->setLayoutMargin( Rect( 0, 0, 8, 0 ) ) + ->setLayoutMargin( Rectf( 0, 0, 8, 0 ) ) ->setLayoutPositionPolicy( PositionPolicy::LeftOf, ofBut ) ->setParent( rlay ); @@ -1130,7 +1130,7 @@ void EETest::createDecoratedWindow() { MenuBar->addMenuButton( "Edit", PopMenu2 ); UIPushButton* Button = UIPushButton::New(); - Button->setLayoutMargin( Rect( 5, 5, 5, 5 ) ); + Button->setLayoutMargin( Rectf( 5, 5, 5, 5 ) ); Button->setText( "Click Me" ); Button->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::WrapContent ) ->setParent( lay ); @@ -1140,7 +1140,7 @@ void EETest::createDecoratedWindow() { mUIWindow->addKeyBinding( {KEY_C, KEYMOD_LALT}, "button-click" ); UITabWidget* TabWidget = UITabWidget::New(); - TabWidget->setLayoutMargin( Rect( 5, 5, 5, 5 ) ) + TabWidget->setLayoutMargin( Rectf( 5, 5, 5, 5 ) ) ->setLayoutWeight( 1 ) ->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::WrapContent ) ->setFlags( UI_HALIGN_CENTER | UI_VALIGN_CENTER ) diff --git a/src/tools/codeeditor/codeeditor.cpp b/src/tools/codeeditor/codeeditor.cpp index ddf926b48..1ee4a488d 100644 --- a/src/tools/codeeditor/codeeditor.cpp +++ b/src/tools/codeeditor/codeeditor.cpp @@ -362,8 +362,8 @@ std::string App::getKeybind( const std::string& command ) { return ""; } -static int MAX_VISIBLE_ITEMS = 18; -static int MAX_RESULT_ITEMS = 100; +static int LOCATEBAR_MAX_VISIBLE_ITEMS = 18; +static int LOCATEBAR_MAX_RESULTS = 100; void App::initLocateBar() { auto addClickListener = [&]( UIWidget* widget, std::string cmd ) { @@ -378,16 +378,16 @@ void App::initLocateBar() { mLocateTable->setHeadersVisible( false ); mLocateTable->setVisible( false ); mLocateInput->addEventListener( Event::OnTextChanged, [&]( const Event* ) { - Vector2f pos( mLocateBarLayout->convertToWorldSpace( {0, 0} ) ); + Vector2f pos( mLocateInput->convertToWorldSpace( {0, 0} ) ); pos.y -= mLocateTable->getPixelsSize().getHeight(); mLocateTable->setPixelsPosition( pos ); if ( !mDirTreeReady ) return; if ( !mLocateInput->getText().empty() ) { mLocateTable->setModel( - mDirTree->fuzzyMatchTree( mLocateInput->getText(), MAX_RESULT_ITEMS ) ); + mDirTree->fuzzyMatchTree( mLocateInput->getText(), LOCATEBAR_MAX_RESULTS ) ); } else { - mLocateTable->setModel( mDirTree->asModel( MAX_RESULT_ITEMS ) ); + mLocateTable->setModel( mDirTree->asModel( LOCATEBAR_MAX_RESULTS ) ); } mLocateTable->getSelection().set( mLocateTable->getModel()->index( 0 ) ); } ); @@ -435,17 +435,17 @@ void App::showLocateBar() { mLocateInput->setFocus(); mLocateTable->setVisible( true ); if ( mDirTree && !mLocateTable->getModel() ) { - mLocateTable->setModel( mDirTree->asModel( MAX_RESULT_ITEMS ) ); + mLocateTable->setModel( mDirTree->asModel( LOCATEBAR_MAX_RESULTS ) ); mLocateTable->getSelection().set( mLocateTable->getModel()->index( 0 ) ); } mLocateBarLayout->runOnMainThread( [&] { Float width = eeceil( mLocateInput->getPixelsSize().getWidth() ); - mLocateTable->setPixelsSize( width, mLocateTable->getRowHeight() * MAX_VISIBLE_ITEMS ); + mLocateTable->setPixelsSize( width, + mLocateTable->getRowHeight() * LOCATEBAR_MAX_VISIBLE_ITEMS ); mLocateTable->setColumnWidth( 0, width * 0.5f ); mLocateTable->setColumnWidth( - 1, - width * 0.5f - mLocateTable->getVerticalScrollBar()->getPixelsSize().getWidth() - 4 ); - Vector2f pos( mLocateBarLayout->convertToWorldSpace( {0, 0} ) ); + 1, width * 0.5f - mLocateTable->getVerticalScrollBar()->getPixelsSize().getWidth() ); + Vector2f pos( mLocateInput->convertToWorldSpace( {0, 0} ) ); pos.y -= mLocateTable->getPixelsSize().getHeight(); mLocateTable->setPixelsPosition( pos ); } ); @@ -1221,7 +1221,7 @@ std::map App::getLocalKeybindings() { {{KEY_F6, KEYMOD_NONE}, "debug-draw-highlight-toggle"}, {{KEY_F7, KEYMOD_NONE}, "debug-draw-boxes-toggle"}, {{KEY_F8, KEYMOD_NONE}, "debug-draw-debug-data"}, - {{KEY_K, KEYMOD_CTRL}, "locate"}, + {{KEY_K, KEYMOD_CTRL}, "open-locatebar"}, }; } @@ -1253,11 +1253,11 @@ void App::onCodeEditorCreated( UICodeEditor* editor, TextDocument& doc ) { editor->addKeyBinds( getLocalKeybindings() ); editor->addUnlockedCommands( - {"fullscreen-toggle", "open-file", "console-toggle", "close-app"} ); + {"fullscreen-toggle", "open-file", "console-toggle", "close-app", "open-locatebar"} ); doc.setCommand( "save-doc", [&] { saveDoc(); } ); doc.setCommand( "save-as-doc", [&] { saveFileDialog(); } ); doc.setCommand( "find-replace", [&] { showFindView(); } ); - doc.setCommand( "locate", [&] { showLocateBar(); } ); + doc.setCommand( "open-locatebar", [&] { showLocateBar(); } ); doc.setCommand( "repeat-find", [&] { findNextText( mSearchState ); } ); doc.setCommand( "close-app", [&] { closeApp(); } ); doc.setCommand( "fullscreen-toggle", [&]() { @@ -1497,6 +1497,17 @@ void App::initProjectTreeView( const std::string& path ) { } } } ); + mProjectTreeView->addEventListener( Event::KeyDown, [&]( const Event* event ) { + const KeyEvent* keyEvent = reinterpret_cast( event ); + if ( mEditorSplitter->getCurEditor() ) { + std::string cmd = + mEditorSplitter->getCurEditor()->getKeyBindings().getCommandFromKeyBind( + {keyEvent->getKeyCode(), keyEvent->getMod()} ); + if ( !cmd.empty() && mEditorSplitter->getCurEditor()->isUnlockedCommand( cmd ) ) { + mEditorSplitter->getCurEditor()->getDocument().execute( cmd ); + } + } + } ); if ( !path.empty() && FileSystem::fileExists( path ) ) { if ( FileSystem::isDirectory( path ) ) {