Fix T92290: Linked Color Palette datablocks can not be used.

* Forbid editing linked palettes.
* Make `color` RNA property of ColorPalette '`LIB_EXCEPTION`', so that
  the color buttons in the palette template remain active on linked data.

NOTE: This incidently makes linked palettes' colors editable from RNA,
not from UI though, so think this is OK for now.
This commit is contained in:
Bastien Montagne 2021-10-22 14:57:34 +02:00
parent 029cf23d71
commit 01e2a532f5
Notes: blender-bot 2023-02-14 10:14:07 +01:00
Referenced by issue #92290, Linked Color Palette datablocks can not be used
2 changed files with 15 additions and 1 deletions

View File

@ -233,7 +233,8 @@ static bool palette_poll(bContext *C)
{
Paint *paint = BKE_paint_get_active_from_context(C);
if (paint && paint->palette != NULL) {
if (paint && paint->palette != NULL && !ID_IS_LINKED(paint->palette) &&
!ID_IS_OVERRIDE_LIBRARY(paint->palette)) {
return true;
}

View File

@ -37,12 +37,20 @@
# include "BKE_report.h"
static PaletteColor *rna_Palette_color_new(Palette *palette)
{
if (ID_IS_LINKED(palette) || ID_IS_OVERRIDE_LIBRARY(palette)) {
return NULL;
}
PaletteColor *color = BKE_palette_color_add(palette);
return color;
}
static void rna_Palette_color_remove(Palette *palette, ReportList *reports, PointerRNA *color_ptr)
{
if (ID_IS_LINKED(palette) || ID_IS_OVERRIDE_LIBRARY(palette)) {
return;
}
PaletteColor *color = color_ptr->data;
if (BLI_findindex(&palette->colors, color) == -1) {
@ -58,6 +66,10 @@ static void rna_Palette_color_remove(Palette *palette, ReportList *reports, Poin
static void rna_Palette_color_clear(Palette *palette)
{
if (ID_IS_LINKED(palette) || ID_IS_OVERRIDE_LIBRARY(palette)) {
return;
}
BKE_palette_clear(palette);
}
@ -141,6 +153,7 @@ static void rna_def_palettecolor(BlenderRNA *brna)
prop = RNA_def_property(srna, "color", PROP_FLOAT, PROP_COLOR_GAMMA);
RNA_def_property_range(prop, 0.0, 1.0);
RNA_def_property_float_sdna(prop, NULL, "rgb");
RNA_def_property_flag(prop, PROP_LIB_EXCEPTION);
RNA_def_property_array(prop, 3);
RNA_def_property_ui_text(prop, "Color", "");
RNA_def_property_update(prop, NC_SCENE | ND_TOOLSETTINGS, NULL);