Skip to content

Commit

Permalink
changed time indicator to a button that resets the timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisj committed May 16, 2024
1 parent f96997a commit bbf2c05
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/ui/layer_bar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,25 +75,31 @@ class LayerWidget extends RefCounted {
console.log("layer is ready", layer.isReady());
if (layer.isReady() && layer.layer instanceof SegmentationUserLayer) {
const graphConnection = layer.layer.graphConnection;
const timeElement = document.createElement("div");
timeElement.innerHTML = "🕘";
const timeButton = makeIcon({ text: "🕘", title: "Share State" });
timeButton.addEventListener("click", (evt) => {
evt.stopPropagation();
if (graphConnection.value instanceof GraphConnection) {
const { timestamp } = graphConnection.value.state;
timestamp.reset();
}
});
let timeStampDisposer: (() => boolean) | undefined = undefined;
const graphConnectionChanged = () => {
if (timeStampDisposer) timeStampDisposer();
if (graphConnection.value instanceof GraphConnection) {
element.appendChild(timeElement);
element.appendChild(timeButton);
const { timestamp } = graphConnection.value.state;
const updateTimeDisplay = () => {
timeElement.style.display =
timeButton.style.display =
timestamp.value > 0 ? "inherit" : "none";
};
timeStampDisposer = this.registerDisposer(
timestamp.changed.add(updateTimeDisplay),
);
updateTimeDisplay();
} else {
if (element.contains(timeElement)) {
element.removeChild(timeElement);
if (element.contains(timeButton)) {
element.removeChild(timeButton);
}
}
};
Expand Down

0 comments on commit bbf2c05

Please sign in to comment.