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
1 change: 1 addition & 0 deletions masonry/src/widgets/button.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ impl Button {
Label::set_text(&mut Self::label_mut(this), new_text);
}

#[expect(missing_docs, reason = "TODO")]
pub fn label_mut<'t>(this: &'t mut WidgetMut<'_, Self>) -> WidgetMut<'t, Label> {
this.ctx.get_mut(&mut this.widget.label)
}
Expand Down
2 changes: 2 additions & 0 deletions masonry/src/widgets/checkbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ impl Checkbox {

// --- MARK: WIDGETMUT ---
impl Checkbox {
#[expect(missing_docs, reason = "TODO")]
pub fn set_checked(this: &mut WidgetMut<'_, Self>, checked: bool) {
this.widget.checked = checked;
// Checked state impacts appearance and accessibility node
Expand All @@ -59,6 +60,7 @@ impl Checkbox {
Label::set_text(&mut Self::label_mut(this), new_text);
}

#[expect(missing_docs, reason = "TODO")]
pub fn label_mut<'t>(this: &'t mut WidgetMut<'_, Self>) -> WidgetMut<'t, Label> {
this.ctx.get_mut(&mut this.widget.label)
}
Expand Down
9 changes: 9 additions & 0 deletions masonry/src/widgets/flex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ impl Flex {
self.with_child_pod(WidgetPod::new_with_id(child, id).erased())
}

/// Builder-style method for [adding](Flex::add_child) a type-erased child to this.
pub fn with_child_pod(mut self, widget: WidgetPod<dyn Widget>) -> Self {
let child = Child::Fixed {
widget,
Expand Down Expand Up @@ -293,10 +294,12 @@ impl Flex {
self
}

#[expect(missing_docs, reason = "TODO")]
pub fn len(&self) -> usize {
self.children.len()
}

#[expect(missing_docs, reason = "TODO")]
pub fn is_empty(&self) -> bool {
self.len() == 0
}
Expand Down Expand Up @@ -387,6 +390,7 @@ impl Flex {
this.ctx.children_changed();
}

#[expect(missing_docs, reason = "TODO")]
pub fn add_child_id(this: &mut WidgetMut<'_, Self>, child: impl Widget, id: WidgetId) {
let child = Child::Fixed {
widget: WidgetPod::new_with_id(child, id).erased(),
Expand Down Expand Up @@ -472,6 +476,7 @@ impl Flex {
this.ctx.children_changed();
}

#[expect(missing_docs, reason = "TODO")]
pub fn insert_flex_child(
this: &mut WidgetMut<'_, Self>,
idx: usize,
Expand All @@ -481,6 +486,7 @@ impl Flex {
Self::insert_flex_child_pod(this, idx, WidgetPod::new(child).erased(), params);
}

#[expect(missing_docs, reason = "TODO")]
pub fn insert_flex_child_pod(
this: &mut WidgetMut<'_, Self>,
idx: usize,
Expand Down Expand Up @@ -533,6 +539,7 @@ impl Flex {
this.ctx.request_layout();
}

#[expect(missing_docs, reason = "TODO")]
pub fn remove_child(this: &mut WidgetMut<'_, Self>, idx: usize) {
let child = this.widget.children.remove(idx);
if let Child::Fixed { widget, .. } | Child::Flex { widget, .. } = child {
Expand All @@ -541,6 +548,7 @@ impl Flex {
this.ctx.request_layout();
}

#[expect(missing_docs, reason = "TODO")]
pub fn child_mut<'t>(
this: &'t mut WidgetMut<'_, Self>,
idx: usize,
Expand Down Expand Up @@ -615,6 +623,7 @@ impl Flex {
this.ctx.children_changed();
}

#[expect(missing_docs, reason = "TODO")]
pub fn clear(this: &mut WidgetMut<'_, Self>) {
if !this.widget.children.is_empty() {
this.ctx.request_layout();
Expand Down
14 changes: 14 additions & 0 deletions masonry/src/widgets/grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ struct Child {
}

#[derive(Default, Debug, Copy, Clone, PartialEq)]
#[expect(missing_docs, reason = "TODO")]
pub struct GridParams {
pub x: i32,
pub y: i32,
Expand All @@ -41,6 +42,7 @@ pub struct GridParams {

// --- MARK: IMPL GRID ---
impl Grid {
#[expect(missing_docs, reason = "TODO")]
pub fn with_dimensions(width: i32, height: i32) -> Self {
Self {
children: Vec::new(),
Expand All @@ -50,6 +52,7 @@ impl Grid {
}
}

#[expect(missing_docs, reason = "TODO")]
pub fn with_spacing(mut self, spacing: f64) -> Self {
self.grid_spacing = spacing;
self
Expand All @@ -62,10 +65,12 @@ impl Grid {
self.with_child_pod(WidgetPod::new(child).erased(), params)
}

#[expect(missing_docs, reason = "TODO")]
pub fn with_child_id(self, child: impl Widget, id: WidgetId, params: GridParams) -> Self {
self.with_child_pod(WidgetPod::new_with_id(child, id).erased(), params)
}

#[expect(missing_docs, reason = "TODO")]
pub fn with_child_pod(mut self, widget: WidgetPod<dyn Widget>, params: GridParams) -> Self {
let child = Child {
widget,
Expand Down Expand Up @@ -108,6 +113,7 @@ fn new_grid_child(params: GridParams, widget: WidgetPod<dyn Widget>) -> Child {

// --- MARK: IMPL GRIDPARAMS ---
impl GridParams {
#[expect(missing_docs, reason = "TODO")]
pub fn new(mut x: i32, mut y: i32, mut width: i32, mut height: i32) -> Self {
if x < 0 {
debug_panic!("Grid x value should be a non-negative number; got {}", x);
Expand Down Expand Up @@ -152,6 +158,7 @@ impl Grid {
Self::insert_child_pod(this, child_pod, params);
}

#[expect(missing_docs, reason = "TODO")]
pub fn add_child_id(
this: &mut WidgetMut<'_, Self>,
child: impl Widget,
Expand All @@ -174,6 +181,7 @@ impl Grid {
this.ctx.request_layout();
}

#[expect(missing_docs, reason = "TODO")]
pub fn insert_grid_child_at(
this: &mut WidgetMut<'_, Self>,
idx: usize,
Expand All @@ -183,6 +191,7 @@ impl Grid {
Self::insert_grid_child_pod(this, idx, WidgetPod::new(child).erased(), params);
}

#[expect(missing_docs, reason = "TODO")]
pub fn insert_grid_child_pod(
this: &mut WidgetMut<'_, Self>,
idx: usize,
Expand All @@ -195,21 +204,25 @@ impl Grid {
this.ctx.request_layout();
}

#[expect(missing_docs, reason = "TODO")]
pub fn set_spacing(this: &mut WidgetMut<'_, Self>, spacing: f64) {
this.widget.grid_spacing = spacing;
this.ctx.request_layout();
}

#[expect(missing_docs, reason = "TODO")]
pub fn set_width(this: &mut WidgetMut<'_, Self>, width: i32) {
this.widget.grid_width = width;
this.ctx.request_layout();
}

#[expect(missing_docs, reason = "TODO")]
pub fn set_height(this: &mut WidgetMut<'_, Self>, height: i32) {
this.widget.grid_height = height;
this.ctx.request_layout();
}

#[expect(missing_docs, reason = "TODO")]
pub fn child_mut<'t>(
this: &'t mut WidgetMut<'_, Self>,
idx: usize,
Expand All @@ -233,6 +246,7 @@ impl Grid {
this.ctx.request_layout();
}

#[expect(missing_docs, reason = "TODO")]
pub fn remove_child(this: &mut WidgetMut<'_, Self>, idx: usize) {
let child = this.widget.children.remove(idx);
this.ctx.remove_child(child.widget);
Expand Down
2 changes: 0 additions & 2 deletions masonry/src/widgets/label.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright 2019 the Xilem Authors and the Druid Authors
// SPDX-License-Identifier: Apache-2.0

#![warn(missing_docs)]

//! A label widget.

use std::mem::Discriminant;
Expand Down
3 changes: 0 additions & 3 deletions masonry/src/widgets/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@

//! Common widgets.

// We use allow because expect(missing_docs) is noisy with rust-analyzer.
#![allow(missing_docs, reason = "We have many as-yet undocumented items")]

#[cfg(test)]
mod tests;

Expand Down
12 changes: 10 additions & 2 deletions masonry/src/widgets/portal.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright 2020 the Xilem Authors and the Druid Authors
// SPDX-License-Identifier: Apache-2.0

#![allow(missing_docs)]

use std::ops::Range;

use accesskit::{Node, Role};
Expand All @@ -23,6 +21,7 @@ use crate::widgets::{Axis, ScrollBar};
// TODO - Document which cases need request_layout, request_compose and request_render
// Conceptually, a Portal is a Widget giving a restricted view of a child widget
// Imagine a very large widget, and a rect that represents the part of the widget we see
#[expect(missing_docs, reason = "TODO")]
pub struct Portal<W: Widget + ?Sized> {
child: WidgetPod<W>,
// TODO - differentiate between the "explicit" viewport pos determined
Expand All @@ -42,12 +41,14 @@ pub struct Portal<W: Widget + ?Sized> {

// --- MARK: BUILDERS ---
impl<W: Widget> Portal<W> {
#[expect(missing_docs, reason = "TODO")]
pub fn new(child: W) -> Self {
Self::new_pod(WidgetPod::new(child))
}
}

impl<W: Widget + ?Sized> Portal<W> {
#[expect(missing_docs, reason = "TODO")]
pub fn new_pod(child: WidgetPod<W>) -> Self {
Self {
child,
Expand All @@ -63,6 +64,7 @@ impl<W: Widget + ?Sized> Portal<W> {
}
}

#[expect(missing_docs, reason = "TODO")]
pub fn get_viewport_pos(&self) -> Point {
self.viewport_pos
}
Expand Down Expand Up @@ -171,16 +173,19 @@ impl<W: Widget + ?Sized> Portal<W> {

// --- MARK: WIDGETMUT ---
impl<W: Widget + FromDynWidget + ?Sized> Portal<W> {
#[expect(missing_docs, reason = "TODO")]
pub fn child_mut<'t>(this: &'t mut WidgetMut<'_, Self>) -> WidgetMut<'t, W> {
this.ctx.get_mut(&mut this.widget.child)
}

#[expect(missing_docs, reason = "TODO")]
pub fn horizontal_scrollbar_mut<'t>(
this: &'t mut WidgetMut<'_, Self>,
) -> WidgetMut<'t, ScrollBar> {
this.ctx.get_mut(&mut this.widget.scrollbar_horizontal)
}

#[expect(missing_docs, reason = "TODO")]
pub fn vertical_scrollbar_mut<'t>(
this: &'t mut WidgetMut<'_, Self>,
) -> WidgetMut<'t, ScrollBar> {
Expand Down Expand Up @@ -211,6 +216,7 @@ impl<W: Widget + FromDynWidget + ?Sized> Portal<W> {
this.ctx.request_layout();
}

#[expect(missing_docs, reason = "TODO")]
pub fn set_viewport_pos(this: &mut WidgetMut<'_, Self>, position: Point) -> bool {
let portal_size = this.ctx.local_layout_rect().size();
let content_size = this
Expand All @@ -235,10 +241,12 @@ impl<W: Widget + FromDynWidget + ?Sized> Portal<W> {
pos_changed
}

#[expect(missing_docs, reason = "TODO")]
pub fn pan_viewport_by(this: &mut WidgetMut<'_, Self>, translation: Vec2) -> bool {
Self::set_viewport_pos(this, this.widget.viewport_pos + translation)
}

#[expect(missing_docs, reason = "TODO")]
// Note - Rect is in child coordinates
pub fn pan_viewport_to(this: &mut WidgetMut<'_, Self>, target: Rect) -> bool {
let viewport = Rect::from_origin_size(this.widget.viewport_pos, this.ctx.widget_state.size);
Expand Down
1 change: 1 addition & 0 deletions masonry/src/widgets/progress_bar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ impl ProgressBar {

// --- MARK: WIDGETMUT ---
impl ProgressBar {
#[expect(missing_docs, reason = "TODO")]
pub fn set_progress(this: &mut WidgetMut<'_, Self>, mut progress: Option<f64>) {
clamp_progress(&mut progress);
let progress_changed = this.widget.progress != progress;
Expand Down
2 changes: 0 additions & 2 deletions masonry/src/widgets/prose.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright 2018 the Xilem Authors and the Druid Authors
// SPDX-License-Identifier: Apache-2.0

#![warn(missing_docs)]

use accesskit::{Node, Role};
use smallvec::{SmallVec, smallvec};
use tracing::{Span, trace_span};
Expand Down
4 changes: 4 additions & 0 deletions masonry/src/widgets/root_widget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ use crate::kurbo::Size;

// TODO: This is a hack to provide an accessibility node with a Window type.
// This should eventually be removed.
#[expect(missing_docs, reason = "TODO")]
pub struct RootWidget<W: ?Sized> {
pub(crate) pod: WidgetPod<W>,
}

impl<W: Widget> RootWidget<W> {
#[expect(missing_docs, reason = "TODO")]
pub fn new(widget: W) -> Self {
Self {
pod: WidgetPod::new(widget),
Expand All @@ -29,12 +31,14 @@ impl<W: Widget> RootWidget<W> {
}

impl<W: Widget + FromDynWidget + ?Sized> RootWidget<W> {
#[expect(missing_docs, reason = "TODO")]
pub fn from_pod(pod: WidgetPod<W>) -> Self {
Self { pod }
}
}

impl<W: Widget + FromDynWidget + ?Sized> RootWidget<W> {
#[expect(missing_docs, reason = "TODO")]
pub fn child_mut<'t>(this: &'t mut WidgetMut<'_, Self>) -> WidgetMut<'t, W> {
this.ctx.get_mut(&mut this.widget.pod)
}
Expand Down
5 changes: 3 additions & 2 deletions masonry/src/widgets/scroll_bar.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright 2022 the Xilem Authors
// SPDX-License-Identifier: Apache-2.0

#![allow(missing_docs)]

use accesskit::{Node, Role};
use smallvec::SmallVec;
use tracing::{Span, trace_span};
Expand Down Expand Up @@ -40,6 +38,7 @@ pub struct ScrollBar {

// --- MARK: BUILDERS ---
impl ScrollBar {
#[expect(missing_docs, reason = "TODO")]
pub fn new(axis: Axis, portal_size: f64, content_size: f64) -> Self {
Self {
axis,
Expand Down Expand Up @@ -106,13 +105,15 @@ impl ScrollBar {
// --- MARK: WIDGETMUT ---
impl ScrollBar {
// TODO - Remove?
#[expect(missing_docs, reason = "TODO")]
pub fn set_sizes(this: &mut WidgetMut<'_, Self>, portal_size: f64, content_size: f64) {
this.widget.portal_size = portal_size;
this.widget.content_size = content_size;
this.ctx.request_render();
}

// TODO - Remove?
#[expect(missing_docs, reason = "TODO")]
pub fn set_content_size(this: &mut WidgetMut<'_, Self>, content_size: f64) {
// TODO - cursor_progress
this.widget.content_size = content_size;
Expand Down
4 changes: 3 additions & 1 deletion masonry/src/widgets/sized_box.rs
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,7 @@ impl SizedBox {

// --- MARK: WIDGETMUT ---
impl SizedBox {
#[expect(missing_docs, reason = "TODO")]
pub fn set_child(this: &mut WidgetMut<'_, Self>, child: impl Widget) {
if let Some(child) = this.widget.child.take() {
this.ctx.remove_child(child);
Expand All @@ -336,6 +337,7 @@ impl SizedBox {
this.ctx.request_layout();
}

#[expect(missing_docs, reason = "TODO")]
pub fn remove_child(this: &mut WidgetMut<'_, Self>) {
if let Some(child) = this.widget.child.take() {
this.ctx.remove_child(child);
Expand Down Expand Up @@ -420,7 +422,7 @@ impl SizedBox {
this.ctx.request_layout();
}

// TODO - Doc
#[expect(missing_docs, reason = "TODO")]
pub fn child_mut<'t>(this: &'t mut WidgetMut<'_, Self>) -> Option<WidgetMut<'t, dyn Widget>> {
let child = this.widget.child.as_mut()?;
Some(this.ctx.get_mut(child))
Expand Down
Loading
Loading