Add double click to zoom the window
Co-Authored-By: Antonio <me@as-cii.com>
This commit is contained in:
parent
bd54bfa4e1
commit
803d2b6710
3 changed files with 31 additions and 13 deletions
|
@ -678,10 +678,15 @@ impl MacWindow {
|
||||||
|
|
||||||
impl Drop for MacWindow {
|
impl Drop for MacWindow {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
let native_window = self.0.lock().native_window;
|
let this = self.0.lock();
|
||||||
unsafe {
|
let window = this.native_window;
|
||||||
native_window.close();
|
this.executor
|
||||||
}
|
.spawn(async move {
|
||||||
|
unsafe {
|
||||||
|
window.close();
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.detach();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -868,17 +873,25 @@ impl PlatformWindow for MacWindow {
|
||||||
fn zoom(&self) {
|
fn zoom(&self) {
|
||||||
let this = self.0.lock();
|
let this = self.0.lock();
|
||||||
let window = this.native_window;
|
let window = this.native_window;
|
||||||
unsafe {
|
this.executor
|
||||||
window.zoom_(nil);
|
.spawn(async move {
|
||||||
}
|
unsafe {
|
||||||
|
window.zoom_(nil);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.detach();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn toggle_full_screen(&self) {
|
fn toggle_full_screen(&self) {
|
||||||
let this = self.0.lock();
|
let this = self.0.lock();
|
||||||
let window = this.native_window;
|
let window = this.native_window;
|
||||||
unsafe {
|
this.executor
|
||||||
window.toggleFullScreen_(nil);
|
.spawn(async move {
|
||||||
}
|
unsafe {
|
||||||
|
window.toggleFullScreen_(nil);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.detach();
|
||||||
}
|
}
|
||||||
|
|
||||||
fn on_input(&self, callback: Box<dyn FnMut(InputEvent) -> bool>) {
|
fn on_input(&self, callback: Box<dyn FnMut(InputEvent) -> bool>) {
|
||||||
|
|
|
@ -575,6 +575,10 @@ impl<'a> WindowContext<'a> {
|
||||||
self.window.active
|
self.window.active
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn zoom_window(&self) {
|
||||||
|
self.window.platform_window.zoom();
|
||||||
|
}
|
||||||
|
|
||||||
pub fn display(&self) -> Option<Rc<dyn PlatformDisplay>> {
|
pub fn display(&self) -> Option<Rc<dyn PlatformDisplay>> {
|
||||||
self.platform
|
self.platform
|
||||||
.displays()
|
.displays()
|
||||||
|
|
|
@ -2690,14 +2690,15 @@ impl Workspace {
|
||||||
|
|
||||||
fn render_titlebar(&self, cx: &mut ViewContext<Self>) -> impl Component<Self> {
|
fn render_titlebar(&self, cx: &mut ViewContext<Self>) -> impl Component<Self> {
|
||||||
div()
|
div()
|
||||||
|
.bg(cx.theme().colors().title_bar)
|
||||||
.when(
|
.when(
|
||||||
matches!(cx.window_bounds(), WindowBounds::Fullscreen),
|
!matches!(cx.window_bounds(), WindowBounds::Fullscreen),
|
||||||
|s| s.pl_20(),
|
|s| s.pl_20(),
|
||||||
)
|
)
|
||||||
.id(0)
|
.id("titlebar")
|
||||||
.on_click(|workspace, event, cx| {
|
.on_click(|workspace, event, cx| {
|
||||||
if event.up.click_count == 2 {
|
if event.up.click_count == 2 {
|
||||||
println!("ZOOOOOM")
|
cx.zoom_window();
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.child("Collab title bar Item") // self.titlebar_item
|
.child("Collab title bar Item") // self.titlebar_item
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue