more crop progress
This commit is contained in:
parent
190dda46d4
commit
e5c1b01806
30
Program.cs
30
Program.cs
@ -639,6 +639,7 @@ public class Game : GameWindow {
|
||||
int ribbonIndex = 0;
|
||||
Vector2i mouseDragStart;
|
||||
Vector2i mouseDragEnd;
|
||||
float activeScale = 1f;
|
||||
Shader shader = new();
|
||||
Matrix4 projection;
|
||||
float zoomLevel = 0f;
|
||||
@ -737,6 +738,11 @@ public class Game : GameWindow {
|
||||
photoIndex -= 5;
|
||||
}
|
||||
|
||||
// FIXME: crop should be a modal tool that starts with C and ends with Enter or Escape.
|
||||
if (input.IsKeyPressed(Keys.C)) {
|
||||
ApplyCrop();
|
||||
}
|
||||
|
||||
if (input.IsKeyPressed(Keys.P) && altIsDown) {
|
||||
ExportPhotos();
|
||||
}
|
||||
@ -993,7 +999,11 @@ public class Game : GameWindow {
|
||||
SwapBuffers();
|
||||
}
|
||||
|
||||
void DrawCropBox() {
|
||||
// left, right, top, bottom
|
||||
(int, int, int, int) GetCrop() {
|
||||
// FIXME: this expects the start point in the top left and the end point
|
||||
// in the bottom right; some sign flipping needs to occur to make anchors
|
||||
// in other direction work well.
|
||||
Vector2i start = mouseDragStart;
|
||||
Vector2i end = mouseDragEnd;
|
||||
end.Y = Math.Min(end.Y, start.Y + (end.X - start.X) * 4 / 6);
|
||||
@ -1002,6 +1012,20 @@ public class Game : GameWindow {
|
||||
int right = Math.Max(start.X, end.X);
|
||||
int top = Math.Min(start.Y, end.Y);
|
||||
int bottom = Math.Max(start.Y, end.Y);
|
||||
return (left, right, top, bottom);
|
||||
}
|
||||
|
||||
void ApplyCrop() {
|
||||
var (left, right, top, bottom) = GetCrop();
|
||||
int area = (right - left) * (bottom - top);
|
||||
if (area < 100) {
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void DrawCropBox() {
|
||||
var (left, right, top, bottom) = GetCrop();
|
||||
int area = (right - left) * (bottom - top);
|
||||
|
||||
if (area < 100) {
|
||||
@ -1032,10 +1056,12 @@ public class Game : GameWindow {
|
||||
if (zoomLevel > 0f) {
|
||||
scale = zoomLevel;
|
||||
}
|
||||
activeScale = scale;
|
||||
|
||||
Vector2i renderSize = (Vector2i) (((Vector2) active.Size) * scale);
|
||||
Vector2i center = (Vector2i) geometry.PhotoBox.Center;
|
||||
Box2i photoBox = Util.MakeBox(center.X - renderSize.X / 2, center.Y - renderSize.Y / 2, renderSize.X, renderSize.Y);
|
||||
// Box2i photoBox = Util.MakeBox(center.X - renderSize.X / 2, center.Y - renderSize.Y / 2, renderSize.X, renderSize.Y);
|
||||
Box2i photoBox = Util.MakeBox(0, 0, renderSize.X, renderSize.Y);
|
||||
DrawTexture(active, photoBox);
|
||||
for (int i = 0; i < 5; i++) {
|
||||
Texture star = (activePhoto.Rating > i) ? STAR_FILLED : STAR_EMPTY;
|
||||
|
Loading…
Reference in New Issue
Block a user