mirror of
https://github.com/enso-org/enso.git
synced 2024-12-24 23:21:36 +03:00
Fixing on-release event not working (https://github.com/enso-org/ide/pull/636)
Original commit: 9e0cd599b5
This commit is contained in:
parent
671d41079b
commit
82325eba1a
@ -243,7 +243,7 @@ impl Registry {
|
|||||||
let mouse = &model.mouse;
|
let mouse = &model.mouse;
|
||||||
|
|
||||||
frp::new_network! { network
|
frp::new_network! { network
|
||||||
mask <- all_with(&keyboard.key_mask,&mouse.button_mask,|k,m| ActionMask::new(k,m));
|
mask <- all_with(&keyboard.key_mask,&mouse.button_mask,|k,m|ActionMask::new(k,m));
|
||||||
nothing_pressed <- mask.map(|m| *m == default());
|
nothing_pressed <- mask.map(|m| *m == default());
|
||||||
nothing_pressed_prev <- nothing_pressed.previous();
|
nothing_pressed_prev <- nothing_pressed.previous();
|
||||||
press <- mask.gate_not(¬hing_pressed);
|
press <- mask.gate_not(¬hing_pressed);
|
||||||
@ -259,10 +259,13 @@ impl Registry {
|
|||||||
double_press <- press.gate(&is_double_press);
|
double_press <- press.gate(&is_double_press);
|
||||||
eval double_press ((m) model.process_action(ActionType::DoublePress,m));
|
eval double_press ((m) model.process_action(ActionType::DoublePress,m));
|
||||||
|
|
||||||
prev_mask <- all_with(&keyboard.previous_key_mask,&mouse.previous_button_mask,
|
prev_mask_on_key_up <- keyboard.key_mask.map3
|
||||||
|k,m| ActionMask::new(k,m));
|
(&keyboard.prev_key_mask,&mouse.button_mask,|_,k,m|ActionMask::new(k,m));
|
||||||
the_same_key <- prev_mask.map2(&mask,|t,s| t == s);
|
prev_mask_on_mouse_up <- mouse.button_mask.map3
|
||||||
release <- prev_mask.gate_not(&the_same_key);
|
(&keyboard.key_mask,&mouse.prev_button_mask,|_,k,m|ActionMask::new(k,m));
|
||||||
|
prev_mask <- any(prev_mask_on_key_up,prev_mask_on_mouse_up);
|
||||||
|
same_key <- prev_mask.map2(&mask,|t,s| t == s);
|
||||||
|
release <- prev_mask.gate_not(&same_key);
|
||||||
eval release ((m) model.process_action(ActionType::Release,m));
|
eval release ((m) model.process_action(ActionType::Release,m));
|
||||||
}
|
}
|
||||||
Self {model,network}
|
Self {model,network}
|
||||||
|
@ -35,7 +35,8 @@ pub trait BitField {
|
|||||||
#[derive(Clone,Default,Deref,Eq,Hash,PartialEq)]
|
#[derive(Clone,Default,Deref,Eq,Hash,PartialEq)]
|
||||||
#[allow(missing_copy_implementations)]
|
#[allow(missing_copy_implementations)]
|
||||||
pub struct BitField256 {
|
pub struct BitField256 {
|
||||||
chunks : [u128;2]
|
/// Raw chunks of this bit field.
|
||||||
|
pub chunks : [u128;2]
|
||||||
}
|
}
|
||||||
|
|
||||||
impl BitField256 {
|
impl BitField256 {
|
||||||
@ -88,7 +89,8 @@ macro_rules! define_single_chunk_bit_field {
|
|||||||
#[derive(Clone,Copy,Default,Deref,Eq,Hash,PartialEq)]
|
#[derive(Clone,Copy,Default,Deref,Eq,Hash,PartialEq)]
|
||||||
#[allow(missing_docs)]
|
#[allow(missing_docs)]
|
||||||
pub struct $name {
|
pub struct $name {
|
||||||
raw : $raw
|
/// Raw implementation of the bit field.
|
||||||
|
pub raw : $raw
|
||||||
}
|
}
|
||||||
|
|
||||||
impl $name {
|
impl $name {
|
||||||
|
@ -98,29 +98,29 @@ impl From<&KeyMask> for KeyMask { fn from(t:&KeyMask) -> Self {t.clone()} }
|
|||||||
#[derive(Clone,CloneRef,Debug)]
|
#[derive(Clone,CloneRef,Debug)]
|
||||||
#[allow(missing_docs)]
|
#[allow(missing_docs)]
|
||||||
pub struct Keyboard {
|
pub struct Keyboard {
|
||||||
pub network : frp::Network,
|
pub network : frp::Network,
|
||||||
pub on_pressed : frp::Source<Key>,
|
pub on_pressed : frp::Source<Key>,
|
||||||
pub on_released : frp::Source<Key>,
|
pub on_released : frp::Source<Key>,
|
||||||
pub on_defocus : frp::Source,
|
pub on_defocus : frp::Source,
|
||||||
pub key_mask : frp::Stream<KeyMask>,
|
pub key_mask : frp::Stream<KeyMask>,
|
||||||
pub previous_key_mask : frp::Stream<KeyMask>,
|
pub prev_key_mask : frp::Stream<KeyMask>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Keyboard {
|
impl Default for Keyboard {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
frp::new_network! { keyboard
|
frp::new_network! { keyboard
|
||||||
on_pressed <- source();
|
on_pressed <- source();
|
||||||
on_released <- source();
|
on_released <- source();
|
||||||
on_defocus <- source();
|
on_defocus <- source();
|
||||||
key_mask <- any_mut::<KeyMask>();
|
key_mask <- any_mut::<KeyMask>();
|
||||||
key_mask <+ on_pressed . map2(&key_mask,|key,mask| mask.with_set(key,true));
|
key_mask <+ on_pressed . map2(&key_mask,|key,mask| mask.with_set(key,true));
|
||||||
key_mask <+ on_released . map2(&key_mask,|key,mask| mask.with_set(key,false));
|
key_mask <+ on_released . map2(&key_mask,|key,mask| mask.with_set(key,false));
|
||||||
key_mask <+ on_defocus . map2(&key_mask,|_,_| default());
|
key_mask <+ on_defocus . map2(&key_mask,|_,_| default());
|
||||||
previous_key_mask <- key_mask.previous();
|
prev_key_mask <- key_mask.previous();
|
||||||
}
|
}
|
||||||
let network = keyboard;
|
let network = keyboard;
|
||||||
let key_mask = key_mask.into();
|
let key_mask = key_mask.into();
|
||||||
Keyboard {network,on_pressed,on_released,on_defocus,key_mask,previous_key_mask}
|
Keyboard {network,on_pressed,on_released,on_defocus,key_mask,prev_key_mask}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,37 +134,37 @@ impl From<&ButtonMask> for ButtonMask { fn from(t:&ButtonMask) -> Self {*t} }
|
|||||||
#[derive(Clone,CloneRef,Debug)]
|
#[derive(Clone,CloneRef,Debug)]
|
||||||
#[allow(missing_docs)]
|
#[allow(missing_docs)]
|
||||||
pub struct Mouse {
|
pub struct Mouse {
|
||||||
pub network : frp::Network,
|
pub network : frp::Network,
|
||||||
pub up : frp::Source<Button>,
|
pub up : frp::Source<Button>,
|
||||||
pub down : frp::Source<Button>,
|
pub down : frp::Source<Button>,
|
||||||
pub wheel : frp::Source,
|
pub wheel : frp::Source,
|
||||||
pub up_0 : frp::Stream,
|
pub up_0 : frp::Stream,
|
||||||
pub up_1 : frp::Stream,
|
pub up_1 : frp::Stream,
|
||||||
pub up_2 : frp::Stream,
|
pub up_2 : frp::Stream,
|
||||||
pub up_3 : frp::Stream,
|
pub up_3 : frp::Stream,
|
||||||
pub up_4 : frp::Stream,
|
pub up_4 : frp::Stream,
|
||||||
pub down_0 : frp::Stream,
|
pub down_0 : frp::Stream,
|
||||||
pub down_1 : frp::Stream,
|
pub down_1 : frp::Stream,
|
||||||
pub down_2 : frp::Stream,
|
pub down_2 : frp::Stream,
|
||||||
pub down_3 : frp::Stream,
|
pub down_3 : frp::Stream,
|
||||||
pub down_4 : frp::Stream,
|
pub down_4 : frp::Stream,
|
||||||
pub is_up_0 : frp::Stream<bool>,
|
pub is_up_0 : frp::Stream<bool>,
|
||||||
pub is_up_1 : frp::Stream<bool>,
|
pub is_up_1 : frp::Stream<bool>,
|
||||||
pub is_up_2 : frp::Stream<bool>,
|
pub is_up_2 : frp::Stream<bool>,
|
||||||
pub is_up_3 : frp::Stream<bool>,
|
pub is_up_3 : frp::Stream<bool>,
|
||||||
pub is_up_4 : frp::Stream<bool>,
|
pub is_up_4 : frp::Stream<bool>,
|
||||||
pub is_down_0 : frp::Stream<bool>,
|
pub is_down_0 : frp::Stream<bool>,
|
||||||
pub is_down_1 : frp::Stream<bool>,
|
pub is_down_1 : frp::Stream<bool>,
|
||||||
pub is_down_2 : frp::Stream<bool>,
|
pub is_down_2 : frp::Stream<bool>,
|
||||||
pub is_down_3 : frp::Stream<bool>,
|
pub is_down_3 : frp::Stream<bool>,
|
||||||
pub is_down_4 : frp::Stream<bool>,
|
pub is_down_4 : frp::Stream<bool>,
|
||||||
pub position : frp::Source<Vector2<f32>>,
|
pub position : frp::Source<Vector2<f32>>,
|
||||||
pub prev_position : frp::Stream<Vector2<f32>>,
|
pub prev_position : frp::Stream<Vector2<f32>>,
|
||||||
pub translation : frp::Stream<Vector2<f32>>,
|
pub translation : frp::Stream<Vector2<f32>>,
|
||||||
pub distance : frp::Stream<f32>,
|
pub distance : frp::Stream<f32>,
|
||||||
pub ever_moved : frp::Stream<bool>,
|
pub ever_moved : frp::Stream<bool>,
|
||||||
pub button_mask : frp::Stream<ButtonMask>,
|
pub button_mask : frp::Stream<ButtonMask>,
|
||||||
pub previous_button_mask : frp::Stream<ButtonMask>,
|
pub prev_button_mask : frp::Stream<ButtonMask>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Mouse {
|
impl Mouse {
|
||||||
@ -265,13 +265,13 @@ impl Default for Mouse {
|
|||||||
button_mask <+ down . map2(&button_mask,|button,mask| mask.with_set(*button,true));
|
button_mask <+ down . map2(&button_mask,|button,mask| mask.with_set(*button,true));
|
||||||
button_mask <+ up . map2(&button_mask,|button,mask| mask.with_set(*button,false));
|
button_mask <+ up . map2(&button_mask,|button,mask| mask.with_set(*button,false));
|
||||||
|
|
||||||
previous_button_mask <- button_mask.previous();
|
prev_button_mask <- button_mask.previous();
|
||||||
};
|
};
|
||||||
let button_mask = button_mask.into();
|
let button_mask = button_mask.into();
|
||||||
Self { network,up,down,wheel,up_0,up_1,up_2,up_3,up_4,down_0,down_1,down_2,down_3,down_4
|
Self { network,up,down,wheel,up_0,up_1,up_2,up_3,up_4,down_0,down_1,down_2,down_3,down_4
|
||||||
, is_down_0,is_down_1,is_down_2,is_down_3,is_down_4,is_up_0,is_up_1,is_up_2,is_up_3
|
, is_down_0,is_down_1,is_down_2,is_down_3,is_down_4,is_up_0,is_up_1,is_up_2,is_up_3
|
||||||
, is_up_4,position,prev_position,translation,distance,ever_moved,button_mask
|
, is_up_4,position,prev_position,translation,distance,ever_moved,button_mask
|
||||||
, previous_button_mask }
|
, prev_button_mask }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user