[Bf-blender-cvs] [068d8c8] wiggly-widgets: Cleanup: Naming, unused function, comments, ...
Julian Eisel
noreply at git.blender.org
Wed Nov 25 13:29:54 CET 2015
Commit: 068d8c8bcfeb13ebc55bc1b5d7e01a31fd278afc
Author: Julian Eisel
Date: Wed Nov 25 13:27:43 2015 +0100
Branches: wiggly-widgets
https://developer.blender.org/rB068d8c8bcfeb13ebc55bc1b5d7e01a31fd278afc
Cleanup: Naming, unused function, comments, ...
===================================================================
M source/blender/editors/space_graph/space_graph.c
M source/blender/editors/space_node/node_draw.c
M source/blender/editors/space_sequencer/sequencer_draw.c
M source/blender/editors/space_sequencer/space_sequencer.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_graph/space_graph.c b/source/blender/editors/space_graph/space_graph.c
index 0340935..bb1919a 100644
--- a/source/blender/editors/space_graph/space_graph.c
+++ b/source/blender/editors/space_graph/space_graph.c
@@ -360,8 +360,8 @@ static void graph_main_area_draw(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, true);
+ WM_widgetmap_widgets_update(C, ar->widgetmaps.first);
+ WM_widgetmap_widgets_draw(C, ar->widgetmaps.first, false, true);
/* scrollers */
// FIXME: args for scrollers depend on the type of data being shown...
diff --git a/source/blender/editors/space_node/node_draw.c b/source/blender/editors/space_node/node_draw.c
index e6e545f..a9c2bce 100644
--- a/source/blender/editors/space_node/node_draw.c
+++ b/source/blender/editors/space_node/node_draw.c
@@ -1366,8 +1366,8 @@ 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, true);
+ WM_widgetmap_widgets_update(C, ar->widgetmaps.first);
+ WM_widgetmap_widgets_draw(C, ar->widgetmaps.first, false, true);
glMatrixMode(GL_PROJECTION);
glPopMatrix();
diff --git a/source/blender/editors/space_sequencer/sequencer_draw.c b/source/blender/editors/space_sequencer/sequencer_draw.c
index 6378f9d..85feb0a 100644
--- a/source/blender/editors/space_sequencer/sequencer_draw.c
+++ b/source/blender/editors/space_sequencer/sequencer_draw.c
@@ -1650,8 +1650,8 @@ 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, true);
+ WM_widgetmap_widgets_update(C, ar->widgetmaps.first);
+ WM_widgetmap_widgets_draw(C, ar->widgetmaps.first, false, true);
/* scrollers */
unit = (sseq->flag & SEQ_DRAWFRAMES) ? V2D_UNIT_FRAMES : V2D_UNIT_SECONDS;
diff --git a/source/blender/editors/space_sequencer/space_sequencer.c b/source/blender/editors/space_sequencer/space_sequencer.c
index 7af6f77..d657709 100644
--- a/source/blender/editors/space_sequencer/space_sequencer.c
+++ b/source/blender/editors/space_sequencer/space_sequencer.c
@@ -605,8 +605,8 @@ static void sequencer_preview_area_draw(const bContext *C, ARegion *ar)
ED_scene_draw_fps(scene, &rect);
}
- WM_widgets_update(C, ar->widgetmaps.first);
- WM_widgets_draw(C, ar->widgetmaps.first, false, true);
+ WM_widgetmap_widgets_update(C, ar->widgetmaps.first);
+ WM_widgetmap_widgets_draw(C, ar->widgetmaps.first, false, true);
}
static void sequencer_preview_area_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(sa), ARegion *ar, wmNotifier *wmn)
diff --git a/source/blender/editors/space_view3d/view3d_draw.c b/source/blender/editors/space_view3d/view3d_draw.c
index 6554022..3c325f7 100644
--- a/source/blender/editors/space_view3d/view3d_draw.c
+++ b/source/blender/editors/space_view3d/view3d_draw.c
@@ -3891,9 +3891,9 @@ static void view3d_main_area_draw_objects(const bContext *C, Scene *scene, View3
/* widgets need to be updated *after* view matrix was set up
* XXX since we do 2 draw calls (with and without depth culling),
* it might be better to have 2 update calls, too */
- WM_widgets_update(C, ar->widgetmaps.first);
+ WM_widgetmap_widgets_update(C, ar->widgetmaps.first);
/* draw depth culled widgets */
- WM_widgets_draw(C, ar->widgetmaps.first, true, false);
+ WM_widgetmap_widgets_draw(C, ar->widgetmaps.first, true, false);
/* post process */
if (do_compositing) {
@@ -4066,9 +4066,9 @@ void view3d_main_area_draw(const bContext *C, ARegion *ar)
glClear(GL_DEPTH_BUFFER_BIT);
if (update_widgets) {
- WM_widgets_update(C, ar->widgetmaps.first);
+ WM_widgetmap_widgets_update(C, ar->widgetmaps.first);
}
- WM_widgets_draw(C, ar->widgetmaps.first, false, true);
+ WM_widgetmap_widgets_draw(C, ar->widgetmaps.first, false, true);
ED_region_pixelspace(ar);
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h
index e893673..f624f2a 100644
--- a/source/blender/windowmanager/WM_api.h
+++ b/source/blender/windowmanager/WM_api.h
@@ -510,8 +510,8 @@ struct wmWidget *WM_widget_new(void (*draw)(const struct bContext *, struct wmWi
int (*intersect)(struct bContext *, const struct wmEvent *, struct wmWidget *),
int (*handler)(struct bContext *, const struct wmEvent *, struct wmWidget *));
-void WM_widgets_update(const struct bContext *C, struct wmWidgetMap *wmap);
-void WM_widgets_draw(const struct bContext *C, const struct wmWidgetMap *wmap,
+void WM_widgetmap_widgets_update(const struct bContext *C, struct wmWidgetMap *wmap);
+void WM_widgetmap_widgets_draw(const struct bContext *C, const struct wmWidgetMap *wmap,
const bool in_scene, const bool free_drawwidgets);
void WM_event_add_area_widgetmap_handlers(struct ARegion *ar);
void WM_modal_handler_attach_widgetgroup(struct bContext *C, struct wmEventHandler *handler,
diff --git a/source/blender/windowmanager/intern/wm_widgets.c b/source/blender/windowmanager/intern/wm_widgets.c
index 4cf0dd6..a59ab4b 100644
--- a/source/blender/windowmanager/intern/wm_widgets.c
+++ b/source/blender/windowmanager/intern/wm_widgets.c
@@ -169,11 +169,15 @@ wmWidgetGroupType *WM_widgetgrouptype_new(
}
/**
- * Creates an idname hash table for all (visible) widgets with \a flag in \a wmap
+ * Creates and returns idname hash table for (visible) widgets in \a wmap
+ *
+ * \param poll Polling function for excluding widgets.
+ * \param data Custom data passed to \a poll
*/
-static GHash *wm_widgetgroup_widget_hash_new(
+static GHash *wm_widgetmap_widget_hash_new(
const bContext *C, wmWidgetMap *wmap,
- const int flag, const bool visible_only)
+ bool (*poll)(const wmWidget *, void *),
+ void *data, const bool include_hidden)
{
GHash *hash = BLI_ghash_str_new(__func__);
@@ -181,8 +185,8 @@ static GHash *wm_widgetgroup_widget_hash_new(
for (wmWidgetGroup *wgroup = wmap->widgetgroups.first; wgroup; wgroup = wgroup->next) {
if (!wgroup->type->poll || wgroup->type->poll(C, wgroup->type)) {
for (wmWidget *widget = wgroup->widgets.first; widget; widget = widget->next) {
- if ((!visible_only || (widget->flag & WM_WIDGET_HIDDEN) == 0) &&
- (flag == 0 || widget->flag & flag))
+ if ((include_hidden || (widget->flag & WM_WIDGET_HIDDEN) == 0) &&
+ (!poll || poll(widget, data)))
{
BLI_ghash_insert(hash, widget->idname, widget);
}
@@ -269,7 +273,7 @@ void wm_widgets_keymap(wmKeyConfig *keyconf)
}
}
-BLI_INLINE bool widgets_compare(const wmWidget *a, const wmWidget *b)
+BLI_INLINE bool widget_compare(const wmWidget *a, const wmWidget *b)
{
return STREQ(a->idname, b->idname);
}
@@ -281,7 +285,7 @@ static void widget_highlight_update(wmWidgetMap *wmap, const wmWidget *old_, wmW
new_->highlighted_part = old_->highlighted_part;
}
-void WM_widgets_update(const bContext *C, wmWidgetMap *wmap)
+void WM_widgetmap_widgets_update(const bContext *C, wmWidgetMap *wmap)
{
wmWidget *widget = wmap->wmap_context.active_widget;
@@ -345,7 +349,7 @@ void WM_widgets_update(const bContext *C, wmWidgetMap *wmap)
if (highlighted) {
wmWidget *highlighted_new = BLI_ghash_lookup(draw_widgets, highlighted->idname);
if (highlighted_new) {
- BLI_assert(widgets_compare(highlighted, highlighted_new));
+ BLI_assert(widget_compare(highlighted, highlighted_new));
widget_highlight_update(wmap, highlighted, highlighted_new);
wm_widget_delete(NULL, highlighted);
}
@@ -365,7 +369,7 @@ void WM_widgets_update(const bContext *C, wmWidgetMap *wmap)
if (!sel_new)
continue;
- BLI_assert(widgets_compare(sel_old, sel_new));
+ BLI_assert(widget_compare(sel_old, sel_new));
/* widget was selected and highlighted */
if (sel_old->flag & WM_WIDGET_HIGHLIGHT) {
@@ -381,11 +385,6 @@ void WM_widgets_update(const bContext *C, wmWidgetMap *wmap)
}
}
-BLI_INLINE bool widgetgroup_poll_check(const bContext *C, const wmWidgetGroup *wgroup)
-{
- return (!wgroup->type->poll || wgroup->type->poll(C, wgroup->type));
-}
-
/**
* Draw all visible widgets in \a wmap.
* Uses global draw_widgets hash table.
@@ -393,7 +392,7 @@ BLI_INLINE bool widgetgroup_poll_check(const bContext *C, const wmWidgetGroup *w
* \param in_scene draw depth-culled widgets (wmWidget->flag WM_WIDGET_SCENE_DEPTH) - TODO
* \param free_drawwidgets free global draw_widgets hash table (always enable for last draw call in region!).
*/
-void WM_widgets_draw(
+void WM_widgetmap_widgets_draw(
const bContext *C, const wmWidgetMap *wmap,
const bool in_scene, const bool free_drawwidgets)
{
@@ -438,7 +437,7 @@ void WM_widgets_draw(
else if (wmap->widgetgroups.first) {
GHashIterator gh_iter;
- GHASH_ITER (gh_iter, draw_widgets) {
+ GHASH_ITER (gh_iter, draw_widgets) { /* draw_widgets excludes hidden widgets */
widget = BLI_ghashIterator_getValue(&gh_iter);
if ((in_scene == (widget->flag & WM_WIDGET_SCENE_DEPTH)) &&
((widget->flag & WM_WIDGET_SELECTED) == 0) && /* selected are drawn later */
@@ -1140,6 +1139,11 @@ static bool wm_widgetmap_deselect_all(wmWidgetMap *wmap, wmWidget ***sel)
return true;
}
+BLI_INLINE bool widget_selectable_poll(const wmWidget *widget, void *UNUSED(data))
+{
+ return (widget->flag & WM_WIDGET_SELECTABLE);
+}
+
/**
* Select all selectable widgets in \a wmap.
* \return if selection has changed.
@@ -1150,7 +1154,7 @@ static bool wm_widgetmap_select_all_intern(bContext *C, wmWidgetMap *wmap, wmWid
* get tot_sel for allocating, once for actually selecting). Instead we collect
* selectable widgets in hash table and use this to get tot_sel and do selection */
- GHash *hash = wm_widgetgroup_widget_hash_new(C, wmap, WM_WIDGET_SELECTABLE, true);
+ GHash *hash = wm_widgetmap_widget_hash_new(C, wmap, widget
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list