Skip to content

Commit

Permalink
Merge pull request #49 from MetaCell/feature/CC-156
Browse files Browse the repository at this point in the history
CC-156 Add code visibility control for single mesh layer
  • Loading branch information
aranega authored Nov 13, 2024
2 parents ca34789 + 77532fb commit 9cd8698
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/layer/single_mesh/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/

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

import type { ManagedUserLayer } from "#src/layer/index.js";
import {
Expand All @@ -37,6 +39,7 @@ import type { Borrowed } from "#src/util/disposable.js";
import { RefCounted } from "#src/util/disposable.js";
import { removeChildren, removeFromParent } from "#src/util/dom.js";
import { makeHelpButton } from "#src/widget/help_button.js";
import { makeIcon } from "#src/widget/icon.js";
import { makeMaximizeButton } from "#src/widget/maximize_button.js";
import { ShaderCodeWidget } from "#src/widget/shader_code_widget.js";
import {
Expand Down Expand Up @@ -207,6 +210,28 @@ class DisplayOptionsTab extends Tab {
spacer.style.flex = "1";

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: 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

0 comments on commit 9cd8698

Please sign in to comment.