Skip to content

Commit

Permalink
temp - crude implementation of time indicator in layer widget
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisj committed May 8, 2024
1 parent 4b854cf commit f163ad1
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/ui/layer_bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@
import "#src/noselect.css";
import "#src/ui/layer_bar.css";
import svg_plus from "ikonate/icons/plus.svg?raw";
import { GraphConnection } from "#src/datasource/graphene/frontend.js";
import type { ManagedUserLayer } from "#src/layer/index.js";
import { addNewLayer, deleteLayer, makeLayer } from "#src/layer/index.js";
import { SegmentationUserLayer } from "#src/layer/segmentation/index.js";
import type { LayerGroupViewer } from "#src/layer_group_viewer.js";
import { NavigationLinkType } from "#src/navigation_state.js";
import type { WatchableValueInterface } from "#src/trackable_value.js";
Expand Down Expand Up @@ -67,6 +69,31 @@ class LayerWidget extends RefCounted {
element.appendChild(prefetchProgress);
labelElement.className = "neuroglancer-layer-item-label";
labelElement.appendChild(labelElementText);
if (layer.layer instanceof SegmentationUserLayer) {
const graphConnection = layer.layer.graphConnection;
const timeElement = document.createElement("div");
timeElement.innerHTML = "🕘";
let timeStampDisposer: (() => boolean) | undefined = undefined;
this.registerDisposer(
graphConnection.changed.add(() => {
if (timeStampDisposer) timeStampDisposer();
if (graphConnection.value instanceof GraphConnection) {
element.appendChild(timeElement);
const { timestamp } = graphConnection.value.state;
const updateTimeDisplay = () => {
timeElement.style.display =
timestamp.value > 0 ? "inherit" : "none";
};
timeStampDisposer = this.registerDisposer(
timestamp.changed.add(updateTimeDisplay),
);
updateTimeDisplay();
} else {
element.removeChild(timeElement);
}
}),
);
}
visibleProgress.className = "neuroglancer-layer-item-visible-progress";
prefetchProgress.className = "neuroglancer-layer-item-prefetch-progress";
layerNumberElement.className = "neuroglancer-layer-item-number";
Expand Down

0 comments on commit f163ad1

Please sign in to comment.