You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In order to preserve window control buttons position, we need to re-apply the logic to update their position on resize, move, and exit/start full-screen. (taken from Electron) Although the move event works fine, on resize we get a flicker.
Code that updates the titlebar:
unsafe {
let id = self.ns_window().unwrap() as cocoa::base::id;
NSWindow::setTitlebarAppearsTransparent_(id, cocoa::base::YES);
let mut style_mask = id.styleMask();
style_mask.set(
NSWindowStyleMask::NSFullSizeContentViewWindowMask,
title_transparent,
);
if remove_tool_bar {
style_mask.remove(
NSWindowStyleMask::NSClosableWindowMask
| NSWindowStyleMask::NSMiniaturizableWindowMask
| NSWindowStyleMask::NSResizableWindowMask,
);
}
id.setStyleMask_(style_mask);
id.setTitleVisibility_(if title_transparent {
NSWindowTitleVisibility::NSWindowTitleHidden
} else {
NSWindowTitleVisibility::NSWindowTitleVisible
});
id.setTitlebarAppearsTransparent_(if title_transparent {
cocoa::base::YES
} else {
cocoa::base::NO
});
let title_bar_x = -4.0;
let title_bar_y = 26.0;
// TAKEN FROM ELECTRON
// https://github.com/patr0nus/DeskGap/blob/master/lib/src/platform/mac/BrowserWindow.mm#L100
// also need to handle on full screen enter, exit, resize, etc
let close = NSWindow::standardWindowButton_(id, NSWindowButton::NSWindowCloseButton);
let miniaturize = id.standardWindowButton_(NSWindowButton::NSWindowMiniaturizeButton);
let zoom = id.standardWindowButton_(NSWindowButton::NSWindowZoomButton);
let title_bar_container_view = close.superview().superview();
let button_height = NSView::frame(close).size.height;
let title_bar_frame_height = button_height + title_bar_y;
let mut title_bar_rect = NSView::frame(title_bar_container_view);
title_bar_rect.size.height = title_bar_frame_height;
title_bar_rect.origin.y = NSWindow::frame(id).size.height - title_bar_frame_height;
NSView::setFrameOrigin(title_bar_container_view, title_bar_rect.origin);
NSView::setFrameSize(title_bar_container_view, title_bar_rect.size);
// OG: NSArray* windowButtons = @[ close, miniaturize, zoom ];
// i don't know what is @ in rust code
let _window_buttons = [close, miniaturize, zoom];
let space_between = NSView::frame(miniaturize).origin.x - NSView::frame(close).origin.x;
let mut button_rect1 = NSView::frame(close);
button_rect1.origin.x = title_bar_x + (1.0 * space_between);
button_rect1.origin.y = (title_bar_frame_height - button_rect1.size.height) / 2.0;
NSView::setFrameOrigin(close, button_rect1.origin);
let mut button_rect2 = NSView::frame(miniaturize);
button_rect2.origin.x = title_bar_x + (2.0 * space_between);
button_rect2.origin.y = (title_bar_frame_height - button_rect2.size.height) / 2.0;
NSView::setFrameOrigin(miniaturize, button_rect2.origin);
let mut button_rect3 = NSView::frame(zoom);
button_rect3.origin.x = title_bar_x + (3.0 * space_between);
button_rect3.origin.y = (title_bar_frame_height - button_rect3.size.height) / 2.0;
NSView::setFrameOrigin(zoom, button_rect3.origin);
}
cc @wusyong (sorry to @, since you were recently involved in the resize logic, I'd love to know what can I do about it.)
The text was updated successfully, but these errors were encountered:
For future reference, there is another event made for this: Event::RedrawRequested(_).
However, this feature has been made in tao in #513 so once merged we'd no longer need to do it manually.
In order to preserve window control buttons position, we need to re-apply the logic to update their position on resize, move, and exit/start full-screen. (taken from Electron) Although the move event works fine, on resize we get a flicker.
Code that updates the titlebar:
cc @wusyong (sorry to @, since you were recently involved in the resize logic, I'd love to know what can I do about it.)
The text was updated successfully, but these errors were encountered: