Started working on removing the CreateParams and supporting different pixel densities.

--HG--
branch : dev
This commit is contained in:
Martí­n Lucas Golini
2017-02-21 23:18:15 -03:00
parent c9dbf5f6e5
commit cab7e5cda1
40 changed files with 562 additions and 99 deletions

View File

@@ -106,31 +106,49 @@ tRECT<T>& operator -=(tRECT<T>& R, T X) {
return R;
}
template <typename T>
tRECT<T> operator *(const tRECT<T>& R, T X) {
return tRECT<T>(R.Left * X, R.Top * X, R.Right * X, R.Bottom * X);
template <typename T, typename Y>
tRECT<T> operator *(const tRECT<T>& R, Y X) {
return tRECT<T>((T)((Y)R.Left * X), (T)((Y)R.Top * X), (T)((Y)R.Right * X), (T)((Y)R.Bottom * X));
}
template <typename T>
tRECT<T>& operator *=(tRECT<T>& R, T X) {
R.Left *= X;
R.Top *= X;
R.Right *= X;
R.Bottom *= X;
template <typename T, typename Y>
tRECT<T>& operator *=(tRECT<T>& R, Y X) {
R.Left = (T)((Y)R.Left * X );
R.Top = (T)((Y)R.Top * X );
R.Right = (T)((Y)R.Right * X );
R.Bottom = (T)((Y)R.Bottom * X );
return R;
}
template <typename T>
tRECT<T> operator /(const tRECT<T>& R, T X) {
return tRECT<T>(R.Left / X, R.Top / X, R.Right / X, R.Bottom / X);
template <typename T, typename Y>
tRECT<T>& operator *(tRECT<T>& R, Y X) {
R.Left = (T)((Y)R.Left * X );
R.Top = (T)((Y)R.Top * X );
R.Right = (T)((Y)R.Right * X );
R.Bottom = (T)((Y)R.Bottom * X );
return R;
}
template <typename T>
tRECT<T>& operator /=(tRECT<T>& R, T X) {
R.Left /= X;
R.Top /= X;
R.Right /= X;
R.Bottom /= X;
template <typename T, typename Y>
tRECT<T> operator /(const tRECT<T>& R, Y X) {
return tRECT<T>((T)((Y)R.Left / X), (T)((Y)R.Top / X), (T)((Y)R.Right / X), (T)((Y)R.Bottom / X));
}
template <typename T, typename Y>
tRECT<T>& operator /=(tRECT<T>& R, Y X) {
R.Left = (T)((Y)R.Left / X );
R.Top = (T)((Y)R.Top / X );
R.Right = (T)((Y)R.Right / X );
R.Bottom = (T)((Y)R.Bottom / X );
return R;
}
template <typename T, typename Y>
tRECT<T>& operator /(tRECT<T>& R, Y X) {
R.Left = (T)((Y)R.Left / X );
R.Top = (T)((Y)R.Top / X );
R.Right = (T)((Y)R.Right / X );
R.Bottom = (T)((Y)R.Bottom / X );
return R;
}

View File

@@ -10,6 +10,8 @@ class EE_API UICheckBox : public UITextBox {
public:
UICheckBox( const UITextBox::CreateParams& Params );
UICheckBox();
virtual ~UICheckBox();
virtual Uint32 getType() const;
@@ -27,11 +29,16 @@ class EE_API UICheckBox : public UITextBox {
UIControlAnim * getActiveButton() const;
UIControlAnim * getInactiveButton() const;
Int32 getTextSeparation() const;
void setTextSeparation(const Int32 & textSeparation);
protected:
UIControlAnim * mActiveButton;
UIControlAnim * mInactiveButton;
bool mActive;
Uint32 mLastTick;
Int32 mTextSeparation;
virtual void onSizeChange();

View File

@@ -39,6 +39,8 @@ class EE_API UIComplexControl : public UIControlAnim {
UIComplexControl( const UIComplexControl::CreateParams& Params );
UIComplexControl();
virtual ~UIComplexControl();
virtual Uint32 getType() const;

View File

@@ -22,6 +22,8 @@ class UIManager;
class EE_API UIControl {
public:
static Float PixelDensity;
typedef cb::Callback1<void, const UIEvent*> UIEventCallback;
class CreateParams {
@@ -72,6 +74,8 @@ class EE_API UIControl {
UIControl( const CreateParams& Params );
UIControl();
virtual ~UIControl();
void screenToControl( Vector2i& position ) const;
@@ -96,12 +100,16 @@ class EE_API UIControl {
const Vector2i& getPosition() const;
const Vector2i& getRealPosition() const;
virtual void setSize( const Sizei& size );
void setSize( const Int32& Width, const Int32& Height );
const Sizei& getSize();
const Sizei& getRealSize();
Recti getRect() const;
void setVisible( const bool& visible );
@@ -140,9 +148,9 @@ class EE_API UIControl {
void setVerticalAlign( Uint32 valign );
void setBackgroundFillEnabled( bool enabled );
UIBackground * setBackgroundFillEnabled( bool enabled );
void setBorderEnabled( bool enabled );
UIBorder * setBorderEnabled( bool enabled );
UIControl * getNextControl() const;
@@ -246,17 +254,19 @@ class EE_API UIControl {
friend class UIWindow;
Vector2i mPos;
Vector2i mRealPos;
Vector2i mScreenPos;
Vector2f mScreenPosf;
Sizei mSize;
Sizei mRealSize;
Uint32 mFlags;
UintPtr mData;
UIControl * mParentCtrl;
UIControl * mChild; //! Pointer to the first child of the control
UIControl * mParentCtrl;
UIControl * mChild; //! Pointer to the first child of the control
UIControl * mChildLast; //! Pointer to the last child added
UIControl * mNext; //! Pointer to the next child of the father
UIControl * mNext; //! Pointer to the next child of the father
UIControl * mPrev; //! Pointer to the prev child of the father
UISkinState * mSkinState;
@@ -267,7 +277,7 @@ class EE_API UIControl {
Uint16 mBlend;
Uint16 mNumCallBacks;
Polygon2f mPoly;
Polygon2f mPoly;
Vector2f mCenter;
UIEventsMap mEvents;
@@ -386,6 +396,42 @@ class EE_API UIControl {
Sizei getSkinSize( UISkin * Skin, const Uint32& State = UISkinState::StateNormal );
Rectf getRectf();
void setInternalPosition( const Vector2i& Pos );
void setInternalSize( const Sizei& size );
void setInternalWidth( const Int32& width );
void setInternalHeight( const Int32& height );
void setInternalPosX( const Int32& x );
void setInternalPosY( const Int32& y );
Float pxToDp( Float px );
Int32 pxToDpI( Float px );
Float dpToPx( Float dp );
Int32 dpToPxI( Float dp );
Sizei dpToPxI(Sizei size);
Sizei pxToDpI( Sizei size );
Recti dpToPxI( Recti size);
Recti pxToDpI( Recti size );
Sizef dpToPx( Sizef size);
Sizef pxToDp( Sizef size );
Sizei dpToPxI( Sizef size);
Sizei pxToDpI( Sizef size );
};
}}

View File

@@ -11,6 +11,8 @@ class EE_API UIControlAnim : public UIDragable {
public:
UIControlAnim( const CreateParams& Params );
UIControlAnim();
virtual ~UIControlAnim();
virtual Uint32 getType() const;

View File

@@ -9,6 +9,8 @@ class EE_API UIDragable : public UIControl {
public:
UIDragable( const UIControl::CreateParams& Params );
UIDragable();
virtual Uint32 getType() const;
virtual bool isType( const Uint32& type ) const;

View File

@@ -26,6 +26,8 @@ class EE_API UIGfx : public UIComplexControl {
UIGfx( const UIGfx::CreateParams& Params );
UIGfx();
virtual ~UIGfx();
virtual Uint32 getType() const;
@@ -42,7 +44,7 @@ class EE_API UIGfx : public UIComplexControl {
const ColorA& getColor() const;
void serColor( const ColorA& col );
void setColor( const ColorA& col );
const EE_RENDER_MODE& getRenderMode() const;

View File

@@ -10,6 +10,8 @@ class EE_API UIRadioButton : public UITextBox {
public:
UIRadioButton( const UITextBox::CreateParams& Params );
UIRadioButton();
virtual ~UIRadioButton();
virtual Uint32 getType() const;
@@ -27,11 +29,16 @@ class EE_API UIRadioButton : public UITextBox {
UIControlAnim * getActiveButton() const;
UIControlAnim * getInactiveButton() const;
Int32 getTextSeparation() const;
void setTextSeparation(const Int32 & textSeparation);
protected:
UIControlAnim * mActiveButton;
UIControlAnim * mInactiveButton;
bool mActive;
Uint32 mLastTick;
Int32 mTextSeparation;
virtual void onSizeChange();

View File

@@ -27,6 +27,8 @@ class EE_API UISlider : public UIComplexControl {
UISlider( const UISlider::CreateParams& Params );
UISlider();
virtual ~UISlider();
virtual Uint32 getType() const;
@@ -73,7 +75,7 @@ class EE_API UISlider : public UIComplexControl {
bool mAllowHalfSliderOut;
bool mExpandBackground;
UIControlAnim * mBackSlider;
UIControlAnim * mSlider;
Private::UISliderButton * mSlider;
Float mMinValue;
Float mMaxValue;
Float mValue;

View File

@@ -9,6 +9,8 @@ class EE_API UISliderButton : public UIControlAnim {
public:
UISliderButton( const UIControlAnim::CreateParams& Params );
UISliderButton();
virtual ~UISliderButton();
protected:
virtual void onPositionChange();

View File

@@ -38,6 +38,8 @@ class EE_API UITextBox : public UIComplexControl {
UITextBox( const UITextBox::CreateParams& Params );
UITextBox();
virtual ~UITextBox();
virtual Uint32 getType() const;
@@ -56,13 +58,13 @@ class EE_API UITextBox : public UIComplexControl {
virtual void setText( const String& text );
const ColorA& getColor() const;
const ColorA& getFontColor() const;
void setColor( const ColorA& color );
void setFontColor( const ColorA& color );
const ColorA& getShadowColor() const;
const ColorA& getFontShadowColor() const;
void setShadowColor( const ColorA& color );
void setFontShadowColor( const ColorA& color );
const ColorA& getSelectionBackColor() const;
@@ -95,6 +97,7 @@ class EE_API UITextBox : public UIComplexControl {
ColorA mFontSelectionBackColor;
Vector2f mAlignOffset;
Recti mPadding;
Recti mRealPadding;
Int32 mSelCurInit;
Int32 mSelCurEnd;

View File

@@ -28,6 +28,8 @@ class EE_API UITextInput : public UITextBox {
UITextInput( const UITextInput::CreateParams& Params );
UITextInput();
virtual ~UITextInput();
virtual Uint32 getType() const;

View File

@@ -60,7 +60,7 @@ class EE_API UITheme : protected ResourceManager<UISkin> {
void addThemeIcon( const std::string& Icon );
UITheme( const std::string& getName, const std::string& abbr, Graphics::Font * defaultFont = NULL );
UITheme( const std::string& name, const std::string& abbr, Graphics::Font * defaultFont = NULL );
virtual ~UITheme();