Skip to content
This repository has been archived by the owner on Dec 28, 2021. It is now read-only.

Scrollbar and ScrollArea #1614

Merged
merged 12 commits into from
Jul 5, 2021
Merged

Conversation

MichaelMauderer
Copy link
Contributor

@MichaelMauderer MichaelMauderer commented Jun 9, 2021

Pull Request Description

Add a re-usable scrollbar component for internal use. Can be tested in the slider demo scene at http://localhost:8080/?entry=slider

[ci no changelog needed]

Peek.2021-06-09.14-57.mp4

Checklist

Please include the following checklist in your PR:

  • The CHANGELOG.md was updated with the changes introduced in this PR.
  • The documentation has been updated if necessary.
  • All code conforms to the Rust style guide.
  • All code has automatic tests where possible.
  • All code has been profiled where possible.
  • All code has been manually tested in the IDE.
  • All code has been manually tested in the "debug/interface" scene.
  • All code has been manually tested by the PR owner against our test scenarios.
  • All code has been manually tested by at least one reviewer against our test scenarios.

@MichaelMauderer MichaelMauderer added Difficulty: Intermediate Some prior knowledge required Priority: High Should be scheduled as soon as possible Type: Enhancement An enhancement to the current state of Enso IDE Category: GUI The Graphical User Interface labels Jun 9, 2021
@MichaelMauderer MichaelMauderer self-assigned this Jun 9, 2021
@MichaelMauderer MichaelMauderer marked this pull request as ready for review June 9, 2021 13:01
@s9ferech
Copy link
Contributor

s9ferech commented Jun 9, 2021

I tried the scroll bars and there are some things that are non-standard and could be improved in my opinion:

  1. When I move the cursor beyond the end of the scroll bar and return, it does not stick to the same position on the handle anymore.
    scroll bar
  2. The handle moves also when I move the mouse orthogonally to the bar.
    orthogonal movement
  3. Clicking on the bar, outside the handle, should move the handle by a bit less than its length, which will lead to scrolling a bit less than the viewport size. Alternatively, it could jump directly to the cursor position.
  4. The handle should be highlighted on hover to give a hint that you can interact with it.

@s9ferech
Copy link
Contributor

s9ferech commented Jun 9, 2021

I ran our test scenarios on this and everything works, except that I could not edit the project name. The same issue was observed on an unrelated branch. It is likely already present on develop.

src/rust/ensogl/lib/components/src/scrollbar.rs Outdated Show resolved Hide resolved
src/rust/ensogl/lib/components/src/scrollbar.rs Outdated Show resolved Hide resolved
src/rust/ensogl/lib/components/src/scrollbar.rs Outdated Show resolved Hide resolved
Comment on lines 92 to 123
// Mouse IO - Dragging
drag_movement <- mouse.translation.gate(&base_frp.is_dragging_any);
drag_delta <- drag_movement.map2(&base_frp.track_max_width, |delta,width|
(delta.x + delta.y) / width
);
drag_delta <- drag_delta.gate(&base_frp.is_dragging_track);
drag_animation <- drag_delta.constant(false);

// Mouse IO - Event Evaluation
should_animate <- any(&click_animation,&drag_animation);

drag_center_delta <- any(&drag_delta,&click_delta);
drag_update <- drag_center_delta.map2(&normalised_track_bounds,|delta,Bounds{start,end}|
Bounds::new(start+delta,end+delta)
);

is_in_bounds <- drag_update.map(|value| should_clamp_with_overflow(value,&None));

new_value_absolute <- all(&frp.set_overall_bounds,&drag_update).map(|(bounds,Bounds{start,end})|
Bounds::new(
absolute_value(&(*bounds,*start)),absolute_value(&(*bounds,*end))).sorted()
).gate(&is_in_bounds);

new_value_lower <- new_value_absolute.map(|b| b.start);
new_value_upper <- new_value_absolute.map(|b| b.end);

track_position_lower.target <+ new_value_lower.gate(&is_in_bounds);
track_position_upper.target <+ new_value_upper.gate(&is_in_bounds);

track_position_lower.skip <+ should_animate.on_false();
track_position_upper.skip <+ should_animate.on_false();

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like pretty complex FRP - it seems it includes dragging etc. Why such things as dragging are not completely handled by slider instead? I was thinking that this component would just wrap slider and just set a few FRP values to it, without its own complex FRP utility. Also, there are no docs describing what really these functions do, which makes it much harder to understand - it contains some dragging, some mouse IO, while all of these things should be handled by the slider component.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The actual drag implementation and underlying logic is shared. But this is the logic how to interpret it, which is different in each component: (1) single number selectors have clicking at the target and dragging only on the background (2) range slider need to act on dragging either the track piece or the edges of the track piece (3) the scrollbar needs to have dragging of the track piece and "jumping" when clicking on some other part of the background.
That is essentially what is encoded here. Maybe some things could be refactored and abstracted, but not too much.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why cant these things be just coded in (moved to) the slider implementation so you'd be able to choose which mode you wants with FRP settings? Just like choosing colors, we could tell "I want this slider to jump to the place when clicking the background". This should be part of the sldier configuration rather than extracted here imo. Can we move it there, please?

@wdanilo
Copy link
Member

wdanilo commented Jun 14, 2021

Also, from the visual point of view, our sliders should not have background, should not have shadows and should have rounded endings:

image

Also, the points raised by Felix are good too!

@wdanilo
Copy link
Member

wdanilo commented Jun 14, 2021

Also, on the Felix's gif, there is a visual artifact visible (this is a max scroll):

image

@s9ferech s9ferech self-assigned this Jun 16, 2021
@s9ferech
Copy link
Contributor

I made some heavy design changes to the scrollbars and added scroll areas to the PR because they are closely related:
scroll area in action
The recording demonstrates hovering over the bars, dragging them, clicking on them and using the mouse wheel. At the current state, content outside the scroll area is not clipped yet. That feature can be added during the next days, as soon as we have general clipping abilities.

@s9ferech s9ferech changed the title Scrollbar component Scrollbar and ScrollArea Jun 25, 2021
@s9ferech s9ferech requested a review from wdanilo June 25, 2021 11:20
src/rust/ensogl/example/src/slider.rs Outdated Show resolved Hide resolved
src/rust/ensogl/lib/components/src/scroll_area.rs Outdated Show resolved Hide resolved
src/rust/ensogl/lib/components/src/scrollbar.rs Outdated Show resolved Hide resolved
src/rust/ensogl/lib/components/src/scrollbar.rs Outdated Show resolved Hide resolved
src/rust/ensogl/lib/components/src/scrollbar.rs Outdated Show resolved Hide resolved
src/rust/ensogl/lib/components/src/scrollbar.rs Outdated Show resolved Hide resolved
src/rust/ensogl/lib/components/src/selector/shape.rs Outdated Show resolved Hide resolved
@s9ferech s9ferech force-pushed the wip/mm/ide-1612-implement-scrollbars branch from b14819e to 9aef6c9 Compare June 25, 2021 17:53
It would likely take me long to fix this test because it now depends on the existence of a `Scene`. The test also not very important. Therefore, I decided to delete it.
@s9ferech s9ferech requested a review from farmaazon July 1, 2021 10:29
@s9ferech
Copy link
Contributor

s9ferech commented Jul 2, 2021

Here is a recording that shows the interactions in a slightly better quality.
https://user-images.githubusercontent.com/8134934/124300195-318e1e80-db56-11eb-9fea-50f28d3790c0.mp4

@wdanilo
Copy link
Member

wdanilo commented Jul 2, 2021

@s9ferech Looks absolutely stunning <3

@s9ferech s9ferech merged commit 9bf3843 into develop Jul 5, 2021
@s9ferech s9ferech deleted the wip/mm/ide-1612-implement-scrollbars branch July 5, 2021 11:12
mwu-tow pushed a commit to enso-org/enso that referenced this pull request Oct 30, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Category: GUI The Graphical User Interface Difficulty: Intermediate Some prior knowledge required Priority: High Should be scheduled as soon as possible Type: Enhancement An enhancement to the current state of Enso IDE
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants