diff --git a/bin/assets/ui/uitheme.eta b/bin/assets/ui/uitheme.eta index d04875c35..92ac1cfb4 100644 Binary files a/bin/assets/ui/uitheme.eta and b/bin/assets/ui/uitheme.eta differ diff --git a/bin/assets/ui/uitheme.png b/bin/assets/ui/uitheme.png index 43af5dbeb..ba6517ea3 100644 Binary files a/bin/assets/ui/uitheme.png and b/bin/assets/ui/uitheme.png differ diff --git a/bin/assets/ui/uitheme2x.eta b/bin/assets/ui/uitheme2x.eta index 1888d5eea..b5ce1613f 100644 Binary files a/bin/assets/ui/uitheme2x.eta and b/bin/assets/ui/uitheme2x.eta differ diff --git a/include/eepp/ui/uicheckbox.hpp b/include/eepp/ui/uicheckbox.hpp index d4dac9a17..014f9383a 100644 --- a/include/eepp/ui/uicheckbox.hpp +++ b/include/eepp/ui/uicheckbox.hpp @@ -50,7 +50,7 @@ class EE_API UICheckBox : public UITextBox { virtual Uint32 onMessage( const UIMessage * Msg ); - void doAftersetTheme(); + void doAfterSetTheme(); virtual void autoSize(); }; diff --git a/include/eepp/ui/uicontrol.hpp b/include/eepp/ui/uicontrol.hpp index 958fc74b6..b5258ddb0 100644 --- a/include/eepp/ui/uicontrol.hpp +++ b/include/eepp/ui/uicontrol.hpp @@ -223,14 +223,14 @@ class EE_API UIControl { virtual void setTheme( UITheme * Theme ); - void setThemeControl( UITheme * Theme, const std::string& ControlName ); + UIControl * setThemeControl( UITheme * Theme, const std::string& ControlName ); + + UIControl * setThemeControl( const std::string& ControlName ); void setThemeToChilds( UITheme * Theme ); UISkin * getSkin(); - void setSkinFromTheme( UITheme * Theme, const std::string& ControlName ); - virtual void setSkin( const UISkin& Skin ); UIControl * getFirstChild() const; @@ -373,7 +373,7 @@ class EE_API UIControl { virtual void drawChilds(); - virtual void doAftersetTheme(); + virtual void doAfterSetTheme(); virtual UIControl * overFind( const Vector2f& Point ); diff --git a/include/eepp/ui/uidropdownlist.hpp b/include/eepp/ui/uidropdownlist.hpp index 440d7cda9..fb5e5f72e 100644 --- a/include/eepp/ui/uidropdownlist.hpp +++ b/include/eepp/ui/uidropdownlist.hpp @@ -84,7 +84,7 @@ class EE_API UIDropDownList : public UITextInput { virtual void autoSizeControl(); - virtual void doAftersetTheme(); + virtual void doAfterSetTheme(); void setFriendControl( UIControl * friendCtrl ); diff --git a/include/eepp/ui/uimenu.hpp b/include/eepp/ui/uimenu.hpp index 6d4d7549c..0b722870f 100644 --- a/include/eepp/ui/uimenu.hpp +++ b/include/eepp/ui/uimenu.hpp @@ -168,7 +168,7 @@ class EE_API UIMenu : public UIComplexControl { UIMenuSubMenu * createSubMenu( const String& Text, SubTexture * Icon, UIMenu * SubMenu ); - void doAftersetTheme(); + void doAfterSetTheme(); bool checkControlSize( UIControl * Control, const bool& Resize = true ); diff --git a/include/eepp/ui/uipushbutton.hpp b/include/eepp/ui/uipushbutton.hpp index 06d692089..590ca545d 100644 --- a/include/eepp/ui/uipushbutton.hpp +++ b/include/eepp/ui/uipushbutton.hpp @@ -114,7 +114,7 @@ class EE_API UIPushButton : public UIComplexControl { virtual void onStateChange(); - virtual void doAftersetTheme(); + virtual void doAfterSetTheme(); virtual Uint32 onKeyDown( const UIEventKey& Event ); diff --git a/include/eepp/ui/uitabwidget.hpp b/include/eepp/ui/uitabwidget.hpp index 442747956..40a6a09f0 100644 --- a/include/eepp/ui/uitabwidget.hpp +++ b/include/eepp/ui/uitabwidget.hpp @@ -191,7 +191,7 @@ class EE_API UITabWidget : public UIComplexControl { UITab * mTabSelected; Uint32 mTabSelectedIndex; - void doAftersetTheme(); + void doAfterSetTheme(); UITab * createTab( const String& Text, UIControl * CtrlOwned, SubTexture * Icon ); diff --git a/include/eepp/ui/uitextbox.hpp b/include/eepp/ui/uitextbox.hpp index 0480c670b..502ed6473 100644 --- a/include/eepp/ui/uitextbox.hpp +++ b/include/eepp/ui/uitextbox.hpp @@ -84,7 +84,7 @@ class EE_API UITextBox : public UIComplexControl { const int& getNumLines() const; - const Vector2f& alignOffset() const; + const Vector2i & getAlignOffset() const; virtual void shrinkText( const Uint32& MaxWidth ); @@ -95,7 +95,8 @@ class EE_API UITextBox : public UIComplexControl { ColorA mFontColor; ColorA mFontShadowColor; ColorA mFontSelectionBackColor; - Vector2f mAlignOffset; + Vector2i mAlignOffset; + Vector2f mRealAlignOffset; Recti mPadding; Recti mRealPadding; Int32 mSelCurInit; diff --git a/src/eepp/gaming/mapeditor/mapeditor.cpp b/src/eepp/gaming/mapeditor/mapeditor.cpp index 0adb3cc88..98b8c560a 100644 --- a/src/eepp/gaming/mapeditor/mapeditor.cpp +++ b/src/eepp/gaming/mapeditor/mapeditor.cpp @@ -57,7 +57,7 @@ MapEditor::MapEditor( UIWindow * AttatchTo, const MapEditorCloseCb& callback ) : if ( NULL == mUIWindow ) { mUIWindow = UIManager::instance()->getMainControl(); - mUIWindow->setSkinFromTheme( mTheme, "winback" ); + mUIWindow->setThemeControl( mTheme, "winback" ); } if ( UIManager::instance()->getMainControl() == mUIWindow ) { diff --git a/src/eepp/ui/tools/textureatlaseditor.cpp b/src/eepp/ui/tools/textureatlaseditor.cpp index 0697f7574..1b0d3edc7 100644 --- a/src/eepp/ui/tools/textureatlaseditor.cpp +++ b/src/eepp/ui/tools/textureatlaseditor.cpp @@ -26,7 +26,7 @@ TextureAtlasEditor::TextureAtlasEditor( UIWindow * AttatchTo, const TGEditorClos if ( NULL == mUIWindow ) { mUIWindow = UIManager::instance()->getMainControl(); - mUIWindow->setSkinFromTheme( mTheme, "winback" ); + mUIWindow->setThemeControl( mTheme, "winback" ); } if ( UIManager::instance()->getMainControl() == mUIWindow ) { diff --git a/src/eepp/ui/uicheckbox.cpp b/src/eepp/ui/uicheckbox.cpp index e808eb316..54b96a03d 100644 --- a/src/eepp/ui/uicheckbox.cpp +++ b/src/eepp/ui/uicheckbox.cpp @@ -71,10 +71,10 @@ void UICheckBox::setTheme( UITheme * Theme ) { mActiveButton->setThemeControl ( Theme, "checkbox_active" ); mInactiveButton->setThemeControl( Theme, "checkbox_inactive" ); - doAftersetTheme(); + doAfterSetTheme(); } -void UICheckBox::doAftersetTheme() { +void UICheckBox::doAfterSetTheme() { UISkin * tSkin = mActiveButton->getSkin(); if ( tSkin ) { diff --git a/src/eepp/ui/uicombobox.cpp b/src/eepp/ui/uicombobox.cpp index 6e0c8c752..9d8d652c7 100644 --- a/src/eepp/ui/uicombobox.cpp +++ b/src/eepp/ui/uicombobox.cpp @@ -50,7 +50,7 @@ void UIComboBox::setTheme( UITheme * Theme ) { } mDropDownList->setThemeControl( Theme, "combobox" ); - mDropDownList->doAftersetTheme(); + mDropDownList->doAfterSetTheme(); mButton->setThemeControl( Theme, "combobox_button" ); diff --git a/src/eepp/ui/uicontrol.cpp b/src/eepp/ui/uicontrol.cpp index 4c8ccfa77..8fd7a8634 100644 --- a/src/eepp/ui/uicontrol.cpp +++ b/src/eepp/ui/uicontrol.cpp @@ -1217,7 +1217,11 @@ void UIControl::safeDeleteSkinState() { eeSAFE_DELETE( mSkinState ); } -void UIControl::setThemeControl( UITheme * Theme, const std::string& ControlName ) { +UIControl * UIControl::setThemeControl( const std::string& ControlName ) { + return setThemeControl( UIThemeManager::instance()->getDefaultTheme(), ControlName ); +} + +UIControl * UIControl::setThemeControl( UITheme * Theme, const std::string& ControlName ) { if ( NULL != Theme ) { UISkin * tSkin = Theme->getByName( Theme->getAbbr() + "_" + ControlName ); @@ -1232,12 +1236,12 @@ void UIControl::setThemeControl( UITheme * Theme, const std::string& ControlName mSkinState = eeNew( UISkinState, ( tSkin ) ); mSkinState->setState( InitialState ); + + doAfterSetTheme(); } } -} -void UIControl::setSkinFromTheme( UITheme * Theme, const std::string& ControlName ) { - setThemeControl( Theme, ControlName ); + return this; } void UIControl::setSkin( const UISkin& Skin ) { @@ -1249,7 +1253,7 @@ void UIControl::setSkin( const UISkin& Skin ) { mSkinState = eeNew( UISkinState, ( SkinCopy ) ); - doAftersetTheme(); + doAfterSetTheme(); } void UIControl::onStateChange() { @@ -1459,7 +1463,7 @@ UIControl * UIControl::getNextComplexControl() { return UIManager::instance()->getMainControl(); } -void UIControl::doAftersetTheme() { +void UIControl::doAfterSetTheme() { } void UIControl::worldToControl( Vector2i& pos ) const { diff --git a/src/eepp/ui/uidropdownlist.cpp b/src/eepp/ui/uidropdownlist.cpp index c04c51945..e8abe76ce 100644 --- a/src/eepp/ui/uidropdownlist.cpp +++ b/src/eepp/ui/uidropdownlist.cpp @@ -88,7 +88,7 @@ bool UIDropDownList::isType( const Uint32& type ) const { void UIDropDownList::setTheme( UITheme * Theme ) { UIControl::setThemeControl( Theme, "dropdownlist" ); - doAftersetTheme(); + doAfterSetTheme(); } void UIDropDownList::onSizeChange() { @@ -103,7 +103,7 @@ void UIDropDownList::autoSizeControl() { } } -void UIDropDownList::doAftersetTheme() { +void UIDropDownList::doAfterSetTheme() { autoPadding(); autoSizeControl(); diff --git a/src/eepp/ui/uimenu.cpp b/src/eepp/ui/uimenu.cpp index 86e855cc8..a222f4aec 100644 --- a/src/eepp/ui/uimenu.cpp +++ b/src/eepp/ui/uimenu.cpp @@ -80,10 +80,10 @@ bool UIMenu::isType( const Uint32& type ) const { void UIMenu::setTheme( UITheme * Theme ) { UIControl::setThemeControl( Theme, "menu" ); - doAftersetTheme(); + doAfterSetTheme(); } -void UIMenu::doAftersetTheme() { +void UIMenu::doAfterSetTheme() { autoPadding(); onSizeChange(); diff --git a/src/eepp/ui/uimenucheckbox.cpp b/src/eepp/ui/uimenucheckbox.cpp index 7f262d2de..47360cecb 100644 --- a/src/eepp/ui/uimenucheckbox.cpp +++ b/src/eepp/ui/uimenucheckbox.cpp @@ -40,7 +40,7 @@ void UIMenuCheckBox::setTheme( UITheme * Theme ) { setActive( mActive ); - doAftersetTheme(); + doAfterSetTheme(); } const bool& UIMenuCheckBox::isActive() const { diff --git a/src/eepp/ui/uimenuitem.cpp b/src/eepp/ui/uimenuitem.cpp index 3845b33b6..8cb33012e 100644 --- a/src/eepp/ui/uimenuitem.cpp +++ b/src/eepp/ui/uimenuitem.cpp @@ -28,7 +28,7 @@ bool UIMenuItem::isType( const Uint32& type ) const { void UIMenuItem::setTheme( UITheme * Theme ) { UIControl::setThemeControl( Theme, "menuitem" ); - doAftersetTheme(); + doAfterSetTheme(); } Uint32 UIMenuItem::onMouseEnter( const Vector2i &Pos, const Uint32 Flags ) { diff --git a/src/eepp/ui/uipopupmenu.cpp b/src/eepp/ui/uipopupmenu.cpp index 1573a7201..7acdad8e2 100644 --- a/src/eepp/ui/uipopupmenu.cpp +++ b/src/eepp/ui/uipopupmenu.cpp @@ -33,7 +33,7 @@ bool UIPopUpMenu::isType( const Uint32& type ) const { void UIPopUpMenu::setTheme( UITheme * Theme ) { UIControl::setThemeControl( Theme, "popupmenu" ); - doAftersetTheme(); + doAfterSetTheme(); } bool UIPopUpMenu::show() { diff --git a/src/eepp/ui/uipushbutton.cpp b/src/eepp/ui/uipushbutton.cpp index aa9cb10e2..bd5c7a3d9 100644 --- a/src/eepp/ui/uipushbutton.cpp +++ b/src/eepp/ui/uipushbutton.cpp @@ -1,4 +1,5 @@ #include +#include namespace EE { namespace UI { @@ -98,6 +99,15 @@ void UIPushButton::onSizeChange() { setInternalHeight( getSkinSize().getHeight() ); } + if ( ( mFlags & UI_AUTO_SIZE ) ) { + Int32 txtW = NULL != mTextBox ? PixelDensity::pxToDpI( mTextBox->getTextCache()->getTextWidth() ) : 0; + Int32 minSize = txtW + ( NULL != mIcon ? mIcon->getSize().getWidth() : 0 ) + getSkinSize().getWidth(); + + if ( minSize > mSize.getWidth() ) { + setInternalWidth( minSize ); + } + } + if ( NULL != mTextBox ) { mTextBox->setSize( mSize ); mTextBox->setPosition( 0, 0 ); @@ -114,11 +124,15 @@ void UIPushButton::onSizeChange() { break; case UI_HALIGN_CENTER: if ( NULL != mIcon->getSubTexture() ) { - if ( mIcon->getPosition().x + mIcon->getSize().getWidth() >= mTextBox->alignOffset().x ) { - mTextBox->setPosition( mIcon->getPosition().x + mIcon->getSize().getWidth() + 1 - mTextBox->alignOffset().x, - mTextBox->getPosition().y ); + Uint32 iconPos = mIcon->getPosition().x + mIcon->getSize().getWidth(); + Uint32 txtOff = mTextBox->getPosition().x + mTextBox->getAlignOffset().x; - mTextBox->setSize( mSize.getWidth() - mIcon->getPosition().x - mIcon->getSize().getWidth() - 1, mTextBox->getSize().getHeight() ); + if ( iconPos >= txtOff) { + Int32 px = PixelDensity::dpToPxI(1); + + mTextBox->setPosition( iconPos + px, mTextBox->getPosition().y ); + + mTextBox->setSize( mSize.getWidth() - mIcon->getPosition().x - mIcon->getSize().getWidth() - px, mTextBox->getSize().getHeight() ); } } @@ -134,10 +148,10 @@ void UIPushButton::onSizeChange() { void UIPushButton::setTheme( UITheme * Theme ) { UIControl::setThemeControl( Theme, "button" ); - doAftersetTheme(); + doAfterSetTheme(); } -void UIPushButton::doAftersetTheme() { +void UIPushButton::doAfterSetTheme() { if ( NULL != mTextBox && NULL == mTextBox->getFont() && NULL != mSkinState && NULL != mSkinState->getSkin() && NULL != mSkinState->getSkin()->getTheme() && NULL != mSkinState->getSkin()->getTheme()->getFont() ) mTextBox->setFont( mSkinState->getSkin()->getTheme()->getFont() ); diff --git a/src/eepp/ui/uitab.cpp b/src/eepp/ui/uitab.cpp index 2aeb3ae3c..64f0dd039 100644 --- a/src/eepp/ui/uitab.cpp +++ b/src/eepp/ui/uitab.cpp @@ -58,7 +58,7 @@ void UITab::setTheme( UITheme * Theme ) { UIControl::setThemeControl( Theme, tabPos ); - doAftersetTheme(); + doAfterSetTheme(); } Uint32 UITab::onMouseClick( const Vector2i &Pos, const Uint32 Flags ) { @@ -123,7 +123,7 @@ void UITab::setText( const String &text ) { void UITab::autoSize() { if ( mFlags & UI_AUTO_SIZE ) { - Uint32 w = PixelDensity::pxToDpI( mTextBox->getTextWidth() ) + getSkinSize().getWidth(); + Uint32 w = PixelDensity::pxToDpI( mTextBox->getTextWidth() ) + mIconSpace + ( NULL != mIcon ? mIcon->getSize().getWidth() : 0 ) + getSkinSize().getWidth(); UITabWidget * tTabW = getTabWidget(); diff --git a/src/eepp/ui/uitabwidget.cpp b/src/eepp/ui/uitabwidget.cpp index 4543331c9..2950faab1 100644 --- a/src/eepp/ui/uitabwidget.cpp +++ b/src/eepp/ui/uitabwidget.cpp @@ -59,17 +59,19 @@ UITabWidget::UITabWidget() : mFontSelectedColor(), mTabSeparation( 0 ), mMaxTextLength( 32 ), - mTabWidgetHeight( 64 ), + mTabWidgetHeight( 0 ), mMinTabWidth( 32 ), - mMaxTabWidth( 210 ), + mMaxTabWidth( 0xFFFFFF ), mTabsClosable( false ), - mSpecialBorderTabs( false ), - mDrawLineBelowTabs( false ), - mLineBelowTabsColor( ColorA::Black ), - mLineBewowTabsYOffset( 0 ), + mSpecialBorderTabs( true ), + mDrawLineBelowTabs( true ), + mLineBelowTabsColor( ColorA(0,0,0,255) ), + mLineBewowTabsYOffset( -1 ), mTabSelected( NULL ), mTabSelectedIndex( eeINDEX_NOT_FOUND ) { + setHorizontalAlign( UI_HALIGN_CENTER ); + UITheme * Theme = UIThemeManager::instance()->getDefaultTheme(); if ( NULL != Theme ) { @@ -127,10 +129,10 @@ void UITabWidget::setTheme( UITheme * Theme ) { } } - doAftersetTheme(); + doAfterSetTheme(); } -void UITabWidget::doAftersetTheme() { +void UITabWidget::doAfterSetTheme() { onSizeChange(); } @@ -141,26 +143,22 @@ void UITabWidget::seContainerSize() { } void UITabWidget::draw() { + UIComplexControl::draw(); + if ( mDrawLineBelowTabs ) { bool smooth = GLi->isLineSmooth(); if ( smooth ) GLi->lineSmooth( false ); Primitives P; - Vector2i p1( mRealPos.x, mRealPos.y + mTabContainer->getRealSize().getHeight() + mLineBewowTabsYOffset ); - Vector2i p2( mRealPos.x + mTabContainer->getRealPosition().x, p1.y ); + Vector2i p1( mScreenPos.x, mScreenPos.y + mTabContainer->getRealSize().getHeight() + mLineBewowTabsYOffset ); + Vector2i p2( mScreenPos.x + mTabContainer->getRealPosition().x, p1.y ); - controlToScreen( p1 ); - controlToScreen( p2 ); - - P.setLineWidth( 1 ); + P.setLineWidth( PixelDensity::dpToPx( 1 ) ); P.setColor( mLineBelowTabsColor ); P.drawLine( Line2f( Vector2f( p1.x, p1.y ), Vector2f( p2.x, p2.y ) ) ); - Vector2i p3( mRealPos.x + mTabContainer->getRealPosition().x + mTabContainer->getRealSize().getWidth(), mRealPos.y + mTabContainer->getRealSize().getHeight() + mLineBewowTabsYOffset ); - Vector2i p4( mRealPos.x + mRealSize.getWidth(), p3.y ); - - controlToScreen( p3 ); - controlToScreen( p4 ); + Vector2i p3( mScreenPos.x + mTabContainer->getRealPosition().x + mTabContainer->getRealSize().getWidth(), mScreenPos.y + mTabContainer->getRealSize().getHeight() + mLineBewowTabsYOffset ); + Vector2i p4( mScreenPos.x + mRealSize.getWidth(), p3.y ); P.drawLine( Line2f( Vector2f( p3.x, p3.y ), Vector2f( p4.x, p4.y ) ) ); diff --git a/src/eepp/ui/uitextbox.cpp b/src/eepp/ui/uitextbox.cpp index f4697a593..a0db4371b 100644 --- a/src/eepp/ui/uitextbox.cpp +++ b/src/eepp/ui/uitextbox.cpp @@ -13,7 +13,7 @@ UITextBox::UITextBox( const UITextBox::CreateParams& Params ) : mFontColor( Params.FontColor ), mFontShadowColor( Params.FontShadowColor ), mFontSelectionBackColor( Params.FontSelectionBackColor ), - mAlignOffset( 0.f, 0.f ), + mRealAlignOffset( 0.f, 0.f ), mSelCurInit( -1 ), mSelCurEnd( -1 ) { @@ -38,7 +38,7 @@ UITextBox::UITextBox() : mFontColor(), mFontShadowColor(), mFontSelectionBackColor(), - mAlignOffset( 0.f, 0.f ), + mRealAlignOffset( 0.f, 0.f ), mSelCurInit( -1 ), mSelCurEnd( -1 ) { @@ -92,7 +92,7 @@ void UITextBox::draw() { } mTextCache->setFlags( getFlags() ); - mTextCache->draw( (Float)mScreenPos.x + mAlignOffset.x + (Float)mRealPadding.Left, (Float)mScreenPos.y + mAlignOffset.y + (Float)mRealPadding.Top, Vector2f::One, 0.f, getBlendMode() ); + mTextCache->draw( (Float)mScreenPos.x + mRealAlignOffset.x + (Float)mRealPadding.Left, (Float)mScreenPos.y + mRealAlignOffset.y + (Float)mRealPadding.Top, Vector2f::One, 0.f, getBlendMode() ); if ( mFlags & UI_CLIP_ENABLE ) { UIManager::instance()->clipSmartDisable( this ); @@ -195,27 +195,29 @@ void UITextBox::autoSize() { void UITextBox::autoAlign() { switch ( fontHAlignGet( getFlags() ) ) { case UI_HALIGN_CENTER: - mAlignOffset.x = (Float)( (Int32)( mRealSize.x - mTextCache->getTextWidth() ) / 2 ); + mRealAlignOffset.x = (Float)( (Int32)( mRealSize.x - mTextCache->getTextWidth() ) / 2 ); break; case UI_HALIGN_RIGHT: - mAlignOffset.x = ( (Float)mRealSize.x - (Float)mTextCache->getTextWidth() ); + mRealAlignOffset.x = ( (Float)mRealSize.x - (Float)mTextCache->getTextWidth() ); break; case UI_HALIGN_LEFT: - mAlignOffset.x = 0.f; + mRealAlignOffset.x = 0.f; break; } switch ( fontVAlignGet( getFlags() ) ) { case UI_VALIGN_CENTER: - mAlignOffset.y = (Float)( ( (Int32)( mRealSize.y - mTextCache->getTextHeight() ) ) / 2 ) - 1; + mRealAlignOffset.y = (Float)( ( (Int32)( mRealSize.y - mTextCache->getTextHeight() ) ) / 2 ) - 1; break; case UI_VALIGN_BOTTOM: - mAlignOffset.y = ( (Float)mRealSize.y - (Float)mTextCache->getTextHeight() ); + mRealAlignOffset.y = ( (Float)mRealSize.y - (Float)mTextCache->getTextHeight() ); break; case UI_VALIGN_TOP: - mAlignOffset.y = 0.f; + mRealAlignOffset.y = 0.f; break; } + + mAlignOffset = PixelDensity::pxToDpI( mRealAlignOffset ); } Uint32 UITextBox::onFocusLoss() { @@ -276,7 +278,7 @@ const int& UITextBox::getNumLines() const { return mTextCache->getNumLines(); } -const Vector2f& UITextBox::alignOffset() const { +const Vector2i& UITextBox::getAlignOffset() const { return mAlignOffset; } @@ -320,7 +322,7 @@ Uint32 UITextBox::onMouseDown( const Vector2i& Pos, const Uint32 Flags ) { if ( isTextSelectionEnabled() && ( Flags & EE_BUTTON_LMASK ) ) { Vector2i controlPos( Pos ); worldToControl( controlPos ); - controlPos = PixelDensity::dpToPxI( controlPos ) - Vector2i( (Int32)mAlignOffset.x, (Int32)mAlignOffset.y ); + controlPos = PixelDensity::dpToPxI( controlPos ) - Vector2i( (Int32)mRealAlignOffset.x, (Int32)mRealAlignOffset.y ); Int32 curPos = mTextCache->getFont()->findClosestCursorPosFromPoint( mTextCache->getText(), controlPos ); @@ -366,10 +368,10 @@ void UITextBox::drawSelection( TextCache * textCache ) { lastEnd = end; } - P.drawRectangle( Rectf( mScreenPos.x + initPos.x + mAlignOffset.x + mRealPadding.Left, - mScreenPos.y + initPos.y - textCache->getFont()->getFontHeight() + mAlignOffset.y + mRealPadding.Top, - mScreenPos.x + endPos.x + mAlignOffset.x + mRealPadding.Left, - mScreenPos.y + endPos.y + mAlignOffset.y + mRealPadding.Top ) + P.drawRectangle( Rectf( mScreenPos.x + initPos.x + mRealAlignOffset.x + mRealPadding.Left, + mScreenPos.y + initPos.y - textCache->getFont()->getFontHeight() + mRealAlignOffset.y + mRealPadding.Top, + mScreenPos.x + endPos.x + mRealAlignOffset.x + mRealPadding.Left, + mScreenPos.y + endPos.y + mRealAlignOffset.y + mRealPadding.Top ) ); } while ( end != lastEnd ); } diff --git a/src/eepp/ui/uitextinput.cpp b/src/eepp/ui/uitextinput.cpp index 77f6d013f..cd8f3cdda 100644 --- a/src/eepp/ui/uitextinput.cpp +++ b/src/eepp/ui/uitextinput.cpp @@ -60,13 +60,13 @@ void UITextInput::update() { UITextBox::update(); if ( mTextBuffer.changedSinceLastUpdate() ) { - Vector2f offSet = mAlignOffset; + Vector2f offSet = mRealAlignOffset; UITextBox::setText( mTextBuffer.getBuffer() ); updateText(); - mAlignOffset = offSet; + mRealAlignOffset = offSet; resetWaitCursor(); @@ -105,8 +105,8 @@ void UITextInput::drawWaitingCursor() { Primitives P; P.setColor( mFontColor ); - Float CurPosX = mScreenPos.x + mAlignOffset.x + mCurPos.x + PixelDensity::dpToPxI( 1.f ) + mRealPadding.Left; - Float CurPosY = mScreenPos.y + mAlignOffset.y + mCurPos.y + mRealPadding.Top; + Float CurPosX = mScreenPos.x + mRealAlignOffset.x + mCurPos.x + PixelDensity::dpToPxI( 1.f ) + mRealPadding.Left; + Float CurPosY = mScreenPos.y + mRealAlignOffset.y + mCurPos.y + mRealPadding.Top; if ( CurPosX > (Float)mScreenPos.x + (Float)mRealSize.x ) CurPosX = (Float)mScreenPos.x + (Float)mRealSize.x; @@ -173,16 +173,16 @@ void UITextInput::alignFix() { mTextCache->getFont()->setText( mTextBuffer.getBuffer().substr( NLPos, mTextBuffer.getCursorPos() - NLPos ) ); Float tW = mTextCache->getFont()->getTextWidth(); - Float tX = mAlignOffset.x + tW; + Float tX = mRealAlignOffset.x + tW; mCurPos.x = tW; mCurPos.y = (Float)LineNum * (Float)mTextCache->getFont()->getFontHeight(); if ( !mTextBuffer.setSupportNewLine() ) { if ( tX < 0.f ) - mAlignOffset.x = -( mAlignOffset.x + ( tW - mAlignOffset.x ) ); + mRealAlignOffset.x = -( mRealAlignOffset.x + ( tW - mRealAlignOffset.x ) ); else if ( tX > mRealSize.getWidth() - mRealPadding.Left - mRealPadding.Right ) - mAlignOffset.x = mRealSize.getWidth() - mRealPadding.Left - mRealPadding.Right - ( mAlignOffset.x + ( tW - mAlignOffset.x ) ); + mRealAlignOffset.x = mRealSize.getWidth() - mRealPadding.Left - mRealPadding.Right - ( mRealAlignOffset.x + ( tW - mRealAlignOffset.x ) ); } } } @@ -250,7 +250,7 @@ Uint32 UITextInput::onMouseClick( const Vector2i& Pos, const Uint32 Flags ) { if ( Flags & EE_BUTTON_LMASK ) { Vector2i controlPos( Pos ); worldToControl( controlPos ); - controlPos = PixelDensity::dpToPxI( controlPos ) - Vector2i( (Int32)mAlignOffset.x, (Int32)mAlignOffset.y ); + controlPos = PixelDensity::dpToPxI( controlPos ) - Vector2i( (Int32)mRealAlignOffset.x, (Int32)mRealAlignOffset.y ); Int32 curPos = mTextCache->getFont()->findClosestCursorPosFromPoint( mTextCache->getText(), controlPos ); diff --git a/src/eepp/ui/uitextinputpassword.cpp b/src/eepp/ui/uitextinputpassword.cpp index 6c6fcc208..8a45e3631 100644 --- a/src/eepp/ui/uitextinputpassword.cpp +++ b/src/eepp/ui/uitextinputpassword.cpp @@ -46,7 +46,7 @@ void UITextInputPassword::draw() { } mPassCache->setFlags( getFlags() ); - mPassCache->draw( (Float)mScreenPos.x + mAlignOffset.x + (Float)mRealPadding.Left, (Float)mScreenPos.y + mAlignOffset.y + (Float)mRealPadding.Top, Vector2f::One, 0.f, getBlendMode() ); + mPassCache->draw( (Float)mScreenPos.x + mRealAlignOffset.x + (Float)mRealPadding.Left, (Float)mScreenPos.y + mRealAlignOffset.y + (Float)mRealPadding.Top, Vector2f::One, 0.f, getBlendMode() ); if ( mFlags & UI_CLIP_ENABLE ) { UIManager::instance()->clipSmartDisable( this ); @@ -71,16 +71,16 @@ void UITextInputPassword::alignFix() { mPassCache->getFont()->setText( pasStr ); Float tW = mPassCache->getFont()->getTextWidth(); - Float tX = mAlignOffset.x + tW; + Float tX = mRealAlignOffset.x + tW; mCurPos.x = tW; mCurPos.y = (Float)LineNum * (Float)mPassCache->getFont()->getFontHeight(); if ( !mTextBuffer.setSupportNewLine() ) { if ( tX < 0.f ) - mAlignOffset.x = -( mAlignOffset.x + ( tW - mAlignOffset.x ) ); + mRealAlignOffset.x = -( mRealAlignOffset.x + ( tW - mRealAlignOffset.x ) ); else if ( tX > mRealSize.getWidth() - mRealPadding.Left - mRealPadding.Right ) - mAlignOffset.x = mRealSize.getWidth() - mRealPadding.Left - mRealPadding.Right - ( mAlignOffset.x + ( tW - mAlignOffset.x ) ); + mRealAlignOffset.x = mRealSize.getWidth() - mRealPadding.Left - mRealPadding.Right - ( mRealAlignOffset.x + ( tW - mRealAlignOffset.x ) ); } } } @@ -88,25 +88,25 @@ void UITextInputPassword::alignFix() { void UITextInputPassword::autoAlign() { switch ( fontHAlignGet( getFlags() ) ) { case UI_HALIGN_CENTER: - mAlignOffset.x = (Float)( (Int32)( mRealSize.x - mPassCache->getTextWidth() ) / 2 ); + mRealAlignOffset.x = (Float)( (Int32)( mRealSize.x - mPassCache->getTextWidth() ) / 2 ); break; case UI_HALIGN_RIGHT: - mAlignOffset.x = ( (Float)mRealSize.x - (Float)mPassCache->getTextWidth() ); + mRealAlignOffset.x = ( (Float)mRealSize.x - (Float)mPassCache->getTextWidth() ); break; case UI_HALIGN_LEFT: - mAlignOffset.x = 0.f; + mRealAlignOffset.x = 0.f; break; } switch ( fontVAlignGet( getFlags() ) ) { case UI_VALIGN_CENTER: - mAlignOffset.y = (Float)( ( (Int32)( mRealSize.y - mPassCache->getTextHeight() ) ) / 2 ) - 1; + mRealAlignOffset.y = (Float)( ( (Int32)( mRealSize.y - mPassCache->getTextHeight() ) ) / 2 ) - 1; break; case UI_VALIGN_BOTTOM: - mAlignOffset.y = ( (Float)mRealSize.y - (Float)mPassCache->getTextHeight() ); + mRealAlignOffset.y = ( (Float)mRealSize.y - (Float)mPassCache->getTextHeight() ); break; case UI_VALIGN_TOP: - mAlignOffset.y = 0.f; + mRealAlignOffset.y = 0.f; break; } } diff --git a/src/eepp/ui/uiwindow.cpp b/src/eepp/ui/uiwindow.cpp index a943bc09b..5ab042bff 100644 --- a/src/eepp/ui/uiwindow.cpp +++ b/src/eepp/ui/uiwindow.cpp @@ -749,27 +749,27 @@ void UIWindow::draw() { ColorA BeginC( 0, 0, 0, 25 * ( getAlpha() / (Float)255 ) ); ColorA EndC( 0, 0, 0, 0 ); - Float SSize = 16.f; + Float SSize = PixelDensity::dpToPx( 16.f ); Vector2i ShadowPos = mScreenPos + Vector2i( 0, 16 ); - P.drawRectangle( Rectf( Vector2f( ShadowPos.x, ShadowPos.y ), Sizef( mSize.getWidth(), mSize.getHeight() ) ), BeginC, BeginC, BeginC, BeginC ); + P.drawRectangle( Rectf( Vector2f( ShadowPos.x, ShadowPos.y ), Sizef( mRealSize.getWidth(), mRealSize.getHeight() ) ), BeginC, BeginC, BeginC, BeginC ); - P.drawRectangle( Rectf( Vector2f( ShadowPos.x, ShadowPos.y - SSize ), Sizef( mSize.getWidth(), SSize ) ), EndC, BeginC, BeginC, EndC ); + P.drawRectangle( Rectf( Vector2f( ShadowPos.x, ShadowPos.y - SSize ), Sizef( mRealSize.getWidth(), SSize ) ), EndC, BeginC, BeginC, EndC ); - P.drawRectangle( Rectf( Vector2f( ShadowPos.x - SSize, ShadowPos.y ), Sizef( SSize, mSize.getHeight() ) ), EndC, EndC, BeginC, BeginC ); + P.drawRectangle( Rectf( Vector2f( ShadowPos.x - SSize, ShadowPos.y ), Sizef( SSize, mRealSize.getHeight() ) ), EndC, EndC, BeginC, BeginC ); - P.drawRectangle( Rectf( Vector2f( ShadowPos.x + mSize.getWidth(), ShadowPos.y ), Sizef( SSize, mSize.getHeight() ) ), BeginC, BeginC, EndC, EndC ); + P.drawRectangle( Rectf( Vector2f( ShadowPos.x + mRealSize.getWidth(), ShadowPos.y ), Sizef( SSize, mRealSize.getHeight() ) ), BeginC, BeginC, EndC, EndC ); - P.drawRectangle( Rectf( Vector2f( ShadowPos.x, ShadowPos.y + mSize.getHeight() ), Sizef( mSize.getWidth(), SSize ) ), BeginC, EndC, EndC, BeginC ); + P.drawRectangle( Rectf( Vector2f( ShadowPos.x, ShadowPos.y + mRealSize.getHeight() ), Sizef( mRealSize.getWidth(), SSize ) ), BeginC, EndC, EndC, BeginC ); - P.drawTriangle( Triangle2f( Vector2f( ShadowPos.x + mSize.getWidth(), ShadowPos.y ), Vector2f( ShadowPos.x + mSize.getWidth(), ShadowPos.y - SSize ), Vector2f( ShadowPos.x + mSize.getWidth() + SSize, ShadowPos.y ) ), BeginC, EndC, EndC ); + P.drawTriangle( Triangle2f( Vector2f( ShadowPos.x + mRealSize.getWidth(), ShadowPos.y ), Vector2f( ShadowPos.x + mRealSize.getWidth(), ShadowPos.y - SSize ), Vector2f( ShadowPos.x + mRealSize.getWidth() + SSize, ShadowPos.y ) ), BeginC, EndC, EndC ); P.drawTriangle( Triangle2f( Vector2f( ShadowPos.x, ShadowPos.y ), Vector2f( ShadowPos.x, ShadowPos.y - SSize ), Vector2f( ShadowPos.x - SSize, ShadowPos.y ) ), BeginC, EndC, EndC ); - P.drawTriangle( Triangle2f( Vector2f( ShadowPos.x + mSize.getWidth(), ShadowPos.y + mSize.getHeight() ), Vector2f( ShadowPos.x + mSize.getWidth(), ShadowPos.y + mSize.getHeight() + SSize ), Vector2f( ShadowPos.x + mSize.getWidth() + SSize, ShadowPos.y + mSize.getHeight() ) ), BeginC, EndC, EndC ); + P.drawTriangle( Triangle2f( Vector2f( ShadowPos.x + mRealSize.getWidth(), ShadowPos.y + mRealSize.getHeight() ), Vector2f( ShadowPos.x + mRealSize.getWidth(), ShadowPos.y + mRealSize.getHeight() + SSize ), Vector2f( ShadowPos.x + mRealSize.getWidth() + SSize, ShadowPos.y + mRealSize.getHeight() ) ), BeginC, EndC, EndC ); - P.drawTriangle( Triangle2f( Vector2f( ShadowPos.x, ShadowPos.y + mSize.getHeight() ), Vector2f( ShadowPos.x - SSize, ShadowPos.y + mSize.getHeight() ), Vector2f( ShadowPos.x, ShadowPos.y + mSize.getHeight() + SSize ) ), BeginC, EndC, EndC ); + P.drawTriangle( Triangle2f( Vector2f( ShadowPos.x, ShadowPos.y + mRealSize.getHeight() ), Vector2f( ShadowPos.x - SSize, ShadowPos.y + mRealSize.getHeight() ), Vector2f( ShadowPos.x, ShadowPos.y + mRealSize.getHeight() + SSize ) ), BeginC, EndC, EndC ); P.setForceDraw( true ); } diff --git a/src/test/eetest.cpp b/src/test/eetest.cpp index 4a1da07f2..e327c9b35 100644 --- a/src/test/eetest.cpp +++ b/src/test/eetest.cpp @@ -269,7 +269,7 @@ void EETest::createUI() { mThemeName = "uitheme"; - if ( PixelDensity::getPixelDensity() == 2 ) { + if ( PixelDensity::getPixelDensity() >= 2 ) { mThemeName += "2x"; } @@ -703,7 +703,7 @@ void EETest::createNewUI() { } UIWindow * MenuCont = eeNew( UIWindow, () ); - MenuCont->setPosition( 350, 400 )->setSize( 200, 125 ); + MenuCont->setPosition( 350, 390 )->setSize( 200, 115 ); UIWinMenu * WinMenu = eeNew( UIWinMenu, () ); WinMenu->setParent( MenuCont->getContainer() ); @@ -722,14 +722,15 @@ void EETest::createNewUI() { WinMenu->addMenuButton( "File", PopMenu ); WinMenu->addMenuButton( "Edit", PopMenu2 ); - /**/ UITabWidget * TabWidget = eeNew( UITabWidget, () ); - TabWidget->setPosition( 350, 550 )->setSize( 200, 100 ); + TabWidget->setPosition( 350, 530 )->setSize( 200, 64 ); - TabWidget->add( "Tab 1", eeNew( UIControl, () ) ); - TabWidget->add( "Tab 2", eeNew( UIControl, () ) ); - TabWidget->add( "Tab 3", eeNew( UIControl, () ) ); + TabWidget->add( "Tab 1", (eeNew( UIComplexControl, () ))->setThemeControl( "winback" ), mTheme->getIconByName( "ok" ) ); + TabWidget->add( "Tab 2", (eeNew( UIComplexControl, () ))->setThemeControl( "winback" ), mTheme->getIconByName( "go-up" ) ); + TabWidget->add( "Tab 3", (eeNew( UIComplexControl, () ))->setThemeControl( "winback" ), mTheme->getIconByName( "add" ) ); + + /**/ } void EETest::createMapEditor() {