Skip to content

Commit

Permalink
Add a size method to UpdateCtx and LifeCycleCtx. (#917)
Browse files Browse the repository at this point in the history
  • Loading branch information
jneem authored May 11, 2020
1 parent 3878d31 commit f666974
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ While some features like the clipboard, menus or file dialogs are not yet availa
- `MouseButtons` to `MouseEvent` to track which buttons are being held down during an event. ([#843] by [@xStrom])
- `Env` and `Key` gained methods for inspecting an `Env` at runtime ([#880] by [@Zarenor])
- `UpdateCtx::request_timer` and `UpdateCtx::request_anim_frame`. ([#898] by [@finnerale])
- `UpdateCtx::size` and `LifeCycleCtx::size`. ([#917] by [@jneem])

### Changed

Expand Down Expand Up @@ -157,6 +158,7 @@ While some features like the clipboard, menus or file dialogs are not yet availa
[#900]: https://github.com/xi-editor/druid/pull/900
[#903]: https://github.com/xi-editor/druid/pull/903
[#909]: https://github.com/xi-editor/druid/pull/909
[#917]: https://github.com/xi-editor/druid/pull/917

## [0.5.0] - 2020-04-01

Expand Down
26 changes: 26 additions & 0 deletions druid/src/contexts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -479,6 +479,19 @@ impl<'a> LifeCycleCtx<'a> {
self.request_paint();
}

/// The layout size.
///
/// This is the layout size as ultimately determined by the parent
/// container, on the previous layout pass.
///
/// Generally it will be the same as the size returned by the child widget's
/// [`layout`] method.
///
/// [`layout`]: trait.Widget.html#tymethod.layout
pub fn size(&self) -> Size {
self.base_state.size()
}

/// Submit a [`Command`] to be run after this event is handled.
///
/// Commands are run in the order they are submitted; all commands
Expand Down Expand Up @@ -557,6 +570,19 @@ impl<'a> UpdateCtx<'a> {
timer_token
}

/// The layout size.
///
/// This is the layout size as ultimately determined by the parent
/// container, on the previous layout pass.
///
/// Generally it will be the same as the size returned by the child widget's
/// [`layout`] method.
///
/// [`layout`]: trait.Widget.html#tymethod.layout
pub fn size(&self) -> Size {
self.base_state.size()
}

/// Submit a [`Command`] to be run after layout and paint finish.
///
/// **Note:**
Expand Down

0 comments on commit f666974

Please sign in to comment.