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