Expose a key-map preference "Fallback Tool (RMB)", disabled by default. The right mouse button uses the fallback tool (currently visible selection tool in the toolbar), instead of always tweaking. When any selection tool is active, right mouse always tweaks. To enable fallback selection on RMB, set the "Right Mouse Select Action" to "Selection Tool". Internal changes: - Add fall-back key-maps, separate key-maps needed for when the tool is run as a fall-back. This is needed so RMB-select can support fall-back tools, so left-mouse can be used when it's the active tool and RMB can be used as a fall-back action when another tool is active. - Add options field to tools so tools without gizmos can enable the full-back tool keymap. - Support multiple key-maps for keymap handlers. - Fall-back keymaps now co-exist with the tool-keymaps. So both keymaps may be active at once - using different mouse buttons. When gizmos are in use, a highlighted gizmo prioritizes the tool-keymap over the fall-back keymap. Resolves T83690. Reviewed By: JulienKaspar Ref D12493
108 lines
3.3 KiB
C
108 lines
3.3 KiB
C
/*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License
|
|
* as published by the Free Software Foundation; either version 2
|
|
* of the License, or (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, write to the Free Software Foundation,
|
|
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
*/
|
|
|
|
/** \file
|
|
* \ingroup spview3d
|
|
*/
|
|
|
|
#include "MEM_guardedalloc.h"
|
|
|
|
#include "BLI_utildefines.h"
|
|
|
|
#include "BKE_context.h"
|
|
|
|
#include "ED_gizmo_utils.h"
|
|
#include "ED_screen.h"
|
|
|
|
#include "UI_resources.h"
|
|
|
|
#include "WM_api.h"
|
|
#include "WM_types.h"
|
|
|
|
#include "view3d_intern.h" /* own include */
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
/** \name Mesh Pre-Select Element Gizmo
|
|
* \{ */
|
|
|
|
struct GizmoGroupPreSelElem {
|
|
wmGizmo *gizmo;
|
|
};
|
|
|
|
static void WIDGETGROUP_mesh_preselect_elem_setup(const bContext *UNUSED(C), wmGizmoGroup *gzgroup)
|
|
{
|
|
const wmGizmoType *gzt_presel = WM_gizmotype_find("GIZMO_GT_mesh_preselect_elem_3d", true);
|
|
struct GizmoGroupPreSelElem *ggd = MEM_callocN(sizeof(struct GizmoGroupPreSelElem), __func__);
|
|
gzgroup->customdata = ggd;
|
|
|
|
wmGizmo *gz = ggd->gizmo = WM_gizmo_new_ptr(gzt_presel, gzgroup, NULL);
|
|
UI_GetThemeColor3fv(TH_GIZMO_PRIMARY, gz->color);
|
|
UI_GetThemeColor3fv(TH_GIZMO_HI, gz->color_hi);
|
|
}
|
|
|
|
void VIEW3D_GGT_mesh_preselect_elem(wmGizmoGroupType *gzgt)
|
|
{
|
|
gzgt->name = "Mesh Preselect Element";
|
|
gzgt->idname = "VIEW3D_GGT_mesh_preselect_elem";
|
|
|
|
gzgt->flag = WM_GIZMOGROUPTYPE_TOOL_FALLBACK_KEYMAP | WM_GIZMOGROUPTYPE_3D;
|
|
|
|
gzgt->gzmap_params.spaceid = SPACE_VIEW3D;
|
|
gzgt->gzmap_params.regionid = RGN_TYPE_WINDOW;
|
|
|
|
gzgt->poll = ED_gizmo_poll_or_unlink_delayed_from_tool;
|
|
gzgt->setup = WIDGETGROUP_mesh_preselect_elem_setup;
|
|
}
|
|
|
|
/** \} */
|
|
|
|
/* -------------------------------------------------------------------- */
|
|
/** \name Mesh Pre-Select Edge Ring Gizmo
|
|
* \{ */
|
|
|
|
struct GizmoGroupPreSelEdgeRing {
|
|
wmGizmo *gizmo;
|
|
};
|
|
|
|
static void WIDGETGROUP_mesh_preselect_edgering_setup(const bContext *UNUSED(C),
|
|
wmGizmoGroup *gzgroup)
|
|
{
|
|
const wmGizmoType *gzt_presel = WM_gizmotype_find("GIZMO_GT_mesh_preselect_edgering_3d", true);
|
|
struct GizmoGroupPreSelEdgeRing *ggd = MEM_callocN(sizeof(struct GizmoGroupPreSelEdgeRing),
|
|
__func__);
|
|
gzgroup->customdata = ggd;
|
|
|
|
wmGizmo *gz = ggd->gizmo = WM_gizmo_new_ptr(gzt_presel, gzgroup, NULL);
|
|
UI_GetThemeColor3fv(TH_GIZMO_PRIMARY, gz->color);
|
|
UI_GetThemeColor3fv(TH_GIZMO_HI, gz->color_hi);
|
|
}
|
|
|
|
void VIEW3D_GGT_mesh_preselect_edgering(wmGizmoGroupType *gzgt)
|
|
{
|
|
gzgt->name = "Mesh Preselect Edge Ring";
|
|
gzgt->idname = "VIEW3D_GGT_mesh_preselect_edgering";
|
|
|
|
gzgt->flag = WM_GIZMOGROUPTYPE_TOOL_FALLBACK_KEYMAP | WM_GIZMOGROUPTYPE_3D;
|
|
|
|
gzgt->gzmap_params.spaceid = SPACE_VIEW3D;
|
|
gzgt->gzmap_params.regionid = RGN_TYPE_WINDOW;
|
|
|
|
gzgt->poll = ED_gizmo_poll_or_unlink_delayed_from_tool;
|
|
gzgt->setup = WIDGETGROUP_mesh_preselect_edgering_setup;
|
|
}
|
|
|
|
/** \} */
|