GPencil: Viewport visbility and editability toggles for layers in Outliner
authorJoshua Leung <aligorith@gmail.com>
Sun, 8 Feb 2015 23:34:17 +0000 (12:34 +1300)
committerJoshua Leung <aligorith@gmail.com>
Sun, 8 Feb 2015 23:47:59 +0000 (12:47 +1300)
* Viewport visibility and locking are currently exposed
* Later on, visibility in renders can also be included

source/blender/editors/space_outliner/outliner_draw.c
source/blender/editors/space_outliner/space_outliner.c

index 97d6a883fa375252f23d117b947b5de251429d62..77e0e46f3e21d7a8668a67af1d4d7dbf20e7b330 100644 (file)
@@ -347,6 +347,11 @@ static void restrictbutton_ebone_visibility_cb(bContext *C, void *UNUSED(poin),
        WM_event_add_notifier(C, NC_OBJECT | ND_POSE, NULL);
 }
 
+static void restrictbutton_gp_layer_flag_cb(bContext *C, void *UNUSED(poin), void *UNUSED(poin2))
+{
+       WM_event_add_notifier(C, NC_GPENCIL | ND_DATA, NULL);
+}
+
 static int group_restrict_flag(Group *gr, int flag)
 {
        GroupObject *gob;
@@ -752,6 +757,29 @@ static void outliner_draw_restrictbuts(uiBlock *block, Scene *scene, ARegion *ar
                                UI_but_func_set(bt, restrictbutton_ebone_select_cb, NULL, ebone);
                                UI_but_flag_enable(bt, UI_BUT_DRAG_LOCK);
 
+                               UI_block_emboss_set(block, UI_EMBOSS);
+                       }
+                       else if (tselem->type == TSE_GP_LAYER) {
+                               bGPDlayer *gpl = (bGPDlayer *)te->directdata;
+                               
+                               UI_block_emboss_set(block, UI_EMBOSS_NONE);
+                               
+                               bt = uiDefIconButBitS(block, UI_BTYPE_ICON_TOGGLE, GP_LAYER_HIDE, 0, ICON_RESTRICT_VIEW_OFF,
+                                                     (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_VIEWX), te->ys, UI_UNIT_X,
+                                                     UI_UNIT_Y, &gpl->flag, 0, 0, 0, 0,
+                                                     TIP_("Restrict/Allow visibility in the 3D View"));
+                               UI_but_func_set(bt, restrictbutton_gp_layer_flag_cb, NULL, gpl);
+                               UI_but_flag_enable(bt, UI_BUT_DRAG_LOCK);
+                               
+                               bt = uiDefIconButBitS(block, UI_BTYPE_ICON_TOGGLE, GP_LAYER_LOCKED, 0, ICON_UNLOCKED,
+                                                     (int)(ar->v2d.cur.xmax - OL_TOG_RESTRICT_SELECTX), te->ys, UI_UNIT_X,
+                                                     UI_UNIT_Y, &gpl->flag, 0, 0, 0, 0,
+                                                     TIP_("Restrict/Allow editing of strokes and keyframes in this layer"));
+                               UI_but_func_set(bt, restrictbutton_gp_layer_flag_cb, NULL, gpl);
+                               UI_but_flag_enable(bt, UI_BUT_DRAG_LOCK);
+                               
+                               /* TODO: visibility in renders */
+                               
                                UI_block_emboss_set(block, UI_EMBOSS);
                        }
                }
index df5a1c8d8c6261a19f563fb458c2296ab316791c..30de9c16500e3a081af949f1f423bd3826257ae0 100644 (file)
@@ -387,6 +387,13 @@ static void outliner_main_area_listener(bScreen *UNUSED(sc), ScrArea *UNUSED(sa)
                                        break;
                        }
                        break;
+               case NC_GPENCIL:
+                       switch (wmn->data) {
+                               case ND_DATA:
+                                       ED_region_tag_redraw(ar);
+                                       break;
+                       }
+                       break;
        }
        
 }