Bladeren bron

Fixed a few issues with clipping gui controls

Peter Robinson 4 jaren geleden
bovenliggende
commit
09ce49f1ae

+ 0 - 12
engine/source/gui/containers/guiWindowCtrl.cc

@@ -547,18 +547,6 @@ void GuiWindowCtrl::selectWindow(void)
    setFirstResponder(mFirstResponder);
 }
 
-void GuiWindowCtrl::drawWinRect(const RectI &myRect)
-{
-   Point2I bl = myRect.point;
-   Point2I tr;
-   tr.x = myRect.point.x + myRect.extent.x - 1;
-   tr.y = myRect.point.y + myRect.extent.y - 1;
-   dglDrawRectFill(myRect, mProfile->mFillColor);
-   dglDrawLine(Point2I(bl.x + 1, tr.y), Point2I(bl.x + 1, bl.y), ColorI(255, 255, 255));
-   dglDrawLine(Point2I(bl.x, tr.y + 1), Point2I(tr.x, tr.y + 1), ColorI(255, 255, 255));
-   //dglDrawRect(myRect, ColorI(0, 0, 0)); // Taken out, this is controled via mProfile->mBorder
-}
-
 void GuiWindowCtrl::onRender(Point2I offset, const RectI &updateRect)
 {
    if( !mProfile || mProfile->mFont.isNull() || mProfile->mBitmapArrayRects.size() < NumBitmaps )

+ 0 - 3
engine/source/gui/containers/guiWindowCtrl.h

@@ -107,9 +107,6 @@ class GuiWindowCtrl : public GuiControl
       RectI *mBitmapBounds;  //bmp is [3*n], bmpHL is [3*n + 1], bmpNA is [3*n + 2]
       TextureHandle mTextureHandle;
 
-
-      void drawWinRect(const RectI &myRect);
-
    public:
       GuiWindowCtrl();
       DECLARE_CONOBJECT(GuiWindowCtrl);

+ 5 - 0
engine/source/gui/guiControl.cc

@@ -740,9 +740,11 @@ void GuiControl::renderChildControls(Point2I offset, RectI content, const RectI
 
 			 if (childClip.intersect(clipRect))
 			 {
+				RectI old = dglGetClipRect();
 				dglSetClipRect(clipRect);
 				glDisable(GL_CULL_FACE);
 				ctrl->onRender(childPosition, RectI(childPosition, ctrl->getExtent()));
+				dglSetClipRect(old);
 			 }
 		  }
 		  size_cpy = objectList.size(); //	CHRIS: i know its wierd but the size of the list changes sometimes during execution of this loop
@@ -1670,7 +1672,10 @@ void GuiControl::renderText(Point2I offset, Point2I extent, const char *text, Gu
 		rotation = -90.0f;
 	}
 
+	RectI old = dglGetClipRect();
+	dglSetClipRect(RectI(offset, extent));
 	dglDrawText( font, start + offset + profile->mTextOffset, text, profile->mFontColors, 9, rotation );
+	dglSetClipRect(old);
 }
 
 void GuiControl::getCursor(GuiCursor *&cursor, bool &showCursor, const GuiEvent &lastGuiEvent)

+ 5 - 0
engine/source/gui/guiTextEditCtrl.cc

@@ -1240,6 +1240,9 @@ void GuiTextEditCtrl::drawText( const RectI &drawRect, GuiControlState currentSt
    StringBuffer textBuffer;
    Point2I drawPoint = drawRect.point;
 
+   RectI old = dglGetClipRect();
+   dglSetClipRect(drawRect);
+
    // Just a little sanity.
    if(mCursorPos > (S32)mTextBuffer.length()) 
       mCursorPos = (S32)mTextBuffer.length();
@@ -1425,6 +1428,8 @@ void GuiTextEditCtrl::drawText( const RectI &drawRect, GuiControlState currentSt
    //draw the cursor
    if (currentState == SelectedState && mCursorOn )
       dglDrawLine( cursorStart, cursorEnd, mProfile->mCursorColor );
+
+   dglSetClipRect(old);
 }
 
 bool GuiTextEditCtrl::hasText()

+ 25 - 16
toybox/Sandbox/1/scripts/scene.cs

@@ -28,11 +28,11 @@ function createSandboxWindow()
         // Create the scene window.
         new SceneWindow(SandboxWindow);
 
-        // Set profile.        
+        // Set profile.
         SandboxWindow.Profile = SandboxWindowProfile;
-        
+
         // Push the window.
-        Canvas.setContent( SandboxWindow );                     
+        Canvas.setContent( SandboxWindow );
     }
 
     // Set camera to a canonical state.
@@ -58,7 +58,7 @@ function destroySandboxWindow()
     // Finish if no window available.
     if ( !isObject(SandboxWindow) )
         return;
-    
+
     // Delete the window.
     SandboxWindow.delete();
 }
@@ -70,19 +70,19 @@ function createSandboxScene()
     // Destroy the scene if it already exists.
     if ( isObject(SandboxScene) )
         destroySandboxScene();
-    
+
     // Create the scene.
     new Scene(SandboxScene);
-            
+
     // Sanity!
     if ( !isObject(SandboxWindow) )
     {
         error( "Sandbox: Created scene but no window available." );
         return;
     }
-        
+
     // Set window to scene.
-    setSceneToWindow();    
+    setSceneToWindow();
 }
 
 //-----------------------------------------------------------------------------
@@ -107,7 +107,7 @@ function setSceneToWindow()
         error( "Cannot set Sandbox Scene to Window as the Scene is invalid." );
         return;
     }
-    
+
      // Set scene to window.
     SandboxWindow.setScene( SandboxScene );
 
@@ -125,12 +125,12 @@ function setSceneToWindow()
     SandboxWindow.setCameraSize( 100, 75 );
     SandboxWindow.setCameraZoom( 1 );
     SandboxWindow.setCameraAngle( 0 );
-    
+
     // Update the toolbox options.
     updateToolboxOptions();
-    
+
     // reset the sandbox manipulation modes.
-    Sandbox.resetManipulationModes();       
+    Sandbox.resetManipulationModes();
 }
 
 //-----------------------------------------------------------------------------
@@ -143,13 +143,22 @@ function setCustomScene( %scene )
         error( "Cannot set Sandbox to use an invalid Scene." );
         return;
     }
-   
-    // Destroy the existing scene.  
+
+    // Destroy the existing scene.
     destroySandboxScene();
 
     // The Sandbox needs the scene to be named this.
-    %scene.setName( "SandboxScene" );    
-    
+    %scene.setName( "SandboxScene" );
+
     // Set the scene to the window.
     setSceneToWindow();
 }
+
+function SceneWindow::onExtentChange(%this)
+{
+    %extent = Canvas.extent;
+    %aspect = %extent.x / %extent.y;
+    %cam = SandboxWindow.getCameraSize();
+    %cam.x = %cam.y * %aspect;
+    %this.setCameraSize(%cam);
+}