Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set a transform on the root AccessKit node #764

Merged
merged 2 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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: 3 additions & 7 deletions masonry/src/passes/accessibility.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,7 @@ fn build_accessibility_tree(
// --- MARK: BUILD NODE ---
fn build_access_node(widget: &mut dyn Widget, ctx: &mut AccessCtx) -> Node {
let mut node = Node::new(widget.accessibility_role());
node.set_bounds(to_accesskit_rect(
ctx.widget_state.window_layout_rect(),
ctx.scale_factor,
DJMcNab marked this conversation as resolved.
Show resolved Hide resolved
));
node.set_bounds(to_accesskit_rect(ctx.widget_state.window_layout_rect()));

node.set_children(
widget
Expand Down Expand Up @@ -124,9 +121,8 @@ fn build_access_node(widget: &mut dyn Widget, ctx: &mut AccessCtx) -> Node {
node
}

fn to_accesskit_rect(r: Rect, scale_factor: f64) -> accesskit::Rect {
let sr = r.scale_from_origin(scale_factor);
accesskit::Rect::new(sr.x0, sr.y0, sr.x1, sr.y1)
fn to_accesskit_rect(r: Rect) -> accesskit::Rect {
accesskit::Rect::new(r.x0, r.y0, r.x1, r.y1)
}

// --- MARK: ROOT ---
Expand Down
4 changes: 3 additions & 1 deletion masonry/src/widget/root_widget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ impl<W: Widget> Widget for RootWidget<W> {
Role::Window
}

fn accessibility(&mut self, _ctx: &mut AccessCtx, _node: &mut Node) {}
fn accessibility(&mut self, ctx: &mut AccessCtx, node: &mut Node) {
node.set_transform(accesskit::Affine::scale(ctx.scale_factor));
}

fn children_ids(&self) -> SmallVec<[WidgetId; 16]> {
smallvec![self.pod.id()]
Expand Down