[Bf-blender-cvs] [2af0ec9457b] blender2.8: UI: move gizmo orientation settings into popover
Campbell Barton
noreply at git.blender.org
Wed Dec 19 12:45:41 CET 2018
Commit: 2af0ec9457b2997e1e903f284dd48bae6534682b
Author: Campbell Barton
Date: Wed Dec 19 22:36:33 2018 +1100
Branches: blender2.8
https://developer.blender.org/rB2af0ec9457b2997e1e903f284dd48bae6534682b
UI: move gizmo orientation settings into popover
Instead of link toggle with enum, use a single popover that contains
both settings. The code for this isn't nice - needing 3x panels for now.
See D4075
===================================================================
M release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
M release/scripts/startup/bl_ui/space_view3d.py
M source/blender/editors/transform/transform_gizmo_3d.c
M source/blender/makesrna/intern/rna_scene.c
===================================================================
diff --git a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
index 590d4299968..6a2de414ae7 100644
--- a/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
+++ b/release/scripts/startup/bl_ui/space_toolsystem_toolbar.py
@@ -67,13 +67,25 @@ class _template_widget:
class TRANSFORM_GGT_gizmo:
@staticmethod
def draw_settings_with_index(context, layout, index):
- row = layout.row(align=True)
scene = context.scene
- orientation_slot = scene.transform_orientation_slots[index]
- value = orientation_slot.use
- row.prop(orientation_slot, "use", text="", icon='LINKED' if value else 'UNLINKED')
- if not value:
- row.prop(orientation_slot, "type", text="")
+ orient_slot = scene.transform_orientation_slots[index]
+ use_global = orient_slot.use_global
+ row = layout.row(align=True)
+
+ row.label(text="Orientation:")
+
+ popover_kw = {
+ "panel": "VIEW3D_PT_transform_orientations_gizmo_" f"{index}",
+ }
+
+ if use_global:
+ popover_kw["text"], popover_kw["icon"] = "Scene", 'OBJECT_ORIGIN'
+ else:
+ popover_kw["text"], popover_kw["icon_value"] = orient_slot.ui_info()
+
+ sub = layout.row()
+ sub.ui_units_x = 4
+ sub.popover(**popover_kw)
class _defs_view3d_generic:
diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py
index 7922cdb90ec..ce2fa8a51e4 100644
--- a/release/scripts/startup/bl_ui/space_view3d.py
+++ b/release/scripts/startup/bl_ui/space_view3d.py
@@ -5270,6 +5270,40 @@ class VIEW3D_PT_transform_orientations(Panel):
row.operator("transform.delete_orientation", text="", icon='X', emboss=False)
+# XXX, each panel needs to access a different orientation index.
+# look into a way to pass this from the UI that draws it.
+def VIEW3D_PT_transform_orientations_gizmo_factory(index):
+ class VIEW3D_PT_transform_orientations_other_n(Panel):
+ bl_space_type = 'VIEW_3D'
+ bl_region_type = 'HEADER'
+ bl_label = "Transform Orientations"
+ bl_ui_units_x = 8
+ bl_idname = "VIEW3D_PT_transform_orientations_gizmo_" + str(index)
+
+ def draw(self, context):
+ layout = self.layout
+
+ layout.label(text="Transform Orientations")
+
+ scene = context.scene
+ orient_slot = scene.transform_orientation_slots[index]
+
+ layout.prop(orient_slot, "use_global", text="Scene Orientation", icon='OBJECT_ORIGIN')
+ use_global = orient_slot.use_global
+
+ col = layout.column()
+ col.active = not use_global
+ col.column().prop(orient_slot, "type", expand=True)
+
+ # Only 'VIEW3D_PT_transform_orientations' can edit
+
+ return VIEW3D_PT_transform_orientations_other_n
+
+VIEW3D_PT_transform_orientations_gizmo_1 = VIEW3D_PT_transform_orientations_gizmo_factory(1)
+VIEW3D_PT_transform_orientations_gizmo_2 = VIEW3D_PT_transform_orientations_gizmo_factory(2)
+VIEW3D_PT_transform_orientations_gizmo_3 = VIEW3D_PT_transform_orientations_gizmo_factory(3)
+
+
class VIEW3D_PT_gpencil_origin(Panel):
bl_space_type = 'VIEW_3D'
bl_region_type = 'HEADER'
@@ -5782,6 +5816,9 @@ classes = (
VIEW3D_PT_gpencil_origin,
VIEW3D_PT_gpencil_lock,
VIEW3D_PT_transform_orientations,
+ VIEW3D_PT_transform_orientations_gizmo_1,
+ VIEW3D_PT_transform_orientations_gizmo_2,
+ VIEW3D_PT_transform_orientations_gizmo_3,
VIEW3D_PT_overlay_gpencil_options,
VIEW3D_PT_context_properties,
TOPBAR_PT_gpencil_materials,
diff --git a/source/blender/editors/transform/transform_gizmo_3d.c b/source/blender/editors/transform/transform_gizmo_3d.c
index b17a345ee09..3680c8c829c 100644
--- a/source/blender/editors/transform/transform_gizmo_3d.c
+++ b/source/blender/editors/transform/transform_gizmo_3d.c
@@ -1242,10 +1242,10 @@ static void gizmo_xform_message_subscribe(
RNA_pointer_create(&scene->id, &RNA_TransformOrientationSlot, orient_slot, &orient_ref_ptr);
{
extern PropertyRNA rna_TransformOrientationSlot_type;
- extern PropertyRNA rna_TransformOrientationSlot_use;
+ extern PropertyRNA rna_TransformOrientationSlot_use_global;
const PropertyRNA *props[] = {
&rna_TransformOrientationSlot_type,
- &rna_TransformOrientationSlot_use,
+ &rna_TransformOrientationSlot_use_global,
};
for (int i = 0; i < ARRAY_SIZE(props); i++) {
if (props[i]) {
diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c
index 3a8cfbff3a1..8a3c328f131 100644
--- a/source/blender/makesrna/intern/rna_scene.c
+++ b/source/blender/makesrna/intern/rna_scene.c
@@ -2237,9 +2237,9 @@ static void rna_def_transform_orientation_slot(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Current Transform Orientation", "");
/* flag */
- prop = RNA_def_property(srna, "use", PROP_BOOLEAN, PROP_NONE);
+ prop = RNA_def_property(srna, "use_global", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", SELECT);
- RNA_def_property_ui_text(prop, "Use", "Disable to unlink the orientation from the scene-setting");
+ RNA_def_property_ui_text(prop, "Use", "Use scene orientation instead of a custom setting");
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);
FunctionRNA *func;
More information about the Bf-blender-cvs
mailing list