NotificationManager: Removed space reservation for "Slope visualization"
dialog, which is gone.
This commit is contained in:
parent
447f4b8303
commit
607c237749
4 changed files with 35 additions and 45 deletions
|
@ -2088,7 +2088,7 @@ void GLCanvas3D::render()
|
||||||
|
|
||||||
wxGetApp().plater()->get_mouse3d_controller().render_settings_dialog(*this);
|
wxGetApp().plater()->get_mouse3d_controller().render_settings_dialog(*this);
|
||||||
|
|
||||||
wxGetApp().plater()->get_notification_manager()->render_notifications(*this, get_overelay_window_width(), get_slope_window_width());
|
wxGetApp().plater()->get_notification_manager()->render_notifications(*this, get_overlay_window_width());
|
||||||
|
|
||||||
wxGetApp().imgui()->render();
|
wxGetApp().imgui()->render();
|
||||||
|
|
||||||
|
|
|
@ -243,7 +243,7 @@ private:
|
||||||
static bool bar_rect_contains(const GLCanvas3D& canvas, float x, float y);
|
static bool bar_rect_contains(const GLCanvas3D& canvas, float x, float y);
|
||||||
static Rect get_bar_rect_screen(const GLCanvas3D& canvas);
|
static Rect get_bar_rect_screen(const GLCanvas3D& canvas);
|
||||||
static Rect get_bar_rect_viewport(const GLCanvas3D& canvas);
|
static Rect get_bar_rect_viewport(const GLCanvas3D& canvas);
|
||||||
static float get_overelay_window_width() { return LayersEditing::s_overelay_window_width; }
|
static float get_overlay_window_width() { return LayersEditing::s_overelay_window_width; }
|
||||||
|
|
||||||
float object_max_z() const { return m_object_max_z; }
|
float object_max_z() const { return m_object_max_z; }
|
||||||
|
|
||||||
|
@ -885,8 +885,7 @@ private:
|
||||||
bool _activate_search_toolbar_item();
|
bool _activate_search_toolbar_item();
|
||||||
bool _deactivate_collapse_toolbar_items();
|
bool _deactivate_collapse_toolbar_items();
|
||||||
|
|
||||||
float get_overelay_window_width() { return LayersEditing::get_overelay_window_width(); }
|
float get_overlay_window_width() { return LayersEditing::get_overlay_window_width(); }
|
||||||
float get_slope_window_width() { return Slope::get_window_width(); }
|
|
||||||
|
|
||||||
static std::vector<float> _parse_colors(const std::vector<std::string>& colors);
|
static std::vector<float> _parse_colors(const std::vector<std::string>& colors);
|
||||||
|
|
||||||
|
|
|
@ -12,13 +12,8 @@
|
||||||
#include <wx/glcanvas.h>
|
#include <wx/glcanvas.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
static constexpr float GAP_WIDTH = 10.0f;
|
||||||
|
static constexpr float SPACE_RIGHT_PANEL = 10.0f;
|
||||||
|
|
||||||
#define NOTIFICATION_MAX_MOVE 3.0f
|
|
||||||
|
|
||||||
#define GAP_WIDTH 10.0f
|
|
||||||
#define SPACE_RIGHT_PANEL 10.0f
|
|
||||||
|
|
||||||
namespace Slic3r {
|
namespace Slic3r {
|
||||||
namespace GUI {
|
namespace GUI {
|
||||||
|
@ -28,7 +23,7 @@ wxDEFINE_EVENT(EVT_EXPORT_GCODE_NOTIFICAION_CLICKED, ExportGcodeNotificationClic
|
||||||
wxDEFINE_EVENT(EVT_PRESET_UPDATE_AVAILABLE_CLICKED, PresetUpdateAvailableClickedEvent);
|
wxDEFINE_EVENT(EVT_PRESET_UPDATE_AVAILABLE_CLICKED, PresetUpdateAvailableClickedEvent);
|
||||||
|
|
||||||
namespace Notifications_Internal{
|
namespace Notifications_Internal{
|
||||||
void push_style_color(ImGuiCol idx, const ImVec4& col, bool fading_out, float current_fade_opacity)
|
static inline void push_style_color(ImGuiCol idx, const ImVec4& col, bool fading_out, float current_fade_opacity)
|
||||||
{
|
{
|
||||||
if (fading_out)
|
if (fading_out)
|
||||||
ImGui::PushStyleColor(idx, ImVec4(col.x, col.y, col.z, col.w * current_fade_opacity));
|
ImGui::PushStyleColor(idx, ImVec4(col.x, col.y, col.z, col.w * current_fade_opacity));
|
||||||
|
@ -74,7 +69,7 @@ NotificationManager::PopNotification::PopNotification(const NotificationData &n,
|
||||||
{
|
{
|
||||||
//init();
|
//init();
|
||||||
}
|
}
|
||||||
NotificationManager::PopNotification::RenderResult NotificationManager::PopNotification::render(GLCanvas3D& canvas, const float& initial_y, bool move_from_overlay, float overlay_width, bool move_from_slope, float slope_width)
|
NotificationManager::PopNotification::RenderResult NotificationManager::PopNotification::render(GLCanvas3D& canvas, const float& initial_y, bool move_from_overlay, float overlay_width)
|
||||||
{
|
{
|
||||||
if (!m_initialized) {
|
if (!m_initialized) {
|
||||||
init();
|
init();
|
||||||
|
@ -95,7 +90,7 @@ NotificationManager::PopNotification::RenderResult NotificationManager::PopNotif
|
||||||
ImGuiWrapper& imgui = *wxGetApp().imgui();
|
ImGuiWrapper& imgui = *wxGetApp().imgui();
|
||||||
bool shown = true;
|
bool shown = true;
|
||||||
ImVec2 mouse_pos = ImGui::GetMousePos();
|
ImVec2 mouse_pos = ImGui::GetMousePos();
|
||||||
float right_gap = SPACE_RIGHT_PANEL + (move_from_overlay ? overlay_width + m_line_height * 5 : (move_from_slope ? slope_width /*+ m_line_height * 0.3f*/ : 0));
|
float right_gap = SPACE_RIGHT_PANEL + (move_from_overlay ? overlay_width + m_line_height * 5 : 0);
|
||||||
|
|
||||||
if (m_line_height != ImGui::CalcTextSize("A").y)
|
if (m_line_height != ImGui::CalcTextSize("A").y)
|
||||||
init();
|
init();
|
||||||
|
@ -263,12 +258,9 @@ void NotificationManager::PopNotification::init()
|
||||||
}
|
}
|
||||||
void NotificationManager::PopNotification::set_next_window_size(ImGuiWrapper& imgui)
|
void NotificationManager::PopNotification::set_next_window_size(ImGuiWrapper& imgui)
|
||||||
{
|
{
|
||||||
if (m_multiline) {
|
m_window_height = m_multiline ?
|
||||||
m_window_height = m_lines_count * m_line_height;
|
m_lines_count * m_line_height :
|
||||||
}else
|
2 * m_line_height;
|
||||||
{
|
|
||||||
m_window_height = 2 * m_line_height;
|
|
||||||
}
|
|
||||||
m_window_height += 1 * m_line_height; // top and bottom
|
m_window_height += 1 * m_line_height; // top and bottom
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -622,14 +614,13 @@ void NotificationManager::SlicingCompleteLargeNotification::render_text(ImGuiWra
|
||||||
imgui.text(m_text1.c_str());
|
imgui.text(m_text1.c_str());
|
||||||
|
|
||||||
render_hypertext(imgui, x_offset + text1_size.x + 4, cursor_y, m_hypertext);
|
render_hypertext(imgui, x_offset + text1_size.x + 4, cursor_y, m_hypertext);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void NotificationManager::SlicingCompleteLargeNotification::set_print_info(const std::string &info)
|
void NotificationManager::SlicingCompleteLargeNotification::set_print_info(const std::string &info)
|
||||||
{
|
{
|
||||||
m_print_info = info;
|
m_print_info = info;
|
||||||
m_has_print_info = true;
|
m_has_print_info = true;
|
||||||
if(m_is_large)
|
if (m_is_large)
|
||||||
m_lines_count = 2;
|
m_lines_count = 2;
|
||||||
}
|
}
|
||||||
void NotificationManager::SlicingCompleteLargeNotification::set_large(bool l)
|
void NotificationManager::SlicingCompleteLargeNotification::set_large(bool l)
|
||||||
|
@ -813,17 +804,17 @@ bool NotificationManager::push_notification_data(std::unique_ptr<NotificationMan
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!this->find_older(notification.get())) {
|
if (this->activate_existing(notification.get())) {
|
||||||
m_pop_notifications.emplace_back(std::move(notification));
|
|
||||||
canvas.request_extra_frame();
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
m_pop_notifications.back()->update(notification->get_data());
|
m_pop_notifications.back()->update(notification->get_data());
|
||||||
canvas.request_extra_frame();
|
canvas.request_extra_frame();
|
||||||
return false;
|
return false;
|
||||||
|
} else {
|
||||||
|
m_pop_notifications.emplace_back(std::move(notification));
|
||||||
|
canvas.request_extra_frame();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void NotificationManager::render_notifications(GLCanvas3D& canvas, float overlay_width, float slope_width)
|
void NotificationManager::render_notifications(GLCanvas3D& canvas, float overlay_width)
|
||||||
{
|
{
|
||||||
float last_x = 0.0f;
|
float last_x = 0.0f;
|
||||||
float current_height = 0.0f;
|
float current_height = 0.0f;
|
||||||
|
@ -837,7 +828,7 @@ void NotificationManager::render_notifications(GLCanvas3D& canvas, float overlay
|
||||||
it = m_pop_notifications.erase(it);
|
it = m_pop_notifications.erase(it);
|
||||||
} else {
|
} else {
|
||||||
(*it)->set_paused(m_hovered);
|
(*it)->set_paused(m_hovered);
|
||||||
PopNotification::RenderResult res = (*it)->render(canvas, last_x, m_move_from_overlay, overlay_width, m_move_from_slope, slope_width);
|
PopNotification::RenderResult res = (*it)->render(canvas, last_x, m_move_from_overlay, overlay_width);
|
||||||
if (res != PopNotification::RenderResult::Finished) {
|
if (res != PopNotification::RenderResult::Finished) {
|
||||||
last_x = (*it)->get_top() + GAP_WIDTH;
|
last_x = (*it)->get_top() + GAP_WIDTH;
|
||||||
current_height = std::max(current_height, (*it)->get_current_top());
|
current_height = std::max(current_height, (*it)->get_current_top());
|
||||||
|
@ -889,20 +880,20 @@ void NotificationManager::sort_notifications()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NotificationManager::find_older(NotificationManager::PopNotification* notification)
|
bool NotificationManager::activate_existing(const NotificationManager::PopNotification* notification)
|
||||||
{
|
{
|
||||||
NotificationType type = notification->get_type();
|
NotificationType new_type = notification->get_type();
|
||||||
std::string text = notification->get_data().text1;
|
const std::string &new_text = notification->get_data().text1;
|
||||||
for (auto it = m_pop_notifications.begin(); it != m_pop_notifications.end(); ++it) {
|
for (auto it = m_pop_notifications.begin(); it != m_pop_notifications.end(); ++it) {
|
||||||
if((*it)->get_type() == type && !(*it)->get_finished()) {
|
if ((*it)->get_type() == new_type && !(*it)->get_finished()) {
|
||||||
if (type == NotificationType::CustomNotification || type == NotificationType::PlaterWarning) {
|
if (new_type == NotificationType::CustomNotification || new_type == NotificationType::PlaterWarning) {
|
||||||
if (!(*it)->compare_text(text))
|
if (!(*it)->compare_text(new_text))
|
||||||
continue;
|
continue;
|
||||||
}else if (type == NotificationType::SlicingWarning) {
|
} else if (new_type == NotificationType::SlicingWarning) {
|
||||||
auto w1 = dynamic_cast<SlicingWarningNotification*>(notification);
|
auto w1 = dynamic_cast<const SlicingWarningNotification*>(notification);
|
||||||
auto w2 = dynamic_cast<SlicingWarningNotification*>(it->get());
|
auto w2 = dynamic_cast<const SlicingWarningNotification*>(it->get());
|
||||||
if (w1 != nullptr && w2 != nullptr) {
|
if (w1 != nullptr && w2 != nullptr) {
|
||||||
if (!(*it)->compare_text(text) || w1->object_id != w2->object_id) {
|
if (!(*it)->compare_text(new_text) || w1->object_id != w2->object_id) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -918,7 +909,7 @@ bool NotificationManager::find_older(NotificationManager::PopNotification* notif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NotificationManager::set_in_preview(bool preview)
|
void NotificationManager::set_in_preview(bool preview)
|
||||||
{
|
{
|
||||||
m_in_preview = preview;
|
m_in_preview = preview;
|
||||||
for (std::unique_ptr<PopNotification> ¬ification : m_pop_notifications) {
|
for (std::unique_ptr<PopNotification> ¬ification : m_pop_notifications) {
|
||||||
|
@ -926,6 +917,7 @@ void NotificationManager::set_in_preview(bool preview)
|
||||||
notification->hide(preview);
|
notification->hide(preview);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool NotificationManager::has_slicing_error_notification()
|
bool NotificationManager::has_slicing_error_notification()
|
||||||
{
|
{
|
||||||
return std::any_of(m_pop_notifications.begin(), m_pop_notifications.end(), [](auto &n) {
|
return std::any_of(m_pop_notifications.begin(), m_pop_notifications.end(), [](auto &n) {
|
||||||
|
|
|
@ -107,7 +107,7 @@ public:
|
||||||
// the "slicing info" normally shown at the side bar.
|
// the "slicing info" normally shown at the side bar.
|
||||||
void set_slicing_complete_large(bool large);
|
void set_slicing_complete_large(bool large);
|
||||||
// renders notifications in queue and deletes expired ones
|
// renders notifications in queue and deletes expired ones
|
||||||
void render_notifications(GLCanvas3D& canvas, float overlay_width, float slope_width);
|
void render_notifications(GLCanvas3D& canvas, float overlay_width);
|
||||||
// finds and closes all notifications of given type
|
// finds and closes all notifications of given type
|
||||||
void close_notification_of_type(const NotificationType type);
|
void close_notification_of_type(const NotificationType type);
|
||||||
// Which view is active? Plater or G-code preview? Hide warnings in G-code preview.
|
// Which view is active? Plater or G-code preview? Hide warnings in G-code preview.
|
||||||
|
@ -154,7 +154,7 @@ private:
|
||||||
};
|
};
|
||||||
PopNotification(const NotificationData &n, NotificationIDProvider &id_provider, wxEvtHandler* evt_handler);
|
PopNotification(const NotificationData &n, NotificationIDProvider &id_provider, wxEvtHandler* evt_handler);
|
||||||
virtual ~PopNotification() { if (m_id) m_id_provider.release_id(m_id); }
|
virtual ~PopNotification() { if (m_id) m_id_provider.release_id(m_id); }
|
||||||
RenderResult render(GLCanvas3D& canvas, const float& initial_y, bool move_from_overlay, float overlay_width, bool move_from_slope, float slope_width);
|
RenderResult render(GLCanvas3D& canvas, const float& initial_y, bool move_from_overlay, float overlay_width);
|
||||||
// close will dissapear notification on next render
|
// close will dissapear notification on next render
|
||||||
void close() { m_close_pending = true; }
|
void close() { m_close_pending = true; }
|
||||||
// data from newer notification of same type
|
// data from newer notification of same type
|
||||||
|
@ -279,7 +279,7 @@ private:
|
||||||
bool push_notification_data(const NotificationData& notification_data, GLCanvas3D& canvas, int timestamp);
|
bool push_notification_data(const NotificationData& notification_data, GLCanvas3D& canvas, int timestamp);
|
||||||
bool push_notification_data(std::unique_ptr<NotificationManager::PopNotification> notification, GLCanvas3D& canvas, int timestamp);
|
bool push_notification_data(std::unique_ptr<NotificationManager::PopNotification> notification, GLCanvas3D& canvas, int timestamp);
|
||||||
//finds older notification of same type and moves it to the end of queue. returns true if found
|
//finds older notification of same type and moves it to the end of queue. returns true if found
|
||||||
bool find_older(NotificationManager::PopNotification* notification);
|
bool activate_existing(const NotificationManager::PopNotification* notification);
|
||||||
// Put the more important notifications to the bottom of the list.
|
// Put the more important notifications to the bottom of the list.
|
||||||
void sort_notifications();
|
void sort_notifications();
|
||||||
// If there is some error notification active, then the "Export G-code" notification after the slicing is finished is suppressed.
|
// If there is some error notification active, then the "Export G-code" notification after the slicing is finished is suppressed.
|
||||||
|
@ -292,11 +292,10 @@ private:
|
||||||
std::deque<std::unique_ptr<PopNotification>> m_pop_notifications;
|
std::deque<std::unique_ptr<PopNotification>> m_pop_notifications;
|
||||||
long m_last_time { 0 };
|
long m_last_time { 0 };
|
||||||
bool m_hovered { false };
|
bool m_hovered { false };
|
||||||
//timestamps used for slining finished - notification could be gone so it needs to be stored here
|
//timestamps used for slicing finished - notification could be gone so it needs to be stored here
|
||||||
std::unordered_set<int> m_used_timestamps;
|
std::unordered_set<int> m_used_timestamps;
|
||||||
bool m_in_preview { false };
|
bool m_in_preview { false };
|
||||||
bool m_move_from_overlay { false };
|
bool m_move_from_overlay { false };
|
||||||
bool m_move_from_slope { false };
|
|
||||||
|
|
||||||
//prepared (basic) notifications
|
//prepared (basic) notifications
|
||||||
const std::vector<NotificationData> basic_notifications = {
|
const std::vector<NotificationData> basic_notifications = {
|
||||||
|
|
Loading…
Reference in a new issue