Escape ## in name of style in imgui visualization(issue 61)
This commit is contained in:
parent
6e15149e7a
commit
3bd557b177
4 changed files with 24 additions and 3 deletions
|
@ -1778,7 +1778,8 @@ void GLGizmoEmboss::draw_style_list() {
|
|||
std::string &trunc_name = m_style_manager.get_truncated_name();
|
||||
if (trunc_name.empty()) {
|
||||
// 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);
|
||||
}
|
||||
|
||||
|
|
|
@ -1365,6 +1365,16 @@ std::string ImGuiWrapper::trunc(const std::string &text,
|
|||
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,
|
||||
const Slic3r::Polygon &interest,
|
||||
const ImVec2 &canvas_size)
|
||||
|
|
|
@ -167,6 +167,13 @@ public:
|
|||
float width,
|
||||
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>
|
||||
/// Suggest loacation of dialog window,
|
||||
/// 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) {
|
||||
for (auto &s : m_style_items)
|
||||
if (s.truncated_name.empty())
|
||||
s.truncated_name = ImGuiWrapper::trunc(s.style.name, max_width);
|
||||
if (s.truncated_name.empty()) {
|
||||
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"
|
||||
|
|
Loading…
Reference in a new issue