diff --git a/src/helper/chipmunk/chipmunk.c b/src/helper/chipmunk/chipmunk.c index 29ab14e2e..56b1aa661 100644 --- a/src/helper/chipmunk/chipmunk.c +++ b/src/helper/chipmunk/chipmunk.c @@ -43,8 +43,10 @@ cpMessage(const char *message, const char *condition, const char *file, int line if(isError) abort(); } +#define XSTR(s) STR(s) +#define STR(s) #s -const char *cpVersionString = "6.0.0b"; +const char *cpVersionString = XSTR(CP_VERSION_MAJOR)"."XSTR(CP_VERSION_MINOR)"."XSTR(CP_VERSION_RELEASE); void cpInitChipmunk(void) diff --git a/src/helper/chipmunk/chipmunk.h b/src/helper/chipmunk/chipmunk.h index 895597bad..bd092ff04 100644 --- a/src/helper/chipmunk/chipmunk.h +++ b/src/helper/chipmunk/chipmunk.h @@ -55,12 +55,22 @@ void cpMessage(const char *message, const char *condition, const char *file, int #include "chipmunk_types.h" // Maximum allocated size for various Chipmunk buffers -#define CP_BUFFER_BYTES (32*1024) +#ifndef CP_BUFFER_BYTES + #define CP_BUFFER_BYTES (32*1024) +#endif -//TODO allow redifinition -#define cpcalloc calloc -#define cprealloc realloc -#define cpfree free +// Chipmunk memory function aliases. +#ifndef cpcalloc + #define cpcalloc calloc +#endif + +#ifndef cprealloc + #define cprealloc realloc +#endif + +#ifndef cpfree + #define cpfree free +#endif typedef struct cpArray cpArray; typedef struct cpHashSet cpHashSet; @@ -86,6 +96,10 @@ typedef struct cpSpace cpSpace; #include "cpSpace.h" +#define CP_VERSION_MAJOR 6 +#define CP_VERSION_MINOR 0 +#define CP_VERSION_RELEASE 0 + /// Version string. extern const char *cpVersionString; diff --git a/src/helper/chipmunk/chipmunk_ffi.h b/src/helper/chipmunk/chipmunk_ffi.h index 4e2214cbc..e88ca9a0d 100644 --- a/src/helper/chipmunk/chipmunk_ffi.h +++ b/src/helper/chipmunk/chipmunk_ffi.h @@ -1,4 +1,4 @@ -// TODO update me +#ifdef CHIPMUNK_FFI // Create non static inlined copies of Chipmunk functions, useful for working with dynamic FFIs // This file should only be included in chipmunk.c @@ -13,6 +13,9 @@ #define MAKE_REF(name) __typeof__(name) *_##name = name #endif +#define MAKE_PROPERTIES_REF(struct, property) \ + MAKE_REF(struct##Get##property); MAKE_REF(struct##Set##property); + MAKE_REF(cpv); // makes a variable named _cpv that contains the function pointer for cpv() MAKE_REF(cpveql); MAKE_REF(cpvadd); @@ -36,26 +39,120 @@ MAKE_REF(cpvdist); MAKE_REF(cpvdistsq); MAKE_REF(cpvnear); +MAKE_REF(cpfmax); +MAKE_REF(cpfmin); +MAKE_REF(cpfabs); +MAKE_REF(cpfclamp); +MAKE_REF(cpflerp); +MAKE_REF(cpflerpconst); + MAKE_REF(cpBBNew); MAKE_REF(cpBBIntersects); MAKE_REF(cpBBContainsBB); MAKE_REF(cpBBContainsVect); MAKE_REF(cpBBMerge); MAKE_REF(cpBBExpand); +MAKE_REF(cpBBArea); +MAKE_REF(cpBBMergedArea); +MAKE_REF(cpBBIntersectsSegment); -MAKE_REF(cpBodyWorld2Local); -MAKE_REF(cpBodyLocal2World); -MAKE_REF(cpBodyApplyImpulse); +MAKE_REF(cpBodyGetMass); +MAKE_REF(cpBodyGetMoment); +MAKE_REF(cpBodyGetPos); +MAKE_REF(cpBodyGetAngle); +MAKE_REF(cpBodyGetRot); +MAKE_PROPERTIES_REF(cpBody, Vel); +MAKE_PROPERTIES_REF(cpBody, Force); +MAKE_PROPERTIES_REF(cpBody, AngVel); +MAKE_PROPERTIES_REF(cpBody, Torque); +MAKE_PROPERTIES_REF(cpBody, VelLimit); +MAKE_PROPERTIES_REF(cpBody, AngVelLimit); +MAKE_PROPERTIES_REF(cpBody, UserData); MAKE_REF(cpBodyIsSleeping); +MAKE_REF(cpBodyIsStatic); MAKE_REF(cpBodyIsRogue); +MAKE_REF(cpBodyLocal2World); +MAKE_REF(cpBodyWorld2Local); MAKE_REF(cpBodyKineticEnergy); -MAKE_REF(cpArbiterIsFirstContact); -MAKE_REF(cpArbiterGetShapes); -MAKE_REF(cpArbiterGetNormal); -MAKE_REF(cpArbiterGetPoint); +MAKE_REF(cpShapeGetBB); +MAKE_PROPERTIES_REF(cpShape, Body); +MAKE_PROPERTIES_REF(cpShape, IsSensor); +MAKE_PROPERTIES_REF(cpShape, Elasticity); +MAKE_PROPERTIES_REF(cpShape, Friction); +MAKE_PROPERTIES_REF(cpShape, SurfaceVelocity); +MAKE_PROPERTIES_REF(cpShape, UserData); +MAKE_PROPERTIES_REF(cpShape, CollisionType); +MAKE_PROPERTIES_REF(cpShape, Group); +MAKE_PROPERTIES_REF(cpShape, Layers); +MAKE_REF(cpArbiterGetShapes); +MAKE_REF(cpArbiterGetBodies); +MAKE_REF(cpArbiterIsFirstContact); +MAKE_REF(cpArbiterGetCount); + +MAKE_REF(cpConstraintGetA); +MAKE_REF(cpConstraintGetB); +MAKE_PROPERTIES_REF(cpConstraint, MaxForce); +MAKE_PROPERTIES_REF(cpConstraint, ErrorBias); +MAKE_PROPERTIES_REF(cpConstraint, MaxBias); +MAKE_PROPERTIES_REF(cpConstraint, UserData); MAKE_REF(cpConstraintGetImpulse); +MAKE_PROPERTIES_REF(cpDampedRotarySpring, RestAngle); +MAKE_PROPERTIES_REF(cpDampedRotarySpring, Stiffness); +MAKE_PROPERTIES_REF(cpDampedRotarySpring, Damping); +//MAKE_PROPERTIES_REF(cpDampedRotarySpring, SpringTorqueFunc); + +MAKE_PROPERTIES_REF(cpDampedSpring, Anchr1); +MAKE_PROPERTIES_REF(cpDampedSpring, Anchr2); +MAKE_PROPERTIES_REF(cpDampedSpring, RestLength); +MAKE_PROPERTIES_REF(cpDampedSpring, Stiffness); +MAKE_PROPERTIES_REF(cpDampedSpring, Damping); +//MAKE_PROPERTIES_REF(cpDampedSpring, SpringForceFunc); + +MAKE_PROPERTIES_REF(cpGearJoint, Phase); +MAKE_REF(cpGearJointGetRatio); + +MAKE_PROPERTIES_REF(cpGrooveJoint, Anchr2); +MAKE_REF(cpGrooveJointGetGrooveA); +MAKE_REF(cpGrooveJointGetGrooveB); + +MAKE_PROPERTIES_REF(cpPinJoint, Anchr1); +MAKE_PROPERTIES_REF(cpPinJoint, Anchr2); +MAKE_PROPERTIES_REF(cpPinJoint, Dist); + +MAKE_PROPERTIES_REF(cpPivotJoint, Anchr1); +MAKE_PROPERTIES_REF(cpPivotJoint, Anchr2); + +MAKE_PROPERTIES_REF(cpRatchetJoint, Angle); +MAKE_PROPERTIES_REF(cpRatchetJoint, Phase); +MAKE_PROPERTIES_REF(cpRatchetJoint, Ratchet); + +MAKE_PROPERTIES_REF(cpRotaryLimitJoint, Min); +MAKE_PROPERTIES_REF(cpRotaryLimitJoint, Max); + +MAKE_PROPERTIES_REF(cpSimpleMotor, Rate); + +MAKE_PROPERTIES_REF(cpSlideJoint, Anchr1); +MAKE_PROPERTIES_REF(cpSlideJoint, Anchr2); +MAKE_PROPERTIES_REF(cpSlideJoint, Min); +MAKE_PROPERTIES_REF(cpSlideJoint, Max); + MAKE_REF(cpSegmentQueryHitPoint); MAKE_REF(cpSegmentQueryHitDist); + +MAKE_REF(cpSpatialIndexDestroy); +MAKE_REF(cpSpatialIndexCount); +MAKE_REF(cpSpatialIndexEach); +MAKE_REF(cpSpatialIndexContains); +MAKE_REF(cpSpatialIndexInsert); +MAKE_REF(cpSpatialIndexRemove); +MAKE_REF(cpSpatialIndexReindex); +MAKE_REF(cpSpatialIndexReindexObject); +MAKE_REF(cpSpatialIndexPointQuery); +MAKE_REF(cpSpatialIndexSegmentQuery); +MAKE_REF(cpSpatialIndexQuery); +MAKE_REF(cpSpatialIndexReindexQuery); + +#endif diff --git a/src/helper/chipmunk/chipmunk_private.h b/src/helper/chipmunk/chipmunk_private.h index b2d9bc4f9..5a3b3fb9c 100644 --- a/src/helper/chipmunk/chipmunk_private.h +++ b/src/helper/chipmunk/chipmunk_private.h @@ -181,3 +181,12 @@ void cpShapeUpdateFunc(cpShape *shape, void *unused); void cpSpaceActivateBody(cpSpace *space, cpBody *body); void cpSpaceLock(cpSpace *space); void cpSpaceUnlock(cpSpace *space, cpBool runPostStep); + +static inline cpCollisionHandler * +cpSpaceLookupHandler(cpSpace *space, cpCollisionType a, cpCollisionType b) +{ + cpCollisionType types[] = {a, b}; + return (cpCollisionHandler *)cpHashSetFind(space->collisionHandlers, CP_HASH_PAIR(a, b), types); +} + + diff --git a/src/helper/chipmunk/constraints/cpConstraint.h b/src/helper/chipmunk/constraints/cpConstraint.h index a6b2c2822..13370e5d5 100644 --- a/src/helper/chipmunk/constraints/cpConstraint.h +++ b/src/helper/chipmunk/constraints/cpConstraint.h @@ -98,7 +98,7 @@ CP_DefineConstraintStructGetter(cpBody *, b, B); CP_DefineConstraintStructProperty(cpFloat, maxForce, MaxForce); CP_DefineConstraintStructProperty(cpFloat, errorBias, ErrorBias); CP_DefineConstraintStructProperty(cpFloat, maxBias, MaxBias); -CP_DefineConstraintStructProperty(cpDataPointer, data, Data); +CP_DefineConstraintStructProperty(cpDataPointer, data, UserData); /// Get the last impulse applied by this constraint. static inline cpFloat diff --git a/src/helper/chipmunk/cpBody.h b/src/helper/chipmunk/cpBody.h index 0d1ba98dd..92eeb78f4 100644 --- a/src/helper/chipmunk/cpBody.h +++ b/src/helper/chipmunk/cpBody.h @@ -190,12 +190,7 @@ CP_DefineBodyStructProperty(cpFloat, t, Torque); CP_DefineBodyStructGetter(cpVect, rot, Rot); CP_DefineBodyStructProperty(cpFloat, v_limit, VelLimit); CP_DefineBodyStructProperty(cpFloat, w_limit, AngVelLimit); -CP_DefineBodyStructProperty(cpDataPointer, data, Data); - -/// Return the user data pointer for a body. -static inline cpDataPointer cpBodyGetUserData(const cpBody *body){return body->data;} -/// Set the user data pointer for a body. -static inline void cpBodySetUserData(cpBody *body, cpDataPointer data){body->data = data;} +CP_DefineBodyStructProperty(cpDataPointer, data, UserData); /// Default Integration functions. void cpBodyUpdateVelocity(cpBody *body, cpVect gravity, cpFloat damping, cpFloat dt); diff --git a/src/helper/chipmunk/cpShape.c b/src/helper/chipmunk/cpShape.c index 1ed92ea8b..439cc1589 100644 --- a/src/helper/chipmunk/cpShape.c +++ b/src/helper/chipmunk/cpShape.c @@ -84,13 +84,7 @@ cpShapeFree(cpShape *shape) void cpShapeSetBody(cpShape *shape, cpBody *body) { - // This is a little tricky, but was requested by a user. - // Changing the body on an active shape swapping out the shape lists on the bodies - if(shape->next){ - cpBodyRemoveShape(shape->body, shape); - cpBodyAddShape(body, shape); - } - + cpAssert(shape->next == NULL, "You cannot change the body on an active shape. You must remove the shape, then "); shape->body = body; } diff --git a/src/helper/chipmunk/cpSpaceComponent.c b/src/helper/chipmunk/cpSpaceComponent.c index 10c26ac07..f53bde0a9 100644 --- a/src/helper/chipmunk/cpSpaceComponent.c +++ b/src/helper/chipmunk/cpSpaceComponent.c @@ -30,9 +30,11 @@ void cpSpaceActivateBody(cpSpace *space, cpBody *body) { + cpAssert(!cpBodyIsRogue(body), "Internal error: Attempting to activate a rouge body."); + if(space->locked){ // cpSpaceActivateBody() is called again once the space is unlocked - cpArrayPush(space->rousedBodies, body); + if(!cpArrayContains(space->rousedBodies, body)) cpArrayPush(space->rousedBodies, body); } else { cpArrayPush(space->bodies, body); @@ -52,12 +54,19 @@ cpSpaceActivateBody(cpSpace *space, cpBody *body) memcpy(arb->contacts, contacts, numContacts*sizeof(cpContact)); cpSpacePushContacts(space, numContacts); + // Reinsert the arbiter into the arbiter cache cpShape *a = arb->a, *b = arb->b; cpShape *shape_pair[] = {a, b}; cpHashValue arbHashID = CP_HASH_PAIR((size_t)a, (size_t)b); cpHashSetInsert(space->cachedArbiters, arbHashID, shape_pair, arb, NULL); - cpArrayPush(space->arbiters, arb); + + // Update the arbiter's state arb->stamp = space->stamp; + arb->handler = cpSpaceLookupHandler(space, a->collision_type, b->collision_type); + cpArrayPush(space->arbiters, arb); + + // TODO pre-step callbacks for freshly awoken bodies need to be done somewhere. + // Probably not here? cpfree(contacts); } @@ -73,6 +82,8 @@ cpSpaceActivateBody(cpSpace *space, cpBody *body) static void cpSpaceDeactivateBody(cpSpace *space, cpBody *body) { + cpAssert(!cpBodyIsRogue(body), "Internal error: Attempting to deactivate a rouge body."); + cpArrayDeleteObj(space->bodies, body); CP_BODY_FOREACH_SHAPE(body, shape){ @@ -293,12 +304,13 @@ cpBodySleepWithGroup(cpBody *body, cpBody *group){ } static void -activateTouchingHelper(cpShape *shape, cpContactPointSet *points, cpArray **bodies){ +activateTouchingHelper(cpShape *shape, cpContactPointSet *points, void *unused){ cpBodyActivate(shape->body); } void cpSpaceActivateShapesTouchingShape(cpSpace *space, cpShape *shape){ - cpArray *bodies = NULL; - cpSpaceShapeQuery(space, shape, (cpSpaceShapeQueryFunc)activateTouchingHelper, &bodies); + if(space->sleepTimeThreshold != INFINITY){ + cpSpaceShapeQuery(space, shape, (cpSpaceShapeQueryFunc)activateTouchingHelper, NULL); + } } diff --git a/src/helper/chipmunk/cpSpaceStep.c b/src/helper/chipmunk/cpSpaceStep.c index 34a7e115b..f5c2ead24 100644 --- a/src/helper/chipmunk/cpSpaceStep.c +++ b/src/helper/chipmunk/cpSpaceStep.c @@ -217,13 +217,6 @@ cpSpaceArbiterSetTrans(cpShape **shapes, cpSpace *space) return cpArbiterInit((cpArbiter *)cpArrayPop(space->pooledArbiters), shapes[0], shapes[1]); } -static inline cpCollisionHandler * -lookupCollisionHandler(cpSpace *space, cpCollisionType a, cpCollisionType b) -{ - cpCollisionType types[] = {a, b}; - return (cpCollisionHandler *)cpHashSetFind(space->collisionHandlers, CP_HASH_PAIR(a, b), types); -} - static inline cpBool queryReject(cpShape *a, cpShape *b) { @@ -246,7 +239,7 @@ collideShapes(cpShape *a, cpShape *b, cpSpace *space) // Reject any of the simple cases if(queryReject(a,b)) return; - cpCollisionHandler *handler = lookupCollisionHandler(space, a->collision_type, b->collision_type); + cpCollisionHandler *handler = cpSpaceLookupHandler(space, a->collision_type, b->collision_type); cpBool sensor = a->sensor || b->sensor; if(sensor && handler == &cpDefaultCollisionHandler) return; @@ -319,7 +312,7 @@ cpSpaceArbiterSetFilter(cpArbiter *arb, cpSpace *space) // Arbiter was used last frame, but not this one if(ticks >= 1 && arb->state != cpArbiterStateCached){ // The handler needs to be looked up again as the handler cached on the arbiter may have been deleted since the last step. - cpCollisionHandler *handler = lookupCollisionHandler(space, arb->a->collision_type, arb->b->collision_type); + cpCollisionHandler *handler = cpSpaceLookupHandler(space, arb->a->collision_type, arb->b->collision_type); handler->separate(arb, space, handler->data); arb->state = cpArbiterStateCached; } diff --git a/src/test/eetest.cpp b/src/test/eetest.cpp index da6bf1c87..30a849e83 100644 --- a/src/test/eetest.cpp +++ b/src/test/eetest.cpp @@ -217,9 +217,9 @@ void cEETest::OnFontLoaded( cResourceLoader * ObjLoaded ) { Map.Font( FF ); Con.Create( FF, true ); - Con.IgnoreCharOnPrompt( 186 ); // 'º' + Con.IgnoreCharOnPrompt( 186 ); // 'º' - mBuda = String::FromUtf8( "El mono ve el pez en el agua y sufre. Piensa que su mundo es el único que existe, el mejor, el real. Sufre porque es bueno y tiene compasión, lo ve y piensa: \"Pobre se está ahogando no puede respirar\". Y lo saca, lo saca y se queda tranquilo, por fin lo salvé. Pero el pez se retuerce de dolor y muere. Por eso te mostré el sueño, es imposible meter el mar en tu cabeza, que es un balde." ); + mBuda = String::FromUtf8( "El mono ve el pez en el agua y sufre. Piensa que su mundo es el único que existe, el mejor, el real. Sufre porque es bueno y tiene compasión, lo ve y piensa: \"Pobre se está ahogando no puede respirar\". Y lo saca, lo saca y se queda tranquilo, por fin lo salvé. Pero el pez se retuerce de dolor y muere. Por eso te mostré el sueño, es imposible meter el mar en tu cabeza, que es un balde." ); CreateUI(); diff --git a/src/ui/cuimenu.hpp b/src/ui/cuimenu.hpp index ad23d99d6..5adb4973b 100644 --- a/src/ui/cuimenu.hpp +++ b/src/ui/cuimenu.hpp @@ -17,13 +17,13 @@ class EE_API cUIMenu : public cUIComplexControl { cUIComplexControl::CreateParams(), RowHeight( 0 ), PaddingContainer(), + MinWidth( 0 ), + MinSpaceForIcons( 0 ), + MinRightMargin( 0 ), Font( NULL ), FontColor( 0, 0, 0, 255 ), FontOverColor( 0, 0, 0, 255 ), - FontSelectedColor( 0, 0, 0, 255 ), - MinWidth( 0 ), - MinSpaceForIcons( 0 ), - MinRightMargin( 0 ) + FontSelectedColor( 0, 0, 0, 255 ) { cUITheme * Theme = cUIThemeManager::instance()->DefaultTheme(); @@ -43,14 +43,14 @@ class EE_API cUIMenu : public cUIComplexControl { Uint32 RowHeight; eeRecti PaddingContainer; + Uint32 MinWidth; + Uint32 MinSpaceForIcons; + Uint32 MinRightMargin; cFont * Font; eeColorA FontColor; eeColorA FontShadowColor; eeColorA FontOverColor; eeColorA FontSelectedColor; - Uint32 MinWidth; - Uint32 MinSpaceForIcons; - Uint32 MinRightMargin; }; diff --git a/src/ui/cuispinbox.hpp b/src/ui/cuispinbox.hpp index b25850000..78e18aaef 100644 --- a/src/ui/cuispinbox.hpp +++ b/src/ui/cuispinbox.hpp @@ -11,10 +11,11 @@ class EE_API cUISpinBox : public cUIComplexControl { class CreateParams : public cUITextInput::CreateParams { public: inline CreateParams() : - cUITextInput::CreateParams() + cUITextInput::CreateParams(), + DefaultValue( 0.f ), + AllowDotsInNumbers( true ) { MaxLenght = 24; - DefaultValue = 0.f; } inline ~CreateParams() {} diff --git a/src/ui/cuitheme.cpp b/src/ui/cuitheme.cpp index 49a8851c6..0c3124744 100644 --- a/src/ui/cuitheme.cpp +++ b/src/ui/cuitheme.cpp @@ -11,6 +11,16 @@ #include "cuipopupmenu.hpp" #include "cuiprogressbar.hpp" #include "cuipushbutton.hpp" +#include "cuiradiobutton.hpp" +#include "cuiscrollbar.hpp" +#include "cuislider.hpp" +#include "cuispinbox.hpp" +#include "cuitextbox.hpp" +#include "cuitextedit.hpp" +#include "cuitextinput.hpp" +#include "cuitooltip.hpp" +#include "cuiwindow.hpp" +#include "cuiwinmenu.hpp" namespace EE { namespace UI { @@ -338,7 +348,7 @@ void cUITheme::PostInit() { } cUICheckBox * cUITheme::CreateCheckBox( cUIControl * Parent, const eeSize& Size, const eeVector2i& Pos, const Uint32& Flags ) { - cUITextBox::CreateParams CheckBoxParams; + cUICheckBox::CreateParams CheckBoxParams; CheckBoxParams.Parent( Parent ); CheckBoxParams.PosSet( Pos ); CheckBoxParams.SizeSet( Size ); @@ -346,6 +356,88 @@ cUICheckBox * cUITheme::CreateCheckBox( cUIControl * Parent, const eeSize& Size, return eeNew( cUICheckBox, ( CheckBoxParams ) ); } +cUIRadioButton * cUITheme::CreateRadioButton( cUIControl * Parent, const eeSize& Size, const eeVector2i& Pos, const Uint32& Flags ) { + cUIRadioButton::CreateParams RadioButtonParams; + RadioButtonParams.Parent( Parent ); + RadioButtonParams.PosSet( Pos ); + RadioButtonParams.SizeSet( Size ); + RadioButtonParams.Flags = Flags; + return eeNew( cUIRadioButton, ( RadioButtonParams ) ); +} + +cUITextBox * cUITheme::CreateTextBox( cUIControl * Parent, const eeSize& Size, const eeVector2i& Pos, const Uint32& Flags ) { + cUITextBox::CreateParams TextBoxParams; + TextBoxParams.Parent( Parent ); + TextBoxParams.PosSet( Pos ); + TextBoxParams.SizeSet( Size ); + TextBoxParams.Flags = Flags; + return eeNew( cUITextBox, ( TextBoxParams ) ); +} + +cUITooltip * cUITheme::CreateTooltip( cUIControl * TooltipOf, cUIControl * Parent, const eeSize& Size, const eeVector2i& Pos, const Uint32& Flags ) { + cUITooltip::CreateParams TooltipParams; + TooltipParams.Parent( Parent ); + TooltipParams.PosSet( Pos ); + TooltipParams.SizeSet( Size ); + TooltipParams.Flags = Flags; + return eeNew( cUITooltip, ( TooltipParams, TooltipOf ) ); +} + +cUITextEdit * cUITheme::CreateTextEdit( cUIControl * Parent, const eeSize& Size, const eeVector2i& Pos, const Uint32& Flags, UI_SCROLLBAR_MODE HScrollBar, UI_SCROLLBAR_MODE VScrollBar, bool WordWrap ) { + cUITextEdit::CreateParams TextEditParams; + TextEditParams.Parent( Parent ); + TextEditParams.PosSet( Pos ); + TextEditParams.SizeSet( Size ); + TextEditParams.Flags = Flags; + TextEditParams.HScrollBar = HScrollBar; + TextEditParams.VScrollBar = VScrollBar; + TextEditParams.WordWrap = WordWrap; + return eeNew( cUITextEdit, ( TextEditParams ) ); +} + +cUITextInput * cUITheme::CreateTextInput( cUIControl * Parent, const eeSize& Size, const eeVector2i& Pos, const Uint32& Flags, bool SupportFreeEditing, Uint32 MaxLenght ) { + cUITextInput::CreateParams TextInputParams; + TextInputParams.Parent( Parent ); + TextInputParams.PosSet( Pos ); + TextInputParams.SizeSet( Size ); + TextInputParams.Flags = Flags; + TextInputParams.SupportFreeEditing = SupportFreeEditing; + TextInputParams.MaxLenght = MaxLenght; + return eeNew( cUITextInput, ( TextInputParams ) ); +} + +cUISpinBox * cUITheme::CreateSpinBox( cUIControl * Parent, const eeSize& Size, const eeVector2i& Pos, const Uint32& Flags, eeFloat DefaultValue, bool AllowDotsInNumbers ) { + cUISpinBox::CreateParams SpinBoxParams; + SpinBoxParams.Parent( Parent ); + SpinBoxParams.PosSet( Pos ); + SpinBoxParams.SizeSet( Size ); + SpinBoxParams.Flags = Flags; + SpinBoxParams.DefaultValue = DefaultValue; + SpinBoxParams.AllowDotsInNumbers = AllowDotsInNumbers; + return eeNew( cUISpinBox, ( SpinBoxParams ) ); +} + +cUIScrollBar * cUITheme::CreateScrollBar( cUIControl * Parent, const eeSize& Size, const eeVector2i& Pos, const Uint32& Flags, bool VerticalScrollBar ) { + cUIScrollBar::CreateParams ScrollBarParams; + ScrollBarParams.Parent( Parent ); + ScrollBarParams.PosSet( Pos ); + ScrollBarParams.SizeSet( Size ); + ScrollBarParams.Flags = Flags; + return eeNew( cUIScrollBar, ( ScrollBarParams ) ); +} + +cUISlider * cUITheme::CreateSlider( cUIControl * Parent, const eeSize& Size, const eeVector2i& Pos, const Uint32& Flags, bool VerticalSlider, bool AllowHalfSliderOut, bool ExpandBackground ) { + cUISlider::CreateParams SliderParams; + SliderParams.Parent( Parent ); + SliderParams.PosSet( Pos ); + SliderParams.SizeSet( Size ); + SliderParams.Flags = Flags; + SliderParams.VerticalSlider = VerticalSlider; + SliderParams.AllowHalfSliderOut = AllowHalfSliderOut; + SliderParams.ExpandBackground = ExpandBackground; + return eeNew( cUISlider, ( SliderParams ) ); +} + cUIComboBox * cUITheme::CreateComboBox( cUIControl * Parent, const eeSize& Size, const eeVector2i& Pos, const Uint32& Flags, Uint32 MinNumVisibleItems, bool PopUpToMainControl, cUIListBox * ListBox ) { cUIComboBox::CreateParams ComboParams; ComboParams.Parent( Parent ); @@ -384,12 +476,17 @@ cUIListBox * cUITheme::CreateListBox( cUIControl * Parent, const eeSize& Size, c return eeNew( cUIListBox, ( LBParams ) ); } -cUIPopUpMenu * cUITheme::CreatePopUpMenu( cUIControl * Parent, const eeSize& Size, const eeVector2i& Pos, const Uint32& Flags ) { +cUIPopUpMenu * cUITheme::CreatePopUpMenu( cUIControl * Parent, const eeSize& Size, const eeVector2i& Pos, const Uint32& Flags, Uint32 RowHeight, eeRecti PaddingContainer, Uint32 MinWidth, Uint32 MinSpaceForIcons, Uint32 MinRightMargin ) { cUIPopUpMenu::CreateParams MenuParams; MenuParams.Parent( Parent ); MenuParams.PosSet( Pos ); MenuParams.SizeSet( Size ); MenuParams.Flags = Flags; + MenuParams.RowHeight = RowHeight; + MenuParams.PaddingContainer = PaddingContainer; + MenuParams.MinWidth = MinWidth; + MenuParams.MinSpaceForIcons = MinSpaceForIcons; + MenuParams.MinRightMargin = MinRightMargin; /** Aqua Theme Stuff *//** MenuParams.MinWidth = 100; @@ -399,22 +496,32 @@ cUIPopUpMenu * cUITheme::CreatePopUpMenu( cUIControl * Parent, const eeSize& Siz return eeNew( cUIPopUpMenu, ( MenuParams ) ); } -cUIProgressBar * cUITheme::CreateProgressBar( cUIControl * Parent, const eeSize& Size, const eeVector2i& Pos, const Uint32& Flags, bool DisplayPercent ) { +cUIProgressBar * cUITheme::CreateProgressBar( cUIControl * Parent, const eeSize& Size, const eeVector2i& Pos, const Uint32& Flags, bool DisplayPercent, bool VerticalExpand, eeVector2f MovementSpeed, eeRectf FillerMargin ) { cUIProgressBar::CreateParams PBParams; PBParams.Parent( Parent ); PBParams.PosSet( Pos ); PBParams.SizeSet( Size ); PBParams.Flags = Flags; PBParams.DisplayPercent = DisplayPercent; + PBParams.VerticalExpand = VerticalExpand; + PBParams.MovementSpeed = MovementSpeed; + PBParams.FillerMargin = FillerMargin; + + /** Aqua Theme Stuff *//** + PBParams.DisplayPercent = true + */ return eeNew( cUIProgressBar, ( PBParams ) ); } -cUIPushButton * cUITheme::CreatePushButton( cUIControl * Parent, const eeSize& Size, const eeVector2i& Pos, const Uint32& Flags, cShape * Icon ) { +cUIPushButton * cUITheme::CreatePushButton( cUIControl * Parent, const eeSize& Size, const eeVector2i& Pos, const Uint32& Flags, cShape * Icon, Int32 IconHorizontalMargin, bool IconAutoMargin ) { cUIPushButton::CreateParams ButtonParams; ButtonParams.Parent( Parent ); ButtonParams.PosSet( Pos ); ButtonParams.SizeSet( Size ); ButtonParams.Flags = Flags; + ButtonParams.Icon = Icon; + ButtonParams.IconHorizontalMargin = IconHorizontalMargin; + ButtonParams.IconAutoMargin = IconAutoMargin; if ( NULL != Icon ) ButtonParams.SetIcon( Icon ); diff --git a/src/ui/cuitheme.hpp b/src/ui/cuitheme.hpp index 259292bed..ff0b2beb5 100644 --- a/src/ui/cuitheme.hpp +++ b/src/ui/cuitheme.hpp @@ -17,6 +17,16 @@ class cUIListBox; class cUIPopUpMenu; class cUIProgressBar; class cUIPushButton; +class cUIRadioButton; +class cUIScrollBar; +class cUISlider; +class cUISpinBox; +class cUITextBox; +class cUITextEdit; +class cUITextInput; +class cUITooltip; +class cUIWindow; +class cUIWinMenu; class EE_API cUITheme : public tResourceManager { public: @@ -62,17 +72,33 @@ class EE_API cUITheme : public tResourceManager { virtual cUICheckBox * CreateCheckBox( cUIControl * Parent, const eeSize& Size = eeSize(), const eeVector2i& Pos = eeVector2i(), const Uint32& Flags = UI_VALIGN_CENTER | UI_HALIGN_LEFT ); + virtual cUIRadioButton * CreateRadioButton( cUIControl * Parent, const eeSize& Size = eeSize(), const eeVector2i& Pos = eeVector2i(), const Uint32& Flags = UI_VALIGN_CENTER | UI_HALIGN_LEFT ); + + virtual cUITextBox * CreateTextBox( cUIControl * Parent, const eeSize& Size = eeSize(), const eeVector2i& Pos = eeVector2i(), const Uint32& Flags = UI_HALIGN_LEFT | UI_VALIGN_CENTER ); + + virtual cUITextEdit * CreateTextEdit( cUIControl * Parent, const eeSize& Size = eeSize(), const eeVector2i& Pos = eeVector2i(), const Uint32& Flags = UI_HALIGN_LEFT | UI_VALIGN_CENTER | UI_AUTO_PADDING | UI_CLIP_ENABLE, UI_SCROLLBAR_MODE HScrollBar = UI_SCROLLBAR_AUTO, UI_SCROLLBAR_MODE VScrollBar = UI_SCROLLBAR_AUTO, bool WordWrap = true ); + + virtual cUITextInput * CreateTextInput( cUIControl * Parent, const eeSize& Size = eeSize(), const eeVector2i& Pos = eeVector2i(), const Uint32& Flags = UI_HALIGN_LEFT | UI_VALIGN_CENTER | UI_CLIP_ENABLE | UI_AUTO_PADDING, bool SupportFreeEditing = true, Uint32 MaxLenght = 256 ); + + virtual cUITooltip * CreateTooltip( cUIControl * TooltipOf, cUIControl * Parent, const eeSize& Size = eeSize(), const eeVector2i& Pos = eeVector2i(), const Uint32& Flags = UI_VALIGN_CENTER | UI_HALIGN_CENTER | UI_AUTO_PADDING | UI_AUTO_SIZE ); + + virtual cUIScrollBar * CreateScrollBar( cUIControl * Parent, const eeSize& Size = eeSize(), const eeVector2i& Pos = eeVector2i(), const Uint32& Flags = UI_VALIGN_CENTER | UI_HALIGN_LEFT | UI_AUTO_SIZE, bool VerticalScrollBar = false ); + + virtual cUISlider * CreateSlider( cUIControl * Parent, const eeSize& Size = eeSize(), const eeVector2i& Pos = eeVector2i(), const Uint32& Flags = UI_VALIGN_CENTER | UI_HALIGN_LEFT, bool VerticalSlider = false, bool AllowHalfSliderOut = true, bool ExpandBackground = false ); + + virtual cUISpinBox * CreateSpinBox( cUIControl * Parent, const eeSize& Size = eeSize(), const eeVector2i& Pos = eeVector2i(), const Uint32& Flags = UI_VALIGN_CENTER | UI_HALIGN_LEFT | UI_CLIP_ENABLE, eeFloat DefaultValue = 0.f, bool AllowDotsInNumbers = true ); + virtual cUIComboBox * CreateComboBox( cUIControl * Parent, const eeSize& Size = eeSize(), const eeVector2i& Pos = eeVector2i(), const Uint32& Flags = UI_CLIP_ENABLE | UI_AUTO_PADDING | UI_VALIGN_CENTER | UI_HALIGN_LEFT, Uint32 MinNumVisibleItems = 6, bool PopUpToMainControl = false, cUIListBox * ListBox = NULL ); virtual cUIDropDownList * CreateDropDownList( cUIControl * Parent, const eeSize& Size = eeSize(), const eeVector2i& Pos = eeVector2i(), const Uint32& Flags = UI_CLIP_ENABLE | UI_AUTO_PADDING | UI_VALIGN_CENTER | UI_HALIGN_LEFT, Uint32 MinNumVisibleItems = 6, bool PopUpToMainControl = false, cUIListBox * ListBox = NULL ); virtual cUIListBox * CreateListBox( cUIControl * Parent, const eeSize& Size = eeSize(), const eeVector2i& Pos = eeVector2i(), const Uint32& Flags = UI_CLIP_ENABLE | UI_AUTO_PADDING, bool SmoothScroll = true, Uint32 RowHeight = 0, UI_SCROLLBAR_MODE VScrollMode = UI_SCROLLBAR_AUTO, UI_SCROLLBAR_MODE HScrollMode = UI_SCROLLBAR_AUTO, eeRecti PaddingContainer = eeRecti() ); - virtual cUIPopUpMenu * CreatePopUpMenu( cUIControl * Parent, const eeSize& Size = eeSize(), const eeVector2i& Pos = eeVector2i(), const Uint32& Flags = UI_AUTO_SIZE | UI_AUTO_PADDING ); + virtual cUIPopUpMenu * CreatePopUpMenu( cUIControl * Parent, const eeSize& Size = eeSize(), const eeVector2i& Pos = eeVector2i(), const Uint32& Flags = UI_AUTO_SIZE | UI_AUTO_PADDING, Uint32 RowHeight = 0, eeRecti PaddingContainer = eeRecti(), Uint32 MinWidth = 0, Uint32 MinSpaceForIcons = 0, Uint32 MinRightMargin = 0 ); - virtual cUIProgressBar * CreateProgressBar( cUIControl * Parent, const eeSize& Size = eeSize(), const eeVector2i& Pos = eeVector2i(), const Uint32& Flags = UI_HALIGN_LEFT | UI_VALIGN_CENTER, bool DisplayPercent = true ); + virtual cUIProgressBar * CreateProgressBar( cUIControl * Parent, const eeSize& Size = eeSize(), const eeVector2i& Pos = eeVector2i(), const Uint32& Flags = UI_HALIGN_LEFT | UI_VALIGN_CENTER, bool DisplayPercent = false, bool VerticalExpand = false, eeVector2f MovementSpeed = eeVector2f( 64, 0 ), eeRectf FillerMargin = eeRectf() ); - virtual cUIPushButton * CreatePushButton( cUIControl * Parent, const eeSize& Size = eeSize(), const eeVector2i& Pos = eeVector2i(), const Uint32& Flags = UI_VALIGN_CENTER | UI_HALIGN_CENTER, cShape * Icon = NULL ); + virtual cUIPushButton * CreatePushButton( cUIControl * Parent, const eeSize& Size = eeSize(), const eeVector2i& Pos = eeVector2i(), const Uint32& Flags = UI_VALIGN_CENTER | UI_HALIGN_CENTER, cShape * Icon = NULL, Int32 IconHorizontalMargin = 0, bool IconAutoMargin = true ); protected: std::string mName; Uint32 mNameHash; @@ -82,7 +108,7 @@ class EE_API cUITheme : public tResourceManager { eeColorA mFontShadowColor; eeColorA mFontOverColor; eeColorA mFontSelectedColor; - private: + static bool SearchFilesOfElement( cShapeGroup * SG, const std::string& Path, std::string Element, Uint32& IsComplex, const std::string ImgExt ); static bool SearchFilesInGroup( cShapeGroup * SG, std::string Element, Uint32& IsComplex ); diff --git a/src/ui/cuitooltip.cpp b/src/ui/cuitooltip.cpp index def94124e..6033e4427 100644 --- a/src/ui/cuitooltip.cpp +++ b/src/ui/cuitooltip.cpp @@ -12,7 +12,7 @@ cUITooltip::cUITooltip( cUITooltip::CreateParams& Params, cUIControl * TooltipOf mTooltipTime( 0.f ), mTooltipOf( TooltipOf ) { - mType |= UI_TYPE_TOOLTIP; + mType = UI_TYPE_TOOLTIP; mTextCache = eeNew( cTextCache, () ); mTextCache->Font( Params.Font );