Skip to content

Commit 9a20e4b

Browse files
author
Evgeni Raikhel
committed
Use a fast auto-commit delay for keyboard arrow-key edits
Nudging Disparity Shift/Threshold with Left/Right, or changing Downscale Ratio via keyboard/gamepad navigation, now schedules the commit 0.1s out instead of the usual 1.7s - keyboard-driven edits already land at a known, deliberate value one step at a time, so there's no need for the same give-me-a-moment-to-change-my-mind pause a mouse drag gets; a mouse click on the same radio buttons still uses the full 1.7s. finalize() takes an optional use_fast_delay flag for this. The radio buttons distinguish the two input methods via IsMouseClicked(), since RadioButton() itself returns true for both a mouse click and a keyboard/gamepad nav selection change; the slider arrow-key branches are unambiguous (mouse dragging is a separate code path) and always pass true.
1 parent 3ccc6b7 commit 9a20e4b

2 files changed

Lines changed: 18 additions & 8 deletions

File tree

common/composite-control-editor.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,14 @@ namespace rs2
107107
}
108108

109109
// Call once a field's edit is finalized (slider released, or immediately after a
110-
// checkbox/radio click). Schedules the real auto-commit commit_delay seconds out.
111-
void finalize()
110+
// checkbox/radio click). Schedules the auto-commit out by commit_delay seconds, or by
111+
// the much shorter fast_commit_delay when use_fast_delay is set - the caller's own way
112+
// of saying "this particular edit came from a keyboard arrow-key nudge, not a mouse
113+
// click/drag," which should feel closer to immediate feedback than the deliberate,
114+
// give-me-a-moment-to-change-my-mind pause a mouse edit gets.
115+
void finalize( bool use_fast_delay = false )
112116
{
113-
_commit_deadline = ImGui::GetTime() + commit_delay;
117+
_commit_deadline = ImGui::GetTime() + ( use_fast_delay ? fast_commit_delay : commit_delay );
114118
// A discrete edit (radio/checkbox click, keyboard arrow-key nudge) calls touch()+
115119
// finalize() together, synchronously, within the SAME frame as the
116120
// end_frame_and_maybe_commit() call below that just set this deadline - unlike a
@@ -228,6 +232,7 @@ namespace rs2
228232
bool _just_finalized = false;
229233

230234
static constexpr double commit_delay = 1.7; // seconds of quiet before auto-sending
235+
static constexpr double fast_commit_delay = 0.1; // ditto, for keyboard arrow-key nudges
231236
static constexpr float border_start_scale = 4.0f; // 400% of normal width, right after an edit
232237
static constexpr float border_end_scale = 2.5f; // 250% of normal width, right before commit
233238
};

common/embedded-filter-model.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,12 @@ namespace rs2
168168
{
169169
_minz_editor.value.downscale_ratio = v;
170170
_minz_editor.touch();
171-
_minz_editor.finalize(); // one click = started and finished at once
171+
// A mouse click lands on this exact frame as IsMouseClicked(); a keyboard/
172+
// gamepad nav selection change reaches this same "pressed" return without one,
173+
// since nothing was physically clicked - use the fast delay there so arrow-key
174+
// navigation feels responsive instead of waiting out the same 1.7s a deliberate
175+
// mouse click gets.
176+
_minz_editor.finalize( ! ImGui::IsMouseClicked( ImGuiMouseButton_Left ) );
172177
}
173178
any_field_active = any_field_active || ImGui::IsItemActive();
174179
}
@@ -262,13 +267,13 @@ namespace rs2
262267
{
263268
_minz_editor.value.disparity_shift = std::min( _minz_editor.value.disparity_shift + 1, 512 );
264269
_minz_editor.touch();
265-
_minz_editor.finalize();
270+
_minz_editor.finalize( true ); // arrow-key nudge - fast turnaround
266271
}
267272
else if( ImGui::IsKeyPressed( ImGuiKey_LeftArrow ) )
268273
{
269274
_minz_editor.value.disparity_shift = std::max( _minz_editor.value.disparity_shift - 1, 0 );
270275
_minz_editor.touch();
271-
_minz_editor.finalize();
276+
_minz_editor.finalize( true ); // arrow-key nudge - fast turnaround
272277
}
273278
}
274279
any_field_active = any_field_active || ImGui::IsItemActive();
@@ -343,13 +348,13 @@ namespace rs2
343348
{
344349
_minz_editor.value.threshold = std::min( _minz_editor.value.threshold + 1, 65535 );
345350
_minz_editor.touch();
346-
_minz_editor.finalize();
351+
_minz_editor.finalize( true ); // arrow-key nudge - fast turnaround
347352
}
348353
else if( ImGui::IsKeyPressed( ImGuiKey_LeftArrow ) )
349354
{
350355
_minz_editor.value.threshold = std::max( _minz_editor.value.threshold - 1, 0 );
351356
_minz_editor.touch();
352-
_minz_editor.finalize();
357+
_minz_editor.finalize( true ); // arrow-key nudge - fast turnaround
353358
}
354359
}
355360
any_field_active = any_field_active || ImGui::IsItemActive();

0 commit comments

Comments
 (0)