Skip to content

Commit

Permalink
Document most items in Masonry
Browse files Browse the repository at this point in the history
Move `#[allow(missing_docs)]` to dow modules. Missing docs now warn everywhere else by default.
  • Loading branch information
PoignardAzur committed Jan 11, 2025
1 parent 78fb169 commit bd6309e
Show file tree
Hide file tree
Showing 10 changed files with 235 additions and 82 deletions.
5 changes: 5 additions & 0 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),
/// A checkbox was checked.
CheckboxChecked(bool),
// FIXME - This is a huge hack
/// Other.
Other(Box<dyn Any + Send>),
}

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
Loading

0 comments on commit bd6309e

Please sign in to comment.