mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-07-13 03:11:47 +08:00
preventing hidden notification to show when updated and close them correctly.
This commit is contained in:
parent
5f6253390f
commit
972dbe238f
@ -1752,6 +1752,7 @@ void GLCanvas3D::render()
|
|||||||
m_tooltip.render(m_mouse.position, *this);
|
m_tooltip.render(m_mouse.position, *this);
|
||||||
|
|
||||||
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_overlay_window_width());
|
wxGetApp().plater()->get_notification_manager()->render_notifications(*this, get_overlay_window_width());
|
||||||
|
|
||||||
wxGetApp().imgui()->render();
|
wxGetApp().imgui()->render();
|
||||||
|
@ -1,12 +1,9 @@
|
|||||||
#include "NotificationManager.hpp"
|
#include "NotificationManager.hpp"
|
||||||
|
|
||||||
#include "GUI_App.hpp"
|
|
||||||
#include "GUI.hpp"
|
#include "GUI.hpp"
|
||||||
#include "Plater.hpp"
|
|
||||||
#include "GLCanvas3D.hpp"
|
|
||||||
#include "ImGuiWrapper.hpp"
|
#include "ImGuiWrapper.hpp"
|
||||||
#include "PrintHostDialogs.hpp"
|
#include "PrintHostDialogs.hpp"
|
||||||
|
|
||||||
#include "wxExtensions.hpp"
|
#include "wxExtensions.hpp"
|
||||||
|
|
||||||
#include <boost/algorithm/string.hpp>
|
#include <boost/algorithm/string.hpp>
|
||||||
@ -147,6 +144,12 @@ void NotificationManager::PopNotification::render(GLCanvas3D& canvas, float init
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (m_state == EState::ClosePending || m_state == EState::Finished)
|
||||||
|
{
|
||||||
|
m_state = EState::Finished;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Size cnv_size = canvas.get_canvas_size();
|
Size cnv_size = canvas.get_canvas_size();
|
||||||
ImGuiWrapper& imgui = *wxGetApp().imgui();
|
ImGuiWrapper& imgui = *wxGetApp().imgui();
|
||||||
ImVec2 mouse_pos = ImGui::GetMousePos();
|
ImVec2 mouse_pos = ImGui::GetMousePos();
|
||||||
@ -240,7 +243,11 @@ void NotificationManager::PopNotification::count_spaces()
|
|||||||
|
|
||||||
void NotificationManager::PopNotification::init()
|
void NotificationManager::PopNotification::init()
|
||||||
{
|
{
|
||||||
std::string text = m_text1 + " " + m_hypertext;
|
// Do not init closing notification
|
||||||
|
if (is_finished())
|
||||||
|
return;
|
||||||
|
|
||||||
|
std::string text = m_text1 + " " + m_hypertext;
|
||||||
size_t last_end = 0;
|
size_t last_end = 0;
|
||||||
m_lines_count = 0;
|
m_lines_count = 0;
|
||||||
|
|
||||||
@ -291,7 +298,9 @@ void NotificationManager::PopNotification::init()
|
|||||||
}
|
}
|
||||||
if (m_lines_count == 3)
|
if (m_lines_count == 3)
|
||||||
m_multiline = true;
|
m_multiline = true;
|
||||||
m_state = EState::Shown;
|
m_notification_start = GLCanvas3D::timestamp_now();
|
||||||
|
//if (m_state != EState::Hidden)
|
||||||
|
// m_state = EState::Shown;
|
||||||
}
|
}
|
||||||
void NotificationManager::PopNotification::set_next_window_size(ImGuiWrapper& imgui)
|
void NotificationManager::PopNotification::set_next_window_size(ImGuiWrapper& imgui)
|
||||||
{
|
{
|
||||||
@ -653,6 +662,7 @@ void NotificationManager::SlicingCompleteLargeNotification::set_large(bool l)
|
|||||||
// m_counting_down = !l;
|
// m_counting_down = !l;
|
||||||
m_hypertext = l ? _u8L("Export G-Code.") : std::string();
|
m_hypertext = l ? _u8L("Export G-Code.") : std::string();
|
||||||
m_state = l ? EState::Shown : EState::Hidden;
|
m_state = l ? EState::Shown : EState::Hidden;
|
||||||
|
init();
|
||||||
}
|
}
|
||||||
//---------------ExportFinishedNotification-----------
|
//---------------ExportFinishedNotification-----------
|
||||||
void NotificationManager::ExportFinishedNotification::count_spaces()
|
void NotificationManager::ExportFinishedNotification::count_spaces()
|
||||||
@ -1270,9 +1280,10 @@ bool NotificationManager::activate_existing(const NotificationManager::PopNotifi
|
|||||||
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() == new_type && !(*it)->is_finished()) {
|
if ((*it)->get_type() == new_type && !(*it)->is_finished()) {
|
||||||
if (std::find(m_multiple_types.begin(), m_multiple_types.end(), new_type) != m_multiple_types.end()) {
|
if (std::find(m_multiple_types.begin(), m_multiple_types.end(), new_type) != m_multiple_types.end()) {
|
||||||
//if (new_type == NotificationType::CustomNotification || new_type == NotificationType::PlaterWarning || new_type == NotificationType::ProgressBar) {
|
// If found same type and same text, return true - update will be performed on the old notif
|
||||||
if (!(*it)->compare_text(new_text))
|
if ((*it)->compare_text(new_text) == false) {
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
} else if (new_type == NotificationType::SlicingWarning) {
|
} else if (new_type == NotificationType::SlicingWarning) {
|
||||||
auto w1 = dynamic_cast<const SlicingWarningNotification*>(notification);
|
auto w1 = dynamic_cast<const SlicingWarningNotification*>(notification);
|
||||||
auto w2 = dynamic_cast<const SlicingWarningNotification*>(it->get());
|
auto w2 = dynamic_cast<const SlicingWarningNotification*>(it->get());
|
||||||
@ -1284,7 +1295,6 @@ bool NotificationManager::activate_existing(const NotificationManager::PopNotifi
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (it != m_pop_notifications.end() - 1)
|
if (it != m_pop_notifications.end() - 1)
|
||||||
std::rotate(it, it + 1, m_pop_notifications.end());
|
std::rotate(it, it + 1, m_pop_notifications.end());
|
||||||
return true;
|
return true;
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
#ifndef slic3r_GUI_NotificationManager_hpp_
|
#ifndef slic3r_GUI_NotificationManager_hpp_
|
||||||
#define slic3r_GUI_NotificationManager_hpp_
|
#define slic3r_GUI_NotificationManager_hpp_
|
||||||
|
|
||||||
|
#include "GUI_App.hpp"
|
||||||
|
#include "Plater.hpp"
|
||||||
|
#include "GLCanvas3D.hpp"
|
||||||
#include "Event.hpp"
|
#include "Event.hpp"
|
||||||
#include "I18N.hpp"
|
#include "I18N.hpp"
|
||||||
|
|
||||||
@ -211,9 +214,9 @@ 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); }
|
||||||
void render(GLCanvas3D& canvas, float initial_y, bool move_from_overlay, float overlay_width);
|
virtual void render(GLCanvas3D& canvas, float initial_y, bool move_from_overlay, float overlay_width);
|
||||||
// close will dissapear notification on next render
|
// close will dissapear notification on next render
|
||||||
virtual void close() { m_state = EState::ClosePending; }
|
virtual void close() { m_state = EState::ClosePending; wxGetApp().plater()->get_current_canvas3D()->schedule_extra_frame(0);}
|
||||||
// data from newer notification of same type
|
// data from newer notification of same type
|
||||||
void update(const NotificationData& n);
|
void update(const NotificationData& n);
|
||||||
bool is_finished() const { return m_state == EState::ClosePending || m_state == EState::Finished; }
|
bool is_finished() const { return m_state == EState::ClosePending || m_state == EState::Finished; }
|
||||||
@ -226,7 +229,7 @@ private:
|
|||||||
const bool is_gray() const { return m_is_gray; }
|
const bool is_gray() const { return m_is_gray; }
|
||||||
void set_gray(bool g) { m_is_gray = g; }
|
void set_gray(bool g) { m_is_gray = g; }
|
||||||
bool compare_text(const std::string& text);
|
bool compare_text(const std::string& text);
|
||||||
void hide(bool h) { m_state = h ? EState::Hidden : EState::Unknown; }
|
void hide(bool h) { if (is_finished()) return; m_state = h ? EState::Hidden : EState::Unknown; }
|
||||||
// sets m_next_render with time of next mandatory rendering. Delta is time since last render.
|
// sets m_next_render with time of next mandatory rendering. Delta is time since last render.
|
||||||
bool update_state(bool paused, const int64_t delta);
|
bool update_state(bool paused, const int64_t delta);
|
||||||
int64_t next_render() const { return is_finished() ? 0 : m_next_render; }
|
int64_t next_render() const { return is_finished() ? 0 : m_next_render; }
|
||||||
@ -313,10 +316,16 @@ private:
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SlicingCompleteLargeNotification(const NotificationData& n, NotificationIDProvider& id_provider, wxEvtHandler* evt_handler, bool largeds);
|
SlicingCompleteLargeNotification(const NotificationData& n, NotificationIDProvider& id_provider, wxEvtHandler* evt_handler, bool largeds);
|
||||||
void set_large(bool l);
|
void set_large(bool l);
|
||||||
bool get_large() { return m_is_large; }
|
bool get_large() { return m_is_large; }
|
||||||
|
void set_print_info(const std::string &info);
|
||||||
void set_print_info(const std::string &info);
|
virtual void render(GLCanvas3D& canvas, float initial_y, bool move_from_overlay, float overlay_width)
|
||||||
|
{
|
||||||
|
// This notification is always hidden if !large (means side bar is collapsed)
|
||||||
|
if (!get_large() && !is_finished())
|
||||||
|
m_state == EState::Hidden;
|
||||||
|
PopNotification::render(canvas, initial_y, move_from_overlay, overlay_width);
|
||||||
|
}
|
||||||
protected:
|
protected:
|
||||||
virtual void render_text(ImGuiWrapper& imgui,
|
virtual void render_text(ImGuiWrapper& imgui,
|
||||||
const float win_size_x, const float win_size_y,
|
const float win_size_x, const float win_size_y,
|
||||||
@ -339,8 +348,8 @@ private:
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
PlaterWarningNotification(const NotificationData& n, NotificationIDProvider& id_provider, wxEvtHandler* evt_handler) : PopNotification(n, id_provider, evt_handler) {}
|
PlaterWarningNotification(const NotificationData& n, NotificationIDProvider& id_provider, wxEvtHandler* evt_handler) : PopNotification(n, id_provider, evt_handler) {}
|
||||||
virtual void close() { m_state = EState::Hidden; }
|
virtual void close() { if(is_finished()) return; m_state = EState::Hidden; wxGetApp().plater()->get_current_canvas3D()->schedule_extra_frame(0); }
|
||||||
void real_close() { m_state = EState::ClosePending; }
|
void real_close() { m_state = EState::ClosePending; wxGetApp().plater()->get_current_canvas3D()->schedule_extra_frame(0); }
|
||||||
void show() { m_state = EState::Unknown; }
|
void show() { m_state = EState::Unknown; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user