Fix #134152: Grease Pencil: Keyframe color missing in viewport text overlays

Use `TH_TIME_GP_KEYFRAME` theme to color the object name in viewport
when there are any keyframes on any layer.

Pull Request: https://projects.blender.org/blender/blender/pulls/134161
This commit is contained in:
Pratik Borhade
2025-02-07 10:56:32 +01:00
committed by Falk David
parent 198d07e240
commit e58b6a3279

View File

@@ -24,6 +24,7 @@
#include "BKE_context.hh"
#include "BKE_customdata.hh"
#include "BKE_global.hh"
#include "BKE_grease_pencil.hh"
#include "BKE_image.hh"
#include "BKE_key.hh"
#include "BKE_layer.hh"
@@ -1322,6 +1323,22 @@ static void draw_viewport_name(ARegion *region, View3D *v3d, int xoffset, int *y
BLF_draw_default(xoffset, *yoffset, 0.0f, name, sizeof(tmpstr));
}
static bool is_grease_pencil_with_layer_keyframe(const Object &ob)
{
if (ob.type != OB_GREASE_PENCIL) {
return false;
}
using namespace blender::bke::greasepencil;
const GreasePencil &grease_pencil = *static_cast<GreasePencil *>(ob.data);
for (const Layer *layer : grease_pencil.layers()) {
if (!layer->frames().is_empty()) {
return true;
}
}
return false;
}
/**
* Draw info beside axes in top-left corner:
* frame-number, collection, object name, bone name (if available), marker name (if available).
@@ -1424,6 +1441,10 @@ static void draw_selected_name(
}
/* color depends on whether there is a keyframe */
if (is_grease_pencil_with_layer_keyframe(*ob)) {
UI_FontThemeColor(font_id, TH_TIME_GP_KEYFRAME);
}
if (blender::animrig::id_frame_has_keyframe((ID *)ob,
/* BKE_scene_ctime_get(scene) */ float(cfra)))
{