Skip to content

Commit

Permalink
rename mouse events to echo web apis
Browse files Browse the repository at this point in the history
  • Loading branch information
zackbrown committed Jan 30, 2024
1 parent f47d23a commit 5036d1e
Show file tree
Hide file tree
Showing 12 changed files with 59 additions and 59 deletions.
10 changes: 5 additions & 5 deletions examples/src/raycast-tests/src/lib.pax
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Text text={self.hit_outer}/>
<Text y=50px text={self.hit_inner}/>
<Frame width=50% @mouse_move=self.frame1>
<Frame width=50% @mousemove=self.frame1>
<Rectangle
@mouse_move=self.frame1rect1
@mousemove=self.frame1rect1
x=30%
y=40%
anchor_x=50%
Expand All @@ -12,7 +12,7 @@
fill={Fill::Solid(Color::hlc(50, 75.0, 150.0))}
/>
<Rectangle
@mouse_move=self.frame1rect2
@mousemove=self.frame1rect2
x=50%
y=50%
anchor_x=50%
Expand All @@ -22,9 +22,9 @@
fill={Fill::Solid(Color::hlc(20, 75.0, 150.0))}
/>
</Frame>
<Frame x=50% width=50% @mouse_move=self.frame2>
<Frame x=50% width=50% @mousemove=self.frame2>
<Rectangle
@mouse_move=self.frame2rect1
@mousemove=self.frame2rect1
x=60%
y=40%
anchor_x=50%
Expand Down
10 changes: 5 additions & 5 deletions examples/src/raycast-tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,23 @@ pub struct Example {
impl Example {
pub fn handle_mount(&mut self, ctx: &NodeContext) {}

pub fn frame1(&mut self, ctx: &NodeContext, args: ArgsMouseMove) {
pub fn frame1(&mut self, ctx: &NodeContext, args: ArgsMousemove) {
self.hit_outer.set(format!("hit outer: frame {}", 1));
}

pub fn frame2(&mut self, ctx: &NodeContext, args: ArgsMouseMove) {
pub fn frame2(&mut self, ctx: &NodeContext, args: ArgsMousemove) {
self.hit_outer.set(format!("hit outer: frame {}", 2));
}

pub fn frame1rect1(&mut self, ctx: &NodeContext, args: ArgsMouseMove) {
pub fn frame1rect1(&mut self, ctx: &NodeContext, args: ArgsMousemove) {
self.hit_inner.set(format!("hit inner: rect {}", 1));
}

pub fn frame1rect2(&mut self, ctx: &NodeContext, args: ArgsMouseMove) {
pub fn frame1rect2(&mut self, ctx: &NodeContext, args: ArgsMousemove) {
self.hit_inner.set(format!("hit inner: rect {}", 2));
}

pub fn frame2rect1(&mut self, ctx: &NodeContext, args: ArgsMouseMove) {
pub fn frame2rect1(&mut self, ctx: &NodeContext, args: ArgsMousemove) {
self.hit_inner.set(format!("hit inner: rect {}", 1));
}
}
10 changes: 5 additions & 5 deletions examples/src/words/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use pax_lang::api::{
ArgsClick, ArgsClap, ArgsScroll, ArgsTouchStart, ArgsTouchMove, ArgsTouchEnd,
ArgsKeyDown, ArgsKeyUp, ArgsKeyPress, ArgsDoubleClick, ArgsMouseMove, ArgsWheel,
ArgsMouseDown, ArgsMouseUp, ArgsMouseOver, ArgsMouseOut, ArgsContextMenu,
ArgsKeyDown, ArgsKeyUp, ArgsKeyPress, ArgsDoubleClick, ArgsMousemove, ArgsWheel,
ArgsMousedown, ArgsMouseup, ArgsMouseOver, ArgsMouseOut, ArgsContextMenu,
NodeContext, Property, PropertyLiteral
};
use pax_lang::Pax;
Expand Down Expand Up @@ -59,19 +59,19 @@ impl Words {
self.content.set("Double Click".to_string());
}

pub fn handle_mouse_move(&mut self, _ctx: &NodeContext, _args: ArgsMouseMove) {
pub fn handle_mousemove(&mut self, _ctx: &NodeContext, _args: ArgsMousemove) {
self.content.set("Mouse Move".to_string());
}

pub fn handle_wheel(&mut self, _ctx: &NodeContext, _args: ArgsWheel) {
self.content.set("Wheel".to_string());
}

pub fn handle_mouse_down(&mut self, _ctx: &NodeContext, _args: ArgsMouseDown) {
pub fn handle_mousedown(&mut self, _ctx: &NodeContext, _args: ArgsMousedown) {
self.content.set("Mouse Down".to_string());
}

pub fn handle_mouse_up(&mut self, _ctx: &NodeContext, _args: ArgsMouseUp) {
pub fn handle_mouseup(&mut self, _ctx: &NodeContext, _args: ArgsMouseup) {
self.content.set("Mouse Up".to_string());
}

Expand Down
6 changes: 3 additions & 3 deletions examples/src/words/src/words.pax
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ fill={Fill::linearGradient(
key_press: handle_key_press,
click: handle_click,
double_click: handle_double_click,
mouse_move: handle_mouse_move,
mousemove: handle_mousemove,
wheel: handle_wheel,
mouse_down: handle_mouse_down,
mouse_up: handle_mouse_up,
mousedown: handle_mousedown,
mouseup: handle_mouseup,
mouse_over: handle_mouse_over,
mouse_out: handle_mouse_out,
context_menu: handle_context_menu,
Expand Down
6 changes: 3 additions & 3 deletions pax-chassis-web/interface/public/pax-chassis-web-interface.js
Original file line number Diff line number Diff line change
Expand Up @@ -1631,7 +1631,7 @@ var Pax = (() => {
}, true);
layer.addEventListener("mousemove", (evt) => {
let event = {
"MouseMove": {
"Mousemove": {
"x": evt.clientX,
"y": evt.clientY,
"button": getMouseButton(evt),
Expand All @@ -1654,7 +1654,7 @@ var Pax = (() => {
}, { "passive": true, "capture": true });
layer.addEventListener("mousedown", (evt) => {
let event = {
"MouseDown": {
"Mousedown": {
"x": evt.clientX,
"y": evt.clientY,
"button": getMouseButton(evt),
Expand All @@ -1665,7 +1665,7 @@ var Pax = (() => {
}, true);
layer.addEventListener("mouseup", (evt) => {
let event = {
"MouseUp": {
"Mouseup": {
"x": evt.clientX,
"y": evt.clientY,
"button": getMouseButton(evt),
Expand Down
6 changes: 3 additions & 3 deletions pax-chassis-web/interface/src/events/listeners.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export function setupEventListeners(chassis: PaxChassisWeb, layer: any) {
// @ts-ignore
layer.addEventListener('mousemove', (evt) => {
let event = {
"MouseMove": {
"Mousemove": {
"x": evt.clientX,
"y": evt.clientY,
"button": getMouseButton(evt),
Expand All @@ -98,7 +98,7 @@ export function setupEventListeners(chassis: PaxChassisWeb, layer: any) {
// @ts-ignore
layer.addEventListener('mousedown', (evt) => {
let event = {
"MouseDown": {
"Mousedown": {
"x": evt.clientX,
"y": evt.clientY,
"button": getMouseButton(evt),
Expand All @@ -110,7 +110,7 @@ export function setupEventListeners(chassis: PaxChassisWeb, layer: any) {
// @ts-ignore
layer.addEventListener('mouseup', (evt) => {
let event = {
"MouseUp": {
"Mouseup": {
"x": evt.clientX,
"y": evt.clientY,
"button": getMouseButton(evt),
Expand Down
20 changes: 10 additions & 10 deletions pax-chassis-web/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use pax_core::{PaxEngine, Renderer};
use pax_message::{ImageLoadInterruptArgs, NativeInterrupt};
use pax_runtime_api::{
ArgsClap, ArgsClick, ArgsContextMenu, ArgsDoubleClick, ArgsKeyDown, ArgsKeyPress, ArgsKeyUp,
ArgsMouseDown, ArgsMouseMove, ArgsMouseOut, ArgsMouseOver, ArgsMouseUp, ArgsScroll,
ArgsMousedown, ArgsMousemove, ArgsMouseOut, ArgsMouseOver, ArgsMouseup, ArgsScroll,
ArgsTouchEnd, ArgsTouchMove, ArgsTouchStart, ArgsWheel, KeyboardEventArgs, ModifierKey,
MouseButton, MouseEventArgs, Touch,
};
Expand Down Expand Up @@ -336,10 +336,10 @@ impl PaxChassisWeb {
topmost_node.dispatch_double_click(args_double_click, globals);
}
}
NativeInterrupt::MouseMove(args) => {
NativeInterrupt::Mousemove(args) => {
let prospective_hit = engine.get_topmost_element_beneath_ray((args.x, args.y));
if let Some(topmost_node) = prospective_hit {
let args_mouse_move = ArgsMouseMove {
let args_mousemove = ArgsMousemove {
mouse: MouseEventArgs {
x: args.x,
y: args.y,
Expand All @@ -351,7 +351,7 @@ impl PaxChassisWeb {
.collect(),
},
};
topmost_node.dispatch_mouse_move(args_mouse_move, globals);
topmost_node.dispatch_mousemove(args_mousemove, globals);
}
}
NativeInterrupt::Wheel(args) => {
Expand All @@ -372,10 +372,10 @@ impl PaxChassisWeb {
topmost_node.dispatch_wheel(args_wheel, globals);
}
}
NativeInterrupt::MouseDown(args) => {
NativeInterrupt::Mousedown(args) => {
let prospective_hit = engine.get_topmost_element_beneath_ray((args.x, args.y));
if let Some(topmost_node) = prospective_hit {
let args_mouse_down = ArgsMouseDown {
let args_mousedown = ArgsMousedown {
mouse: MouseEventArgs {
x: args.x,
y: args.y,
Expand All @@ -387,13 +387,13 @@ impl PaxChassisWeb {
.collect(),
},
};
topmost_node.dispatch_mouse_down(args_mouse_down, globals);
topmost_node.dispatch_mousedown(args_mousedown, globals);
}
}
NativeInterrupt::MouseUp(args) => {
NativeInterrupt::Mouseup(args) => {
let prospective_hit = engine.get_topmost_element_beneath_ray((args.x, args.y));
if let Some(topmost_node) = prospective_hit {
let args_mouse_up = ArgsMouseUp {
let args_mouseup = ArgsMouseup {
mouse: MouseEventArgs {
x: args.x,
y: args.y,
Expand All @@ -405,7 +405,7 @@ impl PaxChassisWeb {
.collect(),
},
};
topmost_node.dispatch_mouse_up(args_mouse_up, globals);
topmost_node.dispatch_mouseup(args_mouseup, globals);
}
}
NativeInterrupt::MouseOver(args) => {
Expand Down
16 changes: 8 additions & 8 deletions pax-core/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use pax_message::{NativeMessage, OcclusionPatch};

use pax_runtime_api::{
ArgsButtonClick, ArgsCheckboxChange, ArgsClap, ArgsClick, ArgsContextMenu, ArgsDoubleClick,
ArgsKeyDown, ArgsKeyPress, ArgsKeyUp, ArgsMouseDown, ArgsMouseMove, ArgsMouseOut,
ArgsMouseOver, ArgsMouseUp, ArgsScroll, ArgsTextboxChange, ArgsTouchEnd, ArgsTouchMove,
ArgsKeyDown, ArgsKeyPress, ArgsKeyUp, ArgsMousedown, ArgsMousemove, ArgsMouseOut,
ArgsMouseOver, ArgsMouseup, ArgsScroll, ArgsTextboxChange, ArgsTouchEnd, ArgsTouchMove,
ArgsTouchStart, ArgsWheel, CommonProperties, Interpolatable, Layer, NodeContext,
OcclusionLayerGen, RenderContext, TransitionManager,
};
Expand Down Expand Up @@ -91,9 +91,9 @@ pub struct HandlerRegistry {
pub button_click_handlers: Vec<fn(Rc<RefCell<dyn Any>>, &NodeContext, ArgsButtonClick)>,
pub textbox_change_handlers: Vec<fn(Rc<RefCell<dyn Any>>, &NodeContext, ArgsTextboxChange)>,
pub click_handlers: Vec<fn(Rc<RefCell<dyn Any>>, &NodeContext, ArgsClick)>,
pub mouse_down_handlers: Vec<fn(Rc<RefCell<dyn Any>>, &NodeContext, ArgsMouseDown)>,
pub mouse_up_handlers: Vec<fn(Rc<RefCell<dyn Any>>, &NodeContext, ArgsMouseUp)>,
pub mouse_move_handlers: Vec<fn(Rc<RefCell<dyn Any>>, &NodeContext, ArgsMouseMove)>,
pub mousedown_handlers: Vec<fn(Rc<RefCell<dyn Any>>, &NodeContext, ArgsMousedown)>,
pub mouseup_handlers: Vec<fn(Rc<RefCell<dyn Any>>, &NodeContext, ArgsMouseup)>,
pub mousemove_handlers: Vec<fn(Rc<RefCell<dyn Any>>, &NodeContext, ArgsMousemove)>,
pub mouse_over_handlers: Vec<fn(Rc<RefCell<dyn Any>>, &NodeContext, ArgsMouseOver)>,
pub mouse_out_handlers: Vec<fn(Rc<RefCell<dyn Any>>, &NodeContext, ArgsMouseOut)>,
pub double_click_handlers: Vec<fn(Rc<RefCell<dyn Any>>, &NodeContext, ArgsDoubleClick)>,
Expand All @@ -116,9 +116,9 @@ impl Default for HandlerRegistry {
key_up_handlers: Vec::new(),
key_press_handlers: Vec::new(),
click_handlers: Vec::new(),
mouse_down_handlers: Vec::new(),
mouse_up_handlers: Vec::new(),
mouse_move_handlers: Vec::new(),
mousedown_handlers: Vec::new(),
mouseup_handlers: Vec::new(),
mousemove_handlers: Vec::new(),
mouse_over_handlers: Vec::new(),
mouse_out_handlers: Vec::new(),
double_click_handlers: Vec::new(),
Expand Down
10 changes: 5 additions & 5 deletions pax-core/src/engine/expanded_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use kurbo::Point;

use pax_runtime_api::{
ArgsButtonClick, ArgsCheckboxChange, ArgsClap, ArgsClick, ArgsContextMenu, ArgsDoubleClick,
ArgsKeyDown, ArgsKeyPress, ArgsKeyUp, ArgsMouseDown, ArgsMouseMove, ArgsMouseOut,
ArgsMouseOver, ArgsMouseUp, ArgsScroll, ArgsTextboxChange, ArgsTouchEnd, ArgsTouchMove,
ArgsKeyDown, ArgsKeyPress, ArgsKeyUp, ArgsMousedown, ArgsMousemove, ArgsMouseOut,
ArgsMouseOver, ArgsMouseup, ArgsScroll, ArgsTextboxChange, ArgsTouchEnd, ArgsTouchMove,
ArgsTouchStart, ArgsWheel, Axis, CommonProperties, NodeContext, RenderContext, Size,
};

Expand Down Expand Up @@ -445,9 +445,9 @@ impl ExpandedNode {
ArgsButtonClick,
button_click_handlers
);
dispatch_event_handler!(dispatch_mouse_down, ArgsMouseDown, mouse_down_handlers);
dispatch_event_handler!(dispatch_mouse_up, ArgsMouseUp, mouse_up_handlers);
dispatch_event_handler!(dispatch_mouse_move, ArgsMouseMove, mouse_move_handlers);
dispatch_event_handler!(dispatch_mousedown, ArgsMousedown, mousedown_handlers);
dispatch_event_handler!(dispatch_mouseup, ArgsMouseup, mouseup_handlers);
dispatch_event_handler!(dispatch_mousemove, ArgsMousemove, mousemove_handlers);
dispatch_event_handler!(dispatch_mouse_over, ArgsMouseOver, mouse_over_handlers);
dispatch_event_handler!(dispatch_mouse_out, ArgsMouseOut, mouse_out_handlers);
dispatch_event_handler!(
Expand Down
6 changes: 3 additions & 3 deletions pax-language-server/src/completion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,9 +289,9 @@ lazy_static! {
("key_up", "Set Key Up event handler"),
("key_press", "Set Key Press event handler"),
("click", "Set Click event handler"),
("mouse_down", "Set Mouse Down event handler"),
("mouse_up", "Set Mouse Up event handler"),
("mouse_move", "Set Mouse Move event handler"),
("mousedown", "Set Mouse Down event handler"),
("mouseup", "Set Mouse Up event handler"),
("mousemove", "Set Mouse Move event handler"),
("mouse_over", "Set Mouse Over event handler"),
("mouse_out", "Set Mouse Out event handler"),
("double_click", "Set Double Click event handler"),
Expand Down
12 changes: 6 additions & 6 deletions pax-message/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ pub enum NativeInterrupt {
KeyPress(KeyPressInterruptArgs),
Click(ClickInterruptArgs),
DoubleClick(DoubleClickInterruptArgs),
MouseMove(MouseMoveInterruptArgs),
Mousemove(MousemoveInterruptArgs),
Wheel(WheelInterruptArgs),
MouseDown(MouseDownInterruptArgs),
MouseUp(MouseUpInterruptArgs),
Mousedown(MousedownInterruptArgs),
Mouseup(MouseupInterruptArgs),
MouseOver(MouseOverInterruptArgs),
MouseOut(MouseOutInterruptArgs),
ContextMenu(ContextMenuInterruptArgs),
Expand Down Expand Up @@ -186,7 +186,7 @@ pub struct DoubleClickInterruptArgs {

#[derive(Deserialize)]
#[repr(C)]
pub struct MouseMoveInterruptArgs {
pub struct MousemoveInterruptArgs {
pub x: f64,
pub y: f64,
pub button: MouseButtonMessage,
Expand All @@ -205,7 +205,7 @@ pub struct WheelInterruptArgs {

#[derive(Deserialize)]
#[repr(C)]
pub struct MouseDownInterruptArgs {
pub struct MousedownInterruptArgs {
pub x: f64,
pub y: f64,
pub button: MouseButtonMessage,
Expand All @@ -214,7 +214,7 @@ pub struct MouseDownInterruptArgs {

#[derive(Deserialize)]
#[repr(C)]
pub struct MouseUpInterruptArgs {
pub struct MouseupInterruptArgs {
pub x: f64,
pub y: f64,
pub button: MouseButtonMessage,
Expand Down
6 changes: 3 additions & 3 deletions pax-runtime-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ pub struct ArgsDoubleClick {

/// User moves the mouse while it is over an element.
#[derive(Clone)]
pub struct ArgsMouseMove {
pub struct ArgsMousemove {
pub mouse: MouseEventArgs,
}

Expand Down Expand Up @@ -296,13 +296,13 @@ pub struct ArgsButtonClick {}

/// User presses a mouse button over an element.
#[derive(Clone)]
pub struct ArgsMouseDown {
pub struct ArgsMousedown {
pub mouse: MouseEventArgs,
}

/// User releases a mouse button over an element.
#[derive(Clone)]
pub struct ArgsMouseUp {
pub struct ArgsMouseup {
pub mouse: MouseEventArgs,
}

Expand Down

0 comments on commit 5036d1e

Please sign in to comment.