ENH: modify dailytips collapse & expand interaction

jira: STUDIO-5209、STUDIO-5210

Change-Id: Ifb0b998e5004d4b49390ba5a250eaf4743bf3471
This commit is contained in:
liz.li 2023-11-13 11:10:45 +08:00 committed by Lane.Wei
parent 8b70ae4a65
commit 310e68c34c
4 changed files with 71 additions and 113 deletions

View File

@ -25,6 +25,7 @@ public:
void render(const ImVec2& pos, const ImVec2& size) const;
bool has_image() const;
void on_change_color_mode(bool is_dark);
void set_fade_opacity(float opacity);
protected:
void load_texture_from_img_url(const std::string url);
@ -39,6 +40,7 @@ private:
GLTexture* m_placeholder_texture{ nullptr };
bool m_is_dark{ false };
DailyTipsLayout m_layout;
float m_fade_opacity{ 1.0f };
};
DailyTipsDataRenderer::DailyTipsDataRenderer(DailyTipsLayout layout)
@ -121,12 +123,17 @@ void DailyTipsDataRenderer::on_change_color_mode(bool is_dark)
m_is_dark = is_dark;
}
void DailyTipsDataRenderer::set_fade_opacity(float opacity)
{
m_fade_opacity = opacity;
}
void DailyTipsDataRenderer::render_img(const ImVec2& start_pos, const ImVec2& size) const
{
if (has_image())
ImGui::Image((ImTextureID)(intptr_t)m_texture->get_id(), size, ImVec2(0, 0), ImVec2(1, 1), m_is_dark ? ImVec4(0.8, 0.8, 0.8, 1) : ImVec4(1, 1, 1, 1));
ImGui::Image((ImTextureID)(intptr_t)m_texture->get_id(), size, ImVec2(0, 0), ImVec2(1, 1), m_is_dark ? ImVec4(0.8, 0.8, 0.8, m_fade_opacity) : ImVec4(1, 1, 1, m_fade_opacity));
else {
ImGui::Image((ImTextureID)(intptr_t)m_placeholder_texture->get_id(), size, ImVec2(0, 0), ImVec2(1, 1), m_is_dark ? ImVec4(0.8, 0.8, 0.8, 1) : ImVec4(1, 1, 1, 1));
ImGui::Image((ImTextureID)(intptr_t)m_placeholder_texture->get_id(), size, ImVec2(0, 0), ImVec2(1, 1), m_is_dark ? ImVec4(0.8, 0.8, 0.8, m_fade_opacity) : ImVec4(1, 1, 1, m_fade_opacity));
}
}
@ -134,6 +141,7 @@ void DailyTipsDataRenderer::render_text(const ImVec2& start_pos, const ImVec2& s
{
ImGuiWrapper& imgui = *wxGetApp().imgui();
ImGui::PushStyleColor(ImGuiCol_Text, m_is_dark ? ImVec4(1.0f, 1.0f, 1.0f, 0.88f * m_fade_opacity) : ImVec4(38 / 255.0f, 46 / 255.0f, 48 / 255.0f, m_fade_opacity));
// main text
// first line is headline (for hint notification it must be divided by \n)
std::string title_line;
@ -182,7 +190,7 @@ void DailyTipsDataRenderer::render_text(const ImVec2& start_pos, const ImVec2& s
ImVec2 link_start_pos = ImGui::GetCursorScreenPos();
imgui.text(first_part_text);
ImColor HyperColor = ImColor(31, 142, 234).Value;
ImColor HyperColor = ImColor(31, 142, 234, (int)(255 * m_fade_opacity)).Value;
ImVec2 wiki_part_rect_min = ImVec2(link_start_pos.x + first_part_size.x, link_start_pos.y);
ImVec2 wiki_part_rect_max = wiki_part_rect_min + wiki_part_size;
ImGui::PushStyleColor(ImGuiCol_Text, HyperColor.Value);
@ -204,6 +212,7 @@ void DailyTipsDataRenderer::render_text(const ImVec2& start_pos, const ImVec2& s
open_wiki();
}
}
ImGui::PopStyleColor();
}
int DailyTipsPanel::uid = 0;
@ -342,6 +351,12 @@ void DailyTipsPanel::on_change_color_mode(bool is_dark)
m_dailytips_renderer->on_change_color_mode(is_dark);
}
void DailyTipsPanel::set_fade_opacity(float opacity)
{
m_fade_opacity = opacity;
m_dailytips_renderer->set_fade_opacity(opacity);
}
//void DailyTipsPanel::render_header(const ImVec2& pos, const ImVec2& size)
//{
// ImGuiWrapper& imgui = *wxGetApp().imgui();
@ -380,7 +395,7 @@ void DailyTipsPanel::render_controller_buttons(const ImVec2& pos, const ImVec2&
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(.0f, .0f, .0f, .0f));
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(.0f, .0f, .0f, .0f));
ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(.0f, .0f, .0f, .0f));
ImGui::PushStyleColor(ImGuiCol_Text, ImColor(144, 144, 144).Value);
ImGui::PushStyleColor(ImGuiCol_Text, ImColor(144, 144, 144, (int)(255 * m_fade_opacity)).Value);
button_text = ImGui::CollapseArrowIcon;
imgui.button((_L("Collapse") + button_text));
@ -406,7 +421,7 @@ void DailyTipsPanel::render_controller_buttons(const ImVec2& pos, const ImVec2&
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(.0f, .0f, .0f, .0f));
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(.0f, .0f, .0f, .0f));
ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4(.0f, .0f, .0f, .0f));
ImGui::PushStyleColor(ImGuiCol_Text, m_is_dark ? ImColor(230, 230, 230).Value : ImColor(38, 46, 48).Value);
ImGui::PushStyleColor(ImGuiCol_Text, m_is_dark ? ImColor(230, 230, 230, (int)(255 * m_fade_opacity)).Value : ImColor(38, 46, 48, (int)(255 * m_fade_opacity)).Value);
// for bold font text, split text and icon-font button
imgui.push_bold_font();
@ -425,7 +440,7 @@ void DailyTipsPanel::render_controller_buttons(const ImVec2& pos, const ImVec2&
lineEnd.y -= 2;
ImVec2 lineStart = lineEnd;
lineStart.x = ImGui::GetItemRectMin().x - expand_btn_size.x;
ImGui::GetWindowDrawList()->AddLine(lineStart, lineEnd, m_is_dark ? ImColor(230, 230, 230) : ImColor(38, 46, 48));
ImGui::GetWindowDrawList()->AddLine(lineStart, lineEnd, m_is_dark ? ImColor(230, 230, 230, (int)(255 * m_fade_opacity)) : ImColor(38, 46, 48, (int)(255 * m_fade_opacity)));
if (ImGui::IsMouseClicked(ImGuiMouseButton_Left))
expand();
@ -447,7 +462,9 @@ void DailyTipsPanel::render_controller_buttons(const ImVec2& pos, const ImVec2&
float text_pos_x = (pos + size).x - button_margin_x * 2 - button_size.x * 2 - text_item_width;
float text_pos_y = pos.y + (size.y - ImGui::CalcTextSize("A").y) / 2;
ImGui::SetCursorScreenPos(ImVec2(text_pos_x, text_pos_y));
ImGui::PushStyleColor(ImGuiCol_Text, m_is_dark ? ImColor(230, 230, 230, (int)(255 * m_fade_opacity)).Value : ImColor(38, 46, 48, (int)(255 * m_fade_opacity)).Value);
imgui.text(text_str);
ImGui::PopStyleColor();
ImGui::PopItemWidth();
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(.0f, .0f, .0f, .0f));
@ -456,13 +473,13 @@ void DailyTipsPanel::render_controller_buttons(const ImVec2& pos, const ImVec2&
ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(.0f, .0f, .0f, .0f));
// prev button
ImColor button_text_color = m_is_dark ? ImColor(228, 228, 228) : ImColor(38, 46, 48);
ImColor button_text_color = m_is_dark ? ImColor(228, 228, 228, (int)(255 * m_fade_opacity)) : ImColor(38, 46, 48, (int)(255 * m_fade_opacity));
ImVec2 prev_button_pos = pos + size + ImVec2(-button_margin_x - button_size.x * 2, -size.y + (size.y - button_size.y) / 2);
ImGui::SetCursorScreenPos(prev_button_pos);
button_text = ImGui::PrevArrowBtnIcon;
if (ImGui::IsMouseHoveringRect(prev_button_pos, prev_button_pos + button_size, true))
{
button_text_color = ImColor(0, 174, 66);
button_text_color = ImColor(0, 174, 66, (int)(255 * m_fade_opacity));
if (ImGui::IsMouseClicked(ImGuiMouseButton_Left))
retrieve_data_from_hint_database(HintDataNavigation::Prev);
}
@ -471,13 +488,13 @@ void DailyTipsPanel::render_controller_buttons(const ImVec2& pos, const ImVec2&
ImGui::PopStyleColor();
// next button
button_text_color = m_is_dark ? ImColor(228, 228, 228) : ImColor(38, 46, 48);
button_text_color = m_is_dark ? ImColor(228, 228, 228, (int)(255 * m_fade_opacity)) : ImColor(38, 46, 48, (int)(255 * m_fade_opacity));
ImVec2 next_button_pos = pos + size + ImVec2(-button_size.x, -size.y + (size.y - button_size.y) / 2);
ImGui::SetCursorScreenPos(next_button_pos);
button_text = ImGui::NextArrowBtnIcon;
if (ImGui::IsMouseHoveringRect(next_button_pos, next_button_pos + button_size, true))
{
button_text_color = ImColor(0, 174, 66);
button_text_color = ImColor(0, 174, 66, (int)(255 * m_fade_opacity));
if (ImGui::IsMouseClicked(ImGuiMouseButton_Left))
retrieve_data_from_hint_database(HintDataNavigation::Next);
}

View File

@ -30,6 +30,7 @@ public:
void collapse();
bool is_expanded();
void on_change_color_mode(bool is_dark);
void set_fade_opacity(float opacity);
protected:
void render_controller_buttons(const ImVec2& pos, const ImVec2& size);
@ -51,6 +52,7 @@ private:
bool m_first_enter{ false };
bool m_is_dark{ false };
DailyTipsLayout m_layout{ DailyTipsLayout::Vertical };
float m_fade_opacity{ 1.0f };
};
class DailyTipsWindow {

View File

@ -17,9 +17,6 @@ namespace {
}
}
static constexpr int BEFORE_COMPLETE_DURATION = 4000; //ms
static constexpr int REFRESH_TIMEOUT = 100; //ms
void NotificationManager::SlicingProgressNotification::on_change_color_mode(bool is_dark)
{
PopNotification::on_change_color_mode(is_dark);
@ -58,11 +55,7 @@ bool NotificationManager::SlicingProgressNotification::set_progress_state(float
if (percent < 0.f)
return true;//set_progress_state(SlicingProgressState::SP_CANCELLED);
else if (percent >= 1.f) {
if (m_dailytips_panel->is_expanded()) {
m_before_complete_start = GLCanvas3D::timestamp_now();
return set_progress_state(SlicingProgressState::SP_BEFORE_COMPLETED);
}
else
return set_progress_state(SlicingProgressState::SP_COMPLETED);
}
else
@ -105,16 +98,8 @@ bool NotificationManager::SlicingProgressNotification::set_progress_state(Notifi
set_export_possible(false);
m_sp_state = state;
return true;
case Slic3r::GUI::NotificationManager::SlicingProgressNotification::SlicingProgressState::SP_BEFORE_COMPLETED:
if (m_sp_state != SlicingProgressState::SP_BEGAN && m_sp_state != SlicingProgressState::SP_PROGRESS)
return false;
m_has_print_info = false;
// m_export_possible is important only for SP_PROGRESS state, thus we can reset it here
set_export_possible(false);
m_sp_state = state;
return true;
case Slic3r::GUI::NotificationManager::SlicingProgressNotification::SlicingProgressState::SP_COMPLETED:
if (m_sp_state != SlicingProgressState::SP_BEGAN && m_sp_state != SlicingProgressState::SP_PROGRESS && m_sp_state != SlicingProgressState::SP_BEFORE_COMPLETED)
if (m_sp_state != SlicingProgressState::SP_BEGAN && m_sp_state != SlicingProgressState::SP_PROGRESS)
return false;
set_percentage(1);
m_has_print_info = false;
@ -149,13 +134,6 @@ void NotificationManager::SlicingProgressNotification::set_status_text(const std
m_state = EState::Shown;
}
break;
case Slic3r::GUI::NotificationManager::SlicingProgressNotification::SlicingProgressState::SP_BEFORE_COMPLETED:
{
NotificationData data{ NotificationType::SlicingProgress, NotificationLevel::ProgressBarNotificationLevel, 0, _u8L("Slice ok.") };
update(data);
m_state = EState::Shown;
}
break;
case Slic3r::GUI::NotificationManager::SlicingProgressNotification::SlicingProgressState::SP_COMPLETED:
{
NotificationData data{ NotificationType::SlicingProgress, NotificationLevel::ProgressBarNotificationLevel, 0, _u8L("Slice ok.") };
@ -198,8 +176,8 @@ int NotificationManager::SlicingProgressNotification::get_duration()
{
if (m_sp_state == SlicingProgressState::SP_CANCELLED)
return 3;
else if (m_sp_state == SlicingProgressState::SP_COMPLETED && !m_sidebar_collapsed)
return 5;
else if (m_sp_state == SlicingProgressState::SP_COMPLETED)
return 3;
else
return 0;
}
@ -207,7 +185,7 @@ int NotificationManager::SlicingProgressNotification::get_duration()
bool NotificationManager::SlicingProgressNotification::update_state(bool paused, const int64_t delta)
{
bool ret = PopNotification::update_state(paused, delta);
if (m_sp_state == SlicingProgressState::SP_BEFORE_COMPLETED || m_sp_state == SlicingProgressState::SP_COMPLETED)
if (m_sp_state == SlicingProgressState::SP_COMPLETED)
ret = true;
// sets Estate to hidden
@ -233,19 +211,11 @@ void NotificationManager::SlicingProgressNotification::render(GLCanvas3D& canvas
}
use_bbl_theme();
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);
m_is_dark ? push_style_color(ImGuiCol_Border, { 62 / 255.f, 62 / 255.f, 69 / 255.f, 1.f }, true, m_current_fade_opacity) : push_style_color(ImGuiCol_Border, m_CurrentColor, true, m_current_fade_opacity);
}
else {
// for debug
//ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, m_WindowRadius / 4);
//m_is_dark ? push_style_color(ImGuiCol_Border, { 62 / 255.f, 62 / 255.f, 69 / 255.f, 1.f }, true, m_current_fade_opacity) : push_style_color(ImGuiCol_Border, m_CurrentColor, true, m_current_fade_opacity);
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f);
push_style_color(ImGuiCol_Border, { 0, 0, 0, 0 }, true, m_current_fade_opacity);
}
// for debug
//ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, m_WindowRadius / 4);
//m_is_dark ? push_style_color(ImGuiCol_Border, { 62 / 255.f, 62 / 255.f, 69 / 255.f, 1.f }, true, m_current_fade_opacity) : push_style_color(ImGuiCol_Border, m_CurrentColor, true, m_current_fade_opacity);
ImGui::PushStyleVar(ImGuiStyleVar_WindowBorderSize, 0.0f);
push_style_color(ImGuiCol_Border, { 0, 0, 0, 0 }, true, m_current_fade_opacity);
Size cnv_size = canvas.get_canvas_size();
@ -265,11 +235,7 @@ void NotificationManager::SlicingProgressNotification::render(GLCanvas3D& canvas
float right_gap = right_margin + (move_from_overlay ? overlay_width + m_line_height * 5 : 0);
m_window_pos = ImVec2((float)cnv_size.get_width() - right_gap - m_window_width, (float)cnv_size.get_height() - m_top_y);
imgui.set_next_window_pos(m_window_pos.x, m_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 * 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_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;
ImGui::SetNextWindowSizeConstraints(ImVec2(m_window_width, m_window_height), ImVec2(m_window_width, m_window_height));
@ -289,21 +255,21 @@ void NotificationManager::SlicingProgressNotification::render(GLCanvas3D& canvas
if (imgui.begin(name, window_flags)) {
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) * scale;
float button_right_margin_x = 3.0f * scale;
ImVec2 button_pos = m_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 * scale;
ImVec2 text_pos = m_window_pos + ImVec2(text_left_margin_x, m_window_height / 2.0f - m_line_height * 1.2f);
ImVec2 view_dailytips_text_pos = m_window_pos + ImVec2(text_left_margin_x, m_window_height / 2.0f + m_line_height * 0.2f);
//if (m_sp_state == SlicingProgressState::SP_CANCELLED || m_sp_state == SlicingProgressState::SP_COMPLETED) {
// ImVec2 button_size = ImVec2(38.f, 38.f) * scale;
// float button_right_margin_x = 3.0f * scale;
// ImVec2 button_pos = m_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 * scale;
// ImVec2 text_pos = m_window_pos + ImVec2(text_left_margin_x, m_window_height / 2.0f - m_line_height * 1.2f);
// ImVec2 view_dailytips_text_pos = m_window_pos + ImVec2(text_left_margin_x, m_window_height / 2.0f + m_line_height * 0.2f);
bbl_render_left_sign(imgui, m_window_width, m_window_height, m_window_pos.x + m_window_width, m_window_pos.y);
render_text(text_pos);
render_close_button(button_pos, button_size);
render_show_dailytips(view_dailytips_text_pos);
}
// bbl_render_left_sign(imgui, m_window_width, m_window_height, m_window_pos.x + m_window_width, m_window_pos.y);
// render_text(text_pos);
// render_close_button(button_pos, button_size);
// render_show_dailytips(view_dailytips_text_pos);
//}
if (m_sp_state == SlicingProgressState::SP_PROGRESS || m_sp_state == SlicingProgressState::SP_BEFORE_COMPLETED) {
if (m_sp_state == SlicingProgressState::SP_CANCELLED || m_sp_state == SlicingProgressState::SP_PROGRESS || m_sp_state == SlicingProgressState::SP_COMPLETED) {
std::string child_name = "##SlicingProgressPanel" + std::to_string(parent_window->ID);
ImGui::SetNextWindowPos(parent_window->Pos + progress_child_window_padding);
@ -317,6 +283,7 @@ void NotificationManager::SlicingProgressNotification::render(GLCanvas3D& canvas
ImVec2 text_pos = ImVec2(progress_bar_pos.x, progress_bar_pos.y - m_line_height * 1.2f);
render_text(text_pos);
render_close_button(button_pos, button_size);
if (m_sp_state == SlicingProgressState::SP_PROGRESS) {
render_bar(progress_bar_pos, progress_bar_size);
render_cancel_button(button_pos, button_size);
@ -327,13 +294,14 @@ void NotificationManager::SlicingProgressNotification::render(GLCanvas3D& canvas
// Separator Line
ImVec2 separator_min = ImVec2(ImGui::GetCursorScreenPos().x + progress_child_window_padding.x, ImGui::GetCursorScreenPos().y);
ImVec2 separator_max = ImVec2(ImGui::GetCursorScreenPos().x + progress_child_window_padding.x + progress_panel_width, ImGui::GetCursorScreenPos().y);
ImGui::GetCurrentWindow()->DrawList->AddLine(separator_min, separator_max, ImColor(238, 238, 238));
ImGui::GetCurrentWindow()->DrawList->AddLine(separator_min, separator_max, ImColor(238, 238, 238, (int)(255 * m_current_fade_opacity)));
child_name = "##DailyTipsPanel" + std::to_string(parent_window->ID);
ImVec2 dailytips_pos = ImGui::GetCursorScreenPos() + dailytips_child_window_padding;
ImVec2 dailytips_size = ImVec2(dailytips_panel_width, dailytips_panel_height);
m_dailytips_panel->set_position(dailytips_pos);
m_dailytips_panel->set_size(dailytips_size);
m_dailytips_panel->set_fade_opacity(m_current_fade_opacity);
ImGui::SetNextWindowPos(dailytips_pos);
if (ImGui::BeginChild(child_name.c_str(), ImVec2(dailytips_panel_width, dailytips_panel_height), false, child_window_flags)) {
render_dailytips_panel(dailytips_pos, dailytips_size);
@ -359,7 +327,8 @@ void Slic3r::GUI::NotificationManager::SlicingProgressNotification::render_text(
{
ImGuiWrapper& imgui = *wxGetApp().imgui();
float scale = imgui.get_font_size() / 15.0f;
if (m_sp_state == SlicingProgressState::SP_BEFORE_COMPLETED) {
ImVec2 icon_size = ImVec2(38.f, 38.f) * scale;
if (m_sp_state == SlicingProgressState::SP_COMPLETED) {
// complete icon
ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(.0f, .0f, .0f, .0f));
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4(.0f, .0f, .0f, .0f));
@ -374,46 +343,20 @@ void Slic3r::GUI::NotificationManager::SlicingProgressNotification::render_text(
ImGui::PopStyleColor(5);
ImVec2 icon_size = ImVec2(38.f, 38.f) * scale;
if (ImGui::IsMouseHoveringRect(m_window_pos, m_window_pos + ImVec2(m_window_width, m_window_height), false)) {
// complete text
imgui.push_bold_font();
ImGui::SetCursorScreenPos(ImVec2(pos.x + icon_size.x + ImGui::CalcTextSize(" ").x, pos.y + (icon_size.y - m_line_height) / 2));
imgui.text(m_text1.substr(0, m_endlines[0]).c_str());
imgui.pop_bold_font();
m_before_complete_start = GLCanvas3D::timestamp_now();
}
else {
// timer to close
int64_t now = GLCanvas3D::timestamp_now();
int64_t duration_time = now - m_before_complete_start;
if (duration_time < 1000) {
imgui.push_bold_font();
ImGui::SetCursorScreenPos(ImVec2(pos.x + icon_size.x + ImGui::CalcTextSize(" ").x, pos.y + (icon_size.y - m_line_height) / 2));
imgui.text(m_text1.substr(0, m_endlines[0]).c_str());
imgui.pop_bold_font();
return;
}
if (duration_time > BEFORE_COMPLETE_DURATION) {
set_progress_state(SlicingProgressState::SP_COMPLETED);
return;
}
// complete text
imgui.push_bold_font();
ImGui::SetCursorScreenPos(ImVec2(pos.x + icon_size.x + ImGui::CalcTextSize(" ").x, pos.y));
imgui.text(m_text1.substr(0, m_endlines[0]).c_str());
imgui.pop_bold_font();
// closing text
boost::format fmt(_u8L("Closing in %ds"));
fmt % (4 - duration_time / 1000);
ImGui::PushStyleColor(ImGuiCol_Text, ImColor(144, 144, 144).Value);
ImGui::SetCursorScreenPos(ImVec2(pos.x + icon_size.x + ImGui::CalcTextSize(" ").x, pos.y + m_line_height + m_line_height / 2));
imgui.text(fmt.str());
ImGui::PopStyleColor();
}
// complete text
imgui.push_bold_font();
ImGui::SetCursorScreenPos(ImVec2(pos.x + icon_size.x + ImGui::CalcTextSize(" ").x, pos.y + (icon_size.y - m_line_height) / 2));
imgui.text(m_text1.substr(0, m_endlines[0]).c_str());
imgui.pop_bold_font();
return;
}
else {
if (m_sp_state == SlicingProgressState::SP_CANCELLED) {
imgui.push_bold_font();
ImGui::SetCursorScreenPos(ImVec2(pos.x + ImGui::CalcTextSize(" ").x, pos.y + (icon_size.y - m_line_height) / 2));
imgui.text(m_text1.substr(0, m_endlines[0]).c_str());
imgui.pop_bold_font();
}
if(m_sp_state == SlicingProgressState::SP_PROGRESS) {
//one line text
ImGui::SetCursorScreenPos(pos);
imgui.text(m_text1.substr(0, m_endlines[0]).c_str());
@ -448,10 +391,6 @@ void Slic3r::GUI::NotificationManager::SlicingProgressNotification::render_bar(c
void NotificationManager::SlicingProgressNotification::render_dailytips_panel(const ImVec2& pos, const ImVec2& size)
{
if (m_sp_state == SlicingProgressState::SP_BEFORE_COMPLETED)
m_dailytips_panel->set_can_expand(false);
else
m_dailytips_panel->set_can_expand(true);
m_dailytips_panel->render();
}

View File

@ -17,7 +17,7 @@ public:
SP_BEGAN, // still hidden but allows to go to SP_PROGRESS state. This prevents showing progress after slicing was canceled.
SP_PROGRESS, // never fades outs, no close button, has cancel button
SP_CANCELLED, // fades after 10 seconds, simple message
SP_BEFORE_COMPLETED, // to keep displaying DailyTips for 3 seconds
//SP_BEFORE_COMPLETED, // to keep displaying DailyTips for 3 seconds
SP_COMPLETED // Has export hyperlink and print info, fades after 20 sec if sidebar is shown, otherwise no fade out
};
SlicingProgressNotification(const NotificationData& n, NotificationIDProvider& id_provider, wxEvtHandler* evt_handler, std::function<bool()> callback)