-
Notifications
You must be signed in to change notification settings - Fork 297
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
[Breaking Change] Refactor Event system and update Widgets accordingly. Add new multi-line TextEdit widget. Remove multiple crate deps, and more. #703
Conversation
@mitchmindtree Just got back and saw your comment on #700. Yeah, the purpose of creating drag events on mouse release was so widgets could differentiate between in-progress and completed drags. I certainly don't mind the idea of separate event for On the names, |
Going to be away for the weekend, but will get back to this on Monday 👍 |
I've been working on improving a DSP API over the past week, but will hopefully get back to this within the next couple days. |
Updated to latest Gfx. Here is a dump from Eco:
|
Thanks! |
…o ensure it is up-to-date. Inline one-time use methods to clarify their purpose (use functions in tests for internal re-use).
… which requires cloning
…_xy. Track widget_under_mouse in InputState and update on resize, mouse_move and scroll
…nder event. Update to input_state mouse api changes. Identify Ui fields that should be removed.
…ous name changes. Changed pressed_button to pressed which now returns an iterator yielding all pressed buttons. Added notes on logic that needs to be reviewed in terms of expected behaviour.
InputState::update and GlobalInput::push_event into Ui::handle_event in order to make GlobalInput::push_event a little less ambiguous. Change handle_event to take `E: Into<Event<Input>>` instead of `E: GenericEvent` in order to make event interpretation logic a little more ergonomic. Not sure if this is a good idea or not, will think over this as work continues.
… events to the Ui::handle_event method. A blanket implementation is provided for all E: GenericEvent, to provide default compatibility with all piston events.
…ue instead of reference)
…pls and functions at beginning of file rather than end.
…nput here, so that this is the only module pistoncore-input is used explicitly (should make it easier to change out in the future if necessary)
Change the pistoncore-input crate name from input to piston_input and change the piston-2dgraphics crate name from graphics to piston_graphics in order to highlight the use of the crates so that we can easily keep them restricted to the backend modules.
…get being dragged in MouseDrag events.
…t::Drag to cover a wider range of use cases.
- Added new `event::Widget` type for events that are targeted towards a specific widget. - Removed `input::Provider` trait in favour of direct `impl`s. - Refactored `Drag` event to provide `origin`, `from`, `to`, `delta_xy`, `total_delta_xy`.
…l position of scrollable widgets.
… it is not being interacted with. Removed old unused mouse module. Removed consideration of input capturing in determination of `depth_order`. Added a `Scrolls` event iterator to the Widget input for only yielded `Scroll` events. Change scrolling so that all scrolling is applied to the widget during the `widget::set_widget` stage via `Scroll` events, rather than as soon as they are received within the `Ui::handle_event` method. Fix scrolling logic in `Ui::handle_event` so that scroll events aren't emitted multiple times to the same widget. Added a `pending_scroll_events` `Vec` to the `Ui` for storing `Scroll` events emitted by widgets during a call to `Ui::set_widgets`. Add `ScrollBar`s to all_widgets.rs and canvas.rs examples.
longer necessary now that a `Scrollbar` is a `Widget`, rather than built into the `Ui` graph itself. Add a Widget::crop_kids method and use this for cropping within backend/graphics.rs instead of scrolling. Widget::scroll_kids now calls the `crop_kids` method internally. Use G2dTexture type directly in all_widgets example rather than GfxGraphics' associated Texture type.
…mpiling all_widgets example. Goes away when the call to Widget::set is removed on the TextBox widget. Have not yet determined why.
Alright, I think this PR is fiiiiinally good to go! I believe the only thing blocking it now is the ICE occurring when rustc attempts to compile the all_widgets.rs example. I've posted an issue for this here. As this PR involved refactoring most of the foundational logic in conrod and in turn updating all of the widgets, it made sense to address some other issues at the same time. One of the biggest changes is the addition of the
It should also be noted that all text handling logic has been moved from the Widgets no longer get
Cropping of children widgets is no longer limited to scrollable widgets - any widget may now crop its children widgets by calling the Removes All-in-all the new event system has allowed us to remove a significant amount of complexity from most widgets! This PR adds two new widgets ( |
…t it wraps. This removes the need for the State::view method and allows the user to treat the widget::State as if it were the widget\'s unique state. This is especially useful as the primary purpose of the widget::State type is to restrict mutable access to widgets\' unique state, whereas immutable access is fine.
I could not resist the temptation and tried modify the "text" example to test the new |
I figured it out, but got the compiler bug on the modified "text" example. 😢 |
@bvssvni hmmm strange that you got the bug on the modified version, but not the regular version! Looking into it now to see if I can recreate this and work out what's going on. Not sure how to side-step this issue just yet. It doesn't look like anyone's looking into the ICE yet, so I'll probably spend the day looking into a workaround to use in the meantime. |
Hmmm I got the same thing. Simply changing the widgets in the |
Nice to make some progress on that compiler bug! |
…3 local variables instead. Fix Text widget alignment and pass on line_spacing.
…e line expression into multiple locals.
Alright, ICE is @bvssvni don't get too excited about In the meantime I'll bump the crate version, publish and merge this! |
Published as 0.36.0 🎉 |
I've been away for a while, but just wanted to say that these changes look really good. @mitchmindtree |
WIP - do not merge yet.These changes are a follow up on the implementation of conrod's new event-based user input system in #684 as discussed in #670.
Related todo:
GlobalInput
takedrag_threshold
as a push_event argument rather than storing it to ensure the value is always up-to-date.widget_under_mouse
inInputState
onmouse_move
,resize
andscroll
so that we can use it to track widget-specificMouseClick
etc events properly.InputState::update
and event interpretation withinGlobalInput::push_event
as they're only used once in a very specific area (Ui::handle_event
).backend::ToEvent
trait which allows users to pass custom events toUi::handle_event
, as long as they implement theToEven
trait.Option<widget::Index>
forButtonPosition::Down
.Ahh, I see thatWidgetInput::all_events
currently takesglobal_input.start
- shouldn't it takeglobal_input.current
?InputState::update
was being called as each event was emitted. As long as we trackwidget_under_mouse
during handle_event and within eachUiEvent
where necessary, I think we can remove the incremental updating of theInputState
in theWidgetInput
event iterator.MouseClick
should track the widget that was directly under it at the time so that it can be delivered to the correct widget (rather than whatever happens to be under the mouse atcurrent
whenUi::set_widgets
is called).Input
types are exposed frombackend
module (so that users don't need to import piston-input crate).Clicked
events when covered by another widget (should be usingGraph::pick_widget
method).to
widget_input::should_provide_event
. Edit: Removing this along with an overhaul of the input::widget module.Widget::drag_area
method and related types and see if these can be removed in favour of using the newDrag
events.Record the precise time each event was received and store it with each event (see Track theJust tracking the time of the lastInstant
at which eachUiEvent
is created once Rust 1.8 lands #708).Click
event now in order to generateDoubleClick
s, will hold off on Track theInstant
at which eachUiEvent
is created once Rust 1.8 lands #708 until it is necessary.Ui::Raw
andWidget::Raw
in favour of adding more event variants that correspond with each of the raw event variants. This should simplify the event API for new conrod users.handle_event
.UserInput
type and related data inUi
.Rect
s for both line and character position:pub mod char
:pub mod line
:Info
spub mod cursor
:Scroll
events for scrollable widgets onMouseScroll
. If not over any scrollable widgets, emitScroll
events to the widget capturing the mouse if there is one.Ui::scroll_widget
andUiCell::scroll_widget
methods that allow for the user (or other widgets) to emitScroll
events to other widgets.Scroll
events to scrollable widgets during thewidget::set_widget
function.Scrollbar
logic into a newScrollbar
widget that emitsScroll
events to its associated widget via theUiCell::scroll_widget
method.Decided to leave the following three points for now in favour of doing #711 instead.
Drag scrollbars whenDrag
events are produced and produce aScroll
event.ApplyScroll
events as they are produced (see ApplyScroll
to widgets immediately when received, rather than duringUi::set_widgets
#709. This will need to be applied within this PR).Trackgraph::Visitable
instead ofwidget::Index
under pressed mouse buttons (in order to differentiate scrollbars from widgets).Events (inspired by DOM events):
Decided to leave the following events for a future PR or until they're needed.
Esc
or some other means.Widgets that still need to be changed over to the new system:
Closes #708.
Closes #724.
Closes #711. Scroll logic is still built in, however the Scrollbar was moved into its own Widget.
Closes #642.
Closes #639.
Closes #602.
Addresses some parts of #342.