[Bf-blender-cvs] [44aad48ea0c] greasepencil-object: Fix warnings for copy paste
Antonio Vazquez
noreply at git.blender.org
Tue Jun 13 16:15:14 CEST 2017
Commit: 44aad48ea0c20da89d4ce8b1e6f0e1a5a25c4f5e
Author: Antonio Vazquez
Date: Tue Jun 13 16:08:47 2017 +0200
Branches: greasepencil-object
https://developer.blender.org/rB44aad48ea0c20da89d4ce8b1e6f0e1a5a25c4f5e
Fix warnings for copy paste
The merge code from master used the old BGPDpalette and the code must use the new Palette
===================================================================
M source/blender/editors/gpencil/gpencil_brush.c
M source/blender/editors/gpencil/gpencil_edit.c
M source/blender/editors/gpencil/gpencil_intern.h
===================================================================
diff --git a/source/blender/editors/gpencil/gpencil_brush.c b/source/blender/editors/gpencil/gpencil_brush.c
index 27a22a969c3..18d853c4ef1 100644
--- a/source/blender/editors/gpencil/gpencil_brush.c
+++ b/source/blender/editors/gpencil/gpencil_brush.c
@@ -864,7 +864,7 @@ static void gp_brush_clone_init(bContext *C, tGP_BrushEditData *gso)
/* Init colormap for mapping between the pasted stroke's source colour(names)
* and the final colours that will be used here instead...
*/
- data->new_colors = gp_copybuf_validate_colormap(gso->gpd);
+ data->new_colors = gp_copybuf_validate_colormap(C, gso->gpd);
}
/* Free custom data used for "clone" brush */
diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c
index 14d947b059f..fb27c5732fa 100644
--- a/source/blender/editors/gpencil/gpencil_edit.c
+++ b/source/blender/editors/gpencil/gpencil_edit.c
@@ -609,34 +609,34 @@ void ED_gpencil_strokes_copybuf_free(void)
/* Ensure that destination datablock has all the colours the pasted strokes need
* Helper function for copy-pasting strokes
*/
-GHash *gp_copybuf_validate_colormap(bGPdata *gpd)
+GHash *gp_copybuf_validate_colormap(bContext *C, bGPdata *gpd)
{
GHash *new_colors = BLI_ghash_str_new("GPencil Paste Dst Colors");
GHashIterator gh_iter;
/* If there's no active palette yet (i.e. new datablock), add one */
- bGPDpalette *palette = BKE_gpencil_palette_getactive(gpd);
+ Palette *palette = BKE_palette_get_active_from_context(C);
if (palette == NULL) {
- palette = BKE_gpencil_palette_addnew(gpd, "Pasted Palette", true);
+ palette = BKE_palette_add_gpencil(C);
}
/* For each color, figure out what to map to... */
GHASH_ITER(gh_iter, gp_strokes_copypastebuf_colors) {
- bGPDpalettecolor *palcolor;
+ PaletteColor *palcolor;
char *name = BLI_ghashIterator_getKey(&gh_iter);
/* Look for existing color to map to */
/* XXX: What to do if same name but different color? Behaviour here should depend on a property? */
- palcolor = BKE_gpencil_palettecolor_getbyname(palette, name);
+ palcolor = BKE_palette_color_getbyname(palette, name);
if (palcolor == NULL) {
/* Doesn't Exist - Create new matching color for this palette */
/* XXX: This still doesn't fix the pasting across file boundaries problem... */
- bGPDpalettecolor *src_color = BLI_ghashIterator_getValue(&gh_iter);
+ PaletteColor *src_color = BLI_ghashIterator_getValue(&gh_iter);
palcolor = MEM_dupallocN(src_color);
BLI_addtail(&palette->colors, palcolor);
- BLI_uniquename(&palette->colors, palcolor, DATA_("GP Color"), '.', offsetof(bGPDpalettecolor, info), sizeof(palcolor->info));
+ BLI_uniquename(&palette->colors, palcolor, DATA_("GP Color"), '.', offsetof(PaletteColor, info), sizeof(palcolor->info));
}
/* Store this mapping (for use later when pasting) */
@@ -711,19 +711,16 @@ static int gp_strokes_copy_exec(bContext *C, wmOperator *op)
if (gp_strokes_copypastebuf.first) {
gp_strokes_copypastebuf_colors = BLI_ghash_str_new("GPencil CopyBuf Colors");
- /* TODO: this code must be review because this is not relevant now and use Blender Palettes */
-#if 0
for (bGPDstroke *gps = gp_strokes_copypastebuf.first; gps; gps = gps->next) {
if (ED_gpencil_stroke_can_use(C, gps)) {
if (BLI_ghash_haskey(gp_strokes_copypastebuf_colors, gps->colorname) == false) {
- bGPDpalettecolor *color = MEM_dupallocN(gps->palcolor);
+ PaletteColor *color = MEM_dupallocN(gps->palcolor);
BLI_ghash_insert(gp_strokes_copypastebuf_colors, gps->colorname, color);
gps->palcolor = color;
}
}
}
-#endif
}
/* updates (to ensure operator buttons are refreshed, when used via hotkeys) */
@@ -833,7 +830,7 @@ static int gp_strokes_paste_exec(bContext *C, wmOperator *op)
CTX_DATA_END;
/* Ensure that all the necessary colors exist */
- new_colors = gp_copybuf_validate_colormap(gpd);
+ new_colors = gp_copybuf_validate_colormap(C, gpd);
/* Copy over the strokes from the buffer (and adjust the colors) */
for (bGPDstroke *gps = gp_strokes_copypastebuf.first; gps; gps = gps->next) {
diff --git a/source/blender/editors/gpencil/gpencil_intern.h b/source/blender/editors/gpencil/gpencil_intern.h
index 6d7f86c01b2..b8490544d75 100644
--- a/source/blender/editors/gpencil/gpencil_intern.h
+++ b/source/blender/editors/gpencil/gpencil_intern.h
@@ -156,7 +156,7 @@ int gp_brush_crt_presets_poll(bContext *C);
extern ListBase gp_strokes_copypastebuf;
/* Build a map for converting between old colornames and destination-color-refs */
-struct GHash *gp_copybuf_validate_colormap(bGPdata *gpd);
+struct GHash *gp_copybuf_validate_colormap(struct bContext *C, struct bGPdata *gpd);
/* Stroke Editing ------------------------------------ */
More information about the Bf-blender-cvs
mailing list