diff --git a/Program.cs b/Program.cs index 2d59fff..319e6b9 100644 --- a/Program.cs +++ b/Program.cs @@ -143,24 +143,24 @@ void main() { // FIXME: this should probably be IDisposable? public class Photo { public bool Loaded = false; - private string file; + public string File; private Texture texture; private Texture placeholder; private Image? image = null; public Photo(string file, Texture placeholder) { - this.file = file; + File = file; this.placeholder = placeholder; texture = placeholder; } public async void Load() { - image = await Image.LoadAsync(file); + image = await Image.LoadAsync(File); ExifProfile? exifs = image.Metadata.ExifProfile; if (exifs != null) { foreach (IExifValue exif in exifs.Values) { if (exif.Tag.ToString() == "Model") { - Console.WriteLine($"{file} {exif.Tag}: {exif.GetValue()}"); + Console.WriteLine($"{File} {exif.Tag}: {exif.GetValue()}"); } } } @@ -456,7 +456,8 @@ public class Game : GameWindow { GL.BindBuffer(BufferTarget.ArrayBuffer, VertexBufferObject); GL.ActiveTexture(TextureUnit.Texture0); - Texture active = photos[photoIndex].Texture(); + Photo activePhoto = photos[photoIndex]; + Texture active = activePhoto.Texture(); // FIXME: make a function for scaling & centering one box on another. float scaleX = 1f * geometry.PhotoBox.Size.X / active.Size.X; @@ -478,10 +479,10 @@ public class Game : GameWindow { DrawBox(box, 3, Color4.White); } } - if (photos[photoIndex].Loaded) { - Texture label = Util.RenderText($"zoom: {(scale * 100):F1}%"); - DrawTexture(label, Util.MakeBox(10, 10, label.Size.X, label.Size.Y)); - label.Dispose(); + + DrawText(activePhoto.File, 10, 10); + if (activePhoto.Loaded) { + DrawText($"zoom: {(scale * 100):F1}%", 10, 30); } SwapBuffers(); @@ -506,6 +507,12 @@ public class Game : GameWindow { DrawTexture(TEXTURE_WHITE, Util.MakeBox(box.Max.X - thickness, box.Min.Y, thickness, box.Size.Y), color); } + void DrawText(string text, int x, int y) { + Texture label = Util.RenderText(text); + DrawTexture(label, Util.MakeBox(x, y, label.Size.X, label.Size.Y)); + label.Dispose(); + } + protected override void OnResize(ResizeEventArgs e) { base.OnResize(e); Console.WriteLine($"OnResize: {e.Width}x{e.Height}");