Commit: a6413f23cd1f0ec261e97584573d637370b56841
Author: Julian Eisel
Date:   Fri Nov 13 21:58:08 2015 +0100
Branches: wiggly-widgets
https://developer.blender.org/rBa6413f23cd1f0ec261e97584573d637370b56841

Cleanup: Add and use widget map context to store wmap runtime data

We might need this for a couple of other things and IMHO it's nicer to keep it 
a bit separated.

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

M       source/blender/editors/space_graph/graph_edit.c
M       source/blender/editors/space_sequencer/sequencer_view.c
M       source/blender/windowmanager/WM_types.h
M       source/blender/windowmanager/intern/wm_event_system.c
M       source/blender/windowmanager/intern/wm_widgets.c

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

diff --git a/source/blender/editors/space_graph/graph_edit.c 
b/source/blender/editors/space_graph/graph_edit.c
index dbf1ce1..c86c416 100644
--- a/source/blender/editors/space_graph/graph_edit.c
+++ b/source/blender/editors/space_graph/graph_edit.c
@@ -2651,7 +2651,7 @@ static int graph_widget_backdrop_transform_modal(bContext 
*C, wmOperator *op, co
                        SpaceIpo *sipo = CTX_wm_space_graph(C);
 
                        /* only end modal if we're not dragging a widget */
-                       if (!wmap->active_widget && event->val == KM_PRESS) {
+                       if (!wmap->wmap_context.active_widget && event->val == 
KM_PRESS) {
                                copy_v2_v2(sipo->backdrop_offset, 
data->init_offset);
                                sipo->backdrop_zoom = data->init_zoom;
 
diff --git a/source/blender/editors/space_sequencer/sequencer_view.c 
b/source/blender/editors/space_sequencer/sequencer_view.c
index 3208a11..790fcc0 100644
--- a/source/blender/editors/space_sequencer/sequencer_view.c
+++ b/source/blender/editors/space_sequencer/sequencer_view.c
@@ -378,7 +378,7 @@ static int sequencer_overdrop_transform_modal(bContext *C, 
wmOperator *op, const
                        SpaceSeq *sseq = CTX_wm_space_seq(C);
 
                        /* only end modal if we're not dragging a widget */
-                       if (!wmap->active_widget && event->val == KM_PRESS) {
+                       if (!wmap->wmap_context.active_widget && event->val == 
KM_PRESS) {
                                copy_v2_v2(sseq->overdrop_offset, 
data->init_offset);
                                sseq->overdrop_zoom = data->init_zoom;
 
@@ -531,7 +531,7 @@ static int sequencer_image_transform_widget_modal(bContext 
*C, wmOperator *op, c
 
                        /* no offset needed in this case */
                        offset[0] = offset[1] = 0;
-                       WM_widget_set_offset(wmap->active_widget, offset);
+                       WM_widget_set_offset(wmap->wmap_context.active_widget, 
offset);
                        break;
                }
 
diff --git a/source/blender/windowmanager/WM_types.h 
b/source/blender/windowmanager/WM_types.h
index 3e43047..0e09f2c 100644
--- a/source/blender/windowmanager/WM_types.h
+++ b/source/blender/windowmanager/WM_types.h
@@ -719,18 +719,25 @@ typedef struct wmWidgetGroupType {
 typedef struct wmWidgetMap {
        struct wmWidgetMap *next, *prev;
 
-       struct wmWidgetMapType *type;
+       wmWidgetMapType *type;
        ListBase widgetgroups;
 
-       /* highlighted widget for this map. We redraw the widgetmap when this 
changes  */
-       struct wmWidget *highlighted_widget;
-       /* active widget for this map. User has clicked currently this widget 
and it gets all input */
-       struct wmWidget *active_widget;
-       /* selected widget for this map. */
-       struct wmWidget *selected_widget;
-
-       /* active group - set while widget is highlighted/active */
-       struct wmWidgetGroup *activegroup;
+       /**
+        * \brief Widget map runtime context
+        *
+        * Contains information about this widget map. Currently
+        * highlighted widget, currently selected widget, ...
+        */
+       struct {
+               /* we redraw the widgetmap when this changes */
+               wmWidget *highlighted_widget;
+               /* user has clicked this widget and it gets all input */
+               wmWidget *active_widget;
+               wmWidget *selected_widget;
+
+               /* set while widget is highlighted/active */
+               wmWidgetGroup *activegroup;
+       } wmap_context;
 } wmWidgetMap;
 
 /* *************** migrated stuff, clean later? ************** */
diff --git a/source/blender/windowmanager/intern/wm_event_system.c 
b/source/blender/windowmanager/intern/wm_event_system.c
index 58b413c..83137e9 100644
--- a/source/blender/windowmanager/intern/wm_event_system.c
+++ b/source/blender/windowmanager/intern/wm_event_system.c
@@ -2092,9 +2092,9 @@ static int wm_handlers_do_intern(bContext *C, wmEvent 
*event, ListBase *handlers
                                        }
                                }
                                /* handle user configurable widgetmap keymap */
-                               else if (widget && wmap->activegroup) {
+                               else if (widget && 
wmap->wmap_context.activegroup) {
                                        /* get user customized keymap from 
default one */
-                                       const wmKeyMap *keymap = 
WM_keymap_active(wm, wmap->activegroup->type->keymap);
+                                       const wmKeyMap *keymap = 
WM_keymap_active(wm, wmap->wmap_context.activegroup->type->keymap);
                                        wmKeyMapItem *kmi;
 
                                        if (!keymap->poll || keymap->poll(C)) {
diff --git a/source/blender/windowmanager/intern/wm_widgets.c 
b/source/blender/windowmanager/intern/wm_widgets.c
index 9fd07c5..aa1a197 100644
--- a/source/blender/windowmanager/intern/wm_widgets.c
+++ b/source/blender/windowmanager/intern/wm_widgets.c
@@ -249,7 +249,7 @@ void WM_widgets_update(const bContext *C, wmWidgetMap *wmap)
        if (!wmap)
                return;
 
-       widget = wmap->active_widget;
+       widget = wmap->wmap_context.active_widget;
 
        if (widget) {
                widget_calculate_scale(widget, C);
@@ -265,7 +265,7 @@ void WM_widgets_update(const bContext *C, wmWidgetMap *wmap)
                                for (widget = wgroup->widgets.first; widget;) {
                                        wmWidget *widget_next = widget->next;
 
-                                       if (widget == wmap->selected_widget) {
+                                       if (widget == 
wmap->wmap_context.selected_widget) {
                                                /* skip */
                                        }
                                        /* do not delete the highlighted 
widget, instead keep it to compare with the new one */
@@ -288,7 +288,7 @@ void WM_widgets_update(const bContext *C, wmWidgetMap *wmap)
                                        for (widget = wgroup->widgets.first; 
widget; widget = widget->next) {
                                                if (widgets_compare(widget, 
highlighted)) {
                                                        widget->flag |= 
WM_WIDGET_HIGHLIGHT;
-                                                       
wmap->highlighted_widget = widget;
+                                                       
wmap->wmap_context.highlighted_widget = widget;
                                                        
widget->highlighted_part = highlighted->highlighted_part;
                                                        
wm_widget_delete(&wgroup->widgets, highlighted);
                                                        highlighted = NULL;
@@ -301,7 +301,7 @@ void WM_widgets_update(const bContext *C, wmWidgetMap *wmap)
                                if (highlighted) {
                                        MEM_freeN(highlighted);
                                        highlighted = NULL;
-                                       wmap->highlighted_widget = NULL;
+                                       wmap->wmap_context.highlighted_widget = 
NULL;
                                }
 
                                for (widget = wgroup->widgets.first; widget; 
widget = widget->next) {
@@ -343,7 +343,7 @@ void WM_widgets_draw(const bContext *C, const wmWidgetMap 
*wmap, const bool in_s
                glPopMatrix();
        }
 
-       widget = wmap->active_widget;
+       widget = wmap->wmap_context.active_widget;
 
        if (widget && in_scene == ((widget->flag & WM_WIDGET_SCENE_DEPTH) != 
0)) {
                if (widget->flag & WM_WIDGET_DRAW_ACTIVE) {
@@ -370,7 +370,7 @@ void WM_widgets_draw(const bContext *C, const wmWidgetMap 
*wmap, const bool in_s
        }
 
        /* draw selected widgets last */
-       if ((widget = wmap->selected_widget) && in_scene == ((widget->flag & 
WM_WIDGET_SCENE_DEPTH) != 0)) {
+       if ((widget = wmap->wmap_context.selected_widget) && in_scene == 
((widget->flag & WM_WIDGET_SCENE_DEPTH) != 0)) {
                if (widgetgroup_poll_check(C, widget->wgroup)) {
                        /* notice that we don't update the widgetgroup, widget 
is now on
                         * its own, it should have all relevant data to update 
itself */
@@ -439,8 +439,8 @@ static void widget_unique_idname_set(wmWidgetGroup *wgroup, 
wmWidget *widget, co
 static wmWidget *widget_find_active_in_region(const ARegion *ar, wmWidgetMap 
**r_wmap)
 {
        for (*r_wmap = ar->widgetmaps.first; *r_wmap; *r_wmap = 
(*r_wmap)->next) {
-               if ((*r_wmap)->active_widget) {
-                       return (*r_wmap)->active_widget;
+               if ((*r_wmap)->wmap_context.active_widget) {
+                       return (*r_wmap)->wmap_context.active_widget;
                }
        }
 
@@ -588,7 +588,7 @@ static int widget_set_active_invoke(bContext *C, wmOperator 
*op, const wmEvent *
                        ((wmEvent *)event)->type = EVT_WIDGET_RELEASED;
                }
                else {
-                       wmWidget *widget = wmap->highlighted_widget;
+                       wmWidget *widget = 
wmap->wmap_context.highlighted_widget;
                        if (widget) {
                                wm_widgetmap_set_active_widget(wmap, C, event, 
widget);
                                break;
@@ -624,7 +624,7 @@ static int widget_set_select_invoke(bContext *C, wmOperator 
*UNUSED(op), const w
        wmWidgetMap *wmap;
 
        for (wmap = ar->widgetmaps.first; wmap; wmap = wmap->next) {
-               wmWidget *widget = wmap->highlighted_widget;
+               wmWidget *widget = wmap->wmap_context.highlighted_widget;
                if (widget) {
                        if (widget->flag & WM_WIDGET_SELECTABLE) {
                                wm_widgetmap_set_selected_widget(C, wmap, 
widget);
@@ -924,7 +924,7 @@ wmWidget *wm_widget_find_highlighted(wmWidgetMap *wmap, 
bContext *C, const wmEve
 bool WM_widgetmap_cursor_set(const wmWidgetMap *wmap, wmWindow *win)
 {
        for (; wmap; wmap = wmap->next) {
-               wmWidget *widget = wmap->highlighted_widget;
+               wmWidget *widget = wmap->wmap_context.highlighted_widget;
                if (widget && widget->get_cursor) {
                        WM_cursor_set(win, widget->get_cursor(widget));
                        return true;
@@ -936,18 +936,18 @@ bool WM_widgetmap_cursor_set(const wmWidgetMap *wmap, 
wmWindow *win)
 
 void wm_widgetmap_set_highlighted_widget(wmWidgetMap *wmap, bContext *C, 
wmWidget *widget, unsigned char part)
 {
-       if ((widget != wmap->highlighted_widget) || (widget && part != 
widget->highlighted_part)) {
-               if (wmap->highlighted_widget) {
-                       wmap->highlighted_widget->flag &= ~WM_WIDGET_HIGHLIGHT;
-                       wmap->highlighted_widget->highlighted_part = 0;
+       if ((widget != wmap->wmap_context.highlighted_widget) || (widget && 
part != widget->highlighted_part)) {
+               if (wmap->wmap_context.highlighted_widget) {
+                       wmap->wmap_context.highlighted_widget->flag &= 
~WM_WIDGET_HIGHLIGHT;
+                       wmap->wmap_context.highlighted_widget->highlighted_part 
= 0;
                }
 
-               wmap->highlighted_widget = widget;
+               wmap->wmap_context.highlighted_widget = widget;
 
                if (widget) {
                        widget->flag |= WM_WIDGET_HIGHLIGHT;
                        widget->highlighted_part = part;
-                       wmap->activegroup = widget->wgroup;
+                       wmap->wmap_context.activegroup = widget->wgroup;
 
                        if (C && widget->get_cursor) {
                                wmWindow *win = CTX_wm_window(C);
@@ -955,7 +955,7 @@ void wm_widgetmap_set_highlighted_widget(wmWidgetMap *wmap, 
bContext *C, wmWidge
                        }
                }
                else {
-                       wmap->activegroup = NULL;
+                       wmap->wmap_context.activegroup = NULL;
                        if (C) {
                                wmWindow *win = CTX_wm_window(C);
                                WM_cursor_set(win, CURSOR_STD);
@@ -972,7 +972,7 @@ void wm_widgetmap_set_highlighted_widget(wmWidgetMap *wmap, 
bContext *C, wmWidge
 
 wmWidget *wm_widgetmap_get_highlighted_widget(wmWidgetMap *wmap)
 {
-       return wmap->highlighted_widget;
+       return wmap->wmap_context.highlighted_widget;
 }
 
 void wm_widgetmap_set_active_widget(
@@ -991,12 +991,12 @@ void wm_widgetmap_set_active_widget(
                                        widget->flag |= WM_WIDGET_ACTIVE;
                                        widget->invoke(C, event, widget);
                                }
-                               wmap->active_widget = widget;
+                               wmap->wmap_context.active_widget = widget;
 
                                WM_operator_name_call_ptr(C, ot, WM_OP_

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