mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-07-20 22:24:29 +08:00
Notifications: Calculating space left for hypertext with escaped text
This commit is contained in:
parent
dfa11781c3
commit
14efdca4b4
@ -7,6 +7,7 @@
|
|||||||
#include "ImGuiWrapper.hpp"
|
#include "ImGuiWrapper.hpp"
|
||||||
|
|
||||||
#include "wxExtensions.hpp"
|
#include "wxExtensions.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>
|
||||||
@ -443,8 +444,8 @@ void NotificationManager::PopNotification::init()
|
|||||||
}
|
}
|
||||||
// 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++;
|
||||||
}
|
}
|
||||||
@ -492,7 +493,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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user