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

CC-154 Add code block visibility control for annotation layer #48

Merged
merged 2 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions src/layer/annotation/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/

import "#src/layer/annotation/style.css";
import svgClosedEye from "ikonate/icons/eye-closed.svg?raw";
import svgOpenedEye from "ikonate/icons/eye.svg?raw";

import type { AnnotationDisplayState } from "#src/annotation/annotation_layer_state.js";
import { AnnotationLayerState } from "#src/annotation/annotation_layer_state.js";
Expand Down Expand Up @@ -69,6 +71,7 @@ import {
import { NullarySignal } from "#src/util/signal.js";
import { DependentViewWidget } from "#src/widget/dependent_view_widget.js";
import { makeHelpButton } from "#src/widget/help_button.js";
import { makeIcon } from "#src/widget/icon.js";
import { LayerReferenceWidget } from "#src/widget/layer_reference.js";
import { makeMaximizeButton } from "#src/widget/maximize_button.js";
import { RenderScaleWidget } from "#src/widget/render_scale_widget.js";
Expand Down Expand Up @@ -783,6 +786,28 @@ class RenderingOptionsTab extends Tab {
label.style.flex = "1";
label.textContent = "Annotation shader:";
topRow.appendChild(label);

const managedLayer = this.layer.managedLayer;
const codeVisible = managedLayer.codeVisible;
this.codeWidget.element.style.display = managedLayer.codeVisible ? "block" : "none";
this.codeWidget.setVisible(codeVisible);
const codeVisibilityControl = makeIcon({
title: codeVisible ? "Hide code": "Show code",
svg: codeVisible ? svgOpenedEye : svgClosedEye,
onClick: () => {
const button = codeVisibilityControl as HTMLDivElement;
managedLayer.setCodeVisible(!managedLayer.codeVisible)
if (managedLayer.codeVisible) {
button.title = "Hide code";
button.innerHTML = svgOpenedEye
} else {
button.title = "Show code";
button.innerHTML = svgClosedEye
}
this.codeWidget.setVisible(managedLayer.codeVisible);
}});
topRow.appendChild(codeVisibilityControl);

topRow.appendChild(
makeMaximizeButton({
title: "Show larger editor view",
Expand Down
25 changes: 7 additions & 18 deletions src/layer/image/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -545,36 +545,26 @@ class RenderingOptionsTab extends Tab {
topRow.appendChild(spacer);

const managedLayer = this.layer.managedLayer;
const codeVisible = managedLayer.codeVisible;
this.codeWidget.element.style.display = managedLayer.codeVisible ? "block" : "none";
this.codeWidget.setVisible(codeVisible);
const codeVisibilityControl = makeIcon({
title: managedLayer.codeVisible ? "Hide code": "Show code",
svg: managedLayer.codeVisible ? svgOpenedEye : svgClosedEye,
title: codeVisible ? "Hide code": "Show code",
svg: codeVisible ? svgOpenedEye : svgClosedEye,
onClick: () => {
const button = codeVisibilityControl as HTMLDivElement;
managedLayer.setCodeVisible(!managedLayer.codeVisible)
if (managedLayer.codeVisible) {
button.title = "Hide code";
button.innerHTML = svgOpenedEye
this.codeWidget.element.style.display = "block";
} else {
button.title = "Show code";
button.innerHTML = svgClosedEye
this.codeWidget.element.style.display = "none";
}
this.codeWidget.setVisible(managedLayer.codeVisible);
}});
// managedLayer.layerChanged.add(() => {
// const button = codeVisibilityControl as HTMLDivElement;
// if (managedLayer.codeVisible) {
// button.title = "Hide code";
// button.innerHTML = svgOpenedEye
// this.codeWidget.element.style.display = "block";
// } else {
// button.title = "Show code";
// button.innerHTML = svgClosedEye
// this.codeWidget.element.style.display = "none";
// }
// });

topRow.appendChild(codeVisibilityControl);

topRow.appendChild(
makeMaximizeButton({
title: "Show larger editor view",
Expand All @@ -597,7 +587,6 @@ class RenderingOptionsTab extends Tab {
).element,
);

this.codeWidget.element.style.display = managedLayer.codeVisible ? "block" : "none";
element.appendChild(this.codeWidget.element);
element.appendChild(
this.registerDisposer(
Expand Down
8 changes: 8 additions & 0 deletions src/widget/shader_code_widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,4 +189,12 @@ export class ShaderCodeWidget extends RefCounted {
this.textEditor = <any>undefined;
super.disposed();
}

setVisible(visible: boolean) {
this.element.style.display = visible ? "block" : "none";
}

isVisible() {
return this.element.style.display === "block";
}
}
Loading