mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-17 05:45:59 +08:00
Re-Initialize Emboss GUI configuration on change monitor scale
This commit is contained in:
parent
7ef291d052
commit
f9b39c0f6f
@ -608,6 +608,12 @@ bool GLGizmoEmboss::on_init()
|
|||||||
ColorRGBA gray_color(.6f, .6f, .6f, .3f);
|
ColorRGBA gray_color(.6f, .6f, .6f, .3f);
|
||||||
m_rotate_gizmo.set_highlight_color(gray_color);
|
m_rotate_gizmo.set_highlight_color(gray_color);
|
||||||
m_shortcut_key = WXK_CONTROL_T;
|
m_shortcut_key = WXK_CONTROL_T;
|
||||||
|
|
||||||
|
// initialize text styles
|
||||||
|
m_style_manager.init(wxGetApp().app_config);
|
||||||
|
|
||||||
|
// Set rotation gizmo upwardrotate
|
||||||
|
m_rotate_gizmo.set_angle(PI / 2);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -720,13 +726,20 @@ void priv::draw_cross_hair(const ImVec2 &position, float radius, ImU32 color, in
|
|||||||
void GLGizmoEmboss::on_render_input_window(float x, float y, float bottom_limit)
|
void GLGizmoEmboss::on_render_input_window(float x, float y, float bottom_limit)
|
||||||
{
|
{
|
||||||
// Check that DPI is same
|
// Check that DPI is same
|
||||||
double screen_scale = wxDisplay(wxGetApp().plater()).GetScaleFactor();
|
GUI_App& app = wxGetApp();
|
||||||
if (m_gui_cfg.has_value() && m_gui_cfg->screen_scale != screen_scale)
|
double screen_scale = wxDisplay(app.plater()).GetScaleFactor();
|
||||||
m_gui_cfg.reset();
|
if (!m_gui_cfg.has_value() ||
|
||||||
|
m_gui_cfg->screen_scale != screen_scale) {
|
||||||
|
// Create cache for gui offsets
|
||||||
|
GuiCfg cfg = create_gui_configuration();
|
||||||
|
cfg.screen_scale = screen_scale;
|
||||||
|
m_gui_cfg.emplace(std::move(cfg));
|
||||||
|
// set position near toolbar
|
||||||
|
m_set_window_offset = ImVec2(-1.f, -1.f);
|
||||||
|
|
||||||
// Cache for gui offsets
|
// change resolution regenerate icons
|
||||||
if (!m_gui_cfg.has_value())
|
init_icons();
|
||||||
initialize(screen_scale);
|
}
|
||||||
set_volume_by_selection();
|
set_volume_by_selection();
|
||||||
|
|
||||||
// Do not render window for not selected text volume
|
// Do not render window for not selected text volume
|
||||||
@ -904,12 +917,9 @@ void GLGizmoEmboss::on_stop_dragging()
|
|||||||
}
|
}
|
||||||
void GLGizmoEmboss::on_dragging(const UpdateData &data) { m_rotate_gizmo.dragging(data); }
|
void GLGizmoEmboss::on_dragging(const UpdateData &data) { m_rotate_gizmo.dragging(data); }
|
||||||
|
|
||||||
void GLGizmoEmboss::initialize(double screen_scale)
|
GLGizmoEmboss::GuiCfg GLGizmoEmboss::create_gui_configuration()
|
||||||
{
|
{
|
||||||
if (m_gui_cfg.has_value()) return;
|
GuiCfg cfg; // initialize by default values;
|
||||||
|
|
||||||
GuiCfg cfg; // initialize by default values;
|
|
||||||
cfg.screen_scale = screen_scale;
|
|
||||||
|
|
||||||
float line_height = ImGui::GetTextLineHeight();
|
float line_height = ImGui::GetTextLineHeight();
|
||||||
float line_height_with_spacing = ImGui::GetTextLineHeightWithSpacing();
|
float line_height_with_spacing = ImGui::GetTextLineHeightWithSpacing();
|
||||||
@ -996,17 +1006,7 @@ void GLGizmoEmboss::initialize(double screen_scale)
|
|||||||
int max_style_image_height = 1.5 * input_height;
|
int max_style_image_height = 1.5 * input_height;
|
||||||
cfg.max_style_image_size = Vec2i(max_style_image_width, max_style_image_height);
|
cfg.max_style_image_size = Vec2i(max_style_image_width, max_style_image_height);
|
||||||
cfg.face_name_size.y() = line_height_with_spacing;
|
cfg.face_name_size.y() = line_height_with_spacing;
|
||||||
|
return cfg;
|
||||||
m_gui_cfg.emplace(std::move(cfg));
|
|
||||||
|
|
||||||
init_icons();
|
|
||||||
|
|
||||||
// initialize text styles
|
|
||||||
m_style_manager.init(wxGetApp().app_config);
|
|
||||||
set_default_text();
|
|
||||||
|
|
||||||
// Set rotation gizmo upwardrotate
|
|
||||||
m_rotate_gizmo.set_angle(PI/2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EmbossStyles GLGizmoEmboss::create_default_styles()
|
EmbossStyles GLGizmoEmboss::create_default_styles()
|
||||||
@ -1014,7 +1014,7 @@ EmbossStyles GLGizmoEmboss::create_default_styles()
|
|||||||
wxFont wx_font_normal = *wxNORMAL_FONT;
|
wxFont wx_font_normal = *wxNORMAL_FONT;
|
||||||
wxFont wx_font_small = *wxSMALL_FONT;
|
wxFont wx_font_small = *wxSMALL_FONT;
|
||||||
|
|
||||||
#ifdef __APPLE__
|
#ifdef __APPLE__=
|
||||||
wx_font_normal.SetFaceName("Helvetica");
|
wx_font_normal.SetFaceName("Helvetica");
|
||||||
wx_font_small.SetFaceName("Helvetica");
|
wx_font_small.SetFaceName("Helvetica");
|
||||||
#endif // __APPLE__
|
#endif // __APPLE__
|
||||||
|
@ -82,7 +82,6 @@ protected:
|
|||||||
std::string get_gizmo_leaving_text() const override { return _u8L("Leave emboss gizmo"); }
|
std::string get_gizmo_leaving_text() const override { return _u8L("Leave emboss gizmo"); }
|
||||||
std::string get_action_snapshot_name() override { return _u8L("Embossing actions"); }
|
std::string get_action_snapshot_name() override { return _u8L("Embossing actions"); }
|
||||||
private:
|
private:
|
||||||
void initialize(double screen_scale);
|
|
||||||
static EmbossStyles create_default_styles();
|
static EmbossStyles create_default_styles();
|
||||||
// localized default text
|
// localized default text
|
||||||
void set_default_text();
|
void set_default_text();
|
||||||
@ -213,10 +212,10 @@ private:
|
|||||||
std::string collection;
|
std::string collection;
|
||||||
};
|
};
|
||||||
Translations translations;
|
Translations translations;
|
||||||
|
|
||||||
GuiCfg() = default;
|
|
||||||
};
|
};
|
||||||
std::optional<const GuiCfg> m_gui_cfg;
|
std::optional<const GuiCfg> m_gui_cfg;
|
||||||
|
static GuiCfg create_gui_configuration();
|
||||||
|
|
||||||
bool m_is_advanced_edit_style = false;
|
bool m_is_advanced_edit_style = false;
|
||||||
|
|
||||||
// when true window will appear near to text volume when open
|
// when true window will appear near to text volume when open
|
||||||
|
Loading…
x
Reference in New Issue
Block a user