mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-10-15 11:51:33 +00:00
* Remove Unused Project Includes and Forward-Declare Where a Type Is Only Referenced Generated with include-what-you-use and applied conservatively. Only OrcaSlicer's own headers, the ones under src/ and tests/, are removed or forward-declared; standard-library and third-party includes are left alone. An include is removed only when both the Release and the Debug configuration leave it unused, never from inside a conditional block, and never from a file with platform-specific blocks, which only gain includes. Files whose only use of a header sits behind a feature or debug macro (libvgcode's OpenGL ES and marker code, the ARACHNE/TESTS_EXPORT_SVGS debug output) keep their includes. clonable_ptr.hpp gains #pragma once; it had no include guard and was only safe while Config.hpp was its sole includer. * Remove Unused Project Includes From Files With Platform-Specific Code A Linux include-what-you-use run cannot see the code inside _WIN32, __APPLE__ or __linux__ blocks, so its verdict is only taken where nothing the removed header declares, directly or through what it includes, is named inside those blocks. Removals also have to hold in both the Release and Debug configuration and never touch a line inside a conditional block. * Restore the libslic3r Precompiled Header and Direct Includes Lost in the Platform Pass The platform-file pass treated pchheader.hpp as an ordinary header and emptied it, and left GUI_Preview.hpp and 14 other files relying on headers they no longer reached directly. * Restore MainFrame.hpp in ParamsDialog.cpp for the Windows-Only Reparent Call * Include Headers That Files Reached Through Ones the Cleanup Removed * Drop Includes Duplicated by the Cleanup or by Main's Own Additions * Leave PreciseSeam.cpp as Main Has It After the Precise Seam Rework
145 lines
4.5 KiB
C++
145 lines
4.5 KiB
C++
#ifndef slic3r_GUI_HintNotification_hpp_
|
|
#define slic3r_GUI_HintNotification_hpp_
|
|
|
|
#include "NotificationManager.hpp"
|
|
#include <string>
|
|
#include <cstddef>
|
|
#include <functional>
|
|
#include <boost/filesystem/path.hpp>
|
|
#include <vector>
|
|
#include <wx/event.h>
|
|
|
|
class wxEvtHandler;
|
|
namespace Slic3r::GUI { class ImGuiWrapper; }
|
|
|
|
namespace Slic3r {namespace GUI {
|
|
|
|
// Database of hints updatable
|
|
struct HintData
|
|
{
|
|
std::string id_string;
|
|
std::string text;
|
|
size_t weight;
|
|
bool was_displayed;
|
|
std::string hypertext;
|
|
std::string follow_text;
|
|
std::string disabled_tags;
|
|
std::string enabled_tags;
|
|
bool runtime_disable; // if true - hyperlink will check before every click if not in disabled mode
|
|
std::string documentation_link;
|
|
std::string image_url;
|
|
std::function<void(void)> callback{ nullptr };
|
|
};
|
|
|
|
enum class HintDataNavigation {
|
|
Curr,
|
|
Prev,
|
|
Next,
|
|
Random,
|
|
};
|
|
|
|
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(HintDatabase const&) = delete;
|
|
void operator=(HintDatabase const&) = delete;
|
|
|
|
// return true if HintData filled;
|
|
HintData* get_hint(HintDataNavigation nav);
|
|
size_t get_index() { return m_hint_id; }
|
|
size_t get_count() {
|
|
if (!m_initialized)
|
|
return 0;
|
|
return m_loaded_hints.size();
|
|
}
|
|
// resets m_initiailized to false and writes used if was initialized
|
|
// used when reloading in runtime - like change language
|
|
void uninit();
|
|
void reinit();
|
|
private:
|
|
void init();
|
|
void init_random_hint_id();
|
|
void load_hints_from_file(const boost::filesystem::path& path);
|
|
bool is_used(const std::string& id);
|
|
void set_used(const std::string& id);
|
|
void clear_used();
|
|
// Returns position in m_loaded_hints with next hint chosed randomly with weights
|
|
size_t get_next_hint_id();
|
|
size_t get_prev_hint_id();
|
|
size_t get_random_next();
|
|
size_t m_hint_id;
|
|
bool m_initialized{ false };
|
|
std::vector<HintData> m_loaded_hints;
|
|
bool m_sorted_hints{ false };
|
|
std::vector<std::string> m_used_ids;
|
|
bool m_used_ids_loaded{ false };
|
|
};
|
|
// 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, bool new_hint)
|
|
: PopNotification(n, id_provider, evt_handler)
|
|
{
|
|
retrieve_data(new_hint);
|
|
}
|
|
virtual void init() override;
|
|
void open_next() { retrieve_data(); }
|
|
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_documentation_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);
|
|
// recursion counter -1 tells to retrieve same hint as last time
|
|
void retrieve_data(bool new_hint = true);
|
|
void open_documentation();
|
|
|
|
bool m_has_hint_data{ false };
|
|
std::function<void(void)> m_hypertext_callback;
|
|
std::string m_disabled_tags;
|
|
std::string m_enabled_tags;
|
|
bool m_runtime_disable;
|
|
std::string m_documentation_link;
|
|
float m_close_b_y{ 0 };
|
|
float m_close_b_w{ 0 };
|
|
// hover of buttons
|
|
long m_docu_hover_time{ 0 };
|
|
long m_prefe_hover_time{ 0 };
|
|
};
|
|
|
|
} //namespace Slic3r
|
|
} //namespace GUI
|
|
|
|
#endif //slic3r_GUI_HintNotification_hpp_
|