-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
107 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,49 @@ | ||
use tauri::{Runtime, Window}; | ||
|
||
#[allow(dead_code)] | ||
pub enum ToolbarThickness { | ||
Thick, | ||
Medium, | ||
Thin, | ||
} | ||
|
||
pub trait WindowExt { | ||
#[cfg(target_os = "macos")] | ||
fn set_transparent_titlebar(&self, transparent: bool); | ||
fn position_traffic_lights(&self, x: f64, y: f64); | ||
fn set_transparent_titlebar(&self, thickness: ToolbarThickness); | ||
} | ||
|
||
impl<R: Runtime> WindowExt for Window<R> { | ||
#[cfg(target_os = "macos")] | ||
fn set_transparent_titlebar(&self, transparent: bool) { | ||
fn set_transparent_titlebar(&self, thickness: ToolbarThickness) { | ||
use cocoa::appkit::{NSWindow, NSWindowTitleVisibility}; | ||
|
||
let window = self.ns_window().unwrap() as cocoa::base::id; | ||
|
||
unsafe { | ||
window.setTitleVisibility_(NSWindowTitleVisibility::NSWindowTitleHidden); | ||
|
||
if transparent { | ||
window.setTitlebarAppearsTransparent_(cocoa::base::YES); | ||
} else { | ||
window.setTitlebarAppearsTransparent_(cocoa::base::NO); | ||
let id = self.ns_window().unwrap() as cocoa::base::id; | ||
|
||
id.setTitlebarAppearsTransparent_(cocoa::base::YES); | ||
|
||
match thickness { | ||
ToolbarThickness::Thick => { | ||
self.set_title("").expect("Title wasn't set to ''"); | ||
make_toolbar(id); | ||
} | ||
ToolbarThickness::Medium => { | ||
id.setTitleVisibility_(NSWindowTitleVisibility::NSWindowTitleHidden); | ||
make_toolbar(id); | ||
} | ||
ToolbarThickness::Thin => { | ||
id.setTitleVisibility_(NSWindowTitleVisibility::NSWindowTitleHidden); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
#[cfg(target_os = "macos")] | ||
fn position_traffic_lights(&self, x: f64, y: f64) { | ||
use cocoa::appkit::{NSView, NSWindow, NSWindowButton}; | ||
use cocoa::foundation::NSRect; | ||
|
||
let window = self.ns_window().unwrap() as cocoa::base::id; | ||
|
||
unsafe { | ||
let close = window.standardWindowButton_(NSWindowButton::NSWindowCloseButton); | ||
let miniaturize = | ||
window.standardWindowButton_(NSWindowButton::NSWindowMiniaturizeButton); | ||
let zoom = window.standardWindowButton_(NSWindowButton::NSWindowZoomButton); | ||
|
||
let title_bar_container_view = close.superview().superview(); | ||
|
||
let close_rect: NSRect = msg_send![close, frame]; | ||
let button_height = close_rect.size.height; | ||
|
||
let title_bar_frame_height = button_height + 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 = NSView::frame(window).size.height - title_bar_frame_height; | ||
let _: () = msg_send![title_bar_container_view, setFrame: title_bar_rect]; | ||
|
||
let window_buttons = vec![close, miniaturize, zoom]; | ||
let space_between = NSView::frame(miniaturize).origin.x - NSView::frame(close).origin.x; | ||
#[cfg(target_os = "macos")] | ||
unsafe fn make_toolbar(id: cocoa::base::id) { | ||
use cocoa::appkit::{NSToolbar, NSWindow}; | ||
|
||
for (i, button) in window_buttons.into_iter().enumerate() { | ||
let mut rect: NSRect = NSView::frame(button); | ||
rect.origin.x = x + (i as f64 * space_between); | ||
button.setFrameOrigin(rect.origin); | ||
} | ||
} | ||
} | ||
let new_toolbar = NSToolbar::alloc(id); | ||
new_toolbar.init_(); | ||
id.setToolbar_(new_toolbar); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
@tailwind base; | ||
@tailwind components; | ||
@tailwind utilities; | ||
@tailwind utilities; | ||
|
||
|
||
* { | ||
background: transparent; | ||
} |