mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-26 16:13:58 -06:00
Update item info notification with icon
This commit is contained in:
parent
654cd753e2
commit
aa17d54eda
8 changed files with 93 additions and 147 deletions
|
@ -139,12 +139,19 @@ namespace ImGui
|
|||
const char EjectHoverButton = 0x13;
|
||||
const char CancelButton = 0x14;
|
||||
const char CancelHoverButton = 0x15;
|
||||
const char LeftArrowButton = 0x16;
|
||||
const char LeftArrowHoverButton = 0x17;
|
||||
const char VarLayerHeightMarker = 0x16;
|
||||
|
||||
const char RightArrowButton = 0x18;
|
||||
const char RightArrowHoverButton = 0x19;
|
||||
const char PreferencesButton = 0x1A;
|
||||
const char PreferencesHoverButton = 0x1B;
|
||||
const char SinkingObjectMarker = 0x1C;
|
||||
const char CustomSupportsMarker = 0x1D;
|
||||
const char CustomSeamMarker = 0x1E;
|
||||
const char MmuSegmentationMarker = 0x1F;
|
||||
|
||||
|
||||
|
||||
// void MyFunction(const char* name, const MyMatrix44& v);
|
||||
}
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include "GLCanvas3D.hpp"
|
||||
#include "Selection.hpp"
|
||||
#include "format.hpp"
|
||||
#include "NotificationManager.hpp"
|
||||
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <wx/progdlg.h>
|
||||
|
@ -2568,6 +2569,8 @@ void ObjectList::update_info_items(size_t obj_idx)
|
|||
if (! shows && should_show) {
|
||||
m_objects_model->AddInfoChild(item_obj, type);
|
||||
Expand(item_obj);
|
||||
wxGetApp().notification_manager()->push_updated_item_info_notification(type);
|
||||
|
||||
}
|
||||
else if (shows && ! should_show) {
|
||||
Unselect(item);
|
||||
|
|
|
@ -218,7 +218,7 @@ void NotificationManager::HintNotification::count_spaces()
|
|||
|
||||
|
||||
std::string text;
|
||||
text = ImGui::LeftArrowButton; // TODO change to left arrow
|
||||
text = ImGui::WarningMarker;
|
||||
float picture_width = ImGui::CalcTextSize(text.c_str()).x;
|
||||
m_left_indentation = picture_width + m_line_height / 2;
|
||||
|
||||
|
|
|
@ -58,8 +58,12 @@ static const std::map<const char, std::string> font_icons_large = {
|
|||
{ImGui::ErrorMarker , "notification_error" },
|
||||
{ImGui::CancelButton , "notification_cancel" },
|
||||
{ImGui::CancelHoverButton , "notification_cancel_hover" },
|
||||
{ImGui::LeftArrowButton , "notification_left" },
|
||||
{ImGui::LeftArrowHoverButton , "notification_left_hover" },
|
||||
{ImGui::SinkingObjectMarker , "move" },
|
||||
{ImGui::CustomSupportsMarker , "fdm_supports" },
|
||||
{ImGui::CustomSeamMarker , "seam" },
|
||||
{ImGui::MmuSegmentationMarker , "move" },
|
||||
{ImGui::VarLayerHeightMarker , "layers" },
|
||||
|
||||
};
|
||||
|
||||
const ImVec4 ImGuiWrapper::COL_GREY_DARK = { 0.333f, 0.333f, 0.333f, 1.0f };
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include "ImGuiWrapper.hpp"
|
||||
#include "PrintHostDialogs.hpp"
|
||||
#include "wxExtensions.hpp"
|
||||
#include "ObjectDataViewModel.hpp"
|
||||
#include "libslic3r/Config.hpp"
|
||||
#include "../Utils/PrintHost.hpp"
|
||||
#include "libslic3r/Config.hpp"
|
||||
|
@ -1058,8 +1059,37 @@ void NotificationManager::PrintHostUploadNotification::render_cancel_button(ImGu
|
|||
ImGui::PopStyleColor();
|
||||
ImGui::PopStyleColor();
|
||||
ImGui::PopStyleColor();
|
||||
|
||||
}
|
||||
//------UpdatedItemsInfoNotification-------
|
||||
void NotificationManager::UpdatedItemsInfoNotification::count_spaces()
|
||||
{
|
||||
//determine line width
|
||||
m_line_height = ImGui::CalcTextSize("A").y;
|
||||
|
||||
std::string text;
|
||||
text = ImGui::WarningMarker;
|
||||
float picture_width = ImGui::CalcTextSize(text.c_str()).x;
|
||||
m_left_indentation = picture_width + m_line_height / 2;
|
||||
|
||||
m_window_width_offset = m_left_indentation + m_line_height * 3.f;
|
||||
m_window_width = m_line_height * 25;
|
||||
}
|
||||
void NotificationManager::UpdatedItemsInfoNotification::render_left_sign(ImGuiWrapper& imgui)
|
||||
{
|
||||
std::string text;
|
||||
switch (m_info_item_type) {
|
||||
case InfoItemType::CustomSupports: text = ImGui::CustomSupportsMarker; break;
|
||||
case InfoItemType::CustomSeam: text = ImGui::CustomSeamMarker; break;
|
||||
case InfoItemType::MmuSegmentation: text = ImGui::MmuSegmentationMarker; break;
|
||||
case InfoItemType::VariableLayerHeight: text = ImGui::VarLayerHeightMarker; break;
|
||||
case InfoItemType::Sinking: text = ImGui::SinkingObjectMarker; break;
|
||||
default: break;
|
||||
}
|
||||
ImGui::SetCursorPosX(m_line_height / 3);
|
||||
ImGui::SetCursorPosY(m_window_height / 2 - m_line_height);
|
||||
imgui.text(text.c_str());
|
||||
}
|
||||
|
||||
//------NotificationManager--------
|
||||
NotificationManager::NotificationManager(wxEvtHandler* evt_handler) :
|
||||
m_evt_handler(evt_handler)
|
||||
|
@ -1087,9 +1117,11 @@ void NotificationManager::push_notification(NotificationType type,
|
|||
{
|
||||
int duration = 0;
|
||||
switch (level) {
|
||||
case NotificationLevel::RegularNotification: duration = 10; break;
|
||||
case NotificationLevel::ErrorNotification: break;
|
||||
case NotificationLevel::ImportantNotification: break;
|
||||
case NotificationLevel::RegularNotification: duration = 10; break;
|
||||
case NotificationLevel::ErrorNotification: break;
|
||||
case NotificationLevel::WarningNotification: break;
|
||||
case NotificationLevel::ImportantNotification: break;
|
||||
case NotificationLevel::ProgressBarNotification: break;
|
||||
default:
|
||||
assert(false);
|
||||
return;
|
||||
|
@ -1324,6 +1356,23 @@ void NotificationManager::push_hint_notification()
|
|||
NotificationData data{ NotificationType::DidYouKnowHint, NotificationLevel::RegularNotification, 0, "" };
|
||||
push_notification_data(std::make_unique<NotificationManager::HintNotification>(data, m_id_provider, m_evt_handler), 0);
|
||||
}
|
||||
|
||||
void NotificationManager::push_updated_item_info_notification(InfoItemType type)
|
||||
{
|
||||
std::string text = _utf8("Object(s) were loaded with ");
|
||||
switch (type) {
|
||||
case InfoItemType::CustomSupports: text += _utf8("custom supports."); break;
|
||||
case InfoItemType::CustomSeam: text += _utf8("custom seam."); break;
|
||||
case InfoItemType::MmuSegmentation: text += _utf8("MMU segmentation."); break;
|
||||
case InfoItemType::VariableLayerHeight: text += _utf8("variable layer height."); break;
|
||||
case InfoItemType::Sinking: text = _utf8("Partially sinking object(s) were loaded."); break;
|
||||
default: text.clear(); break;
|
||||
}
|
||||
if (!text.empty()) {
|
||||
NotificationData data{ NotificationType::UpdatedItemsInfo, NotificationLevel::RegularNotification, 10, text };
|
||||
push_notification_data(std::make_unique<NotificationManager::UpdatedItemsInfoNotification>(data, m_id_provider, m_evt_handler, type), 0);
|
||||
}
|
||||
}
|
||||
bool NotificationManager::push_notification_data(const NotificationData& notification_data, int timestamp)
|
||||
{
|
||||
return push_notification_data(std::make_unique<PopNotification>(notification_data, m_id_provider, m_evt_handler), timestamp);
|
||||
|
|
|
@ -29,6 +29,7 @@ wxDECLARE_EVENT(EVT_PRESET_UPDATE_AVAILABLE_CLICKED, PresetUpdateAvailableClicke
|
|||
|
||||
class GLCanvas3D;
|
||||
class ImGuiWrapper;
|
||||
enum class InfoItemType;
|
||||
|
||||
enum class NotificationType
|
||||
{
|
||||
|
@ -92,7 +93,10 @@ enum class NotificationType
|
|||
// Notification that a printer has more extruders than are supported by MM Gizmo/segmentation.
|
||||
MmSegmentationExceededExtrudersLimit,
|
||||
// Did you know Notification appearing on startup with arrows to change hint
|
||||
DidYouKnowHint
|
||||
DidYouKnowHint,
|
||||
// Shows when ObjectList::update_info_items finds information that should be stressed to the user
|
||||
// Might contain logo taken from gizmos
|
||||
UpdatedItemsInfo
|
||||
};
|
||||
|
||||
class NotificationManager
|
||||
|
@ -166,6 +170,7 @@ public:
|
|||
void upload_job_notification_show_error(int id, const std::string& filename, const std::string& host);
|
||||
// Hint (did you know) notification
|
||||
void push_hint_notification();
|
||||
void push_updated_item_info_notification(InfoItemType type);
|
||||
// Close old notification ExportFinished.
|
||||
void new_export_began(bool on_removable);
|
||||
// finds ExportFinished notification and closes it if it was to removable device
|
||||
|
@ -488,6 +493,20 @@ private:
|
|||
long m_hover_time { 0 };
|
||||
};
|
||||
|
||||
class UpdatedItemsInfoNotification : public PopNotification
|
||||
{
|
||||
public:
|
||||
UpdatedItemsInfoNotification(const NotificationData& n, NotificationIDProvider& id_provider, wxEvtHandler* evt_handler, InfoItemType info_item_type)
|
||||
: PopNotification(n, id_provider, evt_handler)
|
||||
, m_info_item_type(info_item_type)
|
||||
{
|
||||
}
|
||||
void count_spaces() override;
|
||||
protected:
|
||||
void render_left_sign(ImGuiWrapper& imgui) override;
|
||||
InfoItemType m_info_item_type;
|
||||
};
|
||||
|
||||
// in HintNotification.hpp
|
||||
class HintNotification;
|
||||
|
||||
|
@ -516,7 +535,7 @@ private:
|
|||
// Timestamp of last rendering
|
||||
int64_t m_last_render { 0LL };
|
||||
// Notification types that can be shown multiple types at once (compared by text)
|
||||
const std::vector<NotificationType> m_multiple_types = { NotificationType::CustomNotification, NotificationType::PlaterWarning, NotificationType::ProgressBar, NotificationType::PrintHostUpload };
|
||||
const std::vector<NotificationType> m_multiple_types = { NotificationType::CustomNotification, NotificationType::PlaterWarning, NotificationType::ProgressBar, NotificationType::PrintHostUpload, NotificationType::UpdatedItemsInfo };
|
||||
//prepared (basic) notifications
|
||||
static const NotificationData basic_notifications[];
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue