Browse Source

flag_actorHasBounds

dm 7 years ago
parent
commit
1323ce3d3c

+ 2 - 1
oxygine/src/oxygine/VisualStyle.cpp

@@ -18,7 +18,7 @@ namespace oxygine
         STDMaterial mat;
         STDMaterial mat;
         mat._blend = blend_premultiplied_alpha;
         mat._blend = blend_premultiplied_alpha;
         mat._base = STDRenderer::white;
         mat._base = STDRenderer::white;
-
+        _flags |= flag_actorHasBounds;
         _mat = mc().cache(mat);
         _mat = mc().cache(mat);
     }
     }
 
 
@@ -32,6 +32,7 @@ namespace oxygine
     {
     {
         _color = color;
         _color = color;
     }
     }
+
     void VisualStyle::setBlendMode(blend_mode mode)
     void VisualStyle::setBlendMode(blend_mode mode)
     {
     {
         _blend = mode;
         _blend = mode;

+ 0 - 2
oxygine/src/oxygine/VisualStyle.h

@@ -50,8 +50,6 @@ namespace oxygine
         typedef Property<Color, const Color&, VStyleActor, &VStyleActor::getColor, &VStyleActor::setColor> TweenColor;
         typedef Property<Color, const Color&, VStyleActor, &VStyleActor::getColor, &VStyleActor::setColor> TweenColor;
         typedef Property<Color, const Color&, VStyleActor, &VStyleActor::getAddColor, &VStyleActor::setAddColor> TweenAddColor;
         typedef Property<Color, const Color&, VStyleActor, &VStyleActor::getAddColor, &VStyleActor::setAddColor> TweenAddColor;
 
 
-        bool getBounds(RectF& b) const  override { b = getDestRect();  return true; }
-
         void                    setMaterial(spSTDMaterial mat);
         void                    setMaterial(spSTDMaterial mat);
         spSTDMaterial _mat;
         spSTDMaterial _mat;
 
 

+ 10 - 0
oxygine/src/oxygine/actor/Actor.cpp

@@ -1173,6 +1173,16 @@ namespace oxygine
         }
         }
     }
     }
 
 
+    bool Actor::getBounds(RectF& bounds) const
+    {
+        if (_flags | flag_actorHasBounds)
+        {
+            bounds = getDestRect();
+            return true;
+        }
+        return false;
+    }
+
     void Actor::render(const RenderState& parentRS)
     void Actor::render(const RenderState& parentRS)
     {
     {
         _rdelegate->render(this, parentRS);
         _rdelegate->render(this, parentRS);

+ 6 - 2
oxygine/src/oxygine/actor/Actor.h

@@ -174,6 +174,9 @@ namespace oxygine
         /**Sets transparency. if alpha is 0 actor and children are completely invisible. Invisible Actor doesn't receive Touch events.*/
         /**Sets transparency. if alpha is 0 actor and children are completely invisible. Invisible Actor doesn't receive Touch events.*/
         void setAlpha(unsigned char alpha);
         void setAlpha(unsigned char alpha);
 
 
+        /**By default Actor doesn't has bounds, this will set it to Actor::getDestRect*/
+        void setHasOwnBounds(bool enable) { _flags &= ~flag_actorHasBounds; if (enable) _flags |= flag_actorHasBounds; }
+
         /**Enables/Disables Touch events for Actor.*/
         /**Enables/Disables Touch events for Actor.*/
         void setTouchEnabled(bool enabled) { _flags &= ~flag_touchEnabled; if (enabled) _flags |= flag_touchEnabled; }
         void setTouchEnabled(bool enabled) { _flags &= ~flag_touchEnabled; if (enabled) _flags |= flag_touchEnabled; }
         /**Enables/Disables Touch events for children of Actor.*/
         /**Enables/Disables Touch events for children of Actor.*/
@@ -290,7 +293,7 @@ namespace oxygine
         /**recursively removes all event listeners and added tweens*/
         /**recursively removes all event listeners and added tweens*/
         void clean();
         void clean();
 
 
-        virtual bool getBounds(RectF&) const { return false; }
+        virtual bool getBounds(RectF&) const;
 
 
     protected:
     protected:
 
 
@@ -350,7 +353,8 @@ namespace oxygine
             flag_cull                   = 1 << 6,
             flag_cull                   = 1 << 6,
             flag_fastTransform          = 1 << 7,
             flag_fastTransform          = 1 << 7,
             flag_boundsNoChildren       = 1 << 8,
             flag_boundsNoChildren       = 1 << 8,
-            flag_reserved               = 1 << 9,
+            flag_actorHasBounds      = 1 << 9,
+            flag_reserved               = 1 << 10,
             flag_last                   = flag_reserved
             flag_last                   = flag_reserved
         };
         };