Browse Source

make the ribbon actually scroll down off the page etc

main
Colin McMillen 12 months ago
parent
commit
3cf125fba7
  1. 23
      Program.cs

23
Program.cs

@ -286,6 +286,9 @@ public class Photo {
public Texture Texture() {
if (texture == placeholder && image != null) {
// The texture needs to be created on the GL thread, so we instantiate
// it here (since this is called from OnRenderFrame), as long as the
// image is ready to go.
texture = new Texture(image);
image.Dispose();
image = null;
@ -365,7 +368,7 @@ public class UiGeometry {
public UiGeometry(Vector2i windowSize) {
WindowSize = windowSize;
int numThumbnails = 13;
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++) {
@ -467,6 +470,7 @@ public class Game : GameWindow {
int VertexArrayObject;
List<Photo> photos = new();
int photoIndex = 0;
int ribbonIndex = 0;
Shader shader = new();
Matrix4 projection;
float zoomLevel = 0f;
@ -477,6 +481,7 @@ public class Game : GameWindow {
KeyboardState input = KeyboardState;
// FIXME: add a confirm dialog before closing. (Also for the window-close button.)
// Close when Escape is pressed.
if (input.IsKeyDown(Keys.Escape)) {
Close();
@ -487,9 +492,7 @@ public class Game : GameWindow {
for (int i = 0; i < geometry.ThumbnailBoxes.Count; i++) {
Box2i box = geometry.ThumbnailBoxes[i];
if (box.ContainsInclusive((Vector2i) MouseState.Position)) {
if (0 <= i && i < photos.Count) {
photoIndex = i;
}
photoIndex = Math.Clamp(ribbonIndex + i, 0, photos.Count - 1);
}
}
}
@ -594,7 +597,7 @@ public class Game : GameWindow {
}
}
for (int i = 0; i < 100 && i < photos.Count; i++) {
for (int i = 0; i < 40 && i < photos.Count; i++) {
await Task.Run( () => { photos[i].Load(); });
}
}
@ -627,11 +630,15 @@ public class Game : GameWindow {
DrawTexture(active, photoBox);
// Draw thumbnail boxes.
ribbonIndex = Math.Clamp(photoIndex - (geometry.ThumbnailBoxes.Count - 1) / 2, 0, Math.Max(0, photos.Count - geometry.ThumbnailBoxes.Count));
DrawFilledBox(geometry.ThumbnailBox, Color4.Black);
for (int i = 0; i < photos.Count && i < geometry.ThumbnailBoxes.Count(); i++) {
for (int i = 0; i < geometry.ThumbnailBoxes.Count; i++) {
if (ribbonIndex + i >= photos.Count) {
break;
}
Box2i box = geometry.ThumbnailBoxes[i];
DrawTexture(photos[i].Texture(), box);
if (i == photoIndex) {
DrawTexture(photos[ribbonIndex + i].Texture(), box);
if (ribbonIndex + i == photoIndex) {
DrawBox(box, 5, Color4.Black);
DrawBox(box, 3, Color4.White);
}

Loading…
Cancel
Save