skeleton for StraightenTool

This commit is contained in:
Colin McMillen 2023-09-15 10:28:24 -04:00
parent 389ab12fb2
commit f306fc3bc9
2 changed files with 44 additions and 0 deletions

View File

@ -105,6 +105,7 @@ public class Photo {
public GpsInfo? Gps = null;
public Rectangle CropRectangle = Rectangle.Empty;
public Vector2i ViewOffset = Vector2i.Zero;
public float Rotation = 0;
private static long touchCounter = 0;
private Texture texture;

View File

@ -261,6 +261,46 @@ public class CropTool : ITool {
}
public class StraightenTool : ITool {
Photo photo;
float initialRotation;
public StraightenTool(Photo photo) {
this.photo = photo;
initialRotation = photo.Rotation;
}
public ToolStatus HandleInput(KeyboardState input, MouseState mouse, Transform transform, Game game, Photo photo, UiGeometry geometry) {
if (input.IsKeyPressed(Keys.Left)) {
photo.Rotation += 1;
}
if (input.IsKeyPressed(Keys.Right)) {
photo.Rotation -= 1;
}
if (input.IsKeyPressed(Keys.Enter)) {
return ToolStatus.Done;
}
if (input.IsKeyPressed(Keys.Escape)) {
photo.Rotation = initialRotation;
return ToolStatus.Canceled;
}
return ToolStatus.Active;
}
public void Draw(UiGeometry geometry, Game game) {
}
public string Status() {
return String.Format("[straighten] {0}", photo.Rotation);
}
}
public class UiGeometry {
public static Vector2i MIN_WINDOW_SIZE = new(1024, 768);
@ -678,6 +718,9 @@ public class Game : GameWindow {
if (input.IsKeyPressed(Keys.C)) {
activeTool = new CropTool(photos[photoIndex]);
}
if (input.IsKeyPressed(Keys.S)) {
activeTool = new StraightenTool(photos[photoIndex]);
}
}
// Delegate input to the active tool.