feat(ui): D.2b-A — BringToFront + raise on show/click
BringToFront sets a window's ZOrder one past the max among its peers. ShowWindow now raises on open; OnMouseDown raises any pressed top-level window (retail-faithful stacking). Existing drag/resize tests unaffected (raise only touches ZOrder, not geometry). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
6409038576
commit
036db8b8ab
2 changed files with 56 additions and 0 deletions
|
|
@ -248,6 +248,8 @@ public sealed class UiRoot : UiElement
|
|||
// A left-drag starting near an edge resizes; interior drag repositions;
|
||||
// otherwise it's a normal drag-drop candidate.
|
||||
var window = FindWindow(target);
|
||||
// Retail-faithful: pressing on a window raises it above its peers.
|
||||
if (window is not null) BringToFront(window);
|
||||
if (btn == UiMouseButton.Left && window is not null)
|
||||
{
|
||||
var edges = window.Resizable ? HitEdges(window, x, y, ResizeGrip) : ResizeEdges.None;
|
||||
|
|
@ -489,6 +491,7 @@ public sealed class UiRoot : UiElement
|
|||
{
|
||||
if (!_windows.TryGetValue(name, out var w)) return false;
|
||||
w.Visible = true;
|
||||
BringToFront(w);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -510,6 +513,18 @@ public sealed class UiRoot : UiElement
|
|||
return true;
|
||||
}
|
||||
|
||||
/// <summary>Raise a top-level window above its siblings by setting its ZOrder
|
||||
/// one past the current max among the OTHER top-level children. Used on Show
|
||||
/// and on click. Leaves ZOrder unchanged if it is the only / already-topmost child.</summary>
|
||||
public void BringToFront(UiElement window)
|
||||
{
|
||||
int top = window.ZOrder;
|
||||
foreach (var c in Children)
|
||||
if (!ReferenceEquals(c, window))
|
||||
top = System.Math.Max(top, c.ZOrder + 1);
|
||||
window.ZOrder = top;
|
||||
}
|
||||
|
||||
// ── Drag-drop (retail event chain 0x15 → 0x21 → 0x1C → 0x3E) ────────
|
||||
|
||||
private void BeginDrag(UiElement source)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue