gpui2: Another round of fixups
This commit is contained in:
parent
945dba8099
commit
4af6ac25e9
6 changed files with 21 additions and 59 deletions
|
@ -235,7 +235,7 @@ impl Interactivity {
|
||||||
|
|
||||||
pub fn on_boxed_action(
|
pub fn on_boxed_action(
|
||||||
&mut self,
|
&mut self,
|
||||||
action: &Box<dyn Action>,
|
action: &dyn Action,
|
||||||
listener: impl Fn(&Box<dyn Action>, &mut WindowContext) + 'static,
|
listener: impl Fn(&Box<dyn Action>, &mut WindowContext) + 'static,
|
||||||
) {
|
) {
|
||||||
let action = action.boxed_clone();
|
let action = action.boxed_clone();
|
||||||
|
@ -510,7 +510,7 @@ pub trait InteractiveElement: Sized {
|
||||||
|
|
||||||
fn on_boxed_action(
|
fn on_boxed_action(
|
||||||
mut self,
|
mut self,
|
||||||
action: &Box<dyn Action>,
|
action: &dyn Action,
|
||||||
listener: impl Fn(&Box<dyn Action>, &mut WindowContext) + 'static,
|
listener: impl Fn(&Box<dyn Action>, &mut WindowContext) + 'static,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
self.interactivity().on_boxed_action(action, listener);
|
self.interactivity().on_boxed_action(action, listener);
|
||||||
|
@ -877,6 +877,7 @@ impl DivState {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Default)]
|
||||||
pub struct Interactivity {
|
pub struct Interactivity {
|
||||||
pub element_id: Option<ElementId>,
|
pub element_id: Option<ElementId>,
|
||||||
pub key_context: Option<KeyContext>,
|
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)]
|
#[derive(Default)]
|
||||||
pub struct InteractiveElementState {
|
pub struct InteractiveElementState {
|
||||||
pub focus_handle: Option<FocusHandle>,
|
pub focus_handle: Option<FocusHandle>,
|
||||||
|
|
|
@ -71,9 +71,11 @@ impl Element for Overlay {
|
||||||
.map(|child| child.layout(cx))
|
.map(|child| child.layout(cx))
|
||||||
.collect::<SmallVec<_>>();
|
.collect::<SmallVec<_>>();
|
||||||
|
|
||||||
let mut overlay_style = Style::default();
|
let overlay_style = Style {
|
||||||
overlay_style.position = Position::Absolute;
|
position: Position::Absolute,
|
||||||
overlay_style.display = Display::Flex;
|
display: Display::Flex,
|
||||||
|
..Style::default()
|
||||||
|
};
|
||||||
|
|
||||||
let layout_id = cx.request_layout(&overlay_style, child_layout_ids.iter().copied());
|
let layout_id = cx.request_layout(&overlay_style, child_layout_ids.iter().copied());
|
||||||
|
|
||||||
|
|
|
@ -66,12 +66,10 @@ impl MetalRenderer {
|
||||||
.expect("error building metal library");
|
.expect("error building metal library");
|
||||||
|
|
||||||
fn to_float2_bits(point: crate::PointF) -> u64 {
|
fn to_float2_bits(point: crate::PointF) -> u64 {
|
||||||
unsafe {
|
let mut output = point.y.to_bits() as u64;
|
||||||
let mut output = mem::transmute::<_, u32>(point.y.to_bits()) as u64;
|
output <<= 32;
|
||||||
output <<= 32;
|
output |= point.x.to_bits() as u64;
|
||||||
output |= mem::transmute::<_, u32>(point.x.to_bits()) as u64;
|
output
|
||||||
output
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let unit_vertices = [
|
let unit_vertices = [
|
||||||
|
|
|
@ -225,7 +225,12 @@ impl MacPlatform {
|
||||||
menu.setDelegate_(delegate);
|
menu.setDelegate_(delegate);
|
||||||
|
|
||||||
for item_config in menu_config.items {
|
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();
|
let menu_item = NSMenuItem::new(nil).autorelease();
|
||||||
|
@ -242,7 +247,6 @@ impl MacPlatform {
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn create_menu_item(
|
unsafe fn create_menu_item(
|
||||||
&self,
|
|
||||||
item: MenuItem,
|
item: MenuItem,
|
||||||
delegate: id,
|
delegate: id,
|
||||||
actions: &mut Vec<Box<dyn Action>>,
|
actions: &mut Vec<Box<dyn Action>>,
|
||||||
|
@ -348,7 +352,7 @@ impl MacPlatform {
|
||||||
let submenu = NSMenu::new(nil).autorelease();
|
let submenu = NSMenu::new(nil).autorelease();
|
||||||
submenu.setDelegate_(delegate);
|
submenu.setDelegate_(delegate);
|
||||||
for item in items {
|
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.setSubmenu_(submenu);
|
||||||
item.setTitle_(ns_string(name));
|
item.setTitle_(ns_string(name));
|
||||||
|
|
|
@ -2922,10 +2922,7 @@ impl<V> Copy for WindowHandle<V> {}
|
||||||
|
|
||||||
impl<V> Clone for WindowHandle<V> {
|
impl<V> Clone for WindowHandle<V> {
|
||||||
fn clone(&self) -> Self {
|
fn clone(&self) -> Self {
|
||||||
WindowHandle {
|
*self
|
||||||
any_handle: self.any_handle,
|
|
||||||
state_type: PhantomData,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -253,7 +253,7 @@ impl Render for ContextMenu {
|
||||||
} = item
|
} = item
|
||||||
{
|
{
|
||||||
el = el.on_boxed_action(
|
el = el.on_boxed_action(
|
||||||
action,
|
&**action,
|
||||||
cx.listener(ContextMenu::on_action_dispatch),
|
cx.listener(ContextMenu::on_action_dispatch),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue