Skip to content

Commit

Permalink
Document most items in Masonry (#815)
Browse files Browse the repository at this point in the history
Move `#[allow(missing_docs)]` to two modules. Missing docs now warn
everywhere else by default.

Remove `#[expect(rustdoc::broken_intra_doc_links)]` and fix all broken
links.
  • Loading branch information
PoignardAzur authored Jan 13, 2025
1 parent 522dfd4 commit 51a3556
Show file tree
Hide file tree
Showing 22 changed files with 327 additions and 162 deletions.
2 changes: 1 addition & 1 deletion masonry/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ Full documentation at https://github.com/orium/cargo-rdme -->

<!-- Intra-doc links used in lib.rs should be evaluated here.
See https://linebender.org/blog/doc-include/ for related discussion. -->
[tracing_tracy]: https://crates.io/crates/tracing-tracy

<!-- cargo-rdme start -->

Expand Down Expand Up @@ -112,6 +111,7 @@ The following feature flags are available:
[winit]: https://crates.io/crates/winit
[Druid]: https://crates.io/crates/druid
[Xilem]: https://crates.io/crates/xilem
[tracing_tracy]: https://crates.io/crates/tracing-tracy

<!-- cargo-rdme end -->

Expand Down
11 changes: 8 additions & 3 deletions masonry/src/action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,16 @@ use crate::event::PointerButton;
///
/// Note: Actions are still a WIP feature.
pub enum Action {
/// A button was pressed.
ButtonPressed(PointerButton),
/// Text changed.
TextChanged(String),
/// Text entered.
TextEntered(String),
CheckboxChecked(bool),
/// A checkbox was toggled.
CheckboxToggled(bool),
// FIXME - This is a huge hack
/// Other.
Other(Box<dyn Any + Send>),
}

Expand All @@ -28,7 +33,7 @@ impl PartialEq for Action {
(Self::ButtonPressed(l_button), Self::ButtonPressed(r_button)) => l_button == r_button,
(Self::TextChanged(l0), Self::TextChanged(r0)) => l0 == r0,
(Self::TextEntered(l0), Self::TextEntered(r0)) => l0 == r0,
(Self::CheckboxChecked(l0), Self::CheckboxChecked(r0)) => l0 == r0,
(Self::CheckboxToggled(l0), Self::CheckboxToggled(r0)) => l0 == r0,
// FIXME
// (Self::Other(val_l), Self::Other(val_r)) => false,
_ => false,
Expand All @@ -42,7 +47,7 @@ impl std::fmt::Debug for Action {
Self::ButtonPressed(button) => f.debug_tuple("ButtonPressed").field(button).finish(),
Self::TextChanged(text) => f.debug_tuple("TextChanged").field(text).finish(),
Self::TextEntered(text) => f.debug_tuple("TextEntered").field(text).finish(),
Self::CheckboxChecked(b) => f.debug_tuple("CheckboxChecked").field(b).finish(),
Self::CheckboxToggled(b) => f.debug_tuple("CheckboxChecked").field(b).finish(),
Self::Other(_) => write!(f, "Other(...)"),
}
}
Expand Down
9 changes: 9 additions & 0 deletions masonry/src/app_driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,19 @@
use crate::event_loop_runner::MasonryState;
use crate::{Action, RenderRoot, WidgetId};

/// Context for the [`AppDriver`] trait.
///
/// Currently holds a reference to the [`RenderRoot`].
pub struct DriverCtx<'a> {
pub(crate) render_root: &'a mut RenderRoot,
}

/// A trait for defining how your app interacts with the Masonry widget tree.
///
/// When launching your app with [`crate::event_loop_runner::run`], you need to provide
/// a type that implements this trait.
pub trait AppDriver {
/// A hook which will be executed when a widget emits an [`Action`].
fn on_action(&mut self, ctx: &mut DriverCtx<'_>, widget_id: WidgetId, action: Action);

#[allow(unused_variables)]
Expand All @@ -27,6 +35,7 @@ impl DriverCtx<'_> {
self.render_root
}

/// Returns true if something happened that requires a rewrite pass or a re-render.
pub fn content_changed(&self) -> bool {
self.render_root.needs_rewrite_passes()
}
Expand Down
2 changes: 1 addition & 1 deletion masonry/src/box_constraints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use vello::kurbo::Size;
/// The constraints are always [rounded away from zero] to integers
/// to enable pixel perfect layout.
///
/// [`layout`]: crate::widget::Widget::layout
/// [`layout`]: crate::Widget::layout
/// [Flutter BoxConstraints]: https://api.flutter.dev/flutter/rendering/BoxConstraints-class.html
/// [rounded away from zero]: Size::expand
#[derive(Clone, Copy, Debug, PartialEq)]
Expand Down
Loading

0 comments on commit 51a3556

Please sign in to comment.