Switch MouseEventHandler to use MouseRegions
Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
This commit is contained in:
parent
50edcb06dd
commit
893f15ddab
26 changed files with 150 additions and 195 deletions
|
@ -460,7 +460,7 @@ impl TestAppContext {
|
|||
view_id: handle.id(),
|
||||
view_type: PhantomData,
|
||||
titlebar_height: 0.,
|
||||
hovered_region_id: None,
|
||||
hovered_region_ids: Default::default(),
|
||||
clicked_region_id: None,
|
||||
refreshing: false,
|
||||
};
|
||||
|
@ -1080,7 +1080,7 @@ impl MutableAppContext {
|
|||
window_id,
|
||||
view_id,
|
||||
titlebar_height,
|
||||
hovered_region_id: None,
|
||||
hovered_region_ids: Default::default(),
|
||||
clicked_region_id: None,
|
||||
refreshing: false,
|
||||
})
|
||||
|
@ -3402,7 +3402,7 @@ pub struct RenderParams {
|
|||
pub window_id: usize,
|
||||
pub view_id: usize,
|
||||
pub titlebar_height: f32,
|
||||
pub hovered_region_id: Option<MouseRegionId>,
|
||||
pub hovered_region_ids: HashSet<MouseRegionId>,
|
||||
pub clicked_region_id: Option<MouseRegionId>,
|
||||
pub refreshing: bool,
|
||||
}
|
||||
|
@ -3411,14 +3411,14 @@ pub struct RenderContext<'a, T: View> {
|
|||
pub(crate) window_id: usize,
|
||||
pub(crate) view_id: usize,
|
||||
pub(crate) view_type: PhantomData<T>,
|
||||
pub(crate) hovered_region_id: Option<MouseRegionId>,
|
||||
pub(crate) hovered_region_ids: HashSet<MouseRegionId>,
|
||||
pub(crate) clicked_region_id: Option<MouseRegionId>,
|
||||
pub app: &'a mut MutableAppContext,
|
||||
pub titlebar_height: f32,
|
||||
pub refreshing: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
#[derive(Clone, Copy, Default)]
|
||||
pub struct MouseState {
|
||||
pub hovered: bool,
|
||||
pub clicked: bool,
|
||||
|
@ -3432,7 +3432,7 @@ impl<'a, V: View> RenderContext<'a, V> {
|
|||
view_id: params.view_id,
|
||||
view_type: PhantomData,
|
||||
titlebar_height: params.titlebar_height,
|
||||
hovered_region_id: params.hovered_region_id,
|
||||
hovered_region_ids: params.hovered_region_ids.clone(),
|
||||
clicked_region_id: params.clicked_region_id,
|
||||
refreshing: params.refreshing,
|
||||
}
|
||||
|
@ -3447,14 +3447,14 @@ impl<'a, V: View> RenderContext<'a, V> {
|
|||
}
|
||||
|
||||
pub fn mouse_state<Tag: 'static>(&self, region_id: usize) -> MouseState {
|
||||
let region_id = Some(MouseRegionId {
|
||||
let region_id = MouseRegionId {
|
||||
view_id: self.view_id,
|
||||
tag: TypeId::of::<Tag>(),
|
||||
region_id,
|
||||
});
|
||||
};
|
||||
MouseState {
|
||||
hovered: self.hovered_region_id == region_id,
|
||||
clicked: self.clicked_region_id == region_id,
|
||||
hovered: self.hovered_region_ids.contains(®ion_id),
|
||||
clicked: self.clicked_region_id == Some(region_id),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue