Blender
V5.0
source
blender
editors
gpencil_legacy
gpencil_edit.cc
Go to the documentation of this file.
1
/* SPDX-FileCopyrightText: 2008 Blender Authors
2
*
3
* SPDX-License-Identifier: GPL-2.0-or-later */
4
9
10
#include <cstdlib>
11
#include <cstring>
12
13
#include "
MEM_guardedalloc.h
"
14
15
#include "
BLI_ghash.h
"
16
#include "
BLI_listbase.h
"
17
#include "
BLI_utildefines.h
"
18
19
#include "
DNA_gpencil_legacy_types.h
"
20
#include "
DNA_scene_types.h
"
21
#include "
DNA_screen_types.h
"
22
23
#include "
BKE_context.hh
"
24
#include "
BKE_gpencil_legacy.h
"
25
#include "
BKE_lib_id.hh
"
26
#include "
BKE_paint.hh
"
27
#include "
BKE_report.hh
"
28
#include "
BKE_scene.hh
"
29
30
#include "
WM_api.hh
"
31
#include "
WM_message.hh
"
32
#include "
WM_toolsystem.hh
"
33
#include "
WM_types.hh
"
34
35
#include "
RNA_access.hh
"
36
37
#include "
UI_view2d.hh
"
38
39
#include "
ED_gpencil_legacy.hh
"
40
#include "
ED_image.hh
"
41
#include "
ED_object.hh
"
42
#include "
ED_outliner.hh
"
43
#include "
ED_screen.hh
"
44
#include "
ED_view3d.hh
"
45
46
#include "
DEG_depsgraph.hh
"
47
48
#include "
gpencil_intern.hh
"
49
50
/* -------------------------------------------------------------------- */
53
54
static
bool
annotation_actframe_delete_poll
(
bContext
*
C
)
55
{
56
bGPdata
*gpd =
ED_annotation_data_get_active
(
C
);
57
bGPDlayer
*gpl =
BKE_gpencil_layer_active_get
(gpd);
58
59
/* only if there's an active layer with an active frame */
60
return
(gpl && gpl->
actframe
);
61
}
62
63
/* delete active frame - wrapper around API calls */
64
static
wmOperatorStatus
gpencil_actframe_delete_exec
(
bContext
*
C
,
wmOperator
*op)
65
{
66
bGPdata
*gpd =
ED_annotation_data_get_active
(
C
);
67
bGPDlayer
*gpl =
BKE_gpencil_layer_active_get
(gpd);
68
69
Scene
*scene =
CTX_data_scene
(
C
);
70
71
bGPDframe
*gpf =
BKE_gpencil_layer_frame_get
(gpl, scene->
r
.
cfra
,
GP_GETFRAME_USE_PREV
);
72
73
/* if there's no existing Grease-Pencil data there, add some */
74
if
(gpd ==
nullptr
) {
75
BKE_report
(op->
reports
,
RPT_ERROR
,
"No Grease Pencil data"
);
76
return
OPERATOR_CANCELLED
;
77
}
78
if
(
ELEM
(
nullptr
, gpl, gpf)) {
79
BKE_report
(op->
reports
,
RPT_ERROR
,
"No active frame to delete"
);
80
return
OPERATOR_CANCELLED
;
81
}
82
83
/* delete it... */
84
BKE_gpencil_layer_frame_delete
(gpl, gpf);
85
86
/* notifiers */
87
DEG_id_tag_update
(&gpd->
id
,
ID_RECALC_TRANSFORM
|
ID_RECALC_GEOMETRY
);
88
WM_event_add_notifier
(
C
,
NC_GPENCIL
|
ND_DATA
|
NA_EDITED
,
nullptr
);
89
90
return
OPERATOR_FINISHED
;
91
}
92
93
void
GPENCIL_OT_annotation_active_frame_delete
(
wmOperatorType
*
ot
)
94
{
95
/* identifiers */
96
ot
->name =
"Delete Active Frame"
;
97
ot
->idname =
"GPENCIL_OT_annotation_active_frame_delete"
;
98
ot
->description =
"Delete the active frame for the active Annotation Layer"
;
99
100
ot
->flag =
OPTYPE_REGISTER
|
OPTYPE_UNDO
;
101
102
/* callbacks */
103
ot
->exec =
gpencil_actframe_delete_exec
;
104
ot
->poll =
annotation_actframe_delete_poll
;
105
}
106
BKE_context.hh
CTX_data_scene
Scene * CTX_data_scene(const bContext *C)
Definition
blenkernel/intern/context.cc:1310
BKE_gpencil_legacy.h
BKE_gpencil_layer_frame_delete
bool BKE_gpencil_layer_frame_delete(struct bGPDlayer *gpl, struct bGPDframe *gpf)
Definition
gpencil_legacy.cc:1030
BKE_gpencil_layer_frame_get
struct bGPDframe * BKE_gpencil_layer_frame_get(struct bGPDlayer *gpl, int cframe, eGP_GetFrame_Mode addnew)
Definition
gpencil_legacy.cc:867
BKE_gpencil_layer_active_get
struct bGPDlayer * BKE_gpencil_layer_active_get(struct bGPdata *gpd)
Definition
gpencil_legacy.cc:1087
GP_GETFRAME_USE_PREV
@ GP_GETFRAME_USE_PREV
Definition
BKE_gpencil_legacy.h:163
BKE_lib_id.hh
BKE_paint.hh
BKE_report.hh
RPT_ERROR
@ RPT_ERROR
Definition
BKE_report.hh:39
BKE_report
void BKE_report(ReportList *reports, eReportType type, const char *message)
Definition
report.cc:153
BKE_scene.hh
BLI_ghash.h
BLI_listbase.h
BLI_utildefines.h
ELEM
#define ELEM(...)
Definition
BLI_utildefines.h:144
DEG_depsgraph.hh
DEG_id_tag_update
void DEG_id_tag_update(ID *id, unsigned int flags)
Definition
depsgraph_tag.cc:827
ID_RECALC_TRANSFORM
@ ID_RECALC_TRANSFORM
Definition
DNA_ID.h:1054
ID_RECALC_GEOMETRY
@ ID_RECALC_GEOMETRY
Definition
DNA_ID.h:1074
DNA_gpencil_legacy_types.h
DNA_scene_types.h
DNA_screen_types.h
wmOperatorStatus
wmOperatorStatus
Definition
DNA_windowmanager_enums.h:16
OPERATOR_CANCELLED
@ OPERATOR_CANCELLED
Definition
DNA_windowmanager_enums.h:18
OPERATOR_FINISHED
@ OPERATOR_FINISHED
Definition
DNA_windowmanager_enums.h:19
ED_gpencil_legacy.hh
ED_image.hh
ED_object.hh
ED_outliner.hh
ED_screen.hh
ED_view3d.hh
MEM_guardedalloc.h
Read Guarded memory(de)allocation.
RNA_access.hh
C
#define C
Definition
RandGen.cpp:29
UI_view2d.hh
WM_api.hh
WM_message.hh
WM_toolsystem.hh
WM_types.hh
ND_DATA
#define ND_DATA
Definition
WM_types.hh:509
OPTYPE_UNDO
@ OPTYPE_UNDO
Definition
WM_types.hh:182
OPTYPE_REGISTER
@ OPTYPE_REGISTER
Definition
WM_types.hh:180
NA_EDITED
#define NA_EDITED
Definition
WM_types.hh:584
NC_GPENCIL
#define NC_GPENCIL
Definition
WM_types.hh:399
gpencil_actframe_delete_exec
static wmOperatorStatus gpencil_actframe_delete_exec(bContext *C, wmOperator *op)
Definition
gpencil_edit.cc:64
annotation_actframe_delete_poll
static bool annotation_actframe_delete_poll(bContext *C)
Definition
gpencil_edit.cc:54
GPENCIL_OT_annotation_active_frame_delete
void GPENCIL_OT_annotation_active_frame_delete(wmOperatorType *ot)
Definition
gpencil_edit.cc:93
gpencil_intern.hh
ED_annotation_data_get_active
bGPdata * ED_annotation_data_get_active(const bContext *C)
Definition
gpencil_utils.cc:167
RenderData::cfra
int cfra
Definition
DNA_scene_types.h:771
Scene
Definition
DNA_scene_types.h:2120
Scene::r
struct RenderData r
Definition
DNA_scene_types.h:2166
bContext
Definition
blenkernel/intern/context.cc:63
bGPDframe
Definition
DNA_gpencil_legacy_types.h:362
bGPDlayer
Definition
DNA_gpencil_legacy_types.h:424
bGPDlayer::actframe
bGPDframe * actframe
Definition
DNA_gpencil_legacy_types.h:432
bGPdata
Definition
DNA_gpencil_legacy_types.h:613
bGPdata::id
ID id
Definition
DNA_gpencil_legacy_types.h:621
wmOperatorType
Definition
WM_types.hh:1031
wmOperator
Definition
DNA_windowmanager_types.h:531
wmOperator::reports
struct ReportList * reports
Definition
DNA_windowmanager_types.h:551
WM_event_add_notifier
void WM_event_add_notifier(const bContext *C, uint type, void *reference)
Definition
wm_event_system.cc:397
ot
wmOperatorType * ot
Definition
wm_files.cc:4237
Generated on
for Blender by
doxygen
1.16.1