Revision: 17531
          
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=17531
Author:   blendix
Date:     2008-11-21 20:14:38 +0100 (Fri, 21 Nov 2008)

Log Message:
-----------
RNA

* Added RNA for operators. This still uses ID properties internally,
  but through the RNA API now. The OP_get/set_* API that was used is
  replaced by the RNA API. Currently RNA properties for operators are
  defined at runtime since it means operator registration can be done
  in a single function.
* Changed the existing operators to use this system, I haven't defined
  user interface names yet though. I also think there need to be some
  conventions on which properties to expose to make these operators
  usable in macros, for example if mouse coordinates should be stored
  or not.
* When using ID properties through defined RNA properties, it now
  checks that the ID property actually matches the RNA property and
  removes/overwrites it otherwise. This ensures that you can safely
  get/set arrays for example without having to worry that some
  external thing may have changed the length.
* Documentation now has some information on RNA + ID properties.

http://wiki.blender.org/index.php/BlenderDev/Blender2.5/RNA

Modified Paths:
--------------
    branches/blender2.5/blender/source/blender/editors/screen/Makefile
    branches/blender2.5/blender/source/blender/editors/screen/SConscript
    branches/blender2.5/blender/source/blender/editors/screen/screen_ops.c
    
branches/blender2.5/blender/source/blender/editors/space_outliner/space_outliner.c
    branches/blender2.5/blender/source/blender/editors/space_time/Makefile
    branches/blender2.5/blender/source/blender/editors/space_time/SConscript
    branches/blender2.5/blender/source/blender/editors/space_time/time_ops.c
    
branches/blender2.5/blender/source/blender/makesdna/DNA_windowmanager_types.h
    branches/blender2.5/blender/source/blender/makesrna/intern/rna_access.c
    branches/blender2.5/blender/source/blender/windowmanager/SConscript
    branches/blender2.5/blender/source/blender/windowmanager/WM_api.h
    branches/blender2.5/blender/source/blender/windowmanager/intern/Makefile
    branches/blender2.5/blender/source/blender/windowmanager/intern/wm.c
    
branches/blender2.5/blender/source/blender/windowmanager/intern/wm_event_system.c
    
branches/blender2.5/blender/source/blender/windowmanager/intern/wm_init_exit.c
    
branches/blender2.5/blender/source/blender/windowmanager/intern/wm_operators.c

Modified: branches/blender2.5/blender/source/blender/editors/screen/Makefile
===================================================================
--- branches/blender2.5/blender/source/blender/editors/screen/Makefile  
2008-11-21 18:01:12 UTC (rev 17530)
+++ branches/blender2.5/blender/source/blender/editors/screen/Makefile  
2008-11-21 19:14:38 UTC (rev 17531)
@@ -44,6 +44,7 @@
 CPPFLAGS += -I../../blenkernel
 CPPFLAGS += -I../../blenlib
 CPPFLAGS += -I../../makesdna
+CPPFLAGS += -I../../makesrna
 CPPFLAGS += -I../../imbuf
 CPPFLAGS += -I../../python
 CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include

Modified: branches/blender2.5/blender/source/blender/editors/screen/SConscript
===================================================================
--- branches/blender2.5/blender/source/blender/editors/screen/SConscript        
2008-11-21 18:01:12 UTC (rev 17530)
+++ branches/blender2.5/blender/source/blender/editors/screen/SConscript        
2008-11-21 19:14:38 UTC (rev 17531)
@@ -4,7 +4,7 @@
 sources = env.Glob('*.c')
 
 incs = '../include ../../blenlib ../../blenkernel ../../makesdna ../../imbuf'
-incs += ' ../../blenloader ../../windowmanager ../../python'
+incs += ' ../../blenloader ../../windowmanager ../../python ../../makesrna'
 incs += ' #/intern/guardedalloc #/extern/glew/include'
 
 env.BlenderLib ( 'bf_editors_screen', sources, Split(incs), [], 
libtype=['core','intern'], priority=[30, 35] )

Modified: branches/blender2.5/blender/source/blender/editors/screen/screen_ops.c
===================================================================
--- branches/blender2.5/blender/source/blender/editors/screen/screen_ops.c      
2008-11-21 18:01:12 UTC (rev 17530)
+++ branches/blender2.5/blender/source/blender/editors/screen/screen_ops.c      
2008-11-21 19:14:38 UTC (rev 17531)
@@ -42,6 +42,9 @@
 #include "ED_screen.h"
 #include "ED_screen_types.h"
 
+#include "RNA_access.h"
+#include "RNA_define.h"
+
 #include "screen_intern.h"     /* own module include */
 
 /* ************** Exported Poll tests ********************** */
@@ -463,12 +466,9 @@
        int x, y;
 
        /* required properties */
-       if(!(OP_get_int(op, "x", &x) && OP_get_int(op, "y", &y)))
-               return 0;
+       x= RNA_int_get(op->rna, "x");
+       y= RNA_int_get(op->rna, "y");
 
-       /* default properties */
-       OP_verify_int(op, "delta", 0, NULL);
-
        /* setup */
        actedge= screen_find_active_scredge(C->screen, x, y);
        if(actedge==NULL) return 0;
@@ -523,7 +523,7 @@
        sAreaMoveData *md= op->customdata;
        int delta;
        
-       OP_get_int(op, "delta", &delta);
+       delta= RNA_int_get(op->rna, "delta");
        area_move_apply_do(C, md->origval, delta, md->dir, md->bigger, 
md->smaller);
 }
 
@@ -552,8 +552,8 @@
 /* interaction callback */
 static int area_move_invoke(bContext *C, wmOperator *op, wmEvent *event)
 {
-       OP_verify_int(op, "x", event->x, NULL);
-       OP_verify_int(op, "y", event->y, NULL);
+       RNA_int_default(op->rna, "x", event->x);
+       RNA_int_default(op->rna, "y", event->y);
 
        if(!area_move_init(C, op)) 
                return OPERATOR_PASS_THROUGH;
@@ -568,7 +568,7 @@
 {
        WM_event_remove_modal_handler(&C->window->handlers, op);                
                
 
-       OP_set_int(op, "delta", 0);
+       RNA_int_set(op->rna, "delta", 0);
        area_move_apply(C, op);
        area_move_exit(C, op);
 
@@ -583,14 +583,14 @@
 
        md= op->customdata;
 
-       OP_get_int(op, "x", &x);
-       OP_get_int(op, "y", &y);
+       x= RNA_int_get(op->rna, "x");
+       y= RNA_int_get(op->rna, "y");
 
        /* execute the events */
        switch(event->type) {
                case MOUSEMOVE:
                        delta= (md->dir == 'v')? event->x - x: event->y - y;
-                       OP_set_int(op, "delta", delta);
+                       RNA_int_set(op->rna, "delta", delta);
 
                        area_move_apply(C, op);
                        break;
@@ -612,6 +612,8 @@
 
 void ED_SCR_OT_area_move(wmOperatorType *ot)
 {
+       PropertyRNA *prop;
+
        /* identifiers */
        ot->name= "Move area edges";
        ot->idname= "ED_SCR_OT_area_move";
@@ -622,6 +624,11 @@
        ot->modal= area_move_modal;
 
        ot->poll= ED_operator_screen_mainwinactive; /* when mouse is over 
area-edge */
+
+       /* rna */
+       prop= RNA_def_property(ot->rna, "x", PROP_INT, PROP_NONE);
+       prop= RNA_def_property(ot->rna, "y", PROP_INT, PROP_NONE);
+       prop= RNA_def_property(ot->rna, "delta", PROP_INT, PROP_NONE);
 }
 
 /* ************** split area operator *********************************** */
@@ -687,8 +694,7 @@
        if(C->area==NULL) return 0;
        
        /* required properties */
-       OP_verify_float(op, "fac", 0.5f, NULL);
-       OP_verify_int(op, "dir", 'h', &dir);
+       dir= RNA_enum_get(op->rna, "dir");
        
        /* minimal size */
        if(dir=='v' && C->area->winx < 2*AREAMINX) return 0;
@@ -740,8 +746,8 @@
        float fac;
        int dir;
        
-       OP_get_float(op, "fac", &fac);
-       OP_get_int(op, "dir", &dir);
+       fac= RNA_float_get(op->rna, "fac");
+       dir= RNA_enum_get(op->rna, "dir");
 
        sd->narea= area_split(C->window, C->screen, sd->sarea, dir, fac);
        
@@ -801,13 +807,13 @@
                /* prepare operator state vars */
                if(sad->gesture_dir==AZONE_N || sad->gesture_dir==AZONE_S) {
                        dir= 'h';
-                       OP_set_float(op, "fac", ((float)(event->x - 
sad->sa1->v1->vec.x)) / (float)sad->sa1->winx);
+                       RNA_float_set(op->rna, "fac", ((float)(event->x - 
sad->sa1->v1->vec.x)) / (float)sad->sa1->winx);
                }
                else {
                        dir= 'v';
-                       OP_set_float(op, "fac", ((float)(event->y - 
sad->sa1->v1->vec.y)) / (float)sad->sa1->winy);
+                       RNA_float_set(op->rna, "fac", ((float)(event->y - 
sad->sa1->v1->vec.y)) / (float)sad->sa1->winy);
                }
-               OP_set_int(op, "dir", dir);
+               RNA_enum_set(op->rna, "dir", dir);
 
                /* general init, also non-UI case, adds customdata, sets area 
and defaults */
                if(!area_split_init(C, op))
@@ -870,9 +876,8 @@
        /* execute the events */
        switch(event->type) {
                case MOUSEMOVE:
+                       dir= RNA_enum_get(op->rna, "dir");
                        
-                       OP_get_int(op, "dir", &dir);
-                       
                        sd->delta= (dir == 'v')? event->x - sd->origval: 
event->y - sd->origval;
                        area_move_apply_do(C, sd->origval, sd->delta, dir, 
sd->bigger, sd->smaller);
                        
@@ -896,6 +901,9 @@
 
 void ED_SCR_OT_area_split(wmOperatorType *ot)
 {
+       PropertyRNA *prop;
+    static EnumPropertyItem prop_direction_items[] = {{'h', "HORIZONTAL", 
"Horizontal"}, {'v', "VERTICAL", "Vertical"}, {0, NULL, NULL}};
+
        ot->name = "Split area";
        ot->idname = "ED_SCR_OT_area_split";
        
@@ -904,6 +912,15 @@
        ot->modal= area_split_modal;
        
        ot->poll= ED_operator_screenactive; /* XXX should be area active */
+
+       /* rna */
+       prop= RNA_def_property(ot->rna, "dir", PROP_ENUM, PROP_NONE);
+       RNA_def_property_enum_items(prop, prop_direction_items);
+       RNA_def_property_enum_default(prop, 'h');
+
+       prop= RNA_def_property(ot->rna, "fac", PROP_FLOAT, PROP_NONE);
+       RNA_def_property_range(prop, 0.0, 1.0);
+       RNA_def_property_float_default(prop, 0.5f);
 }
 
 /* ************** join area operator 
********************************************** */
@@ -956,10 +973,10 @@
        int x2, y2;
 
        /* required properties, make negative to get return 0 if not set by 
caller */
-       OP_verify_int(op, "x1", -100, &x1);
-       OP_verify_int(op, "y1", -100, &y1);
-       OP_verify_int(op, "x2", -100, &x2);
-       OP_verify_int(op, "y2", -100, &y2);
+       x1= RNA_int_get(op->rna, "x1");
+       y1= RNA_int_get(op->rna, "y1");
+       x2= RNA_int_get(op->rna, "x2");
+       y2= RNA_int_get(op->rna, "y2");
        
        sa1 = screen_areahascursor(C->screen, x1, y1);
        sa2 = screen_areahascursor(C->screen, x2, y2);
@@ -1035,10 +1052,10 @@
                        return OPERATOR_PASS_THROUGH;
                
                /* prepare operator state vars */
-               OP_set_int(op, "x1", sad->x);
-               OP_set_int(op, "y1", sad->y);
-               OP_set_int(op, "x2", event->x);
-               OP_set_int(op, "y2", event->y);
+               RNA_int_set(op->rna, "x1", sad->x);
+               RNA_int_set(op->rna, "y1", sad->y);
+               RNA_int_set(op->rna, "x2", event->x);
+               RNA_int_set(op->rna, "y2", event->y);
 
                if(!area_join_init(C, op)) 
                        return OPERATOR_PASS_THROUGH;
@@ -1163,6 +1180,8 @@
 /* Operator for joining two areas (space types) */
 void ED_SCR_OT_area_join(wmOperatorType *ot)
 {
+       PropertyRNA *prop;
+
        /* identifiers */
        ot->name= "Join area";
        ot->idname= "ED_SCR_OT_area_join";
@@ -1173,6 +1192,16 @@
        ot->modal= area_join_modal;
 
        ot->poll= ED_operator_screenactive;
+
+       /* rna */
+       prop= RNA_def_property(ot->rna, "x1", PROP_INT, PROP_NONE);
+       RNA_def_property_int_default(prop, -100);
+       prop= RNA_def_property(ot->rna, "y1", PROP_INT, PROP_NONE);
+       RNA_def_property_int_default(prop, -100);
+       prop= RNA_def_property(ot->rna, "x2", PROP_INT, PROP_NONE);
+       RNA_def_property_int_default(prop, -100);
+       prop= RNA_def_property(ot->rna, "y2", PROP_INT, PROP_NONE);
+       RNA_def_property_int_default(prop, -100);
 }
 
 /* ************** border select operator (test only) 
***************************** */

Modified: 
branches/blender2.5/blender/source/blender/editors/space_outliner/space_outliner.c
===================================================================
--- 
branches/blender2.5/blender/source/blender/editors/space_outliner/space_outliner.c
  2008-11-21 18:01:12 UTC (rev 17530)
+++ 
branches/blender2.5/blender/source/blender/editors/space_outliner/space_outliner.c
  2008-11-21 19:14:38 UTC (rev 17531)
@@ -511,6 +511,9 @@
 {
        SpaceOops *soutliner= (SpaceOops *)sl;
        SpaceOops *soutlinern= MEM_dupallocN(soutliner);
+
+       if(soutlinern->rnapath)
+               soutlinern->rnapath= MEM_dupallocN(soutlinern->rnapath);
        
        return (SpaceLink *)soutlinern;
 }

Modified: branches/blender2.5/blender/source/blender/editors/space_time/Makefile
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_time/Makefile      
2008-11-21 18:01:12 UTC (rev 17530)
+++ branches/blender2.5/blender/source/blender/editors/space_time/Makefile      
2008-11-21 19:14:38 UTC (rev 17531)
@@ -44,6 +44,7 @@
 CPPFLAGS += -I../../blenkernel
 CPPFLAGS += -I../../blenlib
 CPPFLAGS += -I../../makesdna
+CPPFLAGS += -I../../makesrna
 CPPFLAGS += -I../../imbuf
 CPPFLAGS += -I../../python
 CPPFLAGS += -I$(NAN_GUARDEDALLOC)/include

Modified: 
branches/blender2.5/blender/source/blender/editors/space_time/SConscript
===================================================================
--- branches/blender2.5/blender/source/blender/editors/space_time/SConscript    
2008-11-21 18:01:12 UTC (rev 17530)
+++ branches/blender2.5/blender/source/blender/editors/space_time/SConscript    
2008-11-21 19:14:38 UTC (rev 17531)
@@ -4,6 +4,7 @@
 sources = env.Glob('*.c')
 
 incs = '../include ../../blenlib ../../blenkernel ../../makesdna ../../imbuf'
-incs += '../../windowmanager #/intern/guardedalloc #/extern/glew/include'
+incs += ' ../../windowmanager #/intern/guardedalloc #/extern/glew/include'
+incs += ' ../../makesrna'
 

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
http://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to