[Bf-blender-cvs] [924112241b2] greasepencil-object: GP: Modify existing operators to use new palette api's

Joshua Leung noreply at git.blender.org
Wed Oct 4 14:16:59 CEST 2017


Commit: 924112241b2c6a43cb4ea5534f89e21cec7a42fa
Author: Joshua Leung
Date:   Mon Oct 2 17:00:24 2017 +1300
Branches: greasepencil-object
https://developer.blender.org/rB924112241b2c6a43cb4ea5534f89e21cec7a42fa

GP: Modify existing operators to use new palette api's

===================================================================

M	source/blender/editors/gpencil/gpencil_data.c

===================================================================

diff --git a/source/blender/editors/gpencil/gpencil_data.c b/source/blender/editors/gpencil/gpencil_data.c
index a106a16a61d..bd708316e81 100644
--- a/source/blender/editors/gpencil/gpencil_data.c
+++ b/source/blender/editors/gpencil/gpencil_data.c
@@ -870,23 +870,25 @@ void GPENCIL_OT_stroke_arrange(wmOperatorType *ot)
 
 	ot->prop = RNA_def_enum(ot->srna, "direction", slot_move, GP_STROKE_MOVE_UP, "Direction", "");
 }
+
 /* ******************* Move Stroke to new palette ************************** */
 
 static int gp_stroke_change_palette_exec(bContext *C, wmOperator *op)
 {
-	bGPdata *gpd = ED_gpencil_data_get_active(C);
 	Scene *scene = CTX_data_scene(C);
 	const int type = RNA_enum_get(op->ptr, "type");
 
+	bGPdata *gpd = ED_gpencil_data_get_active(C);
+	bGPDpaletteref *palslot = BKE_gpencil_paletteslot_get_active(gpd);
 	Palette *palette;
 	PaletteColor *palcolor;
 
 	/* sanity checks */
-	if (ELEM(NULL, gpd)) {
+	if (ELEM(NULL, gpd, palslot)) {
 		return OPERATOR_CANCELLED;
 	}
 
-	palette = BKE_palette_get_active_from_context(C);
+	palette = palslot->palette;
 	if (ELEM(NULL, palette)) {
 		return OPERATOR_CANCELLED;
 	}
@@ -972,16 +974,17 @@ void GPENCIL_OT_stroke_change_palette(wmOperatorType *ot)
 static int gp_stroke_change_color_exec(bContext *C, wmOperator *UNUSED(op))
 {
 	bGPdata *gpd = ED_gpencil_data_get_active(C);
+	bGPDpaletteref *palslot = BKE_gpencil_paletteslot_get_active(gpd);
 	Palette *palette;
 	PaletteColor *color;
 
 	/* sanity checks */
-	if (ELEM(NULL, gpd)) {
+	if (ELEM(NULL, gpd, palslot)) {
 		return OPERATOR_CANCELLED;
 	}
 
-	palette = BKE_palette_get_active_from_context(C);
-	color = BKE_palette_color_get_active_from_context(C);
+	palette = palslot->palette;
+	color = BKE_palette_color_get_active(palette);
 	if (ELEM(NULL, color)) {
 		return OPERATOR_CANCELLED;
 	}
@@ -1034,13 +1037,14 @@ void GPENCIL_OT_stroke_change_color(wmOperatorType *ot)
 static int gp_stroke_lock_color_exec(bContext *C, wmOperator *UNUSED(op))
 {
 	bGPdata *gpd = ED_gpencil_data_get_active(C);
+	bGPDpaletteref *palslot = BKE_gpencil_paletteslot_get_active(gpd);
 	Palette *palette;
 
 	/* sanity checks */
-	if (ELEM(NULL, gpd))
+	if (ELEM(NULL, gpd, palslot))
 		return OPERATOR_CANCELLED;
 
-	palette = BKE_palette_get_active_from_context(C);
+	palette = palslot->palette;
 	if (ELEM(NULL, palette))
 		return OPERATOR_CANCELLED;
 	
@@ -1489,6 +1493,7 @@ void GPENCIL_OT_sculpt_select(wmOperatorType *ot)
 }
 
 /* ******************* Convert animation data ************************ */
+
 static int gp_convert_old_palettes_poll(bContext *C)
 {
 	/* TODO: need better poll*/
@@ -1529,6 +1534,7 @@ void GPENCIL_OT_convert_old_palettes(wmOperatorType *ot)
 }
 
 /* ******************* Convert scene gp data to gp object ************************ */
+
 static int gp_convert_scene_to_object_poll(bContext *C)
 {
 	Scene *scene = CTX_data_scene(C);
@@ -1576,7 +1582,8 @@ void GPENCIL_OT_convert_scene_to_object(wmOperatorType *ot)
 	ot->poll = gp_convert_scene_to_object_poll;
 }
 
-/**** Vertex Groups ****/
+/*********************** Vertex Groups ***********************************/
+
 static int gpencil_vertex_group_poll(bContext *C)
 {
 	Object *ob = CTX_data_active_object(C);



More information about the Bf-blender-cvs mailing list