diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-03-25 11:30:59 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-03-25 11:30:59 +0300 |
commit | 6d8a945f06e3dfd720de4839d9df67989ce32388 (patch) | |
tree | f91c4e96bb59b29cfd6c7e40628f9228c538f1f2 | |
parent | a5bbfd9fcaaf8f314ba96bade208ca0c66091ac1 (diff) |
UI: replace popovers with prop_popover_enum
-rw-r--r-- | release/scripts/startup/bl_ui/space_view3d.py | 46 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_scene.c | 34 |
2 files changed, 17 insertions, 63 deletions
diff --git a/release/scripts/startup/bl_ui/space_view3d.py b/release/scripts/startup/bl_ui/space_view3d.py index cf2eefb0804..bf0b7371d87 100644 --- a/release/scripts/startup/bl_ui/space_view3d.py +++ b/release/scripts/startup/bl_ui/space_view3d.py @@ -135,27 +135,25 @@ class VIEW3D_HT_header(Header): # Orientation if object_mode in {'OBJECT', 'EDIT', 'EDIT_GPENCIL'} or has_pose_mode: orient_slot = scene.transform_orientation_slots[0] - trans_name, trans_icon = orient_slot.ui_info() - row = layout.row(align=True) sub = row.row() sub.ui_units_x = 4 - sub.popover( + sub.prop_popover_enum( + orient_slot, + "type", + text="", panel="VIEW3D_PT_transform_orientations", - text=trans_name, - icon_value=trans_icon, ) # Pivot if object_mode in {'OBJECT', 'EDIT', 'EDIT_GPENCIL', 'SCULPT_GPENCIL'} or has_pose_mode: - pivot_point = tool_settings.transform_pivot_point - act_pivot_point = bpy.types.ToolSettings.bl_rna.properties["transform_pivot_point"].enum_items[pivot_point] - row = layout.row(align=True) - row.popover( - panel="VIEW3D_PT_pivot_point", - icon=act_pivot_point.icon, + layout.prop_popover_enum( + tool_settings, + "transform_pivot_point", text="", + icon_only=True, + panel="VIEW3D_PT_pivot_point", ) # Snap @@ -228,29 +226,19 @@ class VIEW3D_HT_header(Header): # grease pencil if object_mode == 'PAINT_GPENCIL': - origin = tool_settings.gpencil_stroke_placement_view3d - gp_origin = tool_settings.bl_rna.properties["gpencil_stroke_placement_view3d"].enum_items[origin] - - or_icon = getattr(gp_origin, "icon", "BLANK1") - or_name = getattr(gp_origin, "name", "Stroke Placement") - layout.popover( + layout.prop_popover_enum( + tool_settings, + "gpencil_stroke_placement_view3d", + text="", panel="VIEW3D_PT_gpencil_origin", - text=or_name, - icon=or_icon, ) if object_mode in {'PAINT_GPENCIL', 'SCULPT_GPENCIL'}: - lock = tool_settings.gpencil_sculpt.lock_axis - gp_lock = tool_settings.gpencil_sculpt.bl_rna.properties["lock_axis"].enum_items[lock] - - lk_icon = getattr(gp_lock, "icon", "BLANK1") - lk_name = getattr(gp_lock, "name", "None") - row = layout.row() - row.enabled = tool_settings.gpencil_stroke_placement_view3d in {'ORIGIN', 'CURSOR'} - row.popover( + row.prop_popover_enum( + tool_settings.gpencil_sculpt, + "lock_axis", + text="", panel="VIEW3D_PT_gpencil_lock", - text=lk_name, - icon=lk_icon, ) if object_mode == 'PAINT_GPENCIL': diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index 9bab1bf5d6d..fd465d51ae6 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -2124,26 +2124,6 @@ const EnumPropertyItem *rna_TransformOrientation_with_scene_itemf( #undef V3D_ORIENT_DEFAULT -void rna_TransformOrientationSlot_ui_info( - ID *scene_id, TransformOrientationSlot *orient_slot, - char *r_name, int *r_icon_value) -{ - Scene *scene = (Scene *)scene_id; - - if (orient_slot->type < V3D_ORIENT_CUSTOM) { - const EnumPropertyItem *items = rna_enum_transform_orientation_items; - const int i = RNA_enum_from_value(items, orient_slot->type); - strcpy(r_name, items[i].name); - *r_icon_value = items[i].icon; - } - else { - TransformOrientation *orientation = BKE_scene_transform_orientation_find( - scene, orient_slot->index_custom); - strcpy(r_name, orientation->name); - *r_icon_value = ICON_OBJECT_ORIGIN; - } -} - static const EnumPropertyItem *rna_UnitSettings_itemf_wrapper( const int system, const int type, bool *r_free) { @@ -2330,20 +2310,6 @@ static void rna_def_transform_orientation_slot(BlenderRNA *brna) RNA_def_property_boolean_sdna(prop, NULL, "flag", SELECT); 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; - PropertyRNA *parm; - - /* UI access only (avoid slow RNA introspection). */ - func = RNA_def_function(srna, "ui_info", "rna_TransformOrientationSlot_ui_info"); - RNA_def_function_ui_description(func, ""); - RNA_def_function_flag(func, FUNC_USE_SELF_ID); - parm = RNA_def_string(func, "name", NULL, sizeof(((TransformOrientation *)NULL)->name), "name", ""); - RNA_def_parameter_flags(parm, PROP_THICK_WRAP, 0); - RNA_def_function_output(func, parm); - parm = RNA_def_property(func, "icon_value", PROP_INT, PROP_NONE); - RNA_def_property_ui_text(parm, "", ""); - RNA_def_function_output(func, parm); } static void rna_def_view3d_cursor(BlenderRNA *brna) |