mirror of
https://github.com/zed-industries/zed.git
synced 2024-11-09 21:26:14 +03:00
gpui2: Another round of fixups
This commit is contained in:
parent
945dba8099
commit
4af6ac25e9
@ -235,7 +235,7 @@ impl Interactivity {
|
||||
|
||||
pub fn on_boxed_action(
|
||||
&mut self,
|
||||
action: &Box<dyn Action>,
|
||||
action: &dyn Action,
|
||||
listener: impl Fn(&Box<dyn Action>, &mut WindowContext) + 'static,
|
||||
) {
|
||||
let action = action.boxed_clone();
|
||||
@ -510,7 +510,7 @@ pub trait InteractiveElement: Sized {
|
||||
|
||||
fn on_boxed_action(
|
||||
mut self,
|
||||
action: &Box<dyn Action>,
|
||||
action: &dyn Action,
|
||||
listener: impl Fn(&Box<dyn Action>, &mut WindowContext) + 'static,
|
||||
) -> Self {
|
||||
self.interactivity().on_boxed_action(action, listener);
|
||||
@ -877,6 +877,7 @@ impl DivState {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct Interactivity {
|
||||
pub element_id: Option<ElementId>,
|
||||
pub key_context: Option<KeyContext>,
|
||||
@ -1689,46 +1690,6 @@ impl Interactivity {
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for Interactivity {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
element_id: None,
|
||||
key_context: None,
|
||||
focusable: false,
|
||||
tracked_focus_handle: None,
|
||||
scroll_handle: None,
|
||||
// scroll_offset: Point::default(),
|
||||
group: None,
|
||||
base_style: Box::<StyleRefinement>::default(),
|
||||
focus_style: None,
|
||||
in_focus_style: None,
|
||||
hover_style: None,
|
||||
group_hover_style: None,
|
||||
active_style: None,
|
||||
group_active_style: None,
|
||||
drag_over_styles: Vec::new(),
|
||||
group_drag_over_styles: Vec::new(),
|
||||
mouse_down_listeners: Vec::new(),
|
||||
mouse_up_listeners: Vec::new(),
|
||||
mouse_move_listeners: Vec::new(),
|
||||
scroll_wheel_listeners: Vec::new(),
|
||||
key_down_listeners: Vec::new(),
|
||||
key_up_listeners: Vec::new(),
|
||||
action_listeners: Vec::new(),
|
||||
drop_listeners: Vec::new(),
|
||||
can_drop_predicate: None,
|
||||
click_listeners: Vec::new(),
|
||||
drag_listener: None,
|
||||
hover_listener: None,
|
||||
tooltip_builder: None,
|
||||
block_mouse: false,
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
location: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct InteractiveElementState {
|
||||
pub focus_handle: Option<FocusHandle>,
|
||||
|
@ -71,9 +71,11 @@ impl Element for Overlay {
|
||||
.map(|child| child.layout(cx))
|
||||
.collect::<SmallVec<_>>();
|
||||
|
||||
let mut overlay_style = Style::default();
|
||||
overlay_style.position = Position::Absolute;
|
||||
overlay_style.display = Display::Flex;
|
||||
let overlay_style = Style {
|
||||
position: Position::Absolute,
|
||||
display: Display::Flex,
|
||||
..Style::default()
|
||||
};
|
||||
|
||||
let layout_id = cx.request_layout(&overlay_style, child_layout_ids.iter().copied());
|
||||
|
||||
|
@ -66,12 +66,10 @@ impl MetalRenderer {
|
||||
.expect("error building metal library");
|
||||
|
||||
fn to_float2_bits(point: crate::PointF) -> u64 {
|
||||
unsafe {
|
||||
let mut output = mem::transmute::<_, u32>(point.y.to_bits()) as u64;
|
||||
output <<= 32;
|
||||
output |= mem::transmute::<_, u32>(point.x.to_bits()) as u64;
|
||||
output
|
||||
}
|
||||
let mut output = point.y.to_bits() as u64;
|
||||
output <<= 32;
|
||||
output |= point.x.to_bits() as u64;
|
||||
output
|
||||
}
|
||||
|
||||
let unit_vertices = [
|
||||
|
@ -225,7 +225,12 @@ impl MacPlatform {
|
||||
menu.setDelegate_(delegate);
|
||||
|
||||
for item_config in menu_config.items {
|
||||
menu.addItem_(self.create_menu_item(item_config, delegate, actions, keymap));
|
||||
menu.addItem_(Self::create_menu_item(
|
||||
item_config,
|
||||
delegate,
|
||||
actions,
|
||||
keymap,
|
||||
));
|
||||
}
|
||||
|
||||
let menu_item = NSMenuItem::new(nil).autorelease();
|
||||
@ -242,7 +247,6 @@ impl MacPlatform {
|
||||
}
|
||||
|
||||
unsafe fn create_menu_item(
|
||||
&self,
|
||||
item: MenuItem,
|
||||
delegate: id,
|
||||
actions: &mut Vec<Box<dyn Action>>,
|
||||
@ -348,7 +352,7 @@ impl MacPlatform {
|
||||
let submenu = NSMenu::new(nil).autorelease();
|
||||
submenu.setDelegate_(delegate);
|
||||
for item in items {
|
||||
submenu.addItem_(self.create_menu_item(item, delegate, actions, keymap));
|
||||
submenu.addItem_(Self::create_menu_item(item, delegate, actions, keymap));
|
||||
}
|
||||
item.setSubmenu_(submenu);
|
||||
item.setTitle_(ns_string(name));
|
||||
|
@ -2922,10 +2922,7 @@ impl<V> Copy for WindowHandle<V> {}
|
||||
|
||||
impl<V> Clone for WindowHandle<V> {
|
||||
fn clone(&self) -> Self {
|
||||
WindowHandle {
|
||||
any_handle: self.any_handle,
|
||||
state_type: PhantomData,
|
||||
}
|
||||
*self
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -253,7 +253,7 @@ impl Render for ContextMenu {
|
||||
} = item
|
||||
{
|
||||
el = el.on_boxed_action(
|
||||
action,
|
||||
&**action,
|
||||
cx.listener(ContextMenu::on_action_dispatch),
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user