Blender V4.5
interface_template_scopes.cc
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#include "BLI_string_ref.hh"
10
11#include "RNA_access.hh"
12#include "RNA_prototypes.hh"
13
14#include "UI_interface.hh"
15
17
18/* -------------------------------------------------------------------- */
21
23{
24 PropertyRNA *prop = RNA_struct_find_property(ptr, propname.c_str());
25
26 if (!prop || RNA_property_type(prop) != PROP_POINTER) {
27 return;
28 }
29
30 const PointerRNA cptr = RNA_property_pointer_get(ptr, prop);
31 if (!cptr.data || !RNA_struct_is_a(cptr.type, &RNA_Histogram)) {
32 return;
33 }
34 Histogram *hist = (Histogram *)cptr.data;
35
36 if (hist->height < UI_UNIT_Y) {
37 hist->height = UI_UNIT_Y;
38 }
39 else if (hist->height > UI_UNIT_Y * 20) {
40 hist->height = UI_UNIT_Y * 20;
41 }
42
43 uiLayout *col = &layout->column(true);
45
46 uiDefBut(block, UI_BTYPE_HISTOGRAM, 0, "", 0, 0, UI_UNIT_X * 10, hist->height, hist, 0, 0, "");
47
48 /* Resize grip. */
49 uiDefIconButI(block,
51 0,
52 ICON_GRIP,
53 0,
54 0,
55 UI_UNIT_X * 10,
56 short(UI_UNIT_Y * 0.3f),
57 &hist->height,
59 UI_UNIT_Y * 20.0f,
60 "");
61}
62
64
65/* -------------------------------------------------------------------- */
68
70{
71 PropertyRNA *prop = RNA_struct_find_property(ptr, propname.c_str());
72
73 if (!prop || RNA_property_type(prop) != PROP_POINTER) {
74 return;
75 }
76
77 const PointerRNA cptr = RNA_property_pointer_get(ptr, prop);
78 if (!cptr.data || !RNA_struct_is_a(cptr.type, &RNA_Scopes)) {
79 return;
80 }
81 Scopes *scopes = (Scopes *)cptr.data;
82
83 uiLayout *col = &layout->column(true);
85
86 if (scopes->wavefrm_height < UI_UNIT_Y) {
87 scopes->wavefrm_height = UI_UNIT_Y;
88 }
89 else if (scopes->wavefrm_height > UI_UNIT_Y * 20) {
90 scopes->wavefrm_height = UI_UNIT_Y * 20;
91 }
92
93 uiDefBut(block,
95 0,
96 "",
97 0,
98 0,
99 UI_UNIT_X * 10,
100 scopes->wavefrm_height,
101 scopes,
102 0,
103 0,
104 "");
105
106 /* Resize grip. */
107 uiDefIconButI(block,
109 0,
110 ICON_GRIP,
111 0,
112 0,
113 UI_UNIT_X * 10,
114 short(UI_UNIT_Y * 0.3f),
115 &scopes->wavefrm_height,
116 UI_UNIT_Y,
117 UI_UNIT_Y * 20.0f,
118 "");
119}
120
122
123/* -------------------------------------------------------------------- */
126
128{
129 PropertyRNA *prop = RNA_struct_find_property(ptr, propname.c_str());
130
131 if (!prop || RNA_property_type(prop) != PROP_POINTER) {
132 return;
133 }
134
135 const PointerRNA cptr = RNA_property_pointer_get(ptr, prop);
136 if (!cptr.data || !RNA_struct_is_a(cptr.type, &RNA_Scopes)) {
137 return;
138 }
139 Scopes *scopes = (Scopes *)cptr.data;
140
141 if (scopes->vecscope_height < UI_UNIT_Y) {
142 scopes->vecscope_height = UI_UNIT_Y;
143 }
144 else if (scopes->vecscope_height > UI_UNIT_Y * 20) {
145 scopes->vecscope_height = UI_UNIT_Y * 20;
146 }
147
148 uiLayout *col = &layout->column(true);
149 uiBlock *block = uiLayoutGetBlock(col);
150
151 uiDefBut(block,
153 0,
154 "",
155 0,
156 0,
157 UI_UNIT_X * 10,
158 scopes->vecscope_height,
159 scopes,
160 0,
161 0,
162 "");
163
164 /* Resize grip. */
165 uiDefIconButI(block,
167 0,
168 ICON_GRIP,
169 0,
170 0,
171 UI_UNIT_X * 10,
172 short(UI_UNIT_Y * 0.3f),
173 &scopes->vecscope_height,
174 UI_UNIT_Y,
175 UI_UNIT_Y * 20.0f,
176 "");
177}
178
@ PROP_POINTER
Definition RNA_types.hh:155
#define UI_UNIT_Y
uiBut * uiDefBut(uiBlock *block, int type, int retval, blender::StringRef str, int x, int y, short width, short height, void *poin, float min, float max, std::optional< blender::StringRef > tip)
uiBut * uiDefIconButI(uiBlock *block, int type, int retval, int icon, int x, int y, short width, short height, int *poin, float min, float max, std::optional< blender::StringRef > tip)
#define UI_UNIT_X
@ UI_BTYPE_VECTORSCOPE
@ UI_BTYPE_HISTOGRAM
@ UI_BTYPE_WAVEFORM
@ UI_BTYPE_GRIP
uiBlock * uiLayoutGetBlock(uiLayout *layout)
constexpr const char * c_str() const
uint col
void uiTemplateHistogram(uiLayout *layout, PointerRNA *ptr, const StringRefNull propname)
void uiTemplateWaveform(uiLayout *layout, PointerRNA *ptr, const StringRefNull propname)
void uiTemplateVectorscope(uiLayout *layout, PointerRNA *ptr, const StringRefNull propname)
bool RNA_struct_is_a(const StructRNA *type, const StructRNA *srna)
PropertyRNA * RNA_struct_find_property(PointerRNA *ptr, const char *identifier)
PropertyType RNA_property_type(PropertyRNA *prop)
PointerRNA RNA_property_pointer_get(PointerRNA *ptr, PropertyRNA *prop)
StructRNA * type
Definition RNA_types.hh:52
void * data
Definition RNA_types.hh:53
int wavefrm_height
int vecscope_height
uiLayout & column(bool align)
PointerRNA * ptr
Definition wm_files.cc:4226