Floating windows: draw the resize grip under the window's tooltips
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -151,11 +151,16 @@ class WindowResizeCorner extends StatelessWidget {
|
||||
super.key,
|
||||
required this.onResize,
|
||||
required this.onResizeEnd,
|
||||
this.showGrip = true,
|
||||
});
|
||||
|
||||
final ValueChanged<Offset> onResize;
|
||||
final VoidCallback onResizeEnd;
|
||||
|
||||
/// Whether this target draws the grip itself. A window's page draws it
|
||||
/// instead ([WindowResizeGrip]), under the tooltips its overlay shows.
|
||||
final bool showGrip;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => Semantics(
|
||||
label: 'Resize window',
|
||||
@@ -167,19 +172,28 @@ class WindowResizeCorner extends StatelessWidget {
|
||||
dragStartBehavior: DragStartBehavior.down,
|
||||
onPanUpdate: (details) => onResize(details.delta),
|
||||
onPanEnd: (_) => onResizeEnd(),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(2),
|
||||
child: Icon(
|
||||
Icons.south_east,
|
||||
size: 16,
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
),
|
||||
),
|
||||
child: showGrip ? const WindowResizeGrip() : const SizedBox.expand(),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// The resize corner's arrow, drawn only (the drag target is
|
||||
/// [WindowResizeCorner]).
|
||||
class WindowResizeGrip extends StatelessWidget {
|
||||
const WindowResizeGrip({super.key});
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => Padding(
|
||||
padding: const EdgeInsets.all(2),
|
||||
child: Icon(
|
||||
Icons.south_east,
|
||||
size: 16,
|
||||
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/// A transparent resize hit region. The visible lower-right affordance
|
||||
/// remains [WindowResizeCorner]; the other regions deliberately add no chrome.
|
||||
class WindowResizeHandle extends StatelessWidget {
|
||||
|
||||
@@ -396,6 +396,8 @@ class _WindowLayerState extends State<WindowLayer>
|
||||
corner,
|
||||
),
|
||||
child: WindowResizeCorner(
|
||||
// The window's page draws the grip, under its tooltips.
|
||||
showGrip: false,
|
||||
onResize: (delta) => _resizeCorner(delta, const {
|
||||
WindowResizeEdge.right,
|
||||
WindowResizeEdge.bottom,
|
||||
|
||||
@@ -2,7 +2,11 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
|
||||
import 'window_frame.dart'
|
||||
show WindowOutline, windowCornerRadius, windowTitleBarHeight;
|
||||
show
|
||||
WindowOutline,
|
||||
WindowResizeGrip,
|
||||
windowCornerRadius,
|
||||
windowTitleBarHeight;
|
||||
import 'window_scope.dart';
|
||||
|
||||
/// A floating window's own page stack. Pages pushed from the window's
|
||||
@@ -157,6 +161,13 @@ class WindowPageBox extends StatelessWidget {
|
||||
),
|
||||
child: const WindowOutline(),
|
||||
),
|
||||
// The resize grip, likewise under the tooltips (the window layer
|
||||
// keeps the drag target).
|
||||
if (WindowScope.maybeOf(context)?.entry.maximized == false)
|
||||
Positioned.fromRect(
|
||||
rect: Rect.fromLTWH(body.right - 16, body.bottom - 16, 16, 16),
|
||||
child: const IgnorePointer(child: WindowResizeGrip()),
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user