[Bf-blender-cvs] [2f6269ca746] greasepencil-object: Merge branch 'blender2.8' into greasepencil-object
Antonio Vazquez
noreply at git.blender.org
Fri Feb 9 16:39:37 CET 2018
Commit: 2f6269ca746bdb9c77cf87173389cbf62eb10d30
Author: Antonio Vazquez
Date: Fri Feb 9 16:39:17 2018 +0100
Branches: greasepencil-object
https://developer.blender.org/rB2f6269ca746bdb9c77cf87173389cbf62eb10d30
Merge branch 'blender2.8' into greasepencil-object
Conflicts:
source/blender/blenkernel/intern/paint.c
===================================================================
===================================================================
diff --cc source/blender/blenkernel/intern/paint.c
index 9a5d9224472,81943d470dc..5e0325ac450
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@@ -41,12 -41,10 +41,13 @@@
#include "DNA_scene_types.h"
#include "DNA_brush_types.h"
#include "DNA_space_types.h"
+#include "DNA_gpencil_types.h"
+ #include "DNA_workspace_types.h"
#include "BLI_bitmap.h"
+#include "BLI_blenlib.h"
#include "BLI_utildefines.h"
+#include "BLI_string_utils.h"
#include "BLI_math_vector.h"
#include "BLI_listbase.h"
@@@ -647,59 -496,9 +644,59 @@@ bool BKE_palette_is_empty(const struct
return BLI_listbase_is_empty(&palette->colors);
}
+/* get the palettecolor looking by name */
+PaletteColor *BKE_palette_color_getbyname(Palette *palette, char *name)
+{
+ /* error checking */
+ if (ELEM(NULL, palette, name)) {
+ return NULL;
+ }
+
+ return BLI_findstring(&palette->colors, name, offsetof(PaletteColor, info));
+}
+
+/* get the palettecolor looking by rgb */
+PaletteColor *BKE_gpencil_palettecolor_getbyrgb(Palette *palette, float rgb[3])
+{
+ PaletteColor *palcolor;
+
+ /* error checking */
+ if (ELEM(NULL, palette, palette->colors.first)) {
+ return NULL;
+ }
+ /* loop over colors until found */
+ for (palcolor = palette->colors.first; palcolor; palcolor = palcolor->next) {
+ if (equals_v3v3(palcolor->rgb, rgb)) {
+ return palcolor;
+ }
+ }
+
+ /* no active color found */
+ return NULL;
+}
+
+/* get the palettecolor looking by rgba */
+PaletteColor *BKE_gpencil_palettecolor_getbyrgba(Palette *palette, float rgba[4])
+{
+ PaletteColor *palcolor;
+
+ /* error checking */
+ if (ELEM(NULL, palette, palette->colors.first)) {
+ return NULL;
+ }
+ /* loop over colors until found */
+ for (palcolor = palette->colors.first; palcolor; palcolor = palcolor->next) {
+ if (equals_v4v4(palcolor->rgb, rgba)) {
+ return palcolor;
+ }
+ }
+
+ /* no active color found */
+ return NULL;
+}
/* are we in vertex paint or weight pain face select mode? */
- bool BKE_paint_select_face_test(const EvaluationContext *eval_ctx, Object *ob)
+ bool BKE_paint_select_face_test(Object *ob, eObjectMode object_mode)
{
return ( (ob != NULL) &&
(ob->type == OB_MESH) &&
diff --cc source/blender/editors/sculpt_paint/paint_ops.c
index 6ea51b32569,c031a733630..41789319e76
--- a/source/blender/editors/sculpt_paint/paint_ops.c
+++ b/source/blender/editors/sculpt_paint/paint_ops.c
@@@ -398,469 -261,10 +398,469 @@@ static void PALETTE_OT_color_delete(wmO
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
}
+/* ********************** Isolate palette color **************************** */
+
+static int palettecolor_isolate_exec(bContext *C, wmOperator *op)
+{
+ Main *bmain = CTX_data_main(C);
+ bGPdata *gpd = ED_gpencil_data_get_active(C);
+ Palette *palette = BKE_palette_get_active_from_context(C);
+
+ PaletteColor *active_color = BKE_palette_color_get_active(palette);
+ PaletteColor *palcolor;
+
+ int flags = PC_COLOR_LOCKED;
+ bool isolate = false;
+
+ if (RNA_boolean_get(op->ptr, "affect_visibility"))
+ flags |= PC_COLOR_HIDE;
+
+ if (ELEM(NULL, gpd, active_color)) {
+ BKE_report(op->reports, RPT_ERROR, "No active color to isolate");
+ return OPERATOR_CANCELLED;
+ }
+
+ /* Test whether to isolate or clear all flags */
+ for (palcolor = palette->colors.first; palcolor; palcolor = palcolor->next) {
+ /* Skip if this is the active one */
+ if (palcolor == active_color)
+ continue;
+
+ /* If the flags aren't set, that means that the color is
+ * not alone, so we have some colors to isolate still
+ */
+ if ((palcolor->flag & flags) == 0) {
+ isolate = true;
+ break;
+ }
+ }
+
+ /* Set/Clear flags as appropriate */
+ if (isolate) {
+ /* Set flags on all "other" colors */
+ for (palcolor = palette->colors.first; palcolor; palcolor = palcolor->next) {
+ if (palcolor == active_color)
+ continue;
+ else
+ palcolor->flag |= flags;
+ }
+ }
+ else {
+ /* Clear flags - Restore everything else */
+ for (palcolor = palette->colors.first; palcolor; palcolor = palcolor->next) {
+ palcolor->flag &= ~flags;
+ }
+ }
+
+ /* notifiers */
+ BKE_gpencil_batch_cache_alldirty_main(bmain);
+ WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
+
+ return OPERATOR_FINISHED;
+}
+
+static void PALETTE_OT_palettecolor_isolate(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Isolate Palette Color";
+ ot->idname = "PALETTE_OT_palettecolor_isolate";
+ ot->description = "Toggle whether the active color is the only one that is editable and/or visible";
+
+ /* callbacks */
+ ot->exec = palettecolor_isolate_exec;
+ ot->poll = palettecolor_active_poll;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+ /* properties */
+ RNA_def_boolean(ot->srna, "affect_visibility", false, "Affect Visibility", "In addition to toggling "
+ "the editability, also affect the visibility");
+}
+
+/* *********************** Hide Palette colors ******************************** */
+
+static int palettecolor_hide_exec(bContext *C, wmOperator *op)
+{
+ Palette *palette = BKE_palette_get_active_from_context(C);
+ PaletteColor *palcolor = BKE_palette_color_get_active(palette);
+
+ bool unselected = RNA_boolean_get(op->ptr, "unselected");
+
+ /* sanity checks */
+ if (ELEM(NULL, palette, palcolor))
+ return OPERATOR_CANCELLED;
+
+ if (unselected) {
+ PaletteColor *color;
+
+ /* hide unselected */
+ for (color = palette->colors.first; color; color = color->next) {
+ if (color != palcolor) {
+ color->flag |= PC_COLOR_HIDE;
+ }
+ }
+ }
+ else {
+ /* hide selected/active */
+ palcolor->flag |= PC_COLOR_HIDE;
+ }
+
+ /* notifiers */
+ WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
+
+ return OPERATOR_FINISHED;
+}
+
+static void PALETTE_OT_palettecolor_hide(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Hide Color(s)";
+ ot->idname = "PALETTE_OT_palettecolor_hide";
+ ot->description = "Hide selected/unselected Grease Pencil colors";
+
+ /* callbacks */
+ ot->exec = palettecolor_hide_exec;
+ ot->poll = palettecolor_active_poll; /* NOTE: we need an active color to play with */
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+
+ /* props */
+ RNA_def_boolean(ot->srna, "unselected", 0, "Unselected", "Hide unselected rather than selected colors");
+}
+
+/* ********************** Show All Colors ***************************** */
+
+static int palettecolor_reveal_exec(bContext *C, wmOperator *UNUSED(op))
+{
+ Palette *palette = BKE_palette_get_active_from_context(C);
+ PaletteColor *palcolor;
+
+ /* sanity checks */
+ if (ELEM(NULL, palette))
+ return OPERATOR_CANCELLED;
+
+ /* make all colors visible */
+ for (palcolor = palette->colors.first; palcolor; palcolor = palcolor->next) {
+ palcolor->flag &= ~PC_COLOR_HIDE;
+ }
+
+ /* notifiers */
+ WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
+
+ return OPERATOR_FINISHED;
+}
+
+static void PALETTE_OT_palettecolor_reveal(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Show All Colors";
+ ot->idname = "PALETTE_OT_palettecolor_reveal";
+ ot->description = "Unhide all hidden Grease Pencil palette colors";
+
+ /* callbacks */
+ ot->exec = palettecolor_reveal_exec;
+ ot->poll = palette_active_poll;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+}
+
+/* ***************** Lock/Unlock All Palette colors ************************ */
+
+static int palettecolor_lock_all_exec(bContext *C, wmOperator *UNUSED(op))
+{
+ Palette *palette = BKE_palette_get_active_from_context(C);
+ PaletteColor *palcolor;
+
+ /* sanity checks */
+ if (ELEM(NULL, palette))
+ return OPERATOR_CANCELLED;
+
+ /* make all layers non-editable */
+ for (palcolor = palette->colors.first; palcolor; palcolor = palcolor->next) {
+ palcolor->flag |= PC_COLOR_LOCKED;
+ }
+
+ /* notifiers */
+ WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
+
+ return OPERATOR_FINISHED;
+}
+
+static void PALETTE_OT_palettecolor_lock_all(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Lock All Colors";
+ ot->idname = "PALETTE_OT_palettecolor_lock_all";
+ ot->description = "Lock all Grease Pencil colors to prevent them from being accidentally modified";
+
+ /* callbacks */
+ ot->exec = palettecolor_lock_all_exec;
+ ot->poll = palette_active_poll;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+}
+
+/* -------------------------- */
+
+static int palettecolor_unlock_all_exec(bContext *C, wmOperator *UNUSED(op))
+{
+ Palette *palette = BKE_palette_get_active_from_context(C);
+ PaletteColor *palcolor;
+
+ /* sanity checks */
+ if (ELEM(NULL, palette))
+ return OPERATOR_CANCELLED;
+
+ /* make all layers editable again*/
+ for (palcolor = palette->colors.first; palcolor; palcolor = palcolor->next) {
+ palcolor->flag &= ~PC_COLOR_LOCKED;
+ }
+
+ /* notifiers */
+ WM_event_add_notifier(C, NC_GPENCIL | ND_DATA | NA_EDITED, NULL);
+
+ return OPERATOR_FINISHED;
+}
+
+static void PALETTE_OT_palettecolor_unlock_all(wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Unlock All Colors";
+ ot->idname = "PALETTE_OT_palettecolor_unlock_all";
+ ot->description = "Unlock all Grease Pencil colors so that they can be edited";
+
+ /* callbacks */
+ ot->exec = palettecolor_unlock_all_exec;
+ ot->poll = palette_active_poll;
+
+ /* flags */
+ ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
+}
+
+/* ******************* Move Color Up/Down ************************** */
+
+enum {
+ PALETTE_COLOR_MOVE_UP = -1,
+ PALETTE_COLOR_MOVE_DOWN = 1
+};
+
+static int palettecolor_move_exec(bContext *C, wmOperator *op)
+{
+ Palette *palette = BKE_palette_get_active_from_context(C);
+ PaletteColor *palcolor = BKE_palette_color_get_active(palette);
+
+ int direction = RNA_enum_get(op->ptr, "direction");
+
+ /* sanity checks */
+ if (ELEM(NULL, palette, palcolor))
+ return OPERATOR_CANCELLED;
+
+ BLI_assert(ELEM(directi
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list