Visibility panel: Use "toggle" keyword
authorDalai Felinto <dfelinto@gmail.com>
Wed, 22 May 2019 16:18:44 +0000 (16:18 +0000)
committerDalai Felinto <dfelinto@gmail.com>
Wed, 22 May 2019 16:22:02 +0000 (16:22 +0000)
No functional nor visual change.
This is a partial revert of 0910932e71d2.

The toggle option was introduced on 6640bcca7422.
This allow us to simplify the outliner draw code so it uses the icon as
defined in the RNA (as oppose to get the value there once again).

release/scripts/startup/bl_ui/properties_object.py
source/blender/editors/space_outliner/outliner_draw.c
source/blender/makesrna/intern/rna_object.c

index aeda8d8..526ec17 100644 (file)
@@ -396,11 +396,11 @@ class OBJECT_PT_visibility(ObjectButtonsPanel, Panel):
         ob = context.object
 
         col = flow.column()
-        col.prop(ob, "hide_viewport", text="Show in Viewports", invert_checkbox=True)
+        col.prop(ob, "hide_viewport", text="Show in Viewports", toggle=False, invert_checkbox=True)
         col = flow.column()
-        col.prop(ob, "hide_render", text="Show in Renders", invert_checkbox=True)
+        col.prop(ob, "hide_render", text="Show in Renders", toggle=False, invert_checkbox=True)
         col = flow.column()
-        col.prop(ob, "hide_select", text="Selectable", invert_checkbox=True)
+        col.prop(ob, "hide_select", text="Selectable", toggle=False, invert_checkbox=True)
 
 
 class OBJECT_PT_custom_props(ObjectButtonsPanel, PropertyPanel, Panel):
index 3a3cdaf..aed7af3 100644 (file)
@@ -1088,13 +1088,10 @@ static void outliner_draw_restrictbuts(uiBlock *block,
         }
 
         if (soops->show_restrict_flags & SO_RESTRICT_SELECT) {
-          const int icon = RNA_property_boolean_get(&ptr, props.object_hide_select) ?
-                               ICON_RESTRICT_SELECT_ON :
-                               ICON_RESTRICT_SELECT_OFF;
           bt = uiDefIconButR_prop(block,
                                   UI_BTYPE_ICON_TOGGLE,
                                   0,
-                                  icon,
+                                  0,
                                   (int)(ar->v2d.cur.xmax - restrict_offsets.select),
                                   te->ys,
                                   UI_UNIT_X,
@@ -1116,13 +1113,10 @@ static void outliner_draw_restrictbuts(uiBlock *block,
         }
 
         if (soops->show_restrict_flags & SO_RESTRICT_VIEWPORT) {
-          const int icon = RNA_property_boolean_get(&ptr, props.object_hide_viewport) ?
-                               ICON_RESTRICT_VIEW_ON :
-                               ICON_RESTRICT_VIEW_OFF;
           bt = uiDefIconButR_prop(block,
                                   UI_BTYPE_ICON_TOGGLE,
                                   0,
-                                  icon,
+                                  0,
                                   (int)(ar->v2d.cur.xmax - restrict_offsets.viewport),
                                   te->ys,
                                   UI_UNIT_X,
@@ -1144,13 +1138,10 @@ static void outliner_draw_restrictbuts(uiBlock *block,
         }
 
         if (soops->show_restrict_flags & SO_RESTRICT_RENDER) {
-          const int icon = RNA_property_boolean_get(&ptr, props.object_hide_render) ?
-                               ICON_RESTRICT_RENDER_ON :
-                               ICON_RESTRICT_RENDER_OFF;
           bt = uiDefIconButR_prop(block,
                                   UI_BTYPE_ICON_TOGGLE,
                                   0,
-                                  icon,
+                                  0,
                                   (int)(ar->v2d.cur.xmax - restrict_offsets.render),
                                   te->ys,
                                   UI_UNIT_X,
index 716a323..e2f566c 100644 (file)
@@ -2819,6 +2819,7 @@ static void rna_def_object(BlenderRNA *brna)
   RNA_def_property_boolean_sdna(prop, NULL, "restrictflag", OB_RESTRICT_VIEWPORT);
   RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
   RNA_def_property_ui_text(prop, "Disable in Viewports", "Globally disable in viewports");
+  RNA_def_property_ui_icon(prop, ICON_RESTRICT_VIEW_OFF, -1);
   RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_hide_update");
 
   prop = RNA_def_property(srna, "hide_select", PROP_BOOLEAN, PROP_NONE);
@@ -2826,12 +2827,14 @@ static void rna_def_object(BlenderRNA *brna)
   RNA_def_property_clear_flag(prop, PROP_ANIMATABLE);
   RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
   RNA_def_property_ui_text(prop, "Disable Selection", "Disable selection in viewport");
+  RNA_def_property_ui_icon(prop, ICON_RESTRICT_SELECT_OFF, -1);
   RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_hide_update");
 
   prop = RNA_def_property(srna, "hide_render", PROP_BOOLEAN, PROP_NONE);
   RNA_def_property_boolean_sdna(prop, NULL, "restrictflag", OB_RESTRICT_RENDER);
   RNA_def_property_override_flag(prop, PROPOVERRIDE_OVERRIDABLE_STATIC);
   RNA_def_property_ui_text(prop, "Disable in Renders", "Globally disable in renders");
+  RNA_def_property_ui_icon(prop, ICON_RESTRICT_RENDER_OFF, -1);
   RNA_def_property_update(prop, NC_OBJECT | ND_DRAW, "rna_Object_hide_update");
 
   prop = RNA_def_property(srna, "show_instancer_for_render", PROP_BOOLEAN, PROP_NONE);