-
-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Less type safety: remove Handler::Msg assoc. type #309
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This is impossible with the new message model. No big loss.
This is not emitted by their children
This breaks ComboBox and automatic updating of data through view widgets (to be fixed later).
This is a big revision to event handling, allowing multiple simultaneous messages from children and removing the need to parametrize many widgets over the message type. Incomplete: new Handler::on_message method not called yet. Remove Response::Msg, VoidMsg, #[derive(VoidMsg)] Replace event::ChildMsg with IndexMsg, SelectMsg Remove Updatable trait; add SingleData::on_message, etc. Remove #[widget(flatmap_msg=.., map_msg=.., use_msg=.., discard_msg)] make_widget!: remove -> message-type bound AdaptWidget: remove map_void_msg, map_msg_discard; adjust map_msg Button, etc...: event closure no longer returns Option<M> Grid, List: now push IndexMsg given a child message
Rename widgets::view::SelectMsg → SelectionMsg
New Scroll enum, EventMgr::set_scroll and Handler::scroll methods
This gets lots of things working again, but many bugs remain.
This prevents keys activating by combobox menu items from doing anything unless the menu is already open, which is the same behaviour as used by menus.
This enables useful output in the case of unhandled messages.
Slider now holds handle to its detents.
Slider now takes nav-focus on click.
Same for SingleData, ListData, MatrixData
This avoids unwanted sending of IndexMsg and is more flexible. Fixes light/dark theme buttons in the gallery (embedded in a Row).
…urning UpdateHandle
Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
When is type safety not a good thing? This PR removes the
Handler::Msg
type andResponse::Msg
variant, replacing this with a new variadic message queue.EventMgr::push_msg
,try_pop_msg
(+ boxed versions)Response::Update
andUpdatable
traitHandler::Msg
,Response::Msg
,VoidMsg
,#[derive(VoidMsg)
#[widget(update = f)]
,#[widget(map_msg = f)]
, etc. (#[widget]
attr on fields no longer accepts parameters)Button
,CheckBox
etc. closures no longer returnOption<M>
but push directly viamgr.push_msg(..)
IndexedList
,IndexedColumn
,IndexedRow
,GenericList
Response::Select
; addSelectMsg
Response::Scrolled
,Pan
andFocus
variants; newScroll
enumdyn WidgetConfig
withdyn Widget
SendEvent
; replace withEventMgr::send
method (widgets no longer handle event routing)Handler::handle_message
: called on parent whenever a child emits a messageList::on_message
andGrid::on_message
; optionally call closure with child index when child emits a messageDriver::get
*Data
traits: replaceupdate_handles
withupdate_on_handles
(pass&WidgetId
in and let data register dependencies),update
method takes&mut EventMgr
and notifies of update instead of returning anUpdateHandle
*Data::handle_message
, called by view widget when a child emits a message (replacement forResponse::Update
andUpdatable
)There are also a few fixes / minor behaviour changes:
ComboBox
widget: if menu entries have accelerator keys, these are now only usable when the menu is open (same as other menus)ComboBox
: fix highlighting of first entryComboBox
: constructor no longer takesactive
parameter; all entries have an associated message (of the same type)examples/mandlebrot
: enable tab focus of main widget (allows full keyboard control)Splitter
widget: fix child index toWidgetId
assignmentSlider
widget: clamp handle to detentsHandler::handle
renamed tohandle_event
WidgetHeirarchy
outputRowSetter
for columnsEffects and motivation
With over 40 commits and approx 2000 line insertions and 3000 deletions, this is not a small PR, and a significant step in trait revision (the rough topic for v0.11). Effects:
dyn Widget
is now possible without parametrizing the message type. Less type parameters to worry about implies simpler code and simpler error messages.SendEvent
impls! As a consequence, theHandler
trait gainedhandle_message
,handle_unused
andscroll
methods.Effects on user code not using data models is limited, mostly to not needing to specify message types or handler annotations (e.g.
#[widget(use_msg = start)]
).Closes #11, #257.
Bugs
Tab order broken in examples filter-list and data-list-view when paging. Warnings are logged, e.g.:
I will leave this to a future PR since this one is otherwise ready.
MSRV
Bump min Rust version to 1.58, only for the new format syntax (embed identifiers).