[Bf-blender-cvs] [8abeeaf] wiggly-widgets: Rename Cage to RectTransform, add DNA for struct that will be used for interaction with the widget.

Antony Riakiotakis noreply at git.blender.org
Fri Dec 5 12:55:53 CET 2014


Commit: 8abeeafcb6fd7eb9ef0769d3c062f344cf48847d
Author: Antony Riakiotakis
Date:   Fri Dec 5 12:55:33 2014 +0100
Branches: wiggly-widgets
https://developer.blender.org/rB8abeeafcb6fd7eb9ef0769d3c062f344cf48847d

Rename Cage to RectTransform, add DNA for struct that will be used for
interaction with the widget.

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

M	source/blender/CMakeLists.txt
M	source/blender/editors/object/object_lamp.c
M	source/blender/editors/space_node/space_node.c
M	source/blender/editors/space_view3d/space_view3d.c
A	source/blender/makesdna/DNA_widget_types.h
M	source/blender/makesdna/intern/makesdna.c
M	source/blender/makesrna/intern/rna_wm.c
M	source/blender/windowmanager/WM_api.h
M	source/blender/windowmanager/intern/wm_generic_widgets.c

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

diff --git a/source/blender/CMakeLists.txt b/source/blender/CMakeLists.txt
index 0d30952..8aeba13 100644
--- a/source/blender/CMakeLists.txt
+++ b/source/blender/CMakeLists.txt
@@ -86,6 +86,7 @@ set(SRC_DNA_INC
 	${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_view2d_types.h
 	${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_view3d_types.h
 	${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_windowmanager_types.h
+	${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_widget_types.h
 	${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_world_types.h
 	${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_movieclip_types.h
 	${CMAKE_CURRENT_SOURCE_DIR}/makesdna/DNA_tracking_types.h
diff --git a/source/blender/editors/object/object_lamp.c b/source/blender/editors/object/object_lamp.c
index 435f7a2..4da2634 100644
--- a/source/blender/editors/object/object_lamp.c
+++ b/source/blender/editors/object/object_lamp.c
@@ -223,7 +223,7 @@ void WIDGETGROUP_lamp_draw(struct wmWidgetGroup *wgroup, const struct bContext *
 	PointerRNA ptr;
 	float dir[3];
 
-	widget = WIDGET_arrow_new(wgroup, UI_ARROW_STYLE_INVERTED, NULL);
+	widget = WIDGET_arrow_new(wgroup, WIDGET_ARROW_STYLE_INVERTED, NULL);
 
 	WIDGET_arrow_set_color(widget, color_lamp);
 	
diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c
index 3841c23..ffc8d28 100644
--- a/source/blender/editors/space_node/space_node.c
+++ b/source/blender/editors/space_node/space_node.c
@@ -859,7 +859,7 @@ static void WIDGETGROUP_node_transform_update(struct wmWidgetGroup *wgroup, cons
 	ima = BKE_image_verify_viewer(IMA_TYPE_COMPOSITE, "Viewer Node");
 	ibuf = BKE_image_acquire_ibuf(ima, NULL, &lock);
 	if (ibuf) {
-		wmWidget *cage = WIDGET_cage_new(wgroup, 0, NULL);
+		wmWidget *cage = WIDGET_rect_transform_new(wgroup, WIDGET_RECT_TRANSFORM_STYLE_TRANSLATE | WIDGET_RECT_TRANSFORM_STYLE_SCALE_UNIFORM, NULL);
 		
 		SpaceNode *snode = CTX_wm_space_node(C);
 		ARegion *ar = CTX_wm_region(C);
@@ -875,7 +875,7 @@ static void WIDGETGROUP_node_transform_update(struct wmWidgetGroup *wgroup, cons
 
 		RNA_pointer_create(snode->id, &RNA_SpaceNodeEditor, snode, &nodeptr);
 		
-		WIDGET_cage_bounds_set(cage, xsize, ysize);
+		WIDGET_rect_transform_bounds_set(cage, xsize, ysize);
 		WM_widget_set_origin(cage, origin);
 		WM_widget_property(cage, &nodeptr, "backdrop_x");
 	}
diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c
index 3c894e9..3e2558d 100644
--- a/source/blender/editors/space_view3d/space_view3d.c
+++ b/source/blender/editors/space_view3d/space_view3d.c
@@ -722,7 +722,7 @@ static void WIDGETGROUP_camera_draw(struct wmWidgetGroup *wgroup, const struct b
 	PointerRNA cameraptr;
 	float dir[3];
 
-	widget = WIDGET_arrow_new(wgroup, UI_ARROW_STYLE_CROSS, NULL);
+	widget = WIDGET_arrow_new(wgroup, WIDGET_ARROW_STYLE_CROSS, NULL);
 	WM_widget_set_draw_on_hover_only(widget, true);
 	WM_widget_set_3d_scale(widget, false);
 	WIDGET_arrow_set_color(widget, color_camera);
@@ -766,7 +766,7 @@ static void WIDGETGROUP_shapekey_draw(struct wmWidgetGroup *wgroup, const struct
 	PointerRNA shapeptr;
 	float dir[3];
 
-	widget = WIDGET_arrow_new(wgroup, UI_ARROW_STYLE_NORMAL, NULL);
+	widget = WIDGET_arrow_new(wgroup, WIDGET_ARROW_STYLE_NORMAL, NULL);
 	WM_widget_set_3d_scale(widget, false);
 	WIDGET_arrow_set_color(widget, color_shape);
 	RNA_pointer_create(&key->id, &RNA_ShapeKey, kb, &shapeptr);
diff --git a/source/blender/makesdna/DNA_widget_types.h b/source/blender/makesdna/DNA_widget_types.h
new file mode 100644
index 0000000..3a869fc
--- /dev/null
+++ b/source/blender/makesdna/DNA_widget_types.h
@@ -0,0 +1,44 @@
+/*
+ * ***** 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.
+ *
+ * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
+ * All rights reserved.
+ *
+ * The Original Code is: all of this file.
+ *
+ * Contributor(s): none yet.
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file DNA_widget_types.h
+ *  \ingroup DNA
+ */
+
+#ifndef __DNA_WM_WIDGET_TYPES_H__
+#define __DNA_WM_WIDGET_TYPES_H__
+
+#include "DNA_vec_types.h"
+
+/* struct used directly for interaction with a rectangle widget */
+typedef struct wmRectTransformWidget {
+	rctf bounds;    /* unrotated bounds of the rectangle */
+	float rotation; /* rotation of the rectangle */
+	float pad;
+} wmRectTransformWidget;
+
+#endif
\ No newline at end of file
diff --git a/source/blender/makesdna/intern/makesdna.c b/source/blender/makesdna/intern/makesdna.c
index 51a0c5a..dec0cb3 100644
--- a/source/blender/makesdna/intern/makesdna.c
+++ b/source/blender/makesdna/intern/makesdna.c
@@ -124,6 +124,7 @@ static const char *includefiles[] = {
 	/* if you add files here, please add them at the end
 	 * of makesdna.c (this file) as well */
 	"DNA_windowmanager_types.h",
+	"DNA_widget_types.h",
 	"DNA_anim_types.h",
 	"DNA_boid_types.h",
 	"DNA_smoke_types.h",
@@ -1275,6 +1276,7 @@ int main(int argc, char **argv)
 #include "DNA_cloth_types.h"
 #include "DNA_gpencil_types.h"
 #include "DNA_windowmanager_types.h"
+#include "DNA_widget_types.h"
 #include "DNA_anim_types.h"
 #include "DNA_boid_types.h"
 #include "DNA_smoke_types.h"
diff --git a/source/blender/makesrna/intern/rna_wm.c b/source/blender/makesrna/intern/rna_wm.c
index 3b97508..3283006 100644
--- a/source/blender/makesrna/intern/rna_wm.c
+++ b/source/blender/makesrna/intern/rna_wm.c
@@ -30,6 +30,7 @@
 #include "DNA_space_types.h"
 #include "DNA_userdef_types.h"
 #include "DNA_windowmanager_types.h"
+#include "DNA_widget_types.h"
 
 #include "BLI_utildefines.h"
 
@@ -1885,6 +1886,37 @@ static void rna_def_wm_keymaps(BlenderRNA *brna, PropertyRNA *cprop)
 	RNA_api_keymaps(srna);
 }
 
+static void rna_def_widgets(BlenderRNA *brna)
+{
+	StructRNA *srna;
+	PropertyRNA *prop;
+
+	/* KeyConfig */
+	srna = RNA_def_struct(brna, "WidgetRectTransform", NULL);
+	RNA_def_struct_sdna(srna, "wmRectTransformWidget");
+	RNA_def_struct_ui_text(srna, "Rect Transform Widget Data", "State for rectangle transform widget interaction");
+	
+	prop = RNA_def_property(srna, "xmin", PROP_FLOAT, PROP_NONE);
+	RNA_def_property_float_sdna(prop, NULL, "bounds.xmin");
+	RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+	RNA_def_property_ui_text(prop, "X Position Minimum", "The minimum X boundary for the rectangle");
+
+	prop = RNA_def_property(srna, "ymin", PROP_FLOAT, PROP_NONE);
+	RNA_def_property_float_sdna(prop, NULL, "bounds.ymin");
+	RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+	RNA_def_property_ui_text(prop, "Y Position Minimum", "The minimum Y boundary for the rectangle");
+
+	prop = RNA_def_property(srna, "xmax", PROP_FLOAT, PROP_NONE);
+	RNA_def_property_float_sdna(prop, NULL, "bounds.xmax");
+	RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+	RNA_def_property_ui_text(prop, "X Position Maximum", "The maximum X boundary for the rectangle");
+
+	prop = RNA_def_property(srna, "ymax", PROP_FLOAT, PROP_NONE);
+	RNA_def_property_float_sdna(prop, NULL, "bounds.ymax");
+	RNA_def_property_clear_flag(prop, PROP_EDITABLE);
+	RNA_def_property_ui_text(prop, "Y Position Maximum", "The maximum Y boundary for the rectangle");
+}
+
 static void rna_def_keyconfig(BlenderRNA *brna)
 {
 	StructRNA *srna;
@@ -2114,6 +2146,7 @@ void RNA_def_wm(BlenderRNA *brna)
 	rna_def_window(brna);
 	rna_def_windowmanager(brna);
 	rna_def_keyconfig(brna);
+	rna_def_widgets(brna);
 }
 
 #endif /* RNA_RUNTIME */
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h
index 5e2fbef..4d98d55 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -514,18 +514,23 @@ void WM_widgetmaptypes_free(void);
 /* wm_generic_widgets.c */
 
 enum {
-	UI_ARROW_STYLE_NORMAL        =  0,
-	UI_ARROW_STYLE_NO_AXIS       = (1 << 1),
-	UI_ARROW_STYLE_CROSS         = (1 << 2),
-	/* inverted offset during interaction - if set it also sets constrained below */
-	UI_ARROW_STYLE_INVERTED      = (1 << 3),
-	/* clamp arrow interaction to property width */
-	UI_ARROW_STYLE_CONSTRAINED   = (1 << 4),
+	WIDGET_ARROW_STYLE_NORMAL        =  1,
+	WIDGET_ARROW_STYLE_NO_AXIS       = (1 << 1),
+	WIDGET_ARROW_STYLE_CROSS         = (1 << 2),
+	WIDGET_ARROW_STYLE_INVERTED      = (1 << 3), /* inverted offset during interaction - if set it also sets constrained below */
+	WIDGET_ARROW_STYLE_CONSTRAINED   = (1 << 4), /* clamp arrow interaction to property width */
 };
 
 enum {
-	UI_DIAL_STYLE_RING = 0,
-	UI_DIAL_STYLE_RING_CLIPPED = 1,
+	WIDGET_DIAL_STYLE_RING = 0,
+	WIDGET_DIAL_STYLE_RING_CLIPPED = 1,
+};
+
+enum {
+	WIDGET_RECT_TRANSFORM_STYLE_TRANSLATE       =  1,       /* widget translates */
+	WIDGET_RECT_TRANSFORM_STYLE_ROTATE          = (1 << 1), /* widget rotates */
+	WIDGET_RECT_TRANSFORM_STYLE_SCALE           = (1 << 2), /* widget scales */
+	WIDGET_RECT_TRANSFORM_STYLE_SCALE_UNIFORM   = (1 << 3), /* widget scales uniformly */
 };
 
 struct wmWidget *WIDGET_arrow_new(struct wmWidgetGroup *wgroup, int style, void *customdata);
@@ -539,9 +544,9 @@ struct wmWidget *WIDGET_dial_new(int style,
 void WIDGET_dial_set_color(struct wmWidget *widget, float color[4]);
 void WIDGET_dial_set_direction(struct wmWidget *widget, float direction[3]);
 
-struct wmWidget *WIDGET_cage_new(struct wmWidgetGroup *wgroup, int style, void *customdata);
-void WIDGET_cage_bind_to_rotation(struct wmWidget *widget, float rotation);
-void WIDGET_cage_bounds_set(struct wmWidget *widget, float w, float h);
+struct wmWidget *WIDGET_rect_transform_new(struct wmWidgetGroup *wg

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list