windows: better looking titlebar (#9053)

~~work in progress. not ready for review. made for visibility only, but
feel free to comment :)~~

TODO:
- [x] add close/min/max buttons (to be rendered with gpui)
- [x] snap layout support
- [x] fix issues with clicking items in titlebar
- [x] cleanup/document

Release Notes:

- Added custom windows titlebar

![](https://media.discordapp.net/attachments/1208481909676576818/1216985375969378324/caption-buttons-working.gif?ex=660260f4&is=65efebf4&hm=53a17af6e2f233eba54302a5adb9efe23900f4d6f6d1d854bec887120789130c&=)

---------

Co-authored-by: Mikayla <mikayla@zed.dev>
This commit is contained in:
Ezekiel Warren 2024-03-14 17:20:30 -07:00 committed by GitHub
parent 6bbc5e2efa
commit 948b3827c8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 694 additions and 122 deletions

View file

@ -31,7 +31,7 @@ use super::X11Display;
#[derive(Default)]
struct Callbacks {
request_frame: Option<Box<dyn FnMut()>>,
input: Option<Box<dyn FnMut(PlatformInput) -> bool>>,
input: Option<Box<dyn FnMut(PlatformInput) -> crate::DispatchEventResult>>,
active_status_change: Option<Box<dyn FnMut(bool)>>,
resize: Option<Box<dyn FnMut(Size<Pixels>, f32)>>,
fullscreen: Option<Box<dyn FnMut(bool)>>,
@ -303,7 +303,7 @@ impl X11WindowState {
pub fn handle_input(&self, input: PlatformInput) {
if let Some(ref mut fun) = self.callbacks.borrow_mut().input {
if fun(input.clone()) {
if !fun(input.clone()).propagate {
return;
}
}
@ -333,6 +333,11 @@ impl PlatformWindow for X11Window {
.map(|v| GlobalPixels(v as f32))
}
// todo(linux)
fn is_maximized(&self) -> bool {
unimplemented!()
}
fn content_size(&self) -> Size<Pixels> {
self.0.inner.borrow_mut().content_size()
}
@ -451,7 +456,7 @@ impl PlatformWindow for X11Window {
self.0.callbacks.borrow_mut().request_frame = Some(callback);
}
fn on_input(&self, callback: Box<dyn FnMut(PlatformInput) -> bool>) {
fn on_input(&self, callback: Box<dyn FnMut(PlatformInput) -> crate::DispatchEventResult>) {
self.0.callbacks.borrow_mut().input = Some(callback);
}