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

Grid View with Scrolling #3588

Merged
merged 17 commits into from
Jul 19, 2022
Merged

Conversation

farmaazon
Copy link
Contributor

@farmaazon farmaazon commented Jul 14, 2022

Pull Request Description

Note: This PR also contains content of previous Grid View PR. We decided to discard the previous, because this one did some refactoring of old one, and it's not a big addition.

Added a scrollable::GridView component, which just embeds the GridView in ScrollArea. Also, re-worked the idea of text layers.

grid_view-.3.mp4

Important Notes

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 dist and ./run ide watch.

@farmaazon farmaazon requested a review from wdanilo July 14, 2022 15:32
@farmaazon farmaazon mentioned this pull request Jul 14, 2022
4 tasks
@farmaazon farmaazon marked this pull request as ready for review July 14, 2022 15:50
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.

Beautiful implementation. I left a few comments, but none is a blocker :)

Comment on lines 81 to 82
/// An internal structure of [`Entry`], which may be passed to FRP network without risk of memory
/// leaks.
Copy link
Member

Choose a reason for hiding this comment

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

  1. I don't understand this comment. Why there could be a risk of a memory leak. Could you elaborate more in the comment, please?
  2. There are English language issues in the doc comments (here and in other doc comments). Could you use an English listing software for the comments, please?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ad 1. I mean: it may be passed to FRP network in contrary to the entire Entry structure, which contains Network. I removed the second part - I think "may be passed to FRP network" is enough.


impl EntryData {
fn new(app: &Application, text_layer: &Option<Layer>) -> Self {
let logger = Logger::new("list_view::entry::Label");
Copy link
Member

Choose a reason for hiding this comment

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

Use the new logging that is exposed in prelude instead of our old logger, please.

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 have to pass something to display::object::Instance. Can I do it in the new logging somehow?

data: Rc<EntryData>,
}

impl crate::Entry for Entry {
Copy link
Member

Choose a reason for hiding this comment

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

why do you need to do crate::Entry in one place but not in the other place (both are in the same line).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because those are different entities. One is crate::Entry and the second is basic::Entry. One is a general "Entry" trait, the second is a concrete implementation.

Comment on lines 141 to 146
bg_color <- input.set_params.map(|params| params.bg_color).on_change();
bg_margin <- input.set_params.map(|params| params.bg_margin).on_change();
font <- input.set_params.map(|params| params.font.clone_ref()).on_change();
text_offset <- input.set_params.map(|params| params.text_offset).on_change();
text_color <- input.set_params.map(|params| params.text_color).on_change();
text_size <- input.set_params.map(|params| params.text_size).on_change();
Copy link
Member

Choose a reason for hiding this comment

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

here we fit the line, so it's not so important, but in such cases as these, I normally prefer to write |t| t.bg_color instead of |params| params.bg_color because the previous word already indicates what we are dealing with (set_params.map). Again, not important at all, but shorter code is easier to parsing with eyes.

&self.data.display_object
}
}

Copy link
Member

Choose a reason for hiding this comment

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

spacing

Comment on lines 301 to 304
/// **Important**. The [`Frp::model_for_entry_needed`] are emitted once when needed and not repeated
/// anymore, after adding connections to this FRP node in particular. Therefore make sure, that you
/// connect providing models logic before emitting any of [`Frp::set_entries_size`] or
/// [`Frp::set_viewport`].
Copy link
Member

Choose a reason for hiding this comment

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

Are you remembering all the data that was transmitted to you? If so, could you add a limit for it and remove old data? I'm just afraid that our memory consumption can blow up trough the window otherwise with big tables of data. What do you think? Maybethe worry is not needed now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, the data are passed to visible entries. We don't cache them. When the view is scrolled back, we re-request them. I can add info there.

/// arguments, similar to [`crate::GridViewTemplate`] - see its docs for details.
#[derive(CloneRef, Debug, Deref, Derivative)]
#[derivative(Clone(bound = ""))]
pub struct GridViewTemplate<E: 'static, M: frp::node::Data, P: frp::node::Data> {
Copy link
Member

Choose a reason for hiding this comment

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

As requested earlier, please use better names than "E", "M", and "P" ora add docs.

Comment on lines 162 to 167
pub struct Model<E, P> {
display_object: display::object::Instance,
visible_entries: RefCell<HashMap<(Row, Col), E>>,
free_entries: RefCell<Vec<E>>,
entry_creation_ctx: EntryCreationCtx<P>,
}
Copy link
Member

Choose a reason for hiding this comment

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

You are using <E, P> here instead of <E::Entry>, right?

  1. Thank you so much for caring about it.
  2. I think that this might be a corner case where we could actually allow <E::Entry>. Let's have a short call about it tmrw :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

After a call, we decided to keep <Entry, EntryParams> instead of <E: Entry>.

@@ -0,0 +1,123 @@
//! A module with [`VisibleArea`] structure.
Copy link
Member

Choose a reason for hiding this comment

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

a short info of what it is would be appreciated :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, it's an outdated doc.

use crate::Viewport;



Copy link
Member

Choose a reason for hiding this comment

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

no section

@farmaazon farmaazon self-assigned this Jul 15, 2022
@@ -0,0 +1,92 @@
//! A debug scene which shows the Select Component. The chosen entries are logged in console.
Copy link
Contributor

Choose a reason for hiding this comment

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

The chosen entries are logged in console.

I believe this is not true

@farmaazon farmaazon added CI: Ready to merge This PR is eligible for automatic merge and removed CI: Ready to merge This PR is eligible for automatic merge labels Jul 18, 2022
@farmaazon farmaazon added the CI: Ready to merge This PR is eligible for automatic merge label Jul 18, 2022
@mergify mergify bot merged commit 7fa4e5e into develop Jul 19, 2022
@mergify mergify bot deleted the wip/farmaazon/grid-view-scrolling-182585742 branch July 19, 2022 08:39
jdunkerley pushed a commit that referenced this pull request Jul 20, 2022
**Note**: This PR also contains content of previous Grid View PR. We decided to discard the previous, because this one did some refactoring of old one, and it's not a big addition.

Added a scrollable::GridView component, which just embeds the GridView in ScrollArea. Also, re-worked the idea of text layers.

https://user-images.githubusercontent.com/3919101/179020359-512ee127-c333-4f86-bff5-f1cb4154e03c.mp4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI: Ready to merge This PR is eligible for automatic merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants