[Bf-blender-cvs] [0f83cba7d24] greasepencil-object: BKE_palette_get_active_from_context(C) now retrieves GP palettes from the active palette slot if the active object is a GP object
Joshua Leung
noreply at git.blender.org
Wed Oct 4 14:17:12 CEST 2017
Commit: 0f83cba7d246e05eb7edf3ab0d97d6bee257b042
Author: Joshua Leung
Date: Wed Oct 4 12:29:59 2017 +1300
Branches: greasepencil-object
https://developer.blender.org/rB0f83cba7d246e05eb7edf3ab0d97d6bee257b042
BKE_palette_get_active_from_context(C) now retrieves GP palettes from the active palette slot
if the active object is a GP object
This makes it possible to reuse all the Palette operators as-is,
without having to add a lot of GP-specific duplicates, and also
simplifies much of the context polling stuff.
===================================================================
M source/blender/blenkernel/intern/paint.c
===================================================================
diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c
index 821f67d7819..582f912a93c 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -41,6 +41,7 @@
#include "DNA_scene_types.h"
#include "DNA_brush_types.h"
#include "DNA_space_types.h"
+#include "DNA_gpencil_types.h"
#include "BLI_bitmap.h"
#include "BLI_blenlib.h"
@@ -59,6 +60,7 @@
#include "BKE_context.h"
#include "BKE_crazyspace.h"
#include "BKE_global.h"
+#include "BKE_gpencil.h"
#include "BKE_image.h"
#include "BKE_key.h"
#include "BKE_library.h"
@@ -366,11 +368,21 @@ void BKE_paint_palette_set(Paint *p, Palette *palette)
Palette *BKE_palette_get_active_from_context(const bContext *C)
{
- Paint *paint = BKE_paint_get_active_from_context(C);
+ Object *ob = CTX_data_active_object(C);
Palette *palette = NULL;
- if (paint && paint->palette) {
- palette = paint->palette;
+ if ((ob) && (ob->type == OB_GPENCIL)) {
+ bGPdata *gpd = CTX_data_gpencil_data(C);
+ bGPDpaletteref *palslot = BKE_gpencil_paletteslot_get_active(gpd);
+ if (palslot) {
+ palette = palslot->palette;
+ }
+ }
+ else {
+ Paint *paint = BKE_paint_get_active_from_context(C);
+ if (paint && paint->palette) {
+ palette = paint->palette;
+ }
}
return palette;
More information about the Bf-blender-cvs
mailing list