Outliner: better support for clips/masks ('Blender File' view)
authorPhilipp Oeser <info@graphics-engineer.com>
Sat, 29 Dec 2018 17:26:04 +0000 (18:26 +0100)
committerPhilipp Oeser <info@graphics-engineer.com>
Fri, 4 Jan 2019 14:51:46 +0000 (15:51 +0100)
- clips/masks were not showing an icon [both dont have a dedicated icon,
took the ones used elsewhere]
- masks hit an assert in outliner_add_element()
- missing outliner update when adding a mask

spotted while looking into T59939

Reviewers: mont29, brecht

Differential Revision: https://developer.blender.org/D4142

source/blender/editors/mask/mask_add.c
source/blender/editors/mask/mask_intern.h
source/blender/editors/mask/mask_ops.c
source/blender/editors/space_outliner/outliner_draw.c
source/blender/editors/space_outliner/outliner_intern.h
source/blender/editors/space_outliner/space_outliner.c

index df07326c5900201cb907c3eabc6dcda29f657f1d..0cc608a56f178aaf2a590b5022c6937928fb1c1d 100644 (file)
@@ -765,7 +765,8 @@ static int create_primitive_from_points(bContext *C, wmOperator *op, const float
        location[0] -= 0.5f * scale;
        location[1] -= 0.5f * scale;
 
        location[0] -= 0.5f * scale;
        location[1] -= 0.5f * scale;
 
-       mask_layer = ED_mask_layer_ensure(C);
+       bool added_mask = false;
+       mask_layer = ED_mask_layer_ensure(C, &added_mask);
        mask = CTX_data_edit_mask(C);
 
        ED_mask_select_toggle_all(mask, SEL_DESELECT);
        mask = CTX_data_edit_mask(C);
 
        ED_mask_select_toggle_all(mask, SEL_DESELECT);
@@ -801,6 +802,9 @@ static int create_primitive_from_points(bContext *C, wmOperator *op, const float
                }
        }
 
                }
        }
 
+       if (added_mask) {
+               WM_event_add_notifier(C, NC_MASK | NA_ADDED, NULL);
+       }
        WM_event_add_notifier(C, NC_MASK | NA_EDITED, mask);
 
        /* TODO: only update this spline */
        WM_event_add_notifier(C, NC_MASK | NA_EDITED, mask);
 
        /* TODO: only update this spline */
index cb2bb95399480ba655b978e4f534d20ce17a515c..60acb430b2078810825e97bdfb03eda5c6b08fe3 100644 (file)
@@ -59,7 +59,7 @@ void MASK_OT_primitive_square_add(struct wmOperatorType *ot);
 
 /* mask_ops.c */
 struct Mask *ED_mask_new(struct bContext *C, const char *name);
 
 /* mask_ops.c */
 struct Mask *ED_mask_new(struct bContext *C, const char *name);
-struct MaskLayer *ED_mask_layer_ensure(struct bContext *C);
+struct MaskLayer *ED_mask_layer_ensure(struct bContext *C, bool *r_added_mask);
 
 void MASK_OT_new(struct wmOperatorType *ot);
 void MASK_OT_layer_new(struct wmOperatorType *ot);
 
 void MASK_OT_new(struct wmOperatorType *ot);
 void MASK_OT_layer_new(struct wmOperatorType *ot);
index cb90d0a4888cc0a1904a3da3d9945ad6132afc06..20fc403762d531319520890d6d8ea34bea1f105f 100644 (file)
@@ -340,7 +340,7 @@ Mask *ED_mask_new(bContext *C, const char *name)
 }
 
 /* Get ative layer. Will create mask/layer to be sure there's an active layer.  */
 }
 
 /* Get ative layer. Will create mask/layer to be sure there's an active layer.  */
-MaskLayer *ED_mask_layer_ensure(bContext *C)
+MaskLayer *ED_mask_layer_ensure(bContext *C, bool *r_added_mask)
 {
        Mask *mask = CTX_data_edit_mask(C);
        MaskLayer *mask_layer;
 {
        Mask *mask = CTX_data_edit_mask(C);
        MaskLayer *mask_layer;
@@ -348,6 +348,7 @@ MaskLayer *ED_mask_layer_ensure(bContext *C)
        if (mask == NULL) {
                /* If there's no active mask, create one. */
                mask = ED_mask_new(C, NULL);
        if (mask == NULL) {
                /* If there's no active mask, create one. */
                mask = ED_mask_new(C, NULL);
+               *r_added_mask = true;
        }
 
        mask_layer = BKE_mask_layer_active(mask);
        }
 
        mask_layer = BKE_mask_layer_active(mask);
@@ -367,6 +368,8 @@ static int mask_new_exec(bContext *C, wmOperator *op)
 
        ED_mask_new(C, name);
 
 
        ED_mask_new(C, name);
 
+       WM_event_add_notifier(C, NC_MASK | NA_ADDED, NULL);
+
        return OPERATOR_FINISHED;
 }
 
        return OPERATOR_FINISHED;
 }
 
index 463eb1b33b4b5dccd76125f1613f64529dcf093e..97c5c1db4cb9b9eaa788c93745550e6e334eee1a 100644 (file)
@@ -1340,6 +1340,10 @@ TreeElementIcon tree_element_get_icon(TreeStoreElem *tselem, TreeElement *te)
                                case ID_SCR:
                                case ID_WS:
                                        data.icon = ICON_WORKSPACE; break;
                                case ID_SCR:
                                case ID_WS:
                                        data.icon = ICON_WORKSPACE; break;
+                               case ID_MSK:
+                                       data.icon = ICON_MOD_MASK; break;
+                               case ID_MC:
+                                       data.icon = ICON_SEQUENCE; break;
                                default:
                                        break;
                        }
                                default:
                                        break;
                        }
index 23ea14abc316df112ed4243731cdf53b0cd82496..d6ebddf94e2628a1f28484210c071342f09db471 100644 (file)
@@ -92,7 +92,7 @@ typedef struct TreeElementIcon {
 #define TREESTORE_ID_TYPE(_id) \
        (ELEM(GS((_id)->name), ID_SCE, ID_LI, ID_OB, ID_ME, ID_CU, ID_MB, ID_NT, ID_MA, ID_TE, ID_IM, ID_LT, ID_LA, ID_CA) || \
         ELEM(GS((_id)->name), ID_KE, ID_WO, ID_SPK, ID_GR, ID_AR, ID_AC, ID_BR, ID_PA, ID_GD, ID_LS, ID_LP) || \
 #define TREESTORE_ID_TYPE(_id) \
        (ELEM(GS((_id)->name), ID_SCE, ID_LI, ID_OB, ID_ME, ID_CU, ID_MB, ID_NT, ID_MA, ID_TE, ID_IM, ID_LT, ID_LA, ID_CA) || \
         ELEM(GS((_id)->name), ID_KE, ID_WO, ID_SPK, ID_GR, ID_AR, ID_AC, ID_BR, ID_PA, ID_GD, ID_LS, ID_LP) || \
-        ELEM(GS((_id)->name), ID_SCR, ID_WM, ID_TXT, ID_VF, ID_SO, ID_CF, ID_PAL, ID_MC, ID_WS))  /* Only in 'blendfile' mode ... :/ */
+        ELEM(GS((_id)->name), ID_SCR, ID_WM, ID_TXT, ID_VF, ID_SO, ID_CF, ID_PAL, ID_MC, ID_WS, ID_MSK))  /* Only in 'blendfile' mode ... :/ */
 
 /* TreeElement->flag */
 enum {
 
 /* TreeElement->flag */
 enum {
index 95225774ddfc43ac3fc292ce743a49220ae23e7e..423641c6fdd11b73feaeeaf0eb7e0fc6f8f720b1 100644 (file)
@@ -228,6 +228,11 @@ static void outliner_main_region_listener(
                                ED_region_tag_redraw(ar);
                        }
                        break;
                                ED_region_tag_redraw(ar);
                        }
                        break;
+               case NC_MASK:
+                       if (ELEM(wmn->action, NA_ADDED)) {
+                               ED_region_tag_redraw(ar);
+                       }
+                       break;
        }
 
 }
        }
 
 }