mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-14 10:55:55 +08:00
Escape ## in name of style in imgui visualization(issue 61)
This commit is contained in:
parent
6e15149e7a
commit
3bd557b177
@ -1778,7 +1778,8 @@ void GLGizmoEmboss::draw_style_list() {
|
|||||||
std::string &trunc_name = m_style_manager.get_truncated_name();
|
std::string &trunc_name = m_style_manager.get_truncated_name();
|
||||||
if (trunc_name.empty()) {
|
if (trunc_name.empty()) {
|
||||||
// generate trunc name
|
// generate trunc name
|
||||||
const std::string ¤t_name = actual_style.name;
|
std::string current_name = actual_style.name;
|
||||||
|
ImGuiWrapper::escape_double_hash(current_name);
|
||||||
trunc_name = ImGuiWrapper::trunc(current_name, max_style_name_width);
|
trunc_name = ImGuiWrapper::trunc(current_name, max_style_name_width);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1365,6 +1365,16 @@ std::string ImGuiWrapper::trunc(const std::string &text,
|
|||||||
return std::string(result_text) + tail;
|
return std::string(result_text) + tail;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ImGuiWrapper::escape_double_hash(std::string &text)
|
||||||
|
{
|
||||||
|
// add space between hashes
|
||||||
|
const std::string search = "##";
|
||||||
|
const std::string replace = "# #";
|
||||||
|
size_t pos = 0;
|
||||||
|
while ((pos = text.find(search, pos)) != std::string::npos)
|
||||||
|
text.replace(pos, search.length(), replace);
|
||||||
|
}
|
||||||
|
|
||||||
ImVec2 ImGuiWrapper::suggest_location(const ImVec2 &dialog_size,
|
ImVec2 ImGuiWrapper::suggest_location(const ImVec2 &dialog_size,
|
||||||
const Slic3r::Polygon &interest,
|
const Slic3r::Polygon &interest,
|
||||||
const ImVec2 &canvas_size)
|
const ImVec2 &canvas_size)
|
||||||
|
@ -167,6 +167,13 @@ public:
|
|||||||
float width,
|
float width,
|
||||||
const char *tail = " ..");
|
const char *tail = " ..");
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Escape ## in data by add space between hashes
|
||||||
|
/// Needed when user written text is visualized by ImGui.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="text">In/Out text to be escaped</param>
|
||||||
|
static void escape_double_hash(std::string &text);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Suggest loacation of dialog window,
|
/// Suggest loacation of dialog window,
|
||||||
/// dependent on actual visible thing on platter
|
/// dependent on actual visible thing on platter
|
||||||
|
@ -278,8 +278,11 @@ void EmbossStyleManager::make_unique_name(std::string &name)
|
|||||||
|
|
||||||
void EmbossStyleManager::init_trunc_names(float max_width) {
|
void EmbossStyleManager::init_trunc_names(float max_width) {
|
||||||
for (auto &s : m_style_items)
|
for (auto &s : m_style_items)
|
||||||
if (s.truncated_name.empty())
|
if (s.truncated_name.empty()) {
|
||||||
s.truncated_name = ImGuiWrapper::trunc(s.style.name, max_width);
|
std::string name = s.style.name;
|
||||||
|
ImGuiWrapper::escape_double_hash(name);
|
||||||
|
s.truncated_name = ImGuiWrapper::trunc(name, max_width);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#include "slic3r/GUI/Jobs/CreateFontStyleImagesJob.hpp"
|
#include "slic3r/GUI/Jobs/CreateFontStyleImagesJob.hpp"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user