Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ parley = { version = "0.6.0", features = ["accesskit"] }
peniko = "0.5.0"
winit = "0.30.12"
tracing = { version = "0.1.41", default-features = false }
ui-events = "0.1.0"
ui-events-winit = "0.1.0"
ui-events = { version = "0.2.0", default-features = false, features = ["kurbo"] }
ui-events-winit = { version = "0.2.0", default-features = false }
smallvec = "1.15.1"
hashbrown = "0.16.0"
dpi = "0.1.2"
Expand Down
8 changes: 4 additions & 4 deletions masonry/examples/layers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
use masonry::accesskit::{Node, Role};
use masonry::core::{
AccessCtx, BoxConstraints, ChildrenIds, ErasedAction, EventCtx, LayoutCtx, NewWidget, NoAction,
PaintCtx, PointerEvent, PropertiesMut, PropertiesRef, RegisterCtx, StyleProperty, Update,
UpdateCtx, Widget, WidgetId, WidgetMut, WidgetPod,
PaintCtx, PointerEvent, PointerUpdate, PropertiesMut, PropertiesRef, RegisterCtx,
StyleProperty, Update, UpdateCtx, Widget, WidgetId, WidgetMut, WidgetPod,
};
use masonry::kurbo::{Point, Size};
use masonry::parley::FontWeight;
Expand Down Expand Up @@ -74,10 +74,10 @@ impl Widget for OverlayBox {
_props: &mut PropertiesMut<'_>,
event: &PointerEvent,
) {
if let PointerEvent::Move(e) = event
if let PointerEvent::Move(PointerUpdate { current, .. }) = event
&& ctx.is_hovered()
{
let position = ctx.window_origin() + ctx.local_position(e.current.position).to_vec2();
let position = current.logical_point();
if let Some(overlay_id) = self.layer_root_id {
ctx.reposition_layer(overlay_id, position);
} else {
Expand Down
5 changes: 1 addition & 4 deletions masonry/src/doc/color_rectangle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,7 @@ impl Widget for ColorRectangle {
event: &PointerEvent,
) {
match event {
PointerEvent::Down {
button: Some(PointerButton::Primary),
..
} => {
PointerEvent::Down(b) if b.button == Some(PointerButton::Primary) => {
ctx.submit_action::<Self::Action>(ColorRectanglePress);
}
_ => {}
Expand Down
8 changes: 4 additions & 4 deletions masonry/src/widgets/button.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ use vello::peniko::Color;
use crate::core::keyboard::{Key, NamedKey};
use crate::core::{
AccessCtx, AccessEvent, BoxConstraints, ChildrenIds, EventCtx, LayoutCtx, NewWidget, PaintCtx,
PointerEvent, PropertiesMut, PropertiesRef, RegisterCtx, TextEvent, Update, UpdateCtx, Widget,
WidgetId, WidgetMut, WidgetPod,
PointerButtonEvent, PointerEvent, PropertiesMut, PropertiesRef, RegisterCtx, TextEvent, Update,
UpdateCtx, Widget, WidgetId, WidgetMut, WidgetPod,
};
use crate::properties::{
ActiveBackground, Background, BorderColor, BorderWidth, BoxShadow, CornerRadius,
Expand Down Expand Up @@ -112,13 +112,13 @@ impl Widget for Button {
event: &PointerEvent,
) {
match event {
PointerEvent::Down { .. } => {
PointerEvent::Down(..) => {
ctx.capture_pointer();
// Changes in pointer capture impact appearance, but not accessibility node
ctx.request_paint_only();
trace!("Button {:?} pressed", ctx.widget_id());
}
PointerEvent::Up { button, .. } => {
PointerEvent::Up(PointerButtonEvent { button, .. }) => {
if ctx.is_active() && ctx.is_hovered() {
ctx.submit_action::<Self::Action>(ButtonPress { button: *button });
trace!("Button {:?} released", ctx.widget_id());
Expand Down
7 changes: 4 additions & 3 deletions masonry/src/widgets/portal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ use vello::kurbo::{Point, Rect, Size, Vec2};

use crate::core::{
AccessCtx, AccessEvent, Axis, BoxConstraints, ChildrenIds, ComposeCtx, EventCtx, FromDynWidget,
LayoutCtx, NewWidget, NoAction, PaintCtx, PointerEvent, PropertiesMut, PropertiesRef,
RegisterCtx, ScrollDelta, TextEvent, Update, UpdateCtx, Widget, WidgetId, WidgetMut, WidgetPod,
LayoutCtx, NewWidget, NoAction, PaintCtx, PointerEvent, PointerScrollEvent, PropertiesMut,
PropertiesRef, RegisterCtx, ScrollDelta, TextEvent, Update, UpdateCtx, Widget, WidgetId,
WidgetMut, WidgetPod,
};
use crate::widgets::ScrollBar;

Expand Down Expand Up @@ -270,7 +271,7 @@ impl<W: Widget + FromDynWidget + ?Sized> Widget for Portal<W> {
let content_size = self.content_size;

match *event {
PointerEvent::Scroll { delta, .. } => {
PointerEvent::Scroll(PointerScrollEvent { delta, .. }) => {
// TODO - Remove reference to scale factor.
// See https://github.com/linebender/xilem/issues/1264
let delta = match delta {
Expand Down
12 changes: 6 additions & 6 deletions masonry/src/widgets/scroll_bar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use vello::kurbo::{Point, Rect, Size};

use crate::core::{
AccessCtx, AccessEvent, AllowRawMut, Axis, BoxConstraints, ChildrenIds, EventCtx, LayoutCtx,
NoAction, PaintCtx, PointerEvent, PropertiesMut, PropertiesRef, RegisterCtx, TextEvent, Update,
UpdateCtx, Widget, WidgetId, WidgetMut,
NoAction, PaintCtx, PointerButtonEvent, PointerEvent, PointerUpdate, PropertiesMut,
PropertiesRef, RegisterCtx, TextEvent, Update, UpdateCtx, Widget, WidgetId, WidgetMut,
};
use crate::theme;
use crate::util::{fill_color, include_screenshot, stroke};
Expand Down Expand Up @@ -129,7 +129,7 @@ impl Widget for ScrollBar {
event: &PointerEvent,
) {
match event {
PointerEvent::Down { state, .. } => {
PointerEvent::Down(PointerButtonEvent { state, .. }) => {
ctx.capture_pointer();

let cursor_min_length = theme::SCROLLBAR_MIN_SIZE;
Expand All @@ -147,20 +147,20 @@ impl Widget for ScrollBar {
};
ctx.request_render();
}
PointerEvent::Move(u) => {
PointerEvent::Move(PointerUpdate { current, .. }) => {
if let Some(grab_anchor) = self.grab_anchor {
let cursor_min_length = theme::SCROLLBAR_MIN_SIZE;
self.cursor_progress = self.progress_from_mouse_pos(
ctx.size(),
cursor_min_length,
grab_anchor,
ctx.local_position(u.current.position),
ctx.local_position(current.position),
);
self.moved = true;
}
ctx.request_render();
}
PointerEvent::Up { .. } | PointerEvent::Cancel(..) => {
PointerEvent::Up(..) | PointerEvent::Cancel(..) => {
self.grab_anchor = None;
ctx.request_render();
}
Expand Down
16 changes: 8 additions & 8 deletions masonry/src/widgets/slider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ use vello::kurbo::{Circle, Point, Rect, Size};
use crate::core::keyboard::{Key, NamedKey};
use crate::core::{
AccessCtx, AccessEvent, BoxConstraints, ChildrenIds, EventCtx, HasProperty, LayoutCtx,
PaintCtx, PointerEvent, PropertiesMut, PropertiesRef, RegisterCtx, TextEvent, Update,
UpdateCtx, Widget, WidgetId, WidgetMut,
PaintCtx, PointerButtonEvent, PointerEvent, PointerUpdate, PropertiesMut, PropertiesRef,
RegisterCtx, TextEvent, Update, UpdateCtx, Widget, WidgetId, WidgetMut,
};
use crate::properties::{Background, BarColor, ThumbColor, ThumbRadius, TrackThickness};
use crate::theme;
Expand Down Expand Up @@ -154,11 +154,11 @@ impl Widget for Slider {
return;
}
match event {
PointerEvent::Down {
PointerEvent::Down(PointerButtonEvent {
button: Some(PointerButton::Primary),
state,
..
} => {
}) => {
ctx.request_focus();
ctx.capture_pointer();
let local_pos = ctx.local_position(state.position);
Expand All @@ -171,9 +171,9 @@ impl Widget for Slider {
ctx.submit_action::<f64>(self.value);
}
}
PointerEvent::Move(e) => {
PointerEvent::Move(PointerUpdate { current, .. }) => {
if ctx.is_active() {
let local_pos = ctx.local_position(e.current.position);
let local_pos = ctx.local_position(current.position);
if self.update_value_from_position(
local_pos.x,
ctx.size().width,
Expand All @@ -185,10 +185,10 @@ impl Widget for Slider {
ctx.request_render();
}
}
PointerEvent::Up {
PointerEvent::Up(PointerButtonEvent {
button: Some(PointerButton::Primary),
..
} => {
}) => {
if ctx.is_active() {
ctx.release_pointer();
}
Expand Down
11 changes: 6 additions & 5 deletions masonry/src/widgets/split.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ use vello::kurbo::{Line, Point, Rect, Size};

use crate::core::{
AccessCtx, AccessEvent, Axis, BoxConstraints, ChildrenIds, CursorIcon, EventCtx, FromDynWidget,
LayoutCtx, NewWidget, NoAction, PaintCtx, PointerEvent, PropertiesMut, PropertiesRef, QueryCtx,
RegisterCtx, TextEvent, Widget, WidgetId, WidgetMut, WidgetPod,
LayoutCtx, NewWidget, NoAction, PaintCtx, PointerButtonEvent, PointerEvent, PointerUpdate,
PropertiesMut, PropertiesRef, QueryCtx, RegisterCtx, TextEvent, Widget, WidgetId, WidgetMut,
WidgetPod,
};
use crate::peniko::Color;
use crate::properties::types::{AsUnit, Length};
Expand Down Expand Up @@ -395,7 +396,7 @@ where
) {
if self.draggable {
match event {
PointerEvent::Down { state, .. } => {
PointerEvent::Down(PointerButtonEvent { state, .. }) => {
let pos = ctx.local_position(state.position);
if self.bar_hit_test(ctx.size(), pos) {
ctx.set_handled();
Expand All @@ -407,9 +408,9 @@ where
} - self.bar_position(ctx.size());
}
}
PointerEvent::Move(u) => {
PointerEvent::Move(PointerUpdate { current, .. }) => {
if ctx.is_active() {
let pos = ctx.local_position(u.current.position);
let pos = ctx.local_position(current.position);
// If widget has pointer capture, assume always it's hovered
let effective_pos = match self.split_axis {
Axis::Horizontal => Point {
Expand Down
60 changes: 31 additions & 29 deletions masonry/src/widgets/text_area.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ use vello::peniko::Fill;
use crate::core::keyboard::{Key, KeyState, NamedKey};
use crate::core::{
AccessCtx, AccessEvent, BoxConstraints, BrushIndex, ChildrenIds, CursorIcon, EventCtx, Ime,
LayoutCtx, PaintCtx, PointerButton, PointerEvent, PropertiesMut, PropertiesRef, QueryCtx,
RegisterCtx, StyleProperty, TextEvent, Update, UpdateCtx, Widget, WidgetId, WidgetMut,
render_text,
LayoutCtx, PaintCtx, PointerButton, PointerButtonEvent, PointerEvent, PointerUpdate,
PropertiesMut, PropertiesRef, QueryCtx, RegisterCtx, StyleProperty, TextEvent, Update,
UpdateCtx, Widget, WidgetId, WidgetMut, render_text,
};
use crate::properties::{
CaretColor, ContentColor, DisabledContentColor, SelectionColor, UnfocusedSelectionColor,
Expand Down Expand Up @@ -493,37 +493,39 @@ impl<const EDITABLE: bool> Widget for TextArea<EDITABLE> {
}

match event {
PointerEvent::Down { button, state, .. } => {
if matches!(button, None | Some(PointerButton::Primary)) {
let cursor_pos = ctx.local_position(state.position);
let (fctx, lctx) = ctx.text_contexts();
let mut drv = self.editor.driver(fctx, lctx);
match state.count {
2 => drv.select_word_at_point(cursor_pos.x as f32, cursor_pos.y as f32),
3 => {
drv.select_hard_line_at_point(cursor_pos.x as f32, cursor_pos.y as f32);
}
_ => {
if state.modifiers.shift() {
drv.shift_click_extension(cursor_pos.x as f32, cursor_pos.y as f32);
} else {
drv.move_to_point(cursor_pos.x as f32, cursor_pos.y as f32);
}
}
PointerEvent::Down(PointerButtonEvent {
button: None | Some(PointerButton::Primary),
state,
..
}) => {
let cursor_pos = ctx.local_position(state.position);
let (fctx, lctx) = ctx.text_contexts();
let mut drv = self.editor.driver(fctx, lctx);
match state.count {
2 => drv.select_word_at_point(cursor_pos.x as f32, cursor_pos.y as f32),
3 => {
drv.select_hard_line_at_point(cursor_pos.x as f32, cursor_pos.y as f32);
}
let new_generation = self.editor.generation();
if new_generation != self.rendered_generation {
ctx.request_render();
ctx.set_ime_area(self.ime_area());
self.rendered_generation = new_generation;
_ => {
if state.modifiers.shift() {
drv.shift_click_extension(cursor_pos.x as f32, cursor_pos.y as f32);
} else {
drv.move_to_point(cursor_pos.x as f32, cursor_pos.y as f32);
}
}
ctx.request_focus();
ctx.capture_pointer();
}
let new_generation = self.editor.generation();
if new_generation != self.rendered_generation {
ctx.request_render();
ctx.set_ime_area(self.ime_area());
self.rendered_generation = new_generation;
}
ctx.request_focus();
ctx.capture_pointer();
}
PointerEvent::Move(u) => {
PointerEvent::Move(PointerUpdate { current, .. }) => {
if ctx.is_active() {
let cursor_pos = ctx.local_position(u.current.position);
let cursor_pos = ctx.local_position(current.position);
let (fctx, lctx) = ctx.text_contexts();
self.editor
.driver(fctx, lctx)
Expand Down
Loading