Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
Previously, fields
id: Id
andrect: Rect
were public; now they are hidden and renamed. TheCodeData
type is also hidden and renamed. This leaks fewer implementation details into the public API.Details
Accessor methods already existed for both while
id
is only assigned to from macro-generated code, so the only missing part was the ability to assign torect
, now achieved via a newwidget_set_rect!
macro.Additionally,
fn TileExt::id
is moved tofn Tile
, with some doc changes to related methods and types.Further goals
I would prefer to remove the
rect
field entirely, as follows:fn rect()
totrait Layout
, implementing for all visitors (Single
,Align
,Pack
andMargins
can simply forward to their inner layout whileFrame
andButton
already store the input rect, thus onlyList
,Float
andGrid
need additional storage).fn rect
via the layout visitor for allmake_layout
widgets and all user-defined widgets using thelayout
property.fn rect()
in other cases. (Or possibly provide this where thewidget_set_rect!
macro is called, which it is possible to detect before generating thewidget_core!()
type.)There is, however, a blocker:
fn rect()
must take&self
while the layout visitor currently requires&mut self
(see #466). Unless/until that is resolved, this approach appears preferable.