Commit: 437232e3641e00cf5789220c9dce9c4ff678edf4
Author: Julian Eisel
Date:   Sun Dec 20 15:38:04 2015 +0100
Branches: temp_widgets_c++_experiment
https://developer.blender.org/rB437232e3641e00cf5789220c9dce9c4ff678edf4

Port over get/set functions for active widget in widget-map

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

M       source/blender/windowmanager/intern/widgets/wm_widgetmap.cc
M       source/blender/windowmanager/intern/widgets/wm_widgetmap.h
M       source/blender/windowmanager/intern/widgets/wm_widgets_c_api.cc
M       source/blender/windowmanager/intern/widgets/wm_widgets_c_api.h
M       source/blender/windowmanager/intern/wm_widgets.c
M       source/blender/windowmanager/wm_event_system.h

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

diff --git a/source/blender/windowmanager/intern/widgets/wm_widgetmap.cc 
b/source/blender/windowmanager/intern/widgets/wm_widgetmap.cc
index bf2675a..299d26c 100644
--- a/source/blender/windowmanager/intern/widgets/wm_widgetmap.cc
+++ b/source/blender/windowmanager/intern/widgets/wm_widgetmap.cc
@@ -37,6 +37,8 @@
 #include "GPU_glew.h"
 #include "GPU_select.h"
 
+#include "MEM_guardedalloc.h"
+
 #include "WM_api.h"
 #include "wm_cursors.h"
 #include "WM_types.h"
@@ -261,3 +263,63 @@ void wmWidgetMap::set_highlighted_widget(bContext *C, 
wmWidget *widget, unsigned
        }
 }
 
+void wmWidgetMap::set_active_widget(bContext *C, const wmEvent *event, 
wmWidget *widget)
+{
+       if (widget) {
+               if (widget->opname) {
+                       wmOperatorType *ot = 
WM_operatortype_find(widget->opname, 0);
+
+                       if (ot) {
+                               /* first activate the widget itself */
+                               if (widget->invoke && widget->handler) {
+                                       widget->flag |= WM_WIDGET_ACTIVE;
+                                       widget->invoke(C, event, widget);
+                               }
+                               wmap_context.active_widget = widget;
+
+                               WM_operator_name_call_ptr(C, ot, 
WM_OP_INVOKE_DEFAULT, &widget->opptr);
+
+                               /* we failed to hook the widget to the operator 
handler or operator was cancelled, return */
+                               if (!wmap_context.active_widget) {
+                                       widget->flag &= ~WM_WIDGET_ACTIVE;
+                                       /* first activate the widget itself */
+                                       if (widget->interaction_data) {
+                                               
MEM_freeN(widget->interaction_data);
+                                               widget->interaction_data = NULL;
+                                       }
+                               }
+                               return;
+                       }
+                       else {
+                               printf("Widget error: operator not found\n");
+                               wmap_context.active_widget = NULL;
+                               return;
+                       }
+               }
+               else {
+                       if (widget->invoke && widget->handler) {
+                               widget->flag |= WM_WIDGET_ACTIVE;
+                               widget->invoke(C, event, widget);
+                               wmap_context.active_widget = widget;
+                       }
+               }
+       }
+       else {
+               widget = wmap_context.active_widget;
+
+               /* deactivate, widget but first take care of some stuff */
+               if (widget) {
+                       widget->flag &= ~WM_WIDGET_ACTIVE;
+                       /* first activate the widget itself */
+                       if (widget->interaction_data) {
+                               MEM_freeN(widget->interaction_data);
+                               widget->interaction_data = NULL;
+                       }
+               }
+               wmap_context.active_widget = NULL;
+
+               ED_region_tag_redraw(CTX_wm_region(C));
+               WM_event_add_mousemove(C);
+       }
+}
+
diff --git a/source/blender/windowmanager/intern/widgets/wm_widgetmap.h 
b/source/blender/windowmanager/intern/widgets/wm_widgetmap.h
index 5089c24..7b84b13 100644
--- a/source/blender/windowmanager/intern/widgets/wm_widgetmap.h
+++ b/source/blender/windowmanager/intern/widgets/wm_widgetmap.h
@@ -50,8 +50,10 @@ public:
                wmWidgetMap *wmap, const char *idname,
                const int spaceid, const int regionid,
                const bool is_3d);
+
        void set_highlighted_widget(struct bContext *C, wmWidget *widget, 
unsigned char part);
        wmWidget *find_highlighted_widget(bContext *C, const struct wmEvent 
*event, unsigned char *part);
+       void set_active_widget(bContext *C, const wmEvent *event, wmWidget 
*widget);
 
        /**
         * \brief Widget map runtime context
diff --git a/source/blender/windowmanager/intern/widgets/wm_widgets_c_api.cc 
b/source/blender/windowmanager/intern/widgets/wm_widgets_c_api.cc
index e43a4e7..788ac59 100644
--- a/source/blender/windowmanager/intern/widgets/wm_widgets_c_api.cc
+++ b/source/blender/windowmanager/intern/widgets/wm_widgets_c_api.cc
@@ -62,6 +62,15 @@ wmWidget *wm_widgetmap_get_highlighted_widget(wmWidgetMap 
*wmap)
        return wmap->wmap_context.highlighted_widget;
 }
 
+void wm_widgetmap_set_active_widget(wmWidgetMap *wmap, bContext *C, const 
wmEvent *event, wmWidget *widget)
+{
+       wmap->set_active_widget(C, event, widget);
+}
+wmWidget *wm_widgetmap_get_active_widget(wmWidgetMap *wmap)
+{
+       return wmap->wmap_context.active_widget;
+}
+
 
 wmWidget *wm_widgetmap_find_highlighted_widget(
         wmWidgetMap *wmap, bContext *C, const wmEvent *event,
diff --git a/source/blender/windowmanager/intern/widgets/wm_widgets_c_api.h 
b/source/blender/windowmanager/intern/widgets/wm_widgets_c_api.h
index 13d2fdc..604d6e1 100644
--- a/source/blender/windowmanager/intern/widgets/wm_widgets_c_api.h
+++ b/source/blender/windowmanager/intern/widgets/wm_widgets_c_api.h
@@ -53,6 +53,7 @@ struct wmWidgetMapType *WM_widgetmaptype_find(
 struct wmWidgetMap *WM_widgetmap_from_type(
         const char *idname, const int spaceid, const int regionid,
         const bool is_3d);
+/* highlighted widget */
 void wm_widgetmap_set_highlighted_widget(
         struct bContext *C, struct wmWidgetMap *wmap, struct wmWidget *widget,
         unsigned char part);
@@ -60,6 +61,10 @@ struct wmWidget *wm_widgetmap_get_highlighted_widget(struct 
wmWidgetMap *wmap);
 struct wmWidget *wm_widgetmap_find_highlighted_widget(
         struct wmWidgetMap *wmap, struct bContext *C, const struct wmEvent 
*event,
         unsigned char *part);
+/* active widget */
+void wm_widgetmap_set_active_widget(
+        struct wmWidgetMap *wmap, struct bContext *C, const struct wmEvent 
*event, struct wmWidget *widget);
+struct wmWidget *wm_widgetmap_get_active_widget(struct wmWidgetMap *wmap);
 
 struct wmWidgetGroupType *WM_widgetgrouptype_new(
         int (*poll)(const struct bContext *, struct wmWidgetGroupType *),
diff --git a/source/blender/windowmanager/intern/wm_widgets.c 
b/source/blender/windowmanager/intern/wm_widgets.c
index b93959f..c8bb210 100644
--- a/source/blender/windowmanager/intern/wm_widgets.c
+++ b/source/blender/windowmanager/intern/wm_widgets.c
@@ -957,68 +957,6 @@ bool WM_widgetmap_cursor_set(const wmWidgetMapC *wmap, 
wmWindow *win)
        return false;
 }
 
-void wm_widgetmap_set_active_widget(
-        wmWidgetMapC *wmap, bContext *C,
-        const wmEvent *event, wmWidget *widget)
-{
-       if (widget) {
-               if (widget->opname) {
-                       wmOperatorType *ot = 
WM_operatortype_find(widget->opname, 0);
-
-                       if (ot) {
-                               /* first activate the widget itself */
-                               if (widget->invoke && widget->handler) {
-                                       widget->flag |= WM_WIDGET_ACTIVE;
-                                       widget->invoke(C, event, widget);
-                               }
-                               wmap->wmap_context.active_widget = widget;
-
-                               WM_operator_name_call_ptr(C, ot, 
WM_OP_INVOKE_DEFAULT, &widget->opptr);
-
-                               /* we failed to hook the widget to the operator 
handler or operator was cancelled, return */
-                               if (!wmap->wmap_context.active_widget) {
-                                       widget->flag &= ~WM_WIDGET_ACTIVE;
-                                       /* first activate the widget itself */
-                                       if (widget->interaction_data) {
-                                               
MEM_freeN(widget->interaction_data);
-                                               widget->interaction_data = NULL;
-                                       }
-                               }
-                               return;
-                       }
-                       else {
-                               printf("Widget error: operator not found");
-                               wmap->wmap_context.active_widget = NULL;
-                               return;
-                       }
-               }
-               else {
-                       if (widget->invoke && widget->handler) {
-                               widget->flag |= WM_WIDGET_ACTIVE;
-                               widget->invoke(C, event, widget);
-                               wmap->wmap_context.active_widget = widget;
-                       }
-               }
-       }
-       else {
-               widget = wmap->wmap_context.active_widget;
-
-               /* deactivate, widget but first take care of some stuff */
-               if (widget) {
-                       widget->flag &= ~WM_WIDGET_ACTIVE;
-                       /* first activate the widget itself */
-                       if (widget->interaction_data) {
-                               MEM_freeN(widget->interaction_data);
-                               widget->interaction_data = NULL;
-                       }
-               }
-               wmap->wmap_context.active_widget = NULL;
-
-               ED_region_tag_redraw(CTX_wm_region(C));
-               WM_event_add_mousemove(C);
-       }
-}
-
 void wm_widgetmap_handler_context(bContext *C, wmEventHandler *handler)
 {
        bScreen *screen = CTX_wm_screen(C);
@@ -1086,11 +1024,6 @@ void wm_widget_handler_modal_update(bContext *C, wmEvent 
*event, wmEventHandler
        }
 }
 
-wmWidget *wm_widgetmap_get_active_widget(wmWidgetMapC *wmap)
-{
-       return wmap->wmap_context.active_widget;
-}
-
 void WM_widgetmap_delete(wmWidgetMapC *wmap)
 {
        if (!wmap)
diff --git a/source/blender/windowmanager/wm_event_system.h 
b/source/blender/windowmanager/wm_event_system.h
index 09c78e3..f8a3a68 100644
--- a/source/blender/windowmanager/wm_event_system.h
+++ b/source/blender/windowmanager/wm_event_system.h
@@ -104,9 +104,6 @@ void        wm_drags_draw(bContext *C, wmWindow *win, rcti 
*rect);
 void wm_widget_handler_modal_update(bContext *C, wmEvent *event, 
wmEventHandler *handler);
 void wm_widgetmap_handler_context(bContext *C, wmEventHandler *handler);
 
-void      wm_widgetmap_set_active_widget(wmWidgetMapC *wmap, bContext *C, 
const wmEvent *event, wmWidget *widget);
-wmWidget *wm_widgetmap_get_active_widget(wmWidgetMapC *wmap);
-
 void      wm_widget_select(bContext *C, wmWidgetMapC *wmap, wmWidget *widget);
 
 #endif /* __WM_EVENT_SYSTEM_H__ */

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

Reply via email to