Blender V5.0
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"
16
18
19/* -------------------------------------------------------------------- */
22
24{
25 PropertyRNA *prop = RNA_struct_find_property(ptr, propname.c_str());
26
27 if (!prop || RNA_property_type(prop) != PROP_POINTER) {
28 return;
29 }
30
31 const PointerRNA cptr = RNA_property_pointer_get(ptr, prop);
32 if (!cptr.data || !RNA_struct_is_a(cptr.type, &RNA_Histogram)) {
33 return;
34 }
35 Histogram *hist = (Histogram *)cptr.data;
36
37 if (hist->height < UI_UNIT_Y) {
38 hist->height = UI_UNIT_Y;
39 }
40 else if (hist->height > UI_UNIT_Y * 20) {
41 hist->height = UI_UNIT_Y * 20;
42 }
43
44 uiLayout *col = &layout->column(true);
45 uiBlock *block = col->block();
46
47 uiDefBut(block, ButType::Histogram, 0, "", 0, 0, UI_UNIT_X * 10, hist->height, hist, 0, 0, "");
48
49 /* Resize grip. */
50 uiDefIconButI(block,
52 0,
53 ICON_GRIP,
54 0,
55 0,
56 UI_UNIT_X * 10,
57 short(UI_UNIT_Y * 0.3f),
58 &hist->height,
60 UI_UNIT_Y * 20.0f,
61 "");
62}
63
65
66/* -------------------------------------------------------------------- */
69
71{
72 PropertyRNA *prop = RNA_struct_find_property(ptr, propname.c_str());
73
74 if (!prop || RNA_property_type(prop) != PROP_POINTER) {
75 return;
76 }
77
78 const PointerRNA cptr = RNA_property_pointer_get(ptr, prop);
79 if (!cptr.data || !RNA_struct_is_a(cptr.type, &RNA_Scopes)) {
80 return;
81 }
82 Scopes *scopes = (Scopes *)cptr.data;
83
84 uiLayout *col = &layout->column(true);
85 uiBlock *block = col->block();
86
87 if (scopes->wavefrm_height < UI_UNIT_Y) {
88 scopes->wavefrm_height = UI_UNIT_Y;
89 }
90 else if (scopes->wavefrm_height > UI_UNIT_Y * 20) {
91 scopes->wavefrm_height = UI_UNIT_Y * 20;
92 }
93
94 uiDefBut(block,
96 0,
97 "",
98 0,
99 0,
100 UI_UNIT_X * 10,
101 scopes->wavefrm_height,
102 scopes,
103 0,
104 0,
105 "");
106
107 /* Resize grip. */
108 uiDefIconButI(block,
110 0,
111 ICON_GRIP,
112 0,
113 0,
114 UI_UNIT_X * 10,
115 short(UI_UNIT_Y * 0.3f),
116 &scopes->wavefrm_height,
117 UI_UNIT_Y,
118 UI_UNIT_Y * 20.0f,
119 "");
120}
121
123
124/* -------------------------------------------------------------------- */
127
129{
130 PropertyRNA *prop = RNA_struct_find_property(ptr, propname.c_str());
131
132 if (!prop || RNA_property_type(prop) != PROP_POINTER) {
133 return;
134 }
135
136 const PointerRNA cptr = RNA_property_pointer_get(ptr, prop);
137 if (!cptr.data || !RNA_struct_is_a(cptr.type, &RNA_Scopes)) {
138 return;
139 }
140 Scopes *scopes = (Scopes *)cptr.data;
141
142 if (scopes->vecscope_height < UI_UNIT_Y) {
143 scopes->vecscope_height = UI_UNIT_Y;
144 }
145 else if (scopes->vecscope_height > UI_UNIT_Y * 20) {
146 scopes->vecscope_height = UI_UNIT_Y * 20;
147 }
148
149 uiLayout *col = &layout->column(true);
150 uiBlock *block = col->block();
151
152 uiDefBut(block,
154 0,
155 "",
156 0,
157 0,
158 UI_UNIT_X * 10,
159 scopes->vecscope_height,
160 scopes,
161 0,
162 0,
163 "");
164
165 /* Resize grip. */
166 uiDefIconButI(block,
168 0,
169 ICON_GRIP,
170 0,
171 0,
172 UI_UNIT_X * 10,
173 short(UI_UNIT_Y * 0.3f),
174 &scopes->vecscope_height,
175 UI_UNIT_Y,
176 UI_UNIT_Y * 20.0f,
177 "");
178}
179
@ PROP_POINTER
Definition RNA_types.hh:167
#define UI_UNIT_Y
uiBut * uiDefIconButI(uiBlock *block, ButType 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
uiBut * uiDefBut(uiBlock *block, uiButTypeWithPointerType but_and_ptr_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)
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:4238