make the ribbon actually scroll down off the page etc
This commit is contained in:
parent
f9aeb81313
commit
3cf125fba7
23
Program.cs
23
Program.cs
@ -286,6 +286,9 @@ public class Photo {
|
|||||||
|
|
||||||
public Texture Texture() {
|
public Texture Texture() {
|
||||||
if (texture == placeholder && image != null) {
|
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);
|
texture = new Texture(image);
|
||||||
image.Dispose();
|
image.Dispose();
|
||||||
image = null;
|
image = null;
|
||||||
@ -365,7 +368,7 @@ public class UiGeometry {
|
|||||||
public UiGeometry(Vector2i windowSize) {
|
public UiGeometry(Vector2i windowSize) {
|
||||||
WindowSize = windowSize;
|
WindowSize = windowSize;
|
||||||
|
|
||||||
int numThumbnails = 13;
|
int numThumbnails = 20;
|
||||||
int thumbnailHeight = WindowSize.Y / numThumbnails;
|
int thumbnailHeight = WindowSize.Y / numThumbnails;
|
||||||
int thumbnailWidth = (int) 1.0 * thumbnailHeight * activeCamera.Resolution.X / activeCamera.Resolution.Y;
|
int thumbnailWidth = (int) 1.0 * thumbnailHeight * activeCamera.Resolution.X / activeCamera.Resolution.Y;
|
||||||
for (int i = 0; i < numThumbnails; i++) {
|
for (int i = 0; i < numThumbnails; i++) {
|
||||||
@ -467,6 +470,7 @@ public class Game : GameWindow {
|
|||||||
int VertexArrayObject;
|
int VertexArrayObject;
|
||||||
List<Photo> photos = new();
|
List<Photo> photos = new();
|
||||||
int photoIndex = 0;
|
int photoIndex = 0;
|
||||||
|
int ribbonIndex = 0;
|
||||||
Shader shader = new();
|
Shader shader = new();
|
||||||
Matrix4 projection;
|
Matrix4 projection;
|
||||||
float zoomLevel = 0f;
|
float zoomLevel = 0f;
|
||||||
@ -477,6 +481,7 @@ public class Game : GameWindow {
|
|||||||
|
|
||||||
KeyboardState input = KeyboardState;
|
KeyboardState input = KeyboardState;
|
||||||
|
|
||||||
|
// FIXME: add a confirm dialog before closing. (Also for the window-close button.)
|
||||||
// Close when Escape is pressed.
|
// Close when Escape is pressed.
|
||||||
if (input.IsKeyDown(Keys.Escape)) {
|
if (input.IsKeyDown(Keys.Escape)) {
|
||||||
Close();
|
Close();
|
||||||
@ -487,9 +492,7 @@ public class Game : GameWindow {
|
|||||||
for (int i = 0; i < geometry.ThumbnailBoxes.Count; i++) {
|
for (int i = 0; i < geometry.ThumbnailBoxes.Count; i++) {
|
||||||
Box2i box = geometry.ThumbnailBoxes[i];
|
Box2i box = geometry.ThumbnailBoxes[i];
|
||||||
if (box.ContainsInclusive((Vector2i) MouseState.Position)) {
|
if (box.ContainsInclusive((Vector2i) MouseState.Position)) {
|
||||||
if (0 <= i && i < photos.Count) {
|
photoIndex = Math.Clamp(ribbonIndex + i, 0, photos.Count - 1);
|
||||||
photoIndex = i;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -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(); });
|
await Task.Run( () => { photos[i].Load(); });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -627,11 +630,15 @@ public class Game : GameWindow {
|
|||||||
DrawTexture(active, photoBox);
|
DrawTexture(active, photoBox);
|
||||||
|
|
||||||
// Draw thumbnail boxes.
|
// 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);
|
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];
|
Box2i box = geometry.ThumbnailBoxes[i];
|
||||||
DrawTexture(photos[i].Texture(), box);
|
DrawTexture(photos[ribbonIndex + i].Texture(), box);
|
||||||
if (i == photoIndex) {
|
if (ribbonIndex + i == photoIndex) {
|
||||||
DrawBox(box, 5, Color4.Black);
|
DrawBox(box, 5, Color4.Black);
|
||||||
DrawBox(box, 3, Color4.White);
|
DrawBox(box, 3, Color4.White);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user