Skip to content

Commit

Permalink
combo box align and visual changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Noy-Zini committed Oct 27, 2024
1 parent de34ecc commit 4b5f3a8
Show file tree
Hide file tree
Showing 6 changed files with 133 additions and 222 deletions.
76 changes: 63 additions & 13 deletions common/device-model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -922,8 +922,11 @@ namespace rs2
}
if (ImGui::IsItemHovered())
{
ImGui::PushStyleColor(ImGuiCol_PopupBg, black);
ImGui::PushStyleColor(ImGuiCol_Text, white);
ImGui::SetTooltip("%s", show_device_info ? "Hide Device Details" : "Show Device Details");
window.link_hovered();
ImGui::PopStyleColor(2);
}
ImGui::PopStyleColor(2);
}
Expand Down Expand Up @@ -1222,6 +1225,10 @@ namespace rs2
auto record_button_color = is_recording ? light_blue : light_grey;
ImGui::PushStyleColor(ImGuiCol_Text, record_button_color);
ImGui::PushStyleColor(ImGuiCol_TextSelectedBg, record_button_color);
bool button_disabled = disable_record_button_logic(is_streaming, is_playback_device);
if (button_disabled)
ImGui::PushStyleColor(ImGuiCol_Text,ImVec4(0.5f,0.5f,0.5f,1.f));

if (ImGui::ButtonEx(record_button_name.c_str(), device_panel_icons_size, (disable_record_button_logic(is_streaming, is_playback_device)) ? ImGuiItemFlags_Disabled : 0))
{
if (is_recording) //is_recording is changed inside stop/start_recording
Expand Down Expand Up @@ -1254,12 +1261,17 @@ namespace rs2
}
if (ImGui::IsItemHovered())
{
ImGui::PushStyleColor(ImGuiCol_PopupBg, black);
ImGui::PushStyleColor(ImGuiCol_Text, white);
std::string record_button_hover_text = get_record_button_hover_text(is_streaming);
ImGui::SetTooltip("%s", record_button_hover_text.c_str());
if (is_streaming) window.link_hovered();
ImGui::PopStyleColor(2);
}

ImGui::PopStyleColor(2);
if(button_disabled)
ImGui::PopStyleColor(3);
else
ImGui::PopStyleColor(2);
ImGui::SameLine();
////////////////////////////////////////
// Draw Sync icon
Expand All @@ -1269,15 +1281,19 @@ namespace rs2
auto sync_button_color = is_sync_enabled ? light_blue : light_grey;
ImGui::PushStyleColor(ImGuiCol_Text, sync_button_color);
ImGui::PushStyleColor(ImGuiCol_TextSelectedBg, sync_button_color);
ImGui::PushStyleColor(ImGuiCol_Text, ImVec4(0.5f, 0.5f, 0.5f, 1.f));
if (ImGui::ButtonEx(sync_button_name.c_str(), device_panel_icons_size, ImGuiItemFlags_Disabled))
{
is_sync_enabled = !is_sync_enabled;
}
ImGui::PopStyleColor(3);
if (ImGui::IsItemHovered())
{
ImGui::PushStyleColor(ImGuiCol_PopupBg, black);
ImGui::PushStyleColor(ImGuiCol_Text, white);
ImGui::SetTooltip("%s", is_sync_enabled ? "Disable streams synchronization" : "Enable streams synchronization");
ImGui::PopStyleColor(2);
}
ImGui::PopStyleColor(2);
ImGui::SameLine();
////////////////////////////////////////
// Draw Info icon
Expand All @@ -1296,8 +1312,11 @@ namespace rs2
}
if (ImGui::IsItemHovered())
{
ImGui::PushStyleColor(ImGuiCol_PopupBg, black);
ImGui::PushStyleColor(ImGuiCol_Text, white);
ImGui::SetTooltip("%s", "Click for more");
window.link_hovered();
ImGui::PopStyleColor(2);
}
ImGui::PopFont();
ImGui::PushFont(window.get_font());
Expand Down Expand Up @@ -1353,10 +1372,13 @@ namespace rs2
}
if (ImGui::IsItemHovered())
{
ImGui::PushStyleColor(ImGuiCol_PopupBg, black);
ImGui::PushStyleColor(ImGuiCol_Text, white);
std::string tooltip = rsutils::string::from()
<< "Install official signed firmware from file to the device"
<< ( is_streaming ? " (Disabled while streaming)" : "" );
ImGui::SetTooltip("%s", tooltip.c_str());
ImGui::PopStyleColor(2);
}


Expand All @@ -1379,8 +1401,11 @@ namespace rs2

if (ImGui::IsItemHovered())
{
ImGui::PushStyleColor(ImGuiCol_PopupBg, black);
ImGui::PushStyleColor(ImGuiCol_Text, white);
std::string tooltip = rsutils::string::from() << "Check for SW / FW updates";
ImGui::SetTooltip("%s", tooltip.c_str());
ImGui::PopStyleColor(2);
}
}

Expand All @@ -1401,10 +1426,13 @@ namespace rs2
}
if (ImGui::IsItemHovered())
{
ImGui::PushStyleColor(ImGuiCol_PopupBg, black);
ImGui::PushStyleColor(ImGuiCol_Text, white);
std::string tooltip = rsutils::string::from()
<< "Install non official unsigned firmware from file to the device"
<< ( is_streaming ? " (Disabled while streaming)" : "" );
ImGui::SetTooltip("%s", tooltip.c_str());
ImGui::PopStyleColor(2);
}
}
}
Expand Down Expand Up @@ -1438,9 +1466,9 @@ namespace rs2
//Move to next line, and we want to keep the horizontal alignment
ImGui::SetCursorPos({ panel_pos.x, ImGui::GetCursorPosY() });
//Using transparent-non-actionable buttons to have the same locations
ImGui::PushStyleColor(ImGuiCol_Button, (ImVec4&)ImColor(0, 0, 0, 0));
ImGui::PushStyleColor(ImGuiCol_ButtonActive, (ImVec4&)ImColor(0, 0, 0, 0));
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, (ImVec4&)ImColor(0, 0, 0, 0));
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.0f, 0.0f, 0.0f, 0.0f));
ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(0.0f, 0.0f, 0.0f, 0.0f));
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(0.0f, 0.0f, 0.0f, 0.0f));
const ImVec2 device_panel_icons_text_size = { icons_width, 5 };

ImGui::PushStyleColor(ImGuiCol_Text, record_button_color);
Expand Down Expand Up @@ -1931,11 +1959,14 @@ namespace rs2
ImGui::Text("Preset: ");
if (ImGui::IsItemHovered())
{
ImGui::PushStyleColor(ImGuiCol_PopupBg, black);
ImGui::PushStyleColor(ImGuiCol_Text, white);
ImGui::SetTooltip("Select a preset configuration (or use the load button)");
ImGui::PopStyleColor(2);
}

ImGui::SameLine();
ImGui::PushItemWidth(185);
ImGui::PushItemWidth(210);

///////////////////////////////////////////
//TODO: make this a member function
Expand Down Expand Up @@ -1971,7 +2002,7 @@ namespace rs2

try
{
if (ImGui::Combo(opt_model.id.c_str(), &selected, labels.data(),
if (ImGui::CustomComboBox(opt_model.id.c_str(), &selected, labels.data(),
static_cast<int>(labels.size())))
{
*opt_model.invalidate_flag = true;
Expand Down Expand Up @@ -2091,10 +2122,13 @@ namespace rs2

if (ImGui::IsItemHovered())
{
ImGui::PushStyleColor(ImGuiCol_PopupBg, black);
ImGui::PushStyleColor(ImGuiCol_Text, white);
std::string tooltip = rsutils::string::from()
<< "Load pre-configured device settings"
<< ( is_streaming && ! load_json_if_streaming ? " (Disabled while streaming)" : "" );
ImGui::SetTooltip("%s", tooltip.c_str());
ImGui::PopStyleColor(2);
}

ImGui::SameLine();
Expand Down Expand Up @@ -2122,7 +2156,10 @@ namespace rs2
}
if (ImGui::IsItemHovered())
{
ImGui::PushStyleColor(ImGuiCol_PopupBg, black);
ImGui::PushStyleColor(ImGuiCol_Text, white);
ImGui::SetTooltip("Save current device settings to file");
ImGui::PopStyleColor(2);
}
ImGui::PopStyleColor(2);
ImGui::SameLine();
Expand Down Expand Up @@ -2281,8 +2318,11 @@ namespace rs2

if (ImGui::IsItemHovered())
{
ImGui::PushStyleColor(ImGuiCol_PopupBg, black);
ImGui::PushStyleColor(ImGuiCol_Text, white);
ImGui::SetTooltip("Remove selected device from current view\n(can be restored by clicking Add Source)");
window.link_hovered();
ImGui::PopStyleColor(2);
}
}
ImGui::PopStyleColor(4);
Expand Down Expand Up @@ -2332,7 +2372,7 @@ namespace rs2
auto advanced_mode_pos = ImVec2{ pos.x + horizontal_space_before_device_control, pos.y + vertical_space_before_advanced_mode_control };
ImGui::SetCursorPos(advanced_mode_pos);
const float advanced_mode_panel_height = draw_preset_panel(panel_width, window, error_message, viewer, update_read_only_options, load_json_if_streaming, json_loading);
ImGui::SetCursorPos({ advanced_mode_pos.x, advanced_mode_pos.y + advanced_mode_panel_height });
ImGui::SetCursorPos({ advanced_mode_pos.x, advanced_mode_pos.y + advanced_mode_panel_height+10});
}

////////////////////////////////////////
Expand Down Expand Up @@ -2421,7 +2461,7 @@ namespace rs2
{
bool stop_recording = false;

ImGui::SetCursorPos({ windows_width - 60, pos.y });
ImGui::SetCursorPos({ windows_width - 60, pos.y + 3 });
ImGui_ScopePushFont(window.get_font());

ImGui_ScopePushStyleColor(ImGuiCol_Button, sensor_bg);
Expand Down Expand Up @@ -2508,8 +2548,13 @@ namespace rs2
}
if (ImGui::IsItemHovered())
{
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(5, 5));
ImGui::SetNextWindowSize(ImVec2(255, 30));
window.link_hovered();
ImGui::SetTooltip("Start streaming data from this sensor");
ImGui::BeginTooltipEx(ImGuiTooltipFlags_None,ImGuiWindowFlags_NoScrollbar);
ImGui::TextUnformatted("Start streaming data from this sensor");
ImGui::EndTooltip();
ImGui::PopStyleVar();
}
}
}
Expand Down Expand Up @@ -2543,8 +2588,13 @@ namespace rs2
}
if (ImGui::IsItemHovered())
{
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(5, 5));
ImGui::SetNextWindowSize(ImVec2(310, 30));
window.link_hovered();
ImGui::SetTooltip("Stop streaming data from selected sub-device");
ImGui::BeginTooltipEx(ImGuiTooltipFlags_None, ImGuiWindowFlags_NoScrollbar);
ImGui::TextUnformatted("Stop streaming data from selected sub-device");
ImGui::EndTooltip();
ImGui::PopStyleVar();
}
}

Expand Down Expand Up @@ -2897,7 +2947,7 @@ namespace rs2
ImGui::PopStyleVar();
ImGui::PopStyleColor(3);

ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 2);
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 10);
}

for (auto&& sub : subdevices)
Expand Down
4 changes: 3 additions & 1 deletion common/option-model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,8 @@ bool option_model::draw_combobox( notifications_model & model,

try
{
if( ImGui::Combo( id.c_str(), &selected, labels.data(), static_cast< int >( labels.size() ) ) )
ImGui::PushItemWidth(184); // Set the width for the combo box itself
if( ImGui::CustomComboBox( id.c_str(), &selected, labels.data(), static_cast< int >( labels.size() ) ) )
{
float tmp_value = range.min + range.step * selected;
model.add_log( rsutils::string::from()
Expand All @@ -275,6 +276,7 @@ bool option_model::draw_combobox( notifications_model & model,
*invalidate_flag = true;
item_clicked = true;
}
ImGui::PopItemWidth();
}
catch( const error & e )
{
Expand Down
26 changes: 14 additions & 12 deletions common/subdevice-model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "post-processing-filters-list.h"
#include "post-processing-block-model.h"
#include <imgui_internal.h>
#include <realsense_imgui.h>

#include "metadata-helper.h"
#include "subdevice-model.h"
Expand Down Expand Up @@ -558,10 +559,10 @@ namespace rs2
}
else
{
ImGui::PushItemWidth(-1);
ImGui::PushItemWidth(170); // Set the width for the combo box itself
ImGui::PushStyleColor(ImGuiCol_TextSelectedBg, { 1,1,1,1 });
auto tmp_selected_res_id = ui.selected_res_id;
if (ImGui::Combo(label.c_str(), &tmp_selected_res_id, res_chars.data(),
if (ImGui::CustomComboBox(label.c_str(), &tmp_selected_res_id, res_chars.data(),
static_cast<int>(res_chars.size())))
{
res = true;
Expand Down Expand Up @@ -637,9 +638,9 @@ namespace rs2
}
else
{
ImGui::PushItemWidth(-1);
ImGui::PushItemWidth(170); // Set the width for the combo box itself
ImGui::PushStyleColor(ImGuiCol_TextSelectedBg, { 1,1,1,1 });
if (ImGui::Combo(label.c_str(), &ui.selected_shared_fps_id, fps_chars.data(),
if (ImGui::CustomComboBox(label.c_str(), &ui.selected_shared_fps_id, fps_chars.data(),
static_cast<int>(fps_chars.size())))
{
res = true;
Expand Down Expand Up @@ -716,9 +717,9 @@ namespace rs2
}
else
{
ImGui::PushItemWidth(-1);
ImGui::PushItemWidth(170); // Set the width for the combo box itself
ImGui::PushStyleColor(ImGuiCol_TextSelectedBg, { 1,1,1,1 });
ImGui::Combo(label.c_str(), &ui.selected_format_id[f.first], formats_chars.data(),
ImGui::CustomComboBox(label.c_str(), &ui.selected_format_id[f.first], formats_chars.data(),
static_cast<int>(formats_chars.size()));
ImGui::PopStyleColor();
ImGui::PopItemWidth();
Expand All @@ -743,9 +744,9 @@ namespace rs2
}
else
{
ImGui::PushItemWidth(-1);
ImGui::PushItemWidth(170); // Set the width for the combo box itself
ImGui::PushStyleColor(ImGuiCol_TextSelectedBg, { 1,1,1,1 });
ImGui::Combo(label.c_str(), &ui.selected_fps_id[f.first], fps_chars.data(),
ImGui::CustomComboBox(label.c_str(), &ui.selected_fps_id[f.first], fps_chars.data(),
static_cast<int>(fps_chars.size()));
ImGui::PopStyleColor();
ImGui::PopItemWidth();
Expand Down Expand Up @@ -798,10 +799,10 @@ namespace rs2
}
else
{
ImGui::PushItemWidth(-1);
ImGui::PushItemWidth(170); // Set the width for the combo box itself
ImGui::PushStyleColor(ImGuiCol_TextSelectedBg, { 1,1,1,1 });
auto tmp_selected_res_id = ui.selected_res_id_map[stream_type_id];
if (ImGui::Combo(label.c_str(), &tmp_selected_res_id, res_chars.data(),
if (ImGui::CustomComboBox(label.c_str(), &tmp_selected_res_id, res_chars.data(),
static_cast<int>(res_chars.size())))
{
res = true;
Expand Down Expand Up @@ -931,9 +932,9 @@ namespace rs2
}
else
{
ImGui::PushItemWidth(-1);
ImGui::PushItemWidth(170); // Set the width for the combo box itself
ImGui::PushStyleColor(ImGuiCol_TextSelectedBg, { 1,1,1,1 });
ImGui::Combo(label.c_str(), &ui.selected_format_id[f.first], formats_chars.data(),
ImGui::CustomComboBox(label.c_str(), &ui.selected_format_id[f.first], formats_chars.data(),
static_cast<int>(formats_chars.size()));
ImGui::PopStyleColor();
ImGui::PopItemWidth();
Expand Down Expand Up @@ -976,6 +977,7 @@ namespace rs2
// The function returns true if one of the configuration parameters changed
bool subdevice_model::draw_stream_selection(std::string& error_message)
{
ImGui::SetCursorPosY(ImGui::GetCursorPosY() + 10);
bool res = false;

std::string label = rsutils::string::from()
Expand Down
2 changes: 1 addition & 1 deletion common/viewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1829,7 +1829,7 @@ namespace rs2

// Don't draw text in boxes that are too small...
auto h = bbox.h;
ImGui::PushStyleColor( ImGuiCol_Text, (ImVec4&)ImColor( 1.f, 1.f, 1.f, a ) );
ImGui::PushStyleColor( ImGuiCol_Text, ImVec4( 1.f, 1.f, 1.f, a ) );
ImColor bg( dark_sensor_bg.x, dark_sensor_bg.y, dark_sensor_bg.z, dark_sensor_bg.w * a );

if( fabs(object.mean_depth) > 0.f )
Expand Down
Loading

0 comments on commit 4b5f3a8

Please sign in to comment.