[Bf-blender-cvs] [5b2b5d177e6] greasepencil-object: Remember last Palette used
Antonio Vazquez
noreply at git.blender.org
Thu Jul 13 11:33:33 CEST 2017
Commit: 5b2b5d177e6c3affe6295f9422a7a1b2054c5291
Author: Antonio Vazquez
Date: Thu Jul 13 11:33:12 2017 +0200
Branches: greasepencil-object
https://developer.blender.org/rB5b2b5d177e6c3affe6295f9422a7a1b2054c5291
Remember last Palette used
When select a GP Object, the last palette used for drawing is selected. The palette only is selected if one stroke was drawn with this palette.
===================================================================
M source/blender/blenkernel/BKE_paint.h
M source/blender/blenkernel/intern/paint.c
M source/blender/editors/gpencil/gpencil_paint.c
M source/blender/editors/space_outliner/outliner_select.c
M source/blender/editors/space_view3d/view3d_select.c
M source/blender/editors/util/undo.c
M source/blender/makesdna/DNA_gpencil_types.h
===================================================================
diff --git a/source/blender/blenkernel/BKE_paint.h b/source/blender/blenkernel/BKE_paint.h
index 9ac3afdedf6..18411d7d00d 100644
--- a/source/blender/blenkernel/BKE_paint.h
+++ b/source/blender/blenkernel/BKE_paint.h
@@ -106,6 +106,7 @@ void BKE_palette_make_local(struct Main *bmain, struct Palette *
bool BKE_palette_is_empty(const struct Palette *palette);
void BKE_palette_clear(struct Palette *palette);
struct Palette *BKE_palette_get_active_from_context(const struct bContext *C);
+void BKE_palette_set_active_byname(const struct bContext *C, char *palname);
struct PaletteColor *BKE_palette_color_add(struct Palette *palette);
struct PaletteColor *BKE_palette_color_add_name(struct Palette *palette, const char *name);
diff --git a/source/blender/blenkernel/intern/paint.c b/source/blender/blenkernel/intern/paint.c
index 52b317d8230..63a843d2d66 100644
--- a/source/blender/blenkernel/intern/paint.c
+++ b/source/blender/blenkernel/intern/paint.c
@@ -382,6 +382,20 @@ Palette *BKE_palette_get_active_from_context(const bContext *C)
return palette;
}
+void BKE_palette_set_active_byname(const bContext *C, char *palname)
+{
+ Paint *paint = BKE_paint_get_active_from_context(C);
+ Main *bmain = CTX_data_main(C);
+
+ if (paint) {
+ Palette *palette = BLI_findstring(&bmain->palettes, palname, offsetof(ID, name));
+ if ((palette) && (paint->palette != palette)) {
+ BKE_paint_palette_set(paint, palette);
+ }
+
+ }
+}
+
PaletteColor *BKE_palette_color_get_active(Palette *palette)
{
PaletteColor *palcolor = NULL;
diff --git a/source/blender/editors/gpencil/gpencil_paint.c b/source/blender/editors/gpencil/gpencil_paint.c
index 81ab7f9f62f..68436175f61 100644
--- a/source/blender/editors/gpencil/gpencil_paint.c
+++ b/source/blender/editors/gpencil/gpencil_paint.c
@@ -1320,6 +1320,8 @@ static void gp_init_palette(tGPsdata *p)
palette->active_color = 0;
palcolor = palette->colors.first;
}
+ /* save last used palette */
+ BLI_strncpy(p->gpd->last_palette_name, palette->id.name, sizeof(p->gpd->last_palette_name));
}
/* asign to temp tGPsdata */
diff --git a/source/blender/editors/space_outliner/outliner_select.c b/source/blender/editors/space_outliner/outliner_select.c
index e95b25bdb55..251b5e7f01b 100644
--- a/source/blender/editors/space_outliner/outliner_select.c
+++ b/source/blender/editors/space_outliner/outliner_select.c
@@ -39,6 +39,7 @@
#include "DNA_scene_types.h"
#include "DNA_sequence_types.h"
#include "DNA_world_types.h"
+#include "DNA_gpencil_types.h"
#include "BLI_utildefines.h"
#include "BLI_listbase.h"
@@ -50,6 +51,7 @@
#include "BKE_sequencer.h"
#include "BKE_armature.h"
#include "BKE_workspace.h"
+#include "BKE_paint.h"
#include "DEG_depsgraph.h"
@@ -212,6 +214,10 @@ static eOLDrawState tree_element_set_active_object(
}
/* set workspace mode */
BKE_workspace_object_mode_set(CTX_wm_workspace(C), ob->mode);
+ bGPdata *gpd = ob->gpd;
+ if (gpd) {
+ BKE_palette_set_active_byname(C, gpd->last_palette_name);
+ }
}
if (ob != scene->obedit)
diff --git a/source/blender/editors/space_view3d/view3d_select.c b/source/blender/editors/space_view3d/view3d_select.c
index cbe7dd6ed56..0ad7866fb8f 100644
--- a/source/blender/editors/space_view3d/view3d_select.c
+++ b/source/blender/editors/space_view3d/view3d_select.c
@@ -44,6 +44,7 @@
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
#include "DNA_tracking_types.h"
+#include "DNA_gpencil_types.h"
#include "MEM_guardedalloc.h"
@@ -1615,8 +1616,11 @@ static bool ed_object_select_pick(
}
/* set workspace mode */
BKE_workspace_object_mode_set(CTX_wm_workspace(C), basact->object->mode);
+ bGPdata *gpd = basact->object->gpd;
+ if (gpd) {
+ BKE_palette_set_active_byname(C, gpd->last_palette_name);
+ }
}
-
}
WM_event_add_notifier(C, NC_SCENE | ND_OB_SELECT, scene);
diff --git a/source/blender/editors/util/undo.c b/source/blender/editors/util/undo.c
index 92ccee9c243..2f59ce5bf2c 100644
--- a/source/blender/editors/util/undo.c
+++ b/source/blender/editors/util/undo.c
@@ -37,6 +37,7 @@
#include "DNA_object_types.h"
#include "DNA_scene_types.h"
+#include "DNA_gpencil_types.h"
#include "BLI_utildefines.h"
@@ -48,6 +49,7 @@
#include "BKE_main.h"
#include "BKE_screen.h"
#include "BKE_workspace.h"
+#include "BKE_paint.h"
#include "ED_armature.h"
#include "ED_particle.h"
@@ -230,6 +232,10 @@ static int ed_undo_step(bContext *C, int step, const char *undoname)
}
/* set workspace mode */
BKE_workspace_object_mode_set(CTX_wm_workspace(C), obact->mode);
+ bGPdata *gpd = obact->gpd;
+ if (gpd) {
+ BKE_palette_set_active_byname(C, gpd->last_palette_name);
+ }
}
}
diff --git a/source/blender/makesdna/DNA_gpencil_types.h b/source/blender/makesdna/DNA_gpencil_types.h
index f4df5d9c150..e95fe848411 100644
--- a/source/blender/makesdna/DNA_gpencil_types.h
+++ b/source/blender/makesdna/DNA_gpencil_types.h
@@ -323,6 +323,8 @@ typedef struct bGPdata {
ListBase palettes DNA_DEPRECATED;
/* drawing manager cache */
void *batch_cache;
+ char last_palette_name[66]; /* name of the last palette used */
+ char pad[6];
} bGPdata;
/* bGPdata->flag */
More information about the Bf-blender-cvs
mailing list