Fix T39028: Quadview views inaccessible with python except bottom right view.
authorBastien Montagne <montagne29@wanadoo.fr>
Tue, 11 Mar 2014 14:07:53 +0000 (15:07 +0100)
committerBastien Montagne <montagne29@wanadoo.fr>
Tue, 11 Mar 2014 14:22:09 +0000 (15:22 +0100)
Expose all four quadviews in a collection in RNA API.

Note the region returned by old region_quadview property is now region_quadviews[2].

release/scripts/startup/bl_ui/space_view3d.py
source/blender/makesrna/intern/rna_space.c

index 98c855d9419c0991c9336b151e6b55ebc3b6dda8..8d5170af837859109b648f4451a4dd90f6b2ada0 100644 (file)
@@ -2693,8 +2693,7 @@ class VIEW3D_PT_view3d_properties(Panel):
         view = context.space_data
 
         col = layout.column()
-        col.active = bool(view.region_3d.view_perspective != 'CAMERA' or
-                          view.region_quadview)
+        col.active = bool(view.region_3d.view_perspective != 'CAMERA' or view.region_quadviews)
         col.prop(view, "lens")
         col.label(text="Lock to Object:")
         col.prop(view, "lock_object", text="")
@@ -2817,11 +2816,10 @@ class VIEW3D_PT_view3d_display(Panel):
 
         layout.separator()
 
-        region = view.region_quadview
-
         layout.operator("screen.region_quadview", text="Toggle Quad View")
 
-        if region:
+        if view.region_quadviews:
+            region = view.region_quadviews[2]
             col = layout.column()
             col.prop(region, "lock_rotation")
             row = col.row()
index 0cc37a6c8c6cf70ce05fcdbf61f1a76b7cd1ee55..9bfb9f79305dd46c523a681a650729d927517a18 100644 (file)
@@ -472,22 +472,33 @@ static PointerRNA rna_SpaceView3D_region_3d_get(PointerRNA *ptr)
        return rna_pointer_inherit_refine(ptr, &RNA_RegionView3D, regiondata);
 }
 
-static PointerRNA rna_SpaceView3D_region_quadview_get(PointerRNA *ptr)
+static void rna_SpaceView3D_region_quadviews_begin(CollectionPropertyIterator *iter, PointerRNA *ptr)
 {
        View3D *v3d = (View3D *)(ptr->data);
        ScrArea *sa = rna_area_from_space(ptr);
-       void *regiondata = NULL;
-       if (sa) {
-               ListBase *regionbase = (sa->spacedata.first == v3d) ? &sa->regionbase : &v3d->regionbase;
-               ARegion *ar = regionbase->last; /* always before last in list, weak .. */
+       int i = 3;
+
+       ARegion *ar = ((sa && sa->spacedata.first == v3d) ? &sa->regionbase : &v3d->regionbase)->last;
+       ListBase lb = {NULL, NULL};
+
+       if (ar && ar->alignment == RGN_ALIGN_QSPLIT) {
+               while (i-- && ar) {
+                       ar = ar->prev;
+               }
 
-               ar = (ar->alignment == RGN_ALIGN_QSPLIT) ? ar->prev : NULL;
-               if (ar) {
-                       regiondata = ar->regiondata;
+               if (i < 0) {
+                       lb.first = ar;
                }
        }
 
-       return rna_pointer_inherit_refine(ptr, &RNA_RegionView3D, regiondata);
+       rna_iterator_listbase_begin(iter, &lb, NULL);
+}
+
+static PointerRNA rna_SpaceView3D_region_quadviews_get(CollectionPropertyIterator *iter)
+{
+       void *regiondata = ((ARegion *)rna_iterator_listbase_get(iter))->regiondata;
+
+       return rna_pointer_inherit_refine(&iter->parent, &RNA_RegionView3D, regiondata);
 }
 
 static void rna_RegionView3D_quadview_update(Main *UNUSED(main), Scene *UNUSED(scene), PointerRNA *ptr)
@@ -2033,10 +2044,13 @@ static void rna_def_space_view3d(BlenderRNA *brna)
        RNA_def_property_pointer_funcs(prop, "rna_SpaceView3D_region_3d_get", NULL, NULL, NULL);
        RNA_def_property_ui_text(prop, "3D Region", "3D region in this space, in case of quad view the camera region");
 
-       prop = RNA_def_property(srna, "region_quadview", PROP_POINTER, PROP_NONE);
+       prop = RNA_def_property(srna, "region_quadviews", PROP_COLLECTION, PROP_NONE);
        RNA_def_property_struct_type(prop, "RegionView3D");
-       RNA_def_property_pointer_funcs(prop, "rna_SpaceView3D_region_quadview_get", NULL, NULL, NULL);
-       RNA_def_property_ui_text(prop, "Quad View Region", "3D region that defines the quad view settings");
+       RNA_def_property_collection_funcs(prop, "rna_SpaceView3D_region_quadviews_begin", "rna_iterator_listbase_next",
+                                         "rna_iterator_listbase_end", "rna_SpaceView3D_region_quadviews_get",
+                                         NULL, NULL, NULL, NULL);
+       RNA_def_property_ui_text(prop, "Quad View Regions", "3D regions (the third one defines quad view settings, "
+                                                           "the forth one is same as 'region_3d')");
 
        prop = RNA_def_property(srna, "show_reconstruction", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "flag2", V3D_SHOW_RECONSTRUCTION);