Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor the logic and hover text for disabling the record button #12513

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading