Commit: bc506314905264a4ee10be3e732d16c155edca8c
Author: Campbell Barton
Date:   Tue Jun 20 15:38:08 2017 +1000
Branches: custom-manipulators
https://developer.blender.org/rBbc506314905264a4ee10be3e732d16c155edca8c

Use id-properties for manipulator type data

===================================================================

M       release/scripts/modules/bpy_types.py
M       source/blender/blenkernel/BKE_screen.h
M       source/blender/editors/include/ED_manipulator_library.h
M       source/blender/editors/manipulator_library/arrow2d_manipulator.c
M       source/blender/editors/manipulator_library/arrow3d_manipulator.c
M       source/blender/editors/manipulator_library/cage2d_manipulator.c
M       source/blender/editors/manipulator_library/dial3d_manipulator.c
M       source/blender/editors/manipulator_library/grab3d_manipulator.c
M       source/blender/editors/manipulator_library/primitive3d_manipulator.c
M       source/blender/editors/mesh/editmesh_bisect.c
M       source/blender/editors/mesh/editmesh_extrude.c
M       source/blender/editors/screen/area.c
M       source/blender/editors/space_action/space_action.c
M       source/blender/editors/space_buttons/space_buttons.c
M       source/blender/editors/space_clip/space_clip.c
M       source/blender/editors/space_console/space_console.c
M       source/blender/editors/space_file/space_file.c
M       source/blender/editors/space_graph/space_graph.c
M       source/blender/editors/space_image/space_image.c
M       source/blender/editors/space_info/space_info.c
M       source/blender/editors/space_logic/space_logic.c
M       source/blender/editors/space_nla/space_nla.c
M       source/blender/editors/space_node/node_manipulators.c
M       source/blender/editors/space_node/space_node.c
M       source/blender/editors/space_outliner/space_outliner.c
M       source/blender/editors/space_script/space_script.c
M       source/blender/editors/space_sequencer/space_sequencer.c
M       source/blender/editors/space_text/space_text.c
M       source/blender/editors/space_time/space_time.c
M       source/blender/editors/space_userpref/space_userpref.c
M       source/blender/editors/space_view3d/space_view3d.c
M       source/blender/editors/space_view3d/view3d_manipulators.c
M       source/blender/editors/transform/transform_manipulator.c
M       source/blender/editors/transform/transform_manipulator2d.c
M       source/blender/makesrna/RNA_access.h
M       source/blender/makesrna/intern/rna_wm_manipulator.c
M       source/blender/python/intern/bpy_manipulator_wrap.c
M       source/blender/python/intern/bpy_rna.c
M       source/blender/windowmanager/manipulators/WM_manipulator_api.h
M       source/blender/windowmanager/manipulators/WM_manipulator_types.h
M       source/blender/windowmanager/manipulators/intern/wm_manipulator.c
M       source/blender/windowmanager/manipulators/intern/wm_manipulator_intern.h
M       source/blender/windowmanager/manipulators/intern/wm_manipulator_map.c
M       
source/blender/windowmanager/manipulators/intern/wm_manipulator_property.c
M       source/blender/windowmanager/manipulators/intern/wm_manipulator_type.c

===================================================================

diff --git a/release/scripts/modules/bpy_types.py 
b/release/scripts/modules/bpy_types.py
index 600b29a6b2b..28dd6657b0d 100644
--- a/release/scripts/modules/bpy_types.py
+++ b/release/scripts/modules/bpy_types.py
@@ -592,6 +592,33 @@ class OrderedMeta(RNAMeta):
         return OrderedDictMini()  # collections.OrderedDict()
 
 
+# Same as 'Operator'
+# only without 'as_keywords'
+class Manipulator(StructRNA, metaclass=OrderedMeta):
+    __slots__ = ()
+
+    def __getattribute__(self, attr):
+        properties = StructRNA.path_resolve(self, "properties")
+        bl_rna = getattr(properties, "bl_rna", None)
+        if (bl_rna is not None) and (attr in bl_rna.properties):
+            return getattr(properties, attr)
+        return super().__getattribute__(attr)
+
+    def __setattr__(self, attr, value):
+        properties = StructRNA.path_resolve(self, "properties")
+        bl_rna = getattr(properties, "bl_rna", None)
+        if (bl_rna is not None) and (attr in bl_rna.properties):
+            return setattr(properties, attr, value)
+        return super().__setattr__(attr, value)
+
+    def __delattr__(self, attr):
+        properties = StructRNA.path_resolve(self, "properties")
+        bl_rna = getattr(properties, "bl_rna", None)
+        if (bl_rna is not None) and (attr in bl_rna.properties):
+            return delattr(properties, attr)
+        return super().__delattr__(attr)
+
+
 # Only defined so operators members can be used by accessing self.order
 # with doc generation 'self.properties.bl_rna.properties' can fail
 class Operator(StructRNA, metaclass=OrderedMeta):
diff --git a/source/blender/blenkernel/BKE_screen.h 
b/source/blender/blenkernel/BKE_screen.h
index 6ff344fea38..d78ddbfca2b 100644
--- a/source/blender/blenkernel/BKE_screen.h
+++ b/source/blender/blenkernel/BKE_screen.h
@@ -130,7 +130,7 @@ typedef struct ARegionType {
        int regionid;           /* unique identifier within this space, defines 
RGN_TYPE_xxxx */
        
        /* add handlers, stuff you only do once or on area/region type/size 
changes */
-       void (*init)(struct wmWindowManager *, struct ARegion *);
+       void (*init)(struct wmWindowManager *, const struct bScreen *, struct 
ARegion *);
        /* exit is called when the region is hidden or removed */
        void (*exit)(struct wmWindowManager *, struct ARegion *);
        /* draw entirely, view changes should be handled here */
diff --git a/source/blender/editors/include/ED_manipulator_library.h 
b/source/blender/editors/include/ED_manipulator_library.h
index 421fdbf1212..b1970a7bab3 100644
--- a/source/blender/editors/include/ED_manipulator_library.h
+++ b/source/blender/editors/include/ED_manipulator_library.h
@@ -64,70 +64,61 @@ void ED_manipulator_draw_preset_facemap(
 /* 3D Arrow Manipulator */
 
 enum {
-       ED_MANIPULATOR_ARROW_STYLE_NORMAL        =  1,
-       ED_MANIPULATOR_ARROW_STYLE_NO_AXIS       = (1 << 1),
-       ED_MANIPULATOR_ARROW_STYLE_CROSS         = (1 << 2),
+       ED_MANIPULATOR_ARROW_STYLE_NORMAL        = 0,
+       ED_MANIPULATOR_ARROW_STYLE_CROSS         = 1,
+       ED_MANIPULATOR_ARROW_STYLE_BOX           = 2,
+       ED_MANIPULATOR_ARROW_STYLE_CONE          = 3,
+};
+
+enum {
        /* inverted offset during interaction - if set it also sets constrained 
below */
        ED_MANIPULATOR_ARROW_STYLE_INVERTED      = (1 << 3),
        /* clamp arrow interaction to property width */
        ED_MANIPULATOR_ARROW_STYLE_CONSTRAINED   = (1 << 4),
-       /* use a box for the arrowhead */
-       ED_MANIPULATOR_ARROW_STYLE_BOX           = (1 << 5),
-       ED_MANIPULATOR_ARROW_STYLE_CONE          = (1 << 6),
 };
 
-void ED_manipulator_arrow3d_set_style(struct wmManipulator *mpr, int style);
-void ED_manipulator_arrow3d_set_line_len(struct wmManipulator *mpr, const 
float len);
 void ED_manipulator_arrow3d_set_ui_range(struct wmManipulator *mpr, const 
float min, const float max);
 void ED_manipulator_arrow3d_set_range_fac(struct wmManipulator *mpr, const 
float range_fac);
-void ED_manipulator_arrow3d_cone_set_aspect(struct wmManipulator *mpr, const 
float aspect[2]);
-
 
 /* -------------------------------------------------------------------- */
 /* 2D Arrow Manipulator */
 
-void ED_manipulator_arrow2d_set_angle(struct wmManipulator *mpr, const float 
rot_fac);
-void ED_manipulator_arrow2d_set_line_len(struct wmManipulator *mpr, const 
float len);
-
+/* none */
 
 /* -------------------------------------------------------------------- */
 /* Cage Manipulator */
 
 enum {
-       ED_MANIPULATOR_RECT_TRANSFORM_STYLE_TRANSLATE       =  1,       /* 
Manipulator translates */
-       ED_MANIPULATOR_RECT_TRANSFORM_STYLE_ROTATE          = (1 << 1), /* 
Manipulator rotates */
-       ED_MANIPULATOR_RECT_TRANSFORM_STYLE_SCALE           = (1 << 2), /* 
Manipulator scales */
-       ED_MANIPULATOR_RECT_TRANSFORM_STYLE_SCALE_UNIFORM   = (1 << 3), /* 
Manipulator scales uniformly */
+       ED_MANIPULATOR_RECT_TRANSFORM_FLAG_TRANSLATE        = (1 << 0), /* 
Manipulator translates */
+       ED_MANIPULATOR_RECT_TRANSFORM_FLAG_ROTATE           = (1 << 1), /* 
Manipulator rotates */
+       ED_MANIPULATOR_RECT_TRANSFORM_FLAG_SCALE            = (1 << 2), /* 
Manipulator scales */
+       ED_MANIPULATOR_RECT_TRANSFORM_FLAG_SCALE_UNIFORM    = (1 << 3), /* 
Manipulator scales uniformly */
 };
 
-void ED_manipulator_cage2d_transform_set_style(struct wmManipulator *mpr, int 
style);
-void ED_manipulator_cage2d_transform_set_dims(
-        struct wmManipulator *mpr, const float width, const float height);
-
-
 /* -------------------------------------------------------------------- */
 /* Dial Manipulator */
 
+/* draw_options */
 enum {
-       ED_MANIPULATOR_DIAL_STYLE_RING = 0,
-       ED_MANIPULATOR_DIAL_STYLE_RING_CLIPPED = 1,
-       ED_MANIPULATOR_DIAL_STYLE_RING_FILLED = 2,
+       ED_MANIPULATOR_DIAL_DRAW_FLAG_NOP               = 0,
+       ED_MANIPULATOR_DIAL_DRAW_FLAG_CLIP              = (1 << 0),
+       ED_MANIPULATOR_DIAL_DRAW_FLAG_FILL              = (1 << 1),
+       ED_MANIPULATOR_DIAL_DRAW_FLAG_ANGLE_MIRROR      = (1 << 2),
+       ED_MANIPULATOR_DIAL_DRAW_FLAG_ANGLE_START_Y     = (1 << 3),
 };
 
-void ED_manipulator_dial3d_set_style(struct wmManipulator *mpr, int style);
-void ED_manipulator_dial3d_set_use_start_y_axis(
-        struct wmManipulator *mpr, const bool enabled);
-void ED_manipulator_dial3d_set_use_double_helper(
-        struct wmManipulator *mpr, const bool enabled);
-
 /* -------------------------------------------------------------------- */
 /* Grab Manipulator */
 
+/* draw_options */
 enum {
-       ED_MANIPULATOR_GRAB_STYLE_RING = 0,
+       ED_MANIPULATOR_GRAB_DRAW_FLAG_NOP               = 0,
+       ED_MANIPULATOR_GRAB_DRAW_FLAG_FILL              = (1 << 0),
 };
 
-void ED_manipulator_grab3d_set_style(struct wmManipulator *mpr, int style);
+enum {
+       ED_MANIPULATOR_GRAB_STYLE_RING = 0,
+};
 
 
 /* -------------------------------------------------------------------- */
@@ -137,7 +128,4 @@ enum {
        ED_MANIPULATOR_PRIMITIVE_STYLE_PLANE = 0,
 };
 
-void ED_manipulator_primitive3d_set_style(struct wmManipulator *mpr, int 
style);
-
-
 #endif  /* __ED_MANIPULATOR_LIBRARY_H__ */
diff --git a/source/blender/editors/manipulator_library/arrow2d_manipulator.c 
b/source/blender/editors/manipulator_library/arrow2d_manipulator.c
index 6e263b86bfa..adc23667d58 100644
--- a/source/blender/editors/manipulator_library/arrow2d_manipulator.c
+++ b/source/blender/editors/manipulator_library/arrow2d_manipulator.c
@@ -51,6 +51,7 @@
 #include "MEM_guardedalloc.h"
 
 #include "RNA_access.h"
+#include "RNA_define.h"
 
 #include "WM_types.h"
 
@@ -59,32 +60,24 @@
 
 #include "manipulator_library_intern.h"
 
-
-typedef struct ArrowManipulator2D {
-       struct wmManipulator manipulator;
-
-       float angle;
-       float line_len;
-} ArrowManipulator2D;
-
-
-static void arrow2d_draw_geom(ArrowManipulator2D *arrow, const float 
matrix[4][4], const float color[4])
+static void arrow2d_draw_geom(wmManipulator *mpr, const float matrix[4][4], 
const float color[4])
 {
        const float size = 0.11f;
        const float size_h = size / 2.0f;
-       const float len = arrow->line_len;
-       const float draw_line_ofs = (arrow->manipulator.line_width * 0.5f) / 
arrow->manipulator.scale;
+       const float arrow_length = RNA_float_get(mpr->ptr, "length");
+       const float arrow_angle = RNA_float_get(mpr->ptr, "angle");
+       const float draw_line_ofs = (mpr->line_width * 0.5f) / mpr->scale;
 
        uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", 
GWN_COMP_F32, 2, GWN_FETCH_FLOAT);
 
        gpuPushMatrix();
        gpuMultMatrix(matrix);
-       gpuScaleUniform(arrow->manipulator.scale);
-       gpuRotate2D(RAD2DEGF(arrow->angle));
+       gpuScaleUniform(mpr->scale);
+       gpuRotate2D(RAD2DEGF(arrow_angle));
        /* local offset */
        gpuTranslate2f(
-               arrow->manipulator.matrix_offset[3][0] + draw_line_ofs,
-               arrow->manipulator.matrix_offset[3][1]);
+               mpr->matrix_offset[3][0] + draw_line_ofs,
+               mpr->matrix_offset[3][1]);
 
        immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR);
 
@@ -92,13 +85,13 @@ static void arrow2d_draw_geom(ArrowManipulator2D *arrow, 
const float matrix[4][4
 
        immBegin(GWN_PRIM_LINES, 2);
        immVertex2f(pos, 0.0f, 0.0f);
-       immVertex2f(pos, 0.0f, len);
+       immVertex2f(pos, 0.0f, arrow_length);
        immEnd();
 
        immBegin(GWN_PRIM_TRIS, 3);
-       immVertex2f(pos, size_h, len);
-       immVertex2f(pos, -size_h, len);
-       immVertex2f(pos, 0.0f, len + size * 1.7f);
+       immVertex2f(pos, size_h, arrow_length);
+       immVertex2f(pos, -size_h, arrow_length);
+       immVertex2f(pos, 0.0f, arrow_length + size * 1.7f);
        immEnd();
 
        immUnbindProgram();
@@ -106,38 +99,33 @@ static void arrow2d_draw_geom(ArrowManipulator2D *arrow, 
const float matrix[4][4
        gpuPopMatrix();
 }
 
-static void manipulator_arrow2d_draw(const bContext *UNUSED(C), struct 
wmManipulator *mpr)
+static void manipulator_arrow2d_draw(const bContext *UNUSED(C), wmManipulator 
*mpr)
 {
-       ArrowManipulator2D *arrow = (ArrowManipulator2D *)mpr;
        float col[4];
 
        manipulator_color_get(mpr, mpr->state & WM_MANIPULATOR_STATE_HIGHLIGHT, 
col);
 
        glLineWidth(mpr->line_width);
        glEnable(GL_BLEND);
-       arrow2d_draw_geom(arrow, mpr->matrix, col);
+       arrow2d_draw_geom(mpr, mpr->matrix, col);
        glDisable(GL_BLEND);
 
        if (mpr->interaction_data) {
-               ManipulatorInteraction *inter = 
arrow->manipulator.interaction_data;
+               ManipulatorInteraction *inter = mpr->interaction_data;
 
                glEnable(GL_BLEND);
-               arrow2d_draw_geom(arrow, inter->init_matrix, (const f

@@ Diff output truncated at 10240 characters. @@

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

Reply via email to