Blender V5.0
overlay_name.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2024 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#pragma once
10
11#include "draw_manager_text.hh"
12
13#include "overlay_base.hh"
14
15namespace blender::draw::overlay {
16
21class Names : Overlay {
22 public:
23 void begin_sync(Resources &res, const State &state) final
24 {
25 enabled_ = state.is_space_v3d() && !res.is_selection();
26 enabled_ &= state.show_text;
27
28 if (!enabled_) {
29 return;
30 }
31 }
32
33 void object_sync(Manager & /*manager*/,
34 const ObjectRef &ob_ref,
35 Resources &res,
36 const State &state) final
37 {
38 if (!enabled_) {
39 return;
40 }
41
42 Object *ob = ob_ref.object;
43
44 if (is_from_dupli_or_set(ob)) {
45 return;
46 }
47
48 if ((ob->dtx & OB_DRAWNAME) == 0) {
49 return;
50 }
51
52 ThemeColorID theme_id = res.object_wire_theme_id(ob_ref, state);
53
54 uchar color[4];
55 /* Color Management: Exception here as texts are drawn in sRGB space directly. */
56 UI_GetThemeColor4ubv(theme_id, color);
57
59 ob->object_to_world().location(),
60 ob->id.name + 2,
61 strlen(ob->id.name + 2),
62 10,
63 0,
65 color);
66 }
67};
68
69} // namespace blender::draw::overlay
unsigned char uchar
@ OB_DRAWNAME
ThemeColorID
void UI_GetThemeColor4ubv(int colorid, unsigned char col[4])
void object_sync(Manager &, const ObjectRef &ob_ref, Resources &res, const State &state) final
void begin_sync(Resources &res, const State &state) final
void DRW_text_cache_add(DRWTextStore *dt, const float co[3], const char *str, const int str_len, short xoffs, short yoffs, short flag, const uchar col[4], const bool shadow, const bool align_center)
@ DRW_TEXT_CACHE_GLOBALSPACE
@ DRW_TEXT_CACHE_STRING_PTR
static ulong state[N]
static bool is_from_dupli_or_set(const Object *ob)
char name[258]
Definition DNA_ID.h:432