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

Add option to hide/show code block #688

Open
wants to merge 23 commits into
base: master
Choose a base branch
from

Conversation

aranega
Copy link
Contributor

@aranega aranega commented Dec 19, 2024

Summary

This PR introduces a new control button in the layer configuration panel that allows users to toggle the visibility of the shader code editor if one is present (depending on the layer's type). This button shows or hides the code editor within the layer configuration panel, allowing users to focus on other parameters present in the layer configuration panel. Open to feedback and suggestions on the implementation and user interaction!

Current version (no code viewer button):

screenwithout

New Option (code viewer visible with button, and hidden):

close
open

Motivation

The ability to show or hide the code viewer was requested to help the user to not be intimidated by the shader code editor which is not manipulated often directly by user visualizing data only. Users often need the option to focus on the 3D view or data without the distraction of the shader code.

User Interaction

In Neuroglancer, the new toggle button is available in the layer configuration panel, placed on top of the shader code editor, next to the "show large editor view" and the "documentation" button. This button allows users to show or hide the code viewer as needed. The control is simple, enabling users to easily manage the visibility of the code viewer without requiring additional keybinds. Very open to suggestions on improving this functionality and placement in the UI.

Implementation

The primary change occurs within the tab rendering components for each impacted layers (currently, annotation layer, image layer, and single mesh layer). A button icon is dynamically updated based on the visibility state, ensuring users can easily toggle between viewing and hiding the code block. The state of the viewer is saved in the state related to each layer.

Example of the new functionality:

video-of-all-three-code-boxes.mp4

Copy link

google-cla bot commented Dec 19, 2024

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@aranega aranega requested a review from jbms January 23, 2025 15:11
@@ -541,6 +552,22 @@ class RenderingOptionsTab extends Tab {
topRow.className = "neuroglancer-image-dropdown-top-row";
topRow.appendChild(document.createTextNode("Shader"));
topRow.appendChild(spacer);

Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we factor out this topRow logic now that it has become more complicated to reduce duplication across layers?

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 tried to factorize the top row creation, but at the end, it's tightly coupled to each reification of the UserLayer as the codeVisible property is located inside each UserLayer that requires it. Also, the top row is created by being associated at some point to the ShaderOverlay class that is defined in each module that defines the UserLayer. We could pass it as parameter, but we woud need also to have something for the help text, as well as the css class for the div. Also, having this as a separate function somewhere would imply that "layer" is passed as parameter and we couldn't access the "codeVisible" attribute unless we consider "layer" as any. If that's not a problem, I can factorize the code like this, and put this function in the same module that defines the ShaderCodeWidget.

At the moment, what I did is to extract the creation of the top row in a separate function, but duplicated (with small variations) in each module. This way, it mimicks more the equivalent of the makeShaderCodeWidget function in each of those modules.

Copy link
Collaborator

Choose a reason for hiding this comment

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

You could make the layer parameter some new interface that specifies the required properties --- and similarly pass in the ShaderOverlay and help strings as parameters.

@jbms
Copy link
Collaborator

jbms commented Feb 21, 2025

Note: The segmentation layer also has a shader code control, used when rendering skeletons only. It would be good to add the option to hide that also.

@aranega aranega requested a review from jbms February 27, 2025 14:25
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