Gizmo: move transform to a persistent option

Based on feedback from animators, this is useful to keep as a view
option (as in 2.7x).

Now the transform gizmos can be enabled from the popover,
the tools still work for location/scale/rotation.
The transform tool has been removed.

See T63518
This commit is contained in:
2019-04-13 20:36:53 +02:00
parent 6815efc3ff
commit 14884cda1f
15 changed files with 218 additions and 214 deletions

View File

@@ -4385,6 +4385,15 @@ def km_transform_modal_map(_params):
return keymap
def km_transform_gizmo(_params):
keymap = (
"Transform Gizmo Context",
{"space_type": 'VIEW_3D', "region_type": 'WINDOW'},
{"items": _template_items_gizmo_tweak_value()},
)
return keymap
def km_backdrop_transform_widget_tweak_modal_map(_params):
keymap = (
"Backdrop Transform Widget Tweak Modal Map",
@@ -6145,6 +6154,7 @@ def generate_keymaps(params=None):
# Gizmos.
km_gizmos(params),
km_transform_gizmo(params),
km_backdrop_transform_widget_tweak_modal_map(params),
km_backdrop_crop_widget(params),
km_backdrop_crop_widget_tweak_modal_map(params),

View File

@@ -77,7 +77,7 @@ class _template_widget:
props = tool.gizmo_group_properties("VIEW3D_GGT_xform_extrude")
layout.prop(props, "axis_type", expand=True)
class TRANSFORM_GGT_gizmo:
class VIEW3D_GGT_xform_gizmo:
@staticmethod
def draw_settings_with_index(context, layout, index):
scene = context.scene
@@ -237,13 +237,13 @@ class _defs_transform:
@ToolDef.from_fn
def translate():
def draw_settings(context, layout, tool):
_template_widget.TRANSFORM_GGT_gizmo.draw_settings_with_index(context, layout, 1)
_template_widget.VIEW3D_GGT_xform_gizmo.draw_settings_with_index(context, layout, 1)
return dict(
idname="builtin.move",
label="Move",
# cursor='SCROLL_XY',
icon="ops.transform.translate",
widget="TRANSFORM_GGT_gizmo",
widget="VIEW3D_GGT_xform_gizmo",
operator="transform.translate",
keymap="3D View Tool: Move",
draw_settings=draw_settings,
@@ -252,13 +252,13 @@ class _defs_transform:
@ToolDef.from_fn
def rotate():
def draw_settings(context, layout, tool):
_template_widget.TRANSFORM_GGT_gizmo.draw_settings_with_index(context, layout, 2)
_template_widget.VIEW3D_GGT_xform_gizmo.draw_settings_with_index(context, layout, 2)
return dict(
idname="builtin.rotate",
label="Rotate",
# cursor='SCROLL_XY',
icon="ops.transform.rotate",
widget="TRANSFORM_GGT_gizmo",
widget="VIEW3D_GGT_xform_gizmo",
operator="transform.rotate",
keymap="3D View Tool: Rotate",
draw_settings=draw_settings,
@@ -267,13 +267,13 @@ class _defs_transform:
@ToolDef.from_fn
def scale():
def draw_settings(context, layout, tool):
_template_widget.TRANSFORM_GGT_gizmo.draw_settings_with_index(context, layout, 3)
_template_widget.VIEW3D_GGT_xform_gizmo.draw_settings_with_index(context, layout, 3)
return dict(
idname="builtin.scale",
label="Scale",
# cursor='SCROLL_XY',
icon="ops.transform.resize",
widget="TRANSFORM_GGT_gizmo",
widget="VIEW3D_GGT_xform_gizmo",
operator="transform.resize",
keymap="3D View Tool: Scale",
draw_settings=draw_settings,
@@ -282,7 +282,7 @@ class _defs_transform:
@ToolDef.from_fn
def scale_cage():
def draw_settings(context, layout, tool):
_template_widget.TRANSFORM_GGT_gizmo.draw_settings_with_index(context, layout, 3)
_template_widget.VIEW3D_GGT_xform_gizmo.draw_settings_with_index(context, layout, 3)
return dict(
idname="builtin.scale_cage",
label="Scale Cage",
@@ -293,31 +293,6 @@ class _defs_transform:
draw_settings=draw_settings,
)
@ToolDef.from_fn
def transform():
def draw_settings(context, layout, tool):
if not layout.use_property_split:
layout.label(text="Gizmos:")
tool_settings = context.tool_settings
layout.prop(tool_settings, "use_gizmo_mode")
props = tool.gizmo_group_properties("TRANSFORM_GGT_gizmo")
layout.prop(props, "drag_action")
_template_widget.TRANSFORM_GGT_gizmo.draw_settings_with_index(context, layout, 1)
return dict(
idname="builtin.transform",
label="Transform",
description=(
"Supports any combination of grab, rotate & scale at once"
),
icon="ops.transform.transform",
widget="TRANSFORM_GGT_gizmo",
keymap="3D View Tool: Transform",
draw_settings=draw_settings,
)
class _defs_view3d_select:
@@ -724,7 +699,7 @@ class _defs_edit_mesh:
props = tool.operator_properties("transform.shear")
layout.label(text="View Axis:")
layout.prop(props, "shear_axis", expand=True)
_template_widget.TRANSFORM_GGT_gizmo.draw_settings_with_index(context, layout, 2)
_template_widget.VIEW3D_GGT_xform_gizmo.draw_settings_with_index(context, layout, 2)
return dict(
idname="builtin.shear",
label="Shear",
@@ -1690,7 +1665,6 @@ class VIEW3D_PT_tools_active(ToolSelectPanelHelper, Panel):
# for reuse
_tools_transform = (
_defs_transform.transform,
_defs_transform.translate,
_defs_transform.rotate,
(

View File

@@ -4775,6 +4775,7 @@ class VIEW3D_PT_gizmo_display(Panel):
def draw(self, context):
layout = self.layout
scene = context.scene
view = context.space_data
overlay = view.overlay
@@ -4784,8 +4785,14 @@ class VIEW3D_PT_gizmo_display(Panel):
col.active = view.show_gizmo
colsub = col.column()
colsub.prop(view, "show_gizmo_navigate", text="Navigate")
colsub.prop(view, "show_gizmo_context", text="Active Object")
colsub.prop(view, "show_gizmo_tool", text="Active Tools")
colsub.prop(view, "show_gizmo_context", text="Active Object")
col.label(text="Transform Gizmos")
rowsub = col.row()
rowsub.active = view.show_gizmo_context
rowsub.prop(view, "show_gizmo_transform")
col.prop(scene.transform_orientation_slots[1], "type", text="")
class VIEW3D_PT_overlay(Panel):

View File

@@ -128,6 +128,7 @@ float BKE_scene_frame_get(const struct Scene *scene);
float BKE_scene_frame_get_from_ctime(const struct Scene *scene, const float frame);
void BKE_scene_frame_set(struct Scene *scene, double cfra);
struct TransformOrientationSlot *BKE_scene_orientation_slot_get_from_flag(struct Scene *scene, int slot_index);
struct TransformOrientationSlot *BKE_scene_orientation_slot_get(struct Scene *scene, int flag);
void BKE_scene_orientation_slot_set_index(struct TransformOrientationSlot *orient_slot, int orientation);
int BKE_scene_orientation_slot_get_index(const struct TransformOrientationSlot *orient_slot);

View File

@@ -651,7 +651,6 @@ void BKE_scene_init(Scene *sce)
sce->toolsettings->uvcalc_flag = UVCALC_TRANSFORM_CORRECT;
sce->toolsettings->unwrapper = 1;
sce->toolsettings->select_thresh = 0.01f;
sce->toolsettings->gizmo_flag = SCE_GIZMO_SHOW_TRANSLATE | SCE_GIZMO_SHOW_ROTATE | SCE_GIZMO_SHOW_SCALE;
sce->toolsettings->selectmode = SCE_SELECT_VERTEX;
sce->toolsettings->uv_selectmode = UV_SELECT_VERTEX;
@@ -1347,24 +1346,28 @@ void BKE_scene_frame_set(struct Scene *scene, double cfra)
/** \name Scene Orientation Slots
* \{ */
TransformOrientationSlot *BKE_scene_orientation_slot_get(Scene *scene, int flag)
TransformOrientationSlot *BKE_scene_orientation_slot_get(Scene *scene, int slot_index)
{
BLI_assert(flag && !(flag & ~(SCE_GIZMO_SHOW_TRANSLATE | SCE_GIZMO_SHOW_ROTATE | SCE_GIZMO_SHOW_SCALE)));
int index = SCE_ORIENT_DEFAULT;
if (flag & SCE_GIZMO_SHOW_TRANSLATE) {
index = SCE_ORIENT_TRANSLATE;
}
else if (flag & SCE_GIZMO_SHOW_ROTATE) {
index = SCE_ORIENT_ROTATE;
}
else if (flag & SCE_GIZMO_SHOW_SCALE) {
index = SCE_ORIENT_SCALE;
if ((scene->orientation_slots[slot_index].flag & SELECT) == 0) {
slot_index = SCE_ORIENT_DEFAULT;
}
return &scene->orientation_slots[slot_index];
}
if ((scene->orientation_slots[index].flag & SELECT) == 0) {
index = SCE_ORIENT_DEFAULT;
TransformOrientationSlot *BKE_scene_orientation_slot_get_from_flag(Scene *scene, int flag)
{
BLI_assert(flag && !(flag & ~(V3D_GIZMO_TYPE_MASK_TRANSLATE | V3D_GIZMO_TYPE_MASK_ROTATE | V3D_GIZMO_TYPE_MASK_SCALE)));
int slot_index = SCE_ORIENT_DEFAULT;
if (flag & V3D_GIZMO_TYPE_MASK_TRANSLATE) {
slot_index = SCE_ORIENT_TRANSLATE;
}
return &scene->orientation_slots[index];
else if (flag & V3D_GIZMO_TYPE_MASK_ROTATE) {
slot_index = SCE_ORIENT_ROTATE;
}
else if (flag & V3D_GIZMO_TYPE_MASK_SCALE) {
slot_index = SCE_ORIENT_SCALE;
}
return BKE_scene_orientation_slot_get(scene, slot_index);
}
/**

View File

@@ -1830,12 +1830,6 @@ void blo_do_versions_280(FileData *fd, Library *UNUSED(lib), Main *bmain)
}
}
for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
if (scene->toolsettings->gizmo_flag == 0) {
scene->toolsettings->gizmo_flag = SCE_GIZMO_SHOW_TRANSLATE | SCE_GIZMO_SHOW_ROTATE | SCE_GIZMO_SHOW_SCALE;
}
}
if (!DNA_struct_elem_find(fd->filesdna, "RigidBodyWorld", "RigidBodyWorld_Shared", "*shared")) {
for (Scene *scene = bmain->scenes.first; scene; scene = scene->id.next) {
RigidBodyWorld *rbw = scene->rigidbody_world;

View File

@@ -155,7 +155,8 @@ void Transform_Properties(struct wmOperatorType *ot, int flags);
/* transform gizmos */
void TRANSFORM_GGT_gizmo(struct wmGizmoGroupType *gzgt);
void VIEW3D_GGT_xform_gizmo(struct wmGizmoGroupType *gzgt);
void VIEW3D_GGT_xform_gizmo_context(struct wmGizmoGroupType *gzgt);
void VIEW3D_GGT_xform_cage(struct wmGizmoGroupType *gzgt);
void VIEW3D_GGT_xform_shear(struct wmGizmoGroupType *gzgt);

View File

@@ -241,7 +241,7 @@ static void gizmo_mesh_spin_init_draw_prepare(
{
Scene *scene = CTX_data_scene(C);
const TransformOrientationSlot *orient_slot = BKE_scene_orientation_slot_get(scene, SCE_GIZMO_SHOW_ROTATE);
const TransformOrientationSlot *orient_slot = BKE_scene_orientation_slot_get(scene, SCE_ORIENT_ROTATE);
switch (orient_slot->type) {
case V3D_ORIENT_VIEW:
{

View File

@@ -697,6 +697,7 @@ static void view3d_widgets(void)
wmGizmoMapType *gzmap_type = WM_gizmomaptype_ensure(
&(const struct wmGizmoMapType_Params){SPACE_VIEW3D, RGN_TYPE_WINDOW});
WM_gizmogrouptype_append_and_link(gzmap_type, VIEW3D_GGT_xform_gizmo_context);
WM_gizmogrouptype_append_and_link(gzmap_type, VIEW3D_GGT_light_spot);
WM_gizmogrouptype_append_and_link(gzmap_type, VIEW3D_GGT_light_area);
WM_gizmogrouptype_append_and_link(gzmap_type, VIEW3D_GGT_light_target);
@@ -706,7 +707,7 @@ static void view3d_widgets(void)
WM_gizmogrouptype_append_and_link(gzmap_type, VIEW3D_GGT_empty_image);
WM_gizmogrouptype_append_and_link(gzmap_type, VIEW3D_GGT_armature_spline);
WM_gizmogrouptype_append(TRANSFORM_GGT_gizmo);
WM_gizmogrouptype_append(VIEW3D_GGT_xform_gizmo);
WM_gizmogrouptype_append(VIEW3D_GGT_xform_cage);
WM_gizmogrouptype_append(VIEW3D_GGT_xform_shear);
WM_gizmogrouptype_append(VIEW3D_GGT_xform_extrude);

View File

@@ -40,6 +40,7 @@
#include "BLI_listbase.h"
#include "BLI_math.h"
#include "BLI_utildefines.h"
#include "BLI_string.h"
#include "BKE_action.h"
#include "BKE_context.h"
@@ -273,9 +274,9 @@ static bool gizmo_is_axis_visible(
}
}
if ((axis_type == MAN_AXES_TRANSLATE && !(twtype & SCE_GIZMO_SHOW_TRANSLATE)) ||
(axis_type == MAN_AXES_ROTATE && !(twtype & SCE_GIZMO_SHOW_ROTATE)) ||
(axis_type == MAN_AXES_SCALE && !(twtype & SCE_GIZMO_SHOW_SCALE)))
if ((axis_type == MAN_AXES_TRANSLATE && !(twtype & V3D_GIZMO_TYPE_MASK_TRANSLATE)) ||
(axis_type == MAN_AXES_ROTATE && !(twtype & V3D_GIZMO_TYPE_MASK_ROTATE)) ||
(axis_type == MAN_AXES_SCALE && !(twtype & V3D_GIZMO_TYPE_MASK_SCALE)))
{
return false;
}
@@ -305,34 +306,34 @@ static bool gizmo_is_axis_visible(
case MAN_AXIS_SCALE_Z:
return (rv3d->twdrawflag & MAN_SCALE_Z);
case MAN_AXIS_SCALE_C:
return (rv3d->twdrawflag & MAN_SCALE_C && (twtype & SCE_GIZMO_SHOW_TRANSLATE) == 0);
return (rv3d->twdrawflag & MAN_SCALE_C && (twtype & V3D_GIZMO_TYPE_MASK_TRANSLATE) == 0);
case MAN_AXIS_TRANS_XY:
return (rv3d->twdrawflag & MAN_TRANS_X &&
rv3d->twdrawflag & MAN_TRANS_Y &&
(twtype & SCE_GIZMO_SHOW_ROTATE) == 0);
(twtype & V3D_GIZMO_TYPE_MASK_ROTATE) == 0);
case MAN_AXIS_TRANS_YZ:
return (rv3d->twdrawflag & MAN_TRANS_Y &&
rv3d->twdrawflag & MAN_TRANS_Z &&
(twtype & SCE_GIZMO_SHOW_ROTATE) == 0);
(twtype & V3D_GIZMO_TYPE_MASK_ROTATE) == 0);
case MAN_AXIS_TRANS_ZX:
return (rv3d->twdrawflag & MAN_TRANS_Z &&
rv3d->twdrawflag & MAN_TRANS_X &&
(twtype & SCE_GIZMO_SHOW_ROTATE) == 0);
(twtype & V3D_GIZMO_TYPE_MASK_ROTATE) == 0);
case MAN_AXIS_SCALE_XY:
return (rv3d->twdrawflag & MAN_SCALE_X &&
rv3d->twdrawflag & MAN_SCALE_Y &&
(twtype & SCE_GIZMO_SHOW_TRANSLATE) == 0 &&
(twtype & SCE_GIZMO_SHOW_ROTATE) == 0);
(twtype & V3D_GIZMO_TYPE_MASK_TRANSLATE) == 0 &&
(twtype & V3D_GIZMO_TYPE_MASK_ROTATE) == 0);
case MAN_AXIS_SCALE_YZ:
return (rv3d->twdrawflag & MAN_SCALE_Y &&
rv3d->twdrawflag & MAN_SCALE_Z &&
(twtype & SCE_GIZMO_SHOW_TRANSLATE) == 0 &&
(twtype & SCE_GIZMO_SHOW_ROTATE) == 0);
(twtype & V3D_GIZMO_TYPE_MASK_TRANSLATE) == 0 &&
(twtype & V3D_GIZMO_TYPE_MASK_ROTATE) == 0);
case MAN_AXIS_SCALE_ZX:
return (rv3d->twdrawflag & MAN_SCALE_Z &&
rv3d->twdrawflag & MAN_SCALE_X &&
(twtype & SCE_GIZMO_SHOW_TRANSLATE) == 0 &&
(twtype & SCE_GIZMO_SHOW_ROTATE) == 0);
(twtype & V3D_GIZMO_TYPE_MASK_TRANSLATE) == 0 &&
(twtype & V3D_GIZMO_TYPE_MASK_ROTATE) == 0);
}
return false;
}
@@ -1184,15 +1185,15 @@ static void gizmo_line_range(const int twtype, const short axis_type, float *r_s
switch (axis_type) {
case MAN_AXES_TRANSLATE:
if (twtype & SCE_GIZMO_SHOW_SCALE) {
if (twtype & V3D_GIZMO_TYPE_MASK_SCALE) {
*r_start = *r_len - ofs + 0.075f;
}
if (twtype & SCE_GIZMO_SHOW_ROTATE) {
if (twtype & V3D_GIZMO_TYPE_MASK_ROTATE) {
*r_len += ofs;
}
break;
case MAN_AXES_SCALE:
if (twtype & (SCE_GIZMO_SHOW_TRANSLATE | SCE_GIZMO_SHOW_ROTATE)) {
if (twtype & (V3D_GIZMO_TYPE_MASK_TRANSLATE | V3D_GIZMO_TYPE_MASK_ROTATE)) {
*r_len -= ofs + 0.025f;
}
break;
@@ -1203,7 +1204,7 @@ static void gizmo_line_range(const int twtype, const short axis_type, float *r_s
static void gizmo_xform_message_subscribe(
wmGizmoGroup *gzgroup, struct wmMsgBus *mbus,
Scene *scene, bScreen *UNUSED(screen), ScrArea *UNUSED(sa), ARegion *ar, const void *type_fn)
Scene *scene, bScreen *screen, ScrArea *sa, ARegion *ar, const void *type_fn)
{
/* Subscribe to view properties */
wmMsgSubscribeValue msg_sub_value_gz_tag_refresh = {
@@ -1213,18 +1214,18 @@ static void gizmo_xform_message_subscribe(
};
int orient_flag = 0;
if (type_fn == TRANSFORM_GGT_gizmo) {
if (type_fn == VIEW3D_GGT_xform_gizmo) {
GizmoGroup *ggd = gzgroup->customdata;
orient_flag = ggd->twtype_init;
}
else if (type_fn == VIEW3D_GGT_xform_cage) {
orient_flag = SCE_GIZMO_SHOW_SCALE;
orient_flag = V3D_GIZMO_TYPE_MASK_SCALE;
/* pass */
}
else if (type_fn == VIEW3D_GGT_xform_shear) {
orient_flag = SCE_GIZMO_SHOW_ROTATE;
orient_flag = V3D_GIZMO_TYPE_MASK_ROTATE;
}
TransformOrientationSlot *orient_slot = BKE_scene_orientation_slot_get(scene, orient_flag);
TransformOrientationSlot *orient_slot = BKE_scene_orientation_slot_get_from_flag(scene, orient_flag);
PointerRNA orient_ref_ptr;
RNA_pointer_create(&scene->id, &RNA_TransformOrientationSlot, orient_slot, &orient_ref_ptr);
const ToolSettings *ts = scene->toolsettings;
@@ -1267,18 +1268,30 @@ static void gizmo_xform_message_subscribe(
PointerRNA toolsettings_ptr;
RNA_pointer_create(&scene->id, &RNA_ToolSettings, scene->toolsettings, &toolsettings_ptr);
if (type_fn == TRANSFORM_GGT_gizmo) {
GizmoGroup *ggd = gzgroup->customdata;
if (type_fn == VIEW3D_GGT_xform_gizmo) {
extern PropertyRNA rna_ToolSettings_transform_pivot_point;
extern PropertyRNA rna_ToolSettings_use_gizmo_mode;
const PropertyRNA *props[] = {
&rna_ToolSettings_transform_pivot_point,
ggd->use_twtype_refresh ? &rna_ToolSettings_use_gizmo_mode : NULL,
};
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__);
}
}
PointerRNA view3d_ptr;
RNA_pointer_create(&screen->id, &RNA_SpaceView3D, sa->spacedata.first, &view3d_ptr);
if (type_fn == VIEW3D_GGT_xform_gizmo) {
GizmoGroup *ggd = gzgroup->customdata;
extern PropertyRNA rna_SpaceView3D_show_gizmo_transform;
const PropertyRNA *props[] = {
ggd->use_twtype_refresh ? &rna_SpaceView3D_show_gizmo_transform : NULL,
};
for (int i = 0; i < ARRAY_SIZE(props); i++) {
WM_msg_subscribe_rna(mbus, &view3d_ptr, props[i], &msg_sub_value_gz_tag_refresh, __func__);
}
}
else if (type_fn == VIEW3D_GGT_xform_cage) {
/* pass */
}
@@ -1513,7 +1526,7 @@ static void gizmogroup_init_properties_from_twtype(wmGizmoGroup *gzgroup)
case MAN_AXIS_SCALE_Z:
if (axis_idx >= MAN_AXIS_RANGE_TRANS_START && axis_idx < MAN_AXIS_RANGE_TRANS_END) {
int draw_options = 0;
if ((ggd->twtype & (SCE_GIZMO_SHOW_ROTATE | SCE_GIZMO_SHOW_SCALE)) == 0) {
if ((ggd->twtype & (V3D_GIZMO_TYPE_MASK_ROTATE | V3D_GIZMO_TYPE_MASK_SCALE)) == 0) {
draw_options |= ED_GIZMO_ARROW_DRAW_FLAG_STEM;
}
RNA_enum_set(axis->ptr, "draw_options", draw_options);
@@ -1616,24 +1629,24 @@ static void WIDGETGROUP_gizmo_setup(const bContext *C, wmGizmoGroup *gzgroup)
gzgroup->customdata = ggd;
{
ggd->twtype = 0;
ScrArea *sa = CTX_wm_area(C);
const bToolRef *tref = sa->runtime.tool;
if (tref == NULL || STREQ(tref->idname, "builtin.transform")) {
ggd->twtype = 0;
if (tref && STREQ(tref->idname, "builtin.move")) {
ggd->twtype |= V3D_GIZMO_TYPE_MASK_TRANSLATE;
}
else if (tref && STREQ(tref->idname, "builtin.rotate")) {
ggd->twtype |= V3D_GIZMO_TYPE_MASK_ROTATE;
}
else if (tref && STREQ(tref->idname, "builtin.scale")) {
ggd->twtype |= V3D_GIZMO_TYPE_MASK_SCALE;
}
else {
/* Setup all gizmos, they can be toggled via 'ToolSettings.gizmo_flag' */
ggd->twtype = SCE_GIZMO_SHOW_TRANSLATE | SCE_GIZMO_SHOW_ROTATE | SCE_GIZMO_SHOW_SCALE;
ggd->twtype = V3D_GIZMO_TYPE_MASK_TRANSLATE | V3D_GIZMO_TYPE_MASK_ROTATE | V3D_GIZMO_TYPE_MASK_SCALE;
ggd->use_twtype_refresh = true;
}
else if (STREQ(tref->idname, "builtin.move")) {
ggd->twtype |= SCE_GIZMO_SHOW_TRANSLATE;
}
else if (STREQ(tref->idname, "builtin.rotate")) {
ggd->twtype |= SCE_GIZMO_SHOW_ROTATE;
}
else if (STREQ(tref->idname, "builtin.scale")) {
ggd->twtype |= SCE_GIZMO_SHOW_SCALE;
}
BLI_assert(ggd->twtype != 0);
ggd->twtype_init = ggd->twtype;
}
@@ -1646,19 +1659,21 @@ static void WIDGETGROUP_gizmo_refresh(const bContext *C, wmGizmoGroup *gzgroup)
{
GizmoGroup *ggd = gzgroup->customdata;
Scene *scene = CTX_data_scene(C);
ScrArea *sa = CTX_wm_area(C);
View3D *v3d = sa->spacedata.first;
ARegion *ar = CTX_wm_region(C);
RegionView3D *rv3d = ar->regiondata;
struct TransformBounds tbounds;
if (ggd->use_twtype_refresh) {
ggd->twtype = scene->toolsettings->gizmo_flag & ggd->twtype_init;
ggd->twtype = v3d->gizmo_type_mask & ggd->twtype_init;
if (ggd->twtype != ggd->twtype_prev) {
ggd->twtype_prev = ggd->twtype;
gizmogroup_init_properties_from_twtype(gzgroup);
}
}
const TransformOrientationSlot *orient_slot = BKE_scene_orientation_slot_get(scene, ggd->twtype_init);
const TransformOrientationSlot *orient_slot = BKE_scene_orientation_slot_get_from_flag(scene, ggd->twtype_init);
/* skip, we don't draw anything anyway */
if ((ggd->all_hidden =
@@ -1700,7 +1715,7 @@ static void WIDGETGROUP_gizmo_refresh(const bContext *C, wmGizmoGroup *gzgroup)
RNA_float_set(axis->ptr, "length", len);
if (axis_idx >= MAN_AXIS_RANGE_TRANS_START && axis_idx < MAN_AXIS_RANGE_TRANS_END) {
if (ggd->twtype & SCE_GIZMO_SHOW_ROTATE) {
if (ggd->twtype & V3D_GIZMO_TYPE_MASK_ROTATE) {
/* Avoid rotate and translate arrows overlap. */
start_co[2] += 0.215f;
}
@@ -1738,7 +1753,7 @@ static void WIDGETGROUP_gizmo_message_subscribe(
bScreen *screen = CTX_wm_screen(C);
ScrArea *sa = CTX_wm_area(C);
ARegion *ar = CTX_wm_region(C);
gizmo_xform_message_subscribe(gzgroup, mbus, scene, screen, sa, ar, TRANSFORM_GGT_gizmo);
gizmo_xform_message_subscribe(gzgroup, mbus, scene, screen, sa, ar, VIEW3D_GGT_xform_gizmo);
}
static void WIDGETGROUP_gizmo_draw_prepare(const bContext *C, wmGizmoGroup *gzgroup)
@@ -1796,7 +1811,7 @@ static void WIDGETGROUP_gizmo_draw_prepare(const bContext *C, wmGizmoGroup *gzgr
if (!equals_m3m3(viewinv_m3, ggd->prev.viewinv_m3)) {
{
Scene *scene = CTX_data_scene(C);
const TransformOrientationSlot *orient_slot = BKE_scene_orientation_slot_get(scene, ggd->twtype_init);
const TransformOrientationSlot *orient_slot = BKE_scene_orientation_slot_get_from_flag(scene, ggd->twtype_init);
switch (orient_slot->type) {
case V3D_ORIENT_VIEW:
{
@@ -1822,7 +1837,7 @@ static void WIDGETGROUP_gizmo_invoke_prepare(
wmGizmoOpElem *gzop = WM_gizmo_operator_get(gz, 0);
PointerRNA *ptr = &gzop->ptr;
PropertyRNA *prop_orient_type = RNA_struct_find_property(ptr, "orient_type");
const TransformOrientationSlot *orient_slot = BKE_scene_orientation_slot_get(scene, ggd->twtype_init);
const TransformOrientationSlot *orient_slot = BKE_scene_orientation_slot_get_from_flag(scene, ggd->twtype_init);
if (orient_slot == &scene->orientation_slots[SCE_ORIENT_DEFAULT]) {
RNA_property_unset(ptr, prop_orient_type);
}
@@ -1871,13 +1886,9 @@ static void WIDGETGROUP_gizmo_invoke_prepare(
}
}
static bool WIDGETGROUP_gizmo_poll(const struct bContext *C, struct wmGizmoGroupType *gzgt)
static bool WIDGETGROUP_gizmo_poll_generic(View3D *v3d)
{
if (!ED_gizmo_poll_or_unlink_delayed_from_tool(C, gzgt)) {
return false;
}
View3D *v3d = CTX_wm_view3d(C);
if (v3d->gizmo_flag & (V3D_GIZMO_HIDE | V3D_GIZMO_HIDE_TOOL)) {
if (v3d->gizmo_flag & V3D_GIZMO_HIDE) {
return false;
}
if (G.moving & (G_TRANSFORM_OBJ | G_TRANSFORM_EDIT)) {
@@ -1886,31 +1897,84 @@ static bool WIDGETGROUP_gizmo_poll(const struct bContext *C, struct wmGizmoGroup
return true;
}
void TRANSFORM_GGT_gizmo(wmGizmoGroupType *gzgt)
static bool WIDGETGROUP_gizmo_poll_context(const struct bContext *C, struct wmGizmoGroupType *UNUSED(gzgt))
{
ScrArea *sa = CTX_wm_area(C);
View3D *v3d = sa->spacedata.first;
if (!WIDGETGROUP_gizmo_poll_generic(v3d)) {
return false;
}
const bToolRef *tref = sa->runtime.tool;
if (v3d->gizmo_flag & V3D_GIZMO_HIDE_CONTEXT) {
return false;
}
if ((v3d->gizmo_type_mask & (V3D_GIZMO_TYPE_MASK_TRANSLATE | V3D_GIZMO_TYPE_MASK_ROTATE | V3D_GIZMO_TYPE_MASK_SCALE)) == 0) {
return false;
}
/* Don't show if the tool has a gizmo. */
if (tref && tref->runtime && tref->runtime->gizmo_group[0]) {
return false;
}
return true;
}
static bool WIDGETGROUP_gizmo_poll_tool(const struct bContext *C, struct wmGizmoGroupType *gzgt)
{
if (!ED_gizmo_poll_or_unlink_delayed_from_tool(C, gzgt)) {
return false;
}
return true;
ScrArea *sa = CTX_wm_area(C);
View3D *v3d = sa->spacedata.first;
if (!WIDGETGROUP_gizmo_poll_generic(v3d)) {
return false;
}
if (v3d->gizmo_flag & V3D_GIZMO_HIDE_TOOL) {
return false;
}
return true;
}
/* Expose as multiple gizmos so tools use one, persistant context another.
* Needed because they use different options which isn't so simple to dynamically update. */
void VIEW3D_GGT_xform_gizmo(wmGizmoGroupType *gzgt)
{
gzgt->name = "Transform Gizmo";
gzgt->idname = "TRANSFORM_GGT_gizmo";
gzgt->idname = "VIEW3D_GGT_xform_gizmo";
gzgt->flag |= WM_GIZMOGROUPTYPE_3D;
gzgt->flag = WM_GIZMOGROUPTYPE_3D;
gzgt->gzmap_params.spaceid = SPACE_VIEW3D;
gzgt->gzmap_params.regionid = RGN_TYPE_WINDOW;
gzgt->poll = WIDGETGROUP_gizmo_poll;
gzgt->poll = WIDGETGROUP_gizmo_poll_tool;
gzgt->setup = WIDGETGROUP_gizmo_setup;
gzgt->refresh = WIDGETGROUP_gizmo_refresh;
gzgt->message_subscribe = WIDGETGROUP_gizmo_message_subscribe;
gzgt->draw_prepare = WIDGETGROUP_gizmo_draw_prepare;
gzgt->invoke_prepare = WIDGETGROUP_gizmo_invoke_prepare;
}
static const EnumPropertyItem rna_enum_gizmo_items[] = {
{SCE_GIZMO_SHOW_TRANSLATE, "TRANSLATE", 0, "Move", ""},
{SCE_GIZMO_SHOW_ROTATE, "ROTATE", 0, "Rotate", ""},
{SCE_GIZMO_SHOW_SCALE, "SCALE", 0, "Scale", ""},
{0, "NONE", 0, "None", ""},
{0, NULL, 0, NULL, NULL},
};
RNA_def_enum(gzgt->srna, "drag_action", rna_enum_gizmo_items, SCE_GIZMO_SHOW_TRANSLATE, "Drag Action", "");
/** Only poll, flag & gzmap_params differ. */
void VIEW3D_GGT_xform_gizmo_context(wmGizmoGroupType *gzgt)
{
gzgt->name = "Transform Gizmo Context";
gzgt->idname = "VIEW3D_GGT_xform_gizmo_context";
gzgt->flag = WM_GIZMOGROUPTYPE_3D | WM_GIZMOGROUPTYPE_PERSISTENT;
gzgt->poll = WIDGETGROUP_gizmo_poll_context;
gzgt->setup = WIDGETGROUP_gizmo_setup;
gzgt->refresh = WIDGETGROUP_gizmo_refresh;
gzgt->message_subscribe = WIDGETGROUP_gizmo_message_subscribe;
gzgt->draw_prepare = WIDGETGROUP_gizmo_draw_prepare;
gzgt->invoke_prepare = WIDGETGROUP_gizmo_invoke_prepare;
}
/** \} */
@@ -1997,7 +2061,7 @@ static void WIDGETGROUP_xform_cage_refresh(const bContext *C, wmGizmoGroup *gzgr
struct TransformBounds tbounds;
const TransformOrientationSlot *orient_slot = BKE_scene_orientation_slot_get(scene, SCE_GIZMO_SHOW_SCALE);
const TransformOrientationSlot *orient_slot = BKE_scene_orientation_slot_get(scene, SCE_ORIENT_SCALE);
if ((ED_transform_calc_gizmo_stats(
C, &(struct TransformCalcParams) {
@@ -2079,7 +2143,7 @@ static void WIDGETGROUP_xform_cage_draw_prepare(const bContext *C, wmGizmoGroup
RegionView3D *rv3d = CTX_wm_region_view3d(C);
{
Scene *scene = CTX_data_scene(C);
const TransformOrientationSlot *orient_slot = BKE_scene_orientation_slot_get(scene, SCE_GIZMO_SHOW_SCALE);
const TransformOrientationSlot *orient_slot = BKE_scene_orientation_slot_get(scene, SCE_ORIENT_SCALE);
switch (orient_slot->type) {
case V3D_ORIENT_VIEW:
{
@@ -2177,7 +2241,7 @@ static void WIDGETGROUP_xform_shear_refresh(const bContext *C, wmGizmoGroup *gzg
struct XFormShearWidgetGroup *xgzgroup = gzgroup->customdata;
struct TransformBounds tbounds;
const TransformOrientationSlot *orient_slot = BKE_scene_orientation_slot_get(scene, SCE_GIZMO_SHOW_ROTATE);
const TransformOrientationSlot *orient_slot = BKE_scene_orientation_slot_get(scene, SCE_ORIENT_ROTATE);
if (ED_transform_calc_gizmo_stats(
C, &(struct TransformCalcParams) {
@@ -2240,7 +2304,7 @@ static void WIDGETGROUP_xform_shear_draw_prepare(const bContext *C, wmGizmoGroup
{
Scene *scene = CTX_data_scene(C);
/* Shear is like rotate, use the rotate setting. */
const TransformOrientationSlot *orient_slot = BKE_scene_orientation_slot_get(scene, SCE_GIZMO_SHOW_ROTATE);
const TransformOrientationSlot *orient_slot = BKE_scene_orientation_slot_get(scene, SCE_ORIENT_ROTATE);
switch (orient_slot->type) {
case V3D_ORIENT_VIEW:
{

View File

@@ -1149,58 +1149,6 @@ static void TRANSFORM_OT_transform(struct wmOperatorType *ot)
P_GPENCIL_EDIT | P_CENTER);
}
static int transform_from_gizmo_invoke(bContext *C, wmOperator *UNUSED(op), const wmEvent *UNUSED(event))
{
bToolRef *tref = WM_toolsystem_ref_from_context(C);
if (tref) {
ARegion *ar = CTX_wm_region(C);
wmGizmoMap *gzmap = ar->gizmo_map;
wmGizmoGroup *gzgroup = gzmap ? WM_gizmomap_group_find(gzmap, "TRANSFORM_GGT_gizmo") : NULL;
if (gzgroup != NULL) {
PointerRNA gzg_ptr;
WM_toolsystem_ref_properties_ensure_from_gizmo_group(tref, gzgroup->type, &gzg_ptr);
const int drag_action = RNA_enum_get(&gzg_ptr, "drag_action");
const char *op_id = NULL;
switch (drag_action) {
case SCE_GIZMO_SHOW_TRANSLATE:
op_id = "TRANSFORM_OT_translate";
break;
case SCE_GIZMO_SHOW_ROTATE:
op_id = "TRANSFORM_OT_rotate";
break;
case SCE_GIZMO_SHOW_SCALE:
op_id = "TRANSFORM_OT_resize";
break;
default:
break;
}
if (op_id) {
wmOperatorType *ot = WM_operatortype_find(op_id, true);
PointerRNA op_ptr;
WM_operator_properties_create_ptr(&op_ptr, ot);
RNA_boolean_set(&op_ptr, "release_confirm", true);
WM_operator_name_call_ptr(C, ot, WM_OP_INVOKE_DEFAULT, &op_ptr);
WM_operator_properties_free(&op_ptr);
return OPERATOR_FINISHED;
}
}
}
return OPERATOR_PASS_THROUGH;
}
/* Use with 'TRANSFORM_GGT_gizmo'. */
static void TRANSFORM_OT_from_gizmo(struct wmOperatorType *ot)
{
/* identifiers */
ot->name = "Transform From Gizmo";
ot->description = "Transform selected items by mode type";
ot->idname = "TRANSFORM_OT_from_gizmo";
ot->flag = 0;
/* api callbacks */
ot->invoke = transform_from_gizmo_invoke;
}
void transform_operatortypes(void)
{
TransformModeItem *tmode;
@@ -1214,8 +1162,6 @@ void transform_operatortypes(void)
WM_operatortype_append(TRANSFORM_OT_select_orientation);
WM_operatortype_append(TRANSFORM_OT_create_orientation);
WM_operatortype_append(TRANSFORM_OT_delete_orientation);
WM_operatortype_append(TRANSFORM_OT_from_gizmo);
}
void ED_keymap_transform(wmKeyConfig *keyconf)

View File

@@ -1466,8 +1466,7 @@ typedef struct ToolSettings {
char edge_mode;
char edge_mode_live_unwrap;
/* SCE_GIZMO_SHOW_* */
char gizmo_flag;
char _pad1[1];
/* Transform */
char transform_pivot_point;
@@ -2272,13 +2271,6 @@ enum {
#define EDGE_MODE_TAG_BEVEL 4
#define EDGE_MODE_TAG_FREESTYLE 5
/* ToolSettings.gizmo_flag */
enum {
SCE_GIZMO_SHOW_TRANSLATE = (1 << 0),
SCE_GIZMO_SHOW_ROTATE = (1 << 1),
SCE_GIZMO_SHOW_SCALE = (1 << 2),
};
/* ToolSettings.gpencil_flags */
typedef enum eGPencil_Flags {
/* When creating new frames, the last frame gets used as the basis for the new one */

View File

@@ -245,7 +245,11 @@ typedef struct View3D {
float bundle_size;
/** Display style for bundle. */
char bundle_drawtype;
char _pad3[2];
/** #V3D_GIZMO_SHOW_* */
char gizmo_flag;
char _pad3[1];
/** Multiview current eye - for internal use. */
char multiview_eye;
@@ -288,7 +292,7 @@ typedef struct View3D {
char gridflag;
/** Transform gizmo info. */
char gizmo_flag;
char gizmo_type_mask;
/* actually only used to define the opacity of the grease pencil vertex in edit mode */
float vertex_opacity;
@@ -545,7 +549,7 @@ enum {
V3D_ORIENT_CUSTOM_MATRIX = (V3D_ORIENT_CUSTOM - 1),
};
/* View3d.mpr_flag (also) */
/** #View3d.gizmo_flag */
enum {
/** All gizmos. */
V3D_GIZMO_HIDE = (1 << 0),
@@ -554,6 +558,13 @@ enum {
V3D_GIZMO_HIDE_TOOL = (1 << 3),
};
/** #View3d.gizmo_type_mask */
enum {
V3D_GIZMO_TYPE_MASK_TRANSLATE = (1 << 0),
V3D_GIZMO_TYPE_MASK_ROTATE = (1 << 1),
V3D_GIZMO_TYPE_MASK_SCALE = (1 << 2),
};
#define RV3D_CAMZOOM_MIN -30
#define RV3D_CAMZOOM_MAX 600

View File

@@ -417,13 +417,6 @@ const EnumPropertyItem rna_enum_bake_pass_filter_type_items[] = {
{0, NULL, 0, NULL, NULL},
};
static const EnumPropertyItem rna_enum_gizmo_items[] = {
{SCE_GIZMO_SHOW_TRANSLATE, "TRANSLATE", 0, "Move", ""},
{SCE_GIZMO_SHOW_ROTATE, "ROTATE", 0, "Rotate", ""},
{SCE_GIZMO_SHOW_SCALE, "SCALE", 0, "Scale", ""},
{0, NULL, 0, NULL, NULL},
};
#ifndef RNA_RUNTIME
static const EnumPropertyItem rna_enum_gpencil_interpolation_mode_items[] = {
/* interpolation */
@@ -581,20 +574,12 @@ static void rna_GPencilInterpolateSettings_type_set(PointerRNA *ptr, int value)
}
}
static void rna_ToolSettings_gizmo_flag_update(Main *UNUSED(bmain), Scene *scene, PointerRNA *UNUSED(ptr))
{
ToolSettings *ts = scene->toolsettings;
if ((ts->gizmo_flag & (SCE_GIZMO_SHOW_TRANSLATE | SCE_GIZMO_SHOW_ROTATE | SCE_GIZMO_SHOW_SCALE)) == 0) {
ts->gizmo_flag |= SCE_GIZMO_SHOW_TRANSLATE;
}
}
static void rna_SpaceImageEditor_uv_sculpt_update(Main *bmain, Scene *scene, PointerRNA *UNUSED(ptr))
{
ED_space_image_uv_sculpt_update(bmain, bmain->wm.first, scene);
}
/* Read-only Iterator of all the scene objects. */
static void rna_Scene_objects_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
@@ -2678,13 +2663,6 @@ static void rna_def_tool_settings(BlenderRNA *brna)
"Scale is affected by snapping settings");
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL); /* header redraw */
prop = RNA_def_property(srna, "use_gizmo_mode", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "gizmo_flag");
RNA_def_property_enum_items(prop, rna_enum_gizmo_items);
RNA_def_property_flag(prop, PROP_ENUM_FLAG);
RNA_def_property_ui_text(prop, "Gizmo Mode", "");
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, "rna_ToolSettings_gizmo_flag_update");
/* Grease Pencil */
prop = RNA_def_property(srna, "use_gpencil_draw_additive", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "gpencil_flags", GP_TOOL_FLAG_RETAIN_LAST);

View File

@@ -513,6 +513,14 @@ static void rna_GPencil_update(Main *bmain, Scene *UNUSED(scene), PointerRNA *UN
WM_main_add_notifier(NC_GPENCIL | NA_EDITED, NULL);
}
static void rna_SpaceView3D_gizmo_flag_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *ptr)
{
View3D *v3d = ptr->data;
if ((v3d->gizmo_type_mask & (V3D_GIZMO_TYPE_MASK_TRANSLATE | V3D_GIZMO_TYPE_MASK_ROTATE | V3D_GIZMO_TYPE_MASK_SCALE)) == 0) {
v3d->gizmo_type_mask |= V3D_GIZMO_TYPE_MASK_TRANSLATE;
}
}
/* Space 3D View */
static void rna_SpaceView3D_camera_update(Main *bmain, Scene *scene, PointerRNA *ptr)
{
@@ -3093,6 +3101,13 @@ static void rna_def_space_view3d(BlenderRNA *brna)
{0, NULL, 0, NULL, NULL},
};
static const EnumPropertyItem rna_enum_gizmo_items[] = {
{V3D_GIZMO_TYPE_MASK_TRANSLATE, "TRANSLATE", 0, "Move", ""},
{V3D_GIZMO_TYPE_MASK_ROTATE, "ROTATE", 0, "Rotate", ""},
{V3D_GIZMO_TYPE_MASK_SCALE, "SCALE", 0, "Scale", ""},
{0, NULL, 0, NULL, NULL},
};
srna = RNA_def_struct(brna, "SpaceView3D", "Space");
RNA_def_struct_sdna(srna, "View3D");
RNA_def_struct_ui_text(srna, "3D View Space", "3D View space data");
@@ -3202,6 +3217,13 @@ static void rna_def_space_view3d(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Tool Gizmo", "Active tool gizmo");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, NULL);
prop = RNA_def_property(srna, "show_gizmo_transform", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_sdna(prop, NULL, "gizmo_type_mask");
RNA_def_property_enum_items(prop, rna_enum_gizmo_items);
RNA_def_property_flag(prop, PROP_ENUM_FLAG);
RNA_def_property_ui_text(prop, "Gizmo Mode", "");
RNA_def_property_update(prop, NC_SPACE | ND_SPACE_VIEW3D, "rna_SpaceView3D_gizmo_flag_update");
prop = RNA_def_property(srna, "use_local_camera", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "scenelock", 1);
RNA_def_property_boolean_funcs(prop, NULL, "rna_SpaceView3D_use_local_camera_set");