Gizmo: add option to catch all mouse clicks
This was previously default behavior, now it's default.
This commit is contained in:
parent
e18a2c4ed7
commit
98c304e865
Notes:
blender-bot
2023-02-14 05:31:29 +01:00
Referenced by commit444a0202d4
, Gizmo: add blank gizmo definition Referenced by commit693ecdf7d3
, Fix build error due to missing file from commit98c304e865
. Referenced by issue #56313, Crash - selecting tools: Transform, Grab, Rotate and Scale. Referenced by issue #56140, Viewport crashes
|
@ -289,6 +289,10 @@ class _defs_transform:
|
|||
|
||||
@ToolDef.from_fn
|
||||
def translate():
|
||||
def draw_settings(context, layout, tool):
|
||||
tool_settings = context.tool_settings
|
||||
layout.prop(tool_settings, "use_gizmo_apron")
|
||||
|
||||
return dict(
|
||||
text="Grab",
|
||||
# cursor='SCROLL_XY',
|
||||
|
@ -299,10 +303,15 @@ class _defs_transform:
|
|||
# keymap=(
|
||||
# ("transform.translate", dict(release_confirm=True), dict(type='EVT_TWEAK_A', value='ANY')),
|
||||
# ),
|
||||
draw_settings=draw_settings,
|
||||
)
|
||||
|
||||
@ToolDef.from_fn
|
||||
def rotate():
|
||||
def draw_settings(context, layout, tool):
|
||||
tool_settings = context.tool_settings
|
||||
layout.prop(tool_settings, "use_gizmo_apron")
|
||||
|
||||
return dict(
|
||||
text="Rotate",
|
||||
# cursor='SCROLL_XY',
|
||||
|
@ -313,10 +322,15 @@ class _defs_transform:
|
|||
# keymap=(
|
||||
# ("transform.rotate", dict(release_confirm=True), dict(type='EVT_TWEAK_A', value='ANY')),
|
||||
# ),
|
||||
draw_settings=draw_settings,
|
||||
)
|
||||
|
||||
@ToolDef.from_fn
|
||||
def scale():
|
||||
def draw_settings(context, layout, tool):
|
||||
tool_settings = context.tool_settings
|
||||
layout.prop(tool_settings, "use_gizmo_apron")
|
||||
|
||||
return dict(
|
||||
text="Scale",
|
||||
# cursor='SCROLL_XY',
|
||||
|
@ -327,6 +341,7 @@ class _defs_transform:
|
|||
# keymap=(
|
||||
# ("transform.resize", dict(release_confirm=True), dict(type='EVT_TWEAK_A', value='ANY')),
|
||||
# ),
|
||||
draw_settings=draw_settings,
|
||||
)
|
||||
|
||||
@ToolDef.from_fn
|
||||
|
@ -342,6 +357,7 @@ class _defs_transform:
|
|||
def transform():
|
||||
def draw_settings(context, layout, tool):
|
||||
tool_settings = context.tool_settings
|
||||
layout.prop(tool_settings, "use_gizmo_apron")
|
||||
layout.prop(tool_settings, "use_gizmo_mode")
|
||||
|
||||
return dict(
|
||||
|
|
|
@ -47,6 +47,7 @@ set(SRC
|
|||
geometry/geom_dial_gizmo.c
|
||||
gizmo_types/arrow2d_gizmo.c
|
||||
gizmo_types/arrow3d_gizmo.c
|
||||
gizmo_types/blank3d_gizmo.c
|
||||
gizmo_types/button2d_gizmo.c
|
||||
gizmo_types/cage2d_gizmo.c
|
||||
gizmo_types/cage3d_gizmo.c
|
||||
|
|
|
@ -40,6 +40,7 @@ void ED_gizmotypes_dial_3d(void);
|
|||
void ED_gizmotypes_grab_3d(void);
|
||||
void ED_gizmotypes_facemap_3d(void);
|
||||
void ED_gizmotypes_primitive_3d(void);
|
||||
void ED_gizmotypes_blank_3d(void);
|
||||
|
||||
struct wmGizmo;
|
||||
struct wmGizmoGroup;
|
||||
|
|
|
@ -136,6 +136,7 @@ void ED_spacetypes_init(void)
|
|||
ED_gizmotypes_arrow_2d();
|
||||
ED_gizmotypes_arrow_3d();
|
||||
ED_gizmotypes_primitive_3d();
|
||||
ED_gizmotypes_blank_3d();
|
||||
ED_gizmotypes_cage_2d();
|
||||
ED_gizmotypes_cage_3d();
|
||||
|
||||
|
|
|
@ -148,7 +148,9 @@ enum {
|
|||
#define MAN_AXIS_RANGE_SCALE_START MAN_AXIS_SCALE_X
|
||||
#define MAN_AXIS_RANGE_SCALE_END (MAN_AXIS_SCALE_ZX + 1)
|
||||
|
||||
MAN_AXIS_LAST = MAN_AXIS_RANGE_SCALE_END,
|
||||
MAN_AXIS_APRON_C,
|
||||
|
||||
MAN_AXIS_LAST = MAN_AXIS_APRON_C + 1,
|
||||
};
|
||||
|
||||
/* axis types */
|
||||
|
@ -162,6 +164,7 @@ enum {
|
|||
typedef struct GizmoGroup {
|
||||
bool all_hidden;
|
||||
int twtype;
|
||||
int axis_type_default;
|
||||
|
||||
/* Users may change the twtype, detect changes to re-setup gizmo options. */
|
||||
int twtype_init;
|
||||
|
@ -193,7 +196,7 @@ static wmGizmo *gizmo_get_axis_from_index(const GizmoGroup *man, const short axi
|
|||
return man->gizmos[axis_idx];
|
||||
}
|
||||
|
||||
static short gizmo_get_axis_type(const int axis_idx)
|
||||
static short gizmo_get_axis_type(const int axis_idx, const int axis_type_default)
|
||||
{
|
||||
if (axis_idx >= MAN_AXIS_RANGE_TRANS_START && axis_idx < MAN_AXIS_RANGE_TRANS_END) {
|
||||
return MAN_AXES_TRANSLATE;
|
||||
|
@ -204,6 +207,9 @@ static short gizmo_get_axis_type(const int axis_idx)
|
|||
if (axis_idx >= MAN_AXIS_RANGE_SCALE_START && axis_idx < MAN_AXIS_RANGE_SCALE_END) {
|
||||
return MAN_AXES_SCALE;
|
||||
}
|
||||
if (axis_idx == MAN_AXIS_APRON_C) {
|
||||
return axis_type_default;
|
||||
}
|
||||
BLI_assert(0);
|
||||
return -1;
|
||||
}
|
||||
|
@ -326,6 +332,8 @@ static bool gizmo_is_axis_visible(
|
|||
rv3d->twdrawflag & MAN_SCALE_X &&
|
||||
(twtype & SCE_MANIP_TRANSLATE) == 0 &&
|
||||
(twtype & SCE_MANIP_ROTATE) == 0);
|
||||
case MAN_AXIS_APRON_C:
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -1169,9 +1177,11 @@ static void gizmo_xform_message_subscribe(
|
|||
if (type_fn == TRANSFORM_GGT_gizmo) {
|
||||
extern PropertyRNA rna_ToolSettings_transform_pivot_point;
|
||||
extern PropertyRNA rna_ToolSettings_use_gizmo_mode;
|
||||
extern PropertyRNA rna_ToolSettings_use_gizmo_apron;
|
||||
const PropertyRNA *props[] = {
|
||||
&rna_ToolSettings_transform_pivot_point,
|
||||
&rna_ToolSettings_use_gizmo_mode,
|
||||
&rna_ToolSettings_use_gizmo_apron,
|
||||
};
|
||||
for (int i = 0; i < ARRAY_SIZE(props); i++) {
|
||||
WM_msg_subscribe_rna(mbus, &toolsettings_ptr, props[i], &msg_sub_value_gz_tag_refresh, __func__);
|
||||
|
@ -1204,6 +1214,12 @@ static GizmoGroup *gizmogroup_init(wmGizmoGroup *gzgroup)
|
|||
const wmGizmoType *gzt_dial = WM_gizmotype_find("GIZMO_GT_dial_3d", true);
|
||||
const wmGizmoType *gzt_prim = WM_gizmotype_find("GIZMO_GT_primitive_3d", true);
|
||||
|
||||
/* Fallback action. */
|
||||
{
|
||||
const wmGizmoType *gzt_mask = WM_gizmotype_find("GIZMO_GT_blank_3d", true);
|
||||
man->gizmos[MAN_AXIS_APRON_C] = WM_gizmo_new_ptr(gzt_mask, gzgroup, NULL);
|
||||
}
|
||||
|
||||
#define GIZMO_NEW_ARROW(v, draw_style) { \
|
||||
man->gizmos[v] = WM_gizmo_new_ptr(gzt_arrow, gzgroup, NULL); \
|
||||
RNA_enum_set(man->gizmos[v]->ptr, "draw_style", draw_style); \
|
||||
|
@ -1291,9 +1307,23 @@ static void gizmogroup_init_properties_from_twtype(wmGizmoGroup *gzgroup)
|
|||
wmOperatorType *translate, *rotate, *trackball, *resize;
|
||||
} ot_store = {NULL};
|
||||
GizmoGroup *man = gzgroup->customdata;
|
||||
|
||||
if (man->twtype & SCE_MANIP_TRANSLATE) {
|
||||
man->axis_type_default = MAN_AXES_TRANSLATE;
|
||||
}
|
||||
else if (man->twtype & SCE_MANIP_ROTATE) {
|
||||
man->axis_type_default = MAN_AXES_ROTATE;
|
||||
}
|
||||
else if (man->twtype & SCE_MANIP_SCALE) {
|
||||
man->axis_type_default = MAN_AXES_SCALE;
|
||||
}
|
||||
else {
|
||||
man->axis_type_default = 0;
|
||||
}
|
||||
|
||||
MAN_ITER_AXES_BEGIN(axis, axis_idx)
|
||||
{
|
||||
const short axis_type = gizmo_get_axis_type(axis_idx);
|
||||
const short axis_type = gizmo_get_axis_type(axis_idx, man->axis_type_default);
|
||||
bool constraint_axis[3] = {1, 0, 0};
|
||||
PointerRNA *ptr;
|
||||
|
||||
|
@ -1356,6 +1386,9 @@ static void gizmogroup_init_properties_from_twtype(wmGizmoGroup *gzgroup)
|
|||
WM_gizmo_set_scale(axis, 0.2f);
|
||||
}
|
||||
break;
|
||||
case MAN_AXIS_APRON_C:
|
||||
WM_gizmo_set_scale(axis, 1.2f);
|
||||
break;
|
||||
}
|
||||
|
||||
switch (axis_type) {
|
||||
|
@ -1472,7 +1505,7 @@ static void WIDGETGROUP_gizmo_refresh(const bContext *C, wmGizmoGroup *gzgroup)
|
|||
|
||||
MAN_ITER_AXES_BEGIN(axis, axis_idx)
|
||||
{
|
||||
const short axis_type = gizmo_get_axis_type(axis_idx);
|
||||
const short axis_type = gizmo_get_axis_type(axis_idx, man->axis_type_default);
|
||||
const int aidx_norm = gizmo_orientation_axis(axis_idx, NULL);
|
||||
|
||||
WM_gizmo_set_matrix_location(axis, rv3d->twmat[3]);
|
||||
|
@ -1537,6 +1570,7 @@ static void WIDGETGROUP_gizmo_message_subscribe(
|
|||
|
||||
static void WIDGETGROUP_gizmo_draw_prepare(const bContext *C, wmGizmoGroup *gzgroup)
|
||||
{
|
||||
const Scene *scene = CTX_data_scene(C);
|
||||
GizmoGroup *man = gzgroup->customdata;
|
||||
// ScrArea *sa = CTX_wm_area(C);
|
||||
ARegion *ar = CTX_wm_region(C);
|
||||
|
@ -1560,9 +1594,13 @@ static void WIDGETGROUP_gizmo_draw_prepare(const bContext *C, wmGizmoGroup *gzgr
|
|||
|
||||
MAN_ITER_AXES_BEGIN(axis, axis_idx)
|
||||
{
|
||||
const short axis_type = gizmo_get_axis_type(axis_idx);
|
||||
const short axis_type = gizmo_get_axis_type(axis_idx, man->axis_type_default);
|
||||
/* XXX maybe unset _HIDDEN flag on redraw? */
|
||||
if (gizmo_is_axis_visible(rv3d, man->twtype, idot, axis_type, axis_idx)) {
|
||||
|
||||
if (axis_idx == MAN_AXIS_APRON_C) {
|
||||
WM_gizmo_set_flag(axis, WM_GIZMO_HIDDEN, (scene->toolsettings->gizmo_flag & SCE_MANIP_DISABLE_APRON) != 0);
|
||||
}
|
||||
else if (gizmo_is_axis_visible(rv3d, man->twtype, idot, axis_type, axis_idx)) {
|
||||
WM_gizmo_set_flag(axis, WM_GIZMO_HIDDEN, false);
|
||||
}
|
||||
else {
|
||||
|
@ -1580,6 +1618,7 @@ static void WIDGETGROUP_gizmo_draw_prepare(const bContext *C, wmGizmoGroup *gzgr
|
|||
case MAN_AXIS_ROT_C:
|
||||
case MAN_AXIS_SCALE_C:
|
||||
case MAN_AXIS_ROT_T:
|
||||
case MAN_AXIS_APRON_C:
|
||||
WM_gizmo_set_matrix_rotation_from_z_axis(axis, rv3d->viewinv[2]);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -2053,9 +2053,13 @@ typedef enum eImagePaintMode {
|
|||
#define EDGE_MODE_TAG_FREESTYLE 5
|
||||
|
||||
/* ToolSettings.gizmo_flag */
|
||||
#define SCE_MANIP_TRANSLATE 1
|
||||
#define SCE_MANIP_ROTATE 2
|
||||
#define SCE_MANIP_SCALE 4
|
||||
enum {
|
||||
SCE_MANIP_TRANSLATE = (1 << 0),
|
||||
SCE_MANIP_ROTATE = (1 << 1),
|
||||
SCE_MANIP_SCALE = (1 << 2),
|
||||
|
||||
SCE_MANIP_DISABLE_APRON = (1 << 3),
|
||||
};
|
||||
|
||||
/* ToolSettings.gpencil_flags */
|
||||
typedef enum eGPencil_Flags {
|
||||
|
|
|
@ -2426,6 +2426,11 @@ static void rna_def_tool_settings(BlenderRNA *brna)
|
|||
RNA_def_property_ui_text(prop, "Gizmo Mode", "");
|
||||
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, "rna_ToolSettings_gizmo_flag_update");
|
||||
|
||||
prop = RNA_def_property(srna, "use_gizmo_apron", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_negative_sdna(prop, NULL, "gizmo_flag", SCE_MANIP_DISABLE_APRON);
|
||||
RNA_def_property_ui_text(prop, "Apron", "Handle input not directly over the gizmo");
|
||||
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
|
||||
|
||||
/* Grease Pencil */
|
||||
prop = RNA_def_property(srna, "use_gpencil_additive_drawing", PROP_BOOLEAN, PROP_NONE);
|
||||
RNA_def_property_boolean_sdna(prop, NULL, "gpencil_flags", GP_TOOL_FLAG_RETAIN_LAST);
|
||||
|
|
Loading…
Reference in New Issue