fix: linux display main page

This commit is contained in:
2026-09-08 21:57:38 +02:00
parent ac23f98fcd
commit 8f5a7c22cc
14 changed files with 442 additions and 195 deletions
+3 -3
View File
@@ -2,7 +2,7 @@ export function TriangleUpIcon(props: React.SVGProps<SVGSVGElement>) {
return (
<svg viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" {...props}>
<path
d="M8 3L13 10H3L8 3Z"
d="M8 5L4 10H12L8 5Z"
stroke="currentColor"
strokeWidth="1.5"
fill="transparent"
@@ -16,7 +16,7 @@ export function TriangleDownIcon(props: React.SVGProps<SVGSVGElement>) {
return (
<svg viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg" {...props}>
<path
d="M8 13L3 6H13L8 13Z"
d="M8 11L4 6H12L8 11Z"
stroke="currentColor"
strokeWidth="1.5"
fill="transparent"
@@ -24,4 +24,4 @@ export function TriangleDownIcon(props: React.SVGProps<SVGSVGElement>) {
/>
</svg>
);
}
}
@@ -0,0 +1,55 @@
/* ChoiceSelect.css */
.choice-select {
position: relative;
display: flex;
align-items: stretch;
}
.choice-select[data-disabled] {
opacity: 0.5;
}
.choice-select__input {
flex: 1 1 auto;
height: var(--card-control-height);
padding: 0 var(--space-6) 0 var(--space-3);
background: var(--bg-panel);
color: var(--text-primary);
border: var(--border-width) solid var(--border-hairline);
border-radius: var(--radius-sm);
font-family: var(--font-ui);
font-size: var(--font-sm);
appearance: none;
-webkit-appearance: none;
-moz-appearance: none;
outline: none;
cursor: pointer;
transition: border-color var(--dur-base) var(--ease-standard);
}
.choice-select__input:focus {
border-color: var(--accent-brand);
}
.choice-select__input:disabled {
cursor: not-allowed;
}
.choice-select__chevron {
position: absolute;
right: var(--space-2);
top: 50%;
height: 70%;
aspect-ratio: 1;
transform: translateY(-50%);
pointer-events: none;
color: var(--accent-brand);
font-size: var(--font-sm);
}
@@ -0,0 +1,44 @@
// ChoiceSelect.tsx
import { TriangleDownIcon } from '../../assets/icons/Triangle';
import './ChoiceSelect.css';
type ChoiceSelectProps<T extends string> = {
value: T;
options: readonly T[];
formatLabel?: (value: T) => string;
onChange: (value: T) => void;
id?: string;
disabled?: boolean;
};
function ChoiceSelect<T extends string>({
value,
options,
formatLabel = (v) => v,
onChange,
id,
disabled,
}: ChoiceSelectProps<T>) {
return (
<div className="choice-select" data-disabled={disabled || undefined}>
<select
id={id}
className="choice-select__input"
value={value}
disabled={disabled}
onChange={(e) => onChange(e.target.value as T)}
>
{options.map((option) => (
<option key={option} value={option}>
{formatLabel(option)}
</option>
))}
</select>
<span className="choice-select__chevron" aria-hidden="true">
<TriangleDownIcon />
</span>
</div>
);
}
export default ChoiceSelect;
+11 -4
View File
@@ -20,14 +20,13 @@
font-family: var(--font-ui);
font-size: 3cqh;
font-weight: var(--font-weight-semibold);
text-align: center;
text-align: left;
color: var(--accent-brand);
background: transparent;
border: none;
border-radius: var(--radius-sm);
padding: 0.5ch;
/* padding: 0.5ch; */
white-space: nowrap;
overflow: hidden;
@@ -35,7 +34,7 @@
}
.choice-stepper__input:focus {
outline: none;
outline: none;
}
.choice-stepper__arrows {
@@ -78,3 +77,11 @@
width: 100%;
height: 100%;
}
.choice-stepper[data-disabled] {
opacity: 0.5;
}
.choice-stepper__input:disabled {
cursor: not-allowed;
}
+151 -43
View File
@@ -1,60 +1,97 @@
import { useEffect, useState } from 'react';
import { JSX, useEffect, useState } from 'react';
import Button from '../Button/Button';
import { TriangleUpIcon, TriangleDownIcon } from '../../assets/icons/Triangle';
import './ChoiceStepper.css';
type ChoiceStepperProps<T> = {
function StepperArrows({
onUp,
onDown,
canUp,
canDown,
disabled,
}: {
onUp: () => void;
onDown: () => void;
canUp: boolean;
canDown: boolean;
disabled?: boolean;
}) {
return (
<div className="choice-stepper__arrows">
<Button
variant="toggle"
className="choice-stepper__arrow-btn"
onClick={onUp}
disabled={disabled || !canUp}
>
<TriangleUpIcon />
</Button>
<Button
variant="toggle"
className="choice-stepper__arrow-btn"
onClick={onDown}
disabled={disabled || !canDown}
>
<TriangleDownIcon />
</Button>
</div>
);
}
// ---- List variant ----
type ChoiceStepperListProps<T> = {
value: T;
values: readonly T[];
formatLabel: (value: T) => string;
onChange: (value: T) => void;
id?: string;
disabled?: boolean;
className?: string;
};
function ChoiceStepper<T>({ value, values, formatLabel, onChange }: ChoiceStepperProps<T>) {
function ChoiceStepperList<T>({
value,
values,
formatLabel,
onChange,
id,
disabled,
className,
}: ChoiceStepperListProps<T>) {
const index = values.indexOf(value);
const canUp = index === -1 || index < values.length - 1;
const canDown = index > 0;
const [text, setText] = useState(formatLabel(value));
useEffect(() => {
setText(formatLabel(value));
}, [value, formatLabel]);
useEffect(() => setText(formatLabel(value)), [value, formatLabel]);
const step = (direction: 1 | -1) => {
const currentIndex = index === -1 ? 0 : index;
const nextIndex = Math.min(values.length - 1, Math.max(0, currentIndex + direction));
if (nextIndex !== currentIndex) {
onChange(values[nextIndex]);
}
if (nextIndex !== currentIndex) onChange(values[nextIndex]);
};
const commitText = () => {
const match = values.find(
(v) => formatLabel(v).trim().toLowerCase() === text.trim().toLowerCase()
);
if (match !== undefined) {
onChange(match);
} else {
setText(formatLabel(value));
}
if (match !== undefined) onChange(match);
else setText(formatLabel(value));
};
return (
<div className="choice-stepper">
<div className={`choice-stepper ${className ?? ''}`} data-disabled={disabled || undefined}>
<input
id={id}
className="choice-stepper__input"
value={text}
disabled={disabled}
onChange={(e) => setText(e.target.value)}
onBlur={commitText}
onKeyDown={(e) => {
if (e.key === 'Enter') {
e.currentTarget.blur();
} else if (e.key === 'ArrowUp') {
if (e.key === 'Enter') e.currentTarget.blur();
else if (e.key === 'ArrowUp') {
e.preventDefault();
step(1);
} else if (e.key === 'ArrowDown') {
@@ -63,28 +100,99 @@ function ChoiceStepper<T>({ value, values, formatLabel, onChange }: ChoiceSteppe
}
}}
/>
<div className="choice-stepper__arrows">
<Button
variant="toggle"
className="choice-stepper__arrow-btn"
onClick={() => step(1)}
disabled={!canUp}
>
<TriangleUpIcon />
</Button>
<Button
variant="toggle"
className="choice-stepper__arrow-btn"
onClick={() => step(-1)}
disabled={!canDown}
>
<TriangleDownIcon />
</Button>
</div>
<StepperArrows
onUp={() => step(1)}
onDown={() => step(-1)}
canUp={canUp}
canDown={canDown}
disabled={disabled}
/>
</div>
);
}
// ---- Range variant (concrete, no generic) ----
type ChoiceStepperRangeProps = {
value: number;
min: number;
max: number;
step?: number;
formatLabel: (value: number) => string;
onChange: (value: number) => void;
id?: string;
disabled?: boolean;
className?: string;
};
function ChoiceStepperRange({
value,
min,
max,
step: stepSize = 1,
formatLabel,
onChange,
id,
disabled,
className,
}: ChoiceStepperRangeProps) {
const [text, setText] = useState(formatLabel(value));
useEffect(() => setText(formatLabel(value)), [value, formatLabel]);
const clamp = (n: number) => Math.min(max, Math.max(min, n));
const canUp = value < max;
const canDown = value > min;
const step = (direction: 1 | -1) => {
const next = clamp(value + direction * stepSize);
if (next !== value) onChange(next);
};
const commitText = () => {
const parsed = Number(text);
if (Number.isFinite(parsed)) onChange(clamp(parsed));
else setText(formatLabel(value));
};
return (
<div className={`choice-stepper ${className ?? ''}`} data-disabled={disabled || undefined}>
<input
id={id}
className="choice-stepper__input"
value={text}
disabled={disabled}
onChange={(e) => setText(e.target.value)}
onBlur={commitText}
onKeyDown={(e) => {
if (e.key === 'Enter') e.currentTarget.blur();
else if (e.key === 'ArrowUp') {
e.preventDefault();
step(1);
} else if (e.key === 'ArrowDown') {
e.preventDefault();
step(-1);
}
}}
/>
<StepperArrows
onUp={() => step(1)}
onDown={() => step(-1)}
canUp={canUp}
canDown={canDown}
disabled={disabled}
/>
</div>
);
}
function ChoiceStepper<T>(props: ChoiceStepperListProps<T>): JSX.Element;
function ChoiceStepper(props: ChoiceStepperRangeProps): JSX.Element;
function ChoiceStepper(props: ChoiceStepperListProps<unknown> | ChoiceStepperRangeProps) {
if ('values' in props) {
return <ChoiceStepperList {...props} />;
}
return <ChoiceStepperRange {...props} />;
}
export default ChoiceStepper;
@@ -68,8 +68,14 @@ function getPeqCrossoverPoints(
getPeqCurvePoints({ freqs, bands: peqChain.bands as any }),
getCrossoverCurvePoints({
freqs,
highPass: { frequency: crossover.high_pass.frequency, filter_type: crossover.high_pass.slope as any },
lowPass: { frequency: crossover.low_pass.frequency, filter_type: crossover.low_pass.slope as any },
highPass: {
frequency: crossover.high_pass.frequency,
filter_type: crossover.high_pass.slope as any,
},
lowPass: {
frequency: crossover.low_pass.frequency,
filter_type: crossover.low_pass.slope as any,
},
}),
]);
}
@@ -317,7 +323,9 @@ function GainSection({
const [showOutputStages, setShowOutputStages] = useState(false);
const [liveInputGains, setLiveInputGains] = useState<Partial<Record<InputChannel, number>>>({});
const [liveOutputGains, setLiveOutputGains] = useState<Partial<Record<OutputChannel, number>>>({});
const [liveOutputGains, setLiveOutputGains] = useState<Partial<Record<OutputChannel, number>>>(
{}
);
const setLiveInputGain = (channel: InputChannel, value: number | null) => {
setLiveInputGains((prev) => {
@@ -381,7 +389,11 @@ function GainSection({
inputColors,
showInputStages,
(channel) =>
getInputChannelCurves(dsp.state.current_config.input_states[channel], freqs, liveInputGains[channel])
getInputChannelCurves(
dsp.state.current_config.input_states[channel],
freqs,
liveInputGains[channel]
)
);
const outputCurves = buildCurvesForChannels(
@@ -390,7 +402,11 @@ function GainSection({
outputColors,
showOutputStages,
(channel) =>
getOutputChannelCurves(dsp.state.current_config.output_states[channel], freqs, liveOutputGains[channel])
getOutputChannelCurves(
dsp.state.current_config.output_states[channel],
freqs,
liveOutputGains[channel]
)
);
const { yMin: inputYMin, yMax: inputYMax } = computeYAxisBounds(
@@ -535,4 +551,4 @@ function GainSection({
);
}
export default GainSection;
export default GainSection;
@@ -13,7 +13,7 @@ import {
} from '../../constants';
import { SidebarId } from '../../constants';
import SignalFlowMatrix from '../../../../components/SignalFlowMatrix/SignalFlowMatrix';
import './MatrixSection.css';
import './Matrixsection.css';
const GAIN_VALUES: number[] = (() => {
const values: number[] = [];
+2 -5
View File
@@ -58,9 +58,7 @@ export function sumCurvePoints(pointArrays: CurvePoint[][]): CurvePoint[] {
return result;
}
export function sumPhaseCurvePoints(
pointArrays: CurvePoint[][]
): CurvePoint[] {
export function sumPhaseCurvePoints(pointArrays: CurvePoint[][]): CurvePoint[] {
if (pointArrays.length === 0) return [];
const length = pointArrays[0].length;
@@ -85,8 +83,7 @@ export function sumPhaseCurvePoints(
}
// Wrap to [-180, 180].
const wrapped =
((((phase + 180) % 360) + 360) % 360) - 180;
const wrapped = ((((phase + 180) % 360) + 360) % 360) - 180;
result[i] = {
x: pointArrays[0][i].x,
+1 -7
View File
@@ -1,10 +1,4 @@
import {
CurvePoint,
CurveStyle,
Curve,
DEFAULT_CURVE_COLORS,
sumCurvePoints,
} from './curve';
import { CurvePoint, CurveStyle, Curve, DEFAULT_CURVE_COLORS, sumCurvePoints } from './curve';
export { sumCurvePoints };
+1 -1
View File
@@ -332,4 +332,4 @@ export function getPeqPhasePoints({
x: freq,
y: peqTotalPhaseDeg(freq, bands, sampleRate),
}));
}
}
+96 -5
View File
@@ -34,21 +34,26 @@
color: var(--text-muted);
}
.add-dsp-form__field input,
.add-dsp-form__field select {
/* Input */
.add-dsp-form__field input {
height: var(--card-control-height);
padding: 0 var(--space-3);
background: var(--bg-panel);
color: var(--text-primary);
border: var(--border-width) solid var(--border-hairline);
border-radius: var(--radius-sm);
color: var(--text-primary);
font-family: var(--font-ui);
font-size: var(--font-sm);
outline: none;
appearance: none;
-webkit-appearance: none;
transition: border-color var(--dur-base) var(--ease-standard);
}
@@ -56,11 +61,15 @@
font-family: var(--font-mono);
}
.add-dsp-form__field input:focus,
.add-dsp-form__field select:focus {
.add-dsp-form__field input:focus {
border-color: var(--accent-brand);
}
.add-dsp-form__field input::placeholder {
color: var(--text-muted);
opacity: 0.5;
}
.add-dsp-form__actions {
display: flex;
justify-content: flex-end;
@@ -68,7 +77,89 @@
margin-top: var(--space-2);
}
.add-dsp-form__field input:disabled {
color: var(--text-muted);
background: var(--bg-panel);
border-color: var(--border-hairline);
opacity: 0.5;
cursor: not-allowed;
}
/* CheckBox */
.add-dsp-form__checkbox-label {
display: flex;
align-items: center;
gap: var(--space-2);
cursor: pointer;
}
.add-dsp-form__checkbox-label input[type='checkbox'] {
appearance: none;
-webkit-appearance: none;
box-sizing: border-box;
flex: 0 0 auto;
display: block;
width: 18px;
height: 18px;
aspect-ratio: 1 / 1;
padding: 0;
margin: 0;
background: var(--bg-panel);
border: var(--border-width) solid var(--border-hairline);
border-radius: var(--radius-sm);
position: relative;
cursor: pointer;
transition:
border-color var(--dur-base) var(--ease-standard),
background var(--dur-base) var(--ease-standard);
}
.add-dsp-form__checkbox-label input[type='checkbox']:checked {
background: var(--accent-brand);
border-color: var(--accent-brand);
}
.add-dsp-form__checkbox-label input[type='checkbox']:checked::after {
content: '';
position: absolute;
left: 50%;
top: 50%;
width: 5px;
height: 9px;
border: solid var(--bg-panel);
border-width: 0 2px 2px 0;
transform: translate(-50%, -60%) rotate(45deg);
}
.add-dsp-form__checkbox-label input[type='checkbox']:focus-visible {
outline: 2px solid var(--accent-brand);
outline-offset: 2px;
}
/* Stepper */
.add-dsp-form__stepper {
width: auto;
flex: 0 0 auto;
min-width: 120px;
height: var(--card-control-height);
}
.add-dsp-form__stepper .choice-stepper__arrows {
padding: 4px 4px 4px 0;
gap: 2px;
}
.add-dsp-form__field .choice-stepper__input {
border: none;
background: transparent;
}
+20 -31
View File
@@ -2,6 +2,8 @@ import { useState } from 'react';
import { DSP, DSP_DEFAULT_PARAMETERS, DSPTypes } from '../../types';
import Button from '../../components/Button/Button';
import Card from '../../components/Card/Card';
import ChoiceStepper from '../../components/ChoiceStepper/ChoiceStepper';
import ChoiceSelect from '../../components/ChoiceSelect/ChoiceSelect';
import './AddDspPage.css';
@@ -14,6 +16,8 @@ type DSPForm = {
demo: boolean;
};
const DSP_TYPES = Object.keys(DSP_DEFAULT_PARAMETERS) as DSPTypes[];
function AddDSPForm({
onCancel,
onAdd,
@@ -39,9 +43,7 @@ function AddDSPForm({
function submit() {
if (!canSubmit) return;
onAdd({
...form,
});
onAdd({ ...form });
}
return (
@@ -64,38 +66,24 @@ function AddDSPForm({
<div className="add-dsp-form__row">
<div className="add-dsp-form__field">
<label htmlFor="f-type">Model</label>
<select
<ChoiceSelect
id="f-type"
value={form.type}
onChange={(e) => {
const type = e.target.value as DSPTypes;
setForm({
...form,
type,
});
}}
>
{Object.keys(DSP_DEFAULT_PARAMETERS).map((type) => (
<option key={type} value={type}>
{type}
</option>
))}
</select>
options={DSP_TYPES}
onChange={(type) => setForm({ ...form, type })}
/>
</div>
<div className="add-dsp-form__field">
<label htmlFor="f-deviceid">Device ID</label>
<input
<ChoiceStepper
id="f-deviceid"
className="mono"
type="number"
className="add-dsp-form__stepper"
value={form.deviceId}
min={1}
max={255}
step={1}
placeholder="1"
value={form.deviceId}
onChange={(e) => setForm({ ...form, deviceId: Number(e.target.value) })}
formatLabel={(v) => String(v)}
onChange={(deviceId) => setForm({ ...form, deviceId })}
/>
</div>
</div>
@@ -114,13 +102,15 @@ function AddDSPForm({
<div className="add-dsp-form__field">
<label htmlFor="f-port">Port</label>
<input
<ChoiceStepper
id="f-port"
className="mono"
type="number"
className="add-dsp-form__stepper"
value={form.port}
min={1}
max={65535}
disabled={form.demo}
onChange={(e) => setForm({ ...form, port: Number(e.target.value) })}
formatLabel={(v) => String(v)}
onChange={(port) => setForm({ ...form, port })}
/>
</div>
</div>
@@ -141,7 +131,6 @@ function AddDSPForm({
<Button variant="ghost" onClick={onCancel}>
Cancel
</Button>
<Button variant="primary" onClick={submit} disabled={!canSubmit}>
Add DSP
</Button>