mirror of
https://github.com/zed-industries/zed.git
synced 2024-12-24 17:28:40 +00:00
Remove platform::WindowContext
trait
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
parent
1c810d7e8d
commit
e803dd9f72
4 changed files with 18 additions and 27 deletions
|
@ -110,7 +110,7 @@ pub trait InputHandler {
|
|||
fn rect_for_range(&self, range_utf16: Range<usize>) -> Option<RectF>;
|
||||
}
|
||||
|
||||
pub trait Window: WindowContext {
|
||||
pub trait Window {
|
||||
fn as_any_mut(&mut self) -> &mut dyn Any;
|
||||
fn on_event(&mut self, callback: Box<dyn FnMut(Event) -> bool>);
|
||||
fn on_active_status_change(&mut self, callback: Box<dyn FnMut(bool)>);
|
||||
|
@ -127,9 +127,7 @@ pub trait Window: WindowContext {
|
|||
fn minimize(&self);
|
||||
fn zoom(&self);
|
||||
fn toggle_full_screen(&self);
|
||||
}
|
||||
|
||||
pub trait WindowContext {
|
||||
fn size(&self) -> Vector2F;
|
||||
fn scale_factor(&self) -> f32;
|
||||
fn titlebar_height(&self) -> f32;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
use cocoa::{
|
||||
appkit::{NSSquareStatusItemLength, NSStatusBar, NSStatusItem, NSView},
|
||||
base::{id, nil, NO, YES},
|
||||
foundation::NSRect,
|
||||
quartzcore::AutoresizingMask,
|
||||
};
|
||||
use core_foundation::base::TCFType;
|
||||
|
|
|
@ -6,7 +6,7 @@ use crate::{
|
|||
vector::{vec2f, Vector2F},
|
||||
},
|
||||
keymap::Keystroke,
|
||||
platform::{self, Event, WindowBounds, WindowContext},
|
||||
platform::{self, Event, WindowBounds},
|
||||
InputHandler, KeyDownEvent, ModifiersChangedEvent, MouseButton, MouseButtonEvent,
|
||||
MouseMovedEvent, Scene,
|
||||
};
|
||||
|
@ -649,9 +649,7 @@ impl platform::Window for Window {
|
|||
})
|
||||
.detach();
|
||||
}
|
||||
}
|
||||
|
||||
impl platform::WindowContext for Window {
|
||||
fn size(&self) -> Vector2F {
|
||||
self.0.as_ref().borrow().size()
|
||||
}
|
||||
|
@ -713,9 +711,7 @@ impl WindowState {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl platform::WindowContext for WindowState {
|
||||
fn size(&self) -> Vector2F {
|
||||
let NSSize { width, height, .. } =
|
||||
unsafe { NSView::frame(self.native_window.contentView()) }.size;
|
||||
|
|
|
@ -228,24 +228,6 @@ impl super::Dispatcher for Dispatcher {
|
|||
}
|
||||
}
|
||||
|
||||
impl super::WindowContext for Window {
|
||||
fn size(&self) -> Vector2F {
|
||||
self.size
|
||||
}
|
||||
|
||||
fn scale_factor(&self) -> f32 {
|
||||
self.scale_factor
|
||||
}
|
||||
|
||||
fn titlebar_height(&self) -> f32 {
|
||||
24.
|
||||
}
|
||||
|
||||
fn present_scene(&mut self, scene: crate::Scene) {
|
||||
self.current_scene = Some(scene);
|
||||
}
|
||||
}
|
||||
|
||||
impl super::Window for Window {
|
||||
fn as_any_mut(&mut self) -> &mut dyn Any {
|
||||
self
|
||||
|
@ -300,6 +282,22 @@ impl super::Window for Window {
|
|||
fn zoom(&self) {}
|
||||
|
||||
fn toggle_full_screen(&self) {}
|
||||
|
||||
fn size(&self) -> Vector2F {
|
||||
self.size
|
||||
}
|
||||
|
||||
fn scale_factor(&self) -> f32 {
|
||||
self.scale_factor
|
||||
}
|
||||
|
||||
fn titlebar_height(&self) -> f32 {
|
||||
24.
|
||||
}
|
||||
|
||||
fn present_scene(&mut self, scene: crate::Scene) {
|
||||
self.current_scene = Some(scene);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn platform() -> Platform {
|
||||
|
|
Loading…
Reference in a new issue