diff options
author | Dan Eicher <dan@eu.phorio.us> | 2012-10-05 23:51:11 +0400 |
---|---|---|
committer | Dan Eicher <dan@eu.phorio.us> | 2012-10-05 23:51:11 +0400 |
commit | ba470956274cc4086ee153e4f9bdda9d2ff714f5 (patch) | |
tree | 354dc117929e6fcda353a0a4219cfe449bcebecc /source/blender/editors | |
parent | db5682ac8c53377e819fd50357de580c02405fca (diff) |
Grease Pencil notifier/listener cleanup
As suggested by Campbell on the IRC gave grease pencil its own notifier type (NC_GPENCIL) and made the makesrna notifier functions actually update properly.
Also got the #ifdef'd GreasePencil.layers.[new/remove] functions working.
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/gpencil/gpencil_buttons.c | 8 | ||||
-rw-r--r-- | source/blender/editors/gpencil/gpencil_edit.c | 10 | ||||
-rw-r--r-- | source/blender/editors/gpencil/gpencil_paint.c | 10 | ||||
-rw-r--r-- | source/blender/editors/gpencil/gpencil_undo.c | 2 | ||||
-rw-r--r-- | source/blender/editors/space_action/space_action.c | 4 | ||||
-rw-r--r-- | source/blender/editors/space_clip/space_clip.c | 20 | ||||
-rw-r--r-- | source/blender/editors/space_image/space_image.c | 8 | ||||
-rw-r--r-- | source/blender/editors/space_node/space_node.c | 7 | ||||
-rw-r--r-- | source/blender/editors/space_sequencer/space_sequencer.c | 8 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/space_view3d.c | 9 |
10 files changed, 46 insertions, 40 deletions
diff --git a/source/blender/editors/gpencil/gpencil_buttons.c b/source/blender/editors/gpencil/gpencil_buttons.c index d90ec02b0c1..8a3c996a481 100644 --- a/source/blender/editors/gpencil/gpencil_buttons.c +++ b/source/blender/editors/gpencil/gpencil_buttons.c @@ -75,17 +75,15 @@ static void gp_ui_activelayer_cb(bContext *C, void *gpd, void *gpl) /* make sure the layer we want to remove is the active one */ gpencil_layer_setactive(gpd, gpl); - WM_event_add_notifier(C, NC_SCREEN | ND_GPENCIL | NA_EDITED, NULL); /* XXX please work! */ + WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL); } /* delete 'active' layer */ static void gp_ui_dellayer_cb(bContext *C, void *gpd, void *gpl) { - /* make sure the layer we want to remove is the active one */ - gpencil_layer_setactive(gpd, gpl); - gpencil_layer_delactive(gpd); + gpencil_layer_delete((bGPdata *)gpd, (bGPDlayer *)gpl); - WM_event_add_notifier(C, NC_SCREEN | ND_GPENCIL | NA_EDITED, NULL); /* XXX please work! */ + WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL); } diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c index 659e99607f0..46df8ba5fac 100644 --- a/source/blender/editors/gpencil/gpencil_edit.c +++ b/source/blender/editors/gpencil/gpencil_edit.c @@ -224,7 +224,7 @@ static int gp_data_add_exec(bContext *C, wmOperator *op) } /* notifiers */ - WM_event_add_notifier(C, NC_SCREEN | ND_GPENCIL | NA_EDITED, NULL); // XXX need a nicer one that will work + WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL); return OPERATOR_FINISHED; } @@ -272,7 +272,7 @@ static int gp_data_unlink_exec(bContext *C, wmOperator *op) } /* notifiers */ - WM_event_add_notifier(C, NC_SCREEN | ND_GPENCIL | NA_EDITED, NULL); // XXX need a nicer one that will work + WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL); return OPERATOR_FINISHED; } @@ -306,10 +306,10 @@ static int gp_layer_add_exec(bContext *C, wmOperator *op) *gpd_ptr = gpencil_data_addnew("GPencil"); /* add new layer now */ - gpencil_layer_addnew(*gpd_ptr); + gpencil_layer_addnew(*gpd_ptr, "GP_Layer", 1); /* notifiers */ - WM_event_add_notifier(C, NC_SCREEN | ND_GPENCIL | NA_EDITED, NULL); // XXX please work! + WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL); return OPERATOR_FINISHED; } @@ -360,7 +360,7 @@ static int gp_actframe_delete_exec(bContext *C, wmOperator *op) gpencil_layer_delframe(gpl, gpf); /* notifiers */ - WM_event_add_notifier(C, NC_SCREEN | ND_GPENCIL | NA_EDITED, NULL); // XXX please work! + WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL); return OPERATOR_FINISHED; } diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c index 0595f4e18bd..de7c2c41a6d 100644 --- a/source/blender/editors/gpencil/gpencil_paint.c +++ b/source/blender/editors/gpencil/gpencil_paint.c @@ -1143,7 +1143,7 @@ static void gp_paint_initstroke(tGPsdata *p, short paintmode) /* get active layer (or add a new one if non-existent) */ p->gpl = gpencil_layer_getactive(p->gpd); if (p->gpl == NULL) { - p->gpl = gpencil_layer_addnew(p->gpd); + p->gpl = gpencil_layer_addnew(p->gpd, "GP_Layer", 1); if (p->custom_color[3]) copy_v3_v3(p->gpl->color, p->custom_color); @@ -1616,7 +1616,7 @@ static int gpencil_draw_exec(bContext *C, wmOperator *op) gpencil_draw_exit(C, op); /* refreshes */ - WM_event_add_notifier(C, NC_SCREEN | ND_GPENCIL | NA_EDITED, NULL); // XXX need a nicer one that will work + WM_event_add_notifier(C, NC_GPENCIL | NA_EDITED, NULL); /* done */ return OPERATOR_FINISHED; @@ -1677,7 +1677,7 @@ static int gpencil_draw_invoke(bContext *C, wmOperator *op, wmEvent *event) //printf("\tGP - hotkey invoked... waiting for click-drag\n"); } - WM_event_add_notifier(C, NC_SCREEN | ND_GPENCIL, NULL); + WM_event_add_notifier(C, NC_GPENCIL | NA_EDITED, NULL); /* add a modal handler for this operator, so that we can then draw continuous strokes */ WM_event_add_modal_handler(C, op); return OPERATOR_RUNNING_MODAL; @@ -1790,7 +1790,7 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, wmEvent *event) estate = OPERATOR_RUNNING_MODAL; /* stroke could be smoothed, send notifier to refresh screen */ - WM_event_add_notifier(C, NC_SCREEN | ND_GPENCIL | NA_EDITED, NULL); + WM_event_add_notifier(C, NC_GPENCIL | NA_EDITED, NULL); } else { //printf("\t\tGP - end of stroke + op\n"); @@ -1880,7 +1880,7 @@ static int gpencil_draw_modal(bContext *C, wmOperator *op, wmEvent *event) case OPERATOR_FINISHED: /* one last flush before we're done */ gpencil_draw_exit(C, op); - WM_event_add_notifier(C, NC_SCREEN | ND_GPENCIL | NA_EDITED, NULL); // XXX need a nicer one that will work + WM_event_add_notifier(C, NC_GPENCIL | NA_EDITED, NULL); break; case OPERATOR_CANCELLED: diff --git a/source/blender/editors/gpencil/gpencil_undo.c b/source/blender/editors/gpencil/gpencil_undo.c index fa9f5196866..3d2cd260fb9 100644 --- a/source/blender/editors/gpencil/gpencil_undo.c +++ b/source/blender/editors/gpencil/gpencil_undo.c @@ -111,7 +111,7 @@ int ED_undo_gpencil_step(bContext *C, int step, const char *name) } } - WM_event_add_notifier(C, NC_SCREEN | ND_GPENCIL | NA_EDITED, NULL); + WM_event_add_notifier(C, NC_GPENCIL | NA_EDITED, NULL); return OPERATOR_FINISHED; } diff --git a/source/blender/editors/space_action/space_action.c b/source/blender/editors/space_action/space_action.c index 92b6517cbd9..2e92b1eea6f 100644 --- a/source/blender/editors/space_action/space_action.c +++ b/source/blender/editors/space_action/space_action.c @@ -357,8 +357,8 @@ static void action_listener(ScrArea *sa, wmNotifier *wmn) /* context changes */ switch (wmn->category) { - case NC_SCREEN: - if (wmn->data == ND_GPENCIL) { + case NC_GPENCIL: + if (wmn->action == NA_EDITED) { /* only handle this event in GPencil mode for performance considerations */ if (saction->mode == SACTCONT_GPENCIL) ED_area_tag_redraw(sa); diff --git a/source/blender/editors/space_clip/space_clip.c b/source/blender/editors/space_clip/space_clip.c index 3f925df30c7..ffe4762ad15 100644 --- a/source/blender/editors/space_clip/space_clip.c +++ b/source/blender/editors/space_clip/space_clip.c @@ -407,8 +407,6 @@ static void clip_listener(ScrArea *sa, wmNotifier *wmn) case NC_SCREEN: switch (wmn->data) { case ND_ANIMPLAY: - case ND_GPENCIL: - clip_scopes_check_gpencil_change(sa); ED_area_tag_redraw(sa); break; } @@ -420,6 +418,12 @@ static void clip_listener(ScrArea *sa, wmNotifier *wmn) ED_area_tag_redraw(sa); } break; + case NC_GPENCIL: + if (wmn->action == NA_EDITED) { + clip_scopes_check_gpencil_change(sa); + ED_area_tag_redraw(sa); + } + break; } } @@ -1159,8 +1163,8 @@ static void clip_main_area_listener(ARegion *ar, wmNotifier *wmn) { /* context changes */ switch (wmn->category) { - case NC_SCREEN: - if (wmn->data == ND_GPENCIL) + case NC_GPENCIL: + if (wmn->action == NA_EDITED) ED_region_tag_redraw(ar); break; } @@ -1373,8 +1377,8 @@ static void clip_props_area_listener(ARegion *ar, wmNotifier *wmn) if (wmn->data == ND_SPACE_CLIP) ED_region_tag_redraw(ar); break; - case NC_SCREEN: - if (wmn->data == ND_GPENCIL) + case NC_GPENCIL: + if (wmn->action == NA_EDITED) ED_region_tag_redraw(ar); break; } @@ -1406,8 +1410,8 @@ static void clip_properties_area_listener(ARegion *ar, wmNotifier *wmn) { /* context changes */ switch (wmn->category) { - case NC_SCREEN: - if (wmn->data == ND_GPENCIL) + case NC_GPENCIL: + if (wmn->data == ND_DATA) ED_region_tag_redraw(ar); break; case NC_BRUSH: diff --git a/source/blender/editors/space_image/space_image.c b/source/blender/editors/space_image/space_image.c index dbad6e8bb24..31cb6d91889 100644 --- a/source/blender/editors/space_image/space_image.c +++ b/source/blender/editors/space_image/space_image.c @@ -708,8 +708,8 @@ static void image_main_area_listener(ARegion *ar, wmNotifier *wmn) { /* context changes */ switch (wmn->category) { - case NC_SCREEN: - if (wmn->data == ND_GPENCIL) + case NC_GPENCIL: + if (wmn->action == NA_EDITED) ED_region_tag_redraw(ar); break; } @@ -737,8 +737,8 @@ static void image_buttons_area_listener(ARegion *ar, wmNotifier *wmn) { /* context changes */ switch (wmn->category) { - case NC_SCREEN: - if (wmn->data == ND_GPENCIL) + case NC_GPENCIL: + if (wmn->data == ND_DATA) ED_region_tag_redraw(ar); break; case NC_BRUSH: diff --git a/source/blender/editors/space_node/space_node.c b/source/blender/editors/space_node/space_node.c index 0601d7c105f..b70d66f60b4 100644 --- a/source/blender/editors/space_node/space_node.c +++ b/source/blender/editors/space_node/space_node.c @@ -440,9 +440,6 @@ static void node_region_listener(ARegion *ar, wmNotifier *wmn) break; case NC_SCREEN: switch (wmn->data) { - case ND_GPENCIL: - ED_region_tag_redraw(ar); - break; case ND_SCREENCAST: case ND_ANIMPLAY: ED_region_tag_redraw(ar); @@ -463,6 +460,10 @@ static void node_region_listener(ARegion *ar, wmNotifier *wmn) if (wmn->action == NA_RENAME) ED_region_tag_redraw(ar); break; + case NC_GPENCIL: + if (wmn->action == NA_EDITED) + ED_region_tag_redraw(ar); + break; } } diff --git a/source/blender/editors/space_sequencer/space_sequencer.c b/source/blender/editors/space_sequencer/space_sequencer.c index 21c70a5b4a9..7bfe58cb50a 100644 --- a/source/blender/editors/space_sequencer/space_sequencer.c +++ b/source/blender/editors/space_sequencer/space_sequencer.c @@ -556,8 +556,8 @@ static void sequencer_preview_area_listener(ARegion *ar, wmNotifier *wmn) { /* context changes */ switch (wmn->category) { - case NC_SCREEN: - if (wmn->data == ND_GPENCIL) { + case NC_GPENCIL: + if (wmn->action == NA_EDITED) { ED_region_tag_redraw(ar); } break; @@ -610,8 +610,8 @@ static void sequencer_buttons_area_listener(ARegion *ar, wmNotifier *wmn) { /* context changes */ switch (wmn->category) { - case NC_SCREEN: - if (wmn->data == ND_GPENCIL) { + case NC_GPENCIL: + if (wmn->data == ND_DATA) { ED_region_tag_redraw(ar); } break; diff --git a/source/blender/editors/space_view3d/space_view3d.c b/source/blender/editors/space_view3d/space_view3d.c index 1e371cb074d..236cbb86724 100644 --- a/source/blender/editors/space_view3d/space_view3d.c +++ b/source/blender/editors/space_view3d/space_view3d.c @@ -776,7 +776,6 @@ static void view3d_main_area_listener(ARegion *ar, wmNotifier *wmn) break; case NC_SCREEN: switch (wmn->data) { - case ND_GPENCIL: case ND_ANIMPLAY: case ND_SKETCH: ED_region_tag_redraw(ar); @@ -793,6 +792,10 @@ static void view3d_main_area_listener(ARegion *ar, wmNotifier *wmn) } break; + case NC_GPENCIL: + if (wmn->action == NA_EDITED) + ED_region_tag_redraw(ar); + break; } } @@ -941,8 +944,8 @@ static void view3d_buttons_area_listener(ARegion *ar, wmNotifier *wmn) if (wmn->action == NA_RENAME) ED_region_tag_redraw(ar); break; - case NC_SCREEN: - if (wmn->data == ND_GPENCIL) + case NC_GPENCIL: + if (wmn->data == ND_DATA) ED_region_tag_redraw(ar); break; } |