[Bf-blender-cvs] [99b8767] wiggly-widgets: Register widget group types more like operator types

Julian Eisel noreply at git.blender.org
Wed May 18 23:13:03 CEST 2016


Commit: 99b87675fce2201c14bb479d9ddd40b8edddd0e4
Author: Julian Eisel
Date:   Wed May 18 23:10:06 2016 +0200
Branches: wiggly-widgets
https://developer.blender.org/rB99b87675fce2201c14bb479d9ddd40b8edddd0e4

Register widget group types more like operator types

Is more consistent and I think it makes it easier to understand the role of widget groups.

Adds file space_node/node_widgets.c

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

M	source/blender/editors/include/ED_transform.h
M	source/blender/editors/include/ED_view3d.h
M	source/blender/editors/object/object_edit.c
M	source/blender/editors/space_graph/graph_edit.c
M	source/blender/editors/space_image/space_image.c
M	source/blender/editors/space_node/CMakeLists.txt
M	source/blender/editors/space_node/node_intern.h
A	source/blender/editors/space_node/node_widgets.c
M	source/blender/editors/space_node/space_node.c
M	source/blender/editors/space_sequencer/sequencer_view.c
M	source/blender/editors/space_view3d/space_view3d.c
M	source/blender/editors/space_view3d/view3d_intern.h
M	source/blender/editors/space_view3d/view3d_widgets.c
M	source/blender/editors/transform/transform_manipulator.c
M	source/blender/makesrna/intern/rna_wm.c
M	source/blender/windowmanager/widgets/WM_widget_api.h
M	source/blender/windowmanager/widgets/WM_widget_types.h
M	source/blender/windowmanager/widgets/intern/wm_widgetgroup.c

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

diff --git a/source/blender/editors/include/ED_transform.h b/source/blender/editors/include/ED_transform.h
index 4f3617c..e028a65 100644
--- a/source/blender/editors/include/ED_transform.h
+++ b/source/blender/editors/include/ED_transform.h
@@ -162,13 +162,9 @@ void Transform_Properties(struct wmOperatorType *ot, int flags);
 
 /* transform manipulators */
 
-int WIDGETGROUP_manipulator_poll(const struct bContext *C, struct wmWidgetGroupType *wgrouptype);
-void WIDGETGROUP_manipulator_init(const struct bContext *C, struct wmWidgetGroup *wgroup);
-void WIDGETGROUP_manipulator_refresh(const struct bContext *C, struct wmWidgetGroup *wgroup);
-void WIDGETGROUP_manipulator_draw_prepare(const struct bContext *C, struct wmWidgetGroup *wgroup);
+void TRANSFORM_WGT_manipulator(struct wmWidgetGroupType *wgt);
 
-void WIDGETGROUP_object_manipulator_init(const struct bContext *C, struct wmWidgetGroup *wgroup);
-int WIDGETGROUP_object_manipulator_poll(const struct bContext *C, struct wmWidgetGroupType *wgrouptype);
+void TRANSFORM_WGT_object(struct wmWidgetGroupType *wgt);
 
 int WIDGETGROUP_manipulator2d_poll(const struct bContext *C, struct wmWidgetGroupType *wgrouptype);
 void WIDGETGROUP_manipulator2d_init(const struct bContext *C, struct wmWidgetGroup *wgroup);
diff --git a/source/blender/editors/include/ED_view3d.h b/source/blender/editors/include/ED_view3d.h
index 69a7bb2..a33bbf6 100644
--- a/source/blender/editors/include/ED_view3d.h
+++ b/source/blender/editors/include/ED_view3d.h
@@ -401,10 +401,6 @@ void ED_view3d_operator_properties_viewmat_set(struct bContext *C, struct wmOper
 void ED_view3d_operator_properties_viewmat_get(struct wmOperator *op, int *winx, int *winy, float persmat[4][4]);
 #endif
 
-int WIDGETGROUP_lamp_poll(const struct bContext *C, struct wmWidgetGroupType *wgrouptype);
-void WIDGETGROUP_lamp_init(const struct bContext *C, struct wmWidgetGroup *wgroup);
-void WIDGETGROUP_lamp_refresh(const struct bContext *C, struct wmWidgetGroup *wgroup);
-
 /* render */
 void ED_view3d_stop_render_preview(struct wmWindowManager *wm, struct ARegion *ar);
 void ED_view3d_shade_update(struct Main *bmain, struct Scene *scene, struct View3D *v3d, struct ScrArea *sa);
diff --git a/source/blender/editors/object/object_edit.c b/source/blender/editors/object/object_edit.c
index 4767847..7c4147b 100644
--- a/source/blender/editors/object/object_edit.c
+++ b/source/blender/editors/object/object_edit.c
@@ -2201,16 +2201,9 @@ void OBJECT_OT_game_physics_copy(struct wmOperatorType *ot)
 static int object_widget_add_exec(bContext *C, wmOperator *UNUSED(op))
 {
 	Object *ob = ED_object_active_context((bContext *)C);
-	wmWidgetGroupType *wgrouptype = WM_widgetgrouptype_register(
-	        CTX_data_main(C),
-	        &(const struct wmWidgetMapType_Params) {"View3D", SPACE_VIEW3D, RGN_TYPE_WINDOW, WM_WIDGETMAPTYPE_3D},
-	        WIDGETGROUP_object_manipulator_poll,
-	        WIDGETGROUP_object_manipulator_init,
-	        WIDGETGROUP_manipulator_refresh,
-	        WIDGETGROUP_manipulator_draw_prepare,
-	        WM_widgetgroup_keymap_common,
-	        "Object Widgets");
-
+	wmWidgetMapType *wmaptype = WM_widgetmaptype_find(&(const struct wmWidgetMapType_Params) {
+	        "View3D", SPACE_VIEW3D, RGN_TYPE_WINDOW, WM_WIDGETMAPTYPE_3D});
+	wmWidgetGroupType *wgrouptype = WM_widgetgrouptype_append(wmaptype, TRANSFORM_WGT_object);
 	/* assign the objects id name to the widget */
 	strcpy(wgrouptype->idname, ob->id.name);
 
diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c
index d090c4c..7e3ce4a 100644
--- a/source/blender/editors/space_graph/graph_edit.c
+++ b/source/blender/editors/space_graph/graph_edit.c
@@ -2793,18 +2793,12 @@ static void widgetgroup_backdrop_refresh(const struct bContext *C, wmWidgetGroup
 	WM_widget_set_property(cage, RECT_TRANSFORM_SLOT_SCALE, op->ptr, "scale");
 }
 
-static wmWidgetGroupType *graph_widget_backdrop_transform_widgets(void)
+static void GRAPH_WGT_backdrop_transform(wmWidgetGroupType *wgt)
 {
-	/* no poll, lives always for the duration of the operator */
-	return WM_widgetgrouptype_register(
-	            NULL,
-	            &(const struct wmWidgetMapType_Params) {"Graph_Canvas", SPACE_IPO, RGN_TYPE_WINDOW, 0},
-	            NULL,
-	            widgetgroup_backdrop_init,
-	            widgetgroup_backdrop_refresh,
-	            NULL,
-	            WM_widgetgroup_keymap_common,
-	            "Backdrop Transform Widgets");
+	wgt->name = "Backdrop Transform Widgets";
+
+	wgt->init = widgetgroup_backdrop_init;
+	wgt->refresh = widgetgroup_backdrop_refresh;
 }
 
 static int graph_widget_backdrop_transform_invoke(bContext *C, wmOperator *op, const wmEvent *event)
@@ -2903,6 +2897,8 @@ static int graph_widget_backdrop_transform_modal(bContext *C, wmOperator *op, co
 void GRAPH_OT_widget_backdrop_transform(struct wmOperatorType *ot)
 {
 	float default_offset[2] = {0.0f, 0.0f};
+	wmWidgetMapType *wmaptype = WM_widgetmaptype_find(&(const struct wmWidgetMapType_Params) {
+	        "Graph_Canvas", SPACE_IPO, RGN_TYPE_WINDOW, 0});
 
 	/* identifiers */
 	ot->name = "Transform Backdrop";
@@ -2918,7 +2914,7 @@ void GRAPH_OT_widget_backdrop_transform(struct wmOperatorType *ot)
 	/* flags */
 	ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
 
-	ot->wgrouptype = graph_widget_backdrop_transform_widgets();
+	ot->wgrouptype = WM_widgetgrouptype_append(wmaptype, GRAPH_WGT_backdrop_transform);
 
 	RNA_def_float_array(ot->srna, "offset", 2, default_offset, FLT_MIN, FLT_MAX, "Offset", "Offset of the backdrop", FLT_MIN, FLT_MAX);
 	RNA_def_float(ot->srna, "scale", 1.0f, 0.0f, FLT_MAX, "Scale", "Scale of the backdrop", 0.0f, FLT_MAX);
diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c
index 90ab2a9..3827164 100644
--- a/source/blender/editors/space_image/space_image.c
+++ b/source/blender/editors/space_image/space_image.c
@@ -582,6 +582,16 @@ static int image_context(const bContext *C, const char *member, bContextDataResu
 	return 0;
 }
 
+static void IMAGE_WGT_manipulator2d(wmWidgetGroupType *wgt)
+{
+	wgt->name = "UV Transform Manipulator";
+
+	wgt->poll = WIDGETGROUP_manipulator2d_poll;
+	wgt->init = WIDGETGROUP_manipulator2d_init;
+	wgt->refresh = WIDGETGROUP_manipulator2d_refresh;
+	wgt->draw_prepare = WIDGETGROUP_manipulator2d_draw_prepare;
+}
+
 static void image_widgets(void)
 {
 	const struct wmWidgetMapType_Params wmap_params = {
@@ -589,17 +599,9 @@ static void image_widgets(void)
 		.spaceid = SPACE_IMAGE, .regionid = RGN_TYPE_WINDOW,
 		.flag = 0,
 	};
-
 	wmWidgetMapType *wmaptype = WM_widgetmaptype_ensure(&wmap_params);
 
-	WM_widgetgrouptype_register_ptr(
-	        NULL, wmaptype,
-	        WIDGETGROUP_manipulator2d_poll,
-	        WIDGETGROUP_manipulator2d_init,
-	        WIDGETGROUP_manipulator2d_refresh,
-	        WIDGETGROUP_manipulator2d_draw_prepare,
-	        WM_widgetgroup_keymap_common,
-	        "UV Transform Manipulator");
+	WM_widgetgrouptype_append(wmaptype, IMAGE_WGT_manipulator2d);
 }
 
 /************************** main region ***************************/
diff --git a/source/blender/editors/space_node/CMakeLists.txt b/source/blender/editors/space_node/CMakeLists.txt
index cde8183..4184392 100644
--- a/source/blender/editors/space_node/CMakeLists.txt
+++ b/source/blender/editors/space_node/CMakeLists.txt
@@ -53,6 +53,7 @@ set(SRC
 	node_templates.c
 	node_toolbar.c
 	node_view.c
+	node_widgets.c
 	space_node.c
 
 	node_intern.h
diff --git a/source/blender/editors/space_node/node_intern.h b/source/blender/editors/space_node/node_intern.h
index 6b8fa0b..181fefc 100644
--- a/source/blender/editors/space_node/node_intern.h
+++ b/source/blender/editors/space_node/node_intern.h
@@ -220,6 +220,10 @@ void NODE_OT_shader_script_update(struct wmOperatorType *ot);
 void NODE_OT_viewer_border(struct wmOperatorType *ot);
 void NODE_OT_clear_viewer_border(struct wmOperatorType *ot);
 
+/* node_widgets.c */
+void NODE_WGT_backdrop_transform(struct wmWidgetGroupType *wgt);
+
+
 extern const char *node_context_dir[];
 
 // XXXXXX
diff --git a/source/blender/editors/space_node/node_widgets.c b/source/blender/editors/space_node/node_widgets.c
new file mode 100644
index 0000000..fde9537
--- /dev/null
+++ b/source/blender/editors/space_node/node_widgets.c
@@ -0,0 +1,109 @@
+/*
+ * ***** 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 blender/editors/space_node/node_widgets.c
+ *  \ingroup spnode
+ */
+
+#include "BKE_context.h"
+#include "BKE_image.h"
+
+#include "DNA_image_types.h"
+
+#include "ED_screen.h"
+
+#include "IMB_imbuf_types.h"
+
+#include "MEM_guardedalloc.h"
+
+#include "RNA_access.h"
+
+#include "WM_api.h"
+#include "WM_types.h"
+
+#include "node_intern.h"
+
+
+static int WIDGETGROUP_node_transform_poll(const bContext *C, wmWidgetGroupType *UNUSED(wgrouptype))
+{
+	SpaceNode *snode = CTX_wm_space_node(C);
+
+	if (snode && snode->edittree && snode->edittree->type == NTREE_COMPOSIT) {
+		bNode *node = nodeGetActive(snode->edittree);
+
+		if (node && node->type == CMP_NODE_VIEWER)
+			return true;
+	}
+
+	return false;
+}
+
+static void WIDGETGROUP_node_transform_init(const bContext *UNUSED(C), wmWidgetGroup *wgroup)
+{
+	wmWidgetWrapper *wwrapper = MEM_mallocN(sizeof(wmWidgetWrapper), __func__);
+
+	wwrapper->widget = WIDGET_rect_transform_new(
+	                       wgroup, "backdrop_cage",
+	                       WIDGET_RECT_TRANSFORM_STYLE_TRANSLAT

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list