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
path: root/source
diff options
context:
space:
mode:
authorDan Eicher <dan@eu.phorio.us>2012-10-05 23:51:11 +0400
committerDan Eicher <dan@eu.phorio.us>2012-10-05 23:51:11 +0400
commitba470956274cc4086ee153e4f9bdda9d2ff714f5 (patch)
tree354dc117929e6fcda353a0a4219cfe449bcebecc /source
parentdb5682ac8c53377e819fd50357de580c02405fca (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')
-rw-r--r--source/blender/blenkernel/BKE_gpencil.h4
-rw-r--r--source/blender/blenkernel/intern/gpencil.c11
-rw-r--r--source/blender/editors/gpencil/gpencil_buttons.c8
-rw-r--r--source/blender/editors/gpencil/gpencil_edit.c10
-rw-r--r--source/blender/editors/gpencil/gpencil_paint.c10
-rw-r--r--source/blender/editors/gpencil/gpencil_undo.c2
-rw-r--r--source/blender/editors/space_action/space_action.c4
-rw-r--r--source/blender/editors/space_clip/space_clip.c20
-rw-r--r--source/blender/editors/space_image/space_image.c8
-rw-r--r--source/blender/editors/space_node/space_node.c7
-rw-r--r--source/blender/editors/space_sequencer/space_sequencer.c8
-rw-r--r--source/blender/editors/space_view3d/space_view3d.c9
-rw-r--r--source/blender/makesrna/intern/rna_gpencil.c92
-rw-r--r--source/blender/windowmanager/WM_types.h1
14 files changed, 120 insertions, 74 deletions
diff --git a/source/blender/blenkernel/BKE_gpencil.h b/source/blender/blenkernel/BKE_gpencil.h
index f3223fb4af1..3cb20ead39e 100644
--- a/source/blender/blenkernel/BKE_gpencil.h
+++ b/source/blender/blenkernel/BKE_gpencil.h
@@ -44,7 +44,7 @@ void free_gpencil_layers(struct ListBase *list);
void BKE_gpencil_free(struct bGPdata *gpd);
struct bGPDframe *gpencil_frame_addnew(struct bGPDlayer *gpl, int cframe);
-struct bGPDlayer *gpencil_layer_addnew(struct bGPdata *gpd);
+struct bGPDlayer *gpencil_layer_addnew(struct bGPdata *gpd, const char *name, int setactive);
struct bGPdata *gpencil_data_addnew(const char name[]);
struct bGPDframe *gpencil_frame_duplicate(struct bGPDframe *src);
@@ -62,6 +62,6 @@ struct bGPDframe *gpencil_layer_getframe(struct bGPDlayer *gpl, int cframe, shor
void gpencil_layer_delframe(struct bGPDlayer *gpl, struct bGPDframe *gpf);
struct bGPDlayer *gpencil_layer_getactive(struct bGPdata *gpd);
void gpencil_layer_setactive(struct bGPdata *gpd, struct bGPDlayer *active);
-void gpencil_layer_delactive(struct bGPdata *gpd);
+void gpencil_layer_delete(struct bGPdata *gpd, struct bGPDlayer *gpl);
#endif /* __BKE_GPENCIL_H__ */
diff --git a/source/blender/blenkernel/intern/gpencil.c b/source/blender/blenkernel/intern/gpencil.c
index 2ec5801746c..84871375788 100644
--- a/source/blender/blenkernel/intern/gpencil.c
+++ b/source/blender/blenkernel/intern/gpencil.c
@@ -163,7 +163,7 @@ bGPDframe *gpencil_frame_addnew(bGPDlayer *gpl, int cframe)
}
/* add a new gp-layer and make it the active layer */
-bGPDlayer *gpencil_layer_addnew(bGPdata *gpd)
+bGPDlayer *gpencil_layer_addnew(bGPdata *gpd, const char *name, int setactive)
{
bGPDlayer *gpl;
@@ -182,11 +182,12 @@ bGPDlayer *gpencil_layer_addnew(bGPdata *gpd)
gpl->thickness = 3;
/* auto-name */
- strcpy(gpl->info, "GP_Layer");
+ strcpy(gpl->info, name);
BLI_uniquename(&gpd->layers, gpl, "GP_Layer", '.', offsetof(bGPDlayer, info), sizeof(gpl->info));
/* make this one the active one */
- gpencil_layer_setactive(gpd, gpl);
+ if (setactive)
+ gpencil_layer_setactive(gpd, gpl);
/* return layer */
return gpl;
@@ -509,10 +510,8 @@ void gpencil_layer_setactive(bGPdata *gpd, bGPDlayer *active)
}
/* delete the active gp-layer */
-void gpencil_layer_delactive(bGPdata *gpd)
+void gpencil_layer_delete(bGPdata *gpd, bGPDlayer *gpl)
{
- bGPDlayer *gpl = gpencil_layer_getactive(gpd);
-
/* error checking */
if (ELEM(NULL, gpd, gpl))
return;
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;
}
diff --git a/source/blender/makesrna/intern/rna_gpencil.c b/source/blender/makesrna/intern/rna_gpencil.c
index 131611d3002..bf7f4984ea1 100644
--- a/source/blender/makesrna/intern/rna_gpencil.c
+++ b/source/blender/makesrna/intern/rna_gpencil.c
@@ -40,6 +40,15 @@
#ifdef RNA_RUNTIME
+#include "WM_api.h"
+
+#include "BKE_gpencil.h"
+
+static void rna_GPencil_update(Main *UNUSED(bmain), Scene *UNUSED(scene), PointerRNA *UNUSED(ptr))
+{
+ WM_main_add_notifier(NC_GPENCIL | NA_EDITED, NULL);
+}
+
static int rna_GPencilLayer_active_frame_editable(PointerRNA *ptr)
{
bGPDlayer *gpl = (bGPDlayer *)ptr->data;
@@ -53,6 +62,7 @@ static int rna_GPencilLayer_active_frame_editable(PointerRNA *ptr)
static PointerRNA rna_GPencil_active_layer_get(PointerRNA *ptr)
{
+
bGPdata *gpd = ptr->id.data;
if (GS(gpd->id.name) == ID_GD) { /* why would this ever be not GD */
@@ -101,6 +111,34 @@ static void rna_GPencilLayer_info_set(PointerRNA *ptr, const char *value)
BLI_uniquename(&gpd->layers, gpl, "GP_Layer", '.', offsetof(bGPDlayer, info), sizeof(gpl->info));
}
+static bGPDlayer *rna_GPencil_layer_new(bGPdata *gpd, const char *name, int setactive)
+{
+ bGPDlayer *gl = gpencil_layer_addnew(gpd, name, setactive);
+
+ WM_main_add_notifier(NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
+
+ return gl;
+}
+
+static void rna_GPencil_layer_remove(bGPdata *gpd, ReportList *reports, bGPDlayer *layer)
+{
+ bGPDlayer *gl;
+
+ for (gl = gpd->layers.first; gl; gl = gl->next) {
+ if (gl == layer)
+ break;
+ }
+
+ if (gl == NULL) {
+ BKE_reportf(reports, RPT_ERROR, "Layer not found in grease pencil data");
+ return;
+ }
+
+ gpencil_layer_delete(gpd, layer);
+
+ WM_main_add_notifier(NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
+}
+
#else
static void rna_def_gpencil_stroke_point(BlenderRNA *brna)
@@ -116,13 +154,13 @@ static void rna_def_gpencil_stroke_point(BlenderRNA *brna)
RNA_def_property_float_sdna(prop, NULL, "x");
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Coordinates", "");
- RNA_def_property_update(prop, NC_SCREEN | ND_GPENCIL, NULL);
+ RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
prop = RNA_def_property(srna, "pressure", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "pressure");
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "Pressure", "Pressure of tablet at point when drawing it");
- RNA_def_property_update(prop, NC_SCREEN | ND_GPENCIL, NULL);
+ RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
}
static void rna_def_gpencil_stroke(BlenderRNA *brna)
@@ -189,7 +227,8 @@ static void rna_def_gpencil_layer(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Info", "Layer name");
RNA_def_property_string_funcs(prop, NULL, NULL, "rna_GPencilLayer_info_set");
RNA_def_struct_name_property(srna, prop);
-
+ RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
+
/* Frames */
prop = RNA_def_property(srna, "frames", PROP_COLLECTION, PROP_NONE);
RNA_def_property_collection_sdna(prop, NULL, "frames", NULL);
@@ -201,32 +240,33 @@ static void rna_def_gpencil_layer(BlenderRNA *brna)
RNA_def_property_pointer_sdna(prop, NULL, "actframe");
RNA_def_property_ui_text(prop, "Active Frame", "Frame currently being displayed for this layer");
RNA_def_property_editable_func(prop, "rna_GPencilLayer_active_frame_editable");
-
+ RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
+
/* Drawing Color */
prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_array(prop, 3);
RNA_def_property_range(prop, 0.0f, 1.0f);
RNA_def_property_ui_text(prop, "Color", "Color for all strokes in this layer");
- RNA_def_property_update(prop, NC_SCREEN | ND_GPENCIL, NULL);
+ RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
prop = RNA_def_property(srna, "alpha", PROP_FLOAT, PROP_NONE);
RNA_def_property_float_sdna(prop, NULL, "color[3]");
RNA_def_property_range(prop, 0.3, 1.0f);
RNA_def_property_ui_text(prop, "Opacity", "Layer Opacity");
- RNA_def_property_update(prop, NC_SCREEN | ND_GPENCIL, NULL);
+ RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
/* Line Thickness */
prop = RNA_def_property(srna, "line_width", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "thickness");
RNA_def_property_range(prop, 1, 10);
RNA_def_property_ui_text(prop, "Thickness", "Thickness of strokes (in pixels)");
- RNA_def_property_update(prop, NC_SCREEN | ND_GPENCIL, NULL);
+ RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
/* Onion-Skinning */
prop = RNA_def_property(srna, "use_onion_skinning", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LAYER_ONIONSKIN);
RNA_def_property_ui_text(prop, "Onion Skinning", "Ghost frames on either side of frame");
- RNA_def_property_update(prop, NC_SCREEN | ND_GPENCIL, NULL);
+ RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
prop = RNA_def_property(srna, "ghost_range_max", PROP_INT, PROP_NONE);
RNA_def_property_int_sdna(prop, NULL, "gstep");
@@ -234,23 +274,23 @@ static void rna_def_gpencil_layer(BlenderRNA *brna)
RNA_def_property_ui_text(prop, "Max Ghost Range",
"Maximum number of frames on either side of the active frame to show "
"(0 = show the 'first' available sketch on either side)");
- RNA_def_property_update(prop, NC_SCREEN | ND_GPENCIL, NULL);
+ RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
/* Flags */
prop = RNA_def_property(srna, "hide", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LAYER_HIDE);
RNA_def_property_ui_text(prop, "Hide", "Set layer Visibility");
- RNA_def_property_update(prop, NC_SCREEN | ND_GPENCIL, NULL);
+ RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
prop = RNA_def_property(srna, "lock", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LAYER_LOCKED);
RNA_def_property_ui_text(prop, "Locked", "Protect layer from further editing and/or frame changes");
- RNA_def_property_update(prop, NC_SCREEN | ND_GPENCIL, NULL);
+ RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
prop = RNA_def_property(srna, "lock_frame", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LAYER_FRAMELOCK);
RNA_def_property_ui_text(prop, "Frame Locked", "Lock current frame displayed by layer");
- RNA_def_property_update(prop, NC_SCREEN | ND_GPENCIL, NULL);
+ RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
/* expose as layers.active */
#if 0
@@ -258,25 +298,25 @@ static void rna_def_gpencil_layer(BlenderRNA *brna)
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LAYER_ACTIVE);
RNA_def_property_boolean_funcs(prop, NULL, "rna_GPencilLayer_active_set");
RNA_def_property_ui_text(prop, "Active", "Set active layer for editing");
- RNA_def_property_update(prop, NC_SCREEN | ND_GPENCIL, NULL);
+ RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
#endif
prop = RNA_def_property(srna, "select", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LAYER_SELECT);
RNA_def_property_ui_text(prop, "Select", "Layer is selected for editing in the DopeSheet");
- RNA_def_property_update(prop, NC_SCREEN | ND_GPENCIL, NULL);
+ RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
/* XXX keep this option? */
prop = RNA_def_property(srna, "show_points", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_LAYER_DRAWDEBUG);
RNA_def_property_ui_text(prop, "Show Points", "Draw the points which make up the strokes (for debugging purposes)");
- RNA_def_property_update(prop, NC_SCREEN | ND_GPENCIL, NULL);
+ RNA_def_property_update_runtime(prop, "rna_GPencil_update");
/* X-Ray */
prop = RNA_def_property(srna, "show_x_ray", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", GP_LAYER_NO_XRAY);
RNA_def_property_ui_text(prop, "X Ray", "Make the layer draw in front of objects");
- RNA_def_property_update(prop, NC_SCREEN | ND_GPENCIL, NULL);
+ RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, "rna_GPencil_update");
}
static void rna_def_gpencil_layers(BlenderRNA *brna, PropertyRNA *cprop)
@@ -284,28 +324,27 @@ static void rna_def_gpencil_layers(BlenderRNA *brna, PropertyRNA *cprop)
StructRNA *srna;
PropertyRNA *prop;
-/* FunctionRNA *func; */
-/* PropertyRNA *parm; */
+ FunctionRNA *func;
+ PropertyRNA *parm;
RNA_def_property_srna(cprop, "GreasePencilLayers");
srna = RNA_def_struct(brna, "GreasePencilLayers", NULL);
RNA_def_struct_sdna(srna, "bGPdata");
RNA_def_struct_ui_text(srna, "Grease Pencil Layers", "Collection of grease pencil layers");
-#if 0
func = RNA_def_function(srna, "new", "rna_GPencil_layer_new");
- RNA_def_function_ui_description(func, "Add a new spline to the curve");
- parm = RNA_def_enum(func, "type", curve_type_items, CU_POLY, "", "type for the new spline");
+ RNA_def_function_ui_description(func, "Add a new grease pencil layer");
+ parm = RNA_def_string(func, "name", "GPencilLayer", MAX_NAME, "Name", "Name of the layer");
RNA_def_property_flag(parm, PROP_REQUIRED);
- parm = RNA_def_pointer(func, "spline", "Spline", "", "The newly created spline");
+ RNA_def_boolean(func, "set_active", 0, "Set Active", "Set the newly created layer to the active layer");
+ parm = RNA_def_pointer(func, "layer", "GPencilLayer", "", "The newly created layer");
RNA_def_function_return(func, parm);
func = RNA_def_function(srna, "remove", "rna_GPencil_layer_remove");
- RNA_def_function_ui_description(func, "Remove a spline from a curve");
+ RNA_def_function_ui_description(func, "Remove a grease pencil layer");
RNA_def_function_flag(func, FUNC_USE_REPORTS);
- parm = RNA_def_pointer(func, "spline", "Spline", "", "The spline to remove");
+ parm = RNA_def_pointer(func, "layer", "GPencilLayer", "", "The layer to remove");
RNA_def_property_flag(parm, PROP_REQUIRED | PROP_NEVER_NULL);
-#endif
prop = RNA_def_property(srna, "active", PROP_POINTER, PROP_NONE);
RNA_def_property_struct_type(prop, "GreasePencil");
@@ -344,11 +383,12 @@ static void rna_def_gpencil_data(BlenderRNA *brna)
RNA_def_property_enum_bitflag_sdna(prop, NULL, "flag");
RNA_def_property_enum_items(prop, draw_mode_items);
RNA_def_property_ui_text(prop, "Draw Mode", "");
+ RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
prop = RNA_def_property(srna, "use_stroke_endpoints", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, NULL, "flag", GP_DATA_DEPTH_STROKE_ENDPOINTS);
RNA_def_property_ui_text(prop, "Only Endpoints", "Only use the first and last parts of the stroke for snapping");
-
+ RNA_def_property_update(prop, NC_GPENCIL | ND_DATA, NULL);
}
diff --git a/source/blender/windowmanager/WM_types.h b/source/blender/windowmanager/WM_types.h
index f9b22331f37..2aa0d83f234 100644
--- a/source/blender/windowmanager/WM_types.h
+++ b/source/blender/windowmanager/WM_types.h
@@ -238,6 +238,7 @@ typedef struct wmNotifier {
#define NC_LOGIC (19<<24)
#define NC_MOVIECLIP (20<<24)
#define NC_MASK (21<<24)
+#define NC_GPENCIL (22<<24)
/* data type, 256 entries is enough, it can overlap */
#define NOTE_DATA 0x00FF0000