ENH:add an tip icon for assembly view

jira: STUDIO-7155
Change-Id: Ie9e4fa578c8aa5bda9ff771d82f396f8b51026bb
This commit is contained in:
zhou.xu 2024-05-30 15:38:48 +08:00 committed by Lane.Wei
parent a381dfa03c
commit 515f947334
2 changed files with 63 additions and 6 deletions

View File

@ -1173,6 +1173,13 @@ GLCanvas3D::GLCanvas3D(wxGLCanvas* canvas, Bed3D &bed)
load_arrange_settings(); load_arrange_settings();
m_selection.set_volumes(&m_volumes.volumes); m_selection.set_volumes(&m_volumes.volumes);
m_assembly_view_desc["object_selection_caption"] = _L("Left mouse button");
m_assembly_view_desc["object_selection"] = _L("object selection");
m_assembly_view_desc["part_selection_caption"] = "Alt +" + _L("Left mouse button");
m_assembly_view_desc["part_selection"] = _L("part selectiont");
m_assembly_view_desc["number_key_caption"] = "1~16 " + _L("number keys");
m_assembly_view_desc["number_key"] = _L("number keys can quickly change the color of objects");
} }
GLCanvas3D::~GLCanvas3D() GLCanvas3D::~GLCanvas3D()
@ -8227,6 +8234,43 @@ void GLCanvas3D::_render_paint_toolbar() const
ImGui::PopStyleColor(); ImGui::PopStyleColor();
} }
float GLCanvas3D::_show_assembly_tooltip_information(float caption_max, float x, float y) const
{
ImGuiWrapper *imgui = wxGetApp().imgui();
ImTextureID normal_id = m_gizmos.get_icon_texture_id(GLGizmosManager::MENU_ICON_NAME::IC_TOOLBAR_TOOLTIP);
ImTextureID hover_id = m_gizmos.get_icon_texture_id(GLGizmosManager::MENU_ICON_NAME::IC_TOOLBAR_TOOLTIP_HOVER);
caption_max += imgui->calc_text_size(": ").x + 35.f;
float font_size = ImGui::GetFontSize();
ImVec2 button_size = ImVec2(font_size * 1.8, font_size * 1.3);
ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 0.0f);
ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, {0, ImGui::GetStyle().FramePadding.y});
ImGui::ImageButton3(normal_id, hover_id, button_size);
if (ImGui::IsItemHovered()) {
ImGui::BeginTooltip2(ImVec2(x, y));
auto draw_text_with_caption = [this, &imgui, & caption_max](const wxString &caption, const wxString &text) {
imgui->text_colored(ImGuiWrapper::COL_ACTIVE, caption);
ImGui::SameLine(caption_max);
imgui->text_colored(ImGuiWrapper::COL_WINDOW_BG, text);
};
for (const auto &t : std::array<std::string, 3>{"object_selection", "part_selection", "number_key"}) {
draw_text_with_caption(m_assembly_view_desc.at(t + "_caption") + ": ", m_assembly_view_desc.at(t));
}
ImGui::EndTooltip();
}
ImGui::PopStyleVar(2);
auto same_line_size = button_size.x * 1.8;//with an space size
ImGui::SameLine(same_line_size);
same_line_size = imgui->calc_text_size("|").x + same_line_size + imgui->calc_text_size(" ").x;
imgui->text_colored(ImGuiWrapper::COL_ACTIVE, "|");
ImGui::SameLine(same_line_size);
return same_line_size;
}
//BBS //BBS
void GLCanvas3D::_render_assemble_control() const void GLCanvas3D::_render_assemble_control() const
{ {
@ -8258,7 +8302,18 @@ void GLCanvas3D::_render_assemble_control() const
imgui->begin(_L("Assemble Control"), ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoTitleBar); imgui->begin(_L("Assemble Control"), ImGuiWindowFlags_NoMove | ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoTitleBar);
ImGui::AlignTextToFramePadding(); ImGui::AlignTextToFramePadding();
float tip_icon_size;
{
float caption_max = 0.f;
for (const auto &t : std::array<std::string, 3>{"object_selection", "part_selection", "number_key"}) {
caption_max = std::max(caption_max, imgui->calc_text_size(m_assembly_view_desc.at(t + "_caption")).x);
}
const ImVec2 pos = ImGui::GetCursorScreenPos();
const float text_y =imgui->calc_text_size(_L("part_selection")).y;
float get_cur_x = pos.x;
float get_cur_y = pos.y - ImGui::GetFrameHeight() - 4 * text_y;
tip_icon_size =_show_assembly_tooltip_information(caption_max, get_cur_x, get_cur_y);
}
{ {
float clp_dist = m_gizmos.m_assemble_view_data->model_objects_clipper()->get_position(); float clp_dist = m_gizmos.m_assemble_view_data->model_objects_clipper()->get_position();
if (clp_dist == 0.f) { if (clp_dist == 0.f) {
@ -8273,11 +8328,11 @@ void GLCanvas3D::_render_assemble_control() const
} }
} }
ImGui::SameLine(window_padding.x + text_size_x + item_spacing); ImGui::SameLine(tip_icon_size + window_padding.x + text_size_x + item_spacing);
ImGui::PushItemWidth(slider_width); ImGui::PushItemWidth(slider_width);
bool view_slider_changed = imgui->bbl_slider_float_style("##clp_dist", &clp_dist, 0.f, 1.f, "%.2f", 1.0f, true); bool view_slider_changed = imgui->bbl_slider_float_style("##clp_dist", &clp_dist, 0.f, 1.f, "%.2f", 1.0f, true);
ImGui::SameLine(window_padding.x + text_size_x + slider_width + item_spacing * 2); ImGui::SameLine(tip_icon_size +window_padding.x + text_size_x + slider_width + item_spacing * 2);
ImGui::PushItemWidth(value_size); ImGui::PushItemWidth(value_size);
bool view_input_changed = ImGui::BBLDragFloat("##clp_dist_input", &clp_dist, 0.05f, 0.0f, 0.0f, "%.2f"); bool view_input_changed = ImGui::BBLDragFloat("##clp_dist_input", &clp_dist, 0.05f, 0.0f, 0.0f, "%.2f");
@ -8286,14 +8341,14 @@ void GLCanvas3D::_render_assemble_control() const
} }
{ {
ImGui::SameLine(window_padding.x + text_size_x + slider_width + item_spacing * 6 + value_size); ImGui::SameLine(tip_icon_size +window_padding.x + text_size_x + slider_width + item_spacing * 6 + value_size);
imgui->text(_L("Explosion Ratio")); imgui->text(_L("Explosion Ratio"));
ImGui::SameLine(window_padding.x + 2 * text_size_x + slider_width + item_spacing * 7 + value_size); ImGui::SameLine(tip_icon_size +window_padding.x + 2 * text_size_x + slider_width + item_spacing * 7 + value_size);
ImGui::PushItemWidth(slider_width); ImGui::PushItemWidth(slider_width);
bool explosion_slider_changed = imgui->bbl_slider_float_style("##ratio_slider", &m_explosion_ratio, 1.0f, 3.0f, "%1.2f"); bool explosion_slider_changed = imgui->bbl_slider_float_style("##ratio_slider", &m_explosion_ratio, 1.0f, 3.0f, "%1.2f");
ImGui::SameLine(window_padding.x + 2 * text_size_x + 2 * slider_width + item_spacing * 8 + value_size); ImGui::SameLine(tip_icon_size +window_padding.x + 2 * text_size_x + 2 * slider_width + item_spacing * 8 + value_size);
ImGui::PushItemWidth(value_size); ImGui::PushItemWidth(value_size);
bool explosion_input_changed = ImGui::BBLDragFloat("##ratio_input", &m_explosion_ratio, 0.1f, 1.0f, 3.0f, "%1.2f"); bool explosion_input_changed = ImGui::BBLDragFloat("##ratio_input", &m_explosion_ratio, 0.1f, 1.0f, 3.0f, "%1.2f");
} }

View File

@ -507,6 +507,7 @@ private:
wxGLCanvas* m_canvas; wxGLCanvas* m_canvas;
wxGLContext* m_context; wxGLContext* m_context;
Bed3D &m_bed; Bed3D &m_bed;
std::map<std::string, wxString> m_assembly_view_desc;
#if ENABLE_RETINA_GL #if ENABLE_RETINA_GL
std::unique_ptr<RetinaHelper> m_retina_helper; std::unique_ptr<RetinaHelper> m_retina_helper;
#endif #endif
@ -1145,6 +1146,7 @@ private:
// BBS // BBS
//void _render_view_toolbar() const; //void _render_view_toolbar() const;
void _render_paint_toolbar() const; void _render_paint_toolbar() const;
float _show_assembly_tooltip_information(float caption_max, float x, float y) const;
void _render_assemble_control() const; void _render_assemble_control() const;
void _render_assemble_info() const; void _render_assemble_info() const;
#if ENABLE_SHOW_CAMERA_TARGET #if ENABLE_SHOW_CAMERA_TARGET