Skip to content

Commit 3ccc6b7

Browse files
author
Evgeni Raikhel
committed
Hide Reset to Default behind a hover-reveal corner marker
Reset to Default is a destructive-ish, rarely-used action that doesn't need to compete for attention with the fields above it every time the MinZ box is open. It now starts collapsed to a small "..." marker in the box's bottom-right corner, and expands to the full button only while the mouse is nearby (with a margin so the tiny marker isn't fiddly to hit); moving away collapses it back. The overlay draws as an absolute-position layer via SetCursorScreenPos rather than in the normal top-to-bottom flow, and reserves no line of its own - it sits on top of, and may partially overlap, the last field's row instead of making the box taller.
1 parent cd988c3 commit 3ccc6b7

1 file changed

Lines changed: 62 additions & 24 deletions

File tree

common/embedded-filter-model.cpp

Lines changed: 62 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -366,36 +366,74 @@ namespace rs2
366366
if( ImGui::IsItemHovered() )
367367
ImGui::SetTooltip( "Unchecked = Auto (firmware-computed threshold)" );
368368

369-
// Reset to Default - goes through the exact same touch()/finalize() pipeline as every
370-
// other field edit above (one click = one discrete, debounced, atomically-committed
371-
// change), rather than a separate commit path, so it gets the fade animation and the
372-
// undo grace window for free. range.def is the FULL FW-reported default struct (header
373-
// fields included); before_commit below forces enable back on regardless, same as any
374-
// other edit in this box - "reset" doesn't leave the control disabled even if that's
375-
// literally what the FW default says, for consistency with "touching this box means you
376-
// want it on."
377-
if( ImGui::Button( "Reset to Default##minz" ) )
369+
ImGui::Dummy( ImVec2( 0, 2 ) );
370+
float frame_bottom = ImGui::GetCursorScreenPos().y;
371+
ImVec2 frame_min( frame_left, frame_top );
372+
ImVec2 frame_max( frame_left + frame_width, frame_bottom );
373+
374+
// Reset to Default starts hidden behind a small "..." marker tucked into the box's
375+
// bottom-right corner - this is a destructive-ish, rarely-used action that doesn't need
376+
// to compete for attention with the fields above it every time the box is open. Hovering
377+
// anywhere within reveal_margin of the corner (not just exactly on the tiny marker, which
378+
// would be fiddly to hit) swaps it for the real button in the same spot; moving away
379+
// collapses it back to "...". Drawn as an absolute-position overlay via
380+
// SetCursorScreenPos rather than inline in the normal top-to-bottom flow, since its
381+
// presence/absence shouldn't shift any of the fields above it - the cursor is restored
382+
// afterward so the NEXT thing this panel draws isn't displaced. No line of its own is
383+
// reserved for it (frame_bottom sits right after the last field's normal 2px pad), so
384+
// the revealed button sits on top of - and may partially overlap - that last field's
385+
// own row rather than pushing the box taller.
378386
{
379-
try
387+
ImVec2 saved_cursor = ImGui::GetCursorScreenPos();
388+
389+
ImVec2 button_size = ImGui::CalcTextSize( "Reset to Default" );
390+
button_size.x += ImGui::GetStyle().FramePadding.x * 2.0f;
391+
button_size.y += ImGui::GetStyle().FramePadding.y * 2.0f;
392+
ImVec2 button_pos( frame_max.x - button_size.x - 4.0f, frame_max.y - button_size.y - 4.0f );
393+
394+
constexpr float reveal_margin = 24.0f;
395+
ImVec2 mouse = ImGui::GetIO().MousePos;
396+
bool nearby = mouse.x >= button_pos.x - reveal_margin && mouse.x <= frame_max.x + reveal_margin
397+
&& mouse.y >= button_pos.y - reveal_margin && mouse.y <= frame_max.y + reveal_margin;
398+
399+
if( nearby )
380400
{
381-
auto range = _embedded_filter->get_composite_option_range_as< rs2_minz_control_range >( id );
382-
_minz_editor.value = range.def;
383-
_minz_editor.touch();
384-
_minz_editor.finalize();
401+
// Goes through the exact same touch()/finalize() pipeline as every other field
402+
// edit above (one click = one discrete, debounced, atomically-committed change),
403+
// rather than a separate commit path, so it gets the fade animation and the undo
404+
// grace window for free. range.def is the FULL FW-reported default struct (header
405+
// fields included); before_commit below forces enable back on regardless, same as
406+
// any other edit in this box - "reset" doesn't leave the control disabled even if
407+
// that's literally what the FW default says, for consistency with "touching this
408+
// box means you want it on."
409+
ImGui::SetCursorScreenPos( button_pos );
410+
if( ImGui::Button( "Reset to Default##minz" ) )
411+
{
412+
try
413+
{
414+
auto range = _embedded_filter->get_composite_option_range_as< rs2_minz_control_range >( id );
415+
_minz_editor.value = range.def;
416+
_minz_editor.touch();
417+
_minz_editor.finalize();
418+
}
419+
catch( const std::exception & e )
420+
{
421+
error_message = e.what();
422+
}
423+
}
424+
any_field_active = any_field_active || ImGui::IsItemActive();
425+
if( ImGui::IsItemHovered() )
426+
ImGui::SetTooltip( "Restore all fields to the firmware-reported default values" );
385427
}
386-
catch( const std::exception & e )
428+
else
387429
{
388-
error_message = e.what();
430+
ImVec2 marker_size = ImGui::CalcTextSize( "..." );
431+
ImGui::SetCursorScreenPos( ImVec2( frame_max.x - marker_size.x - 8.0f, frame_max.y - marker_size.y - 6.0f ) );
432+
ImGui::TextDisabled( "..." );
389433
}
390-
}
391-
any_field_active = any_field_active || ImGui::IsItemActive();
392-
if( ImGui::IsItemHovered() )
393-
ImGui::SetTooltip( "Restore all fields to the firmware-reported default values" );
394434

395-
ImGui::Dummy( ImVec2( 0, 2 ) );
396-
float frame_bottom = ImGui::GetCursorScreenPos().y;
397-
ImVec2 frame_min( frame_left, frame_top );
398-
ImVec2 frame_max( frame_left + frame_width, frame_bottom );
435+
ImGui::SetCursorScreenPos( saved_cursor );
436+
}
399437

400438
// Draws the dirty-state fade/border, the hover tooltip, and sends the whole struct once
401439
// the debounce timer lapses (or focus leaves the group early) - see

0 commit comments

Comments
 (0)