mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-15 22:05:53 +08:00
Textline offset same as Vertical center of text
This commit is contained in:
parent
f51c0e651b
commit
acb3e6dd37
@ -3152,17 +3152,6 @@ void GLGizmoEmboss::draw_advanced()
|
|||||||
m_text_lines.reset();
|
m_text_lines.reset();
|
||||||
m_imgui->disabled_end(); // !can_use_per_glyph
|
m_imgui->disabled_end(); // !can_use_per_glyph
|
||||||
|
|
||||||
// Set offset of slice from base line
|
|
||||||
//m_imgui->disabled_begin(!per_glyph);
|
|
||||||
//ImGui::SameLine();
|
|
||||||
//ImGui::SetNextItemWidth(m_gui_cfg->input_width);
|
|
||||||
//if (m_imgui->slider_float("##base_line_y_offset", &m_text_lines.offset, -10.f, 10.f, "%f mm")) {
|
|
||||||
// reinit_text_lines(m_text_lines.get_lines().size());
|
|
||||||
// process();
|
|
||||||
//} else if (ImGui::IsItemHovered())
|
|
||||||
// ImGui::SetTooltip("TEST PURPOSE ONLY\nMove base line (up/down) for allign letters");
|
|
||||||
//m_imgui->disabled_end(); // !per_glyph
|
|
||||||
|
|
||||||
auto draw_align = [&align = font_prop.align, gui_cfg = m_gui_cfg, &icons = m_icons]() {
|
auto draw_align = [&align = font_prop.align, gui_cfg = m_gui_cfg, &icons = m_icons]() {
|
||||||
bool is_change = false;
|
bool is_change = false;
|
||||||
ImGui::SameLine(gui_cfg->advanced_input_offset);
|
ImGui::SameLine(gui_cfg->advanced_input_offset);
|
||||||
@ -3224,6 +3213,8 @@ void GLGizmoEmboss::draw_advanced()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// input gap between lines
|
// input gap between lines
|
||||||
|
bool is_multiline = m_text_lines.get_lines().size() > 1;
|
||||||
|
m_imgui->disabled_begin(!is_multiline);
|
||||||
auto def_line_gap = stored_style ?
|
auto def_line_gap = stored_style ?
|
||||||
&stored_style->prop.line_gap : nullptr;
|
&stored_style->prop.line_gap : nullptr;
|
||||||
int min_line_gap = -half_ascent, max_line_gap = half_ascent;
|
int min_line_gap = -half_ascent, max_line_gap = half_ascent;
|
||||||
@ -3240,6 +3231,7 @@ void GLGizmoEmboss::draw_advanced()
|
|||||||
exist_change = true;
|
exist_change = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
m_imgui->disabled_end(); // !is_multiline
|
||||||
|
|
||||||
// input boldness
|
// input boldness
|
||||||
auto def_boldness = stored_style ?
|
auto def_boldness = stored_style ?
|
||||||
|
@ -255,7 +255,6 @@ bool get_line_height_offset(const FontProp &fp, const FontFile &ff, double &line
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
void TextLinesModel::init(const Transform3d &text_tr,
|
void TextLinesModel::init(const Transform3d &text_tr,
|
||||||
@ -286,7 +285,9 @@ void TextLinesModel::init(const Transform3d &text_tr,
|
|||||||
m_model.reset();
|
m_model.reset();
|
||||||
m_lines.clear();
|
m_lines.clear();
|
||||||
|
|
||||||
double first_line_center = this->offset + line_height_mm / 3 + get_align_y_offset_in_mm(align, count_lines, ff, fp);
|
// size_in_mm .. contain volume scale and should be ascent value in mm
|
||||||
|
double line_offset = fp.size_in_mm * ascent_ratio_offset;
|
||||||
|
double first_line_center = line_offset + get_align_y_offset_in_mm(align, count_lines, ff, fp);
|
||||||
std::vector<float> line_centers(count_lines);
|
std::vector<float> line_centers(count_lines);
|
||||||
for (size_t i = 0; i < count_lines; ++i)
|
for (size_t i = 0; i < count_lines; ++i)
|
||||||
line_centers[i] = static_cast<float>(first_line_center - i * line_height_mm);
|
line_centers[i] = static_cast<float>(first_line_center - i * line_height_mm);
|
||||||
|
@ -17,9 +17,6 @@ namespace Slic3r::GUI {
|
|||||||
class TextLinesModel
|
class TextLinesModel
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// line offset in y direction (up/down)
|
|
||||||
float offset = 0;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Initialize model and lines
|
/// Initialize model and lines
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -41,6 +38,11 @@ private:
|
|||||||
|
|
||||||
// Keep model for visualization text lines
|
// Keep model for visualization text lines
|
||||||
GLModel m_model;
|
GLModel m_model;
|
||||||
|
|
||||||
|
// Used to move slice (text line) on place where is approx vertical center of text
|
||||||
|
// When copy value const double ASCENT_CENTER from Emboss.cpp and Vertical align is center than
|
||||||
|
// text line will cross object center
|
||||||
|
const double ascent_ratio_offset = 1/3.;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace Slic3r::GUI
|
} // namespace Slic3r::GUI
|
||||||
|
Loading…
x
Reference in New Issue
Block a user