gpui: Implement dynamic window control elements (#30828)

Allows setting element as window control elements which consist of
`Drag`, `Close`, `Max`, or `Min`. This allows you to implement
dynamically sized elements that control the platform window, this is
used for areas such as the title bar. Currently only implemented for
Windows.

Release Notes:

- N/A
This commit is contained in:
Matin Aniss 2025-06-07 03:11:24 +10:00 committed by GitHub
parent d9efa2860f
commit ca3f46588a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 129 additions and 96 deletions

View file

@ -4,8 +4,8 @@ use crate::{
KeyDownEvent, Keystroke, Modifiers, ModifiersChangedEvent, MouseButton, MouseDownEvent,
MouseMoveEvent, MouseUpEvent, Pixels, PlatformAtlas, PlatformDisplay, PlatformInput,
PlatformWindow, Point, PromptButton, PromptLevel, RequestFrameOptions, ScaledPixels, Size,
Timer, WindowAppearance, WindowBackgroundAppearance, WindowBounds, WindowKind, WindowParams,
platform::PlatformInputHandler, point, px, size,
Timer, WindowAppearance, WindowBackgroundAppearance, WindowBounds, WindowControlArea,
WindowKind, WindowParams, platform::PlatformInputHandler, point, px, size,
};
use block::ConcreteBlock;
use cocoa::{
@ -1146,6 +1146,10 @@ impl PlatformWindow for MacWindow {
self.0.as_ref().lock().close_callback = Some(callback);
}
fn on_hit_test_window_control(&self, _callback: Box<dyn FnMut() -> Option<WindowControlArea>>) {
unimplemented!()
}
fn on_appearance_changed(&self, callback: Box<dyn FnMut()>) {
self.0.lock().appearance_changed_callback = Some(callback);
}