Ver código fonte

Prevents a control's clearBounds from having a width or height less than zero.
Disables selective container clearing as it can cause parts of a form not to be drawn. We can turn this back on later with a little bit of work.

Adam Blake 13 anos atrás
pai
commit
d9bcfe45db
2 arquivos alterados com 12 adições e 7 exclusões
  1. 3 3
      gameplay/src/Control.cpp
  2. 9 4
      gameplay/src/Form.cpp

+ 3 - 3
gameplay/src/Control.cpp

@@ -951,9 +951,9 @@ void Control::update(const Control* container, const Vector2& offset)
  
  
     _viewportClipBounds.set(x, y, width, height);
     _viewportClipBounds.set(x, y, width, height);
 
 
-    _absoluteClipBounds.set(x - border.left - padding.left, y - border.top - padding.top,
-        width + border.left + padding.left + border.right + padding.right,
-        height + border.top + padding.top + border.bottom + padding.bottom);
+    width += border.left + padding.left + border.right + padding.right;
+    height += border.top + padding.top + border.bottom + padding.bottom;
+    _absoluteClipBounds.set(x - border.left - padding.left, y - border.top - padding.top, max(width, 0.0f), max(height, 0.0f));
     if (_clearBounds.isEmpty())
     if (_clearBounds.isEmpty())
     {
     {
         _clearBounds.set(_absoluteClipBounds);
         _clearBounds.set(_absoluteClipBounds);

+ 9 - 4
gameplay/src/Form.cpp

@@ -546,20 +546,25 @@ void Form::draw()
 
 
         GP_ASSERT(_theme);
         GP_ASSERT(_theme);
         _theme->setProjectionMatrix(_projectionMatrix);
         _theme->setProjectionMatrix(_projectionMatrix);
+        
+        // By setting needsClear to true here, an optimization meant to clear and redraw only areas of the form
+        // that have changed is disabled.  Currently, repositioning controls can result in areas of the screen being cleared
+        // after another control has been drawn there.  This should probably be done in two passes -- one to clear areas where
+        // dirty controls were last frame, and another to draw them where they are now.
         Container::draw(_theme->getSpriteBatch(), Rectangle(0, 0, _bounds.width, _bounds.height),
         Container::draw(_theme->getSpriteBatch(), Rectangle(0, 0, _bounds.width, _bounds.height),
-                        _skin != NULL, false, _bounds.height);
+                        /*_skin != NULL*/ true, false, _bounds.height);
         _theme->setProjectionMatrix(_defaultProjectionMatrix);
         _theme->setProjectionMatrix(_defaultProjectionMatrix);
 
 
-        // restore the previous game viewport
+        // Restore the previous game viewport.
         game->setViewport(prevViewport);
         game->setViewport(prevViewport);
         // Rebind the previous framebuffer and game viewport.
         // Rebind the previous framebuffer and game viewport.
         previousFrameBuffer->bind();
         previousFrameBuffer->bind();
     }
     }
 
 
-    // Draw either with a 3D quad or sprite batch
+    // Draw either with a 3D quad or sprite batch.
     if (_node)
     if (_node)
     {
     {
-         // If we have the node set, then draw a 3D quad model
+         // If we have the node set, then draw a 3D quad model.
         _nodeQuad->draw();
         _nodeQuad->draw();
     }
     }
     else
     else