NEW:add tip button for move,rotate,scale
jira: STUDIO-7273 Change-Id: I44aeecd8aaa17ec49ac1d8ff2bee5c3729c52061 (cherry picked from commit 998f33b4ce588f59cef345e327a97f6f669f6089)
This commit is contained in:
parent
8400e162a7
commit
f5eb2899e7
|
@ -4200,11 +4200,22 @@ void GLCanvas3D::on_mouse(wxMouseEvent& evt)
|
|||
int volume_idx = get_first_hover_volume_idx();
|
||||
bool already_selected = m_selection.contains_volume(volume_idx);
|
||||
bool ctrl_down = evt.CmdDown();
|
||||
|
||||
bool alt_down = evt.AltDown();
|
||||
Selection::IndicesList curr_idxs = m_selection.get_volume_idxs();
|
||||
|
||||
if (already_selected && ctrl_down)
|
||||
m_selection.remove(volume_idx);
|
||||
else if (alt_down) {
|
||||
Selection::EMode mode = Selection::Volume;
|
||||
if (already_selected) {
|
||||
std::vector<unsigned int> volume_idxs;
|
||||
for (auto idx : curr_idxs) { volume_idxs.emplace_back(idx); }
|
||||
m_selection.remove_volumes(mode, volume_idxs);
|
||||
}
|
||||
std::vector<unsigned int> add_volume_idxs;
|
||||
add_volume_idxs.emplace_back(volume_idx);
|
||||
m_selection.add_volumes(mode, add_volume_idxs, true);
|
||||
}
|
||||
else {
|
||||
m_selection.add(volume_idx, !ctrl_down, true);
|
||||
m_mouse.drag.move_requires_threshold = !already_selected;
|
||||
|
|
|
@ -54,6 +54,24 @@ GizmoObjectManipulation::GizmoObjectManipulation(GLCanvas3D& glcanvas)
|
|||
{
|
||||
m_imperial_units = wxGetApp().app_config->get("use_inches") == "1";
|
||||
m_new_unit_string = m_imperial_units ? L("in") : L("mm");
|
||||
|
||||
const wxString shift = "Shift+";
|
||||
const wxString alt = GUI::shortkey_alt_prefix();
|
||||
const wxString ctrl = GUI::shortkey_ctrl_prefix();
|
||||
m_desc_move["part_selection_caption"] = alt + _L("Left mouse button");
|
||||
m_desc_move["part_selection"] = _L("Part selection");
|
||||
m_desc_move["snap_step_caption"] = shift + _L("Left mouse button");
|
||||
m_desc_move["snap_step"] = _L("Fixed step drag");
|
||||
|
||||
m_desc_rotate["part_selection_caption"] = alt + _L("Left mouse button");
|
||||
m_desc_rotate["part_selection"] = _L("Part selection");
|
||||
|
||||
m_desc_scale["part_selection_caption"] = alt + _L("Left mouse button");
|
||||
m_desc_scale["part_selection"] = _L("Part selection");
|
||||
m_desc_scale["snap_step_caption"] = shift + _L("Left mouse button");
|
||||
m_desc_scale["snap_step"] = _L("Fixed step drag");
|
||||
m_desc_scale["single_sided_caption"] = ctrl + _L("Left mouse button");
|
||||
m_desc_scale["single_sided"] = _L("Single sided scaling");
|
||||
}
|
||||
|
||||
void GizmoObjectManipulation::UpdateAndShow(const bool show)
|
||||
|
@ -559,7 +577,91 @@ bool GizmoObjectManipulation::reset_button(ImGuiWrapper *imgui_wrapper, float ca
|
|||
|
||||
if (b_value) { ImGui::PopStyleColor(3); }
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
void GizmoObjectManipulation::show_move_tooltip_information(ImGuiWrapper *imgui_wrapper, float caption_max, float x, float y)
|
||||
{
|
||||
ImTextureID normal_id = m_glcanvas.get_gizmos_manager().get_icon_texture_id(GLGizmosManager::MENU_ICON_NAME::IC_TOOLBAR_TOOLTIP);
|
||||
ImTextureID hover_id = m_glcanvas.get_gizmos_manager().get_icon_texture_id(GLGizmosManager::MENU_ICON_NAME::IC_TOOLBAR_TOOLTIP_HOVER);
|
||||
|
||||
caption_max += imgui_wrapper->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_wrapper,& caption_max](const wxString &caption, const wxString &text) {
|
||||
imgui_wrapper->text_colored(ImGuiWrapper::COL_ACTIVE, caption);
|
||||
ImGui::SameLine(caption_max);
|
||||
imgui_wrapper->text_colored(ImGuiWrapper::COL_WINDOW_BG, text);
|
||||
};
|
||||
|
||||
for (const auto &t : std::array<std::string, 2>{"part_selection", "snap_step"})
|
||||
draw_text_with_caption(m_desc_move.at(t + "_caption") + ": ", m_desc_move.at(t));
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
ImGui::PopStyleVar(2);
|
||||
}
|
||||
|
||||
void GizmoObjectManipulation::show_rotate_tooltip_information(ImGuiWrapper *imgui_wrapper, float caption_max, float x, float y)
|
||||
{
|
||||
ImTextureID normal_id = m_glcanvas.get_gizmos_manager().get_icon_texture_id(GLGizmosManager::MENU_ICON_NAME::IC_TOOLBAR_TOOLTIP);
|
||||
ImTextureID hover_id = m_glcanvas.get_gizmos_manager().get_icon_texture_id(GLGizmosManager::MENU_ICON_NAME::IC_TOOLBAR_TOOLTIP_HOVER);
|
||||
|
||||
caption_max += imgui_wrapper->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_wrapper, &caption_max](const wxString &caption, const wxString &text) {
|
||||
imgui_wrapper->text_colored(ImGuiWrapper::COL_ACTIVE, caption);
|
||||
ImGui::SameLine(caption_max);
|
||||
imgui_wrapper->text_colored(ImGuiWrapper::COL_WINDOW_BG, text);
|
||||
};
|
||||
|
||||
for (const auto &t : std::array<std::string, 1>{"part_selection"})
|
||||
draw_text_with_caption(m_desc_rotate.at(t + "_caption") + ": ", m_desc_rotate.at(t));
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
ImGui::PopStyleVar(2);
|
||||
}
|
||||
|
||||
void GizmoObjectManipulation::show_scale_tooltip_information(ImGuiWrapper *imgui_wrapper, float caption_max, float x, float y)
|
||||
{
|
||||
ImTextureID normal_id = m_glcanvas.get_gizmos_manager().get_icon_texture_id(GLGizmosManager::MENU_ICON_NAME::IC_TOOLBAR_TOOLTIP);
|
||||
ImTextureID hover_id = m_glcanvas.get_gizmos_manager().get_icon_texture_id(GLGizmosManager::MENU_ICON_NAME::IC_TOOLBAR_TOOLTIP_HOVER);
|
||||
|
||||
caption_max += imgui_wrapper->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_wrapper, &caption_max](const wxString &caption, const wxString &text) {
|
||||
imgui_wrapper->text_colored(ImGuiWrapper::COL_ACTIVE, caption);
|
||||
ImGui::SameLine(caption_max);
|
||||
imgui_wrapper->text_colored(ImGuiWrapper::COL_WINDOW_BG, text);
|
||||
};
|
||||
|
||||
for (const auto &t : std::array<std::string, 3>{"part_selection", "snap_step", "single_sided"})
|
||||
draw_text_with_caption(m_desc_scale.at(t + "_caption") + ": ", m_desc_scale.at(t));
|
||||
ImGui::EndTooltip();
|
||||
}
|
||||
ImGui::PopStyleVar(2);
|
||||
}
|
||||
|
||||
void GizmoObjectManipulation::do_render_move_window(ImGuiWrapper *imgui_wrapper, std::string window_name, float x, float y, float bottom_limit)
|
||||
{
|
||||
|
@ -685,7 +787,14 @@ bool GizmoObjectManipulation::reset_button(ImGuiWrapper *imgui_wrapper, float ca
|
|||
}
|
||||
}
|
||||
if (!focued_on_text) m_glcanvas.handle_sidebar_focus_event("", false);
|
||||
|
||||
float get_cur_y = ImGui::GetContentRegionMax().y + ImGui::GetFrameHeight() + y;
|
||||
float tip_caption_max = 0.f;
|
||||
float total_text_max = 0.f;
|
||||
for (const auto &t : std::array<std::string, 2>{"part_selection", "snap_step"}) {
|
||||
tip_caption_max = std::max(tip_caption_max, imgui_wrapper->calc_text_size(m_desc_move[t + "_caption"]).x);
|
||||
total_text_max = std::max(total_text_max, imgui_wrapper->calc_text_size(m_desc_move[t]).x);
|
||||
}
|
||||
show_move_tooltip_information(imgui_wrapper, tip_caption_max, x, get_cur_y);
|
||||
m_last_active_item = current_active_id;
|
||||
last_move_input_window_width = ImGui::GetWindowWidth();
|
||||
imgui_wrapper->end();
|
||||
|
@ -802,7 +911,14 @@ void GizmoObjectManipulation::do_render_rotate_window(ImGuiWrapper *imgui_wrappe
|
|||
}
|
||||
}
|
||||
if (!focued_on_text) m_glcanvas.handle_sidebar_focus_event("", false);
|
||||
|
||||
float get_cur_y = ImGui::GetContentRegionMax().y + ImGui::GetFrameHeight() + y;
|
||||
float tip_caption_max = 0.f;
|
||||
float total_text_max = 0.f;
|
||||
for (const auto &t : std::array<std::string, 1>{"part_selection"}) {
|
||||
tip_caption_max = std::max(tip_caption_max, imgui_wrapper->calc_text_size(m_desc_move[t + "_caption"]).x);
|
||||
total_text_max = std::max(total_text_max, imgui_wrapper->calc_text_size(m_desc_move[t]).x);
|
||||
}
|
||||
show_rotate_tooltip_information(imgui_wrapper, tip_caption_max, x, get_cur_y);
|
||||
m_last_active_item = current_active_id;
|
||||
last_rotate_input_window_width = ImGui::GetWindowWidth();
|
||||
imgui_wrapper->end();
|
||||
|
@ -1004,7 +1120,14 @@ void GizmoObjectManipulation::do_render_scale_input_window(ImGuiWrapper* imgui_w
|
|||
}
|
||||
if (!focued_on_text)
|
||||
m_glcanvas.handle_sidebar_focus_event("", false);
|
||||
|
||||
float get_cur_y = ImGui::GetContentRegionMax().y + ImGui::GetFrameHeight() + y;
|
||||
float tip_caption_max = 0.f;
|
||||
float total_text_max = 0.f;
|
||||
for (const auto &t : std::array<std::string, 3>{"part_selection", "snap_step", "single_sided"}) {
|
||||
tip_caption_max = std::max(tip_caption_max, imgui_wrapper->calc_text_size(m_desc_scale[t + "_caption"]).x);
|
||||
total_text_max = std::max(total_text_max, imgui_wrapper->calc_text_size(m_desc_scale[t]).x);
|
||||
}
|
||||
show_scale_tooltip_information(imgui_wrapper, tip_caption_max, x, get_cur_y);
|
||||
m_last_active_item = current_active_id;
|
||||
|
||||
last_scale_input_window_width = ImGui::GetWindowWidth();
|
||||
|
|
|
@ -126,6 +126,9 @@ public:
|
|||
bool reset_button(ImGuiWrapper *imgui_wrapper, float caption_max, float unit_size, float space_size, float end_text_size);
|
||||
bool bbl_checkbox(const wxString &label, bool &value);
|
||||
|
||||
void show_move_tooltip_information(ImGuiWrapper *imgui_wrapper, float caption_max, float x, float y);
|
||||
void show_rotate_tooltip_information(ImGuiWrapper *imgui_wrapper, float caption_max, float x, float y);
|
||||
void show_scale_tooltip_information(ImGuiWrapper *imgui_wrapper, float caption_max, float x, float y);
|
||||
private:
|
||||
void reset_settings_value();
|
||||
void update_settings_value(const Selection& selection);
|
||||
|
@ -136,7 +139,7 @@ private:
|
|||
//Show or hide mirror buttons
|
||||
//void update_mirror_buttons_visibility();
|
||||
|
||||
// change values
|
||||
// change values
|
||||
void change_position_value(int axis, double value);
|
||||
void change_rotation_value(int axis, double value);
|
||||
void change_scale_value(int axis, double value);
|
||||
|
@ -148,6 +151,9 @@ private:
|
|||
|
||||
GLCanvas3D& m_glcanvas;
|
||||
unsigned int m_last_active_item { 0 };
|
||||
std::map<std::string, wxString> m_desc_move;
|
||||
std::map<std::string, wxString> m_desc_rotate;
|
||||
std::map<std::string, wxString> m_desc_scale;
|
||||
};
|
||||
|
||||
}}
|
||||
|
|
Loading…
Reference in New Issue