Skip to content

Commit

Permalink
show patient name when lil-gui controller is closed
Browse files Browse the repository at this point in the history
  • Loading branch information
tuner committed Jan 10, 2025
1 parent 099e7e3 commit a855767
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 8 deletions.
26 changes: 19 additions & 7 deletions src/gui/gui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,14 @@ export function setupGui(
customCostWeights: Partial<CostWeights> = {}
) {
container.innerHTML = HTML_TEMPLATE;

const jellyfishGui = container.querySelector(".jellyfish-gui") as HTMLElement;
const patientNameElement = jellyfishGui.querySelector(
".jellyfish-patient-name"
) as HTMLElement;
const jellyfishPlotContainer = jellyfishGui.querySelector(
".jellyfish-plot-container"
) as HTMLElement;

const { generalProps, layoutProps, costWeights } =
getSavedOrDefaultSettings();
Expand All @@ -46,6 +53,15 @@ export function setupGui(
const patients = Array.from(new Set(tables.samples.map((d) => d.patient)));
generalProps.patient ??= patients[0];

const gui = new GUI({ container: jellyfishGui });
gui.onChange(saveSettings);

const isGuiOpen = () => !gui._closed;

gui.onOpenClose(() => {
patientNameElement.style.visibility = isGuiOpen() ? "hidden" : null;
});

const onPatientChange = () => {
updatePlot(
jellyfishGui,
Expand All @@ -59,12 +75,11 @@ export function setupGui(
translateX = 0;
translateY = 0;

patientNameElement.textContent = generalProps.patient;

onZoomOrPan();
};

const gui = new GUI({ container: jellyfishGui });
gui.onChange(saveSettings);

let patientController: Controller;
if (patients.length > 1) {
patientController = gui
Expand Down Expand Up @@ -135,10 +150,6 @@ export function setupGui(
});
}

const jellyfishPlotContainer = jellyfishGui.querySelector(
".jellyfish-plot-container"
) as HTMLElement;

jellyfishPlotContainer.addEventListener("mousedown", (event: MouseEvent) => {
if (event.button !== 0) {
return;
Expand Down Expand Up @@ -348,6 +359,7 @@ const HTML_TEMPLATE = `
</svg>
<span>Previous</span>
</button>
<div class="jellyfish-patient-name"></div>
<button class="jellyfish-next-patient">
<span>Next</span>
<svg viewBox="0 0 8 16" fill="currentColor">
Expand Down
12 changes: 11 additions & 1 deletion style.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a855767

Please sign in to comment.