add StatusBox geometry and draw it

This commit is contained in:
Colin McMillen 2023-07-24 13:14:07 -04:00
parent a0d6267905
commit 56311bc56c

View File

@ -234,6 +234,7 @@ public class UiGeometry {
public readonly Vector2i WindowSize;
public readonly List<Box2i> ThumbnailBoxes = new();
public readonly Box2i PhotoBox;
public readonly Box2i StatusBox;
public UiGeometry() : this(MIN_WINDOW_SIZE) {}
@ -248,7 +249,10 @@ public class UiGeometry {
ThumbnailBoxes.Add(box);
}
PhotoBox = new Box2i(0, 0, WindowSize.X - thumbnailWidth, WindowSize.Y);
int statusBoxHeight = 20;
int statusBoxPadding = 4;
PhotoBox = new Box2i(0, 0, WindowSize.X - thumbnailWidth, WindowSize.Y - statusBoxHeight - statusBoxPadding);
StatusBox = new Box2i(0, WindowSize.Y - statusBoxHeight, WindowSize.X - thumbnailWidth, WindowSize.Y);
}
}
@ -468,6 +472,15 @@ public class Game : GameWindow {
}
Vector2i renderSize = (Vector2i) (((Vector2) active.Size) * scale);
// FIXME: clip by the actual PhotoBox size -- this bleeds over UI elements when zoomed in.
// This doesn't work -- boo.
// if (renderSize.X > geometry.PhotoBox.Size.X) {
// renderSize.X = geometry.PhotoBox.Size.X;
// }
// if (renderSize.Y > geometry.PhotoBox.Size.Y) {
// renderSize.Y = geometry.PhotoBox.Size.Y;
// }
Vector2i center = (Vector2i) geometry.PhotoBox.Center;
Box2i photoBox = Util.MakeBox(center.X - renderSize.X / 2, center.Y - renderSize.Y / 2, renderSize.X, renderSize.Y);
DrawTexture(active, photoBox);
@ -480,9 +493,10 @@ public class Game : GameWindow {
}
}
DrawText(activePhoto.File, 10, 10);
// Draw status box.
DrawText(activePhoto.File, geometry.StatusBox.Min.X + 80, geometry.StatusBox.Min.Y);
if (activePhoto.Loaded) {
DrawText($"zoom: {(scale * 100):F1}%", 10, 30);
DrawText($"{(scale * 100):F1}%", geometry.StatusBox.Min.X, geometry.StatusBox.Min.Y);
}
SwapBuffers();