Java Code Examples for com.badlogic.gdx.scenes.scene2d.utils.ScissorStack#pushScissors()

The following examples show how to use com.badlogic.gdx.scenes.scene2d.utils.ScissorStack#pushScissors() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PagePreviewCanvas.java    From gdx-texture-packer-gui with Apache License 2.0 5 votes vote down vote up
@Override
public void draw(Batch batch, float parentAlpha) {
	batch.flush();
	getStage().calculateScissors(widgetAreaBounds.set(getX(), getY(), getWidth(), getHeight()), scissorBounds);
	if (ScissorStack.pushScissors(scissorBounds)) {
		super.draw(batch, parentAlpha);
		batch.flush();
		ScissorStack.popScissors();
	}
}
 
Example 2
Source File: ScrollPane.java    From riiablo with Apache License 2.0 5 votes vote down vote up
@Override
public void draw (Batch batch, float parentAlpha) {
	if (widget == null) return;

	validate();

	// Setup transform for this group.
	applyTransform(batch, computeTransform());

	if (scrollX) hKnobBounds.x = hScrollBounds.x + (int)((hScrollBounds.width - hKnobBounds.width) * getVisualScrollPercentX());
	if (scrollY)
		vKnobBounds.y = vScrollBounds.y + (int)((vScrollBounds.height - vKnobBounds.height) * (1 - getVisualScrollPercentY()));

	updateWidgetPosition();

	// Draw the background ninepatch.
	Color color = getColor();
	batch.setColor(color.r, color.g, color.b, color.a * parentAlpha);
	if (style.background != null) style.background.draw(batch, 0, 0, getWidth(), getHeight());

	// Caculate the scissor bounds based on the batch transform, the available widget area and the camera transform. We need to
	// project those to screen coordinates for OpenGL ES to consume.
	getStage().calculateScissors(widgetAreaBounds, scissorBounds);

	// Enable scissors for widget area and draw the widget.
	batch.flush();
	if (ScissorStack.pushScissors(scissorBounds)) {
		drawChildren(batch, parentAlpha);
		batch.flush();
		ScissorStack.popScissors();
	}

	// Render scrollbars and knobs on top if they will be visible
	float alpha = color.a * parentAlpha * Interpolation.fade.apply(fadeAlpha / fadeAlphaSeconds);
	drawScrollBars(batch, color.r, color.g, color.b, alpha);

	resetTransform(batch);
}
 
Example 3
Source File: ScrollPane.java    From riiablo with Apache License 2.0 5 votes vote down vote up
public void drawDebug (ShapeRenderer shapes) {
	shapes.flush();
	applyTransform(shapes, computeTransform());
	if (ScissorStack.pushScissors(scissorBounds)) {
		drawDebugChildren(shapes);
		ScissorStack.popScissors();
	}
	resetTransform(shapes);
}
 
Example 4
Source File: MundusSplitPane.java    From Mundus with Apache License 2.0 5 votes vote down vote up
@Override
public void draw(Batch batch, float parentAlpha) {
    validate();

    Color color = getColor();

    applyTransform(batch, computeTransform());
    // Matrix4 transform = batch.getTransformMatrix();
    if (firstWidget != null) {
        getStage().calculateScissors(firstWidgetBounds, firstScissors);
        if (ScissorStack.pushScissors(firstScissors)) {
            if (firstWidget.isVisible()) firstWidget.draw(batch, parentAlpha * color.a);
            batch.flush();
            ScissorStack.popScissors();
        }
    }
    if (secondWidget != null) {
        getStage().calculateScissors(secondWidgetBounds, secondScissors);
        if (ScissorStack.pushScissors(secondScissors)) {
            if (secondWidget.isVisible()) secondWidget.draw(batch, parentAlpha * color.a);
            batch.flush();
            ScissorStack.popScissors();
        }
    }

    Drawable handle = style.handle;
    if (mouseOnHandle && isTouchable() && style.handleOver != null) handle = style.handleOver;
    batch.setColor(color.r, color.g, color.b, parentAlpha * color.a);
    handle.draw(batch, handleBounds.x, handleBounds.y, handleBounds.width, handleBounds.height);
    resetTransform(batch);

}
 
Example 5
Source File: MundusMultiSplitPane.java    From Mundus with Apache License 2.0 5 votes vote down vote up
@Override
public void draw(Batch batch, float parentAlpha) {
    validate();

    Color color = getColor();

    applyTransform(batch, computeTransform());

    SnapshotArray<Actor> actors = getChildren();
    for (int i = 0; i < actors.size; i++) {
        Actor actor = actors.get(i);
        Rectangle bounds = widgetBounds.get(i);
        Rectangle scissor = scissors.get(i);
        getStage().calculateScissors(bounds, scissor);
        if (ScissorStack.pushScissors(scissor)) {
            if (actor.isVisible()) actor.draw(batch, parentAlpha * color.a);
            batch.flush();
            ScissorStack.popScissors();
        }
    }

    batch.setColor(color.r, color.g, color.b, parentAlpha * color.a);

    Drawable handle = style.handle;
    Drawable handleOver = style.handle;
    if (isTouchable() && style.handleOver != null) handleOver = style.handleOver;
    for (Rectangle rect : handleBounds) {
        if (this.handleOver == rect) {
            handleOver.draw(batch, rect.x, rect.y, rect.width, rect.height);
        } else {
            handle.draw(batch, rect.x, rect.y, rect.width, rect.height);
        }
    }
    resetTransform(batch);
}
 
Example 6
Source File: MultiSplitPane.java    From vis-ui with Apache License 2.0 5 votes vote down vote up
@Override
public void draw (Batch batch, float parentAlpha) {
	validate();

	Color color = getColor();

	applyTransform(batch, computeTransform());

	SnapshotArray<Actor> actors = getChildren();
	for (int i = 0; i < actors.size; i++) {
		Actor actor = actors.get(i);
		Rectangle bounds = widgetBounds.get(i);
		Rectangle scissor = scissors.get(i);
		getStage().calculateScissors(bounds, scissor);
		if (ScissorStack.pushScissors(scissor)) {
			if (actor.isVisible()) actor.draw(batch, parentAlpha * color.a);
			batch.flush();
			ScissorStack.popScissors();
		}
	}

	batch.setColor(color.r, color.g, color.b, parentAlpha * color.a);

	Drawable handle = style.handle;
	Drawable handleOver = style.handle;
	if (isTouchable() && style.handleOver != null) handleOver = style.handleOver;
	for (Rectangle rect : handleBounds) {
		if (this.handleOver == rect) {
			handleOver.draw(batch, rect.x, rect.y, rect.width, rect.height);
		} else {
			handle.draw(batch, rect.x, rect.y, rect.width, rect.height);
		}
	}
	resetTransform(batch);
}
 
Example 7
Source File: VisSplitPane.java    From vis-ui with Apache License 2.0 5 votes vote down vote up
@Override
public void draw (Batch batch, float parentAlpha) {
	validate();

	Color color = getColor();

	applyTransform(batch, computeTransform());
	// Matrix4 transform = batch.getTransformMatrix();
	if (firstWidget != null) {
		getStage().calculateScissors(firstWidgetBounds, firstScissors);
		if (ScissorStack.pushScissors(firstScissors)) {
			if (firstWidget.isVisible()) firstWidget.draw(batch, parentAlpha * color.a);
			batch.flush();
			ScissorStack.popScissors();
		}
	}
	if (secondWidget != null) {
		getStage().calculateScissors(secondWidgetBounds, secondScissors);
		if (ScissorStack.pushScissors(secondScissors)) {
			if (secondWidget.isVisible()) secondWidget.draw(batch, parentAlpha * color.a);
			batch.flush();
			ScissorStack.popScissors();
		}
	}

	Drawable handle = style.handle;
	if (mouseOnHandle && isTouchable() && style.handleOver != null) handle = style.handleOver;
	batch.setColor(color.r, color.g, color.b, parentAlpha * color.a);
	handle.draw(batch, handleBounds.x, handleBounds.y, handleBounds.width, handleBounds.height);
	resetTransform(batch);

}