Browse Source

add some basic zoom keybinds

main
Colin McMillen 12 months ago
parent
commit
b02647d469
  1. 33
      Program.cs

33
Program.cs

@ -232,7 +232,7 @@ public class UiGeometry {
public UiGeometry(Vector2i windowSize) {
WindowSize = windowSize;
int numThumbnails = 10;
int numThumbnails = 20;
int thumbnailHeight = WindowSize.Y / numThumbnails;
int thumbnailWidth = (int) 1.0 * thumbnailHeight * activeCamera.Resolution.X / activeCamera.Resolution.Y;
for (int i = 0; i < numThumbnails; i++) {
@ -277,6 +277,7 @@ public class Game : GameWindow {
int photoIndex = 0;
Shader shader = new();
Matrix4 projection;
float zoomLevel = 0f;
protected override void OnUpdateFrame(FrameEventArgs e) {
base.OnUpdateFrame(e);
@ -310,6 +311,30 @@ public class Game : GameWindow {
upTimer = Int64.MaxValue;
}
if (input.IsKeyDown(Keys.D0)) {
zoomLevel = 0f;
}
if (input.IsKeyDown(Keys.D1)) {
zoomLevel = 1f;
}
if (input.IsKeyDown(Keys.D2)) {
zoomLevel = 2f;
}
if (input.IsKeyDown(Keys.D3)) {
zoomLevel = 4f;
}
if (input.IsKeyDown(Keys.D4)) {
zoomLevel = 8f;
}
if (input.IsKeyDown(Keys.D5)) {
zoomLevel = 16f;
}
// FIXME: make a proper Model class for tracking the state of the controls?
if (input.IsKeyPressed(Keys.Down) || now > downTimer) {
if (photoIndex < photos.Count - 1) {
@ -361,7 +386,8 @@ public class Game : GameWindow {
// Load textures from JPEGs.
// string[] files = Directory.GetFiles(@"c:\users\colin\desktop\photos-test\");
string[] files = Directory.GetFiles(@"c:\users\colin\pictures\photos\2023\07\14\");
//string[] files = Directory.GetFiles(@"C:\Users\colin\Pictures\photos\2018\06\23");
// string[] files = Directory.GetFiles(@"C:\Users\colin\Pictures\photos\2018\06\23");
// string[] files = Directory.GetFiles(@"C:\Users\colin\Desktop\Germany all\104D7000");
for (int i = 0; i < files.Count(); i++) {
string file = files[i];
@ -391,6 +417,9 @@ public class Game : GameWindow {
float scaleX = 1f * geometry.PhotoBox.Size.X / active.Size.X;
float scaleY = 1f * geometry.PhotoBox.Size.Y / active.Size.Y;
float scale = Math.Min(scaleX, scaleY);
if (zoomLevel > 0f) {
scale = zoomLevel;
}
Vector2i renderSize = (Vector2i) (((Vector2) active.Size) * scale);
Vector2i center = (Vector2i) geometry.PhotoBox.Center;

Loading…
Cancel
Save