Keep Scope opacity at half or more, and ignore a value that is not a number

A fainter mask reads as Scope off while labels still fade outside the
keyhole and the HUD gets no backplates.

Co-authored-by: Manjunath Paparaju <[email protected]>
This commit is contained in:
Sameh KhamisandManjunath Paparaju committed 2026-11-14 15:31:33 -08:00
1 parent a1e7b2a394
commit 2fd8d32a5d
7 files changed
+106 -42

No files matched your search

+63 -20
View File
@@ -108,7 +108,11 @@ test('bloom and sharpen render their state, slider and readout', async (t) => {
await nextTick();
assert.equal($('bloom-toggle').classList.contains('active'), false);
assert.equal($('bloom-slider-row').classList.contains('visible'), false);
assert.equal($('bloom-intensity-value').textContent, '140%', 'the amount stays');
assert.equal(
$('bloom-intensity-value').textContent,
'140%',
'the amount stays',
);
});
test('a publish never rewrites a slider the user is dragging', async (t) => {
@@ -326,36 +330,50 @@ test('scope opacity renders what VisualSettings shows and sets the mask', async
assert.equal($('scope-opacity-slider').value, '100');
assert.equal($('scope-opacity-value').textContent, '100%');
owner._setScope({ opacityPct: 42.4 });
owner._setScope({ opacityPct: 62.4 });
await nextTick();
assert.equal(mask.opacity, 0.42);
assert.equal($('scope-opacity-slider').value, '42');
assert.equal($('scope-opacity-value').textContent, '42%');
assert.equal(store.view.scope.opacityPct, 42);
assert.equal(mask.opacity, 0.62);
assert.equal($('scope-opacity-slider').value, '62');
assert.equal($('scope-opacity-value').textContent, '62%');
assert.equal(store.view.scope.opacityPct, 62);
// No fainter than the floor, where the view would read as Scope off.
owner._setScope({ opacityPct: 10 });
await nextTick();
assert.equal(mask.opacity, 0.5, 'floored');
assert.equal($('scope-opacity-value').textContent, '50%');
assert.equal($('scope-opacity-slider').min, '50');
// A value that is not a number changes nothing.
owner._setScope({ opacityPct: Number.NaN });
await nextTick();
assert.equal($('scope-opacity-value').textContent, '50%');
owner._setScope({ opacityPct: 180 });
await nextTick();
assert.equal(mask.opacity, 1, 'clamped');
assert.equal($('scope-opacity-value').textContent, '100%');
owner._setScope({ opacityPct: 30 }, { apply: false });
owner._setScope({ opacityPct: 70 }, { apply: false });
await nextTick();
assert.equal(mask.opacity, 1, 'only shown');
assert.equal($('scope-opacity-value').textContent, '30%');
assert.equal($('scope-opacity-value').textContent, '70%');
owner._setScope({ enabled: false });
await nextTick();
assert.equal($('scope-opacity-slider').disabled, true, 'off with the scope');
assert.equal(store.view.scope.opacityPct, 30, 'kept while off');
assert.equal(store.view.scope.opacityPct, 70, 'kept while off');
});
test('the Visual panel groups its controls and words its on/off pills', (t) => {
const { $ } = fixture(t);
const panel = $('pp-toggles');
assert.deepEqual(
[...panel.querySelectorAll('.pp-section-heading, .visual-presets__heading')].map(
(el) => el.textContent.trim(),
),
[
...panel.querySelectorAll(
'.pp-section-heading, .visual-presets__heading',
),
].map((el) => el.textContent.trim()),
['Look', 'MAP SOURCE 3D', 'Overlay', 'Effects'],
);
assert.equal(panel.querySelector('.pp-header-label').textContent, 'VISUAL');
@@ -384,7 +402,10 @@ test('the 3D aircraft group renders what AircraftDisplay shows', async (t) => {
assert.equal(coreClasses(button), 'pp-toggle-btn active');
assert.equal(button.getAttribute('aria-pressed'), 'true');
assert.equal(row.classList.contains('visible'), true);
assert.equal($('models3d-mode-proximity').getAttribute('aria-checked'), 'true');
assert.equal(
$('models3d-mode-proximity').getAttribute('aria-checked'),
'true',
);
// The button leaves the row to its own sync.
owner._setModels3dEnabled(false);
@@ -400,7 +421,10 @@ test('the 3D aircraft group renders what AircraftDisplay shows', async (t) => {
await nextTick();
assert.equal(all.classList.contains('active'), true);
assert.equal(all.getAttribute('aria-checked'), 'true');
assert.equal($('models3d-mode-proximity').classList.contains('active'), false);
assert.equal(
$('models3d-mode-proximity').classList.contains('active'),
false,
);
assert.deepEqual(params.at(-1), ['military', { models3dMode: 'all' }]);
owner._syncModels3dFromLayerState({
@@ -429,12 +453,18 @@ test('the Draw controls render what the draw tool publishes', async (t) => {
assert.equal(segment('area').getAttribute('aria-label'), 'Area');
assert.equal(segment('area').title, 'Area');
assert.equal(segment('area').textContent, 'pentagon');
const swatch = (color) => document.querySelector(`#draw-colors [data-color="${color}"]`);
const swatch = (color) =>
document.querySelector(`#draw-colors [data-color="${color}"]`);
assert.equal(swatch('primary').getAttribute('aria-checked'), 'true');
assert.equal(swatch('amber').getAttribute('aria-label'), 'Amber');
assert.equal($('draw-hint').textContent, '');
store.publishDraw({ active: true, shape: 'line', color: 'amber', hint: 'Click to add points.' });
store.publishDraw({
active: true,
shape: 'line',
color: 'amber',
hint: 'Click to add points.',
});
await nextTick();
assert.equal(swatch('amber').getAttribute('aria-checked'), 'true');
assert.equal(swatch('primary').classList.contains('active'), false);
@@ -530,7 +560,10 @@ test('the imported files render what the file import publishes and keep focus',
assert.equal(document.activeElement === button(first, 'toggle'), true);
assert.equal(button(first, 'toggle').getAttribute('aria-pressed'), 'true');
assert.equal(button(first, 'fly').title, 'Fly to <b>a</b>.geojson');
assert.equal(button(first, 'remove').getAttribute('aria-label'), 'Remove <b>a</b>.geojson');
assert.equal(
button(first, 'remove').getAttribute('aria-label'),
'Remove <b>a</b>.geojson',
);
await press(button(first, 'remove'));
assert.equal(rowsNow().length, 1);
@@ -646,7 +679,11 @@ test('VisualSettings publishes a style’s parameters and writes a moved slider
assert.equal(store.parameters, null, 'the sliders go with their owner');
assert.equal($('param-slider-panel').classList.contains('active'), false);
assert.equal(store.act('setStyleParameter', 'grainAmt', 0.2), undefined);
assert.equal(owner.stages.noir.uniforms.grainAmt, 0.3, 'a stopped owner no longer answers');
assert.equal(
owner.stages.noir.uniforms.grainAmt,
0.3,
'a stopped owner no longer answers',
);
// An older owner's stop leaves a newer owner's rows.
const newer = { style: 'noir', rows: [] };
owner._parameters = { style: 'noir', rows: [] };
@@ -658,10 +695,16 @@ test('VisualSettings publishes a style’s parameters and writes a moved slider
test('the four Cockpit groups teleport to the published slots and back to their places', async (t) => {
const { store, $ } = fixture(t);
const groupOf = (id) => $(id).closest('.pp-toggle-group') ?? $(id);
const ids = ['hud-toggle', 'detection-toggle', 'param-slider-panel', 'models3d-toggle'];
const ids = [
'hud-toggle',
'detection-toggle',
'param-slider-panel',
'models3d-toggle',
];
const body = $('pp-toggles').querySelector('.pp-panel-body');
const order = () =>
[...body.children].filter((el) => el.matches('.pp-toggle-group, #param-slider-panel'))
[...body.children]
.filter((el) => el.matches('.pp-toggle-group, #param-slider-panel'))
.map((el) => el.id || el.querySelector('[id]')?.id);
const home = order();
const popover = document.body.appendChild(document.createElement('div'));