diff options
author | Campbell Barton <ideasman42@gmail.com> | 2015-03-18 07:09:04 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2015-03-18 08:10:43 +0300 |
commit | 29195197147a882849859ea963cae42484dfeaba (patch) | |
tree | b45cf4a573fda9a1ff45c1eb2dd158cb5e15e1ff /source/blender/editors/sculpt_paint | |
parent | a975a3ca63d155e9ee1f0ba96fd451c330885aaa (diff) |
RNA: palette colors api
Methods so Python can manage colors.
palette.colors.new()/remove()/clear()/active
Diffstat (limited to 'source/blender/editors/sculpt_paint')
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_ops.c | 9 | ||||
-rw-r--r-- | source/blender/editors/sculpt_paint/paint_utils.c | 1 |
2 files changed, 8 insertions, 2 deletions
diff --git a/source/blender/editors/sculpt_paint/paint_ops.c b/source/blender/editors/sculpt_paint/paint_ops.c index 121b0b83a4b..eebd49895ef 100644 --- a/source/blender/editors/sculpt_paint/paint_ops.c +++ b/source/blender/editors/sculpt_paint/paint_ops.c @@ -196,7 +196,10 @@ static int palette_color_add_exec(bContext *C, wmOperator *UNUSED(op)) Brush *brush = paint->brush; PaintMode mode = BKE_paintmode_get_active_from_context(C); Palette *palette = paint->palette; - PaletteColor *color = BKE_palette_color_add(palette); + PaletteColor *color; + + color = BKE_palette_color_add(palette); + palette->active_color = BLI_listbase_count(&palette->colors) - 1; if (ELEM(mode, PAINT_TEXTURE_PROJECTIVE, PAINT_TEXTURE_2D, PAINT_VERTEX)) { copy_v3_v3(color->rgb, BKE_brush_color_get(scene, brush)); @@ -231,7 +234,9 @@ static int palette_color_delete_exec(bContext *C, wmOperator *UNUSED(op)) Palette *palette = paint->palette; PaletteColor *color = BLI_findlink(&palette->colors, palette->active_color); - BKE_palette_color_remove(palette, color); + if (color) { + BKE_palette_color_remove(palette, color); + } return OPERATOR_FINISHED; } diff --git a/source/blender/editors/sculpt_paint/paint_utils.c b/source/blender/editors/sculpt_paint/paint_utils.c index c0ed5005397..b19cced2f8e 100644 --- a/source/blender/editors/sculpt_paint/paint_utils.c +++ b/source/blender/editors/sculpt_paint/paint_utils.c @@ -439,6 +439,7 @@ void paint_sample_color(bContext *C, ARegion *ar, int x, int y, bool texpaint_pr } color = BKE_palette_color_add(palette); + palette->active_color = BLI_listbase_count(&palette->colors) - 1; } |