[Bf-blender-cvs] [748d9ec] wiggly-widgets: Separate widget drawing to update and draw phase to make in-scene widget drawing possible (need to update once, draw twice).
Antony Riakiotakis
noreply at git.blender.org
Tue Feb 10 12:52:43 CET 2015
Commit: 748d9eca90915195f3aadec59627015d6344bc18
Author: Antony Riakiotakis
Date: Tue Feb 10 12:52:29 2015 +0100
Branches: wiggly-widgets
https://developer.blender.org/rB748d9eca90915195f3aadec59627015d6344bc18
Separate widget drawing to update and draw phase to make in-scene widget
drawing possible (need to update once, draw twice).
===================================================================
M source/blender/editors/space_node/node_draw.c
M source/blender/editors/space_sequencer/sequencer_draw.c
M source/blender/editors/space_view3d/view3d_draw.c
M source/blender/windowmanager/WM_api.h
M source/blender/windowmanager/intern/wm_widgets.c
===================================================================
diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c
index 6298ac2..b2020da 100644
--- a/source/blender/editors/space_node/node_draw.c
+++ b/source/blender/editors/space_node/node_draw.c
@@ -1354,6 +1354,7 @@ void drawnodespace(const bContext *C, ARegion *ar)
glaDefine2DArea(&ar->winrct);
wmOrtho2_pixelspace(ar->winx, ar->winy);
+ WM_widgets_update(C, ar->widgetmaps.first);
WM_widgets_draw(C, ar->widgetmaps.first, false);
glMatrixMode(GL_PROJECTION);
diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c
index f899867..d6fc5c4 100644
--- a/source/blender/editors/space_sequencer/sequencer_draw.c
+++ b/source/blender/editors/space_sequencer/sequencer_draw.c
@@ -1582,6 +1582,7 @@ void draw_timeline_seq(const bContext *C, ARegion *ar)
UI_view2d_view_restore(C);
/* finally draw any widgets here */
+ WM_widgets_update(C, ar->widgetmaps.first);
WM_widgets_draw(C, ar->widgetmaps.first, false);
/* scrollers */
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index b04188f..479e865 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -3617,6 +3617,7 @@ void view3d_main_area_draw(const bContext *C, ARegion *ar)
view3d_main_area_setup_view(scene, v3d, ar, NULL, NULL);
glClear(GL_DEPTH_BUFFER_BIT);
+ WM_widgets_update(C, ar->widgetmaps.first);
WM_widgets_draw(C, ar->widgetmaps.first, false);
BIF_draw_manipulator(C);
ED_region_pixelspace(ar);
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h
index a9e7807..d124031 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -478,6 +478,7 @@ struct wmWidget *WM_widget_new(void (*draw)(struct wmWidget *, const struct bCon
void WM_widget_property(struct wmWidget *, int slot, struct PointerRNA *ptr, const char *propname);
struct PointerRNA *WM_widget_operator(struct wmWidget *, const char *opname);
+void WM_widgets_update(const struct bContext *C, struct wmWidgetMap *wmap);
void WM_widgets_draw(const struct bContext *C, struct wmWidgetMap *wmap, bool in_scene);
void WM_event_add_area_widgetmap_handlers(struct ARegion *ar);
void WM_modal_handler_attach_widgetgroup(struct bContext *C, struct wmEventHandler *handler, struct wmWidgetGroupType *wgrouptype, struct wmOperator *op);
diff --git a/source/blender/windowmanager/intern/wm_widgets.c b/source/blender/windowmanager/intern/wm_widgets.c
index cd72945..63cb987 100644
--- a/source/blender/windowmanager/intern/wm_widgets.c
+++ b/source/blender/windowmanager/intern/wm_widgets.c
@@ -256,6 +256,74 @@ static bool widgets_compare(wmWidget *widget, wmWidget *widget2)
return true;
}
+void WM_widgets_update(const bContext *C, wmWidgetMap *wmap)
+{
+ wmWidget *widget;
+
+ if (!wmap)
+ return;
+
+ widget = wmap->active_widget;
+
+ if (widget) {
+ widget_calculate_scale(widget, C);
+ }
+ else if (wmap->widgetgroups.first) {
+ wmWidgetGroup *wgroup;
+
+ for (wgroup = wmap->widgetgroups.first; wgroup; wgroup = wgroup->next) {
+ if (!wgroup->type->poll || wgroup->type->poll(C, wgroup->type))
+ {
+ wmWidget *highlighted = NULL;
+
+ /* first delete and recreate the widgets */
+ for (widget = wgroup->widgets.first; widget;) {
+ wmWidget *widget_next = widget->next;
+
+ /* do not delete the highlighted widget, instead keep it to compare with the new one */
+ if (widget->flag & WM_WIDGET_HIGHLIGHT) {
+ highlighted = widget;
+ BLI_remlink(&wgroup->widgets, widget);
+ widget->next = widget->prev = NULL;
+ }
+ else {
+ wm_widget_delete(&wgroup->widgets, widget);
+ }
+ widget = widget_next;
+ }
+
+ if (wgroup->type->draw) {
+ wgroup->type->draw(C, wgroup);
+ }
+
+ if (highlighted) {
+ for (widget = wgroup->widgets.first; widget; widget = widget->next) {
+ if (widgets_compare(widget, highlighted))
+ {
+ widget->flag |= WM_WIDGET_HIGHLIGHT;
+ wmap->highlighted_widget = widget;
+ widget->highlighted_part = highlighted->highlighted_part;
+ wm_widget_delete(&wgroup->widgets, highlighted);
+ highlighted = NULL;
+ break;
+ }
+ }
+ }
+
+ /* if we don't find a highlighted widget, delete the old one here */
+ if (highlighted) {
+ MEM_freeN(highlighted);
+ highlighted = NULL;
+ wmap->highlighted_widget = NULL;
+ }
+
+ for (widget = wgroup->widgets.first; widget; widget = widget->next) {
+ widget_calculate_scale(widget, C);
+ }
+ }
+ }
+ }
+}
void WM_widgets_draw(const bContext *C, wmWidgetMap *wmap, bool in_scene)
{
@@ -286,7 +354,6 @@ void WM_widgets_draw(const bContext *C, wmWidgetMap *wmap, bool in_scene)
widget = wmap->active_widget;
if (widget && in_scene == ((widget->flag & WM_WIDGET_SCENE_DEPTH)!= 0)) {
- widget_calculate_scale(widget, C);
/* notice that we don't update the widgetgroup, widget is now on its own, it should have all
* relevant data to update itself */
widget->draw(widget, C);
@@ -297,56 +364,12 @@ void WM_widgets_draw(const bContext *C, wmWidgetMap *wmap, bool in_scene)
for (wgroup = wmap->widgetgroups.first; wgroup; wgroup = wgroup->next) {
if (!wgroup->type->poll || wgroup->type->poll(C, wgroup->type))
{
- wmWidget *widget_iter;
- wmWidget *highlighted = NULL;
-
- /* first delete and recreate the widgets */
- for (widget_iter = wgroup->widgets.first; widget_iter;) {
- wmWidget *widget_next = widget_iter->next;
-
- /* do not delete the highlighted widget, instead keep it to compare with the new one */
- if (widget_iter->flag & WM_WIDGET_HIGHLIGHT) {
- highlighted = widget_iter;
- BLI_remlink(&wgroup->widgets, widget_iter);
- widget_iter->next = widget_iter->prev = NULL;
+ for (widget = wgroup->widgets.first; widget; widget = widget->next) {
+ if ((!(widget->flag & WM_WIDGET_DRAW_HOVER) || (widget->flag & WM_WIDGET_HIGHLIGHT)) &&
+ ((widget->flag & WM_WIDGET_SCENE_DEPTH) == 0) == in_scene)
+ {
+ widget->draw(widget, C);
}
- else {
- wm_widget_delete(&wgroup->widgets, widget_iter);
- }
- widget_iter = widget_next;
- }
-
- if (wgroup->type->draw) {
- wgroup->type->draw(C, wgroup);
- }
-
- if (highlighted) {
- for (widget_iter = wgroup->widgets.first; widget_iter; widget_iter = widget_iter->next) {
- if (widgets_compare(widget_iter, highlighted))
- {
- widget_iter->flag |= WM_WIDGET_HIGHLIGHT;
- wmap->highlighted_widget = widget_iter;
- widget_iter->highlighted_part = highlighted->highlighted_part;
- wm_widget_delete(&wgroup->widgets, highlighted);
- highlighted = NULL;
- break;
- }
- }
- }
-
- /* if we don't find a highlighted widget, delete the old one here */
- if (highlighted) {
- MEM_freeN(highlighted);
- highlighted = NULL;
- wmap->highlighted_widget = NULL;
- }
-
-
- for (widget_iter = wgroup->widgets.first; widget_iter; widget_iter = widget_iter->next) {
- widget_calculate_scale(widget_iter, C);
- /* scale must be calculated still for hover widgets, we just avoid drawing */
- if (!(widget_iter->flag & WM_WIDGET_DRAW_HOVER) || (widget_iter->flag & WM_WIDGET_HIGHLIGHT))
- widget_iter->draw(widget_iter, C);
}
}
}
More information about the Bf-blender-cvs
mailing list