Code cleanup: use ED_gpencil_ prefix for grease pencil

This commit is contained in:
Campbell Barton 2014-06-14 02:54:17 +10:00
parent b96172cb05
commit f37c971878
17 changed files with 68 additions and 68 deletions

@ -676,7 +676,7 @@ static void gp_draw_data(bGPdata *gpd, int offsx, int offsy, int winx, int winy,
* ............................ */
/* draw grease-pencil sketches to specified 2d-view that uses ibuf corrections */
void draw_gpencil_2dimage(const bContext *C)
void ED_gpencil_draw_2dimage(const bContext *C)
{
ScrArea *sa = CTX_wm_area(C);
ARegion *ar = CTX_wm_region(C);
@ -685,7 +685,7 @@ void draw_gpencil_2dimage(const bContext *C)
int offsx, offsy, sizex, sizey;
int dflag = GP_DRAWDATA_NOSTATUS;
gpd = gpencil_data_get_active(C); // XXX
gpd = ED_gpencil_data_get_active(C); // XXX
if (gpd == NULL) return;
/* calculate rect */
@ -738,7 +738,7 @@ void draw_gpencil_2dimage(const bContext *C)
/* draw grease-pencil sketches to specified 2d-view assuming that matrices are already set correctly
* Note: this gets called twice - first time with onlyv2d=1 to draw 'canvas' strokes,
* second time with onlyv2d=0 for screen-aligned strokes */
void draw_gpencil_view2d(const bContext *C, bool onlyv2d)
void ED_gpencil_draw_view2d(const bContext *C, bool onlyv2d)
{
ScrArea *sa = CTX_wm_area(C);
ARegion *ar = CTX_wm_region(C);
@ -748,7 +748,7 @@ void draw_gpencil_view2d(const bContext *C, bool onlyv2d)
/* check that we have grease-pencil stuff to draw */
if (sa == NULL) return;
gpd = gpencil_data_get_active(C); // XXX
gpd = ED_gpencil_data_get_active(C); // XXX
if (gpd == NULL) return;
/* special hack for Image Editor */
@ -764,7 +764,7 @@ void draw_gpencil_view2d(const bContext *C, bool onlyv2d)
/* draw grease-pencil sketches to specified 3d-view assuming that matrices are already set correctly
* Note: this gets called twice - first time with only3d=1 to draw 3d-strokes,
* second time with only3d=0 for screen-aligned strokes */
void draw_gpencil_view3d(Scene *scene, View3D *v3d, ARegion *ar, bool only3d)
void ED_gpencil_draw_view3d(Scene *scene, View3D *v3d, ARegion *ar, bool only3d)
{
bGPdata *gpd;
int dflag = 0;
@ -772,7 +772,7 @@ void draw_gpencil_view3d(Scene *scene, View3D *v3d, ARegion *ar, bool only3d)
int offsx, offsy, winx, winy;
/* check that we have grease-pencil stuff to draw */
gpd = gpencil_data_get_active_v3d(scene); // XXX
gpd = ED_gpencil_data_get_active_v3d(scene); // XXX
if (gpd == NULL) return;
/* when rendering to the offscreen buffer we don't want to

@ -61,30 +61,30 @@
/* Generics - Loopers */
/* Loops over the gp-frames for a gp-layer, and applies the given callback */
short ED_gplayer_frames_looper(bGPDlayer *gpl, Scene *scene, short (*gpf_cb)(bGPDframe *, Scene *))
bool ED_gplayer_frames_looper(bGPDlayer *gpl, Scene *scene, short (*gpf_cb)(bGPDframe *, Scene *))
{
bGPDframe *gpf;
/* error checker */
if (gpl == NULL)
return 0;
return false;
/* do loop */
for (gpf = gpl->frames.first; gpf; gpf = gpf->next) {
/* execute callback */
if (gpf_cb(gpf, scene))
return 1;
return true;
}
/* nothing to return */
return 0;
return false;
}
/* ****************************************** */
/* Data Conversion Tools */
/* make a listing all the gp-frames in a layer as cfraelems */
void ED_gplayer_make_cfra_list(bGPDlayer *gpl, ListBase *elems, short onlysel)
void ED_gplayer_make_cfra_list(bGPDlayer *gpl, ListBase *elems, bool onlysel)
{
bGPDframe *gpf;
CfraElem *ce;
@ -110,22 +110,22 @@ void ED_gplayer_make_cfra_list(bGPDlayer *gpl, ListBase *elems, short onlysel)
/* Selection Tools */
/* check if one of the frames in this layer is selected */
short ED_gplayer_frame_select_check(bGPDlayer *gpl)
bool ED_gplayer_frame_select_check(bGPDlayer *gpl)
{
bGPDframe *gpf;
/* error checking */
if (gpl == NULL)
return 0;
return false;
/* stop at the first one found */
for (gpf = gpl->frames.first; gpf; gpf = gpf->next) {
if (gpf->flag & GP_FRAME_SELECT)
return 1;
return true;
}
/* not found */
return 0;
return false;
}
/* helper function - select gp-frame based on SELECT_* mode */

@ -350,7 +350,7 @@ static void draw_gpencil_panel(bContext *C, uiLayout *layout, bGPdata *gpd, Poin
}
}
void gpencil_panel_standard_header(const bContext *C, Panel *pa)
void ED_gpencil_panel_standard_header(const bContext *C, Panel *pa)
{
PointerRNA ptr;
RNA_pointer_create((ID *)CTX_wm_screen(C), &RNA_Space, CTX_wm_space_data(C), &ptr);
@ -359,7 +359,7 @@ void gpencil_panel_standard_header(const bContext *C, Panel *pa)
}
/* Standard panel to be included wherever Grease Pencil is used... */
void gpencil_panel_standard(const bContext *C, Panel *pa)
void ED_gpencil_panel_standard(const bContext *C, Panel *pa)
{
bGPdata **gpd_ptr = NULL;
PointerRNA ptr;
@ -369,7 +369,7 @@ void gpencil_panel_standard(const bContext *C, Panel *pa)
draw_gpencil_space_specials(C, pa->layout);
/* get pointer to Grease Pencil Data */
gpd_ptr = gpencil_data_get_pointers((bContext *)C, &ptr);
gpd_ptr = ED_gpencil_data_get_pointers((bContext *)C, &ptr);
if (gpd_ptr)
draw_gpencil_panel((bContext *)C, pa->layout, *gpd_ptr, &ptr);

@ -86,7 +86,7 @@
/* Context Wrangling... */
/* Get pointer to active Grease Pencil datablock, and an RNA-pointer to trace back to whatever owns it */
bGPdata **gpencil_data_get_pointers(const bContext *C, PointerRNA *ptr)
bGPdata **ED_gpencil_data_get_pointers(const bContext *C, PointerRNA *ptr)
{
ID *screen_id = (ID *)CTX_wm_screen(C);
Scene *scene = CTX_data_scene(C);
@ -180,19 +180,19 @@ bGPdata **gpencil_data_get_pointers(const bContext *C, PointerRNA *ptr)
}
/* Get the active Grease Pencil datablock */
bGPdata *gpencil_data_get_active(const bContext *C)
bGPdata *ED_gpencil_data_get_active(const bContext *C)
{
bGPdata **gpd_ptr = gpencil_data_get_pointers(C, NULL);
bGPdata **gpd_ptr = ED_gpencil_data_get_pointers(C, NULL);
return (gpd_ptr) ? *(gpd_ptr) : NULL;
}
/* needed for offscreen rendering */
bGPdata *gpencil_data_get_active_v3d(Scene *scene)
bGPdata *ED_gpencil_data_get_active_v3d(Scene *scene)
{
Base *base = scene->basact;
bGPdata *gpd = NULL;
/* We have to make sure active object is actually visible and selected, else we must use default scene gpd,
* to be consistent with gpencil_data_get_active's behavior.
* to be consistent with ED_gpencil_data_get_active's behavior.
*/
if (base && (scene->lay & base->lay) && (base->object->flag & SELECT)) {
gpd = base->object->gpd;
@ -207,7 +207,7 @@ bGPdata *gpencil_data_get_active_v3d(Scene *scene)
static int gp_add_poll(bContext *C)
{
/* the base line we have is that we have somewhere to add Grease Pencil data */
return gpencil_data_get_pointers(C, NULL) != NULL;
return ED_gpencil_data_get_pointers(C, NULL) != NULL;
}
/* ******************* Add New Data ************************ */
@ -215,7 +215,7 @@ static int gp_add_poll(bContext *C)
/* add new datablock - wrapper around API */
static int gp_data_add_exec(bContext *C, wmOperator *op)
{
bGPdata **gpd_ptr = gpencil_data_get_pointers(C, NULL);
bGPdata **gpd_ptr = ED_gpencil_data_get_pointers(C, NULL);
if (gpd_ptr == NULL) {
BKE_report(op->reports, RPT_ERROR, "Nowhere for grease pencil data to go");
@ -253,7 +253,7 @@ void GPENCIL_OT_data_add(wmOperatorType *ot)
/* poll callback for adding data/layers - special */
static int gp_data_unlink_poll(bContext *C)
{
bGPdata **gpd_ptr = gpencil_data_get_pointers(C, NULL);
bGPdata **gpd_ptr = ED_gpencil_data_get_pointers(C, NULL);
/* if we have access to some active data, make sure there's a datablock before enabling this */
return (gpd_ptr && *gpd_ptr);
@ -263,7 +263,7 @@ static int gp_data_unlink_poll(bContext *C)
/* unlink datablock - wrapper around API */
static int gp_data_unlink_exec(bContext *C, wmOperator *op)
{
bGPdata **gpd_ptr = gpencil_data_get_pointers(C, NULL);
bGPdata **gpd_ptr = ED_gpencil_data_get_pointers(C, NULL);
if (gpd_ptr == NULL) {
BKE_report(op->reports, RPT_ERROR, "Nowhere for grease pencil data to go");
@ -301,7 +301,7 @@ void GPENCIL_OT_data_unlink(wmOperatorType *ot)
/* add new layer - wrapper around API */
static int gp_layer_add_exec(bContext *C, wmOperator *op)
{
bGPdata **gpd_ptr = gpencil_data_get_pointers(C, NULL);
bGPdata **gpd_ptr = ED_gpencil_data_get_pointers(C, NULL);
/* if there's no existing Grease-Pencil data there, add some */
if (gpd_ptr == NULL) {
@ -337,7 +337,7 @@ void GPENCIL_OT_layer_add(wmOperatorType *ot)
static int gp_actframe_delete_poll(bContext *C)
{
bGPdata *gpd = gpencil_data_get_active(C);
bGPdata *gpd = ED_gpencil_data_get_active(C);
bGPDlayer *gpl = gpencil_layer_getactive(gpd);
/* only if there's an active layer with an active frame */
@ -348,7 +348,7 @@ static int gp_actframe_delete_poll(bContext *C)
static int gp_actframe_delete_exec(bContext *C, wmOperator *op)
{
Scene *scene = CTX_data_scene(C);
bGPdata *gpd = gpencil_data_get_active(C);
bGPdata *gpd = ED_gpencil_data_get_active(C);
bGPDlayer *gpl = gpencil_layer_getactive(gpd);
bGPDframe *gpf = gpencil_layer_getframe(gpl, CFRA, 0);
@ -1559,7 +1559,7 @@ static void gp_convert_set_end_frame(struct Main *UNUSED(main), struct Scene *UN
static int gp_convert_poll(bContext *C)
{
bGPdata *gpd = gpencil_data_get_active(C);
bGPdata *gpd = ED_gpencil_data_get_active(C);
bGPDlayer *gpl = NULL;
bGPDframe *gpf = NULL;
ScrArea *sa = CTX_wm_area(C);
@ -1578,7 +1578,7 @@ static int gp_convert_poll(bContext *C)
static int gp_convert_layer_exec(bContext *C, wmOperator *op)
{
PropertyRNA *prop = RNA_struct_find_property(op->ptr, "use_timing_data");
bGPdata *gpd = gpencil_data_get_active(C);
bGPdata *gpd = ED_gpencil_data_get_active(C);
bGPDlayer *gpl = gpencil_layer_getactive(gpd);
Scene *scene = CTX_data_scene(C);
const int mode = RNA_enum_get(op->ptr, "type");

@ -177,7 +177,7 @@ static int gpencil_draw_poll(bContext *C)
{
if (ED_operator_regionactive(C)) {
/* check if current context can support GPencil data */
if (gpencil_data_get_pointers(C, NULL) != NULL) {
if (ED_gpencil_data_get_pointers(C, NULL) != NULL) {
/* check if Grease Pencil isn't already running */
if (ED_gpencil_session_active() == 0)
return 1;
@ -1161,7 +1161,7 @@ static int gp_session_initdata(bContext *C, tGPsdata *p)
}
/* get gp-data */
gpd_ptr = gpencil_data_get_pointers(C, &p->ownerPtr);
gpd_ptr = ED_gpencil_data_get_pointers(C, &p->ownerPtr);
if (gpd_ptr == NULL) {
p->status = GP_STATUS_ERROR;
if (G.debug & G_DEBUG)

@ -70,7 +70,7 @@ int ED_undo_gpencil_step(bContext *C, int step, const char *name)
{
bGPdata **gpd_ptr = NULL, *new_gpd = NULL;
gpd_ptr = gpencil_data_get_pointers(C, NULL);
gpd_ptr = ED_gpencil_data_get_pointers(C, NULL);
if (step == 1) { /* undo */
//printf("\t\tGP - undo step\n");

@ -65,9 +65,9 @@ typedef struct tGPspoint {
/* ----------- Grease Pencil Tools/Context ------------- */
struct bGPdata **gpencil_data_get_pointers(const struct bContext *C, struct PointerRNA *ptr);
struct bGPdata *gpencil_data_get_active(const struct bContext *C);
struct bGPdata *gpencil_data_get_active_v3d(struct Scene *scene); /* for offscreen rendering */
struct bGPdata **ED_gpencil_data_get_pointers(const struct bContext *C, struct PointerRNA *ptr);
struct bGPdata *ED_gpencil_data_get_active(const struct bContext *C);
struct bGPdata *ED_gpencil_data_get_active_v3d(struct Scene *scene); /* for offscreen rendering */
/* ----------- Grease Pencil Operators ----------------- */
@ -77,19 +77,19 @@ void ED_operatortypes_gpencil(void);
/* ------------ Grease-Pencil Drawing API ------------------ */
/* drawgpencil.c */
void draw_gpencil_2dimage(const struct bContext *C);
void draw_gpencil_view2d(const struct bContext *C, bool onlyv2d);
void draw_gpencil_view3d(struct Scene *scene, struct View3D *v3d, struct ARegion *ar, bool only3d);
void ED_gpencil_draw_2dimage(const struct bContext *C);
void ED_gpencil_draw_view2d(const struct bContext *C, bool onlyv2d);
void ED_gpencil_draw_view3d(struct Scene *scene, struct View3D *v3d, struct ARegion *ar, bool only3d);
void gpencil_panel_standard_header(const struct bContext *C, struct Panel *pa);
void gpencil_panel_standard(const struct bContext *C, struct Panel *pa);
void ED_gpencil_panel_standard_header(const struct bContext *C, struct Panel *pa);
void ED_gpencil_panel_standard(const struct bContext *C, struct Panel *pa);
/* ----------- Grease-Pencil AnimEdit API ------------------ */
short ED_gplayer_frames_looper(struct bGPDlayer *gpl, struct Scene *scene,
bool ED_gplayer_frames_looper(struct bGPDlayer *gpl, struct Scene *scene,
short (*gpf_cb)(struct bGPDframe *, struct Scene *));
void ED_gplayer_make_cfra_list(struct bGPDlayer *gpl, ListBase *elems, short onlysel);
void ED_gplayer_make_cfra_list(struct bGPDlayer *gpl, ListBase *elems, bool onlysel);
short ED_gplayer_frame_select_check(struct bGPDlayer *gpl);
bool ED_gplayer_frame_select_check(struct bGPDlayer *gpl);
void ED_gplayer_frame_select_set(struct bGPDlayer *gpl, short mode);
void ED_gplayer_frames_select_border(struct bGPDlayer *gpl, float min, float max, short select_mode);
void ED_gpencil_select_frames(struct bGPDlayer *gpl, short select_mode);

@ -84,8 +84,8 @@ void ED_clip_buttons_register(ARegionType *art)
strcpy(pt->idname, "CLIP_PT_gpencil");
strcpy(pt->label, N_("Grease Pencil"));
strcpy(pt->translation_context, BLF_I18NCONTEXT_DEFAULT_BPYRNA);
pt->draw_header = gpencil_panel_standard_header;
pt->draw = gpencil_panel_standard;
pt->draw_header = ED_gpencil_panel_standard_header;
pt->draw = ED_gpencil_panel_standard;
pt->flag |= PNL_DEFAULT_CLOSED;
pt->poll = clip_grease_pencil_panel_poll;
BLI_addtail(&art->paneltypes, pt);

@ -1795,12 +1795,12 @@ void clip_draw_grease_pencil(bContext *C, int onlyv2d)
}
}
draw_gpencil_2dimage(C);
ED_gpencil_draw_2dimage(C);
glPopMatrix();
}
}
else {
draw_gpencil_view2d(C, 0);
ED_gpencil_draw_view2d(C, 0);
}
}

@ -947,8 +947,8 @@ void image_buttons_register(ARegionType *art)
strcpy(pt->idname, "IMAGE_PT_gpencil");
strcpy(pt->label, N_("Grease Pencil"));
strcpy(pt->translation_context, BLF_I18NCONTEXT_DEFAULT_BPYRNA);
pt->draw_header = gpencil_panel_standard_header;
pt->draw = gpencil_panel_standard;
pt->draw_header = ED_gpencil_panel_standard_header;
pt->draw = ED_gpencil_panel_standard;
BLI_strncpy(pt->category, category, BLI_strlen_utf8(category));
BLI_addtail(&art->paneltypes, pt);
}

@ -644,14 +644,14 @@ void draw_image_grease_pencil(bContext *C, bool onlyv2d)
/* draw in View2D space? */
if (onlyv2d) {
/* draw grease-pencil ('image' strokes) */
draw_gpencil_2dimage(C);
ED_gpencil_draw_2dimage(C);
}
else {
/* assume that UI_view2d_restore(C) has been called... */
//SpaceImage *sima = (SpaceImage *)CTX_wm_space_data(C);
/* draw grease-pencil ('screen' strokes) */
draw_gpencil_view2d(C, 0);
ED_gpencil_draw_view2d(C, 0);
}
}

@ -202,8 +202,8 @@ void node_buttons_register(ARegionType *art)
strcpy(pt->idname, "NODE_PT_gpencil");
strcpy(pt->label, N_("Grease Pencil"));
strcpy(pt->translation_context, BLF_I18NCONTEXT_DEFAULT_BPYRNA);
pt->draw_header = gpencil_panel_standard_header;
pt->draw = gpencil_panel_standard;
pt->draw_header = ED_gpencil_panel_standard_header;
pt->draw = ED_gpencil_panel_standard;
pt->poll = active_nodetree_poll;
BLI_addtail(&art->paneltypes, pt);
}

@ -1341,7 +1341,7 @@ void drawnodespace(const bContext *C, ARegion *ar)
if (snode->flag & SNODE_SHOW_GPENCIL) {
/* draw grease-pencil ('canvas' strokes) */
draw_gpencil_view2d(C, true);
ED_gpencil_draw_view2d(C, true);
}
}
else {
@ -1360,7 +1360,7 @@ void drawnodespace(const bContext *C, ARegion *ar)
if (snode->treepath.last) {
if (snode->flag & SNODE_SHOW_GPENCIL) {
/* draw grease-pencil (screen strokes, and also paintbuffer) */
draw_gpencil_view2d(C, false);
ED_gpencil_draw_view2d(C, false);
}
}

@ -68,8 +68,8 @@ void sequencer_buttons_register(ARegionType *art)
strcpy(pt->idname, "SEQUENCER_PT_gpencil");
strcpy(pt->label, N_("Grease Pencil"));
strcpy(pt->translation_context, BLF_I18NCONTEXT_DEFAULT_BPYRNA);
pt->draw_header = gpencil_panel_standard_header;
pt->draw = gpencil_panel_standard;
pt->draw_header = ED_gpencil_panel_standard_header;
pt->draw = ED_gpencil_panel_standard;
pt->poll = sequencer_grease_pencil_panel_poll;
BLI_addtail(&art->paneltypes, pt);
}

@ -1236,7 +1236,7 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq
if (sseq->flag & SEQ_SHOW_GPENCIL) {
if (is_imbuf) {
/* draw grease-pencil (image aligned) */
draw_gpencil_2dimage(C);
ED_gpencil_draw_2dimage(C);
}
}
@ -1249,7 +1249,7 @@ void draw_image_seq(const bContext *C, Scene *scene, ARegion *ar, SpaceSeq *sseq
if (sseq->flag & SEQ_SHOW_GPENCIL) {
if (is_imbuf) {
/* draw grease-pencil (screen aligned) */
draw_gpencil_view2d(C, 0);
ED_gpencil_draw_view2d(C, 0);
}
}

@ -1181,8 +1181,8 @@ void view3d_buttons_register(ARegionType *art)
strcpy(pt->idname, "VIEW3D_PT_gpencil");
strcpy(pt->label, N_("Grease Pencil")); /* XXX C panels are not available through RNA (bpy.types)! */
strcpy(pt->translation_context, BLF_I18NCONTEXT_DEFAULT_BPYRNA);
pt->draw_header = gpencil_panel_standard_header;
pt->draw = gpencil_panel_standard;
pt->draw_header = ED_gpencil_panel_standard_header;
pt->draw = ED_gpencil_panel_standard;
BLI_addtail(&art->paneltypes, pt);
pt = MEM_callocN(sizeof(PanelType), "spacetype view3d panel vgroup");

@ -2255,7 +2255,7 @@ void draw_depth_gpencil(Scene *scene, ARegion *ar, View3D *v3d)
glEnable(GL_DEPTH_TEST);
if (v3d->flag2 & V3D_SHOW_GPENCIL) {
draw_gpencil_view3d(scene, v3d, ar, true);
ED_gpencil_draw_view3d(scene, v3d, ar, true);
}
v3d->zbuf = zbuf;
@ -2714,7 +2714,7 @@ static void view3d_draw_objects(
if (v3d->flag2 & V3D_SHOW_GPENCIL) {
/* must be before xray draw which clears the depth buffer */
if (v3d->zbuf) glDisable(GL_DEPTH_TEST);
draw_gpencil_view3d(scene, v3d, ar, true);
ED_gpencil_draw_view3d(scene, v3d, ar, true);
if (v3d->zbuf) glEnable(GL_DEPTH_TEST);
}
@ -2834,7 +2834,7 @@ void ED_view3d_draw_offscreen(Scene *scene, View3D *v3d, ARegion *ar, int winx,
if (v3d->flag2 & V3D_SHOW_GPENCIL) {
/* draw grease-pencil stuff - needed to get paint-buffer shown too (since it's 2D) */
draw_gpencil_view3d(scene, v3d, ar, false);
ED_gpencil_draw_view3d(scene, v3d, ar, false);
}
/* freeing the images again here could be done after the operator runs, leaving for now */
@ -3449,7 +3449,7 @@ static void view3d_main_area_draw_info(const bContext *C, Scene *scene,
if (v3d->flag2 & V3D_SHOW_GPENCIL) {
/* draw grease-pencil stuff - needed to get paint-buffer shown too (since it's 2D) */
draw_gpencil_view3d(scene, v3d, ar, false);
ED_gpencil_draw_view3d(scene, v3d, ar, false);
}
if ((v3d->flag2 & V3D_RENDER_OVERRIDE) == 0) {