PrusaSlicer-NonPlainar/src/slic3r/GUI/ImGuiWrapper.hpp

90 lines
2.3 KiB
C++
Raw Normal View History

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;
class wxKeyEvent;
2018-11-26 09:56:07 +00:00
2018-10-31 09:19:44 +00:00
namespace Slic3r {
namespace GUI {
class ImGuiWrapper
{
typedef std::map<std::string, ImFont*> FontsMap;
FontsMap m_fonts;
2019-02-19 12:26:26 +00:00
const ImWchar *m_glyph_ranges;
unsigned m_font_texture;
float m_style_scaling;
2018-11-26 09:56:07 +00:00
unsigned m_mouse_buttons;
bool m_disabled;
2018-11-26 09:56:07 +00:00
2018-10-31 09:19:44 +00:00
public:
ImGuiWrapper();
2018-11-26 09:56:07 +00:00
~ImGuiWrapper();
2018-10-31 09:19:44 +00:00
bool init();
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);
void set_style_scaling(float scaling);
2018-11-26 09:56:07 +00:00
bool update_mouse_data(wxMouseEvent &evt);
bool update_key_data(wxKeyEvent &evt);
2018-10-31 09:19:44 +00:00
void new_frame();
void render();
void set_next_window_pos(float x, float y, int flag);
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);
2018-10-31 09:19:44 +00:00
void end();
2018-11-26 09:56:07 +00:00
bool button(const wxString &label);
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");
bool input_vec3(const std::string &label, const Vec3d &value, float width, const std::string &format = "%.3f");
bool checkbox(const wxString &label, bool &value);
void text(const wxString &label);
bool combo(const wxString& label, const std::vector<wxString>& options, wxString& current_selection);
2018-10-31 09:19:44 +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:
std::string clipboard_text;
void init_default_font(float scaling);
2018-10-31 09:19:44 +00:00
void create_device_objects();
void create_fonts_texture();
void init_input();
2018-11-26 09:56:07 +00:00
void render_draw_data(ImDrawData *draw_data);
2018-10-31 09:19:44 +00:00
void destroy_device_objects();
void destroy_fonts_texture();
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_