mirror of
https://git.mirrors.martin98.com/https://github.com/prusa3d/PrusaSlicer.git
synced 2025-08-15 01:15:55 +08:00
Change GUI of emboss
This commit is contained in:
parent
f4376273c0
commit
48420b33d0
@ -91,15 +91,23 @@ struct Limits
|
|||||||
MinMax<float> angle{-180.f, 180.f}; // in mm
|
MinMax<float> angle{-180.f, 180.f}; // in mm
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static void apply(std::optional<T> &val, const MinMax<T> &limit) {
|
static bool apply(std::optional<T> &val, const MinMax<T> &limit) {
|
||||||
if (val.has_value())
|
if (val.has_value())
|
||||||
apply<T>(*val, limit);
|
return apply<T>(*val, limit);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
template<typename T>
|
template<typename T>
|
||||||
static void apply(T &val, const MinMax<T> &limit)
|
static bool apply(T &val, const MinMax<T> &limit)
|
||||||
{
|
{
|
||||||
if (val > limit.max) val = limit.max;
|
if (val > limit.max) {
|
||||||
if (val < limit.min) val = limit.min;
|
val = limit.max;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (val < limit.min) {
|
||||||
|
val = limit.min;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
static const Limits limits;
|
static const Limits limits;
|
||||||
@ -644,27 +652,26 @@ void GLGizmoEmboss::initialize()
|
|||||||
|
|
||||||
float icon_width_with_spacing = cfg.icon_width + space;
|
float icon_width_with_spacing = cfg.icon_width + space;
|
||||||
float scroll_width = icon_width_with_spacing; // TODO: fix it
|
float scroll_width = icon_width_with_spacing; // TODO: fix it
|
||||||
cfg.style_combobox_width = cfg.max_font_name_width + space
|
|
||||||
+ icon_width_with_spacing
|
|
||||||
+ scroll_width;
|
|
||||||
cfg.delete_pos_x = cfg.max_font_name_width + space;
|
cfg.delete_pos_x = cfg.max_font_name_width + space;
|
||||||
int count_line_of_text = 3;
|
int count_line_of_text = 3;
|
||||||
cfg.text_size = ImVec2(-FLT_MIN, line_height_with_spacing * count_line_of_text);
|
cfg.text_size = ImVec2(-FLT_MIN, line_height_with_spacing * count_line_of_text);
|
||||||
ImVec2 letter_m_size = ImGui::CalcTextSize("M");
|
ImVec2 letter_m_size = ImGui::CalcTextSize("M");
|
||||||
int count_letter_M_in_input = 12;
|
int count_letter_M_in_input = 12;
|
||||||
cfg.advanced_input_width = letter_m_size.x * count_letter_M_in_input;
|
cfg.input_width = letter_m_size.x * count_letter_M_in_input;
|
||||||
GuiCfg::Translations &tr = cfg.translations;
|
GuiCfg::Translations &tr = cfg.translations;
|
||||||
tr.font = _u8L("Font");
|
tr.type = _u8L("Type");
|
||||||
tr.size = _u8L("Height");
|
tr.style = _u8L("Style");
|
||||||
tr.depth = _u8L("Depth");
|
tr.font = _u8L("Font");
|
||||||
float max_edit_text_width = std::max({
|
tr.size = _u8L("Height");
|
||||||
|
tr.depth = _u8L("Depth");
|
||||||
|
float max_text_width = std::max({
|
||||||
|
ImGui::CalcTextSize(tr.type.c_str()).x,
|
||||||
|
ImGui::CalcTextSize(tr.style.c_str()).x,
|
||||||
ImGui::CalcTextSize(tr.font.c_str()).x,
|
ImGui::CalcTextSize(tr.font.c_str()).x,
|
||||||
ImGui::CalcTextSize(tr.size.c_str()).x,
|
ImGui::CalcTextSize(tr.size.c_str()).x,
|
||||||
ImGui::CalcTextSize(tr.depth.c_str()).x });
|
ImGui::CalcTextSize(tr.depth.c_str()).x});
|
||||||
cfg.edit_input_offset =
|
cfg.input_offset = max_text_width + 3 * space + ImGui::GetTreeNodeToLabelSpacing();
|
||||||
3 * space + ImGui::GetTreeNodeToLabelSpacing() +
|
|
||||||
max_edit_text_width;
|
|
||||||
|
|
||||||
tr.use_surface = _u8L("Use surface");
|
tr.use_surface = _u8L("Use surface");
|
||||||
tr.char_gap = _u8L("Char gap");
|
tr.char_gap = _u8L("Char gap");
|
||||||
tr.line_gap = _u8L("Line gap");
|
tr.line_gap = _u8L("Line gap");
|
||||||
@ -693,22 +700,19 @@ void GLGizmoEmboss::initialize()
|
|||||||
float window_height =
|
float window_height =
|
||||||
window_title + // window title
|
window_title + // window title
|
||||||
cfg.text_size.y + // text field
|
cfg.text_size.y + // text field
|
||||||
input_height * 3 + // type Radios + style selector + close button
|
input_height * 6 + // type Radios + style selector + font name +
|
||||||
tree_header + // Edit style
|
// height + depth + close button
|
||||||
|
tree_header + // advance tree
|
||||||
2 * style.WindowPadding.y;
|
2 * style.WindowPadding.y;
|
||||||
float window_width = cfg.style_combobox_width + style.WindowPadding.x * 2;
|
float window_width = cfg.input_offset + cfg.input_width + style.WindowPadding.x * 2;
|
||||||
cfg.minimal_window_size = ImVec2(window_width, window_height);
|
cfg.minimal_window_size = ImVec2(window_width, window_height);
|
||||||
|
|
||||||
float addition_edit_height = input_height * 3 + tree_header;
|
|
||||||
cfg.minimal_window_size_with_edit = ImVec2(cfg.minimal_window_size.x,
|
|
||||||
cfg.minimal_window_size.y +
|
|
||||||
addition_edit_height);
|
|
||||||
// 6 = charGap, LineGap, Bold, italic, surfDist, angle
|
// 6 = charGap, LineGap, Bold, italic, surfDist, angle
|
||||||
// 4 = 1px for fix each edit image of drag float
|
// 4 = 1px for fix each edit image of drag float
|
||||||
float advance_height = input_height * 7 + 8;
|
float advance_height = input_height * 7 + 8;
|
||||||
cfg.minimal_window_size_with_advance =
|
cfg.minimal_window_size_with_advance =
|
||||||
ImVec2(cfg.minimal_window_size_with_edit.x,
|
ImVec2(cfg.minimal_window_size.x,
|
||||||
cfg.minimal_window_size_with_edit.y + advance_height);
|
cfg.minimal_window_size.y + advance_height);
|
||||||
|
|
||||||
cfg.min_style_image_height = line_height_with_spacing;
|
cfg.min_style_image_height = line_height_with_spacing;
|
||||||
cfg.max_style_image_width = cfg.max_font_name_width -
|
cfg.max_style_image_width = cfg.max_font_name_width -
|
||||||
@ -1058,26 +1062,26 @@ void GLGizmoEmboss::draw_window()
|
|||||||
draw_text_input();
|
draw_text_input();
|
||||||
draw_model_type();
|
draw_model_type();
|
||||||
draw_style_list();
|
draw_style_list();
|
||||||
|
|
||||||
m_imgui->disabled_begin(!is_selected_style);
|
m_imgui->disabled_begin(!is_selected_style);
|
||||||
if (ImGui::TreeNode(_u8L("Edit style").c_str())) {
|
ImGui::TreePush();
|
||||||
|
draw_style_edit();
|
||||||
#ifdef SHOW_WX_FONT_DESCRIPTOR
|
ImGui::TreePop();
|
||||||
ImGui::SameLine();
|
if (ImGui::TreeNode(_u8L("advanced").c_str())) {
|
||||||
if (m_font_manager.is_activ_font())
|
if (!m_is_advanced_edit_style) {
|
||||||
m_imgui->text_colored(ImGuiWrapper::COL_GREY_DARK, m_font_manager.get_font_item().path);
|
set_minimal_window_size(true);
|
||||||
#endif // SHOW_WX_FONT_DESCRIPTOR
|
|
||||||
if (!m_is_edit_style) {
|
|
||||||
set_minimal_window_size(true, m_is_advanced_edit_style);
|
|
||||||
} else {
|
} else {
|
||||||
draw_style_edit();
|
draw_advanced();
|
||||||
}
|
}
|
||||||
ImGui::TreePop();
|
ImGui::TreePop();
|
||||||
} else if (m_is_edit_style)
|
} else if (m_is_advanced_edit_style)
|
||||||
set_minimal_window_size(false, m_is_advanced_edit_style);
|
set_minimal_window_size(false);
|
||||||
|
|
||||||
m_imgui->disabled_end(); // !is_selected_style
|
m_imgui->disabled_end(); // !is_selected_style
|
||||||
|
|
||||||
|
#ifdef SHOW_WX_FONT_DESCRIPTOR
|
||||||
|
if (is_selected_style)
|
||||||
|
m_imgui->text_colored(ImGuiWrapper::COL_GREY_DARK, m_font_manager.get_font_item().path);
|
||||||
|
#endif // SHOW_WX_FONT_DESCRIPTOR
|
||||||
|
|
||||||
if (ImGui::Button(_u8L("Close").c_str())) close();
|
if (ImGui::Button(_u8L("Close").c_str())) close();
|
||||||
|
|
||||||
// Option to create text volume when reselecting volumes
|
// Option to create text volume when reselecting volumes
|
||||||
@ -1377,8 +1381,8 @@ void GLGizmoEmboss::draw_model_type()
|
|||||||
ModelVolumeType::INVALID;
|
ModelVolumeType::INVALID;
|
||||||
|
|
||||||
bool is_last_solid_part = is_text_object(m_volume);
|
bool is_last_solid_part = is_text_object(m_volume);
|
||||||
ImGui::Text("%s :", _u8L("Type").c_str());
|
ImGui::Text("%s", m_gui_cfg->translations.type.c_str());
|
||||||
ImGui::SameLine(75);
|
ImGui::SameLine(m_gui_cfg->input_offset);
|
||||||
if (type == part) {
|
if (type == part) {
|
||||||
draw_icon(IconType::part, IconState::hovered);
|
draw_icon(IconType::part, IconState::hovered);
|
||||||
} else {
|
} else {
|
||||||
@ -1500,8 +1504,9 @@ void GLGizmoEmboss::draw_style_list() {
|
|||||||
const std::string ¤t_name = actual_font_item.name;
|
const std::string ¤t_name = actual_font_item.name;
|
||||||
trunc_name = ImGuiWrapper::trunc(current_name, max_width);
|
trunc_name = ImGuiWrapper::trunc(current_name, max_width);
|
||||||
}
|
}
|
||||||
|
ImGui::Text("%s", m_gui_cfg->translations.style.c_str());
|
||||||
ImGui::SetNextItemWidth(m_gui_cfg->style_combobox_width);
|
ImGui::SameLine(m_gui_cfg->input_offset);
|
||||||
|
ImGui::SetNextItemWidth(m_gui_cfg->input_width);
|
||||||
if (ImGui::BeginCombo("##style_selector", trunc_name.c_str())) {
|
if (ImGui::BeginCombo("##style_selector", trunc_name.c_str())) {
|
||||||
m_font_manager.init_style_images(m_gui_cfg->max_style_image_width);
|
m_font_manager.init_style_images(m_gui_cfg->max_style_image_width);
|
||||||
const auto &fonts = m_font_manager.get_fonts();
|
const auto &fonts = m_font_manager.get_fonts();
|
||||||
@ -1605,52 +1610,58 @@ void GLGizmoEmboss::draw_style_list() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_stored && is_changed) {
|
ImGui::SameLine();
|
||||||
ImGui::SameLine();
|
bool can_undo = is_stored && is_changed;
|
||||||
if (draw_button(IconType::undo)) {
|
if (draw_button(IconType::undo, !can_undo)) {
|
||||||
bool is_path_changed = font_item.path != m_stored_font_item->path;
|
bool is_path_changed = font_item.path != m_stored_font_item->path;
|
||||||
|
|
||||||
// is rotation changed
|
// is rotation changed
|
||||||
auto &angle = font_item.prop.angle;
|
auto &angle = font_item.prop.angle;
|
||||||
const auto &angle_ = m_stored_font_item->prop.angle;
|
const auto &angle_ = m_stored_font_item->prop.angle;
|
||||||
// TODO: compare with approx
|
// TODO: compare with approx
|
||||||
if (angle.has_value() != angle_.has_value() ||
|
if (angle.has_value() != angle_.has_value() ||
|
||||||
(angle.has_value() && !is_approx(*angle, *angle_))) {
|
(angle.has_value() && !is_approx(*angle, *angle_))) {
|
||||||
auto &tc = m_volume->text_configuration;
|
auto &tc = m_volume->text_configuration;
|
||||||
if (m_volume != nullptr && tc.has_value()) {
|
if (m_volume != nullptr && tc.has_value()) {
|
||||||
// change actual text configuration
|
// change actual text configuration
|
||||||
tc->font_item.prop.angle = angle_;
|
tc->font_item.prop.angle = angle_;
|
||||||
float act_angle = angle_.has_value() ? *angle_ : .0f;
|
float act_angle = angle_.has_value() ? *angle_ : .0f;
|
||||||
float prev_angle = angle.has_value() ? *angle : .0f;
|
float prev_angle = angle.has_value() ? *angle : .0f;
|
||||||
do_rotate(act_angle - prev_angle);
|
do_rotate(act_angle - prev_angle);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// is distance changed
|
// is distance changed
|
||||||
auto &distance = font_item.prop.distance;
|
auto &distance = font_item.prop.distance;
|
||||||
const auto &distance_ = m_stored_font_item->prop.distance;
|
const auto &distance_ = m_stored_font_item->prop.distance;
|
||||||
if (distance.has_value() != distance_.has_value() ||
|
if (distance.has_value() != distance_.has_value() ||
|
||||||
(distance.has_value() && !is_approx(*distance, *distance_))) {
|
(distance.has_value() && !is_approx(*distance, *distance_))) {
|
||||||
auto &tc = m_volume->text_configuration;
|
auto &tc = m_volume->text_configuration;
|
||||||
if (m_volume != nullptr && tc.has_value()) {
|
if (m_volume != nullptr && tc.has_value()) {
|
||||||
tc->font_item.prop.distance = distance_;
|
tc->font_item.prop.distance = distance_;
|
||||||
float act_distance = distance_.has_value() ? *distance_ : .0f;
|
float act_distance = distance_.has_value() ? *distance_ : .0f;
|
||||||
float prev_distance = distance.has_value() ? *distance : .0f;
|
float prev_distance = distance.has_value() ? *distance : .0f;
|
||||||
do_translate(Vec3d::UnitZ() * (act_distance - prev_distance));
|
do_translate(Vec3d::UnitZ() * (act_distance - prev_distance));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
font_item = *m_stored_font_item;
|
font_item = *m_stored_font_item;
|
||||||
if (is_path_changed) {
|
if (is_path_changed) {
|
||||||
m_font_manager.get_wx_font() = WxFontUtils::load_wxFont(font_item.path);
|
m_font_manager.get_wx_font() = WxFontUtils::load_wxFont(font_item.path);
|
||||||
m_font_manager.wx_font_changed();
|
m_font_manager.wx_font_changed();
|
||||||
}
|
}
|
||||||
m_font_manager.free_style_images();
|
m_font_manager.free_style_images();
|
||||||
process();
|
process();
|
||||||
} else if (ImGui::IsItemHovered())
|
} else if (ImGui::IsItemHovered()) {
|
||||||
|
if (can_undo)
|
||||||
ImGui::SetTooltip("%s", _u8L("Reload stored values of selected style").c_str());
|
ImGui::SetTooltip("%s", _u8L("Reload stored values of selected style").c_str());
|
||||||
|
else if (!is_stored)
|
||||||
|
ImGui::SetTooltip("%s", _u8L("Nothing to reload from").c_str());
|
||||||
|
else if (!is_changed)
|
||||||
|
ImGui::SetTooltip("%s", _u8L("Everything is already restored").c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#ifdef ALLOW_REVERT_ALL_STYLES
|
#ifdef ALLOW_REVERT_ALL_STYLES
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
if (draw_button(IconType::revert_all)) {
|
if (draw_button(IconType::revert_all)) {
|
||||||
@ -1792,8 +1803,8 @@ bool GLGizmoEmboss::rev_input(const std::string &name,
|
|||||||
{
|
{
|
||||||
// draw offseted input
|
// draw offseted input
|
||||||
auto draw_offseted_input = [&]()->bool{
|
auto draw_offseted_input = [&]()->bool{
|
||||||
float input_offset = m_gui_cfg->edit_input_offset;
|
float input_offset = m_gui_cfg->input_offset;
|
||||||
float input_width = m_gui_cfg->advanced_input_width;
|
float input_width = m_gui_cfg->input_width;
|
||||||
ImGui::SameLine(input_offset);
|
ImGui::SameLine(input_offset);
|
||||||
ImGui::SetNextItemWidth(input_width);
|
ImGui::SetNextItemWidth(input_width);
|
||||||
return ImGui::InputFloat(("##" + name).c_str(),
|
return ImGui::InputFloat(("##" + name).c_str(),
|
||||||
@ -1844,8 +1855,8 @@ void GLGizmoEmboss::draw_style_edit() {
|
|||||||
ImGuiWrapper::text_colored(ImGuiWrapper::COL_ORANGE_LIGHT, tr.font);
|
ImGuiWrapper::text_colored(ImGuiWrapper::COL_ORANGE_LIGHT, tr.font);
|
||||||
else
|
else
|
||||||
ImGuiWrapper::text(tr.font);
|
ImGuiWrapper::text(tr.font);
|
||||||
ImGui::SameLine(m_gui_cfg->edit_input_offset);
|
ImGui::SameLine(m_gui_cfg->input_offset);
|
||||||
ImGui::SetNextItemWidth(m_gui_cfg->advanced_input_width);
|
ImGui::SetNextItemWidth(m_gui_cfg->input_width);
|
||||||
draw_font_list();
|
draw_font_list();
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
bool exist_change = false;
|
bool exist_change = false;
|
||||||
@ -1878,21 +1889,28 @@ void GLGizmoEmboss::draw_style_edit() {
|
|||||||
// size can't be zero or negative
|
// size can't be zero or negative
|
||||||
Limits::apply(font_prop.size_in_mm, limits.size_in_mm);
|
Limits::apply(font_prop.size_in_mm, limits.size_in_mm);
|
||||||
|
|
||||||
// store font size into path
|
// only different value need process
|
||||||
if (fi.type == WxFontUtils::get_actual_type()) {
|
if (m_volume != nullptr &&
|
||||||
if (wx_font.has_value()) {
|
m_volume->text_configuration.has_value() &&
|
||||||
wx_font->SetPointSize(static_cast<int>(font_prop.size_in_mm));
|
!is_approx(font_prop.size_in_mm, m_volume->text_configuration->font_item.prop.size_in_mm)) {
|
||||||
m_font_manager.wx_font_changed();
|
|
||||||
|
// store font size into path
|
||||||
|
if (fi.type == WxFontUtils::get_actual_type()) {
|
||||||
|
if (wx_font.has_value()) {
|
||||||
|
wx_font->SetPointSize(
|
||||||
|
static_cast<int>(font_prop.size_in_mm));
|
||||||
|
m_font_manager.wx_font_changed();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
process();
|
||||||
}
|
}
|
||||||
process();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SHOW_WX_WEIGHT_INPUT
|
#ifdef SHOW_WX_WEIGHT_INPUT
|
||||||
if (wx_font.has_value()) {
|
if (wx_font.has_value()) {
|
||||||
ImGui::Text("%s", "weight");
|
ImGui::Text("%s", "weight");
|
||||||
ImGui::SameLine(m_gui_cfg->edit_input_offset);
|
ImGui::SameLine(m_gui_cfg->input_offset);
|
||||||
ImGui::SetNextItemWidth(m_gui_cfg->advanced_input_width);
|
ImGui::SetNextItemWidth(m_gui_cfg->input_width);
|
||||||
int weight = wx_font->GetNumericWeight();
|
int weight = wx_font->GetNumericWeight();
|
||||||
int min_weight = 1, max_weight = 1000;
|
int min_weight = 1, max_weight = 1000;
|
||||||
if (ImGui::SliderInt("##weight", &weight, min_weight, max_weight)) {
|
if (ImGui::SliderInt("##weight", &weight, min_weight, max_weight)) {
|
||||||
@ -1920,17 +1938,7 @@ void GLGizmoEmboss::draw_style_edit() {
|
|||||||
_u8L("Revert embossed depth."), 0.1f, 0.25, "%.2f mm")) {
|
_u8L("Revert embossed depth."), 0.1f, 0.25, "%.2f mm")) {
|
||||||
Limits::apply(font_prop.emboss, limits.emboss);
|
Limits::apply(font_prop.emboss, limits.emboss);
|
||||||
process();
|
process();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ImGui::TreeNode(_u8L("advanced").c_str())) {
|
|
||||||
if (!m_is_advanced_edit_style) {
|
|
||||||
set_minimal_window_size(true, true);
|
|
||||||
} else {
|
|
||||||
draw_advanced();
|
|
||||||
}
|
|
||||||
ImGui::TreePop();
|
|
||||||
} else if (m_is_advanced_edit_style)
|
|
||||||
set_minimal_window_size(true, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GLGizmoEmboss::rev_slider(const std::string &name,
|
bool GLGizmoEmboss::rev_slider(const std::string &name,
|
||||||
@ -1944,14 +1952,13 @@ bool GLGizmoEmboss::rev_slider(const std::string &name,
|
|||||||
{
|
{
|
||||||
auto draw_slider_optional_int = [&]() -> bool {
|
auto draw_slider_optional_int = [&]() -> bool {
|
||||||
float slider_offset = m_gui_cfg->advanced_input_offset;
|
float slider_offset = m_gui_cfg->advanced_input_offset;
|
||||||
float slider_width = m_gui_cfg->advanced_input_width;
|
float slider_width = m_gui_cfg->input_width;
|
||||||
ImGui::SameLine(slider_offset);
|
ImGui::SameLine(slider_offset);
|
||||||
ImGui::SetNextItemWidth(slider_width);
|
ImGui::SetNextItemWidth(slider_width);
|
||||||
return m_imgui->slider_optional_int( ("##" + name).c_str(), value,
|
return m_imgui->slider_optional_int( ("##" + name).c_str(), value,
|
||||||
v_min, v_max, format.c_str(), 1.f, false, tooltip);
|
v_min, v_max, format.c_str(), 1.f, false, tooltip);
|
||||||
};
|
};
|
||||||
float undo_offset = ImGui::GetStyle().FramePadding.x +
|
float undo_offset = ImGui::GetStyle().FramePadding.x;
|
||||||
ImGui::GetTreeNodeToLabelSpacing();
|
|
||||||
bool exist_change = default_value != nullptr ? (value != *default_value) : false;
|
bool exist_change = default_value != nullptr ? (value != *default_value) : false;
|
||||||
return revertible(name, value, default_value, exist_change,
|
return revertible(name, value, default_value, exist_change,
|
||||||
undo_tooltip, undo_offset, draw_slider_optional_int);
|
undo_tooltip, undo_offset, draw_slider_optional_int);
|
||||||
@ -1968,14 +1975,13 @@ bool GLGizmoEmboss::rev_slider(const std::string &name,
|
|||||||
{
|
{
|
||||||
auto draw_slider_optional_float = [&]() -> bool {
|
auto draw_slider_optional_float = [&]() -> bool {
|
||||||
float slider_offset = m_gui_cfg->advanced_input_offset;
|
float slider_offset = m_gui_cfg->advanced_input_offset;
|
||||||
float slider_width = m_gui_cfg->advanced_input_width;
|
float slider_width = m_gui_cfg->input_width;
|
||||||
ImGui::SameLine(slider_offset);
|
ImGui::SameLine(slider_offset);
|
||||||
ImGui::SetNextItemWidth(slider_width);
|
ImGui::SetNextItemWidth(slider_width);
|
||||||
return m_imgui->slider_optional_float(("##" + name).c_str(), value,
|
return m_imgui->slider_optional_float(("##" + name).c_str(), value,
|
||||||
v_min, v_max, format.c_str(), 1.f, false, tooltip);
|
v_min, v_max, format.c_str(), 1.f, false, tooltip);
|
||||||
};
|
};
|
||||||
float undo_offset = ImGui::GetStyle().FramePadding.x +
|
float undo_offset = ImGui::GetStyle().FramePadding.x;
|
||||||
ImGui::GetTreeNodeToLabelSpacing();
|
|
||||||
bool exist_change = (default_value != nullptr)?
|
bool exist_change = (default_value != nullptr)?
|
||||||
(!is_approx(value, *default_value)) : false;
|
(!is_approx(value, *default_value)) : false;
|
||||||
return revertible(name, value, default_value, exist_change,
|
return revertible(name, value, default_value, exist_change,
|
||||||
@ -1993,14 +1999,13 @@ bool GLGizmoEmboss::rev_slider(const std::string &name,
|
|||||||
{
|
{
|
||||||
auto draw_slider_float = [&]() -> bool {
|
auto draw_slider_float = [&]() -> bool {
|
||||||
float slider_offset = m_gui_cfg->advanced_input_offset;
|
float slider_offset = m_gui_cfg->advanced_input_offset;
|
||||||
float slider_width = m_gui_cfg->advanced_input_width;
|
float slider_width = m_gui_cfg->input_width;
|
||||||
ImGui::SameLine(slider_offset);
|
ImGui::SameLine(slider_offset);
|
||||||
ImGui::SetNextItemWidth(slider_width);
|
ImGui::SetNextItemWidth(slider_width);
|
||||||
return m_imgui->slider_float("##" + name, &value, v_min, v_max,
|
return m_imgui->slider_float("##" + name, &value, v_min, v_max,
|
||||||
format.c_str(), 1.f, false, tooltip);
|
format.c_str(), 1.f, false, tooltip);
|
||||||
};
|
};
|
||||||
float undo_offset = ImGui::GetStyle().FramePadding.x +
|
float undo_offset = ImGui::GetStyle().FramePadding.x;
|
||||||
ImGui::GetTreeNodeToLabelSpacing();
|
|
||||||
bool exist_change = default_value != nullptr ?
|
bool exist_change = default_value != nullptr ?
|
||||||
(!is_approx(value, *default_value)) : false;
|
(!is_approx(value, *default_value)) : false;
|
||||||
return revertible(name, value, default_value, exist_change,
|
return revertible(name, value, default_value, exist_change,
|
||||||
@ -2134,6 +2139,7 @@ void GLGizmoEmboss::draw_advanced()
|
|||||||
|
|
||||||
// input surface distance
|
// input surface distance
|
||||||
bool allowe_surface_distance =
|
bool allowe_surface_distance =
|
||||||
|
m_volume != nullptr &&
|
||||||
m_volume->text_configuration.has_value() &&
|
m_volume->text_configuration.has_value() &&
|
||||||
!m_volume->text_configuration->font_item.prop.use_surface &&
|
!m_volume->text_configuration->font_item.prop.use_surface &&
|
||||||
!is_text_object(m_volume);
|
!is_text_object(m_volume);
|
||||||
@ -2190,7 +2196,7 @@ void GLGizmoEmboss::draw_advanced()
|
|||||||
if (font_file->infos.size() > 1) {
|
if (font_file->infos.size() > 1) {
|
||||||
ImGui::Text("%s", tr.collection.c_str());
|
ImGui::Text("%s", tr.collection.c_str());
|
||||||
ImGui::SameLine(m_gui_cfg->advanced_input_offset);
|
ImGui::SameLine(m_gui_cfg->advanced_input_offset);
|
||||||
ImGui::SetNextItemWidth(m_gui_cfg->advanced_input_width);
|
ImGui::SetNextItemWidth(m_gui_cfg->input_width);
|
||||||
unsigned int selected = font_prop.collection_number.has_value() ?
|
unsigned int selected = font_prop.collection_number.has_value() ?
|
||||||
*font_prop.collection_number : 0;
|
*font_prop.collection_number : 0;
|
||||||
if (ImGui::BeginCombo("## Font collection", std::to_string(selected).c_str())) {
|
if (ImGui::BeginCombo("## Font collection", std::to_string(selected).c_str())) {
|
||||||
@ -2234,15 +2240,13 @@ void GLGizmoEmboss::draw_advanced()
|
|||||||
#endif // ALLOW_DEBUG_MODE
|
#endif // ALLOW_DEBUG_MODE
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLGizmoEmboss::set_minimal_window_size(bool is_edit_style,
|
void GLGizmoEmboss::set_minimal_window_size(bool is_advance_edit_style)
|
||||||
bool is_advance_edit_style)
|
|
||||||
{
|
{
|
||||||
ImVec2 window_size = ImGui::GetWindowSize();
|
ImVec2 window_size = ImGui::GetWindowSize();
|
||||||
const ImVec2& min_win_size_prev = get_minimal_window_size();
|
const ImVec2& min_win_size_prev = get_minimal_window_size();
|
||||||
//ImVec2 diff(window_size.x - min_win_size_prev.x,
|
//ImVec2 diff(window_size.x - min_win_size_prev.x,
|
||||||
// window_size.y - min_win_size_prev.y);
|
// window_size.y - min_win_size_prev.y);
|
||||||
float diff_y = window_size.y - min_win_size_prev.y;
|
float diff_y = window_size.y - min_win_size_prev.y;
|
||||||
m_is_edit_style = is_edit_style;
|
|
||||||
m_is_advanced_edit_style = is_advance_edit_style;
|
m_is_advanced_edit_style = is_advance_edit_style;
|
||||||
const ImVec2 &min_win_size = get_minimal_window_size();
|
const ImVec2 &min_win_size = get_minimal_window_size();
|
||||||
ImGui::SetWindowSize(ImVec2(0.f, min_win_size.y + diff_y),
|
ImGui::SetWindowSize(ImVec2(0.f, min_win_size.y + diff_y),
|
||||||
@ -2251,10 +2255,8 @@ void GLGizmoEmboss::set_minimal_window_size(bool is_edit_style,
|
|||||||
|
|
||||||
const ImVec2 &GLGizmoEmboss::get_minimal_window_size() const
|
const ImVec2 &GLGizmoEmboss::get_minimal_window_size() const
|
||||||
{
|
{
|
||||||
return (m_is_edit_style) ?
|
return m_is_advanced_edit_style ?
|
||||||
((m_is_advanced_edit_style) ?
|
m_gui_cfg->minimal_window_size_with_advance :
|
||||||
m_gui_cfg->minimal_window_size_with_advance :
|
|
||||||
m_gui_cfg->minimal_window_size_with_edit) :
|
|
||||||
m_gui_cfg->minimal_window_size;
|
m_gui_cfg->minimal_window_size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -136,7 +136,7 @@ private:
|
|||||||
template<typename T, typename Draw>
|
template<typename T, typename Draw>
|
||||||
bool revertible(const std::string &name, T &value, T *default_value, bool exist_change, const std::string &undo_tooltip, float undo_offset, Draw draw);
|
bool revertible(const std::string &name, T &value, T *default_value, bool exist_change, const std::string &undo_tooltip, float undo_offset, Draw draw);
|
||||||
|
|
||||||
void set_minimal_window_size(bool is_edit_style, bool is_advance_edit_style);
|
void set_minimal_window_size(bool is_advance_edit_style);
|
||||||
const ImVec2 &get_minimal_window_size() const;
|
const ImVec2 &get_minimal_window_size() const;
|
||||||
|
|
||||||
// process mouse event
|
// process mouse event
|
||||||
@ -166,10 +166,8 @@ private:
|
|||||||
size_t max_count_char_in_volume_name = 20;
|
size_t max_count_char_in_volume_name = 20;
|
||||||
// Zero means it is calculated in init function
|
// Zero means it is calculated in init function
|
||||||
ImVec2 minimal_window_size = ImVec2(0, 0);
|
ImVec2 minimal_window_size = ImVec2(0, 0);
|
||||||
ImVec2 minimal_window_size_with_edit = ImVec2(0, 0);
|
|
||||||
ImVec2 minimal_window_size_with_advance = ImVec2(0, 0);
|
ImVec2 minimal_window_size_with_advance = ImVec2(0, 0);
|
||||||
float advanced_input_width = 0.f;
|
float input_width = 0.f;
|
||||||
float style_combobox_width = 0.f;
|
|
||||||
float delete_pos_x = 0.f;
|
float delete_pos_x = 0.f;
|
||||||
float max_font_name_width = 0.f;
|
float max_font_name_width = 0.f;
|
||||||
unsigned int icon_width = 0;
|
unsigned int icon_width = 0;
|
||||||
@ -177,7 +175,7 @@ private:
|
|||||||
float min_style_image_height = 0.f;
|
float min_style_image_height = 0.f;
|
||||||
int max_style_image_width = 0.f;
|
int max_style_image_width = 0.f;
|
||||||
|
|
||||||
float edit_input_offset = 0.f;
|
float input_offset = 0.f;
|
||||||
float advanced_input_offset = 0.f;
|
float advanced_input_offset = 0.f;
|
||||||
|
|
||||||
ImVec2 text_size;
|
ImVec2 text_size;
|
||||||
@ -185,7 +183,8 @@ private:
|
|||||||
// Only translations needed for calc GUI size
|
// Only translations needed for calc GUI size
|
||||||
struct Translations
|
struct Translations
|
||||||
{
|
{
|
||||||
// edit style
|
std::string type;
|
||||||
|
std::string style;
|
||||||
std::string font;
|
std::string font;
|
||||||
std::string size;
|
std::string size;
|
||||||
std::string depth;
|
std::string depth;
|
||||||
@ -207,7 +206,6 @@ private:
|
|||||||
std::optional<const GuiCfg> m_gui_cfg;
|
std::optional<const GuiCfg> m_gui_cfg;
|
||||||
// setted only when wanted to use - not all the time
|
// setted only when wanted to use - not all the time
|
||||||
std::optional<ImVec2> m_set_window_offset;
|
std::optional<ImVec2> m_set_window_offset;
|
||||||
bool m_is_edit_style = false;
|
|
||||||
bool m_is_advanced_edit_style = false;
|
bool m_is_advanced_edit_style = false;
|
||||||
|
|
||||||
FontManager m_font_manager;
|
FontManager m_font_manager;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user