mirror of
https://github.com/Stone-Red-Code/RemSox.git
synced 2026-09-06 15:56:29 +02:00
Implement z-index for windows and ensure correct stacking order on interaction
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using RemSox.Processing;
|
||||
using RemSox.UI.GUI.Rendering;
|
||||
|
||||
@@ -12,6 +14,7 @@ public static class WindowManager
|
||||
private static readonly ConcurrentDictionary<int, List<Window>> windows = new();
|
||||
|
||||
private static int nextWindowId = 1;
|
||||
private static int nextZIndex = 1;
|
||||
|
||||
private static Window? focusedWindow;
|
||||
|
||||
@@ -26,7 +29,8 @@ public static class WindowManager
|
||||
Window window = new(title, process.Id, GetNextWindowId(), renderSource)
|
||||
{
|
||||
Position = position,
|
||||
Size = size
|
||||
Size = size,
|
||||
ZIndex = nextZIndex++
|
||||
};
|
||||
|
||||
if (!windows.ContainsKey(process.Id))
|
||||
@@ -69,6 +73,11 @@ public static class WindowManager
|
||||
return;
|
||||
}
|
||||
|
||||
if (window != null)
|
||||
{
|
||||
window.ZIndex = nextZIndex++;
|
||||
}
|
||||
|
||||
Window? previousFocusedWindow = focusedWindow;
|
||||
focusedWindow = window;
|
||||
|
||||
@@ -81,6 +90,19 @@ public static class WindowManager
|
||||
return focusedWindow == window;
|
||||
}
|
||||
|
||||
public static Window? TryBeginInteract(Point pointerPosition)
|
||||
{
|
||||
var allWindows = windows.Values.SelectMany(w => w).OrderByDescending(w => w.ZIndex);
|
||||
foreach (var window in allWindows)
|
||||
{
|
||||
if (window.TryBeginInteract(pointerPosition))
|
||||
{
|
||||
return window;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static int GetNextWindowId()
|
||||
{
|
||||
return nextWindowId++;
|
||||
|
||||
Reference in New Issue
Block a user