FIX: dailytips adapts screen scale

jira: STUDIO-5019 STUDIO-5026 STUDIO-5027 STUDIO-5028 STUDIO-5025

Change-Id: I63d3af1870218ba8e0f048a6ef03fb29fabe27cb
This commit is contained in:
liz.li 2023-11-01 11:02:32 +08:00 committed by Lane.Wei
parent d7283d48a1
commit 0c7f991e5f
5 changed files with 34 additions and 45 deletions

View File

@ -82,11 +82,11 @@ documentation_link = https://wiki.bambulab.com/en/software/bambu-studio/Timelaps
[hint:Auto-Arrange]
text = Auto-Arrange\nDid you know that you can auto-arrange all objects in your project?
documentation_link = https://wiki.bambulab.com/en/software/bambu-studio/auto-arranging
image = images/dailytips_AutoArrange.PNG
[hint:Auto-Orient]
text = Auto-Orient\nDid you know that you can rotate objects to an optimal orientation for printing by a simple click?
documentation_link = https://wiki.bambulab.com/en/software/bambu-studio/auto-orientation
image = images/dailytips_AutoArrange.PNG
[hint:Lay on Face]
text = Lay on Face\nDid you know that you can quickly orient a model so that one of its faces sits on the print bed? Select the \"Place on face\" function or press the <b>F</b> key.

View File

@ -204,7 +204,6 @@ void DailyTipsPanel::set_size(const ImVec2& size)
{
m_width = size.x;
m_height = size.y;
m_content_height = m_height - m_header_height - m_footer_height;
}
void DailyTipsPanel::set_can_expand(bool can_expand)
@ -230,8 +229,11 @@ DailyTipsPanel::DailyTipsPanel(const ImVec2& pos, const ImVec2& size, bool can_e
void DailyTipsPanel::render()
{
m_header_height = m_can_expand ? 38.0f * m_scale : 0;
m_footer_height = 38.0f * m_scale;
ImGuiWrapper& imgui = *wxGetApp().imgui();
float scale = imgui.get_font_size() / 15.0f;
m_header_height = m_can_expand ? 38.0f * scale : 0;
m_footer_height = 38.0f * scale;
m_content_height = m_height - m_header_height - m_footer_height;
if (!m_first_enter) {
@ -322,11 +324,6 @@ bool DailyTipsPanel::is_expanded()
return m_is_expanded;
}
void DailyTipsPanel::set_scale(float scale)
{
m_scale = scale;
}
void DailyTipsPanel::on_change_color_mode(bool is_dark)
{
m_is_dark = is_dark;
@ -353,6 +350,7 @@ void DailyTipsPanel::render_header(const ImVec2& pos, const ImVec2& size)
void DailyTipsPanel::render_controller_buttons(const ImVec2& pos, const ImVec2& size)
{
ImGuiWrapper& imgui = *wxGetApp().imgui();
float scale = imgui.get_font_size() / 15.0f;
ImGuiWindow* parent_window = ImGui::GetCurrentWindow();
int window_flags = parent_window->Flags;
std::string name = "##DailyTipsPanelControllers" + std::to_string(parent_window->ID);
@ -406,7 +404,7 @@ void DailyTipsPanel::render_controller_buttons(const ImVec2& pos, const ImVec2&
ImGui::SetCursorScreenPos(ImVec2(btn_pos.x + expand_btn_size.x + ImGui::CalcTextSize(" ").x, btn_pos.y));
button_text = ImGui::ExpandArrowIcon;
imgui.button(button_text.c_str());
expand_btn_size.x += 19.0f * m_scale;
expand_btn_size.x += 19.0f * scale;
if (ImGui::IsMouseHoveringRect(btn_pos, btn_pos + expand_btn_size, true))
{
//underline
@ -483,7 +481,8 @@ void DailyTipsPanel::render_controller_buttons(const ImVec2& pos, const ImVec2&
void DailyTipsPanel::push_styles()
{
ImGuiWrapper& imgui = *wxGetApp().imgui();
imgui.push_common_window_style(m_scale);
float scale = imgui.get_font_size() / 15.0f;
imgui.push_common_window_style(scale);
ImGui::PushStyleVar(ImGuiStyleVar_WindowRounding, 0.0f);
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, ImVec2(0.0f, 0.0f));
// framePadding cannot be zero. Otherwise, there is a problem with icon font button display
@ -524,16 +523,18 @@ void DailyTipsWindow::render()
// ImGui::OpenPopup((_u8L("Daily Tips")).c_str());
ImGuiWrapper& imgui = *wxGetApp().imgui();
float scale = imgui.get_font_size() / 15.0f;
const Size& cnv_size = wxGetApp().plater()->get_current_canvas3D()->get_canvas_size();
ImVec2 center = ImVec2(cnv_size.get_width() * 0.5f, cnv_size.get_height() * 0.5f);
ImGui::SetNextWindowPos(center, ImGuiCond_Appearing, ImVec2(0.5f, 0.5f));
ImVec2 padding = ImVec2(25, 25) * m_scale;
imgui.push_menu_style(m_scale);
ImVec2 padding = ImVec2(25, 25) * scale;
imgui.push_menu_style(scale);
ImGui::PushStyleVar(ImGuiStyleVar_WindowPadding, padding);
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 12.f * m_scale);
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(10, 3) * m_scale);
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(10, 7) * m_scale);
ImGui::PushStyleVar(ImGuiStyleVar_FrameRounding, 12.f * scale);
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(10, 3) * scale);
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(10, 7) * scale);
ImGui::PushStyleColor(ImGuiCol_TitleBgActive, m_is_dark ? ImVec4(54 / 255.0f, 54 / 255.0f, 60 / 255.0f, 1.00f) : ImVec4(245 / 255.0f, 245 / 255.0f, 245 / 255.0f, 1.00f));
ImGui::GetCurrentContext()->DimBgRatio = 1.0f;
int windows_flag =
@ -549,7 +550,7 @@ void DailyTipsWindow::render()
imgui.pop_bold_font();
ImVec2 panel_pos = ImGui::GetWindowPos() + ImGui::GetWindowContentRegionMin();
ImVec2 panel_size = ImVec2(400.0f, 435.0f) * m_scale;
ImVec2 panel_size = ImVec2(400.0f, 435.0f) * scale;
m_panel->set_position(panel_pos);
m_panel->set_size(panel_size);
m_panel->render();
@ -569,12 +570,6 @@ void DailyTipsWindow::render()
imgui.pop_menu_style();
}
void DailyTipsWindow::set_scale(float scale)
{
m_scale = scale;
m_panel->set_scale(scale);
}
void DailyTipsWindow::on_change_color_mode(bool is_dark)
{
m_is_dark = is_dark;

View File

@ -25,7 +25,6 @@ public:
void expand(bool expand = true);
void collapse();
bool is_expanded();
void set_scale(float scale);
void on_change_color_mode(bool is_dark);
protected:
@ -48,7 +47,6 @@ private:
float m_footer_height;
int m_uid;
bool m_first_enter{ false };
float m_scale = 1.0f;
bool m_is_dark{ false };
};
@ -58,13 +56,11 @@ public:
void open();
void close();
void render();
void set_scale(float scale);
void on_change_color_mode(bool is_dark);
private:
DailyTipsPanel* m_panel{ nullptr };
bool m_show{ false };
float m_scale = 1.0f;
bool m_is_dark{ false };
};

View File

@ -7010,7 +7010,6 @@ void GLCanvas3D::_check_and_update_toolbar_icon_scale()
auto* m_notification = wxGetApp().plater()->get_notification_manager();
m_notification->set_scale(sc);
wxGetApp().plater()->get_dailytips()->set_scale(sc);
#endif
return;
@ -7036,7 +7035,6 @@ void GLCanvas3D::_check_and_update_toolbar_icon_scale()
auto* m_notification = wxGetApp().plater()->get_notification_manager();
m_notification->set_scale(sc);
wxGetApp().plater()->get_dailytips()->set_scale(sc);
#else
//BBS: GUI refactor: GLToolbar
m_main_toolbar.set_icons_size(GLGizmosManager::Default_Icons_Size * scale);

View File

@ -222,6 +222,7 @@ void NotificationManager::SlicingProgressNotification::render(GLCanvas3D& canvas
init();
ImGuiWrapper& imgui = *wxGetApp().imgui();
float scale = imgui.get_font_size() / 15.0f;
bool fading_pop = false;
if (m_state == EState::FadingOut) {
@ -231,7 +232,7 @@ void NotificationManager::SlicingProgressNotification::render(GLCanvas3D& canvas
fading_pop = true;
}
use_bbl_theme();
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(8 * m_scale, 0));
ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2(8 * scale, 0));
if (m_sp_state == SlicingProgressNotification::SlicingProgressState::SP_COMPLETED || m_sp_state == SlicingProgressNotification::SlicingProgressState::SP_CANCELLED)
{
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize,m_WindowRadius / 4);
@ -242,13 +243,13 @@ void NotificationManager::SlicingProgressNotification::render(GLCanvas3D& canvas
push_style_color(ImGuiCol_Border, { 0, 0, 0, 0 }, true, m_current_fade_opacity);
}
const ImVec2 progress_child_window_padding = ImVec2(25.f, 5.f) * m_scale;
const ImVec2 dailytips_child_window_padding = ImVec2(25.f, 2.f) * m_scale;
const ImVec2 bottom_padding = ImVec2(25.f, 20.f) * m_scale;
const ImVec2 progress_child_window_padding = ImVec2(25.f, 5.f) * scale;
const ImVec2 dailytips_child_window_padding = ImVec2(25.f, 2.f) * scale;
const ImVec2 bottom_padding = ImVec2(25.f, 20.f) * scale;
const float progress_panel_width = (m_window_width - 2 * progress_child_window_padding.x);
const float progress_panel_height = (78.0f * m_scale);
const float progress_panel_height = (78.0f * scale);
const float dailytips_panel_width = (m_window_width - 2 * dailytips_child_window_padding.x);
const float dailytips_panel_height = (395.0f * m_scale);
const float dailytips_panel_height = (395.0f * scale);
Size cnv_size = canvas.get_canvas_size();
float right_gap = right_margin + (move_from_overlay ? overlay_width + m_line_height * 5 : 0);
@ -256,7 +257,7 @@ void NotificationManager::SlicingProgressNotification::render(GLCanvas3D& canvas
imgui.set_next_window_pos(window_pos.x, window_pos.y, ImGuiCond_Always, 0.0f, 0.0f);
// dynamically resize window by progress state
if (m_sp_state == SlicingProgressNotification::SlicingProgressState::SP_COMPLETED || m_sp_state == SlicingProgressNotification::SlicingProgressState::SP_CANCELLED)
m_window_height = 64.0f * m_scale;
m_window_height = 64.0f * scale;
else
m_window_height = progress_panel_height + m_dailytips_panel->get_size().y + progress_child_window_padding.y + dailytips_child_window_padding.y + bottom_padding.y;
m_top_y = initial_y + m_window_height;
@ -279,10 +280,10 @@ void NotificationManager::SlicingProgressNotification::render(GLCanvas3D& canvas
ImGuiWindow* parent_window = ImGui::GetCurrentWindow();
if (m_sp_state == SlicingProgressState::SP_CANCELLED || m_sp_state == SlicingProgressState::SP_COMPLETED) {
ImVec2 button_size = ImVec2(38.f, 38.f) * m_scale;
float button_right_margin_x = 3.0f * m_scale;
ImVec2 button_size = ImVec2(38.f, 38.f) * scale;
float button_right_margin_x = 3.0f * scale;
ImVec2 button_pos = window_pos + ImVec2(m_window_width - button_size.x - button_right_margin_x, (m_window_height - button_size.y) / 2.0f);
float text_left_margin_x = 15.0f * m_scale;
float text_left_margin_x = 15.0f * scale;
ImVec2 text_pos = window_pos + ImVec2(text_left_margin_x, m_window_height / 2.0f - m_line_height * 1.2f);
ImVec2 view_dailytips_text_pos = window_pos + ImVec2(text_left_margin_x, m_window_height / 2.0f + m_line_height * 0.2f);
@ -298,11 +299,11 @@ void NotificationManager::SlicingProgressNotification::render(GLCanvas3D& canvas
ImGui::SetNextWindowPos(parent_window->Pos + progress_child_window_padding);
if (ImGui::BeginChild(child_name.c_str(), ImVec2(progress_panel_width, progress_panel_height), false, child_window_flags)) {
ImVec2 child_window_pos = ImGui::GetWindowPos();
ImVec2 button_size = ImVec2(38.f, 38.f) * m_scale;
ImVec2 button_size = ImVec2(38.f, 38.f) * scale;
ImVec2 button_pos = child_window_pos + ImVec2(progress_panel_width - button_size.x, (progress_panel_height - button_size.y) / 2.0f);
float margin_x = 8.0f * m_scale;
float margin_x = 8.0f * scale;
ImVec2 progress_bar_pos = child_window_pos + ImVec2(0, progress_panel_height / 2.0f);
ImVec2 progress_bar_size = ImVec2(progress_panel_width - button_size.x - margin_x, 4.0f * m_scale);
ImVec2 progress_bar_size = ImVec2(progress_panel_width - button_size.x - margin_x, 4.0f * scale);
ImVec2 text_pos = ImVec2(progress_bar_pos.x, progress_bar_pos.y - m_line_height * 1.2f);
render_text(text_pos);
@ -346,7 +347,7 @@ void NotificationManager::SlicingProgressNotification::render(GLCanvas3D& canvas
void Slic3r::GUI::NotificationManager::SlicingProgressNotification::render_text(const ImVec2& pos)
{
ImGuiWrapper& imgui = *wxGetApp().imgui();
float scale = imgui.get_font_size() / 15.0f;
if (m_sp_state == SlicingProgressState::SP_BEFORE_COMPLETED) {
// complete icon
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(.0f, .0f, .0f, .0f));
@ -355,7 +356,7 @@ void Slic3r::GUI::NotificationManager::SlicingProgressNotification::render_text(
push_style_color(ImGuiCol_TextSelectedBg, ImVec4(0, .75f, .75f, 1.f), m_state == EState::FadingOut, m_current_fade_opacity);
ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(.0f, .0f, .0f, .0f));
ImVec2 icon_size = ImVec2(38.f, 38.f) * m_scale;
ImVec2 icon_size = ImVec2(38.f, 38.f) * scale;
ImGui::SetCursorScreenPos(pos);
std::wstring icon_text;
icon_text = ImGui::CompleteIcon;
@ -423,7 +424,6 @@ void NotificationManager::SlicingProgressNotification::render_dailytips_panel(co
m_dailytips_panel->set_can_expand(false);
else
m_dailytips_panel->set_can_expand(true);
m_dailytips_panel->set_scale(m_scale);
m_dailytips_panel->set_position(pos);
m_dailytips_panel->set_size(size);
m_dailytips_panel->render();