36 : _description(description),
107 auto ellapsed = duration_cast<milliseconds>(
now - last_progress_time).
count() / 1000.f;
109 auto new_progress = last_progress + ellapsed * progress_speed;
110 curr_progress_value =
std::min(threshold_progress, new_progress);
112 if (last_progress != progress)
116 int delta = progress - last_progress;
118 if (ellapsed > 0.
f) progress_speed = delta / ellapsed;
120 threshold_progress = float(
std::min(100, progress + delta));
125 auto filled_w = (curr_progress_value * (bar_width - 4)) / 100.f;
131 if (curr_progress_value > 0.
f)
133 for (
int i = 20;
i >= 0;
i -= 2)
135 auto a = curr_progress_value / 100.f;
137 { float(
pos.x + filled_w +
i), float(
pos.y + 17 +
i) },
145 { float(
pos.x + filled_w), float(
pos.y + 15) },
149 rs2::rect pbar{ float(
pos.x + 3), float(
pos.y + 3), float(bar_width), 17.f };
151 if (pbar.contains(mouse.cursor))
163 auto progress = update_manager->get_progress();
164 _progress_bar.draw(win, bar_width,
progress);
210 strlen(msg) + 1, { float(
width - (
count > 1 ? 40 : 10)), float(h) },
226 if (parts.size() > 1) title = parts[0];
234 auto lines =
static_cast<int>(
std::count(title.begin(), title.end(),
'\n') + 1);
241 if (update_state == 2)
243 auto k = duration_cast<milliseconds>(
system_clock::now() - _progress_bar.last_progress_time).
count() / 500.f;
315 std::shared_ptr<notification_model>& selected,
std::string& error_message)
317 std::function<void()>
action;
320 std::function<void()> follow_up = []{};
344 auto s =
smoothstep(static_cast<float>(elapsed / 250.
f), 0.0
f, 1.0
f);
372 for (
int i = stack - 1;
i >= 0;
i--)
374 auto ccopy =
alpha(
c, (0.9
f *
c.w) / (
i + 1));
376 ImVec4 shadow{ 0.1f, 0.1f, 0.1f, 0.1f };
432 selected = shared_from_this();
461 return add_notification(n, []{},
false);
467 std::shared_ptr<notification_model>
result =
nullptr;
471 lock_guard<recursive_mutex>
lock(
m);
474 for (
auto&& nm : pending_notifications)
484 auto m = std::make_shared<notification_model>(
n);
494 if (use_custom_action)
497 m->enable_click =
true;
498 m->enable_expand =
false;
499 m->enable_dismiss =
false;
502 pending_notifications.push_back(
m);
504 if (pending_notifications.size() > (
size_t)MAX_SIZE)
506 auto it = pending_notifications.begin();
507 while (
it != pending_notifications.end() && (*it)->pinned)
it++;
509 if (
it != pending_notifications.end())
510 pending_notifications.erase(
it);
523 lock_guard<recursive_mutex>
lock(
m);
526 model->index =
index++;
529 pending_notifications.push_back(model);
531 if (pending_notifications.size() > (
size_t)MAX_SIZE)
533 auto it = pending_notifications.begin();
534 while (
it != pending_notifications.end() && (*it)->pinned)
it++;
536 if (
it != pending_notifications.end())
537 pending_notifications.erase(
it);
541 output.add_log(model->severity, __FILE__, __LINE__, model->get_title());
546 bool modal_notification_found =
false;
549 std::vector<std::function<void()>> follow_up;
552 bool pinned_drawn =
false;
553 std::lock_guard<std::recursive_mutex>
lock(
m);
554 if (pending_notifications.size() > 0)
557 pending_notifications.erase(std::remove_if(
std::begin(pending_notifications),
559 [&](std::shared_ptr<notification_model>& n)
561 if (n->snoozed && n->pinned)
563 n->dismissed = false;
567 return ((n->get_age_in_ms() > n->get_max_lifetime_ms() &&
568 !n->pinned && !n->expanded) || n->to_close);
569 }),
end(pending_notifications));
572 for (
auto& noti : pending_notifications)
574 modal_notification_found = modal_notification_found || noti->expanded;
575 if (pinned_drawn && noti->pinned && !noti->forced)
580 follow_up.push_back(noti->draw(win, w,
height, selected, error_message));
582 if (noti->pinned) pinned_drawn =
true;
585 height += noti->height + 4 +
586 std::min(noti->count, noti->max_stack) * noti->stack_offset;
602 if (selected && selected->message !=
"")
606 ImGui::Text(
"Received the following notification:");
610 std::stringstream ss;
612 << std::fixed << selected->timestamp
613 <<
"\nSeverity: " << selected->severity
614 <<
"\nDescription: ";
616 for (
auto&& part : parts) ss << part <<
"\n";
626 selected->message =
"";
634 for (
auto line : lines)
636 if (
line.size() &&
line[0] ==
'$') clip +=
line.substr(2) +
"\n";
646 ImGui::SetTooltip(
"Paste the copied commands to a terminal and enter your password to run");
659 for (
auto&
action : follow_up)
670 return modal_notification_found;
739 std::lock_guard<std::mutex>
lock(_log_lock);
756 log(
"\nERROR: " + error);
776 throw std::runtime_error(
"Invoke operation failed!");
781 auto cleanup = [
invoke]() {
784 log(
to_string() <<
"Started " << _process_name <<
" process");
786 auto me = shared_from_this();
787 std::weak_ptr<process_manager> ptr(me);
789 std::thread
t([ptr, cleanup, invoke]() {
790 auto self = ptr.lock();
795 self->process_flow(cleanup, invoke);
802 catch (
const std::exception& ex)
804 self->fail(ex.what());
809 self->fail(
to_string() <<
"Unknown error during " << self->_process_name <<
" process!");
819 std::function<
void()> cleanup,
823 _exporter->process(_data);
836 ImVec4 shadow{ 1.f, 1.f, 1.f, 0.1f };
873 const auto bar_width =
width - 115;
947 message =
"Frame Metadata is a device feature allowing\n" 948 "software synchronization between different\n" 950 "It must be explicitly enabled on Windows OS\n";
965 ImVec4 shadow{ 1.f, 1.f, 1.f, 0.1f };
984 const auto bar_width =
width - 115;
985 if (
ImGui::Button(button_name.c_str(), { float(bar_width), 20.f }))
994 ImGui::SetTooltip(
"%s",
"Enables metadata on connected devices (you may be prompted for administrator privileges)");
1006 return rawtime < next_time;
1019 :
notification_model(), _current_version(current_version), _recommended_version(recommended_version), _recommended_version_link(recommended_version_link)
1043 ImVec4 shadow{ 1.f, 1.f, 1.f, 0.1f };
1045 { float(x +
width), float(y + 25) },
1057 ImGui::Text(
"We strongly recommend you upgrade \nyour software\n");
1069 const auto bar_width =
width - 115;
1073 if (
ImGui::Button(button_name.c_str(), { float(bar_width), 20.f }))
1075 bool should_dismiss =
true;
1080 catch (
const exception&
e)
1082 error_message = e.what();
1083 should_dismiss =
false;
1085 if (should_dismiss)
dismiss(
false);
float smoothstep(float x, float min, float max)
int calc_height() override
static const textual_icon lock
IMGUI_API void PushStyleVar(ImGuiStyleVar idx, float val)
static const ImVec4 transparent
GLenum GLuint GLenum GLsizei const GLchar * message
static const ImVec4 white
IMGUI_API float GetCursorPosX()
IMGUI_API void AddRectFilled(const ImVec2 &a, const ImVec2 &b, ImU32 col, float rounding=0.0f, int rounding_corners=0x0F)
virtual void set_color_scheme(float t) const
std::shared_ptr< notification_model > add_notification(const notification_data &n)
GLenum GLuint GLenum severity
IMGUI_API void SetTooltip(const char *fmt,...) IM_PRINTFARGS(1)
static const ImVec4 almost_white_bg
ImVec4 saturate(const ImVec4 &a, float f)
std::chrono::system_clock::time_point created_time
IMGUI_API void AddRectFilledMultiColor(const ImVec2 &a, const ImVec2 &b, ImU32 col_upr_left, ImU32 col_upr_right, ImU32 col_bot_right, ImU32 col_bot_left)
IMGUI_API bool InputTextMultiline(const char *label, char *buf, size_t buf_size, const ImVec2 &size=ImVec2(0, 0), ImGuiInputTextFlags flags=0, ImGuiTextEditCallback callback=NULL, void *user_data=NULL)
const std::string _recommended_version_link
virtual int calc_height()
static const ImVec4 light_grey
IMGUI_API void PopTextWrapPos()
static config_file & instance()
int calc_height() override
static const ImVec4 light_blue
IMGUI_API bool IsItemActive()
IMGUI_API void SetNextWindowPos(const ImVec2 &pos, ImGuiSetCond cond=0)
void log(rs2_log_severity severity, const char *message)
static const textual_icon throphy
GLdouble GLdouble GLdouble w
GLsizei const GLchar *const * string
void draw_content(ux_window &win, int x, int y, float t, std::string &error_message) override
export_notification_model(std::shared_ptr< export_manager > manager)
IMGUI_API void PushTextWrapPos(float wrap_pos_x=0.0f)
bool dequeue(T *item, unsigned int timeout_ms)
void start(invoker invoke)
GLfloat GLfloat GLfloat GLfloat h
std::vector< std::string > split_string(std::string &input, char delim)
sw_recommended_update_alert_model(const std::string ¤t_version, const std::string &recommended_version, const std::string &recommended_version_link)
double get_timestamp() const
virtual void draw_pre_effect(int x, int y)
std::chrono::system_clock::time_point last_moved
void draw_pre_effect(int x, int y) override
GLboolean GLboolean GLboolean GLboolean a
rs2_notification_category get_category() const
ImFont * get_font() const
T get_or_default(const char *key, T def) const
std::function< void(std::function< void()>)> invoker
IMGUI_API bool BeginPopup(const char *str_id)
IMGUI_API void SameLine(float pos_x=0.0f, float spacing_w=-1.0f)
std::string error_to_string(const error &e)
IMGUI_API ImDrawList * GetWindowDrawList()
IMGUI_API void PopStyleVar(int count=1)
void draw_progress_bar(ux_window &win, int w)
static const ImVec4 regular_blue
const std::string _recommended_version
void invoke(std::function< void()> action)
bool enable_complex_dismiss
std::function< void()> custom_action
virtual void draw_expanded(ux_window &win, std::string &error_message)
static const textual_icon link
void open_url(const char *url)
rs2_log_severity _severity
std::string get_description() const
void draw_content(ux_window &win, int x, int y, float t, std::string &error_message) override
void draw(ux_window &win, int w, int progress)
virtual void dismiss(bool snooze)
GLint GLsizei GLsizei height
IMGUI_API void SetNextWindowSize(const ImVec2 &size, ImGuiSetCond cond=0)
void set_color_scheme(float t) const override
static const ImVec4 sensor_bg
std::chrono::system_clock::time_point last_progress_time
void set_color_scheme(float t) const override
IMGUI_API void SetCursorPosX(float x)
static const ImVec4 sensor_header_light_blue
IMGUI_API void Text(const char *fmt,...) IM_PRINTFARGS(1)
virtual int get_max_lifetime_ms() const
IMGUI_API bool Button(const char *label, const ImVec2 &size=ImVec2(0, 0))
progress_bar _progress_bar
void log(std::string line)
rs2_notification_category category
void unset_color_scheme() const
IMGUI_API void EndPopup()
static const ImVec4 dark_red
ImVec4 alpha(const ImVec4 &v, float a)
static const textual_icon dotdotdot
IMGUI_API void PushStyleColor(ImGuiCol idx, const ImVec4 &col)
static const ImVec4 black
version_upgrade_model(int version)
bool try_dequeue(T *item)
bool draw(ux_window &win, int w, int h, std::string &error_message)
virtual void draw_content(ux_window &win, int x, int y, float t, std::string &error_message)
rs2_log_severity get_severity() const
IMGUI_API void PushFont(ImFont *font)
std::chrono::system_clock::time_point last_interacted
void draw_text(const char *msg, int x, int y, int h)
void process_flow(std::function< void()> cleanup, invoker invoke) override
ImVec4 Colors[ImGuiCol_COUNT]
void draw_content(ux_window &win, int x, int y, float t, std::string &error_message) override
IMGUI_API ImVec2 GetCursorScreenPos()
std::string get_file_name(const std::string &path)
GLdouble GLdouble GLdouble q
void set(const char *key, const char *value)
rs2_notification_category
Category of the librealsense notification.
IMGUI_API float GetTextLineHeight()
single_consumer_queue< std::function< void()> > dispatch_queue
#define RS2_API_VERSION_STR
IMGUI_API bool BeginPopupModal(const char *name, bool *p_open=NULL, ImGuiWindowFlags extra_flags=0)
IMGUI_API bool Selectable(const char *label, bool selected=false, ImGuiSelectableFlags flags=0, const ImVec2 &size=ImVec2(0, 0))
void set_color_scheme(float t) const override
IMGUI_API void SetCursorScreenPos(const ImVec2 &pos)
IMGUI_API ImGuiStyle & GetStyle()
IMGUI_API void CloseCurrentPopup()
ImFont * get_large_font() const
IMGUI_API void OpenPopup(const char *str_id)
virtual void draw_dismiss(ux_window &win, int x, int y)
std::shared_ptr< process_manager > update_manager
IMGUI_API void AddRect(const ImVec2 &a, const ImVec2 &b, ImU32 col, float rounding=0.0f, int rounding_corners=0x0F, float thickness=1.0f)
void fail(std::string error)
rs2_log_severity
Severity of the librealsense logger.
const std::string _current_version
std::function< void()> draw(ux_window &win, int w, int y, std::shared_ptr< notification_model > &selected, std::string &error_message)
IMGUI_API bool IsItemHovered()
IMGUI_API void PopStyleColor(int count=1)
rs2::mouse_info & get_mouse()
rs2_notification_category _category
std::string to_string(T value)
double get_age_in_ms(bool total=false) const