mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-16 05:36:03 +08:00
Add orange border for input when warning appear
This commit is contained in:
parent
7cf99ba430
commit
250f2444fa
@ -1177,22 +1177,6 @@ void GLGizmoEmboss::draw_text_input()
|
|||||||
// when their glyph range is out of language character range
|
// when their glyph range is out of language character range
|
||||||
if (exist_font) ImGui::PushFont(imgui_font);
|
if (exist_font) ImGui::PushFont(imgui_font);
|
||||||
|
|
||||||
// flag for extend font ranges if neccessary
|
|
||||||
// ranges can't be extend during font is activ(pushed)
|
|
||||||
std::string range_text;
|
|
||||||
float window_height = ImGui::GetWindowHeight();
|
|
||||||
float minimal_height = get_minimal_window_size().y;
|
|
||||||
float extra_height = window_height - minimal_height;
|
|
||||||
ImVec2 text_size(m_gui_cfg->text_size.x,
|
|
||||||
m_gui_cfg->text_size.y + extra_height);
|
|
||||||
const ImGuiInputTextFlags flags = ImGuiInputTextFlags_AllowTabInput | ImGuiInputTextFlags_AutoSelectAll;
|
|
||||||
if (ImGui::InputTextMultiline("##Text", &m_text, text_size, flags)) {
|
|
||||||
process();
|
|
||||||
range_text = create_range_text();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (exist_font) ImGui::PopFont();
|
|
||||||
|
|
||||||
// show warning about incorrectness view of font
|
// show warning about incorrectness view of font
|
||||||
std::string warning;
|
std::string warning;
|
||||||
std::string tool_tip;
|
std::string tool_tip;
|
||||||
@ -1211,35 +1195,48 @@ void GLGizmoEmboss::draw_text_input()
|
|||||||
tool_tip += t;
|
tool_tip += t;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if (is_text_empty(m_text))
|
if (is_text_empty(m_text)) append_warning(_u8L("Empty"), _u8L("Embossed text can NOT contain only white spaces."));
|
||||||
append_warning(_u8L("Empty"),
|
|
||||||
_u8L("Embossed text can NOT contain only white spaces."));
|
|
||||||
if (m_text_contain_unknown_glyph)
|
if (m_text_contain_unknown_glyph)
|
||||||
append_warning(_u8L("Bad symbol"),
|
append_warning(_u8L("Bad symbol"), _u8L("Text contain character glyph (represented by '?') unknown by font."));
|
||||||
_u8L("Text contain character glyph (represented by '?') unknown by font."));
|
|
||||||
|
|
||||||
const FontProp &prop = m_style_manager.get_font_prop();
|
const FontProp &prop = m_style_manager.get_font_prop();
|
||||||
if (prop.skew.has_value())
|
if (prop.skew.has_value()) append_warning(_u8L("Skew"), _u8L("Unsupported visualization of font skew for text input."));
|
||||||
append_warning(_u8L("Skew"),
|
if (prop.boldness.has_value()) append_warning(_u8L("Boldness"), _u8L("Unsupported visualization of font boldness for text input."));
|
||||||
_u8L("Unsupported visualization of font skew for text input."));
|
|
||||||
if (prop.boldness.has_value())
|
|
||||||
append_warning(_u8L("Boldness"),
|
|
||||||
_u8L("Unsupported visualization of font boldness for text input."));
|
|
||||||
if (prop.line_gap.has_value())
|
if (prop.line_gap.has_value())
|
||||||
append_warning(_u8L("Line gap"),
|
append_warning(_u8L("Line gap"), _u8L("Unsupported visualization of gap between lines inside text input."));
|
||||||
_u8L("Unsupported visualization of gap between lines inside text input."));
|
|
||||||
auto &ff = m_style_manager.get_font_file_with_cache();
|
auto &ff = m_style_manager.get_font_file_with_cache();
|
||||||
float imgui_size = EmbossStyleManager::get_imgui_font_size(prop, *ff.font_file);
|
float imgui_size = EmbossStyleManager::get_imgui_font_size(prop, *ff.font_file);
|
||||||
if (imgui_size > EmbossStyleManager::max_imgui_font_size)
|
if (imgui_size > EmbossStyleManager::max_imgui_font_size)
|
||||||
append_warning(_u8L("To tall"),
|
append_warning(_u8L("To tall"), _u8L("Diminished font height inside text input."));
|
||||||
_u8L("Diminished font height inside text input."));
|
|
||||||
if (imgui_size < EmbossStyleManager::min_imgui_font_size)
|
if (imgui_size < EmbossStyleManager::min_imgui_font_size)
|
||||||
append_warning(_u8L("To small"),
|
append_warning(_u8L("To small"), _u8L("Enlarged font height inside text input."));
|
||||||
_u8L("Enlarged font height inside text input."));
|
if (!who.empty()) warning = GUI::format(_L("%1% is NOT shown."), who);
|
||||||
if (!who.empty())
|
|
||||||
warning = GUI::format(_L("%1% is NOT shown."), who);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// add border around input when warning appears
|
||||||
|
ScopeGuard input_border_sg;
|
||||||
|
if (!warning.empty()) {
|
||||||
|
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.0f);
|
||||||
|
ImGui::PushStyleColor(ImGuiCol_Border, ImGuiWrapper::COL_ORANGE_LIGHT);
|
||||||
|
input_border_sg = ScopeGuard([]() { ImGui::PopStyleColor(); ImGui::PopStyleVar(); });
|
||||||
|
}
|
||||||
|
|
||||||
|
// flag for extend font ranges if neccessary
|
||||||
|
// ranges can't be extend during font is activ(pushed)
|
||||||
|
std::string range_text;
|
||||||
|
float window_height = ImGui::GetWindowHeight();
|
||||||
|
float minimal_height = get_minimal_window_size().y;
|
||||||
|
float extra_height = window_height - minimal_height;
|
||||||
|
ImVec2 text_size(m_gui_cfg->text_size.x,
|
||||||
|
m_gui_cfg->text_size.y + extra_height);
|
||||||
|
const ImGuiInputTextFlags flags = ImGuiInputTextFlags_AllowTabInput | ImGuiInputTextFlags_AutoSelectAll;
|
||||||
|
if (ImGui::InputTextMultiline("##Text", &m_text, text_size, flags)) {
|
||||||
|
process();
|
||||||
|
range_text = create_range_text();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (exist_font) ImGui::PopFont();
|
||||||
|
|
||||||
if (!warning.empty()) {
|
if (!warning.empty()) {
|
||||||
if (ImGui::IsItemHovered() && !tool_tip.empty())
|
if (ImGui::IsItemHovered() && !tool_tip.empty())
|
||||||
ImGui::SetTooltip("%s", tool_tip.c_str());
|
ImGui::SetTooltip("%s", tool_tip.c_str());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user