Browse Source

skeleton for StraightenTool

main
Colin McMillen 8 months ago
parent
commit
f306fc3bc9
  1. 1
      Photo.cs
  2. 43
      Program.cs

1
Photo.cs

@ -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;

43
Program.cs

@ -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.

Loading…
Cancel
Save