Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/sculpt_paint/paint_ops.c
| Show First 20 Lines • Show All 391 Lines • ▼ Show 20 Lines | static int palette_sort_exec(bContext *C, wmOperator *op) | ||||
| tPaletteColorHSV *col_elm = NULL; | tPaletteColorHSV *col_elm = NULL; | ||||
| const int totcol = BLI_listbase_count(&palette->colors); | const int totcol = BLI_listbase_count(&palette->colors); | ||||
| if (totcol > 0) { | if (totcol > 0) { | ||||
| color_array = MEM_calloc_arrayN(totcol, sizeof(tPaletteColorHSV), __func__); | color_array = MEM_calloc_arrayN(totcol, sizeof(tPaletteColorHSV), __func__); | ||||
| /* Put all colors in an array. */ | /* Put all colors in an array. */ | ||||
| int t = 0; | int t = 0; | ||||
| for (PaletteColor *color = palette->colors.first; color; color = color->next) { | LISTBASE_FOREACH (PaletteColor *, color, &palette->colors) { | ||||
| float h, s, v; | float h, s, v; | ||||
| rgb_to_hsv(color->rgb[0], color->rgb[1], color->rgb[2], &h, &s, &v); | rgb_to_hsv(color->rgb[0], color->rgb[1], color->rgb[2], &h, &s, &v); | ||||
| col_elm = &color_array[t]; | col_elm = &color_array[t]; | ||||
| copy_v3_v3(col_elm->rgb, color->rgb); | copy_v3_v3(col_elm->rgb, color->rgb); | ||||
| col_elm->value = color->value; | col_elm->value = color->value; | ||||
| col_elm->h = h; | col_elm->h = h; | ||||
| col_elm->s = s; | col_elm->s = s; | ||||
| col_elm->v = v; | col_elm->v = v; | ||||
| ▲ Show 20 Lines • Show All 129 Lines • ▼ Show 20 Lines | static int palette_join_exec(bContext *C, wmOperator *op) | ||||
| palette_join = (Palette *)BKE_libblock_find_name(bmain, ID_PAL, name); | palette_join = (Palette *)BKE_libblock_find_name(bmain, ID_PAL, name); | ||||
| if (palette_join == NULL) { | if (palette_join == NULL) { | ||||
| return OPERATOR_CANCELLED; | return OPERATOR_CANCELLED; | ||||
| } | } | ||||
| const int totcol = BLI_listbase_count(&palette_join->colors); | const int totcol = BLI_listbase_count(&palette_join->colors); | ||||
| if (totcol > 0) { | if (totcol > 0) { | ||||
| for (PaletteColor *color = palette_join->colors.first; color; color = color->next) { | LISTBASE_FOREACH (PaletteColor *, color, &palette_join->colors) { | ||||
| PaletteColor *palcol = BKE_palette_color_add(palette); | PaletteColor *palcol = BKE_palette_color_add(palette); | ||||
| if (palcol) { | if (palcol) { | ||||
| copy_v3_v3(palcol->rgb, color->rgb); | copy_v3_v3(palcol->rgb, color->rgb); | ||||
| palcol->value = color->value; | palcol->value = color->value; | ||||
| done = true; | done = true; | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 828 Lines • Show Last 20 Lines | |||||