Commit: 81e2e1be41085f5523fc6e102348e79bf31fbf54
Author: Campbell Barton
Date:   Sat Dec 6 15:03:42 2014 +0100
Branches: wiggly-widgets
https://developer.blender.org/rB81e2e1be41085f5523fc6e102348e79bf31fbf54

Widget API: remove unused identifier member

also comment some of the code.

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

M       source/blender/editors/space_node/space_node.c
M       source/blender/editors/space_view3d/space_view3d.c
M       source/blender/windowmanager/WM_api.h
M       source/blender/windowmanager/WM_types.h
M       source/blender/windowmanager/intern/wm_widgets.c

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

diff --git a/source/blender/editors/space_node/space_node.c 
b/source/blender/editors/space_node/space_node.c
index 43819f8..68f54d7 100644
--- a/source/blender/editors/space_node/space_node.c
+++ b/source/blender/editors/space_node/space_node.c
@@ -343,7 +343,7 @@ static SpaceLink *node_new(const bContext *UNUSED(C))
 
        /* main area */
        ar = MEM_callocN(sizeof(ARegion), "main area for node");
-       ar->widgetmap = WM_widgetmap_from_type("Node", SPACE_NODE, 
RGN_TYPE_WINDOW, true);
+       ar->widgetmap = WM_widgetmap_from_type(SPACE_NODE, RGN_TYPE_WINDOW, 
true);
 
        BLI_addtail(&snode->regionbase, ar);
        ar->regiontype = RGN_TYPE_WINDOW;
@@ -664,8 +664,9 @@ static void node_main_area_init(wmWindowManager *wm, 
ARegion *ar)
        WM_event_add_dropbox_handler(&ar->handlers, lb);
 
        /* make sure we have a widgetmap - sucks a bit to do it here, but works 
for now */
-       if (!ar->widgetmap)
-               ar->widgetmap = WM_widgetmap_from_type("Node", SPACE_NODE, 
RGN_TYPE_WINDOW, false);
+       if (!ar->widgetmap) {
+               ar->widgetmap = WM_widgetmap_from_type(SPACE_NODE, 
RGN_TYPE_WINDOW, false);
+       }
 
        WM_event_add_widget_handler(ar);
 
@@ -887,9 +888,11 @@ static void WIDGETGROUP_node_transform_update(struct 
wmWidgetGroup *wgroup, cons
 
 static void node_widgets(void)
 {
-       struct wmWidgetMapType *wmaptype = WM_widgetmaptype_find("Node", 
SPACE_NODE, RGN_TYPE_WINDOW, false);
-       struct wmWidgetGroupType *wgroup_node_transform = 
WM_widgetgrouptype_new(WIDGETGROUP_node_transform_poll,
-                                                                               
 WIDGETGROUP_node_transform_update);
+       struct wmWidgetMapType *wmaptype;
+       struct wmWidgetGroupType *wgroup_node_transform;
+
+       wgroup_node_transform = 
WM_widgetgrouptype_new(WIDGETGROUP_node_transform_poll, 
WIDGETGROUP_node_transform_update);
+       wmaptype = WM_widgetmaptype_find(SPACE_NODE, RGN_TYPE_WINDOW, false);
 
        WM_widgetgrouptype_register(wmaptype, wgroup_node_transform);
 }
diff --git a/source/blender/editors/space_view3d/space_view3d.c 
b/source/blender/editors/space_view3d/space_view3d.c
index 3e2558d..5b810fe 100644
--- a/source/blender/editors/space_view3d/space_view3d.c
+++ b/source/blender/editors/space_view3d/space_view3d.c
@@ -386,7 +386,7 @@ static SpaceLink *view3d_new(const bContext *C)
        
        BLI_addtail(&v3d->regionbase, ar);
        ar->regiontype = RGN_TYPE_WINDOW;
-       ar->widgetmap = WM_widgetmap_from_type("View3D", SPACE_VIEW3D, 
RGN_TYPE_WINDOW, true);
+       ar->widgetmap = WM_widgetmap_from_type(SPACE_VIEW3D, RGN_TYPE_WINDOW, 
true);
        
        ar->regiondata = MEM_callocN(sizeof(RegionView3D), "region view3d");
 
@@ -555,8 +555,9 @@ static void view3d_main_area_init(wmWindowManager *wm, 
ARegion *ar)
        WM_event_add_dropbox_handler(&ar->handlers, lb);
 
        /* make sure we have a widgetmap - sucks a bit to do it here, but works 
for now */
-       if (!ar->widgetmap)
-               ar->widgetmap = WM_widgetmap_from_type("View3D", SPACE_VIEW3D, 
RGN_TYPE_WINDOW, true);
+       if (!ar->widgetmap) {
+               ar->widgetmap = WM_widgetmap_from_type(SPACE_VIEW3D, 
RGN_TYPE_WINDOW, true);
+       }
 
        WM_event_add_widget_handler(ar);
 }
@@ -779,21 +780,21 @@ static void WIDGETGROUP_shapekey_draw(struct 
wmWidgetGroup *wgroup, const struct
 
 static void view3d_widgets(void)
 {
-       struct wmWidgetMapType *wmaptype = WM_widgetmaptype_find("View3D", 
SPACE_VIEW3D, RGN_TYPE_WINDOW, true);
-       /*
-       struct wmWidgetGroupType *wgroup_manipulator = 
WM_widgetgrouptype_new(WIDGETGROUP_manipulator_create,
-                                                                             
WIDGETGROUP_manipulator_poll,
-                                                                             
WIDGETGROUP_manipulator_update,
-                                                                             
WIDGETGROUP_manipulator_free);
-       */
-       struct wmWidgetGroupType *wgroup_light = 
WM_widgetgrouptype_new(WIDGETGROUP_lamp_poll,
-                                                                       
WIDGETGROUP_lamp_draw);
-
-       struct wmWidgetGroupType *wgroup_camera = 
WM_widgetgrouptype_new(WIDGETGROUP_camera_poll,
-                                                                        
WIDGETGROUP_camera_draw);
-
-       struct wmWidgetGroupType *wgroup_shapekey = 
WM_widgetgrouptype_new(WIDGETGROUP_shapekey_poll,
-                                                                          
WIDGETGROUP_shapekey_draw);
+       struct wmWidgetMapType *wmaptype = WM_widgetmaptype_find(SPACE_VIEW3D, 
RGN_TYPE_WINDOW, true);
+       wmWidgetGroupType *wgroup_light,*wgroup_camera, *wgroup_shapekey;
+       // struct wmWidgetGroupType *wgroup_manipulator;
+
+       wgroup_light = WM_widgetgrouptype_new(WIDGETGROUP_lamp_poll, 
WIDGETGROUP_lamp_draw);
+       wgroup_camera = WM_widgetgrouptype_new(WIDGETGROUP_camera_poll, 
WIDGETGROUP_camera_draw);
+       wgroup_shapekey = WM_widgetgrouptype_new(WIDGETGROUP_shapekey_poll, 
WIDGETGROUP_shapekey_draw);
+
+#if 0
+       wgroup_manipulator = WM_widgetgrouptype_new(
+               WIDGETGROUP_manipulator_create,
+               WIDGETGROUP_manipulator_poll,
+               WIDGETGROUP_manipulator_update,
+               WIDGETGROUP_manipulator_free);
+#endif
        
        //WM_widgetgrouptype_register(wmaptype, wgroup_manipulator);
        WM_widgetgrouptype_register(wmaptype, wgroup_light);
diff --git a/source/blender/windowmanager/WM_api.h 
b/source/blender/windowmanager/WM_api.h
index b3aba29..d5fdad9 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -470,9 +470,9 @@ bool        WM_event_is_tablet(const struct wmEvent *event);
 
 
 /* widget API */
-struct wmWidgetGroupType *WM_widgetgrouptype_new(bool (*poll)(struct 
wmWidgetGroup *, const struct bContext *),
-                                                 void (*draw)(struct 
wmWidgetGroup *, const struct bContext *)
-                                                 );
+struct wmWidgetGroupType *WM_widgetgrouptype_new(
+        bool (*poll)(struct wmWidgetGroup *, const struct bContext *),
+        void (*draw)(struct wmWidgetGroup *, const struct bContext *));
 
 struct wmWidget *WM_widget_new(void (*draw)(struct wmWidget *, const struct 
bContext *),
                                void (*render_3d_intersection)(const struct 
bContext *, struct wmWidget *, int),
@@ -499,14 +499,14 @@ void WM_widget_set_scale(struct wmWidget *widget, float 
scale);
 void *WM_widgetgroup_customdata(struct wmWidgetGroup *wgroup);
 void WM_widgetgroup_customdata_set(struct wmWidgetGroup *wgroup, void *data);
 
-struct wmWidgetMapType *WM_widgetmaptype_find(const char *idname, int spaceid, 
int regionid, bool is_3d);
+struct wmWidgetMapType *WM_widgetmaptype_find(int spaceid, int regionid, bool 
is_3d);
 
 bool WM_widgetgrouptype_register(struct wmWidgetMapType *wmap, struct 
wmWidgetGroupType *wgroup);
 void WM_widgetgrouptype_unregister(struct wmWidgetMapType *wmap, struct 
wmWidgetGroupType *wgroup);
 
 /* creates a widgetmap with all registered widgets for that type */
-struct wmWidgetMap *WM_widgetmap_from_type(const char *idname, int spaceid, 
int regionid, bool is_3d);
-void WM_widgetmap_delete(struct wmWidgetMap *);
+struct wmWidgetMap *WM_widgetmap_from_type(int spaceid, int regionid, bool 
is_3d);
+void WM_widgetmap_delete(struct wmWidgetMap *wmap);
 
 void WM_widgetmaptypes_free(void);
 
diff --git a/source/blender/windowmanager/WM_types.h 
b/source/blender/windowmanager/WM_types.h
index 8a646dd..cee1cb9 100644
--- a/source/blender/windowmanager/WM_types.h
+++ b/source/blender/windowmanager/WM_types.h
@@ -508,8 +508,6 @@ typedef struct wmTimer {
        int sleep;                              /* internal, put timers to 
sleep when needed */
 } wmTimer;
 
-typedef struct wmWidget wmWidget;
-
 typedef struct wmOperatorType {
        const char *name;               /* text for ui, undo */
        const char *idname;             /* unique identifier */
@@ -655,6 +653,8 @@ typedef struct wmDropBox {
  * Also they */
 typedef struct wmWidget wmWidget;
 typedef struct wmWidgetGroup wmWidgetGroup;
+typedef struct wmWidgetMapType wmWidgetMapType;
+typedef struct wmWidgetGroupType wmWidgetGroupType;
 
 /* *************** migrated stuff, clean later? ************** */
 
diff --git a/source/blender/windowmanager/intern/wm_widgets.c 
b/source/blender/windowmanager/intern/wm_widgets.c
index 613b753..9c296ef 100644
--- a/source/blender/windowmanager/intern/wm_widgets.c
+++ b/source/blender/windowmanager/intern/wm_widgets.c
@@ -107,11 +107,20 @@ typedef struct wmWidgetGroupType {
        int flag;
 } wmWidgetGroupType;
 
+/**
+ * This is a container for all widget types that can be instansiated in a area.
+ * (similar to dropboxes).
+ *
+ * \note There is only ever one of these for every (area, region) combination.
+ */
 typedef struct wmWidgetMapType {
        struct wmWidgetMapType *next, *prev;
        short spaceid, regionid;
-       char idname[KMAP_MAX_NAME];
-       /* check if widgetmap does 3D drawing */
+       /**
+        * Check if widgetmap does 3D drawing
+        * (uses a different kind of interaction),
+        * - 3d: use glSelect buffer.
+        * - 2d: use simple cursor position intersection test. */
        bool is_3d;
        /* types of widgetgroups for this widgetmap type */
        ListBase widgetgrouptypes;
@@ -122,8 +131,9 @@ typedef struct wmWidgetMapType {
  * area type can query the widgetbox to do so */
 static ListBase widgetmaptypes = {NULL, NULL};
 
-struct wmWidgetGroupType *WM_widgetgrouptype_new(bool (*poll)(struct 
wmWidgetGroup *, const struct bContext *C),
-                                                 void (*draw)(struct 
wmWidgetGroup *, const struct bContext *))
+struct wmWidgetGroupType *WM_widgetgrouptype_new(
+        bool (*poll)(struct wmWidgetGroup *, const struct bContext *C),
+        void (*draw)(struct wmWidgetGroup *, const struct bContext *))
 {
        wmWidgetGroupType *wgrouptype;
        
@@ -421,17 +431,17 @@ void WM_widget_set_scale(struct wmWidget *widget, float 
scale)
 }
 
 
-wmWidgetMapType *WM_widgetmaptype_find(const char *idname, int spaceid, int 
regionid, bool is_3d)
+wmWidgetMapType *WM_widgetmaptype_find(int spaceid, int regionid, bool is_3d)
 {
        wmWidgetMapType *wmaptype;
        
-       for (wmaptype = widgetmaptypes.first; wmaptype; wmaptype = 
wmaptype->next)
-               if (wmaptype->spaceid == spaceid && wmaptype->regionid == 
regionid && wmaptype->is_3d == is_3d)
-                       if (0 == strncmp(idname, wmaptype->idname, 
KMAP_MAX_NAME))
-                               return wmaptype;
+       for (wmaptype = widgetmaptypes.first; wmaptype; wmaptype = 
wmaptype->next) {
+

@@ 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