From 8fb4863eb049f5861ed9ab03bfcae053fd7dffd4 Mon Sep 17 00:00:00 2001 From: Boof2015 <75185879+Boof2015@users.noreply.github.com> Date: Thu, 7 May 2026 04:09:52 -0400 Subject: [PATCH] minor UI fix --- .../components/ScopeSettingsSection.tsx | 99 +++++++++++-------- 1 file changed, 57 insertions(+), 42 deletions(-) diff --git a/src/renderer/components/ScopeSettingsSection.tsx b/src/renderer/components/ScopeSettingsSection.tsx index 64534d2..6e9189f 100644 --- a/src/renderer/components/ScopeSettingsSection.tsx +++ b/src/renderer/components/ScopeSettingsSection.tsx @@ -1,4 +1,4 @@ -import type { CSSProperties, JSX, ReactNode } from 'react' +import { useState, type CSSProperties, type JSX, type ReactNode } from 'react' import type { ScopeKind } from '../../types/scope' import { SCOPE_LABELS } from '../../types/scope' import type { ScopeSettings } from '../../types/settings' @@ -215,6 +215,58 @@ function RangeControl({ ) } +function VUReferenceControl({ + value, + onChange, +}: { + value: number + onChange: (value: number) => void +}): JSX.Element { + const matchedPreset = findVUReferencePreset(value) + const [customExpanded, setCustomExpanded] = useState(matchedPreset === null) + const showCustom = customExpanded || matchedPreset === null + const selectValue = showCustom ? 'custom' : matchedPreset!.id + + return ( + <> + { + if (next === 'custom') { + setCustomExpanded(true) + return + } + const preset = VU_REFERENCE_PRESETS.find((entry) => entry.id === next) + if (preset) { + setCustomExpanded(false) + onChange(preset.dbfs) + } + }} + > + {VU_REFERENCE_PRESETS.map((preset) => ( + + ))} + + + + {showCustom && ( + onChange(sanitizeVUReferenceDbfs(next))} + /> + )} + + ) +} + interface ScopeSettingsSectionProps { kind: ScopeKind settings: ScopeSettings[ScopeKind] @@ -516,47 +568,10 @@ export default function ScopeSettingsSection({ )} - {(() => { - const matchedPreset = findVUReferencePreset(current.referenceDb) - const selectValue = matchedPreset ? matchedPreset.id : 'custom' - return ( - <> - { - if (value === 'custom') { - // Stay on the current value; the slider below takes over. - return - } - const preset = VU_REFERENCE_PRESETS.find((entry) => entry.id === value) - if (preset) { - onUpdate('vumeter', { referenceDb: preset.dbfs }) - } - }} - > - {VU_REFERENCE_PRESETS.map((preset) => ( - - ))} - - - - {selectValue === 'custom' && ( - onUpdate('vumeter', { referenceDb: sanitizeVUReferenceDbfs(value) })} - /> - )} - - ) - })()} + onUpdate('vumeter', { referenceDb: value })} + /> {current.referenceDb !== DEFAULT_VU_REFERENCE_DBFS && (