Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntonioya <blendergit@gmail.com>2019-03-11 19:42:45 +0300
committerAntonioya <blendergit@gmail.com>2019-03-11 19:42:45 +0300
commit057117de7869cc7adb5f82f25879f15ce18ac4dd (patch)
tree20580f0a9f52627af35d56bf0cc9a4637e77c0f9 /source/blender/draw/modes
parent84cb5f3b5cba7c3bf0d16c1d6256e24554a88cee (diff)
GPencil: Add support to display the material name in selected strokes
2D artists have requested a way to see in viewport the name of the material assigned to a stroke. This is a special request for 2D animation and required to manage complex drawings with multiple materials on it. We don't need add a separate option for this in the panel. Now, when enable Name option in the Viewport Display panel, when you select a stroke in edit mode, the name of the material is displayed near the first point selected. Design reviewed by @mendio and @pepeland
Diffstat (limited to 'source/blender/draw/modes')
-rw-r--r--source/blender/draw/modes/object_mode.c60
1 files changed, 60 insertions, 0 deletions
diff --git a/source/blender/draw/modes/object_mode.c b/source/blender/draw/modes/object_mode.c
index 3c64fe14100..1a7e9e40d6d 100644
--- a/source/blender/draw/modes/object_mode.c
+++ b/source/blender/draw/modes/object_mode.c
@@ -28,6 +28,7 @@
#include "DNA_constraint_types.h"
#include "DNA_camera_types.h"
#include "DNA_curve_types.h"
+#include "DNA_gpencil_types.h"
#include "DNA_mesh_types.h"
#include "DNA_meta_types.h"
#include "DNA_modifier_types.h"
@@ -2873,6 +2874,60 @@ static void OBJECT_cache_populate_particles(
}
}
+static void OBJECT_gpencil_color_names(Object *ob, struct DRWTextStore *dt, uchar color[4])
+{
+ if (ob->mode != OB_MODE_EDIT_GPENCIL) {
+ return;
+ }
+
+ bGPdata *gpd = (bGPdata *)ob->data;
+ if (gpd == NULL) {
+ return;
+ }
+
+ for (bGPDlayer *gpl = gpd->layers.first; gpl; gpl = gpl->next) {
+ if (gpl->flag & GP_LAYER_HIDE) {
+ continue;
+ }
+ bGPDframe *gpf = gpl->actframe;
+ if (gpf == NULL) {
+ continue;
+ }
+ for (bGPDstroke *gps = gpf->strokes.first; gps; gps = gps->next) {
+ Material *ma = give_current_material(ob, gps->mat_nr + 1);
+ if (ma == NULL) {
+ continue;
+ }
+
+ MaterialGPencilStyle *gp_style = ma->gp_style;
+ /* skip stroke if it doesn't have any valid data */
+ if ((gps->points == NULL) || (gps->totpoints < 1) || (gp_style == NULL)) {
+ continue;
+ }
+ /* check if the color is visible */
+ if (gp_style->flag & GP_STYLE_COLOR_HIDE) {
+ continue;
+ }
+
+ /* only if selected */
+ if (gps->flag & GP_STROKE_SELECT) {
+ float fpt[3];
+ for (int i = 0; i < gps->totpoints; i++) {
+ bGPDspoint *pt = &gps->points[i];
+ if (pt->flag & GP_SPOINT_SELECT) {
+ mul_v3_m4v3(fpt, ob->obmat, &pt->x);
+ DRW_text_cache_add(
+ dt, fpt,
+ ma->id.name + 2, strlen(ma->id.name + 2),
+ 10, 0, DRW_TEXT_CACHE_GLOBALSPACE | DRW_TEXT_CACHE_STRING_PTR, color);
+ break;
+ }
+ }
+ }
+ }
+ }
+}
+
static void OBJECT_cache_populate(void *vedata, Object *ob)
{
OBJECT_PassList *psl = ((OBJECT_Data *)vedata)->psl;
@@ -3143,6 +3198,11 @@ static void OBJECT_cache_populate(void *vedata, Object *ob)
dt, ob->obmat[3],
ob->id.name + 2, strlen(ob->id.name + 2),
10, 0, DRW_TEXT_CACHE_GLOBALSPACE | DRW_TEXT_CACHE_STRING_PTR, color);
+
+ /* draw grease pencil stroke names */
+ if (ob->type == OB_GPENCIL) {
+ OBJECT_gpencil_color_names(ob, dt, color);
+ }
}
if ((ob->dtx & OB_TEXSPACE) && ELEM(ob->type, OB_MESH, OB_CURVE, OB_MBALL)) {