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

Horizontal layer buttons #2566

Merged
merged 33 commits into from
Nov 20, 2023

Conversation

javerbukh
Copy link
Contributor

@javerbukh javerbukh commented Nov 13, 2023

Description

Screen.Recording.2023-11-17.at.3.13.54.PM.mov

This pull request converts the layer select dropdown menu in Plot Options into a horizontal panel of buttons. Both single and multiselect are supported in this PR. The work left to do is as follows:

  • Have buttons update with mixed color
  • Have buttons update with mixed visibility
  • Improve style
  • Add tests
  • Update documentation

Closes #2491

Change log entry

  • Is a change log needed? If yes, is it added to CHANGES.rst? If you want to avoid merge conflicts,
    list the proposed change log here for review and add to CHANGES.rst before merge. If no, maintainer
    should add a no-changelog-entry-needed label.
  • Convert the layer select dropdown into a horizontal panel of buttons. [Horizontal layer buttons #2566]

Checklist for package maintainer(s)

This checklist is meant to remind the package maintainer(s) who will review this pull request of some common things to look for. This list is not exhaustive.

  • Are two approvals required? Branch protection rule does not check for the second approval. If a second approval is not necessary, please apply the trivial label.
  • Do the proposed changes actually accomplish desired goals? Also manually run the affected example notebooks, if necessary.
  • Do the proposed changes follow the STScI Style Guides?
  • Are tests added/updated as required? If so, do they follow the STScI Style Guides?
  • Are docs added/updated as required? If so, do they follow the STScI Style Guides?
  • Did the CI pass? If not, are the failures related?
  • Is a milestone set? Set this to bugfix milestone if this is a bug fix and needs to be released ASAP; otherwise, set this to the next major release milestone.
  • After merge, any internal documentations need updating (e.g., JIRA, Innerspace)?

@kecnry
Copy link
Member

kecnry commented Nov 13, 2023

Excited to give this a spin and pleasantly relieved at how lightweight the diff is so far!

Color change and multiselect working

Move logic to LayerSelect
@javerbukh javerbukh force-pushed the horizontal-layer-buttons branch from ddeb60c to bf22850 Compare November 14, 2023 18:36
Copy link
Member

@kecnry kecnry left a comment

Choose a reason for hiding this comment

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

This is coming together! I still see some lag, so will take a closer look through the logic tomorrow and see if we can avoid that as much as possible 🤞

jdaviz/core/template_mixin.py Outdated Show resolved Hide resolved
jdaviz/core/template_mixin.py Outdated Show resolved Hide resolved
jdaviz/core/template_mixin.py Outdated Show resolved Hide resolved
Copy link
Member

@kecnry kecnry left a comment

Choose a reason for hiding this comment

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

This is really getting there!

Note that we have decided to postpone:

  • the bug (also on main) of the image visibility eye button not actually toggling the visibility
  • optimizing this so that changes to a layer color don't rebuild the entire dictionary but instead edit it in place
  • style fine-tuning

Comment on lines +629 to +630
# Determine layers visible in selected viewer(s) - consider mixed to be visible
visible_layers = [layer['label'] for layer in self.layer.items if not layer['is_subset'] and (layer['visible'] or layer['mixed_visibility'])] # noqa
Copy link
Member

Choose a reason for hiding this comment

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

@rosteen - does this change make sense to you? Now that we have this info already parsed, we can avoid the double-loop and can explicitly handle the mixed case - this means that if a layer is visible in one selected viewer, but not all, it will still be included in the logic. The alternative would be to only act all layers visible in all selected viewers, but I think you said you intended for this behavior, right?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Seems fine to me, and yeah I preferred updating all visible layers in any selected viewer.

Comment on lines 1266 to +1267
"color": layer.state.color,
"icon": self.app.state.layer_icons.get(layer.layer.label)}
"all_colors_to_label": label_to_color.get(layer.layer.label, False),
Copy link
Member

Choose a reason for hiding this comment

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

can we merge color and all_colors_to_label (some updates will also be needed to plugin_layer_select_tabs.vue if so)? Maybe just color = label_to_color.get(layer.layer.label, layer.state.color)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could, but I'm not sure what the benefit would be.

jdaviz/core/template_mixin.py Outdated Show resolved Hide resolved
jdaviz/core/template_mixin.py Outdated Show resolved Hide resolved
Comment on lines -1289 to +1359
layer_labels = [layer.layer.label for layer in layers]
layer_labels = [layer.layer.label for layer in layers if self.app.state.layer_icons.get(layer.layer.label)] # noqa
Copy link
Member

Choose a reason for hiding this comment

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

what does this change do?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sometimes this gets called before the icon has been created, which then crashes when we try to sort self.items by the icon key.

@kecnry kecnry added this to the 3.8 milestone Nov 17, 2023
Copy link

codecov bot commented Nov 17, 2023

Codecov Report

Attention: 9 lines in your changes are missing coverage. Please review.

Comparison is base (cfe7e25) 90.84% compared to head (bea110d) 90.79%.
Report is 7 commits behind head on main.

❗ Current head bea110d differs from pull request most recent head 32a75df. Consider uploading reports for the commit 32a75df to get more accurate results

Files Patch % Lines
jdaviz/core/template_mixin.py 90.00% 9 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2566      +/-   ##
==========================================
- Coverage   90.84%   90.79%   -0.05%     
==========================================
  Files         160      160              
  Lines       19357    19475     +118     
==========================================
+ Hits        17584    17682      +98     
- Misses       1773     1793      +20     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@javerbukh javerbukh marked this pull request as ready for review November 17, 2023 21:10
@rosteen
Copy link
Collaborator

rosteen commented Nov 20, 2023

Starting to test this, and it concerns me that the color swatch is so laggy to update when you click a layer. I also get an "add large data?" warning from Glue every time I click one of the layer tabs, which makes me worry that something unintended is happening, although my guess is that's from the histogram viewer:

Screen.Recording.2023-11-20.at.10.40.11.AM.mov

Is the color of the colorbar in the histogram viewer supposed to match the selected color for the layer, or is that a future feature?

@javerbukh
Copy link
Contributor Author

@rosteen It's the same amount of lag when switching layers as on main, at least the was the case with my testing. The histogram color should be updating but I think @kecnry found that was an issue introduced in the RGB presets code. I saw the warning messages as well but I am not sure where they are coming from, although the histogram is a good guess.

Copy link
Collaborator

@rosteen rosteen left a comment

Choose a reason for hiding this comment

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

Alright, if the issues I saw are unrelated then I can approve. I like the styling.

@javerbukh
Copy link
Contributor Author

Sounds good! Thank you @kecnry and @rosteen , merging when CI passes.

@javerbukh javerbukh enabled auto-merge (squash) November 20, 2023 15:59
@javerbukh javerbukh merged commit cde8d3f into spacetelescope:main Nov 20, 2023
12 of 13 checks passed
@kecnry kecnry mentioned this pull request Nov 22, 2023
9 tasks
rosteen pushed a commit to rosteen/jdaviz that referenced this pull request Nov 29, 2023
* Layers now represented as horizontal buttons

Color change and multiselect working

Move logic to LayerSelect

* Fix codestyle

* Fix codestlye and remove comments

* Viewer multiselect mixed state working

* Working on handling edge cases of mixed state

* Use messages in LayerSelect to call parts of _on_layers_changed

* Remove unused elements

* Fix button colors not updating after unmix state

* Fix codestyle

* Attempt 2 at fixing code style

* Fix CI, put buttons in icon order

* Code style again

* Fix more tests

* Everything handled by _on_layers_changed

* button styling/tooltip based on (mixed)-color/visibility

* improve tab styling

* avoid second loop when applying RGB presets

* improved handling of colormap and mixed colormode

* remove elevation

* redundant and conflicting with tab backgrounds

* use all_color_to_label in tab styling

* Mixed visibility and color represented in button

* improved handling of subset color when in colormap

* improved dark-theme support

* tooltip and RGB preset support for mixed visibility

* Visible is set to layer visible and bitmap visible

* avoid displacement when no tabs selected

* Fix CI tests

* RGB presets: handle unmixing state

* Address review comments

* Forgot one change

* for styling, always check if item in list, not as substring

* Update changelog

* Add tests

---------

Co-authored-by: Kyle Conroy <kyleconroy@gmail.com>
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.

[FEAT] Plot Options redesign
3 participants