Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Kocik <kocikdav@gmail.com>2021-07-29 14:15:17 +0300
committerDavid Kocik <kocikdav@gmail.com>2021-07-29 14:20:50 +0300
commit0d74502aeb84c4f8a9eebfea6d22b8abc71b6036 (patch)
tree314347a70ad8b453104e7b0d6bd1218f5c096621 /src/slic3r/GUI/HintNotification.hpp
parent7fd34e52c198ae3b01219d7a25d6ba7dd4580427 (diff)
Hint notification
Reads data from hints.ini. Has hyperlinks to highlight settings, toolbars and gizmos.
Diffstat (limited to 'src/slic3r/GUI/HintNotification.hpp')
-rw-r--r--src/slic3r/GUI/HintNotification.hpp97
1 files changed, 97 insertions, 0 deletions
diff --git a/src/slic3r/GUI/HintNotification.hpp b/src/slic3r/GUI/HintNotification.hpp
new file mode 100644
index 000000000..125420fb6
--- /dev/null
+++ b/src/slic3r/GUI/HintNotification.hpp
@@ -0,0 +1,97 @@
+#ifndef slic3r_GUI_HintNotification_hpp_
+#define slic3r_GUI_HintNotification_hpp_
+
+#include "NotificationManager.hpp"
+
+namespace Slic3r {
+namespace GUI {
+
+// Database of hints updatable
+struct HintData
+{
+ std::string text;
+ std::string hypertext;
+ std::string follow_text;
+ std::string disabled_modes;
+ bool runtime_disable; // if true - hyperlink will check before every click if not in disabled mode
+ std::function<void(void)> callback{ nullptr };
+};
+
+class HintDatabase
+{
+public:
+ static HintDatabase& get_instance()
+ {
+ static HintDatabase instance; // Guaranteed to be destroyed.
+ // Instantiated on first use.
+ return instance;
+ }
+private:
+ HintDatabase()
+ : m_hint_id(0)
+ {}
+public:
+ HintDatabase(HintDatabase const&) = delete;
+ void operator=(HintDatabase const&) = delete;
+
+ // return true if HintData filled;
+ HintData* get_hint(bool up = true);
+ size_t get_count() {
+ if (!m_initialized)
+ return 0;
+ return m_loaded_hints.size();
+ }
+private:
+ void init();
+ void load_hints_from_file(const boost::filesystem::path& path);
+ size_t m_hint_id;
+ bool m_initialized { false };
+ std::vector<HintData> m_loaded_hints;
+
+};
+// Notification class - shows current Hint ("Did you know")
+class NotificationManager::HintNotification : public NotificationManager::PopNotification
+{
+public:
+ HintNotification(const NotificationData& n, NotificationIDProvider& id_provider, wxEvtHandler* evt_handler)
+ : PopNotification(n, id_provider, evt_handler)
+ {
+ retrieve_data();
+ }
+ virtual void init() override;
+protected:
+ virtual void set_next_window_size(ImGuiWrapper& imgui) override;
+ virtual void count_spaces() override;
+ virtual void count_lines() override;
+ virtual bool on_text_click() override;
+ virtual void render_text(ImGuiWrapper& imgui,
+ const float win_size_x, const float win_size_y,
+ const float win_pos_x, const float win_pos_y) override;
+ virtual void render_close_button(ImGuiWrapper& imgui,
+ const float win_size_x, const float win_size_y,
+ const float win_pos_x, const float win_pos_y) override;
+ virtual void render_minimize_button(ImGuiWrapper& imgui,
+ const float win_pos_x, const float win_pos_y) override {}
+ void render_preferences_button(ImGuiWrapper& imgui,
+ const float win_pos_x, const float win_pos_y);
+ void render_right_arrow_button(ImGuiWrapper& imgui,
+ const float win_size_x, const float win_size_y,
+ const float win_pos_x, const float win_pos_y);
+ void render_logo(ImGuiWrapper& imgui,
+ const float win_size_x, const float win_size_y,
+ const float win_pos_x, const float win_pos_y);
+
+ void retrieve_data(size_t recursion_counter = 0);
+
+ bool m_has_hint_data { false };
+ std::function<void(void)> m_hypertext_callback;
+ std::string m_disabled_modes;
+ bool m_runtime_disable;
+ float m_close_b_y { 0 };
+ float m_close_b_w { 0 };
+};
+
+} //namespace Slic3r
+} //namespace GUI
+
+#endif //slic3r_GUI_HintNotification_hpp_ \ No newline at end of file