2018-10-31 09:19:44 +00:00
|
|
|
#ifndef slic3r_ImGuiWrapper_hpp_
|
|
|
|
#define slic3r_ImGuiWrapper_hpp_
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include <map>
|
|
|
|
|
2018-11-26 09:56:07 +00:00
|
|
|
#include <imgui/imgui.h>
|
|
|
|
|
|
|
|
#include "libslic3r/Point.hpp"
|
|
|
|
|
|
|
|
class wxString;
|
2018-10-31 09:19:44 +00:00
|
|
|
class wxMouseEvent;
|
2019-02-15 14:35:32 +00:00
|
|
|
class wxKeyEvent;
|
2018-11-26 09:56:07 +00:00
|
|
|
|
2018-10-31 09:19:44 +00:00
|
|
|
|
|
|
|
namespace Slic3r {
|
|
|
|
namespace GUI {
|
|
|
|
|
|
|
|
class ImGuiWrapper
|
|
|
|
{
|
2019-02-19 12:26:26 +00:00
|
|
|
const ImWchar *m_glyph_ranges;
|
2019-05-23 16:04:27 +00:00
|
|
|
// Chinese, Japanese, Korean
|
|
|
|
bool m_font_cjk;
|
2019-03-29 13:57:53 +00:00
|
|
|
float m_font_size;
|
2018-11-27 11:10:21 +00:00
|
|
|
unsigned m_font_texture;
|
2019-01-24 10:30:29 +00:00
|
|
|
float m_style_scaling;
|
2018-11-26 09:56:07 +00:00
|
|
|
unsigned m_mouse_buttons;
|
2019-01-18 14:02:07 +00:00
|
|
|
bool m_disabled;
|
2019-02-19 11:39:24 +00:00
|
|
|
bool m_new_frame_open;
|
|
|
|
std::string m_clipboard_text;
|
2018-11-26 09:56:07 +00:00
|
|
|
|
2018-10-31 09:19:44 +00:00
|
|
|
public:
|
2019-04-01 12:12:05 +00:00
|
|
|
ImGuiWrapper();
|
2018-11-26 09:56:07 +00:00
|
|
|
~ImGuiWrapper();
|
2018-10-31 09:19:44 +00:00
|
|
|
|
2018-11-27 11:10:21 +00:00
|
|
|
void read_glsl_version();
|
2018-10-31 09:19:44 +00:00
|
|
|
|
2019-02-19 12:26:26 +00:00
|
|
|
void set_language(const std::string &language);
|
2018-10-31 09:19:44 +00:00
|
|
|
void set_display_size(float w, float h);
|
2019-04-02 11:26:22 +00:00
|
|
|
void set_scaling(float font_size, float scale_style, float scale_both);
|
2018-11-26 09:56:07 +00:00
|
|
|
bool update_mouse_data(wxMouseEvent &evt);
|
2019-02-15 14:35:32 +00:00
|
|
|
bool update_key_data(wxKeyEvent &evt);
|
2018-10-31 09:19:44 +00:00
|
|
|
|
2019-04-01 12:12:05 +00:00
|
|
|
float get_font_size() const { return m_font_size; }
|
2019-03-06 08:15:33 +00:00
|
|
|
float get_style_scaling() const { return m_style_scaling; }
|
|
|
|
|
2018-10-31 09:19:44 +00:00
|
|
|
void new_frame();
|
|
|
|
void render();
|
|
|
|
|
2019-04-03 14:39:28 +00:00
|
|
|
float scaled(float x) const { return x * m_font_size; }
|
|
|
|
ImVec2 scaled(float x, float y) const { return ImVec2(x * m_font_size, y * m_font_size); }
|
2019-04-01 13:36:48 +00:00
|
|
|
ImVec2 calc_text_size(const wxString &text);
|
2019-04-01 12:12:05 +00:00
|
|
|
|
2019-07-10 11:45:25 +00:00
|
|
|
void set_next_window_pos(float x, float y, int flag, float pivot_x = 0.0f, float pivot_y = 0.0f);
|
2018-10-31 09:19:44 +00:00
|
|
|
void set_next_window_bg_alpha(float alpha);
|
|
|
|
|
2018-11-26 09:56:07 +00:00
|
|
|
bool begin(const std::string &name, int flags = 0);
|
|
|
|
bool begin(const wxString &name, int flags = 0);
|
2019-12-16 12:35:45 +00:00
|
|
|
bool begin(const std::string& name, bool* close, int flags = 0);
|
|
|
|
bool begin(const wxString& name, bool* close, int flags = 0);
|
2018-10-31 09:19:44 +00:00
|
|
|
void end();
|
|
|
|
|
2018-11-26 09:56:07 +00:00
|
|
|
bool button(const wxString &label);
|
2019-01-30 07:26:23 +00:00
|
|
|
bool radio_button(const wxString &label, bool active);
|
2018-11-26 09:56:07 +00:00
|
|
|
bool input_double(const std::string &label, const double &value, const std::string &format = "%.3f");
|
2020-02-21 11:17:46 +00:00
|
|
|
bool input_double(const wxString &label, const double &value, const std::string &format = "%.3f");
|
2018-11-26 09:56:07 +00:00
|
|
|
bool input_vec3(const std::string &label, const Vec3d &value, float width, const std::string &format = "%.3f");
|
|
|
|
bool checkbox(const wxString &label, bool &value);
|
2019-03-04 11:59:20 +00:00
|
|
|
void text(const char *label);
|
2019-03-04 11:21:00 +00:00
|
|
|
void text(const std::string &label);
|
2018-11-26 14:54:12 +00:00
|
|
|
void text(const wxString &label);
|
2019-12-04 14:12:00 +00:00
|
|
|
bool slider_float(const char* label, float* v, float v_min, float v_max, const char* format = "%.3f", float power = 1.0f);
|
|
|
|
bool slider_float(const std::string& label, float* v, float v_min, float v_max, const char* format = "%.3f", float power = 1.0f);
|
|
|
|
bool slider_float(const wxString& label, float* v, float v_min, float v_max, const char* format = "%.3f", float power = 1.0f);
|
2019-03-04 14:40:06 +00:00
|
|
|
bool combo(const wxString& label, const std::vector<std::string>& options, int& selection); // Use -1 to not mark any option as selected
|
2019-07-09 13:27:28 +00:00
|
|
|
bool undo_redo_list(const ImVec2& size, const bool is_undo, bool (*items_getter)(const bool, int, const char**), int& hovered, int& selected);
|
2018-10-31 09:19:44 +00:00
|
|
|
|
2019-01-18 14:02:07 +00:00
|
|
|
void disabled_begin(bool disabled);
|
|
|
|
void disabled_end();
|
|
|
|
|
2018-11-26 09:56:07 +00:00
|
|
|
bool want_mouse() const;
|
|
|
|
bool want_keyboard() const;
|
|
|
|
bool want_text_input() const;
|
|
|
|
bool want_any_input() const;
|
2019-02-19 12:26:26 +00:00
|
|
|
|
2018-10-31 09:19:44 +00:00
|
|
|
private:
|
2019-05-28 10:53:16 +00:00
|
|
|
void init_font(bool compress);
|
2019-02-15 14:35:32 +00:00
|
|
|
void init_input();
|
2019-02-19 13:46:29 +00:00
|
|
|
void init_style();
|
2018-11-26 09:56:07 +00:00
|
|
|
void render_draw_data(ImDrawData *draw_data);
|
2019-02-22 13:52:32 +00:00
|
|
|
bool display_initialized() const;
|
2019-04-01 12:12:05 +00:00
|
|
|
void destroy_font();
|
2019-02-15 14:35:32 +00:00
|
|
|
|
|
|
|
static const char* clipboard_get(void* user_data);
|
|
|
|
static void clipboard_set(void* user_data, const char* text);
|
2018-10-31 09:19:44 +00:00
|
|
|
};
|
|
|
|
|
2018-11-27 14:35:30 +00:00
|
|
|
|
2018-10-31 09:19:44 +00:00
|
|
|
} // namespace GUI
|
|
|
|
} // namespace Slic3r
|
|
|
|
|
|
|
|
#endif // slic3r_ImGuiWrapper_hpp_
|
|
|
|
|