Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2019-03-07 18:06:22 +0300
committerCampbell Barton <ideasman42@gmail.com>2019-03-07 18:39:40 +0300
commitcf38b08f5271f00ff9e0008cb338ae9fdac49dd6 (patch)
treee194ff8bcbe88557d0447553778692b3e4fd5c91 /source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c
parent605749ffaaa1dc004eb8595c2b5c3bad00f2bb34 (diff)
Fix gizmos not responding to theme color updates
Re-create gizmos when changing theme colors, since theme colors don't change often this allows gizmos to setup their colors on initialization.
Diffstat (limited to 'source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c')
-rw-r--r--source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c69
1 files changed, 59 insertions, 10 deletions
diff --git a/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c b/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c
index f2620499661..a4207704ab0 100644
--- a/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c
+++ b/source/blender/windowmanager/gizmo/intern/wm_gizmo_map.c
@@ -30,6 +30,7 @@
#include "BKE_context.h"
#include "BKE_global.h"
+#include "BKE_main.h"
#include "ED_screen.h"
#include "ED_select_utils.h"
@@ -156,17 +157,12 @@ void wm_gizmomap_select_array_remove(wmGizmoMap *gzmap, wmGizmo *gz)
*
* \{ */
-/**
- * Creates a gizmo-map with all registered gizmos for that type
- */
-wmGizmoMap *WM_gizmomap_new_from_type(
- const struct wmGizmoMapType_Params *gzmap_params)
+static wmGizmoMap *wm_gizmomap_new_from_type_ex(
+ struct wmGizmoMapType *gzmap_type,
+ wmGizmoMap *gzmap)
{
- wmGizmoMapType *gzmap_type = WM_gizmomaptype_ensure(gzmap_params);
- wmGizmoMap *gzmap;
-
- gzmap = MEM_callocN(sizeof(wmGizmoMap), "GizmoMap");
gzmap->type = gzmap_type;
+ gzmap->is_init = true;
WM_gizmomap_tag_refresh(gzmap);
/* create all gizmo-groups for this gizmo-map. We may create an empty one
@@ -178,7 +174,19 @@ wmGizmoMap *WM_gizmomap_new_from_type(
return gzmap;
}
-void wm_gizmomap_remove(wmGizmoMap *gzmap)
+/**
+ * Creates a gizmo-map with all registered gizmos for that type
+ */
+wmGizmoMap *WM_gizmomap_new_from_type(
+ const struct wmGizmoMapType_Params *gzmap_params)
+{
+ wmGizmoMapType *gzmap_type = WM_gizmomaptype_ensure(gzmap_params);
+ wmGizmoMap *gzmap = MEM_callocN(sizeof(wmGizmoMap), "GizmoMap");
+ wm_gizmomap_new_from_type_ex(gzmap_type, gzmap);
+ return gzmap;
+}
+
+static void wm_gizmomap_free_data(wmGizmoMap *gzmap)
{
/* Clear first so further calls don't waste time trying to maintain correct array state. */
wm_gizmomap_select_array_clear(gzmap);
@@ -189,10 +197,22 @@ void wm_gizmomap_remove(wmGizmoMap *gzmap)
wm_gizmogroup_free(NULL, gzgroup);
}
BLI_assert(BLI_listbase_is_empty(&gzmap->groups));
+}
+void wm_gizmomap_remove(wmGizmoMap *gzmap)
+{
+ wm_gizmomap_free_data(gzmap);
MEM_freeN(gzmap);
}
+/** Re-create the gizmos (use when changing theme settings). */
+void WM_gizmomap_reinit(wmGizmoMap *gzmap)
+{
+ wmGizmoMapType *gzmap_type = gzmap->type;
+ wm_gizmomap_free_data(gzmap);
+ memset(gzmap, 0x0, sizeof(*gzmap));
+ wm_gizmomap_new_from_type_ex(gzmap_type, gzmap);
+}
wmGizmoGroup *WM_gizmomap_group_find(
struct wmGizmoMap *gzmap,
@@ -326,6 +346,9 @@ static void gizmomap_prepare_drawing(
{
if (!gzmap || BLI_listbase_is_empty(&gzmap->groups))
return;
+
+ gzmap->is_init = false;
+
wmGizmo *gz_modal = gzmap->gzmap_context.modal;
/* only active gizmo needs updating */
@@ -1233,3 +1256,29 @@ void WM_gizmoconfig_update(struct Main *bmain)
}
/** \} */
+
+/* -------------------------------------------------------------------- */
+/** \name Recreate All Gizmos
+ *
+ * Use when adjusting themes.
+ *
+ * \{ */
+
+void WM_reinit_gizmomap_all(Main *bmain)
+{
+ for (bScreen *screen = bmain->screen.first; screen; screen = screen->id.next) {
+ for (ScrArea *sa = screen->areabase.first; sa; sa = sa->next) {
+ for (SpaceLink *sl = sa->spacedata.first; sl; sl = sl->next) {
+ ListBase *regionbase = (sl == sa->spacedata.first) ? &sa->regionbase : &sl->regionbase;
+ for (ARegion *ar = regionbase->first; ar; ar = ar->next) {
+ wmGizmoMap *gzmap = ar->gizmo_map;
+ if ((gzmap != NULL) && (gzmap->is_init == false)) {
+ WM_gizmomap_reinit(gzmap);
+ }
+ }
+ }
+ }
+ }
+}
+
+/** \} */