tableBounds.height = height;\r
Stage stage = this.stage;\r
Rectangle scissorBounds = Pools.obtain(Rectangle.class);\r
- ScissorStack.calculateScissors(stage.getCamera(), stage.getSpriteBatch().getTransformMatrix(), tableBounds, scissorBounds);\r
+ stage.calculateScissors(tableBounds, scissorBounds);\r
if (ScissorStack.pushScissors(scissorBounds)) return true;\r
Pools.free(scissorBounds);\r
return false;\r
import com.badlogic.gdx.graphics.OrthographicCamera;\r
import com.badlogic.gdx.graphics.g2d.SpriteBatch;\r
import com.badlogic.gdx.math.Matrix4;\r
+import com.badlogic.gdx.math.Rectangle;\r
import com.badlogic.gdx.math.Vector2;\r
import com.badlogic.gdx.math.Vector3;\r
import com.badlogic.gdx.scenes.scene2d.InputEvent.Type;\r
\r
/** Applies a touch down event to the stage and returns true if an actor in the scene {@link Event#handle() handled} the event. */\r
public boolean touchDown (int screenX, int screenY, int pointer, int button) {\r
+ if (screenX < viewportX || screenX >= viewportX + viewportWidth) return false;\r
+ if (screenY < viewportY || screenY >= viewportY + viewportHeight) return false;\r
+\r
pointerTouched[pointer] = true;\r
pointerScreenX[pointer] = screenX;\r
pointerScreenY[pointer] = screenY;\r
/** Applies a mouse moved event to the stage and returns true if an actor in the scene {@link Event#handle() handled} the event.\r
* This event only occurs on the desktop. */\r
public boolean mouseMoved (int screenX, int screenY) {\r
+ if (screenX < viewportX || screenX >= viewportX + viewportWidth) return false;\r
+ if (screenY < viewportY || screenY >= viewportY + viewportHeight) return false;\r
+\r
mouseScreenX = screenX;\r
mouseScreenY = screenY;\r
\r
return coords;\r
}\r
\r
+ public void calculateScissors (Rectangle area, Rectangle scissor) {\r
+ ScissorStack.calculateScissors(camera, viewportX, viewportY, viewportWidth, viewportHeight, batch.getTransformMatrix(),\r
+ area, scissor);\r
+ }\r
+\r
public void dispose () {\r
clear();\r
if (ownsBatch) batch.dispose();\r
\r
// Caculate the scissor bounds based on the batch transform, the available widget area and the camera transform. We need to\r
// project those to screen coordinates for OpenGL ES to consume.\r
- ScissorStack.calculateScissors(getStage().getCamera(), batch.getTransformMatrix(), widgetAreaBounds, scissorBounds);\r
+ getStage().calculateScissors(widgetAreaBounds, scissorBounds);\r
\r
// Draw the background ninepatch.\r
Color color = getColor();\r
applyTransform(batch, computeTransform());\r
Matrix4 transform = batch.getTransformMatrix();\r
if (firstWidget != null) {\r
- ScissorStack.calculateScissors(getStage().getCamera(), transform, firstWidgetBounds, firstScissors);\r
+ getStage().calculateScissors(firstWidgetBounds, firstScissors);\r
if (ScissorStack.pushScissors(firstScissors)) {\r
if (firstWidget.isVisible()) firstWidget.draw(batch, parentAlpha * color.a);\r
batch.flush();\r
}\r
}\r
if (secondWidget != null) {\r
- ScissorStack.calculateScissors(getStage().getCamera(), transform, secondWidgetBounds, secondScissors);\r
+ getStage().calculateScissors(secondWidgetBounds, secondScissors);\r
if (ScissorStack.pushScissors(secondScissors)) {\r
if (secondWidget.isVisible()) secondWidget.draw(batch, parentAlpha * color.a);\r
batch.flush();\r
* @param batchTransform the transformation {@link Matrix4}\r
* @param area the {@link Rectangle} to transform to window coordinates\r
* @param scissor the Rectangle to store the result in */\r
- public static void calculateScissors (Camera camera, Matrix4 batchTransform, Rectangle area, Rectangle scissor) {\r
+ public static void calculateScissors (Camera camera, float viewportX, float viewportY, float viewportWidth,\r
+ float viewportHeight, Matrix4 batchTransform, Rectangle area, Rectangle scissor) {\r
tmp.set(area.x, area.y, 0);\r
tmp.mul(batchTransform);\r
- camera.project(tmp);\r
+ camera.project(tmp, viewportX, viewportY, viewportWidth, viewportHeight);\r
scissor.x = tmp.x;\r
scissor.y = tmp.y;\r
\r
tmp.set(area.x + area.width, area.y + area.height, 0);\r
tmp.mul(batchTransform);\r
- camera.project(tmp);\r
+ camera.project(tmp, viewportX, viewportY, viewportWidth, viewportHeight);\r
scissor.width = tmp.x - scissor.x;\r
scissor.height = tmp.y - scissor.y;\r
}\r
\r
public void resize (int width, int height) {\r
stage.setViewport(width, height, false);\r
+\r
+ // Gdx.gl.glViewport(100, 100, width - 200, height - 200);\r
+ // stage.setViewport(800, 600, false, 100, 100, width - 200, height - 200);\r
}\r
\r
public void dispose () {\r