Added shortcuts for gizmos
This commit is contained in:
parent
ddf8acb440
commit
c60ed7bc07
5 changed files with 96 additions and 8 deletions
|
@ -31,6 +31,8 @@
|
||||||
#define ENABLE_NEW_MENU_LAYOUT (1 && ENABLE_1_42_0)
|
#define ENABLE_NEW_MENU_LAYOUT (1 && ENABLE_1_42_0)
|
||||||
// All rotations made using the rotate gizmo are done with respect to the world reference system
|
// All rotations made using the rotate gizmo are done with respect to the world reference system
|
||||||
#define ENABLE_WORLD_ROTATIONS (1 && ENABLE_1_42_0)
|
#define ENABLE_WORLD_ROTATIONS (1 && ENABLE_1_42_0)
|
||||||
|
// Enables shortcut keys for gizmos
|
||||||
|
#define ENABLE_GIZMOS_SHORTCUT (1 && ENABLE_1_42_0)
|
||||||
|
|
||||||
#endif // _technologies_h_
|
#endif // _technologies_h_
|
||||||
|
|
||||||
|
|
|
@ -2659,6 +2659,43 @@ bool GLCanvas3D::Gizmos::is_running() const
|
||||||
return (curr != nullptr) ? (curr->get_state() == GLGizmoBase::On) : false;
|
return (curr != nullptr) ? (curr->get_state() == GLGizmoBase::On) : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if ENABLE_GIZMOS_SHORTCUT
|
||||||
|
bool GLCanvas3D::Gizmos::handle_shortcut(int key, const Selection& selection)
|
||||||
|
{
|
||||||
|
if (!m_enabled)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
bool handled = false;
|
||||||
|
for (GizmosMap::iterator it = m_gizmos.begin(); it != m_gizmos.end(); ++it)
|
||||||
|
{
|
||||||
|
if ((it->second == nullptr) || !it->second->is_selectable())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
int it_key = it->second->get_shortcut_key();
|
||||||
|
|
||||||
|
if (it->second->is_activable(selection) && ((it_key == key - 64) || (it_key == key - 96)))
|
||||||
|
{
|
||||||
|
if ((it->second->get_state() == GLGizmoBase::On))
|
||||||
|
{
|
||||||
|
it->second->set_state(GLGizmoBase::Off);
|
||||||
|
m_current = Undefined;
|
||||||
|
handled = true;
|
||||||
|
}
|
||||||
|
else if ((it->second->get_state() == GLGizmoBase::Off))
|
||||||
|
{
|
||||||
|
it->second->set_state(GLGizmoBase::On);
|
||||||
|
m_current = it->first;
|
||||||
|
handled = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
it->second->set_state(GLGizmoBase::Off);
|
||||||
|
}
|
||||||
|
|
||||||
|
return handled;
|
||||||
|
}
|
||||||
|
#endif // ENABLE_GIZMOS_SHORTCUT
|
||||||
|
|
||||||
bool GLCanvas3D::Gizmos::is_dragging() const
|
bool GLCanvas3D::Gizmos::is_dragging() const
|
||||||
{
|
{
|
||||||
if (!m_enabled)
|
if (!m_enabled)
|
||||||
|
@ -4273,7 +4310,16 @@ void GLCanvas3D::on_char(wxKeyEvent& evt)
|
||||||
#endif // ENABLE_MODIFIED_CAMERA_TARGET
|
#endif // ENABLE_MODIFIED_CAMERA_TARGET
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
evt.Skip();
|
#if ENABLE_GIZMOS_SHORTCUT
|
||||||
|
if (evt.ShiftDown() && m_gizmos.handle_shortcut(keyCode, m_selection))
|
||||||
|
{
|
||||||
|
_update_gizmos_data();
|
||||||
|
render();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif // ENABLE_GIZMOS_SHORTCUT
|
||||||
|
evt.Skip();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4761,16 +4807,14 @@ void GLCanvas3D::on_key_down(wxKeyEvent& evt)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int key = evt.GetKeyCode();
|
int key = evt.GetKeyCode();
|
||||||
|
#ifdef __WXOSX__
|
||||||
|
if (key == WXK_BACK)
|
||||||
|
#else
|
||||||
if (key == WXK_DELETE)
|
if (key == WXK_DELETE)
|
||||||
|
#endif // __WXOSX__
|
||||||
post_event(SimpleEvent(EVT_GLCANVAS_REMOVE_OBJECT));
|
post_event(SimpleEvent(EVT_GLCANVAS_REMOVE_OBJECT));
|
||||||
else
|
else
|
||||||
{
|
evt.Skip();
|
||||||
#ifdef __WXOSX__
|
|
||||||
if (key == WXK_BACK)
|
|
||||||
post_event(SimpleEvent(EVT_GLCANVAS_REMOVE_OBJECT));
|
|
||||||
#endif
|
|
||||||
evt.Skip();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -611,6 +611,9 @@ private:
|
||||||
EType get_current_type() const;
|
EType get_current_type() const;
|
||||||
|
|
||||||
bool is_running() const;
|
bool is_running() const;
|
||||||
|
#if ENABLE_GIZMOS_SHORTCUT
|
||||||
|
bool handle_shortcut(int key, const Selection& selection);
|
||||||
|
#endif // ENABLE_GIZMOS_SHORTCUT
|
||||||
|
|
||||||
bool is_dragging() const;
|
bool is_dragging() const;
|
||||||
void start_dragging(const Selection& selection);
|
void start_dragging(const Selection& selection);
|
||||||
|
|
|
@ -30,6 +30,10 @@
|
||||||
#include "GUI_Utils.hpp"
|
#include "GUI_Utils.hpp"
|
||||||
#include "GUI_App.hpp"
|
#include "GUI_App.hpp"
|
||||||
|
|
||||||
|
#if ENABLE_GIZMOS_SHORTCUT
|
||||||
|
#include <wx/defs.h>
|
||||||
|
#endif // ENABLE_GIZMOS_SHORTCUT
|
||||||
|
|
||||||
// TODO: Display tooltips quicker on Linux
|
// TODO: Display tooltips quicker on Linux
|
||||||
|
|
||||||
static const float DEFAULT_BASE_COLOR[3] = { 0.625f, 0.625f, 0.625f };
|
static const float DEFAULT_BASE_COLOR[3] = { 0.625f, 0.625f, 0.625f };
|
||||||
|
@ -161,6 +165,9 @@ GLGizmoBase::GLGizmoBase(GLCanvas3D& parent)
|
||||||
: m_parent(parent)
|
: m_parent(parent)
|
||||||
, m_group_id(-1)
|
, m_group_id(-1)
|
||||||
, m_state(Off)
|
, m_state(Off)
|
||||||
|
#if ENABLE_GIZMOS_SHORTCUT
|
||||||
|
, m_shortcut_key(0)
|
||||||
|
#endif // ENABLE_GIZMOS_SHORTCUT
|
||||||
, m_hover_id(-1)
|
, m_hover_id(-1)
|
||||||
, m_dragging(false)
|
, m_dragging(false)
|
||||||
{
|
{
|
||||||
|
@ -639,6 +646,10 @@ bool GLGizmoRotate3D::on_init()
|
||||||
if (!m_textures[On].load_from_file(path + "rotate_on.png", false))
|
if (!m_textures[On].load_from_file(path + "rotate_on.png", false))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
#if ENABLE_GIZMOS_SHORTCUT
|
||||||
|
m_shortcut_key = WXK_CONTROL_R;
|
||||||
|
#endif // ENABLE_GIZMOS_SHORTCUT
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -713,6 +724,10 @@ bool GLGizmoScale3D::on_init()
|
||||||
m_grabbers[2].angles(0) = half_pi;
|
m_grabbers[2].angles(0) = half_pi;
|
||||||
m_grabbers[3].angles(0) = half_pi;
|
m_grabbers[3].angles(0) = half_pi;
|
||||||
|
|
||||||
|
#if ENABLE_GIZMOS_SHORTCUT
|
||||||
|
m_shortcut_key = WXK_CONTROL_S;
|
||||||
|
#endif // ENABLE_GIZMOS_SHORTCUT
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1057,6 +1072,10 @@ bool GLGizmoMove3D::on_init()
|
||||||
m_grabbers.push_back(Grabber());
|
m_grabbers.push_back(Grabber());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if ENABLE_GIZMOS_SHORTCUT
|
||||||
|
m_shortcut_key = WXK_CONTROL_M;
|
||||||
|
#endif // ENABLE_GIZMOS_SHORTCUT
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1213,6 +1232,10 @@ bool GLGizmoFlatten::on_init()
|
||||||
if (!m_textures[On].load_from_file(path + "layflat_on.png", false))
|
if (!m_textures[On].load_from_file(path + "layflat_on.png", false))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
#if ENABLE_GIZMOS_SHORTCUT
|
||||||
|
m_shortcut_key = WXK_CONTROL_F;
|
||||||
|
#endif // ENABLE_GIZMOS_SHORTCUT
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1542,6 +1565,10 @@ bool GLGizmoSlaSupports::on_init()
|
||||||
if (!m_textures[On].load_from_file(path + "sla_support_points_on.png", false))
|
if (!m_textures[On].load_from_file(path + "sla_support_points_on.png", false))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
#if ENABLE_GIZMOS_SHORTCUT
|
||||||
|
m_shortcut_key = WXK_CONTROL_L;
|
||||||
|
#endif // ENABLE_GIZMOS_SHORTCUT
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1893,6 +1920,10 @@ bool GLGizmoCut::on_init()
|
||||||
|
|
||||||
m_grabbers.emplace_back();
|
m_grabbers.emplace_back();
|
||||||
|
|
||||||
|
#if ENABLE_GIZMOS_SHORTCUT
|
||||||
|
m_shortcut_key = WXK_CONTROL_C;
|
||||||
|
#endif // ENABLE_GIZMOS_SHORTCUT
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -77,6 +77,9 @@ protected:
|
||||||
|
|
||||||
int m_group_id;
|
int m_group_id;
|
||||||
EState m_state;
|
EState m_state;
|
||||||
|
#if ENABLE_GIZMOS_SHORTCUT
|
||||||
|
int m_shortcut_key;
|
||||||
|
#endif // ENABLE_GIZMOS_SHORTCUT
|
||||||
// textures are assumed to be square and all with the same size in pixels, no internal check is done
|
// textures are assumed to be square and all with the same size in pixels, no internal check is done
|
||||||
GLTexture m_textures[Num_States];
|
GLTexture m_textures[Num_States];
|
||||||
int m_hover_id;
|
int m_hover_id;
|
||||||
|
@ -100,6 +103,11 @@ public:
|
||||||
EState get_state() const { return m_state; }
|
EState get_state() const { return m_state; }
|
||||||
void set_state(EState state) { m_state = state; on_set_state(); }
|
void set_state(EState state) { m_state = state; on_set_state(); }
|
||||||
|
|
||||||
|
#if ENABLE_GIZMOS_SHORTCUT
|
||||||
|
int get_shortcut_key() const { return m_shortcut_key; }
|
||||||
|
void set_shortcut_key(int key) { m_shortcut_key = key; }
|
||||||
|
#endif // ENABLE_GIZMOS_SHORTCUT
|
||||||
|
|
||||||
bool is_activable(const GLCanvas3D::Selection& selection) const { return on_is_activable(selection); }
|
bool is_activable(const GLCanvas3D::Selection& selection) const { return on_is_activable(selection); }
|
||||||
bool is_selectable() const { return on_is_selectable(); }
|
bool is_selectable() const { return on_is_selectable(); }
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue