fix(ui): manual modal dragging, maximize/restore icon, day-toggle style

- Drive modal title-bar dragging manually via pointer capture + Window.Position;
  Avalonia 12's BeginMoveDrag and VisualRoot-as-Window cast no longer work
  (VisualRoot is a TopLevelHost). Applies to ModalShell and WorktreeModalView.
- Toggle the MainWindow maximize button between maximize/restore glyphs on
  WindowState changes (adds Icon.WinRestore geometry).
- Add the ToggleButton.day-toggle style used by the Prime weekday picker row.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
mika kuns
2026-06-02 17:02:56 +02:00
parent 26998f05ff
commit f1715a34fa
6 changed files with 99 additions and 7 deletions

View File

@@ -28,7 +28,10 @@
<!-- Title strip -->
<Border DockPanel.Dock="Top" Height="36"
PointerPressed="OnTitleBarPressed">
Background="Transparent"
PointerPressed="OnTitleBarPressed"
PointerMoved="OnTitleBarMoved"
PointerReleased="OnTitleBarReleased">
<Grid ColumnDefinitions="*,Auto" Margin="14,0">
<TextBlock Grid.Column="0" Text="Worktree" VerticalAlignment="Center"
FontFamily="{DynamicResource MonoFont}" FontSize="{StaticResource FontSizeBody}"

View File

@@ -66,9 +66,31 @@ public partial class WorktreeModalView : Window
e.Handled = true;
}
private PixelPoint _dragStartScreen;
private PixelPoint _dragStartPos;
private bool _dragging;
private void OnTitleBarPressed(object? sender, PointerPressedEventArgs e)
{
if (e.GetCurrentPoint(this).Properties.IsLeftButtonPressed)
BeginMoveDrag(e);
if (!e.GetCurrentPoint(this).Properties.IsLeftButtonPressed) return;
_dragStartScreen = this.PointToScreen(e.GetPosition(this));
_dragStartPos = Position;
_dragging = true;
e.Pointer.Capture(sender as IInputElement);
}
private void OnTitleBarMoved(object? sender, PointerEventArgs e)
{
if (!_dragging || !e.GetCurrentPoint(this).Properties.IsLeftButtonPressed) return;
var cur = this.PointToScreen(e.GetPosition(this));
Position = new PixelPoint(
_dragStartPos.X + (cur.X - _dragStartScreen.X),
_dragStartPos.Y + (cur.Y - _dragStartScreen.Y));
}
private void OnTitleBarReleased(object? sender, PointerReleasedEventArgs e)
{
_dragging = false;
e.Pointer.Capture(null);
}
}