Blender V5.3
ed_draw.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2008 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include <cmath>
10#include <cstdlib>
11#include <cstring>
12
13#include "MEM_guardedalloc.h"
14
15#include "BLI_listbase.hh"
16#include "BLI_math_vector_c.hh"
17#include "BLI_rect.hh"
18#include "BLI_string_utf8.hh"
19#include "BLI_utildefines.hh"
20
21#include "BLT_translation.hh"
22
23#include "BKE_context.hh"
24#include "BKE_global.hh"
25#include "BKE_image.hh"
26#include "BKE_screen.hh"
27
28#include "BLF_api.hh"
29
30#include "DNA_camera_types.h"
31
32#include "IMB_imbuf_types.hh"
33#include "IMB_metadata.hh"
34
35#include "ED_screen.hh"
36#include "ED_space_api.hh"
37#include "ED_util.hh"
38
39#include "GPU_immediate.hh"
40#include "GPU_matrix.hh"
41#include "GPU_state.hh"
42
43#include "UI_interface.hh"
44#include "UI_resources.hh"
45
46#include "WM_api.hh"
47#include "WM_types.hh"
48
49namespace blender {
50
51/* -------------------------------------------------------------------- */
61
62#define SLIDE_PIXEL_DISTANCE (300.0f * UI_SCALE_FAC)
63#define OVERSHOOT_RANGE_DELTA 0.2f
64#define SLIDER_UNIT_STRING_SIZE 64
65
66struct tSlider {
69
72
75
78
80 float factor;
81
83 float last_cursor[2];
84
86 float factor_bounds[2];
87
90
91 /* How the factor number is drawn. When drawing percent it is factor*100. */
93
94 /* Optional string that will display next to the slider to indicate which property is modified
95 * right now. */
96 std::string property_label;
97
98 /* What unit to add to the slider. */
100
106
110
114
117
120};
121
123 const bool facing_right,
124 const float x,
125 const float y)
126{
127 const uint shdr_pos_2d = GPU_vertformat_attr_add(
128 immVertexFormat(), "pos", gpu::VertAttrType::SFLOAT_32_32);
131 GPU_polygon_smooth(true);
133 const float triangle_side_length = facing_right ? 6 * UI_SCALE_FAC : -6 * UI_SCALE_FAC;
134 const float triangle_offset = facing_right ? 2 * UI_SCALE_FAC : -2 * UI_SCALE_FAC;
135
137 immVertex2f(shdr_pos_2d, x + triangle_offset + triangle_side_length, y);
138 immVertex2f(shdr_pos_2d, x + triangle_offset, y + triangle_side_length / 2);
139 immVertex2f(shdr_pos_2d, x + triangle_offset, y - triangle_side_length / 2);
140 immEnd();
141
142 GPU_polygon_smooth(false);
145}
146
147static void draw_ticks(const float start_factor,
148 const float end_factor,
149 const float line_start[2],
150 const float base_tick_height,
151 const float line_width,
152 const uint8_t color_overshoot[4],
153 const uint8_t color_line[4])
154{
155 /* Use factor represented as 0-100 int to avoid floating point precision problems. */
156 const int tick_increment = 10;
157
158 /* Round initial_tick_factor up to the next tick_increment. */
159 int tick_percentage = ceil((start_factor * 100) / tick_increment) * tick_increment;
160
161 while (tick_percentage <= int(end_factor * 100)) {
162 float tick_height;
163 /* Different ticks have different heights. Multiples of 100% are the tallest, 50% is a bit
164 * smaller and the rest is the minimum size. */
165 if (tick_percentage % 100 == 0) {
166 tick_height = base_tick_height;
167 }
168 else if (tick_percentage % 50 == 0) {
169 tick_height = base_tick_height * 0.8;
170 }
171 else {
172 tick_height = base_tick_height * 0.5;
173 }
174
175 const float x = line_start[0] +
176 ((float(tick_percentage) / 100) - start_factor) * SLIDE_PIXEL_DISTANCE;
177 rctf tick_rect{};
178 tick_rect.xmin = x - (line_width / 2);
179 tick_rect.xmax = x + (line_width / 2);
180 tick_rect.ymin = line_start[1] - (tick_height / 2);
181 tick_rect.ymax = line_start[1] + (tick_height / 2);
182
183 if (tick_percentage < 0 || tick_percentage > 100) {
184 ui::draw_roundbox_3ub_alpha(&tick_rect, true, 1, color_overshoot, 255);
185 }
186 else {
187 ui::draw_roundbox_3ub_alpha(&tick_rect, true, 1, color_line, 255);
188 }
189 tick_percentage += tick_increment;
190 }
191}
192
193static void draw_main_line(const rctf *main_line_rect,
194 const float factor,
195 const bool overshoot,
196 const uint8_t color_overshoot[4],
197 const uint8_t color_line[4])
198{
199 if (overshoot) {
200 /* In overshoot mode, draw the 0-100% range differently to provide a visual reference. */
201 const float line_zero_percent = main_line_rect->xmin -
202 ((factor - 0.5f - OVERSHOOT_RANGE_DELTA) *
204
205 const float clamped_line_zero_percent = clamp_f(
206 line_zero_percent, main_line_rect->xmin, main_line_rect->xmax);
207 const float clamped_line_hundred_percent = clamp_f(
208 line_zero_percent + SLIDE_PIXEL_DISTANCE, main_line_rect->xmin, main_line_rect->xmax);
209
210 rctf left_overshoot_line_rect{};
211 left_overshoot_line_rect.xmin = main_line_rect->xmin;
212 left_overshoot_line_rect.xmax = clamped_line_zero_percent;
213 left_overshoot_line_rect.ymin = main_line_rect->ymin;
214 left_overshoot_line_rect.ymax = main_line_rect->ymax;
215
216 rctf right_overshoot_line_rect{};
217 right_overshoot_line_rect.xmin = clamped_line_hundred_percent;
218 right_overshoot_line_rect.xmax = main_line_rect->xmax;
219 right_overshoot_line_rect.ymin = main_line_rect->ymin;
220 right_overshoot_line_rect.ymax = main_line_rect->ymax;
221
222 ui::draw_roundbox_3ub_alpha(&left_overshoot_line_rect, true, 0, color_overshoot, 255);
223 ui::draw_roundbox_3ub_alpha(&right_overshoot_line_rect, true, 0, color_overshoot, 255);
224
225 rctf non_overshoot_line_rect{};
226 non_overshoot_line_rect.xmin = clamped_line_zero_percent;
227 non_overshoot_line_rect.xmax = clamped_line_hundred_percent;
228 non_overshoot_line_rect.ymin = main_line_rect->ymin;
229 non_overshoot_line_rect.ymax = main_line_rect->ymax;
230 ui::draw_roundbox_3ub_alpha(&non_overshoot_line_rect, true, 0, color_line, 255);
231 }
232 else {
233 ui::draw_roundbox_3ub_alpha(main_line_rect, true, 0, color_line, 255);
234 }
235}
236
237static void draw_backdrop(const int fontid,
238 const rctf *main_line_rect,
239 const uint8_t color_bg[4],
240 const short region_y_size,
241 const float base_tick_height,
242 const std::string &property_label)
243{
244 float percent_string_pixel_size[2];
245 const char *percentage_string_placeholder = "000%%";
247 percentage_string_placeholder,
248 sizeof(percentage_string_placeholder),
249 &percent_string_pixel_size[0],
250 &percent_string_pixel_size[1]);
251
252 float property_name_pixel_size[2];
254 property_label.c_str(),
255 property_label.size(),
256 &property_name_pixel_size[0],
257 &property_name_pixel_size[1]);
258 const float pad[2] = {(region_y_size - base_tick_height) / 2 + 12.0f * UI_SCALE_FAC,
259 3.0f * UI_SCALE_FAC};
260 rctf backdrop_rect{};
261 backdrop_rect.xmin = main_line_rect->xmin - property_name_pixel_size[0] - pad[0];
262 backdrop_rect.xmax = main_line_rect->xmax + percent_string_pixel_size[0] + pad[0];
263 backdrop_rect.ymin = pad[1];
264 backdrop_rect.ymax = region_y_size - pad[1];
266 ui::draw_roundbox_3ub_alpha(&backdrop_rect, true, 4.0f, color_bg, color_bg[3]);
267}
268
272static void slider_draw(const bContext * /*C*/, ARegion *region, void *arg)
273{
274 tSlider *slider = static_cast<tSlider *>(arg);
275
276 /* Only draw in region from which the Operator was started. */
277 if (region != slider->region_header) {
278 return;
279 }
280
281 uint8_t color_text[4];
282 uint8_t color_line[4];
283 uint8_t color_handle[4];
284 uint8_t color_overshoot[4];
285 uint8_t color_bg[4];
286
287 /* Get theme colors. */
291 ui::theme::get_color_4ubv(TH_TEXT, color_overshoot);
293
294 color_overshoot[0] = color_overshoot[0] * 0.8;
295 color_overshoot[1] = color_overshoot[1] * 0.8;
296 color_overshoot[2] = color_overshoot[2] * 0.8;
297 color_bg[3] = 160;
298
299 /* Get the default font. */
300 const uiStyle *style = ui::style_get();
301 const uiFontStyle *fstyle = &style->widget;
302 const int fontid = fstyle->uifont_id;
303 BLF_color3ubv(fontid, color_text);
304 BLF_rotation(fontid, 0.0f);
305
306 const float line_width = 1.5 * UI_SCALE_FAC;
307 const float base_tick_height = 12.0 * UI_SCALE_FAC;
308 const float line_y = region->winy / 2;
309
310 rctf main_line_rect{};
311 main_line_rect.xmin = (region->winx / 2) - (SLIDE_PIXEL_DISTANCE / 2);
312 main_line_rect.xmax = (region->winx / 2) + (SLIDE_PIXEL_DISTANCE / 2);
313 main_line_rect.ymin = line_y - line_width / 2;
314 main_line_rect.ymax = line_y + line_width / 2;
315
316 float line_start_factor = 0;
317 int handle_pos_x;
318 if (slider->overshoot) {
319 main_line_rect.xmin = main_line_rect.xmin - SLIDE_PIXEL_DISTANCE * OVERSHOOT_RANGE_DELTA;
320 main_line_rect.xmax = main_line_rect.xmax + SLIDE_PIXEL_DISTANCE * OVERSHOOT_RANGE_DELTA;
321 line_start_factor = slider->factor - 0.5f - OVERSHOOT_RANGE_DELTA;
322 handle_pos_x = region->winx / 2;
323 }
324 else {
325 const float total_range = slider->factor_bounds[1] - slider->factor_bounds[0];
326 /* 0-1 value of the representing the position of the slider in the allowed range. */
327 const float range_factor = (slider->factor - slider->factor_bounds[0]) / total_range;
328 handle_pos_x = main_line_rect.xmin + SLIDE_PIXEL_DISTANCE * range_factor;
329 }
330
331 draw_backdrop(fontid,
332 &main_line_rect,
333 color_bg,
334 slider->region_header->winy,
335 base_tick_height,
336 slider->property_label);
337
338 draw_main_line(&main_line_rect, slider->factor, slider->overshoot, color_overshoot, color_line);
339
340 const float factor_range = slider->overshoot ? 1 + OVERSHOOT_RANGE_DELTA * 2 : 1;
341 const float line_start_position[2] = {main_line_rect.xmin, line_y};
342 draw_ticks(line_start_factor,
343 line_start_factor + factor_range,
344 line_start_position,
345 base_tick_height,
346 line_width,
347 color_overshoot,
348 color_line);
349
350 /* Draw triangles at the ends of the line in overshoot mode to indicate direction of 0-100%
351 * range. */
352 if (slider->overshoot) {
353 if (slider->factor > 1 + OVERSHOOT_RANGE_DELTA + 0.5) {
354 draw_overshoot_triangle(color_line, false, main_line_rect.xmin, line_y);
355 }
356 if (slider->factor < 0 - OVERSHOOT_RANGE_DELTA - 0.5) {
357 draw_overshoot_triangle(color_line, true, main_line_rect.xmax, line_y);
358 }
359 }
360
361 /* Draw handle indicating current factor. */
362 rctf handle_rect{};
363 handle_rect.xmin = handle_pos_x - (line_width);
364 handle_rect.xmax = handle_pos_x + (line_width);
365 handle_rect.ymin = line_y - (base_tick_height / 2);
366 handle_rect.ymax = line_y + (base_tick_height / 2);
367
368 ui::draw_roundbox_3ub_alpha(&handle_rect, true, 1, color_handle, 255);
369
370 char factor_string[256];
371 switch (slider->slider_mode) {
373 SNPRINTF_UTF8(factor_string, "%.0f %s", slider->factor * 100, slider->unit_string);
374 break;
376 SNPRINTF_UTF8(factor_string, "%.1f %s", slider->factor, slider->unit_string);
377 break;
378 }
379
380 /* Draw factor string. */
381 float factor_string_pixel_size[2];
383 factor_string,
384 sizeof(factor_string),
385 &factor_string_pixel_size[0],
386 &factor_string_pixel_size[1]);
387
388 const float text_padding = 12.0 * UI_SCALE_FAC;
389 const float factor_string_pos_x = main_line_rect.xmax + text_padding;
391 fontid, factor_string_pos_x, (region->winy / 2) - factor_string_pixel_size[1] / 2, 0.0f);
392 BLF_draw(fontid, factor_string, sizeof(factor_string));
393
394 if (!slider->property_label.empty()) {
395 float property_name_pixel_size[2];
397 slider->property_label.c_str(),
398 slider->property_label.length(),
399 &property_name_pixel_size[0],
400 &property_name_pixel_size[1]);
401 BLF_position(fontid,
402 main_line_rect.xmin - text_padding - property_name_pixel_size[0],
403 (region->winy / 2) - property_name_pixel_size[1] / 2,
404 0.0f);
405 BLF_draw(fontid, slider->property_label.c_str(), slider->property_label.length());
406 }
407}
408
409static void slider_update_factor(tSlider *slider, const wmEvent *event)
410{
411 /* Normalize so no matter the factor bounds, the mouse distance traveled from min to max is
412 * constant. */
413 const float slider_range = slider->factor_bounds[1] - slider->factor_bounds[0];
414 const float factor_delta = (event->xy[0] - slider->last_cursor[0]) /
415 (SLIDE_PIXEL_DISTANCE / slider_range);
416 /* Reduced factor delta in precision mode (shift held). */
417 slider->raw_factor += slider->precision ? (factor_delta / 8) : factor_delta;
418 slider->factor = slider->raw_factor;
419 copy_v2fl_v2i(slider->last_cursor, event->xy);
420
421 if (slider->increments) {
422 slider->factor = round(slider->factor / slider->increment_step) * slider->increment_step;
423 }
424
425 if (!slider->overshoot) {
426 slider->factor = clamp_f(slider->factor, slider->factor_bounds[0], slider->factor_bounds[1]);
427 }
428 else {
429 if (!slider->allow_overshoot_lower) {
430 slider->factor = max_ff(slider->factor, slider->factor_bounds[0]);
431 }
432 if (!slider->allow_overshoot_upper) {
433 slider->factor = min_ff(slider->factor, slider->factor_bounds[1]);
434 }
435 }
436}
437
439{
440 tSlider *slider = MEM_new<tSlider>(__func__);
441 slider->scene = CTX_data_scene(C);
442 slider->area = CTX_wm_area(C);
443 slider->region_header = CTX_wm_region(C);
444
445 /* Default is true, caller needs to manually set to false. */
446 slider->allow_overshoot_lower = true;
447 slider->allow_overshoot_upper = true;
448 slider->allow_increments = true;
449
450 slider->factor_bounds[0] = 0;
451 slider->factor_bounds[1] = 1;
452
453 slider->unit_string[0] = '%';
454
456
457 /* Set initial factor. */
458 slider->raw_factor = 0.5f;
459 slider->factor = 0.5;
460
461 slider->increment_step = 0.1f;
462
463 /* Add draw callback. Always in header. */
464 if (slider->area) {
465 for (ARegion &region : slider->area->regionbase) {
466 /* Keep logic in sync with ED_area_status_text. */
467 if (region.regiontype == RGN_TYPE_HEADER && region.runtime->visible) {
468 slider->region_header = &region;
469 /* Hide the area menu bar contents, as the slider will be drawn on top. Only for the header
470 * since the tool header is already empty in the center.*/
471 ED_area_status_text(slider->area, "");
472 }
473 else if (region.regiontype == RGN_TYPE_TOOL_HEADER && region.runtime->visible) {
474 slider->region_header = &region;
475 break;
476 }
477 }
478 if (slider->region_header && !G.background) {
481 }
482 }
483
484 return slider;
485}
486
487void ED_slider_init(tSlider *slider, const wmEvent *event)
488{
489 copy_v2fl_v2i(slider->last_cursor, event->xy);
490}
491
492bool ED_slider_modal(tSlider *slider, const wmEvent *event)
493{
494 bool event_handled = true;
495 /* Handle key presses. */
496 switch (event->type) {
497 case EVT_EKEY:
498 if (slider->allow_overshoot_lower || slider->allow_overshoot_upper) {
499 slider->overshoot = event->val == KM_PRESS ? !slider->overshoot : slider->overshoot;
500 slider_update_factor(slider, event);
501 }
502 break;
503 case EVT_LEFTSHIFTKEY:
505 slider->precision = event->val == KM_PRESS;
506 break;
507 case EVT_LEFTCTRLKEY:
508 case EVT_RIGHTCTRLKEY:
509 slider->increments = slider->allow_increments && event->val == KM_PRESS;
510 break;
511 case MOUSEMOVE:;
512 /* Update factor. */
513 slider_update_factor(slider, event);
514 break;
515 default:
516 event_handled = false;
517 break;
518 }
519
521
522 return event_handled;
523}
524
526 char *status_string,
527 const size_t size_of_status_string)
528{
529 /* 50 characters is enough to fit the individual setting strings. Extend if message is longer. */
530 char overshoot_str[50];
531 char precision_str[50];
532 char increments_str[50];
533
534 if (slider->allow_overshoot_lower || slider->allow_overshoot_upper) {
535 if (slider->overshoot) {
536 STRNCPY_UTF8(overshoot_str, IFACE_("[E] - Disable overshoot"));
537 }
538 else {
539 STRNCPY_UTF8(overshoot_str, IFACE_("[E] - Enable overshoot"));
540 }
541 }
542 else {
543 STRNCPY_UTF8(overshoot_str, IFACE_("Overshoot disabled"));
544 }
545
546 if (slider->precision) {
547 STRNCPY_UTF8(precision_str, IFACE_("[Shift] - Precision active"));
548 }
549 else {
550 STRNCPY_UTF8(precision_str, IFACE_("Shift - Hold for precision"));
551 }
552
553 if (slider->allow_increments) {
554 if (slider->increments) {
555 STRNCPY_UTF8(increments_str, IFACE_(" | [Ctrl] - Increments active"));
556 }
557 else {
558 STRNCPY_UTF8(increments_str, IFACE_(" | Ctrl - Hold for increments"));
559 }
560 }
561 else {
562 increments_str[0] = '\0';
563 }
564
565 BLI_snprintf_utf8(status_string,
566 size_of_status_string,
567 "%s | %s%s",
568 overshoot_str,
569 precision_str,
570 increments_str);
571}
572
573void ED_slider_status_get(const tSlider *slider, WorkspaceStatus &status)
574{
575 if (slider->allow_overshoot_lower || slider->allow_overshoot_upper) {
576 status.item_bool(IFACE_("Overshoot"), slider->overshoot, ICON_EVENT_E);
577 }
578 else {
579 status.item(IFACE_("Overshoot Disabled"), ICON_STATUS_INFO);
580 }
581
582 status.item_bool(IFACE_("Precision"), slider->precision, ICON_EVENT_SHIFT);
583
584 if (slider->allow_increments) {
585 status.item_bool(IFACE_("Snap"), slider->increments, ICON_EVENT_CTRL);
586 }
587}
588
590{
591 /* Remove draw callback. */
592 if (slider->draw_handle) {
594 }
595 ED_area_status_text(slider->area, nullptr);
596 ED_workspace_status_text(C, nullptr);
597 MEM_delete(slider);
598}
599
600/* Setters & Getters */
601
602float ED_slider_factor_get(const tSlider *slider)
603{
604 return slider->factor;
605}
606
607void ED_slider_factor_set(tSlider *slider, const float factor)
608{
609 slider->raw_factor = factor;
610 slider->factor = factor;
611 if (!slider->overshoot) {
612 slider->factor = clamp_f(slider->factor, slider->factor_bounds[0], slider->factor_bounds[1]);
613 }
614}
615
616void ED_slider_increment_step_set(tSlider *slider, const float increment_step)
617{
618 if (increment_step == 0) {
619 /* Because this value is used as a divisor, it cannot be 0. */
621 return;
622 }
623 slider->increment_step = increment_step;
624}
625
626void ED_slider_allow_overshoot_set(tSlider *slider, const bool lower, const bool upper)
627{
628 slider->allow_overshoot_lower = lower;
629 slider->allow_overshoot_upper = upper;
630}
631
633{
634 return slider->allow_increments;
635}
636
637void ED_slider_allow_increments_set(tSlider *slider, const bool value)
638{
639 slider->allow_increments = value;
640}
641
643 float factor_bound_lower,
644 float factor_bound_upper)
645{
646 slider->factor_bounds[0] = factor_bound_lower;
647 slider->factor_bounds[1] = factor_bound_upper;
648}
649
651{
652 slider->slider_mode = mode;
653}
654
656{
657 return slider->slider_mode;
658}
659
660void ED_slider_unit_set(tSlider *slider, const char *unit)
661{
662 STRNCPY_UTF8(slider->unit_string, unit);
663}
664
665void ED_slider_property_label_set(tSlider *slider, const char *property_label)
666{
667 slider->property_label.assign(property_label);
668}
669
671
672void ED_region_draw_mouse_line_cb(const bContext *C, ARegion *region, void *arg_info)
673{
674 wmWindow *win = CTX_wm_window(C);
675 const float *mval_src = static_cast<float *>(arg_info);
676 const float mval_dst[2] = {
677 float(win->runtime->eventstate->xy[0] - region->winrct.xmin),
678 float(win->runtime->eventstate->xy[1] - region->winrct.ymin),
679 };
680
681 const uint shdr_pos = GPU_vertformat_attr_add(
682 immVertexFormat(), "pos", gpu::VertAttrType::SFLOAT_32_32);
683
684 GPU_line_width(1.0f);
685
687
688 float viewport_size[4];
689 GPU_viewport_size_get_f(viewport_size);
690 immUniform2f("viewport_size", viewport_size[2] / UI_SCALE_FAC, viewport_size[3] / UI_SCALE_FAC);
691
692 immUniform1i("colors_len", 0); /* "simple" mode */
694 immUniform1f("dash_width", 6.0f);
695 immUniform1f("udash_factor", 0.5f);
696
698 immVertex2fv(shdr_pos, mval_src);
699 immVertex2fv(shdr_pos, mval_dst);
700 immEnd();
701
703}
704
705#define MAX_METADATA_STR 1024
706
707static const char *meta_data_list[] = {
708 "File",
709 "Strip",
710 "Date",
711 "RenderTime",
712 "Note",
713 "Marker",
714 "Time",
715 "Frame",
716 "Camera",
717 "Scene",
718};
719
720BLI_INLINE bool metadata_is_valid(const ImBuf *ibuf, char *r_str, short index, int offset)
721{
722 return (
724 ibuf->metadata(), meta_data_list[index], r_str + offset, MAX_METADATA_STR - offset) &&
725 r_str[0]);
726}
727
729{
730 /* Metadata field stored by Blender for multi-layer EXR images. Is rather
731 * useless to be viewed all the time. Can still be seen in the Metadata
732 * panel. */
733 if (STREQ(field, "BlenderMultiChannel")) {
734 return false;
735 }
736 /* Is almost always has value "scanlineimage", also useless to be seen
737 * all the time. */
738 if (STREQ(field, "type")) {
739 return false;
740 }
741 return !BKE_stamp_is_known_field(field);
742}
743
750
751static void metadata_custom_draw_fields(const char *field, const char *value, void *ctx_v)
752{
753 if (!metadata_is_custom_drawable(field)) {
754 return;
755 }
756 MetadataCustomDrawContext *ctx = static_cast<MetadataCustomDrawContext *>(ctx_v);
757 char temp_str[MAX_METADATA_STR];
758 SNPRINTF_UTF8(temp_str, "%s: %s", field, value);
759 BLF_position(ctx->fontid, ctx->xmin, ctx->ymin + ctx->current_y, 0.0f);
760 BLF_draw(ctx->fontid, temp_str, sizeof(temp_str));
761 ctx->current_y += ctx->vertical_offset;
762}
763
764static void metadata_draw_imbuf(const ImBuf *ibuf, const rctf *rect, int fontid, const bool is_top)
765{
766 char temp_str[MAX_METADATA_STR];
767 int ofs_y = 0;
768 const float height = BLF_height_max(fontid);
769 const float margin = height / 8;
770 const float vertical_offset = (height + margin);
771
772 /* values taking margins into account */
773 const float descender = BLF_descender(fontid);
774 const float xmin = (rect->xmin + margin);
775 const float xmax = (rect->xmax - margin);
776 const float ymin = (rect->ymin + margin) - descender;
777 const float ymax = (rect->ymax - margin) - descender;
778
779 if (is_top) {
780 for (int i = 0; i < 4; i++) {
781 /* first line */
782 if (i == 0) {
783 bool do_newline = false;
784 int len = SNPRINTF_UTF8_RLEN(temp_str, "%s: ", meta_data_list[0]);
785 if (metadata_is_valid(ibuf, temp_str, 0, len)) {
786 BLF_position(fontid, xmin, ymax - vertical_offset, 0.0f);
787 BLF_draw(fontid, temp_str, sizeof(temp_str));
788 do_newline = true;
789 }
790
791 len = SNPRINTF_UTF8_RLEN(temp_str, "%s: ", meta_data_list[1]);
792 if (metadata_is_valid(ibuf, temp_str, 1, len)) {
793 int line_width = BLF_width(fontid, temp_str, sizeof(temp_str));
794 BLF_position(fontid, xmax - line_width, ymax - vertical_offset, 0.0f);
795 BLF_draw(fontid, temp_str, sizeof(temp_str));
796 do_newline = true;
797 }
798
799 if (do_newline) {
800 ofs_y += vertical_offset;
801 }
802 } /* Strip */
803 else if (ELEM(i, 1, 2)) {
804 int len = SNPRINTF_UTF8_RLEN(temp_str, "%s: ", meta_data_list[i + 1]);
805 if (metadata_is_valid(ibuf, temp_str, i + 1, len)) {
806 BLF_position(fontid, xmin, ymax - vertical_offset - ofs_y, 0.0f);
807 BLF_draw(fontid, temp_str, sizeof(temp_str));
808 ofs_y += vertical_offset;
809 }
810 } /* Note (wrapped) */
811 else if (i == 3) {
812 int len = SNPRINTF_UTF8_RLEN(temp_str, "%s: ", meta_data_list[i + 1]);
813 if (metadata_is_valid(ibuf, temp_str, i + 1, len)) {
814 ResultBLF info;
815 BLF_enable(fontid, BLF_WORD_WRAP);
816 BLF_wordwrap(fontid, ibuf->x - (margin * 2));
817 BLF_position(fontid, xmin, ymax - vertical_offset - ofs_y, 0.0f);
818 BLF_draw(fontid, temp_str, sizeof(temp_str), &info);
819 BLF_wordwrap(fontid, 0);
820 BLF_disable(fontid, BLF_WORD_WRAP);
821 ofs_y += vertical_offset * info.lines;
822 }
823 }
824 else {
825 int len = SNPRINTF_UTF8_RLEN(temp_str, "%s: ", meta_data_list[i + 1]);
826 if (metadata_is_valid(ibuf, temp_str, i + 1, len)) {
827 int line_width = BLF_width(fontid, temp_str, sizeof(temp_str));
828 BLF_position(fontid, xmax - line_width, ymax - vertical_offset - ofs_y, 0.0f);
829 BLF_draw(fontid, temp_str, sizeof(temp_str));
830 ofs_y += vertical_offset;
831 }
832 }
833 }
834 }
835 else {
837 ctx.fontid = fontid;
838 ctx.xmin = xmin;
839 ctx.ymin = ymin;
840 ctx.current_y = ofs_y;
841 ctx.vertical_offset = vertical_offset;
843 int ofs_x = 0;
844 ofs_y = ctx.current_y;
845 for (int i = 5; i < 10; i++) {
846 int len = SNPRINTF_UTF8_RLEN(temp_str, "%s: ", meta_data_list[i]);
847 if (metadata_is_valid(ibuf, temp_str, i, len)) {
848 BLF_position(fontid, xmin + ofs_x, ymin + ofs_y, 0.0f);
849 BLF_draw(fontid, temp_str, sizeof(temp_str));
850
851 ofs_x += BLF_width(fontid, temp_str, sizeof(temp_str)) + UI_UNIT_X;
852 }
853 }
854 }
855}
856
860
861static void metadata_custom_count_fields(const char *field, const char * /*value*/, void *ctx_v)
862{
863 if (!metadata_is_custom_drawable(field)) {
864 return;
865 }
866 MetadataCustomCountContext *ctx = static_cast<MetadataCustomCountContext *>(ctx_v);
867 ctx->count++;
868}
869
870static float metadata_box_height_get(const ImBuf *ibuf, int fontid, const bool is_top)
871{
872 const float height = BLF_height_max(fontid);
873 const float margin = (height / 8);
874 char str[MAX_METADATA_STR] = "";
875 short count = 0;
876
877 if (is_top) {
878 if (metadata_is_valid(ibuf, str, 0, 0) || metadata_is_valid(ibuf, str, 1, 0)) {
879 count++;
880 }
881 for (int i = 2; i < 5; i++) {
882 if (metadata_is_valid(ibuf, str, i, 0)) {
883 if (i == 4) {
884 struct {
885 ResultBLF info;
886 rcti rect;
887 } wrap;
888
889 BLF_enable(fontid, BLF_WORD_WRAP);
890 BLF_wordwrap(fontid, ibuf->x - (margin * 2));
891 BLF_boundbox(fontid, str, sizeof(str), &wrap.rect, &wrap.info);
892 BLF_wordwrap(fontid, 0);
893 BLF_disable(fontid, BLF_WORD_WRAP);
894
895 count += wrap.info.lines;
896 }
897 else {
898 count++;
899 }
900 }
901 }
902 }
903 else {
904 for (int i = 5; i < 10; i++) {
905 if (metadata_is_valid(ibuf, str, i, 0)) {
906 count = 1;
907 break;
908 }
909 }
911 ctx.count = 0;
913 count += ctx.count;
914 }
915
916 if (count) {
917 return (height + margin) * count;
918 }
919
920 return 0;
921}
922
923static void text_info_row(const char *text,
924 const int text_len,
925 int col1,
926 int col2,
927 int row,
928 const int size_x,
929 const int size_y)
930{
931 const int font_id = BLF_default();
932 float text_color[4];
933
935 BLF_color4fv(font_id, text_color);
936
937 /* Ensure text is visible against bright background. */
938 const float shadow_color[4] = {0.0f, 0.0f, 0.0f, 0.8f};
939 BLF_enable(font_id, BLF_SHADOW);
940 BLF_shadow_offset(font_id, 0, 0);
941 BLF_shadow(font_id, FontShadowType::Outline, shadow_color);
942
943 BLF_position(font_id, col1, row, 0.0f);
944 BLF_draw(font_id, text, text_len);
945 BLF_position(font_id, col2, row, 0.0f);
946 char draw_text[MAX_NAME];
947 SNPRINTF_UTF8(draw_text, "%d x %d", size_x, size_y);
948 BLF_draw(font_id, draw_text, sizeof(draw_text));
949
950 BLF_disable(font_id, BLF_SHADOW);
951}
952
953void ED_region_overlay_info_text_draw(const int render_size_x,
954 const int render_size_y,
955 const int viewer_size_x,
956 const int viewer_size_y,
957 const int draw_offset_x,
958 const int draw_offset_y)
959{
961 const int font_id = BLF_default();
962 int overlay_lineheight = (ui::style_get()->widget.points * UI_SCALE_FAC * 1.6f);
963
964 const StringRef render_size_name = IFACE_("Render Size");
965 const StringRef viewer_size_name = IFACE_("Image Size");
966
967 const int render_size_width = BLF_width(font_id, render_size_name.data(), MAX_NAME);
968 const int viewer_size_width = BLF_width(font_id, viewer_size_name.data(), MAX_NAME);
969 int longest_label = max_ii(render_size_width, viewer_size_width);
970
971 int col1 = draw_offset_x;
972 int col2 = draw_offset_x + longest_label + (0.5 * U.widget_unit);
973
974 text_info_row(render_size_name.data(),
975 render_size_name.size(),
976 col1,
977 col2,
978 draw_offset_y - overlay_lineheight,
979 render_size_x,
980 render_size_y);
981
982 text_info_row(viewer_size_name.data(),
983 viewer_size_name.size(),
984 col1,
985 col2,
986 draw_offset_y - overlay_lineheight * 2,
987 viewer_size_x,
988 viewer_size_y);
989}
990
992 int x, int y, const rcti *frame, float zoomx, float zoomy, float passepartout_alpha)
993{
995
996 /* Offset and zoom using GPU viewport. */
997 const auto frame_width = BLI_rcti_size_x(frame);
998 const auto frame_height = BLI_rcti_size_y(frame);
1000 GPU_matrix_scale_2f(zoomx, zoomy);
1001
1002 GPUVertFormat *format = immVertexFormat();
1003 uint pos = GPU_vertformat_attr_add(format, "pos", gpu::VertAttrType::SFLOAT_32_32);
1004
1007
1008 const float x1 = frame->xmin - frame_width / 2;
1009 const float x2 = frame->xmax - frame_width / 2;
1010 const float y1 = frame->ymin - frame_height / 2;
1011 const float y2 = frame->ymax - frame_height / 2;
1012
1013 /* Darken the area outside the frame. */
1014 if (passepartout_alpha > 0) {
1015 /* Using a sufficiently large number instead of numeric_limits::infinity(), to avoid comparison
1016 * issues and different behavior around large numbers on different platforms. */
1017 constexpr float inf = 10e5;
1018 immUniformColor4f(0.0f, 0.0f, 0.0f, passepartout_alpha);
1019 immRectf(pos, -inf, y2, inf, inf);
1020 immRectf(pos, -inf, y1, inf, -inf);
1021 immRectf(pos, -inf, y1, x1, y2);
1022 immRectf(pos, x2, y1, inf, y2);
1023 }
1024
1025 float wire_color[3];
1026 ui::theme::get_color_3fv(TH_TEXT, wire_color);
1027 immUniformColor4f(wire_color[0], wire_color[1], wire_color[2], 1);
1028
1029 /* The bounding box must be drawn last to ensure it remains visible
1030 * when passepartout_alpha > 0. */
1031 imm_draw_box_wire_2d(pos, x1, y1, x2, y2);
1032
1035
1037}
1038
1040 int x, int y, const ImBuf *ibuf, const rctf *frame, float zoomx, float zoomy)
1041{
1042 const uiStyle *style = ui::style_get_dpi();
1043
1044 if (!ibuf->metadata()) {
1045 return;
1046 }
1047
1048 /* find window pixel coordinates of origin */
1050
1051 /* Offset and zoom using GPU viewport. */
1053 GPU_matrix_scale_2f(zoomx, zoomy);
1054
1056
1057 /* *** upper box*** */
1058
1059 /* get needed box height */
1060 float box_y = metadata_box_height_get(ibuf, blf_mono_font, true);
1061
1062 if (box_y) {
1063 /* set up rect */
1064 rctf rect;
1065 BLI_rctf_init(&rect, frame->xmin, frame->xmax, frame->ymax, frame->ymax + box_y);
1066 /* draw top box */
1067 GPUVertFormat *format = immVertexFormat();
1068 uint pos = GPU_vertformat_attr_add(format, "pos", gpu::VertAttrType::SFLOAT_32_32);
1071 immRectf(pos, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
1073
1074 BLF_clipping(blf_mono_font, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
1076
1078 metadata_draw_imbuf(ibuf, &rect, blf_mono_font, true);
1079
1081 }
1082
1083 /* *** lower box*** */
1084
1085 box_y = metadata_box_height_get(ibuf, blf_mono_font, false);
1086
1087 if (box_y) {
1088 /* set up box rect */
1089 rctf rect;
1090 BLI_rctf_init(&rect, frame->xmin, frame->xmax, frame->ymin - box_y, frame->ymin);
1091 /* draw top box */
1092 GPUVertFormat *format = immVertexFormat();
1093 uint pos = GPU_vertformat_attr_add(format, "pos", gpu::VertAttrType::SFLOAT_32_32);
1096 immRectf(pos, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
1098
1099 BLF_clipping(blf_mono_font, rect.xmin, rect.ymin, rect.xmax, rect.ymax);
1101
1103 metadata_draw_imbuf(ibuf, &rect, blf_mono_font, false);
1104
1106 }
1107
1109}
1110
1111/* -------------------------------------------------------------------- */
1114
1115#define M_GOLDEN_RATIO_CONJUGATE 0.618033988749895f
1116
1117static void drawviewborder_grid3(uint shdr_pos, rctf rect, float fac)
1118{
1119 float x3, y3, x4, y4;
1120
1121 x3 = rect.xmin + fac * (rect.xmax - rect.xmin);
1122 y3 = rect.ymin + fac * (rect.ymax - rect.ymin);
1123 x4 = rect.xmin + (1.0f - fac) * (rect.xmax - rect.xmin);
1124 y4 = rect.ymin + (1.0f - fac) * (rect.ymax - rect.ymin);
1125
1127
1128 immVertex2f(shdr_pos, rect.xmin, y3);
1129 immVertex2f(shdr_pos, rect.xmax, y3);
1130
1131 immVertex2f(shdr_pos, rect.xmin, y4);
1132 immVertex2f(shdr_pos, rect.xmax, y4);
1133
1134 immVertex2f(shdr_pos, x3, rect.ymin);
1135 immVertex2f(shdr_pos, x3, rect.ymax);
1136
1137 immVertex2f(shdr_pos, x4, rect.ymin);
1138 immVertex2f(shdr_pos, x4, rect.ymax);
1139
1140 immEnd();
1141}
1142
1144static void drawviewborder_triangle(uint shdr_pos, rctf rect, const bool golden, const char dir)
1145{
1146 float ofs;
1147 float w = rect.xmax - rect.xmin;
1148 float h = rect.ymax - rect.ymin;
1149
1151
1152 if (w > h) {
1153 if (golden) {
1154 ofs = w * (1.0f - M_GOLDEN_RATIO_CONJUGATE);
1155 }
1156 else {
1157 ofs = h * (h / w);
1158 }
1159 if (dir == 'B') {
1160 std::swap(rect.ymin, rect.ymax);
1161 }
1162
1163 immVertex2f(shdr_pos, rect.xmin, rect.ymin);
1164 immVertex2f(shdr_pos, rect.xmax, rect.ymax);
1165
1166 immVertex2f(shdr_pos, rect.xmax, rect.ymin);
1167 immVertex2f(shdr_pos, rect.xmin + (w - ofs), rect.ymax);
1168
1169 immVertex2f(shdr_pos, rect.xmin, rect.ymax);
1170 immVertex2f(shdr_pos, rect.xmin + ofs, rect.ymin);
1171 }
1172 else {
1173 if (golden) {
1174 ofs = h * (1.0f - M_GOLDEN_RATIO_CONJUGATE);
1175 }
1176 else {
1177 ofs = w * (w / h);
1178 }
1179 if (dir == 'B') {
1180 std::swap(rect.xmin, rect.xmax);
1181 }
1182
1183 immVertex2f(shdr_pos, rect.xmin, rect.ymin);
1184 immVertex2f(shdr_pos, rect.xmax, rect.ymax);
1185
1186 immVertex2f(shdr_pos, rect.xmax, rect.ymin);
1187 immVertex2f(shdr_pos, rect.xmin, rect.ymin + ofs);
1188
1189 immVertex2f(shdr_pos, rect.xmin, rect.ymax);
1190 immVertex2f(shdr_pos, rect.xmax, rect.ymin + (h - ofs));
1191 }
1192
1193 immEnd();
1194}
1195
1198 const rctf *rect,
1199 const float color[4])
1200{
1202
1203 if (flag & COMPOSITION_GUIDES_CENTER) {
1204 float xmid, ymid;
1205
1206 xmid = rect->xmin + 0.5f * (rect->xmax - rect->xmin);
1207 ymid = rect->ymin + 0.5f * (rect->ymax - rect->ymin);
1208
1210
1211 immVertex2f(shdr_pos, rect->xmin, ymid);
1212 immVertex2f(shdr_pos, rect->xmax, ymid);
1213
1214 immVertex2f(shdr_pos, xmid, rect->ymin);
1215 immVertex2f(shdr_pos, xmid, rect->ymax);
1216
1217 immEnd();
1218 }
1219
1220 if (flag & COMPOSITION_GUIDES_CENTER_DIAG) {
1222
1223 immVertex2f(shdr_pos, rect->xmin, rect->ymin);
1224 immVertex2f(shdr_pos, rect->xmax, rect->ymax);
1225
1226 immVertex2f(shdr_pos, rect->xmin, rect->ymax);
1227 immVertex2f(shdr_pos, rect->xmax, rect->ymin);
1228
1229 immEnd();
1230 }
1231
1232 if (flag & COMPOSITION_GUIDES_THIRDS) {
1233 drawviewborder_grid3(shdr_pos, *rect, 1.0f / 3.0f);
1234 }
1235
1236 if (flag & COMPOSITION_GUIDES_GOLDEN) {
1237 drawviewborder_grid3(shdr_pos, *rect, 1.0f - M_GOLDEN_RATIO_CONJUGATE);
1238 }
1239
1241 drawviewborder_triangle(shdr_pos, *rect, false, 'A');
1242 }
1243
1245 drawviewborder_triangle(shdr_pos, *rect, false, 'B');
1246 }
1247
1249 drawviewborder_triangle(shdr_pos, *rect, true, 'A');
1250 }
1251
1253 drawviewborder_triangle(shdr_pos, *rect, true, 'B');
1254 }
1255}
1256
1258
1259#undef MAX_METADATA_STR
1260
1261} // namespace blender
#define SNPRINTF_UTF8(dst, format,...)
#define SNPRINTF_UTF8_RLEN(dst, format,...)
#define STRNCPY_UTF8(dst, src)
#define IFACE_(msgid)
#define MAX_NAME
Definition DNA_defs.h:63
#define UI_SCALE_FAC
#define REGION_DRAW_POST_PIXEL
Read Blender memory allocation and freeing.
#define C
Definition RandGen.cpp:29
#define UI_UNIT_X
int pad[32 - sizeof(int)]
#define BLI_assert_unreachable()
#define BLI_INLINE
#define ELEM(...)
#define STREQ(a, b)
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
Definition btQuadWord.h:119
void item(std::string text, int icon1, int icon2=0)
Definition area.cc:1076
void item_bool(std::string text, bool inverted, int icon1, int icon2=0)
Definition area.cc:1097
constexpr int64_t size() const
constexpr const char * data() const
#define MAX_METADATA_STR
Definition ed_draw.cc:705
#define SLIDER_UNIT_STRING_SIZE
Definition ed_draw.cc:64
#define SLIDE_PIXEL_DISTANCE
Definition ed_draw.cc:62
#define OVERSHOOT_RANGE_DELTA
Definition ed_draw.cc:63
#define M_GOLDEN_RATIO_CONJUGATE
Definition ed_draw.cc:1115
#define str(s)
#define round
#define ceil
ccl_device_inline dual1 len(const ccl_private dual< T > &a)
Definition math_dual.h:263
BLI_INLINE Texture * wrap(MTLTexture *texture)
void font_theme_color_set(int fontid, int colorid)
void get_color_4ubv(int colorid, unsigned char col[4])
void get_color_3fv(int colorid, float col[3])
void get_color_4fv(int colorid, float col[4])
const uiStyle * style_get()
const uiStyle * style_get_dpi()
void draw_roundbox_corner_set(int type)
void draw_roundbox_3ub_alpha(const rctf *rect, bool filled, float rad, const unsigned char col[3], unsigned char alpha)
BMesh Iterators.
MINLINE float min_ff(float a, float b)
static void drawviewborder_triangle(uint shdr_pos, rctf rect, const bool golden, const char dir)
Definition ed_draw.cc:1144
UserDef U
Definition blender.cc:58
size_t size_t size_t BLI_snprintf_utf8(char *__restrict dst, size_t dst_maxncpy, const char *__restrict format,...) ATTR_NONNULL(1
void BLF_boundbox(int fontid, const char *str, size_t str_len, rcti *r_box, ResultBLF *r_info=nullptr) ATTR_NONNULL(2)
Definition blf.cc:805
bool ED_slider_modal(tSlider *slider, const wmEvent *event)
Definition ed_draw.cc:492
@ COMPOSITION_GUIDES_THIRDS
@ COMPOSITION_GUIDES_GOLDEN
@ COMPOSITION_GUIDES_CENTER_DIAG
@ COMPOSITION_GUIDES_HARMONY_TRI_B
@ COMPOSITION_GUIDES_GOLDEN_TRI_A
@ COMPOSITION_GUIDES_HARMONY_TRI_A
@ COMPOSITION_GUIDES_CENTER
@ COMPOSITION_GUIDES_GOLDEN_TRI_B
ScrArea * CTX_wm_area(const bContext *C)
static void metadata_custom_count_fields(const char *field, const char *, void *ctx_v)
Definition ed_draw.cc:861
bool BKE_stamp_is_known_field(const char *field_name)
void ED_slider_status_string_get(const tSlider *slider, char *status_string, size_t size_of_status_string)
Definition ed_draw.cc:525
void BLF_shadow_offset(int fontid, int x, int y)
Definition blf.cc:979
void BLF_position(int fontid, float x, float y, float z)
Definition blf.cc:390
void immEnd()
void ED_draw_composition_guides(uint shdr_pos, eCompositionGuideFlags flag, const rctf *rect, const float color[4])
Definition ed_draw.cc:1196
float BLF_width(int fontid, const char *str, size_t str_len, ResultBLF *r_info=nullptr) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(2)
Definition blf.cc:835
static void slider_update_factor(tSlider *slider, const wmEvent *event)
Definition ed_draw.cc:409
unsigned int uint
Definition BKE_text.h:55
void GPU_polygon_smooth(bool enable)
Definition gpu_state.cc:85
void BLF_shadow(int fontid, FontShadowType type, const float rgba[4]=nullptr)
Definition blf.cc:967
void ED_slider_init(tSlider *slider, const wmEvent *event)
Definition ed_draw.cc:487
void immUniform2f(const char *name, float x, float y)
void BLF_wordwrap(int fontid, int wrap_width, BLFWrapMode mode=BLFWrapMode::Minimal)
Definition blf.cc:957
GPUVertFormat * immVertexFormat()
void ED_slider_factor_set(tSlider *slider, float factor)
Definition ed_draw.cc:607
float ED_slider_factor_get(const tSlider *slider)
Definition ed_draw.cc:602
void ED_region_overlay_info_text_draw(const int render_size_x, const int render_size_y, const int viewer_size_x, const int viewer_size_y, const int draw_offset_x, const int draw_offset_y)
Definition ed_draw.cc:953
void immBegin(GPUPrimType, uint vertex_len)
void ED_slider_mode_set(tSlider *slider, SliderMode mode)
Definition ed_draw.cc:650
wmWindow * CTX_wm_window(const bContext *C)
MINLINE int max_ii(int a, int b)
void immUniformColor4fv(const float rgba[4])
void immUniformThemeColorAlpha(int color_id, float a)
void ED_region_tag_redraw(ARegion *region)
Definition area.cc:681
void BLF_disable(int fontid, FontFlags flag)
Definition blf.cc:331
void immUnbindProgram()
BLI_INLINE bool metadata_is_custom_drawable(const char *field)
Definition ed_draw.cc:728
static void draw_ticks(const float start_factor, const float end_factor, const float line_start[2], const float base_tick_height, const float line_width, const uint8_t color_overshoot[4], const uint8_t color_line[4])
Definition ed_draw.cc:147
void GPU_line_width(float width)
Definition gpu_state.cc:151
BLI_INLINE bool metadata_is_valid(const ImBuf *ibuf, char *r_str, short index, int offset)
Definition ed_draw.cc:720
void GPU_matrix_scale_2f(float x, float y)
@ GPU_BLEND_NONE
Definition GPU_state.hh:88
@ GPU_BLEND_ALPHA
Definition GPU_state.hh:90
tSlider * ED_slider_create(bContext *C)
Definition ed_draw.cc:438
SliderMode ED_slider_mode_get(const tSlider *slider)
Definition ed_draw.cc:655
Global G
Definition blender.cc:57
static void text_info_row(const char *text, const int text_len, int col1, int col2, int row, const int size_x, const int size_y)
Definition ed_draw.cc:923
void immBindBuiltinProgram(GPUBuiltinShader shader_id)
int BLF_set_default()
void ED_slider_allow_increments_set(tSlider *slider, bool value)
Definition ed_draw.cc:637
void BLF_size(int fontid, float size)
Definition blf.cc:445
BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
Definition BLI_rect.hh:207
void * ED_region_draw_cb_activate(ARegionType *art, void(*draw)(const bContext *, ARegion *, void *), void *customdata, int type)
static void draw_overshoot_triangle(const uint8_t color[4], const bool facing_right, const float x, const float y)
Definition ed_draw.cc:122
void immUniform1f(const char *name, float x)
void immVertex2f(uint attr_id, float x, float y)
bool ED_region_draw_cb_exit(ARegionType *art, void *handle)
void GPU_viewport_size_get_f(float coords[4])
Definition gpu_state.cc:258
void BLF_color3ubv(int fontid, const unsigned char rgb[3])
Definition blf.cc:478
void ED_slider_unit_set(tSlider *slider, const char *unit)
Definition ed_draw.cc:660
static void draw_backdrop(const int fontid, const rctf *main_line_rect, const uint8_t color_bg[4], const short region_y_size, const float base_tick_height, const std::string &property_label)
Definition ed_draw.cc:237
int BLF_default()
@ GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR
void immUniformThemeColor3(int color_id)
unsigned char uint8_t
Definition BKE_text.h:79
static void metadata_custom_draw_fields(const char *field, const char *value, void *ctx_v)
Definition ed_draw.cc:751
void immUniformColor4f(float r, float g, float b, float a)
void BLF_clipping(int fontid, int xmin, int ymin, int xmax, int ymax)
Definition blf.cc:945
void ED_region_image_metadata_draw(int x, int y, const ImBuf *ibuf, const rctf *frame, float zoomx, float zoomy)
Definition ed_draw.cc:1039
void ED_area_status_text(ScrArea *area, const char *str)
Definition area.cc:975
void GPU_matrix_translate_2f(float x, float y)
void BLF_draw(int fontid, const char *str, size_t str_len, ResultBLF *r_info=nullptr) ATTR_NONNULL(2)
Definition blf.cc:587
uint GPU_vertformat_attr_add(GPUVertFormat *format, StringRef name, gpu::VertAttrType type)
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
Definition BLI_rect.hh:203
void ED_slider_allow_overshoot_set(tSlider *slider, bool lower, bool upper)
Definition ed_draw.cc:626
static void drawviewborder_grid3(uint shdr_pos, rctf rect, float fac)
Definition ed_draw.cc:1117
void ED_slider_factor_bounds_set(tSlider *slider, float factor_bound_lower, float factor_bound_upper)
Definition ed_draw.cc:642
int BLF_height_max(int fontid) ATTR_WARN_UNUSED_RESULT
Definition blf.cc:883
static void slider_draw(const bContext *, ARegion *region, void *arg)
Definition ed_draw.cc:272
static void metadata_draw_imbuf(const ImBuf *ibuf, const rctf *rect, int fontid, const bool is_top)
Definition ed_draw.cc:764
void imm_draw_box_wire_2d(uint pos, float x1, float y1, float x2, float y2)
MINLINE float max_ff(float a, float b)
void IMB_metadata_foreach(const ImBuf *ibuf, IMBMetadataForeachCb callback, void *userdata)
int BLF_descender(int fontid) ATTR_WARN_UNUSED_RESULT
Definition blf.cc:905
void ED_slider_status_get(const tSlider *slider, WorkspaceStatus &status)
Definition ed_draw.cc:573
bool IMB_metadata_get_field(const IDProperty *metadata, const char *key, char *value, size_t value_maxncpy)
int blf_mono_font
Definition blf.cc:50
static void draw_main_line(const rctf *main_line_rect, const float factor, const bool overshoot, const uint8_t color_overshoot[4], const uint8_t color_line[4])
Definition ed_draw.cc:193
Scene * CTX_data_scene(const bContext *C)
void GPU_blend(GPUBlend blend)
Definition gpu_state.cc:44
void ED_region_draw_mouse_line_cb(const bContext *C, ARegion *region, void *arg_info)
Definition ed_draw.cc:672
void immUniform1i(const char *name, int x)
bool ED_slider_allow_increments_get(const tSlider *slider)
Definition ed_draw.cc:632
void BLF_width_and_height(int fontid, const char *str, size_t str_len, float *r_width, float *r_height) ATTR_NONNULL()
Definition blf.cc:822
MINLINE void copy_v2fl_v2i(float r[2], const int a[2])
void immVertex2fv(uint attr_id, const float data[2])
void immUniformColor3ubvAlpha(const unsigned char rgb[3], unsigned char a)
void GPU_matrix_pop()
void BLF_rotation(int fontid, float angle)
Definition blf.cc:936
void ED_slider_property_label_set(tSlider *slider, const char *property_label)
Definition ed_draw.cc:665
void ED_slider_increment_step_set(tSlider *slider, float increment_step)
Definition ed_draw.cc:616
void immRectf(uint pos, float x1, float y1, float x2, float y2)
ARegion * CTX_wm_region(const bContext *C)
void ED_workspace_status_text(bContext *C, const char *str)
Definition area.cc:1153
static float metadata_box_height_get(const ImBuf *ibuf, int fontid, const bool is_top)
Definition ed_draw.cc:870
void ED_slider_destroy(bContext *C, tSlider *slider)
Definition ed_draw.cc:589
void BLF_enable(int fontid, FontFlags flag)
Definition blf.cc:322
void ED_region_render_region_draw(int x, int y, const rcti *frame, float zoomx, float zoomy, float passepartout_alpha)
Definition ed_draw.cc:991
@ SLIDER_MODE_PERCENT
Definition ED_util.hh:90
@ SLIDER_MODE_FLOAT
Definition ED_util.hh:90
@ BLF_SHADOW
Definition BLF_enums.hh:38
@ BLF_CLIPPING
Definition BLF_enums.hh:37
@ BLF_WORD_WRAP
Definition BLF_enums.hh:42
void GPU_matrix_push()
void BLF_color4fv(int fontid, const float rgba[4])
Definition blf.cc:507
void BLI_rctf_init(struct rctf *rect, float xmin, float xmax, float ymin, float ymax)
Definition rct.cc:418
MINLINE float clamp_f(float value, float min, float max)
static const char * meta_data_list[]
Definition ed_draw.cc:707
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
bke::ARegionRuntime * runtime
eRegion_Type regiontype
const IDProperty * metadata() const
ListBaseT< ARegion > regionbase
struct ARegionType * type
float factor_bounds[2]
Definition ed_draw.cc:86
ScrArea * area
Definition ed_draw.cc:68
SliderMode slider_mode
Definition ed_draw.cc:92
float increment_step
Definition ed_draw.cc:89
bool allow_overshoot_upper
Definition ed_draw.cc:105
bool allow_increments
Definition ed_draw.cc:113
void * draw_handle
Definition ed_draw.cc:74
ARegion * region_header
Definition ed_draw.cc:71
bool allow_overshoot_lower
Definition ed_draw.cc:104
std::string property_label
Definition ed_draw.cc:96
char unit_string[SLIDER_UNIT_STRING_SIZE]
Definition ed_draw.cc:99
Scene * scene
Definition ed_draw.cc:67
float last_cursor[2]
Definition ed_draw.cc:83
wmEventType type
Definition WM_types.hh:817
bke::WindowRuntime * runtime
uiFontStyle widget