You've already forked AstralRinth
forked from didirus/AstralRinth
* Initial bug fixes * fix compile error on non-mac * Fix even more bugs * Fix more * fix more * fix build * fix build * Search fixes * Fix small instance ui * working basic * fix javaw issue * removed zip * working functions * merge fixes * fixed loadintg bar bug * menu fix * wait for settings to sync * safety expanded and for loading bars * swtiching to windows * minimize * default landing page * test link registry * url redirection * fix formatting * .mrpack windows * working mrpack reader * changed to one layer deep * working .mrpack + command handling for both opening and existing process * forge version numbers * working mac opening mrpack * reverted changes * prettier/fmt * missed debug statement * improvements + refactoring * renamed things to fit plugin * fixed bugs * removed println * overrides dont include mrpack * merge * fixes * fixes * fixed deletion * merge errors * force sync before export * removed testing * missed line * removed console log * mac error reverted * incoreclty named helper * additional fixes * added removed merges * fixed mislabled invokes * mac * added to new register method * comments, cleanup * mac clippy change * review changes * minor changes * moved create pack * removed playground compilation bug * fixed linux bug; other add ons * fixed review commets * cicd fix * mistaken import for prod * cicd fix --------- Co-authored-by: Jai A <jaiagr+gpg@pm.me>
71 lines
2.6 KiB
Rust
71 lines
2.6 KiB
Rust
/// from: https://github.com/tauri-apps/tauri/issues/4789, full credit to haasal
|
|
#[cfg(target_os = "macos")]
|
|
use tauri::{Runtime, Window};
|
|
|
|
#[cfg(target_os = "macos")]
|
|
pub trait WindowExt {
|
|
fn set_transparent_titlebar(&self, transparent: bool);
|
|
fn position_traffic_lights(&self, x: f64, y: f64);
|
|
}
|
|
|
|
#[cfg(target_os = "macos")]
|
|
impl<R: Runtime> WindowExt for Window<R> {
|
|
fn set_transparent_titlebar(&self, transparent: bool) {
|
|
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);
|
|
}
|
|
}
|
|
}
|
|
|
|
fn position_traffic_lights(&self, x: f64, y: f64) {
|
|
use cocoa::appkit::{NSView, NSWindow, NSWindowButton};
|
|
use cocoa::foundation::NSRect;
|
|
use objc::{msg_send, sel, sel_impl};
|
|
|
|
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;
|
|
|
|
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);
|
|
}
|
|
}
|
|
}
|
|
}
|