Animate selection rectangle

This commit is contained in:
MiChinao
2020-08-26 23:46:12 +02:00
parent 95faeeffa4
commit 8313cda7bc
4 changed files with 10 additions and 21 deletions
Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 KiB

@@ -314,11 +314,8 @@ public class Sandbox {
return sceneControl.getCurrentScene();
}
public void prepareSelectionRectangle(float x, float y, boolean setOpacity) {
// space is panning, so if we are not, then prepare the selection rectangle
if (setOpacity) {
selectionRec.setOpacity(0.6f);
}
public void prepareSelectionRectangle(float x, float y) {
selectionRec.setOpacity(0.8f);
selectionRec.setWidth(0);
selectionRec.setHeight(0);
selectionRec.setX(x);
@@ -23,6 +23,8 @@ import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input;
import com.badlogic.gdx.graphics.OrthographicCamera;
import com.badlogic.gdx.math.*;
import com.badlogic.gdx.scenes.scene2d.Action;
import com.badlogic.gdx.scenes.scene2d.actions.Actions;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.viewport.Viewport;
import com.kotcrab.vis.ui.util.OsUtils;
@@ -105,18 +107,11 @@ public class SelectionTool extends SimpleTool {
public boolean stageMouseDown(float x, float y) {
sandbox = Sandbox.getInstance();
boolean setOpacity = false;
//TODO: Anyone can explain what was the purpose of this?
if (!Gdx.input.isKeyPressed(Input.Keys.SPACE)) {
setOpacity = true;
}
// transform stage coordinates to screen coordinates
Vector2 screenCoords = Sandbox.getInstance().worldToScreen(x, y);
// preparing selection tool rectangle to follow mouse
sandbox.prepareSelectionRectangle(screenCoords.x, screenCoords.y, setOpacity);
sandbox.prepareSelectionRectangle(screenCoords.x, screenCoords.y);
return true;
}
@@ -19,19 +19,19 @@
package games.rednblack.editor.view.ui.widget.actors.basic;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.math.Interpolation;
import com.badlogic.gdx.math.Rectangle;
import com.badlogic.gdx.scenes.scene2d.Group;
import com.badlogic.gdx.scenes.scene2d.actions.Actions;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import games.rednblack.editor.HyperLap2DFacade;
import games.rednblack.editor.proxy.EditorTextureManager;
import games.rednblack.editor.proxy.ProjectManager;
public class PixelRect extends Group {
private final HyperLap2DFacade facade;
private final ProjectManager projectManager;
private PixelLine[] lines = new PixelLine[4];
private Image fill;
private final PixelLine[] lines = new PixelLine[4];
private final Image fill;
public PixelRect() {
this(0, 0);
@@ -39,7 +39,6 @@ public class PixelRect extends Group {
public PixelRect(float width, float height) {
facade = HyperLap2DFacade.getInstance();
projectManager = facade.retrieveProxy(ProjectManager.NAME);
EditorTextureManager tm = facade.retrieveProxy(EditorTextureManager.NAME);
lines[0] = new PixelLine(tm, 0, 0, width, 0);
lines[1] = new PixelLine(tm, 0, 0, 0, height);
@@ -95,9 +94,7 @@ public class PixelRect extends Group {
}
public void setOpacity(float opacity) {
Color clr = getColor();
clr.a = opacity;
setColor(clr);
addAction(Actions.alpha(opacity, 0.3f, Interpolation.exp5Out));
}
public Rectangle getRect() {