WIP
This commit is contained in:
@@ -7,6 +7,7 @@ mod image_cache;
|
||||
mod platform;
|
||||
mod renderer;
|
||||
mod sprite_cache;
|
||||
mod status_item;
|
||||
mod window;
|
||||
|
||||
use cocoa::base::{BOOL, NO, YES};
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
use super::{event::key_to_native, BoolExt as _, Dispatcher, FontSystem, Window};
|
||||
use super::{
|
||||
event::key_to_native, status_item::StatusItem, BoolExt as _, Dispatcher, FontSystem, Window,
|
||||
};
|
||||
use crate::{
|
||||
executor, keymap,
|
||||
platform::{self, CursorStyle},
|
||||
@@ -439,23 +441,6 @@ impl platform::Platform for MacPlatform {
|
||||
}
|
||||
}
|
||||
|
||||
fn open_window(
|
||||
&self,
|
||||
id: usize,
|
||||
options: platform::WindowOptions,
|
||||
executor: Rc<executor::Foreground>,
|
||||
) -> Box<dyn platform::Window> {
|
||||
Box::new(Window::open(id, options, executor, self.fonts()))
|
||||
}
|
||||
|
||||
fn key_window_id(&self) -> Option<usize> {
|
||||
Window::key_window_id()
|
||||
}
|
||||
|
||||
fn fonts(&self) -> Arc<dyn platform::FontSystem> {
|
||||
self.fonts.clone()
|
||||
}
|
||||
|
||||
fn hide(&self) {
|
||||
unsafe {
|
||||
let app = NSApplication::sharedApplication(nil);
|
||||
@@ -497,6 +482,27 @@ impl platform::Platform for MacPlatform {
|
||||
}
|
||||
}
|
||||
|
||||
fn open_window(
|
||||
&self,
|
||||
id: usize,
|
||||
options: platform::WindowOptions,
|
||||
executor: Rc<executor::Foreground>,
|
||||
) -> Box<dyn platform::Window> {
|
||||
Box::new(Window::open(id, options, executor, self.fonts()))
|
||||
}
|
||||
|
||||
fn key_window_id(&self) -> Option<usize> {
|
||||
Window::key_window_id()
|
||||
}
|
||||
|
||||
fn add_status_item(&self) -> Box<dyn platform::StatusItem> {
|
||||
Box::new(StatusItem::add())
|
||||
}
|
||||
|
||||
fn fonts(&self) -> Arc<dyn platform::FontSystem> {
|
||||
self.fonts.clone()
|
||||
}
|
||||
|
||||
fn write_to_clipboard(&self, item: ClipboardItem) {
|
||||
unsafe {
|
||||
self.pasteboard.clearContents();
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
use cocoa::{
|
||||
appkit::{NSSquareStatusItemLength, NSStatusBar},
|
||||
base::{id, nil},
|
||||
};
|
||||
use core_foundation::base::TCFType;
|
||||
use core_graphics::color::CGColor;
|
||||
use objc::{msg_send, sel, sel_impl};
|
||||
|
||||
pub struct StatusItem(id);
|
||||
|
||||
impl StatusItem {
|
||||
pub fn add() -> Self {
|
||||
unsafe {
|
||||
let status_bar = NSStatusBar::systemStatusBar(nil);
|
||||
let native_item: id =
|
||||
msg_send![status_bar, statusItemWithLength: NSSquareStatusItemLength];
|
||||
let button: id = msg_send![native_item, button];
|
||||
let layer: id = msg_send![button, layer];
|
||||
let _: () = msg_send![layer, setBackgroundColor: CGColor::rgb(1., 0., 0., 1.).as_concrete_TypeRef()];
|
||||
StatusItem(native_item)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl crate::StatusItem for StatusItem {}
|
||||
@@ -120,6 +120,14 @@ impl super::Platform for Platform {
|
||||
|
||||
fn activate(&self, _ignoring_other_apps: bool) {}
|
||||
|
||||
fn hide(&self) {}
|
||||
|
||||
fn hide_other_apps(&self) {}
|
||||
|
||||
fn unhide_other_apps(&self) {}
|
||||
|
||||
fn quit(&self) {}
|
||||
|
||||
fn open_window(
|
||||
&self,
|
||||
_: usize,
|
||||
@@ -136,13 +144,9 @@ impl super::Platform for Platform {
|
||||
None
|
||||
}
|
||||
|
||||
fn hide(&self) {}
|
||||
|
||||
fn hide_other_apps(&self) {}
|
||||
|
||||
fn unhide_other_apps(&self) {}
|
||||
|
||||
fn quit(&self) {}
|
||||
fn add_status_item(&self) -> Box<dyn crate::StatusItem> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn write_to_clipboard(&self, item: ClipboardItem) {
|
||||
*self.current_clipboard_item.lock() = Some(item);
|
||||
|
||||
Reference in New Issue
Block a user