Skip to content

Commit

Permalink
Use a macro to implement context methods (#972)
Browse files Browse the repository at this point in the history
* Use a macro to implement context methods

This attempts to solve the issue of duplicate code and out of
date documentation for methods shared between multiple contexts.

The approach taken here is to use a simple macro to implement
those methods.

A consequence of this work is that methods are now more
consistently available across more contexts; as an example,
`window_id` and `window` are now available from all contexts,
whereas they were previously missing from `PaintCtx` for no
particular reason.

* Update druid/src/contexts.rs

Co-authored-by: Leopold Luley <[email protected]>

Co-authored-by: Leopold Luley <[email protected]>
  • Loading branch information
cmyr and luleyleo authored May 31, 2020
1 parent a4b0762 commit c1303e1
Show file tree
Hide file tree
Showing 2 changed files with 177 additions and 422 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ This means that druid no longer requires cairo on macOS and uses Core Graphics i
- `LifeCycle::Size` event to inform widgets that their size changed. ([#953] by [@xStrom])
- `Button::dynamic` constructor. ([#963] by [@totsteps])
- `set_menu` method on `UpdateCtx` and `LifeCycleCtx` ([#970] by [@cmyr])
- Standardize and expose more methods on more contexts ([#972] by [@cmyr])

### Changed

Expand All @@ -73,8 +74,7 @@ This means that druid no longer requires cairo on macOS and uses Core Graphics i
- Replaced `Command::one_shot` and `::take_object` with a `SingleUse` payload wrapper type. ([#959] by [@finnerale])
- Renamed `WidgetPod` methods: `paint` to `paint_raw`, `paint_with_offset` to `paint`, `paint_with_offset_always` to `paint_always`. ([#980] by [@totsteps])
- `Command` and `Selector` have been reworked and are now statically typed, similarly to `Env` and `Key`. ([#993] by [@finnerale])
- Standardize the type returned by the contexts' `text()` methods. ([#996] by
[@cmyr])
- Standardize the type returned by the contexts' `text()` methods. ([#996] by [@cmyr])

### Deprecated

Expand Down Expand Up @@ -240,6 +240,7 @@ This means that druid no longer requires cairo on macOS and uses Core Graphics i
[#967]: https://github.com/xi-editor/druid/pull/967
[#969]: https://github.com/xi-editor/druid/pull/969
[#970]: https://github.com/xi-editor/druid/pull/970
[#972]: https://github.com/xi-editor/druid/pull/972
[#980]: https://github.com/xi-editor/druid/pull/980
[#982]: https://github.com/xi-editor/druid/pull/982
[#984]: https://github.com/xi-editor/druid/pull/984
Expand Down
Loading

0 comments on commit c1303e1

Please sign in to comment.