Skip to content
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

Scrollbar LMB click and hold scrolling #3824

Merged
merged 22 commits into from
Oct 26, 2022

Conversation

Frizi
Copy link
Contributor

@Frizi Frizi commented Oct 21, 2022

Pull Request Description

Implements https://www.pivotaltracker.com/story/show/183390702

hold-scroll.mp4

Important Notes

This PR adds browser timers (setTimeout and setInterval) support to the FRP core. Those then are used to implement the "hold to scroll repeatedly" functionality.

There was a camera-releated bug in the scroll-view debug scene, due to hardcoding made specifically for component browser. This is now fixed, and instead component browser sets the scroll-view camera manually. This is due to change when camera handling in layers will be refactored, and by then no explicit camera setting will be necessary.

There are also some minor extra changes or docs improvements in areas I was going through when looking at FRP implementation.

Checklist

Please include the following checklist in your PR:

  • The documentation has been updated if necessary.
  • All code conforms to the
    Scala,
    Java,
    and
    Rust
    style guides.
  • All code has been tested:
    • Unit tests have been written where possible.
    • If GUI codebase was changed: Enso GUI was tested when built using BOTH
      ./run ide build and ./run ide watch.

@Frizi Frizi force-pushed the wip/frizi/scrollbar-repeat-183390702 branch from e6ca13a to ed24dea Compare October 21, 2022 12:36
@Frizi Frizi marked this pull request as ready for review October 21, 2022 12:44
Copy link
Member

@wdanilo wdanilo left a comment

Choose a reason for hiding this comment

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

Many things to be fixed. Please fix them and ping me afterwards. Also, this PR should not be opened because:

  1. The checkboxes are not selected.
  2. It does not contain screencast of the implemented feature.

CHANGELOG.md Outdated Show resolved Hide resolved
Comment on lines -248 to +249
let camera = scene.layers.node_searcher.camera();
let display_object = display::object::Instance::new();
let masked_layer = layer::Masked::new(&logger, &camera);
let masked_layer = layer::Masked::new(&logger);
Copy link
Member

Choose a reason for hiding this comment

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

Masked layer is probably used by many different parts of the application. Is it? If so, are you 100% sure that removing camera binding here does not introduce any regression?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am. This particular change was only affecting scroll-area, and by extension grid-view. I made sure to understand the change and test it manually in all instances. This is essentially a tiny step closer towards cameras being inherited through the layers tree, which as I understand is an eventual goal.

This is in essence a removal of a hard-coded value for one specific view being embedded in a supposedly reusable piece of code.

lib/rust/ensogl/component/scrollbar/src/lib.rs Outdated Show resolved Hide resolved
lib/rust/ensogl/component/scrollbar/src/lib.rs Outdated Show resolved Hide resolved
lib/rust/ensogl/component/scrollbar/src/lib.rs Outdated Show resolved Hide resolved
lib/rust/ensogl/core/src/timer/interval.rs Outdated Show resolved Hide resolved
lib/rust/ensogl/core/src/timer/timeout.rs Outdated Show resolved Hide resolved
lib/rust/ensogl/core/src/timer/timeout.rs Outdated Show resolved Hide resolved
lib/rust/ensogl/core/src/timer/timeout.rs Outdated Show resolved Hide resolved
lib/rust/frp/src/io/js.rs Outdated Show resolved Hide resolved
CHANGELOG.md Outdated Show resolved Hide resolved
lib/rust/ensogl/core/src/timer/interval.rs Outdated Show resolved Hide resolved
lib/rust/ensogl/core/src/timer/delayed_repeats.rs Outdated Show resolved Hide resolved
@Frizi
Copy link
Contributor Author

Frizi commented Oct 24, 2022

I tried writing a fake browser time support for our mock web bindings. It turns out that this isn't easily doable, because there is an assumption in place that all mocks are ZSTs (there is a transmute that expects that). We would need to preserve the callback in Function object to be able to call it later, which violates that assumption. I think it warrants a separate task.

@Frizi Frizi requested a review from wdanilo October 24, 2022 16:50
@enso-org enso-org deleted a comment from Frizi Oct 25, 2022
@Frizi Frizi requested a review from farmaazon October 25, 2022 10:52
Copy link
Member

@wdanilo wdanilo left a comment

Choose a reason for hiding this comment

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

We are almost there. TBH, I'm nicely surprised by the code quality - first PRs are always hard, but this one is getting really nice. I'm happy that you got so fluent in FRP usage so fast, good job!

Comment on lines +73 to +85
#[derive(Debug, Clone, Copy, Default)]
pub struct DelayedIntervalConfig {
/// Initial delay between timer activation and first `on_trigger` event being emitted.
pub delay_ms: i32,
/// Time between subsequent `on_trigger` events.
pub interval_ms: i32,
}

impl DelayedIntervalConfig {
/// Constructor.
pub fn new(delay_ms: i32, interval_ms: i32) -> Self {
Self { delay_ms, interval_ms }
}
Copy link
Member

Choose a reason for hiding this comment

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

Weare almost there. This is kind of anti-pattern with FRP. Instead, these config should be set up by FRP inputs set_delay and set_interval. In order to do it, use the define_endpoints_2, store Frp in the DelayedInterval and Deref to it.

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 define_endpoints_2 macro is part of ensogl_core, which depends on the frp crate. I can't use it here.

I am also not thrilled about this DelayedIntervalConfig struct, but I don't really see a great alternative. The main reason it exists it is that you can't change interval values while the timer is running. I wanted an API that makes it very clear that changing the timeout values also restarts the whole timer applying both timeout values at once, and there is no way around that. If I split this into separate set_delay and set_interval streams, the semantics around timer restarts would be potentially surprising.

Avoiding this whole problem was my motivation for using simple boolean based API before. Unfortunately that led to interval values being essentially static, so I changed it to a stream accepting both values at once. Please let me know if you have better ideas how to handle that case.

lib/rust/frp/src/io/timer/delayed_interval.rs Show resolved Hide resolved
lib/rust/frp/src/io/timer/delayed_interval.rs Outdated Show resolved Hide resolved
lib/rust/frp/src/io/timer/interval.rs Show resolved Hide resolved
lib/rust/frp/src/io/timer/interval.rs Outdated Show resolved Hide resolved
lib/rust/frp/src/io/timer/interval.rs Outdated Show resolved Hide resolved
lib/rust/frp/src/io/timer/timeout.rs Show resolved Hide resolved
lib/rust/frp/src/io/timer/timeout.rs Outdated Show resolved Hide resolved
@Frizi Frizi force-pushed the wip/frizi/scrollbar-repeat-183390702 branch from 3e6cd6b to 7bd0a76 Compare October 26, 2022 00:39
@Frizi Frizi merged commit d7954bf into develop Oct 26, 2022
@Frizi Frizi deleted the wip/frizi/scrollbar-repeat-183390702 branch October 26, 2022 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants