[Bf-blender-cvs] [7f480352caa] blender2.8: WM: move manipulator library into editors

Campbell Barton noreply at git.blender.org
Wed Jun 7 23:40:48 CEST 2017


Commit: 7f480352caaa14a20c0438ae0ed1c2607b6c2c00
Author: Campbell Barton
Date:   Thu Jun 8 07:16:47 2017 +1000
Branches: blender2.8
https://developer.blender.org/rB7f480352caaa14a20c0438ae0ed1c2607b6c2c00

WM: move manipulator library into editors

As with operators, the window-manager has the API for defining,
the editor can implement and register its own manipulators.

This exposes wmManipulator, keeping it opaque isn't
practical if editors and Python are to implement their own.

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

M	build_files/cmake/macros.cmake
M	source/blender/editors/CMakeLists.txt
A	source/blender/editors/include/ED_manipulator_library.h
A	source/blender/editors/manipulator_library/CMakeLists.txt
R090	source/blender/windowmanager/manipulators/intern/manipulator_library/arrow2d_manipulator.c	source/blender/editors/manipulator_library/arrow2d_manipulator.c
R088	source/blender/windowmanager/manipulators/intern/manipulator_library/arrow_manipulator.c	source/blender/editors/manipulator_library/arrow3d_manipulator.c
R077	source/blender/windowmanager/manipulators/intern/manipulator_library/cage_manipulator.c	source/blender/editors/manipulator_library/cage2d_manipulator.c
R089	source/blender/windowmanager/manipulators/intern/manipulator_library/dial_manipulator.c	source/blender/editors/manipulator_library/dial3d_manipulator.c
R097	source/blender/windowmanager/manipulators/intern/manipulator_library/geom_arrow_manipulator.c	source/blender/editors/manipulator_library/geom_arrow_manipulator.c
R095	source/blender/windowmanager/manipulators/intern/manipulator_library/geom_cube_manipulator.c	source/blender/editors/manipulator_library/geom_cube_manipulator.c
R099	source/blender/windowmanager/manipulators/intern/manipulator_library/geom_dial_manipulator.c	source/blender/editors/manipulator_library/geom_dial_manipulator.c
A	source/blender/editors/manipulator_library/manipulator_draw_utils.c
R094	source/blender/windowmanager/manipulators/intern/manipulator_library/manipulator_geometry.h	source/blender/editors/manipulator_library/manipulator_geometry.h
R087	source/blender/windowmanager/manipulators/intern/manipulator_library/manipulator_library_intern.h	source/blender/editors/manipulator_library/manipulator_library_intern.h
R096	source/blender/windowmanager/manipulators/intern/manipulator_library/manipulator_library_utils.c	source/blender/editors/manipulator_library/manipulator_library_utils.c
R085	source/blender/windowmanager/manipulators/intern/manipulator_library/primitive_manipulator.c	source/blender/editors/manipulator_library/primitive3d_manipulator.c
M	source/blender/editors/space_api/spacetypes.c
M	source/blender/editors/space_node/node_widgets.c
M	source/blender/editors/space_view3d/view3d_manipulators.c
M	source/blender/editors/transform/transform_manipulator.c
M	source/blender/editors/util/CMakeLists.txt
M	source/blender/windowmanager/CMakeLists.txt
M	source/blender/windowmanager/WM_api.h
D	source/blender/windowmanager/manipulators/WM_manipulator_library.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_manipulatorgroup.c
M	source/blender/windowmanager/manipulators/intern/wm_manipulatormap.c

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

diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake
index 92342d580c3..563e83fd79a 100644
--- a/build_files/cmake/macros.cmake
+++ b/build_files/cmake/macros.cmake
@@ -579,6 +579,7 @@ function(SETUP_BLENDER_SORTED_LIBS)
 		bf_editor_curve
 		bf_editor_gpencil
 		bf_editor_interface
+		bf_editor_manipulator_library
 		bf_editor_mesh
 		bf_editor_metaball
 		bf_editor_object
diff --git a/source/blender/editors/CMakeLists.txt b/source/blender/editors/CMakeLists.txt
index f62db3c1ddb..757fca0a1b2 100644
--- a/source/blender/editors/CMakeLists.txt
+++ b/source/blender/editors/CMakeLists.txt
@@ -29,6 +29,7 @@ if(WITH_BLENDER)
 	add_subdirectory(gpencil)
 	add_subdirectory(interface)
 	add_subdirectory(io)
+	add_subdirectory(manipulator_library)
 	add_subdirectory(mask)
 	add_subdirectory(mesh)
 	add_subdirectory(metaball)
diff --git a/source/blender/editors/include/ED_manipulator_library.h b/source/blender/editors/include/ED_manipulator_library.h
new file mode 100644
index 00000000000..a9c04c8e004
--- /dev/null
+++ b/source/blender/editors/include/ED_manipulator_library.h
@@ -0,0 +1,139 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file ED_manipulator_library.h
+ *  \ingroup wm
+ *
+ * \name Generic Manipulators.
+ *
+ * This is exposes pre-defined manipulators for re-use.
+ */
+
+
+#ifndef __ED_MANIPULATOR_LIBRARY_H__
+#define __ED_MANIPULATOR_LIBRARY_H__
+
+/* initialize manipulators */
+void ED_manipulatortypes_arrow_2d(void);
+void ED_manipulatortypes_arrow_3d(void);
+void ED_manipulatortypes_cage_2d(void);
+void ED_manipulatortypes_dial_3d(void);
+void ED_manipulatortypes_facemap_3d(void);
+void ED_manipulatortypes_primitive_3d(void);
+
+struct wmManipulatorGroup;
+
+/* -------------------------------------------------------------------- */
+/* 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),
+	/* 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),
+};
+
+/* slots for properties */
+enum {
+	ED_MANIPULATOR_ARROW_SLOT_OFS_WORLD_SPACE = 0
+};
+
+struct wmManipulator *ED_manipulator_arrow3d_new(
+        struct wmManipulatorGroup *mgroup, const char *name, const int style);
+void ED_manipulator_arrow3d_set_direction(struct wmManipulator *manipulator, const float direction[3]);
+void ED_manipulator_arrow3d_set_up_vector(struct wmManipulator *manipulator, const float direction[3]);
+void ED_manipulator_arrow3d_set_line_len(struct wmManipulator *manipulator, const float len);
+void ED_manipulator_arrow3d_set_ui_range(struct wmManipulator *manipulator, const float min, const float max);
+void ED_manipulator_arrow3d_set_range_fac(struct wmManipulator *manipulator, const float range_fac);
+void ED_manipulator_arrow3d_cone_set_aspect(struct wmManipulator *manipulator, const float aspect[2]);
+
+
+/* -------------------------------------------------------------------- */
+/* 2D Arrow Manipulator */
+
+struct wmManipulator *ED_manipulator_arrow2d_new(struct wmManipulatorGroup *mgroup, const char *name);
+void ED_manipulator_arrow2d_set_angle(struct wmManipulator *manipulator, const float rot_fac);
+void ED_manipulator_arrow2d_set_line_len(struct wmManipulator *manipulator, const float len);
+
+
+/* -------------------------------------------------------------------- */
+/* 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 */
+};
+
+enum {
+	ED_MANIPULATOR_RECT_TX_SLOT_OFFSET = 0,
+	ED_MANIPULATOR_RECT_TX_SLOT_SCALE = 1
+};
+
+struct wmManipulator *ED_manipulator_rect_transform_new(
+        struct wmManipulatorGroup *mgroup, const char *name, const int style);
+void ED_manipulator_rect_transform_set_dimensions(
+        struct wmManipulator *manipulator, const float width, const float height);
+
+
+/* -------------------------------------------------------------------- */
+/* Dial Manipulator */
+
+enum {
+	ED_MANIPULATOR_DIAL_STYLE_RING = 0,
+	ED_MANIPULATOR_DIAL_STYLE_RING_CLIPPED = 1,
+	ED_MANIPULATOR_DIAL_STYLE_RING_FILLED = 2,
+};
+
+struct wmManipulator *ED_manipulator_dial3d_new(
+        struct wmManipulatorGroup *mgroup, const char *name, const int style);
+void ED_manipulator_dial3d_set_up_vector(
+        struct wmManipulator *manipulator, const float direction[3]);
+
+
+/* -------------------------------------------------------------------- */
+/* Facemap Manipulator */
+
+struct wmManipulator *ED_manipulator_facemap_new(
+        struct wmManipulatorGroup *mgroup, const char *name, const int style,
+        struct Object *ob, const int facemap);
+struct bFaceMap *ED_manipulator_facemap_get_fmap(struct wmManipulator *manipulator);
+
+
+/* -------------------------------------------------------------------- */
+/* Primitive Manipulator */
+
+enum {
+	ED_MANIPULATOR_PRIMITIVE_STYLE_PLANE = 0,
+};
+
+struct wmManipulator *ED_manipulator_primitive3d_new(
+        struct wmManipulatorGroup *mgroup, const char *name, const int style);
+void ED_manipulator_primitive3d_set_direction(struct wmManipulator *manipulator, const float direction[3]);
+void ED_manipulator_primitive3d_set_up_vector(struct wmManipulator *manipulator, const float direction[3]);
+
+#endif  /* __ED_MANIPULATOR_LIBRARY_H__ */
diff --git a/source/blender/editors/manipulator_library/CMakeLists.txt b/source/blender/editors/manipulator_library/CMakeLists.txt
new file mode 100644
index 00000000000..bcb814e963f
--- /dev/null
+++ b/source/blender/editors/manipulator_library/CMakeLists.txt
@@ -0,0 +1,56 @@
+# ***** BEGIN GPL LICENSE BLOCK *****
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+set(INC
+	../include
+	../../blenkernel
+	../../blenlib
+	../../blentranslation
+	../../bmesh
+	../../depsgraph
+	../../gpu
+	../../makesdna
+	../../makesrna
+	../../windowmanager
+	../../../../intern/guardedalloc
+	../../../../intern/eigen
+	../../../../intern/glew-mx
+)
+
+set(INC_SYS
+	${GLEW_INCLUDE_PATH}
+)
+
+set(SRC
+	arrow2d_manipulator.c
+	arrow3d_manipulator.c
+	cage2d_manipulator.c
+	dial3d_manipulator.c
+	geom_arrow_manipulator.c
+	geom_cube_manipulator.c
+	manipulator_draw_utils.c
+	manipulator_library_utils.c
+	primitive3d_manipulator.c
+
+	manipulator_geometry.h
+	manipulator_library_intern.h
+)
+
+add_definitions(${GL_DEFINITIONS})
+
+blender_add_lib(bf_editor_manipulator_library "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/source/blender/windowmanager/manipulators/intern/manipulator_library/arrow2d_manipulator.c b/source/blender/editors/manipulator_library/arrow2d_manipulator.c
similarity index 90%
rename from source/blender/windowmanager/manipulators/intern/manipulator_library/arrow2d_manipulator.c
rename to source/blender/editors/manipulator_library/arrow2d_manipulator.c
index 0cec342dd06..61827723752 100644
--- a/source/blender/windowmanager/manipulators/intern/manipulator_library/arrow2d_manipulator.c
+++ b/source/blender/editors/manipulator_library/arrow2d_manipulator.c
@@ -23,7 +23,7 @@
  * ***** END GPL LICENSE BLOCK *****
  */
 
-/** \file blender/windowmanager/manipulators/intern/manipulator_library/arrow2d_manipulator.c
+/** \file arrow2d_manipulator.c
  *  \ingroup wm
  *
  * \name 2D Arrow Manipulator
@@ -43,6 +43,7 @@
 #include "DNA_windowmanager_types.h"
 
 #include "ED_screen.h"
+#include "ED_manipulator_library.h"
 
 #include "GPU_draw.h"
 #include "GPU_immediate.h"
@@ -55,11 +56,8 @@
 #include "WM_types.h"
 
 /* own includes */
-#include "WM_manipulator_api.h"
-#include "WM_manipulator_types.h"
-#include "wm_manipulator_wmapi.h"
-#include "WM_manipulator_library.h"
-#include "wm_manipulator_intern.h"
+#include "WM_api.h"
+
 #include "manipulator_library_intern.h"
 
 
@@ -112,7 +110,7 @@ static void manipulator_arrow2d_draw(const bContext *UNUSED(C), struct wmManipul
 	ArrowManipulator2D *arrow = (ArrowManipulator2D *)manipulator;
 	float col[4];
 
-	manipulator_color_get(manipulator, manipulator->state & WM_MANIPULATOR_HIGHLIGHT, col);
+	manipulator_color_get(manipulator, manipulator->state & WM_MANIPULATOR_STATE_HIGHLIGHT, col);
 
 	glLineWidth(manipul

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list