Skip to content

Commit

Permalink
PR IntelRealSense#12513 from noacoohen: Refactor the logic and hover …
Browse files Browse the repository at this point in the history
…text by for disabling the record button
  • Loading branch information
Nir-Az authored Dec 13, 2023
2 parents 9efe9cb + 36ac8eb commit 514c9e1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
25 changes: 22 additions & 3 deletions common/device-model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1213,11 +1213,11 @@ namespace rs2
textual_icon button_icon = is_recording ? textual_icons::stop : textual_icons::circle;
const float icons_width = 78.0f;
const ImVec2 device_panel_icons_size{ icons_width, 25 };
std::string recorod_button_name = rsutils::string::from() << button_icon << "##" << id;
std::string record_button_name = rsutils::string::from() << button_icon << "##" << id;
auto record_button_color = is_recording ? light_blue : light_grey;
ImGui::PushStyleColor(ImGuiCol_Text, record_button_color);
ImGui::PushStyleColor(ImGuiCol_TextSelectedBg, record_button_color);
if (ImGui::ButtonEx(recorod_button_name.c_str(), device_panel_icons_size, (!is_streaming || is_playback_device) ? ImGuiButtonFlags_Disabled : 0))
if (ImGui::ButtonEx(record_button_name.c_str(), device_panel_icons_size, (disable_record_button_logic(is_streaming, is_playback_device)) ? ImGuiButtonFlags_Disabled : 0))
{
if (is_recording) //is_recording is changed inside stop/start_recording
{
Expand Down Expand Up @@ -1249,7 +1249,7 @@ namespace rs2
}
if (ImGui::IsItemHovered())
{
std::string record_button_hover_text = (!is_streaming ? "Start streaming to enable recording" : (is_recording ? "Stop Recording" : "Start Recording"));
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();
}
Expand Down Expand Up @@ -3274,6 +3274,25 @@ namespace rs2
//TODO: Move under hour glass
}

bool device_model::disable_record_button_logic(bool is_streaming, bool is_playback_device)
{
return (!is_streaming || is_playback_device);
}

std::string device_model::get_record_button_hover_text(bool is_streaming)
{
std::string record_button_hover_text;
if (!is_streaming)
{
record_button_hover_text = "Start streaming to enable recording";
}
else
{
record_button_hover_text = is_recording ? "Stop Recording" : "Start Recording";
}
return record_button_hover_text;
}

std::vector<std::pair<std::string, std::string>> get_devices_names(const device_list& list)
{
std::vector<std::pair<std::string, std::string>> device_names;
Expand Down
2 changes: 2 additions & 0 deletions common/device-model.h
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,8 @@ namespace rs2
viewer_model& viewer, std::string& error_message);
void begin_update_unsigned(viewer_model& viewer, std::string& error_message);
void check_for_device_updates(viewer_model& viewer, bool activated_by_user = false);
bool disable_record_button_logic(bool is_streaming, bool is_playback_device);
std::string get_record_button_hover_text(bool is_streaming);


std::shared_ptr< atomic_objects_in_frame > get_detected_objects() const { return _detected_objects; }
Expand Down

0 comments on commit 514c9e1

Please sign in to comment.