diff options
author | Campbell Barton <ideasman42@gmail.com> | 2019-04-17 07:17:24 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2019-04-17 07:21:24 +0300 |
commit | e12c08e8d170b7ca40f204a5b0423c23a9fbc2c1 (patch) | |
tree | 8cf3453d12edb177a218ef8009357518ec6cab6a /source/blender/windowmanager/gizmo/intern/wm_gizmo_type.c | |
parent | b3dabc200a4b0399ec6b81f2ff2730d07b44fcaa (diff) |
ClangFormat: apply to source, most of intern
Apply clang format as proposed in T53211.
For details on usage and instructions for migrating branches
without conflicts, see:
https://wiki.blender.org/wiki/Tools/ClangFormat
Diffstat (limited to 'source/blender/windowmanager/gizmo/intern/wm_gizmo_type.c')
-rw-r--r-- | source/blender/windowmanager/gizmo/intern/wm_gizmo_type.c | 162 |
1 files changed, 80 insertions, 82 deletions
diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_type.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_type.c index b164d4c549f..fd8a01ca575 100644 --- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_type.c +++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_type.c @@ -45,7 +45,6 @@ #include "wm_gizmo_wmapi.h" #include "wm_gizmo_intern.h" - /** \name Gizmo Type Append * * \note This follows conventions from #WM_operatortype_find #WM_operatortype_append & friends. @@ -55,65 +54,65 @@ static GHash *global_gizmotype_hash = NULL; const wmGizmoType *WM_gizmotype_find(const char *idname, bool quiet) { - if (idname[0]) { - wmGizmoType *gzt; - - gzt = BLI_ghash_lookup(global_gizmotype_hash, idname); - if (gzt) { - return gzt; - } - - if (!quiet) { - printf("search for unknown gizmo '%s'\n", idname); - } - } - else { - if (!quiet) { - printf("search for empty gizmo\n"); - } - } - - return NULL; + if (idname[0]) { + wmGizmoType *gzt; + + gzt = BLI_ghash_lookup(global_gizmotype_hash, idname); + if (gzt) { + return gzt; + } + + if (!quiet) { + printf("search for unknown gizmo '%s'\n", idname); + } + } + else { + if (!quiet) { + printf("search for empty gizmo\n"); + } + } + + return NULL; } /* caller must free */ void WM_gizmotype_iter(GHashIterator *ghi) { - BLI_ghashIterator_init(ghi, global_gizmotype_hash); + BLI_ghashIterator_init(ghi, global_gizmotype_hash); } static wmGizmoType *wm_gizmotype_append__begin(void) { - wmGizmoType *gzt = MEM_callocN(sizeof(wmGizmoType), "gizmotype"); - gzt->srna = RNA_def_struct_ptr(&BLENDER_RNA, "", &RNA_GizmoProperties); + wmGizmoType *gzt = MEM_callocN(sizeof(wmGizmoType), "gizmotype"); + gzt->srna = RNA_def_struct_ptr(&BLENDER_RNA, "", &RNA_GizmoProperties); #if 0 - /* Set the default i18n context now, so that opfunc can redefine it if needed! */ - RNA_def_struct_translation_context(ot->srna, BLT_I18NCONTEXT_OPERATOR_DEFAULT); - ot->translation_context = BLT_I18NCONTEXT_OPERATOR_DEFAULT; + /* Set the default i18n context now, so that opfunc can redefine it if needed! */ + RNA_def_struct_translation_context(ot->srna, BLT_I18NCONTEXT_OPERATOR_DEFAULT); + ot->translation_context = BLT_I18NCONTEXT_OPERATOR_DEFAULT; #endif - return gzt; + return gzt; } static void wm_gizmotype_append__end(wmGizmoType *gzt) { - BLI_assert(gzt->struct_size >= sizeof(wmGizmo)); + BLI_assert(gzt->struct_size >= sizeof(wmGizmo)); - RNA_def_struct_identifier(&BLENDER_RNA, gzt->srna, gzt->idname); + RNA_def_struct_identifier(&BLENDER_RNA, gzt->srna, gzt->idname); - BLI_ghash_insert(global_gizmotype_hash, (void *)gzt->idname, gzt); + BLI_ghash_insert(global_gizmotype_hash, (void *)gzt->idname, gzt); } void WM_gizmotype_append(void (*gtfunc)(struct wmGizmoType *)) { - wmGizmoType *gzt = wm_gizmotype_append__begin(); - gtfunc(gzt); - wm_gizmotype_append__end(gzt); + wmGizmoType *gzt = wm_gizmotype_append__begin(); + gtfunc(gzt); + wm_gizmotype_append__end(gzt); } void WM_gizmotype_append_ptr(void (*gtfunc)(struct wmGizmoType *, void *), void *userdata) { - wmGizmoType *mt = wm_gizmotype_append__begin(); - gtfunc(mt, userdata); - wm_gizmotype_append__end(mt); + wmGizmoType *mt = wm_gizmotype_append__begin(); + gtfunc(mt, userdata); + wm_gizmotype_append__end(mt); } /** @@ -121,86 +120,85 @@ void WM_gizmotype_append_ptr(void (*gtfunc)(struct wmGizmoType *, void *), void */ static void gizmotype_free(wmGizmoType *gzt) { - if (gzt->ext.srna) { /* python gizmo, allocs own string */ - MEM_freeN((void *)gzt->idname); - } + if (gzt->ext.srna) { /* python gizmo, allocs own string */ + MEM_freeN((void *)gzt->idname); + } - BLI_freelistN(&gzt->target_property_defs); - MEM_freeN(gzt); + BLI_freelistN(&gzt->target_property_defs); + MEM_freeN(gzt); } /** * \param C: May be NULL. */ -static void gizmotype_unlink( - bContext *C, Main *bmain, wmGizmoType *gzt) +static void gizmotype_unlink(bContext *C, Main *bmain, wmGizmoType *gzt) { - /* Free instances. */ - for (bScreen *sc = bmain->screens.first; sc; sc = sc->id.next) { - for (ScrArea *sa = sc->areabase.first; sa; sa = sa->next) { - for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { - ListBase *lb = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase; - for (ARegion *ar = lb->first; ar; ar = ar->next) { - wmGizmoMap *gzmap = ar->gizmo_map; - if (gzmap) { - wmGizmoGroup *gzgroup; - for (gzgroup = gzmap->groups.first; gzgroup; gzgroup = gzgroup->next) { - for (wmGizmo *gz = gzgroup->gizmos.first, *gz_next; gz; gz = gz_next) { - gz_next = gz->next; - BLI_assert(gzgroup->parent_gzmap == gzmap); - if (gz->type == gzt) { - WM_gizmo_unlink(&gzgroup->gizmos, gzgroup->parent_gzmap, gz, C); - ED_region_tag_redraw(ar); - } - } - } - } - } - } - } - } + /* Free instances. */ + for (bScreen *sc = bmain->screens.first; sc; sc = sc->id.next) { + for (ScrArea *sa = sc->areabase.first; sa; sa = sa->next) { + for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) { + ListBase *lb = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase; + for (ARegion *ar = lb->first; ar; ar = ar->next) { + wmGizmoMap *gzmap = ar->gizmo_map; + if (gzmap) { + wmGizmoGroup *gzgroup; + for (gzgroup = gzmap->groups.first; gzgroup; gzgroup = gzgroup->next) { + for (wmGizmo *gz = gzgroup->gizmos.first, *gz_next; gz; gz = gz_next) { + gz_next = gz->next; + BLI_assert(gzgroup->parent_gzmap == gzmap); + if (gz->type == gzt) { + WM_gizmo_unlink(&gzgroup->gizmos, gzgroup->parent_gzmap, gz, C); + ED_region_tag_redraw(ar); + } + } + } + } + } + } + } + } } void WM_gizmotype_remove_ptr(bContext *C, Main *bmain, wmGizmoType *gzt) { - BLI_assert(gzt == WM_gizmotype_find(gzt->idname, false)); + BLI_assert(gzt == WM_gizmotype_find(gzt->idname, false)); - BLI_ghash_remove(global_gizmotype_hash, gzt->idname, NULL, NULL); + BLI_ghash_remove(global_gizmotype_hash, gzt->idname, NULL, NULL); - gizmotype_unlink(C, bmain, gzt); + gizmotype_unlink(C, bmain, gzt); - gizmotype_free(gzt); + gizmotype_free(gzt); } bool WM_gizmotype_remove(bContext *C, Main *bmain, const char *idname) { - wmGizmoType *gzt = BLI_ghash_lookup(global_gizmotype_hash, idname); + wmGizmoType *gzt = BLI_ghash_lookup(global_gizmotype_hash, idname); - if (gzt == NULL) { - return false; - } + if (gzt == NULL) { + return false; + } - WM_gizmotype_remove_ptr(C, bmain, gzt); + WM_gizmotype_remove_ptr(C, bmain, gzt); - return true; + return true; } static void wm_gizmotype_ghash_free_cb(wmGizmoType *mt) { - gizmotype_free(mt); + gizmotype_free(mt); } void wm_gizmotype_free(void) { - BLI_ghash_free(global_gizmotype_hash, NULL, (GHashValFreeFP)wm_gizmotype_ghash_free_cb); - global_gizmotype_hash = NULL; + BLI_ghash_free(global_gizmotype_hash, NULL, (GHashValFreeFP)wm_gizmotype_ghash_free_cb); + global_gizmotype_hash = NULL; } /* called on initialize WM_init() */ void wm_gizmotype_init(void) { - /* reserve size is set based on blender default setup */ - global_gizmotype_hash = BLI_ghash_str_new_ex("wm_gizmotype_init gh", 128); + /* reserve size is set based on blender default setup */ + global_gizmotype_hash = BLI_ghash_str_new_ex("wm_gizmotype_init gh", 128); } /** \} */ |