Annotations: Split annotation operators and pointer functions
This allows to have annotation panels and grease pencil object panel at the same time. Differential Revision: https://developer.blender.org/D6467
This commit is contained in:
@@ -581,9 +581,9 @@ class AnnotationDataPanel:
|
||||
def poll(cls, context):
|
||||
# Show this panel as long as someone that might own this exists
|
||||
# AND the owner isn't an object (e.g. GP Object)
|
||||
if context.gpencil_data_owner is None:
|
||||
if context.annotation_data_owner is None:
|
||||
return False
|
||||
elif type(context.gpencil_data_owner) is bpy.types.Object:
|
||||
elif type(context.annotation_data_owner) is bpy.types.Object:
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
@@ -597,14 +597,14 @@ class AnnotationDataPanel:
|
||||
layout.use_property_decorate = False
|
||||
|
||||
# Grease Pencil owner.
|
||||
gpd_owner = context.gpencil_data_owner
|
||||
gpd = context.gpencil_data
|
||||
gpd_owner = context.annotation_data_owner
|
||||
gpd = context.annotation_data
|
||||
|
||||
# Owner selector.
|
||||
if context.space_data.type == 'CLIP_EDITOR':
|
||||
layout.row().prop(context.space_data, "grease_pencil_source", expand=True)
|
||||
|
||||
layout.template_ID(gpd_owner, "grease_pencil", new="gpencil.data_add", unlink="gpencil.data_unlink")
|
||||
layout.template_ID(gpd_owner, "grease_pencil", new="gpencil.annotation_add", unlink="gpencil.data_unlink")
|
||||
|
||||
# List of layers/notes.
|
||||
if gpd and gpd.layers:
|
||||
@@ -624,17 +624,17 @@ class AnnotationDataPanel:
|
||||
col = row.column()
|
||||
|
||||
sub = col.column(align=True)
|
||||
sub.operator("gpencil.layer_add", icon='ADD', text="")
|
||||
sub.operator("gpencil.layer_remove", icon='REMOVE', text="")
|
||||
sub.operator("gpencil.layer_annotation_add", icon='ADD', text="")
|
||||
sub.operator("gpencil.layer_annotation_remove", icon='REMOVE', text="")
|
||||
|
||||
gpl = context.active_gpencil_layer
|
||||
gpl = context.active_annotation_layer
|
||||
if gpl:
|
||||
if len(gpd.layers) > 1:
|
||||
col.separator()
|
||||
|
||||
sub = col.column(align=True)
|
||||
sub.operator("gpencil.layer_move", icon='TRIA_UP', text="").type = 'UP'
|
||||
sub.operator("gpencil.layer_move", icon='TRIA_DOWN', text="").type = 'DOWN'
|
||||
sub.operator("gpencil.layer_annotation_move", icon='TRIA_UP', text="").type = 'UP'
|
||||
sub.operator("gpencil.layer_annotation_move", icon='TRIA_DOWN', text="").type = 'DOWN'
|
||||
|
||||
tool_settings = context.tool_settings
|
||||
if gpd and gpl:
|
||||
@@ -653,7 +653,7 @@ class AnnotationDataPanel:
|
||||
else:
|
||||
lock_label = iface_("Lock Frame")
|
||||
row.prop(gpl, "lock_frame", text=lock_label, icon='UNLOCKED')
|
||||
row.operator("gpencil.active_frame_delete", text="", icon='X')
|
||||
row.operator("gpencil.annotation_active_frame_delete", text="", icon='X')
|
||||
|
||||
|
||||
class AnnotationOnionSkin:
|
||||
@@ -665,26 +665,26 @@ class AnnotationOnionSkin:
|
||||
def poll(cls, context):
|
||||
# Show this panel as long as someone that might own this exists
|
||||
# AND the owner isn't an object (e.g. GP Object)
|
||||
if context.gpencil_data_owner is None:
|
||||
if context.annotation_data_owner is None:
|
||||
return False
|
||||
elif type(context.gpencil_data_owner) is bpy.types.Object:
|
||||
elif type(context.annotation_data_owner) is bpy.types.Object:
|
||||
return False
|
||||
else:
|
||||
gpl = context.active_gpencil_layer
|
||||
gpl = context.active_annotation_layer
|
||||
if gpl is None:
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
def draw_header(self, context):
|
||||
gpl = context.active_gpencil_layer
|
||||
gpl = context.active_annotation_layer
|
||||
self.layout.prop(gpl, "use_annotation_onion_skinning", text="")
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
layout.use_property_decorate = False
|
||||
|
||||
gpl = context.active_gpencil_layer
|
||||
gpl = context.active_annotation_layer
|
||||
col = layout.column()
|
||||
split = col.split(factor=0.5)
|
||||
split.active = gpl.use_annotation_onion_skinning
|
||||
|
||||
@@ -2115,6 +2115,8 @@ class VIEW3D_PT_tools_active(ToolSelectPanelHelper, Panel):
|
||||
_defs_gpencil_paint.curve,
|
||||
_defs_gpencil_paint.box,
|
||||
_defs_gpencil_paint.circle,
|
||||
None,
|
||||
*_tools_annotate,
|
||||
],
|
||||
'EDIT_GPENCIL': [
|
||||
*_tools_gpencil_select,
|
||||
@@ -2129,11 +2131,13 @@ class VIEW3D_PT_tools_active(ToolSelectPanelHelper, Panel):
|
||||
_defs_gpencil_edit.shear,
|
||||
_defs_gpencil_edit.tosphere,
|
||||
),
|
||||
|
||||
None,
|
||||
*_tools_annotate,
|
||||
],
|
||||
'SCULPT_GPENCIL': [
|
||||
_defs_gpencil_sculpt.generate_from_brushes,
|
||||
None,
|
||||
*_tools_annotate,
|
||||
lambda context: (
|
||||
VIEW3D_PT_tools_active._tools_gpencil_select
|
||||
if _defs_gpencil_sculpt.poll_select_mask(context)
|
||||
@@ -2142,6 +2146,8 @@ class VIEW3D_PT_tools_active(ToolSelectPanelHelper, Panel):
|
||||
],
|
||||
'WEIGHT_GPENCIL': [
|
||||
_defs_gpencil_weight.generate_from_brushes,
|
||||
None,
|
||||
*_tools_annotate,
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
@@ -1056,7 +1056,7 @@ void ED_annotation_draw_2dimage(const bContext *C)
|
||||
int offsx, offsy, sizex, sizey;
|
||||
int dflag = GP_DRAWDATA_NOSTATUS;
|
||||
|
||||
bGPdata *gpd = ED_gpencil_data_get_active(C); // XXX
|
||||
bGPdata *gpd = ED_annotation_data_get_active(C);
|
||||
if (gpd == NULL) {
|
||||
return;
|
||||
}
|
||||
@@ -1132,7 +1132,7 @@ void ED_annotation_draw_view2d(const bContext *C, bool onlyv2d)
|
||||
if (sa == NULL) {
|
||||
return;
|
||||
}
|
||||
bGPdata *gpd = ED_gpencil_data_get_active(C); // XXX
|
||||
bGPdata *gpd = ED_annotation_data_get_active(C);
|
||||
if (gpd == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -218,19 +218,9 @@ static void gp_session_validatebuffer(tGPsdata *p);
|
||||
/* check if context is suitable for drawing */
|
||||
static bool gpencil_draw_poll(bContext *C)
|
||||
{
|
||||
/* if is inside grease pencil draw mode cannot use annotations */
|
||||
Object *obact = CTX_data_active_object(C);
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
if ((sa) && (sa->spacetype == SPACE_VIEW3D)) {
|
||||
if ((obact) && (obact->type == OB_GPENCIL) && (obact->mode == OB_MODE_PAINT_GPENCIL)) {
|
||||
CTX_wm_operator_poll_msg_set(C, "Annotation cannot be used in grease pencil draw mode");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (ED_operator_regionactive(C)) {
|
||||
/* check if current context can support GPencil data */
|
||||
if (ED_gpencil_data_get_pointers(C, NULL) != NULL) {
|
||||
if (ED_annotation_data_get_pointers(C, NULL) != NULL) {
|
||||
/* check if Grease Pencil isn't already running */
|
||||
if (ED_gpencil_session_active() == 0) {
|
||||
return true;
|
||||
@@ -240,7 +230,7 @@ static bool gpencil_draw_poll(bContext *C)
|
||||
}
|
||||
}
|
||||
else {
|
||||
CTX_wm_operator_poll_msg_set(C, "Failed to find Grease Pencil data to draw into");
|
||||
CTX_wm_operator_poll_msg_set(C, "Failed to find Annotation data to draw into");
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -1115,7 +1105,7 @@ static bool gp_session_initdata(bContext *C, tGPsdata *p)
|
||||
}
|
||||
|
||||
/* get gp-data */
|
||||
gpd_ptr = ED_gpencil_data_get_pointers(C, &p->ownerPtr);
|
||||
gpd_ptr = ED_annotation_data_get_pointers(C, &p->ownerPtr);
|
||||
if ((gpd_ptr == NULL) || !ED_gpencil_data_owner_is_annotation(&p->ownerPtr)) {
|
||||
p->status = GP_STATUS_ERROR;
|
||||
if (G.debug & G_DEBUG) {
|
||||
@@ -1886,9 +1876,6 @@ static int gpencil_draw_exec(bContext *C, wmOperator *op)
|
||||
/* start of interactive drawing part of operator */
|
||||
static int gpencil_draw_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
||||
{
|
||||
Object *ob = CTX_data_active_object(C);
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
tGPsdata *p = NULL;
|
||||
|
||||
/* support for tablets eraser pen */
|
||||
@@ -1896,26 +1883,6 @@ static int gpencil_draw_invoke(bContext *C, wmOperator *op, const wmEvent *event
|
||||
RNA_enum_set(op->ptr, "mode", GP_PAINTMODE_ERASER);
|
||||
}
|
||||
|
||||
/* if try to do annotations with a gp object selected, first
|
||||
* unselect the object to avoid conflicts.
|
||||
* The solution is not perfect but we can keep running the annotations while
|
||||
* found a better solution.
|
||||
*/
|
||||
if (sa && sa->spacetype == SPACE_VIEW3D) {
|
||||
if ((ob != NULL) && (ob->type == OB_GPENCIL)) {
|
||||
ob->mode = OB_MODE_OBJECT;
|
||||
bGPdata *gpd = (bGPdata *)ob->data;
|
||||
ED_gpencil_setup_modes(C, gpd, 0);
|
||||
DEG_id_tag_update(&gpd->id, ID_RECALC_COPY_ON_WRITE);
|
||||
|
||||
ViewLayer *view_layer = CTX_data_view_layer(C);
|
||||
BKE_view_layer_base_deselect_all(view_layer);
|
||||
view_layer->basact = NULL;
|
||||
DEG_id_tag_update(&scene->id, ID_RECALC_SELECT);
|
||||
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
|
||||
}
|
||||
}
|
||||
|
||||
if (G.debug & G_DEBUG) {
|
||||
printf("GPencil - Starting Drawing\n");
|
||||
}
|
||||
|
||||
@@ -91,77 +91,56 @@
|
||||
/* ******************* Add New Data ************************ */
|
||||
static bool gp_data_add_poll(bContext *C)
|
||||
{
|
||||
Object *obact = CTX_data_active_object(C);
|
||||
if (obact && obact->type == OB_GPENCIL) {
|
||||
if (obact->mode != OB_MODE_OBJECT) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/* the base line we have is that we have somewhere to add Grease Pencil data */
|
||||
return ED_gpencil_data_get_pointers(C, NULL) != NULL;
|
||||
return ED_annotation_data_get_pointers(C, NULL) != NULL;
|
||||
}
|
||||
|
||||
/* add new datablock - wrapper around API */
|
||||
static int gp_data_add_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
PointerRNA gpd_owner = {NULL};
|
||||
bGPdata **gpd_ptr = ED_gpencil_data_get_pointers(C, &gpd_owner);
|
||||
bool is_annotation = ED_gpencil_data_owner_is_annotation(&gpd_owner);
|
||||
bGPdata **gpd_ptr = ED_annotation_data_get_pointers(C, &gpd_owner);
|
||||
|
||||
if (gpd_ptr == NULL) {
|
||||
BKE_report(op->reports, RPT_ERROR, "Nowhere for grease pencil data to go");
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
else {
|
||||
/* decrement user count and add new datablock */
|
||||
/* TODO: if a datablock exists,
|
||||
* we should make a copy of it instead of starting fresh (as in other areas) */
|
||||
Main *bmain = CTX_data_main(C);
|
||||
|
||||
/* decrement user count of old GP datablock */
|
||||
if (*gpd_ptr) {
|
||||
bGPdata *gpd = (*gpd_ptr);
|
||||
id_us_min(&gpd->id);
|
||||
}
|
||||
/* decrement user count and add new datablock */
|
||||
/* TODO: if a datablock exists,
|
||||
* we should make a copy of it instead of starting fresh (as in other areas) */
|
||||
Main *bmain = CTX_data_main(C);
|
||||
|
||||
/* Add new datablock, with a single layer ready to use
|
||||
* (so users don't have to perform an extra step). */
|
||||
if (is_annotation) {
|
||||
bGPdata *gpd = BKE_gpencil_data_addnew(bmain, DATA_("Annotations"));
|
||||
*gpd_ptr = gpd;
|
||||
|
||||
/* tag for annotations */
|
||||
gpd->flag |= GP_DATA_ANNOTATIONS;
|
||||
|
||||
/* add new layer (i.e. a "note") */
|
||||
BKE_gpencil_layer_addnew(*gpd_ptr, DATA_("Note"), true);
|
||||
}
|
||||
else {
|
||||
/* GP Object Case - This shouldn't happen! */
|
||||
*gpd_ptr = BKE_gpencil_data_addnew(bmain, DATA_("GPencil"));
|
||||
|
||||
/* add default sets of colors and brushes */
|
||||
Object *ob = CTX_data_active_object(C);
|
||||
ED_gpencil_add_defaults(C, ob);
|
||||
|
||||
/* add new layer */
|
||||
BKE_gpencil_layer_addnew(*gpd_ptr, DATA_("GP_Layer"), true);
|
||||
}
|
||||
/* decrement user count of old GP datablock */
|
||||
if (*gpd_ptr) {
|
||||
bGPdata *gpd = (*gpd_ptr);
|
||||
id_us_min(&gpd->id);
|
||||
}
|
||||
|
||||
/* Add new datablock, with a single layer ready to use
|
||||
* (so users don't have to perform an extra step). */
|
||||
bGPdata *gpd = BKE_gpencil_data_addnew(bmain, DATA_("Annotations"));
|
||||
*gpd_ptr = gpd;
|
||||
|
||||
/* tag for annotations */
|
||||
gpd->flag |= GP_DATA_ANNOTATIONS;
|
||||
|
||||
/* add new layer (i.e. a "note") */
|
||||
BKE_gpencil_layer_addnew(*gpd_ptr, DATA_("Note"), true);
|
||||
|
||||
/* notifiers */
|
||||
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
}
|
||||
|
||||
void GPENCIL_OT_data_add(wmOperatorType *ot)
|
||||
void GPENCIL_OT_annotation_add(wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name = "Grease Pencil Add New";
|
||||
ot->idname = "GPENCIL_OT_data_add";
|
||||
ot->description = "Add new Grease Pencil data-block";
|
||||
ot->name = "Annotation Add New";
|
||||
ot->idname = "GPENCIL_OT_annotation_add";
|
||||
ot->description = "Add new Annotation data-block";
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
/* callbacks */
|
||||
@@ -174,7 +153,7 @@ void GPENCIL_OT_data_add(wmOperatorType *ot)
|
||||
/* poll callback for adding data/layers - special */
|
||||
static bool gp_data_unlink_poll(bContext *C)
|
||||
{
|
||||
bGPdata **gpd_ptr = ED_gpencil_data_get_pointers(C, NULL);
|
||||
bGPdata **gpd_ptr = ED_annotation_data_get_pointers(C, NULL);
|
||||
|
||||
/* only unlink annotation datablocks */
|
||||
if ((gpd_ptr != NULL) && (*gpd_ptr != NULL)) {
|
||||
@@ -190,7 +169,7 @@ static bool gp_data_unlink_poll(bContext *C)
|
||||
/* unlink datablock - wrapper around API */
|
||||
static int gp_data_unlink_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
bGPdata **gpd_ptr = ED_gpencil_data_get_pointers(C, NULL);
|
||||
bGPdata **gpd_ptr = ED_annotation_data_get_pointers(C, NULL);
|
||||
|
||||
if (gpd_ptr == NULL) {
|
||||
BKE_report(op->reports, RPT_ERROR, "Nowhere for grease pencil data to go");
|
||||
@@ -231,47 +210,43 @@ void GPENCIL_OT_data_unlink(wmOperatorType *ot)
|
||||
/* add new layer - wrapper around API */
|
||||
static int gp_layer_add_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
const bool is_annotation = STREQ(op->idname, "GPENCIL_OT_layer_annotation_add");
|
||||
|
||||
PointerRNA gpd_owner = {NULL};
|
||||
bGPdata **gpd_ptr = ED_gpencil_data_get_pointers(C, &gpd_owner);
|
||||
bool is_annotation = ED_gpencil_data_owner_is_annotation(&gpd_owner);
|
||||
Main *bmain = CTX_data_main(C);
|
||||
bGPdata *gpd = NULL;
|
||||
|
||||
/* if there's no existing Grease-Pencil data there, add some */
|
||||
if (gpd_ptr == NULL) {
|
||||
BKE_report(op->reports, RPT_ERROR, "Nowhere for grease pencil data to go");
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
|
||||
if (*gpd_ptr == NULL) {
|
||||
Main *bmain = CTX_data_main(C);
|
||||
if (is_annotation) {
|
||||
/* Annotations */
|
||||
*gpd_ptr = BKE_gpencil_data_addnew(bmain, DATA_("Annotations"));
|
||||
|
||||
/* mark as annotation */
|
||||
(*gpd_ptr)->flag |= GP_DATA_ANNOTATIONS;
|
||||
}
|
||||
else {
|
||||
/* GP Object */
|
||||
/* NOTE: This shouldn't actually happen in practice */
|
||||
*gpd_ptr = BKE_gpencil_data_addnew(bmain, DATA_("GPencil"));
|
||||
|
||||
/* add default sets of colors and brushes */
|
||||
Object *ob = CTX_data_active_object(C);
|
||||
ED_gpencil_add_defaults(C, ob);
|
||||
}
|
||||
}
|
||||
|
||||
/* add new layer now */
|
||||
if (is_annotation) {
|
||||
bGPdata **gpd_ptr = ED_annotation_data_get_pointers(C, &gpd_owner);
|
||||
/* if there's no existing Grease-Pencil data there, add some */
|
||||
if (gpd_ptr == NULL) {
|
||||
BKE_report(op->reports, RPT_ERROR, "Nowhere for grease pencil data to go");
|
||||
return OPERATOR_CANCELLED;
|
||||
}
|
||||
/* Annotations */
|
||||
if (*gpd_ptr == NULL) {
|
||||
*gpd_ptr = BKE_gpencil_data_addnew(bmain, DATA_("Annotations"));
|
||||
}
|
||||
|
||||
/* mark as annotation */
|
||||
(*gpd_ptr)->flag |= GP_DATA_ANNOTATIONS;
|
||||
BKE_gpencil_layer_addnew(*gpd_ptr, DATA_("Note"), true);
|
||||
gpd = *gpd_ptr;
|
||||
}
|
||||
else {
|
||||
BKE_gpencil_layer_addnew(*gpd_ptr, DATA_("GP_Layer"), true);
|
||||
/* GP Object */
|
||||
Object *ob = CTX_data_active_object(C);
|
||||
if ((ob != NULL) && (ob->type == OB_GPENCIL)) {
|
||||
gpd = (bGPdata *)ob->data;
|
||||
BKE_gpencil_layer_addnew(gpd, DATA_("GP_Layer"), true);
|
||||
}
|
||||
}
|
||||
|
||||
/* notifiers */
|
||||
bGPdata *gpd = *gpd_ptr;
|
||||
DEG_id_tag_update(&gpd->id, ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_COPY_ON_WRITE);
|
||||
if (gpd) {
|
||||
DEG_id_tag_update(&gpd->id,
|
||||
ID_RECALC_TRANSFORM | ID_RECALC_GEOMETRY | ID_RECALC_COPY_ON_WRITE);
|
||||
}
|
||||
WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
|
||||
|
||||
return OPERATOR_FINISHED;
|
||||
@@ -291,11 +266,32 @@ void GPENCIL_OT_layer_add(wmOperatorType *ot)
|
||||
ot->poll = gp_add_poll;
|
||||
}
|
||||
|
||||
static bool gp_add_annotation_poll(bContext *C)
|
||||
{
|
||||
return ED_annotation_data_get_pointers(C, NULL) != NULL;
|
||||
}
|
||||
|
||||
void GPENCIL_OT_layer_annotation_add(wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name = "Add New Annotation Layer";
|
||||
ot->idname = "GPENCIL_OT_layer_annotation_add";
|
||||
ot->description = "Add new Annotation layer or note for the active data-block";
|
||||
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
/* callbacks */
|
||||
ot->exec = gp_layer_add_exec;
|
||||
ot->poll = gp_add_annotation_poll;
|
||||
}
|
||||
/* ******************* Remove Active Layer ************************* */
|
||||
|
||||
static int gp_layer_remove_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
bGPdata *gpd = ED_gpencil_data_get_active(C);
|
||||
const bool is_annotation = STREQ(op->idname, "GPENCIL_OT_layer_annotation_remove");
|
||||
|
||||
bGPdata *gpd = (!is_annotation) ? ED_gpencil_data_get_active(C) :
|
||||
ED_annotation_data_get_active(C);
|
||||
bGPDlayer *gpl = BKE_gpencil_layer_getactive(gpd);
|
||||
|
||||
/* sanity checks */
|
||||
@@ -343,6 +339,27 @@ void GPENCIL_OT_layer_remove(wmOperatorType *ot)
|
||||
ot->poll = gp_active_layer_poll;
|
||||
}
|
||||
|
||||
static bool gp_active_layer_annotation_poll(bContext *C)
|
||||
{
|
||||
bGPdata *gpd = ED_annotation_data_get_active(C);
|
||||
bGPDlayer *gpl = BKE_gpencil_layer_getactive(gpd);
|
||||
|
||||
return (gpl != NULL);
|
||||
}
|
||||
|
||||
void GPENCIL_OT_layer_annotation_remove(wmOperatorType *ot)
|
||||
{
|
||||
/* identifiers */
|
||||
ot->name = "Remove Annotation Layer";
|
||||
ot->idname = "GPENCIL_OT_layer_annotation_remove";
|
||||
ot->description = "Remove active Annotation layer";
|
||||
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
/* callbacks */
|
||||
ot->exec = gp_layer_remove_exec;
|
||||
ot->poll = gp_active_layer_annotation_poll;
|
||||
}
|
||||
/* ******************* Move Layer Up/Down ************************** */
|
||||
|
||||
enum {
|
||||
@@ -352,7 +369,10 @@ enum {
|
||||
|
||||
static int gp_layer_move_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
bGPdata *gpd = ED_gpencil_data_get_active(C);
|
||||
const bool is_annotation = STREQ(op->idname, "GPENCIL_OT_layer_annotation_move");
|
||||
|
||||
bGPdata *gpd = (!is_annotation) ? ED_gpencil_data_get_active(C) :
|
||||
ED_annotation_data_get_active(C);
|
||||
bGPDlayer *gpl = BKE_gpencil_layer_getactive(gpd);
|
||||
|
||||
const int direction = RNA_enum_get(op->ptr, "type") * -1;
|
||||
@@ -394,6 +414,28 @@ void GPENCIL_OT_layer_move(wmOperatorType *ot)
|
||||
ot->prop = RNA_def_enum(ot->srna, "type", slot_move, 0, "Type", "");
|
||||
}
|
||||
|
||||
void GPENCIL_OT_layer_annotation_move(wmOperatorType *ot)
|
||||
{
|
||||
static const EnumPropertyItem slot_move[] = {
|
||||
{GP_LAYER_MOVE_UP, "UP", 0, "Up", ""},
|
||||
{GP_LAYER_MOVE_DOWN, "DOWN", 0, "Down", ""},
|
||||
{0, NULL, 0, NULL, NULL},
|
||||
};
|
||||
|
||||
/* identifiers */
|
||||
ot->name = "Move Annotation Layer";
|
||||
ot->idname = "GPENCIL_OT_layer_annotation_move";
|
||||
ot->description = "Move the active Annotation layer up/down in the list";
|
||||
|
||||
/* api callbacks */
|
||||
ot->exec = gp_layer_move_exec;
|
||||
ot->poll = gp_active_layer_annotation_poll;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
ot->prop = RNA_def_enum(ot->srna, "type", slot_move, 0, "Type", "");
|
||||
}
|
||||
/* ********************* Duplicate Layer ************************** */
|
||||
|
||||
static int gp_layer_copy_exec(bContext *C, wmOperator *UNUSED(op))
|
||||
@@ -995,7 +1037,7 @@ void GPENCIL_OT_lock_all(wmOperatorType *ot)
|
||||
|
||||
/* callbacks */
|
||||
ot->exec = gp_lock_all_exec;
|
||||
ot->poll = gp_reveal_poll; /* XXX: could use dedicated poll later */
|
||||
ot->poll = gp_reveal_poll;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
@@ -1034,7 +1076,7 @@ void GPENCIL_OT_unlock_all(wmOperatorType *ot)
|
||||
|
||||
/* callbacks */
|
||||
ot->exec = gp_unlock_all_exec;
|
||||
ot->poll = gp_reveal_poll; /* XXX: could use dedicated poll later */
|
||||
ot->poll = gp_reveal_poll;
|
||||
|
||||
/* flags */
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
@@ -2176,22 +2218,22 @@ static void joined_gpencil_fix_animdata_cb(ID *id, FCurve *fcu, void *user_data)
|
||||
if (fcu->driver) {
|
||||
/* Fix driver references to invalid ID's */
|
||||
for (DriverVar *dvar = fcu->driver->variables.first; dvar; dvar = dvar->next) {
|
||||
/* only change the used targets, since the others will need fixing manually anyway */
|
||||
/* Only change the used targets, since the others will need fixing manually anyway. */
|
||||
DRIVER_TARGETS_USED_LOOPER_BEGIN (dvar) {
|
||||
/* change the ID's used... */
|
||||
/* Change the ID's used. */
|
||||
if (dtar->id == src_id) {
|
||||
dtar->id = dst_id;
|
||||
|
||||
/* also check on the subtarget...
|
||||
* XXX: We duplicate the logic from drivers_path_rename_fix() here, with our own
|
||||
* little twists so that we know that it isn't going to clobber the wrong data
|
||||
/* Also check on the subtarget...
|
||||
* We duplicate the logic from drivers_path_rename_fix() here, with our own
|
||||
* little twists so that we know that it isn't going to clobber the wrong data
|
||||
*/
|
||||
if (dtar->rna_path && strstr(dtar->rna_path, "layers[")) {
|
||||
GHASH_ITER (gh_iter, afd->names_map) {
|
||||
const char *old_name = BLI_ghashIterator_getKey(&gh_iter);
|
||||
const char *new_name = BLI_ghashIterator_getValue(&gh_iter);
|
||||
|
||||
/* only remap if changed */
|
||||
/* Only remap if changed. */
|
||||
if (!STREQ(old_name, new_name)) {
|
||||
if ((dtar->rna_path) && strstr(dtar->rna_path, old_name)) {
|
||||
/* Fix up path */
|
||||
@@ -2230,7 +2272,6 @@ int ED_gpencil_join_objects_exec(bContext *C, wmOperator *op)
|
||||
}
|
||||
|
||||
/* Ensure all rotations are applied before */
|
||||
// XXX: Why don't we apply them here instead of warning?
|
||||
CTX_DATA_BEGIN (C, Object *, ob_iter, selected_editable_objects) {
|
||||
if (ob_iter->type == OB_GPENCIL) {
|
||||
if ((ob_iter->rot[0] != 0) || (ob_iter->rot[1] != 0) || (ob_iter->rot[2] != 0)) {
|
||||
|
||||
@@ -1650,10 +1650,23 @@ static bool gp_actframe_delete_poll(bContext *C)
|
||||
return (gpl && gpl->actframe);
|
||||
}
|
||||
|
||||
static bool gp_annotation_actframe_delete_poll(bContext *C)
|
||||
{
|
||||
bGPdata *gpd = ED_annotation_data_get_active(C);
|
||||
bGPDlayer *gpl = BKE_gpencil_layer_getactive(gpd);
|
||||
|
||||
/* only if there's an active layer with an active frame */
|
||||
return (gpl && gpl->actframe);
|
||||
}
|
||||
|
||||
/* delete active frame - wrapper around API calls */
|
||||
static int gp_actframe_delete_exec(bContext *C, wmOperator *op)
|
||||
{
|
||||
bGPdata *gpd = ED_gpencil_data_get_active(C);
|
||||
const int is_annotation = RNA_boolean_get(op->ptr, "is_annotation");
|
||||
|
||||
bGPdata *gpd = (!is_annotation) ? ED_gpencil_data_get_active(C) :
|
||||
ED_annotation_data_get_active(C);
|
||||
|
||||
bGPDlayer *gpl = BKE_gpencil_layer_getactive(gpd);
|
||||
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
@@ -1682,6 +1695,8 @@ static int gp_actframe_delete_exec(bContext *C, wmOperator *op)
|
||||
|
||||
void GPENCIL_OT_active_frame_delete(wmOperatorType *ot)
|
||||
{
|
||||
PropertyRNA *prop;
|
||||
|
||||
/* identifiers */
|
||||
ot->name = "Delete Active Frame";
|
||||
ot->idname = "GPENCIL_OT_active_frame_delete";
|
||||
@@ -1692,8 +1707,29 @@ void GPENCIL_OT_active_frame_delete(wmOperatorType *ot)
|
||||
/* callbacks */
|
||||
ot->exec = gp_actframe_delete_exec;
|
||||
ot->poll = gp_actframe_delete_poll;
|
||||
|
||||
prop = RNA_def_boolean(ot->srna, "is_annotation", false, "Annotation", "");
|
||||
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
||||
}
|
||||
|
||||
void GPENCIL_OT_annotation_active_frame_delete(wmOperatorType *ot)
|
||||
{
|
||||
PropertyRNA *prop;
|
||||
|
||||
/* identifiers */
|
||||
ot->name = "Delete Active Frame";
|
||||
ot->idname = "GPENCIL_OT_annotation_active_frame_delete";
|
||||
ot->description = "Delete the active frame for the active Annotation Layer";
|
||||
|
||||
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
|
||||
|
||||
/* callbacks */
|
||||
ot->exec = gp_actframe_delete_exec;
|
||||
ot->poll = gp_annotation_actframe_delete_poll;
|
||||
|
||||
prop = RNA_def_boolean(ot->srna, "is_annotation", true, "Annotation", "");
|
||||
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
||||
}
|
||||
/* **************** Delete All Active Frames ****************** */
|
||||
|
||||
static bool gp_actframe_delete_all_poll(bContext *C)
|
||||
|
||||
@@ -428,12 +428,15 @@ void GPENCIL_OT_sculpt_paint(struct wmOperatorType *ot);
|
||||
|
||||
/* buttons editing --- */
|
||||
|
||||
void GPENCIL_OT_data_add(struct wmOperatorType *ot);
|
||||
void GPENCIL_OT_annotation_add(struct wmOperatorType *ot);
|
||||
void GPENCIL_OT_data_unlink(struct wmOperatorType *ot);
|
||||
|
||||
void GPENCIL_OT_layer_add(struct wmOperatorType *ot);
|
||||
void GPENCIL_OT_layer_remove(struct wmOperatorType *ot);
|
||||
void GPENCIL_OT_layer_move(struct wmOperatorType *ot);
|
||||
void GPENCIL_OT_layer_annotation_add(struct wmOperatorType *ot);
|
||||
void GPENCIL_OT_layer_annotation_remove(struct wmOperatorType *ot);
|
||||
void GPENCIL_OT_layer_annotation_move(struct wmOperatorType *ot);
|
||||
void GPENCIL_OT_layer_duplicate(struct wmOperatorType *ot);
|
||||
void GPENCIL_OT_layer_duplicate_object(struct wmOperatorType *ot);
|
||||
|
||||
@@ -449,6 +452,7 @@ void GPENCIL_OT_layer_merge(struct wmOperatorType *ot);
|
||||
void GPENCIL_OT_blank_frame_add(struct wmOperatorType *ot);
|
||||
|
||||
void GPENCIL_OT_active_frame_delete(struct wmOperatorType *ot);
|
||||
void GPENCIL_OT_annotation_active_frame_delete(struct wmOperatorType *ot);
|
||||
void GPENCIL_OT_active_frames_delete_all(struct wmOperatorType *ot);
|
||||
void GPENCIL_OT_frame_duplicate(struct wmOperatorType *ot);
|
||||
void GPENCIL_OT_frame_clean_fill(struct wmOperatorType *ot);
|
||||
|
||||
@@ -276,12 +276,15 @@ void ED_operatortypes_gpencil(void)
|
||||
|
||||
/* Editing (Buttons) ------------ */
|
||||
|
||||
WM_operatortype_append(GPENCIL_OT_data_add);
|
||||
WM_operatortype_append(GPENCIL_OT_annotation_add);
|
||||
WM_operatortype_append(GPENCIL_OT_data_unlink);
|
||||
|
||||
WM_operatortype_append(GPENCIL_OT_layer_add);
|
||||
WM_operatortype_append(GPENCIL_OT_layer_remove);
|
||||
WM_operatortype_append(GPENCIL_OT_layer_move);
|
||||
WM_operatortype_append(GPENCIL_OT_layer_annotation_add);
|
||||
WM_operatortype_append(GPENCIL_OT_layer_annotation_remove);
|
||||
WM_operatortype_append(GPENCIL_OT_layer_annotation_move);
|
||||
WM_operatortype_append(GPENCIL_OT_layer_duplicate);
|
||||
WM_operatortype_append(GPENCIL_OT_layer_duplicate_object);
|
||||
|
||||
@@ -295,6 +298,7 @@ void ED_operatortypes_gpencil(void)
|
||||
WM_operatortype_append(GPENCIL_OT_blank_frame_add);
|
||||
|
||||
WM_operatortype_append(GPENCIL_OT_active_frame_delete);
|
||||
WM_operatortype_append(GPENCIL_OT_annotation_active_frame_delete);
|
||||
WM_operatortype_append(GPENCIL_OT_active_frames_delete_all);
|
||||
WM_operatortype_append(GPENCIL_OT_frame_duplicate);
|
||||
WM_operatortype_append(GPENCIL_OT_frame_clean_fill);
|
||||
|
||||
@@ -92,23 +92,20 @@
|
||||
* and an RNA-pointer to trace back to whatever owns it,
|
||||
* when context info is not available.
|
||||
*/
|
||||
bGPdata **ED_gpencil_data_get_pointers_direct(
|
||||
ID *screen_id, ScrArea *sa, Scene *scene, Object *ob, PointerRNA *r_ptr)
|
||||
bGPdata **ED_gpencil_data_get_pointers_direct(ScrArea *sa, Object *ob, PointerRNA *r_ptr)
|
||||
{
|
||||
/* if there's an active area, check if the particular editor may
|
||||
* have defined any special Grease Pencil context for editing...
|
||||
*/
|
||||
if (sa) {
|
||||
SpaceLink *sl = sa->spacedata.first;
|
||||
|
||||
switch (sa->spacetype) {
|
||||
/* XXX: Should we reduce reliance on context.gpencil_data for these cases? */
|
||||
case SPACE_PROPERTIES: /* properties */
|
||||
case SPACE_INFO: /* header info (needed after workspaces merge) */
|
||||
case SPACE_ACTION: /* Dopesheet header. */
|
||||
case SPACE_INFO: /* header info */
|
||||
case SPACE_TOPBAR: /* Topbar */
|
||||
case SPACE_VIEW3D: /* 3D-View */
|
||||
{
|
||||
if (ob && (ob->type == OB_GPENCIL)) {
|
||||
/* GP Object */
|
||||
/* GP Object. */
|
||||
if (r_ptr) {
|
||||
RNA_id_pointer_create(&ob->id, r_ptr);
|
||||
}
|
||||
@@ -120,25 +117,44 @@ bGPdata **ED_gpencil_data_get_pointers_direct(
|
||||
|
||||
break;
|
||||
}
|
||||
default: /* Unsupported space. */
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
case SPACE_TOPBAR: /* Topbar (needed after topbar merge) */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get pointer to active Grease Pencil datablock for annotations,
|
||||
* and an RNA-pointer to trace back to whatever owns it,
|
||||
* when context info is not available.
|
||||
*/
|
||||
bGPdata **ED_annotation_data_get_pointers_direct(ID *screen_id,
|
||||
ScrArea *sa,
|
||||
Scene *scene,
|
||||
PointerRNA *r_ptr)
|
||||
{
|
||||
/* If there's an active area, check if the particular editor may
|
||||
* have defined any special Grease Pencil context for editing. */
|
||||
if (sa) {
|
||||
SpaceLink *sl = sa->spacedata.first;
|
||||
|
||||
switch (sa->spacetype) {
|
||||
case SPACE_PROPERTIES: /* properties */
|
||||
case SPACE_INFO: /* header info */
|
||||
{
|
||||
return NULL;
|
||||
break;
|
||||
}
|
||||
|
||||
case SPACE_TOPBAR: /* Topbar */
|
||||
case SPACE_VIEW3D: /* 3D-View */
|
||||
{
|
||||
if (ob && (ob->type == OB_GPENCIL)) {
|
||||
/* GP Object */
|
||||
if (r_ptr) {
|
||||
RNA_id_pointer_create(&ob->id, r_ptr);
|
||||
}
|
||||
return (bGPdata **)&ob->data;
|
||||
}
|
||||
else {
|
||||
/* Annotations */
|
||||
/* XXX: */
|
||||
if (r_ptr) {
|
||||
RNA_id_pointer_create(&scene->id, r_ptr);
|
||||
}
|
||||
return &scene->gpd;
|
||||
if (r_ptr) {
|
||||
RNA_id_pointer_create(&scene->id, r_ptr);
|
||||
}
|
||||
return &scene->gpd;
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -156,7 +172,7 @@ bGPdata **ED_gpencil_data_get_pointers_direct(
|
||||
return &snode->nodetree->gpd;
|
||||
}
|
||||
|
||||
/* even when there is no node-tree, don't allow this to flow to scene */
|
||||
/* Even when there is no node-tree, don't allow this to flow to scene. */
|
||||
return NULL;
|
||||
}
|
||||
case SPACE_SEQ: /* Sequencer */
|
||||
@@ -165,7 +181,6 @@ bGPdata **ED_gpencil_data_get_pointers_direct(
|
||||
|
||||
/* For now, Grease Pencil data is associated with the space
|
||||
* (actually preview region only). */
|
||||
/* XXX our convention for everything else is to link to data though... */
|
||||
if (r_ptr) {
|
||||
RNA_pointer_create(screen_id, &RNA_SpaceSequenceEditor, sseq, r_ptr);
|
||||
}
|
||||
@@ -175,8 +190,7 @@ bGPdata **ED_gpencil_data_get_pointers_direct(
|
||||
{
|
||||
SpaceImage *sima = (SpaceImage *)sl;
|
||||
|
||||
/* for now, Grease Pencil data is associated with the space... */
|
||||
/* XXX our convention for everything else is to link to data though... */
|
||||
/* For now, Grease Pencil data is associated with the space... */
|
||||
if (r_ptr) {
|
||||
RNA_pointer_create(screen_id, &RNA_SpaceImageEditor, sima, r_ptr);
|
||||
}
|
||||
@@ -221,34 +235,61 @@ bGPdata **ED_gpencil_data_get_pointers_direct(
|
||||
* and an RNA-pointer to trace back to whatever owns it. */
|
||||
bGPdata **ED_gpencil_data_get_pointers(const bContext *C, PointerRNA *r_ptr)
|
||||
{
|
||||
ID *screen_id = (ID *)CTX_wm_screen(C);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
Object *ob = CTX_data_active_object(C);
|
||||
|
||||
return ED_gpencil_data_get_pointers_direct(screen_id, sa, scene, ob, r_ptr);
|
||||
return ED_gpencil_data_get_pointers_direct(sa, ob, r_ptr);
|
||||
}
|
||||
|
||||
/* Get pointer to active Grease Pencil datablock,
|
||||
* and an RNA-pointer to trace back to whatever owns it. */
|
||||
bGPdata **ED_annotation_data_get_pointers(const bContext *C, PointerRNA *r_ptr)
|
||||
{
|
||||
ID *screen_id = (ID *)CTX_wm_screen(C);
|
||||
Scene *scene = CTX_data_scene(C);
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
|
||||
return ED_annotation_data_get_pointers_direct(screen_id, sa, scene, r_ptr);
|
||||
}
|
||||
/* -------------------------------------------------------- */
|
||||
|
||||
/* Get the active Grease Pencil datablock, when context is not available */
|
||||
bGPdata *ED_gpencil_data_get_active_direct(ID *screen_id, ScrArea *sa, Scene *scene, Object *ob)
|
||||
bGPdata *ED_gpencil_data_get_active_direct(ScrArea *sa, Object *ob)
|
||||
{
|
||||
bGPdata **gpd_ptr = ED_gpencil_data_get_pointers_direct(screen_id, sa, scene, ob, NULL);
|
||||
bGPdata **gpd_ptr = ED_gpencil_data_get_pointers_direct(sa, ob, NULL);
|
||||
return (gpd_ptr) ? *(gpd_ptr) : NULL;
|
||||
}
|
||||
|
||||
/* Get the active Grease Pencil datablock, when context is not available */
|
||||
bGPdata *ED_annotation_data_get_active_direct(ID *screen_id, ScrArea *sa, Scene *scene)
|
||||
{
|
||||
bGPdata **gpd_ptr = ED_annotation_data_get_pointers_direct(screen_id, sa, scene, NULL);
|
||||
return (gpd_ptr) ? *(gpd_ptr) : NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the active Grease Pencil datablock
|
||||
* \note This is the original (bmain) copy of the datablock, stored in files.
|
||||
* Do not use for reading evaluated copies of GP Objects data
|
||||
*/
|
||||
bGPdata *ED_gpencil_data_get_active(const bContext *C)
|
||||
{
|
||||
bGPdata **gpd_ptr = ED_gpencil_data_get_pointers(C, NULL);
|
||||
return (gpd_ptr) ? *(gpd_ptr) : NULL;
|
||||
Object *ob = CTX_data_active_object(C);
|
||||
if (ob == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
bGPdata *gpd = (bGPdata *)ob->data;
|
||||
|
||||
return gpd;
|
||||
}
|
||||
|
||||
/* Get the active Grease Pencil datablock
|
||||
* \note This is the original (bmain) copy of the datablock, stored in files.
|
||||
* Do not use for reading evaluated copies of GP Objects data
|
||||
*/
|
||||
bGPdata *ED_annotation_data_get_active(const bContext *C)
|
||||
{
|
||||
bGPdata **gpd_ptr = ED_annotation_data_get_pointers(C, NULL);
|
||||
return (gpd_ptr) ? *(gpd_ptr) : NULL;
|
||||
}
|
||||
/**
|
||||
* Get the evaluated copy of the active Grease Pencil datablock (where applicable)
|
||||
* - For the 3D View (i.e. "GP Objects"), this gives the evaluated copy of the GP datablock
|
||||
@@ -259,20 +300,13 @@ bGPdata *ED_gpencil_data_get_active(const bContext *C)
|
||||
*/
|
||||
bGPdata *ED_gpencil_data_get_active_evaluated(const bContext *C)
|
||||
{
|
||||
ID *screen_id = (ID *)CTX_wm_screen(C);
|
||||
ScrArea *sa = CTX_wm_area(C);
|
||||
|
||||
const Depsgraph *depsgraph = CTX_data_ensure_evaluated_depsgraph(C);
|
||||
Scene *scene_eval = DEG_get_evaluated_scene(depsgraph);
|
||||
Object *ob = CTX_data_active_object(C);
|
||||
Object *ob_eval = DEG_get_evaluated_object(depsgraph, ob);
|
||||
|
||||
#if 0
|
||||
if (ob && ob->type == OB_GPENCIL) {
|
||||
BLI_assert(ob_eval->data == DEG_get_evaluated_id(ob->data));
|
||||
}
|
||||
#endif
|
||||
return ED_gpencil_data_get_active_direct(screen_id, sa, scene_eval, ob_eval);
|
||||
return ED_gpencil_data_get_active_direct(sa, ob_eval);
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------- */
|
||||
@@ -318,14 +352,23 @@ bool ED_gpencil_has_keyframe_v3d(Scene *UNUSED(scene), Object *ob, int cfra)
|
||||
/* poll callback for adding data/layers - special */
|
||||
bool gp_add_poll(bContext *C)
|
||||
{
|
||||
/* the base line we have is that we have somewhere to add Grease Pencil data */
|
||||
return ED_gpencil_data_get_pointers(C, NULL) != NULL;
|
||||
Object *ob = CTX_data_active_object(C);
|
||||
if (ob == NULL) {
|
||||
return false;
|
||||
}
|
||||
bGPdata *gpd = (bGPdata *)ob->data;
|
||||
|
||||
return (gpd != NULL);
|
||||
}
|
||||
|
||||
/* poll callback for checking if there is an active layer */
|
||||
bool gp_active_layer_poll(bContext *C)
|
||||
{
|
||||
bGPdata *gpd = ED_gpencil_data_get_active(C);
|
||||
Object *ob = CTX_data_active_object(C);
|
||||
if (ob == NULL) {
|
||||
return false;
|
||||
}
|
||||
bGPdata *gpd = (bGPdata *)ob->data;
|
||||
bGPDlayer *gpl = BKE_gpencil_layer_getactive(gpd);
|
||||
|
||||
return (gpl != NULL);
|
||||
|
||||
@@ -97,15 +97,21 @@ struct bGPdata *ED_gpencil_data_get_active(const struct bContext *C);
|
||||
struct bGPdata *ED_gpencil_data_get_active_evaluated(const struct bContext *C);
|
||||
|
||||
/* Context independent (i.e. each required part is passed in instead) */
|
||||
struct bGPdata **ED_gpencil_data_get_pointers_direct(struct ID *screen_id,
|
||||
struct ScrArea *sa,
|
||||
struct Scene *scene,
|
||||
struct bGPdata **ED_gpencil_data_get_pointers_direct(struct ScrArea *sa,
|
||||
struct Object *ob,
|
||||
struct PointerRNA *r_ptr);
|
||||
struct bGPdata *ED_gpencil_data_get_active_direct(struct ID *screen_id,
|
||||
struct ScrArea *sa,
|
||||
struct Scene *scene,
|
||||
struct Object *ob);
|
||||
struct bGPdata *ED_gpencil_data_get_active_direct(struct ScrArea *sa, struct Object *ob);
|
||||
|
||||
struct bGPdata *ED_annotation_data_get_active(const struct bContext *C);
|
||||
struct bGPdata **ED_annotation_data_get_pointers(const struct bContext *C,
|
||||
struct PointerRNA *r_ptr);
|
||||
struct bGPdata **ED_annotation_data_get_pointers_direct(struct ID *screen_id,
|
||||
struct ScrArea *sa,
|
||||
struct Scene *scene,
|
||||
struct PointerRNA *r_ptr);
|
||||
struct bGPdata *ED_annotation_data_get_active_direct(struct ID *screen_id,
|
||||
struct ScrArea *sa,
|
||||
struct Scene *scene);
|
||||
|
||||
bool ED_gpencil_data_owner_is_annotation(struct PointerRNA *owner_ptr);
|
||||
|
||||
|
||||
@@ -90,11 +90,14 @@ const char *screen_context_dir[] = {
|
||||
"selected_editable_sequences", /* sequencer */
|
||||
"gpencil_data",
|
||||
"gpencil_data_owner", /* grease pencil data */
|
||||
"annotation_data",
|
||||
"annotation_data_owner",
|
||||
"visible_gpencil_layers",
|
||||
"editable_gpencil_layers",
|
||||
"editable_gpencil_strokes",
|
||||
"active_gpencil_layer",
|
||||
"active_gpencil_frame",
|
||||
"active_annotation_layer",
|
||||
"active_operator",
|
||||
"visible_fcurves",
|
||||
"editable_fcurves",
|
||||
@@ -506,7 +509,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
|
||||
* That causes the get_active function to fail when called from context.
|
||||
* For that reason, we end up using an alternative where we pass everything in!
|
||||
*/
|
||||
bGPdata *gpd = ED_gpencil_data_get_active_direct((ID *)sc, sa, scene, obact);
|
||||
bGPdata *gpd = ED_gpencil_data_get_active_direct(sa, obact);
|
||||
|
||||
if (gpd) {
|
||||
CTX_data_id_pointer_set(result, &gpd->id);
|
||||
@@ -515,14 +518,33 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
|
||||
}
|
||||
else if (CTX_data_equals(member, "gpencil_data_owner")) {
|
||||
/* Pointer to which data/datablock owns the reference to the Grease Pencil data being used
|
||||
* (as gpencil_data).
|
||||
* XXX: see comment for gpencil_data case.
|
||||
*/
|
||||
* (as gpencil_data). */
|
||||
bGPdata **gpd_ptr = NULL;
|
||||
PointerRNA ptr;
|
||||
|
||||
/* get pointer to Grease Pencil Data */
|
||||
gpd_ptr = ED_gpencil_data_get_pointers_direct((ID *)sc, sa, scene, obact, &ptr);
|
||||
gpd_ptr = ED_gpencil_data_get_pointers_direct(sa, obact, &ptr);
|
||||
|
||||
if (gpd_ptr) {
|
||||
CTX_data_pointer_set(result, ptr.owner_id, ptr.type, ptr.data);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else if (CTX_data_equals(member, "annotation_data")) {
|
||||
bGPdata *gpd = ED_annotation_data_get_active_direct((ID *)sc, sa, scene);
|
||||
|
||||
if (gpd) {
|
||||
CTX_data_id_pointer_set(result, &gpd->id);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else if (CTX_data_equals(member, "annotation_data_owner")) {
|
||||
/* Pointer to which data/datablock owns the reference to the Grease Pencil data being used. */
|
||||
bGPdata **gpd_ptr = NULL;
|
||||
PointerRNA ptr;
|
||||
|
||||
/* Get pointer to Grease Pencil Data. */
|
||||
gpd_ptr = ED_annotation_data_get_pointers_direct((ID *)sc, sa, scene, &ptr);
|
||||
|
||||
if (gpd_ptr) {
|
||||
CTX_data_pointer_set(result, ptr.owner_id, ptr.type, ptr.data);
|
||||
@@ -530,8 +552,19 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
|
||||
}
|
||||
}
|
||||
else if (CTX_data_equals(member, "active_gpencil_layer")) {
|
||||
/* XXX: see comment for gpencil_data case... */
|
||||
bGPdata *gpd = ED_gpencil_data_get_active_direct((ID *)sc, sa, scene, obact);
|
||||
bGPdata *gpd = ED_gpencil_data_get_active_direct(sa, obact);
|
||||
|
||||
if (gpd) {
|
||||
bGPDlayer *gpl = BKE_gpencil_layer_getactive(gpd);
|
||||
|
||||
if (gpl) {
|
||||
CTX_data_pointer_set(result, &gpd->id, &RNA_GPencilLayer, gpl);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (CTX_data_equals(member, "active_annotation_layer")) {
|
||||
bGPdata *gpd = ED_annotation_data_get_active_direct((ID *)sc, sa, scene);
|
||||
|
||||
if (gpd) {
|
||||
bGPDlayer *gpl = BKE_gpencil_layer_getactive(gpd);
|
||||
@@ -543,8 +576,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
|
||||
}
|
||||
}
|
||||
else if (CTX_data_equals(member, "active_gpencil_frame")) {
|
||||
/* XXX: see comment for gpencil_data case... */
|
||||
bGPdata *gpd = ED_gpencil_data_get_active_direct((ID *)sc, sa, scene, obact);
|
||||
bGPdata *gpd = ED_gpencil_data_get_active_direct(sa, obact);
|
||||
|
||||
if (gpd) {
|
||||
bGPDlayer *gpl = BKE_gpencil_layer_getactive(gpd);
|
||||
@@ -556,8 +588,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
|
||||
}
|
||||
}
|
||||
else if (CTX_data_equals(member, "visible_gpencil_layers")) {
|
||||
/* XXX: see comment for gpencil_data case... */
|
||||
bGPdata *gpd = ED_gpencil_data_get_active_direct((ID *)sc, sa, scene, obact);
|
||||
bGPdata *gpd = ED_gpencil_data_get_active_direct(sa, obact);
|
||||
|
||||
if (gpd) {
|
||||
bGPDlayer *gpl;
|
||||
@@ -572,8 +603,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
|
||||
}
|
||||
}
|
||||
else if (CTX_data_equals(member, "editable_gpencil_layers")) {
|
||||
/* XXX: see comment for gpencil_data case... */
|
||||
bGPdata *gpd = ED_gpencil_data_get_active_direct((ID *)sc, sa, scene, obact);
|
||||
bGPdata *gpd = ED_gpencil_data_get_active_direct(sa, obact);
|
||||
|
||||
if (gpd) {
|
||||
bGPDlayer *gpl;
|
||||
@@ -588,8 +618,7 @@ int ed_screen_context(const bContext *C, const char *member, bContextDataResult
|
||||
}
|
||||
}
|
||||
else if (CTX_data_equals(member, "editable_gpencil_strokes")) {
|
||||
/* XXX: see comment for gpencil_data case... */
|
||||
bGPdata *gpd = ED_gpencil_data_get_active_direct((ID *)sc, sa, scene, obact);
|
||||
bGPdata *gpd = ED_gpencil_data_get_active_direct(sa, obact);
|
||||
const bool is_multiedit = (bool)GPENCIL_MULTIEDIT_SESSIONS_ON(gpd);
|
||||
|
||||
if (gpd) {
|
||||
|
||||
Reference in New Issue
Block a user