Merge branch 'dk_notifications'

This commit is contained in:
David Kocik 2021-05-20 13:10:06 +02:00
commit 7ad482f63c

View File

@ -6,6 +6,7 @@
#include "PrintHostDialogs.hpp" #include "PrintHostDialogs.hpp"
#include "wxExtensions.hpp" #include "wxExtensions.hpp"
#include "../Utils/PrintHost.hpp" #include "../Utils/PrintHost.hpp"
#include "libslic3r/Config.hpp"
#include <boost/algorithm/string.hpp> #include <boost/algorithm/string.hpp>
#include <boost/log/trivial.hpp> #include <boost/log/trivial.hpp>
@ -304,8 +305,8 @@ void NotificationManager::PopNotification::count_lines()
} }
// hypertext calculation // hypertext calculation
if (!m_hypertext.empty()) { if (!m_hypertext.empty()) {
int prev_end = m_endlines.size() > 1 ? m_endlines[m_endlines.size() - 2] : 0; int prev_end = m_endlines.size() > 1 ? m_endlines[m_endlines.size() - 2] : 0; // m_endlines.size() - 2 because we are fitting hypertext instead of last endline
if (ImGui::CalcTextSize((text.substr(prev_end, last_end - prev_end) + m_hypertext).c_str()).x > m_window_width - m_window_width_offset) { if (ImGui::CalcTextSize((escape_string_cstyle(text.substr(prev_end, last_end - prev_end)) + m_hypertext).c_str()).x > m_window_width - m_window_width_offset) {
m_endlines.push_back(last_end); m_endlines.push_back(last_end);
m_lines_count++; m_lines_count++;
} }
@ -366,7 +367,7 @@ void NotificationManager::PopNotification::render_text(ImGuiWrapper& imgui, cons
} }
//hyperlink text //hyperlink text
if (!m_hypertext.empty()) { if (!m_hypertext.empty()) {
render_hypertext(imgui, x_offset + ImGui::CalcTextSize((line + " ").c_str()).x, starting_y + (m_lines_count - 1) * shift_y, m_hypertext); render_hypertext(imgui, x_offset + ImGui::CalcTextSize((line + (line.empty() ? "" : " ")).c_str()).x, starting_y + (m_lines_count - 1) * shift_y, m_hypertext);
} }