Blender V5.3
screen_draw.cc
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#include "ED_screen.hh"
10#include "ED_screen_types.hh"
11
12#include "GPU_batch_presets.hh"
13#include "GPU_immediate.hh"
14#include "GPU_platform.hh"
15#include "GPU_state.hh"
16
17#include "BKE_global.hh"
18#include "BKE_screen.hh"
19
20#include "BLF_api.hh"
21
22#include "BLI_listbase.hh"
23#include "BLI_math_color_c.hh"
24#include "BLI_math_vector_c.hh"
25#include "BLI_rect.hh"
26#include "BLI_time.hh"
27
28#include "BLT_translation.hh"
29
30#include "WM_api.hh"
31
32#include "UI_interface.hh"
33#include "UI_resources.hh"
34
35#include "screen_intern.hh"
36
37namespace blender {
38
39#define CORNER_RESOLUTION 3
40
41static void do_vert_pair(gpu::VertBuf *vbo, uint pos, uint *vidx, int corner, int i)
42{
43 float inter[2];
44 inter[0] = cosf(corner * M_PI_2 + (i * M_PI_2 / (CORNER_RESOLUTION - 1.0f)));
45 inter[1] = sinf(corner * M_PI_2 + (i * M_PI_2 / (CORNER_RESOLUTION - 1.0f)));
46
47 /* Snap point to edge */
48 float div = 1.0f / max_ff(fabsf(inter[0]), fabsf(inter[1]));
49 float exter[2];
50 mul_v2_v2fl(exter, inter, div);
51 exter[0] = roundf(exter[0]);
52 exter[1] = roundf(exter[1]);
53
54 if (i == 0 || i == (CORNER_RESOLUTION - 1)) {
55 copy_v2_v2(inter, exter);
56 }
57
58 /* Small offset to be able to tell inner and outer vertex apart inside the shader.
59 * Edge width is specified in the shader. */
60 mul_v2_fl(inter, 1.0f - 0.0001f);
61 mul_v2_fl(exter, 1.0f);
62
63 GPU_vertbuf_attr_set(vbo, pos, (*vidx)++, inter);
64 GPU_vertbuf_attr_set(vbo, pos, (*vidx)++, exter);
65}
66
67static gpu::Batch *batch_screen_edges_get(int *corner_len)
68{
69 static gpu::Batch *screen_edges_batch = nullptr;
70
71 if (screen_edges_batch == nullptr) {
72 GPUVertFormat format = {0};
73 uint pos = GPU_vertformat_attr_add(&format, "pos", gpu::VertAttrType::SFLOAT_32_32);
74
75 gpu::VertBuf *vbo = GPU_vertbuf_create_with_format(format);
77
78 uint vidx = 0;
79 for (int corner = 0; corner < 4; corner++) {
80 for (int c = 0; c < CORNER_RESOLUTION; c++) {
81 do_vert_pair(vbo, pos, &vidx, corner, c);
82 }
83 }
84 /* close the loop */
85 do_vert_pair(vbo, pos, &vidx, 0, 0);
86
87 screen_edges_batch = GPU_batch_create_ex(GPU_PRIM_TRI_STRIP, vbo, nullptr, GPU_BATCH_OWNS_VBO);
88 gpu_batch_presets_register(screen_edges_batch);
89 }
90
91 if (corner_len) {
92 *corner_len = CORNER_RESOLUTION * 2;
93 }
94 return screen_edges_batch;
95}
96
97#undef CORNER_RESOLUTION
98
102static void drawscredge_area(const ScrArea &area, float edge_thickness)
103{
104 rctf rect;
105 BLI_rctf_rcti_copy(&rect, &area.totrct);
106 BLI_rctf_pad(&rect, edge_thickness, edge_thickness);
107
108 gpu::Batch *batch = batch_screen_edges_get(nullptr);
110 GPU_batch_uniform_4fv(batch, "rect", (float *)&rect);
111 GPU_batch_draw(batch);
112}
113
115{
117 screen->do_draw = false;
118
119 if (screen->state != SCREENNORMAL) {
120 return;
121 }
122
123 if (screen->areabase.is_single() && win->global_areas.areabase.first_ == nullptr) {
124 /* Do not show edges on windows without global areas and with only one editor. */
125 return;
126 }
127
128 ARegion *region = screen->active_region;
129 ScrArea *active_area = nullptr;
130
131 if (region) {
132 /* Find active area from active region. */
133 const int pos[2] = {BLI_rcti_cent_x(&region->winrct), BLI_rcti_cent_y(&region->winrct)};
134 active_area = BKE_screen_find_area_xy(screen, SPACE_TYPE_ANY, pos);
135 }
136
137 if (!active_area) {
138 for (ScrArea &area : screen->areabase) {
140 /* Get area from action zone, if not scroll-bar. */
141 if (zone && zone->type != AZONE_REGION_SCROLL) {
142 active_area = &area;
143 break;
144 }
145 }
146 }
147
148 if (G.moving & G_TRANSFORM_WM) {
149 active_area = BKE_screen_find_area_xy(screen, SPACE_TYPE_ANY, win->runtime->eventstate->xy);
150 /* We don't want an active area when resizing, otherwise outline for active area flickers, see:
151 * #136314. */
152 if (active_area && !win->runtime->drawcalls.is_empty()) {
153 active_area = nullptr;
154 }
155 }
156
157 rcti scissor_rect;
158 BLI_rcti_init_minmax(&scissor_rect);
159 for (ScrArea &area : screen->areabase) {
160 BLI_rcti_do_minmax_v(&scissor_rect, int2{area.v1->vec.x, area.v1->vec.y});
161 BLI_rcti_do_minmax_v(&scissor_rect, int2{area.v3->vec.x, area.v3->vec.y});
162 }
163
165 /* For some reason, on linux + Intel UHD Graphics 620 the driver
166 * hangs if we don't flush before this. (See #57455) */
167 GPU_flush();
168 }
169
170 GPU_scissor(scissor_rect.xmin,
171 scissor_rect.ymin,
172 BLI_rcti_size_x(&scissor_rect) + 1,
173 BLI_rcti_size_y(&scissor_rect) + 1);
174 GPU_scissor_test(true);
175
176 float col[4];
178
179 const float edge_thickness = float(U.border_width) * UI_SCALE_FAC;
180
181 /* Entire width of the evaluated outline as far as the shader is concerned. */
182 const float shader_scale = edge_thickness + EDITORRADIUS;
183 const float corner_coverage[10] = {
184 0.144f, 0.25f, 0.334f, 0.40f, 0.455, 0.5, 0.538, 0.571, 0.6, 0.625f};
185 const float shader_width = corner_coverage[U.border_width - 1];
186
188
189 int verts_per_corner = 0;
190 gpu::Batch *batch = batch_screen_edges_get(&verts_per_corner);
191
193 GPU_batch_uniform_1i(batch, "cornerLen", verts_per_corner);
194 GPU_batch_uniform_1f(batch, "scale", shader_scale);
195 GPU_batch_uniform_1f(batch, "width", shader_width);
196 GPU_batch_uniform_4fv(batch, "color", col);
197
198 for (ScrArea &area : screen->areabase) {
199 drawscredge_area(area, edge_thickness);
200 }
201
202 float outline1[4];
203 float outline2[4];
204 rctf bounds;
205 /* Outset by 1/2 pixel, regardless of UI scale or pixel size. #141550. */
206 const float padding = 0.5f;
210 for (ScrArea &area : screen->areabase) {
214 nullptr,
215 nullptr,
216 1.0f,
217 (&area == active_area) ? outline2 : outline1,
218 U.pixelsize,
220 }
221
223 GPU_scissor_test(false);
224}
225
227 bScreen *screen,
228 eScreenAxis dir_axis,
229 float anim_factor)
230{
231 rctf rect = {SHRT_MAX, SHRT_MIN, SHRT_MAX, SHRT_MIN};
232
233 for (const ScrEdge &edge : screen->edgebase) {
234 if (edge.v1->editflag && edge.v2->editflag) {
235 if (dir_axis == SCREEN_AXIS_H) {
236 rect.xmin = std::min({rect.xmin, float(edge.v1->vec.x), float(edge.v2->vec.x)});
237 rect.xmax = std::max({rect.xmax, float(edge.v1->vec.x), float(edge.v2->vec.x)});
238 rect.ymin = rect.ymax = float(edge.v1->vec.y);
239 }
240 else {
241 rect.ymin = std::min({rect.ymin, float(edge.v1->vec.y), float(edge.v2->vec.y)});
242 rect.ymax = std::max({rect.ymax, float(edge.v1->vec.y), float(edge.v2->vec.y)});
243 rect.xmin = rect.xmax = float(edge.v1->vec.x);
244 }
245 };
246 }
247
248 rcti window_rect;
249 WM_window_screen_rect_calc(win, &window_rect);
250 const float offset = U.border_width * UI_SCALE_FAC;
251 const float width = std::min(2.0f * offset, 5.0f * UI_SCALE_FAC);
252 if (dir_axis == SCREEN_AXIS_H) {
253 BLI_rctf_pad(&rect, -offset, width);
254 }
255 else {
256 BLI_rctf_pad(&rect, width, -offset);
257 }
258
259 float inner[4] = {1.0f, 1.0f, 1.0f, 0.4f * anim_factor};
260 float outline[4];
262 outline[3] *= anim_factor;
263
266 &rect, inner, nullptr, 1.0f, outline, width - U.pixelsize, 2.5f * UI_SCALE_FAC);
267}
268
270{
271 rctf rect;
272 BLI_rctf_rcti_copy(&rect, &region->winrct);
274
275 switch (region->alignment) {
276 case RGN_ALIGN_RIGHT:
277 rect.xmax = rect.xmin - U.pixelsize;
278 rect.xmin = rect.xmax - (4.0f * U.pixelsize);
279 rect.ymax -= EDITORRADIUS;
280 rect.ymin += EDITORRADIUS;
281 break;
282 case RGN_ALIGN_LEFT:
283 rect.xmin = rect.xmax + U.pixelsize;
284 rect.xmax = rect.xmin + (4.0f * U.pixelsize);
285 rect.ymax -= EDITORRADIUS;
286 rect.ymin += EDITORRADIUS;
287 break;
288 case RGN_ALIGN_TOP:
289 rect.ymax = rect.ymin - U.pixelsize;
290 rect.ymin = rect.ymax - (4.0f * U.pixelsize);
291 rect.xmax -= EDITORRADIUS;
292 rect.xmin += EDITORRADIUS;
293 break;
294 case RGN_ALIGN_BOTTOM:
295 rect.ymin = rect.ymax + U.pixelsize;
296 rect.ymax = rect.ymin + (4.0f * U.pixelsize);
297 rect.xmax -= EDITORRADIUS;
298 rect.xmin += EDITORRADIUS;
299 break;
300 default:
301 return;
302 }
303
304 float inner[4] = {1.0f, 1.0f, 1.0f, 0.4f};
305 float outline[4] = {0.0f, 0.0f, 0.0f, 0.3f};
307 &rect, inner, nullptr, 1.0f, outline, 1.0f * U.pixelsize, 2.5f * UI_SCALE_FAC);
308}
309
311 const wmWindow *win, int x, int y, const ScrArea *source, const std::string &hint)
312{
313 const char *area_name = IFACE_(ED_area_name(source).c_str());
314 const uiFontStyle *fstyle = UI_FSTYLE_TOOLTIP;
315 const bTheme *btheme = ui::theme::theme_get();
316 const uiWidgetColors *wcol = &btheme->tui.wcol_tooltip;
317 float col_fg[4], col_bg[4];
318 rgba_uchar_to_float(col_fg, wcol->text);
319 rgba_uchar_to_float(col_bg, wcol->inner);
320
323
324 const float margin = scale * 4.0f;
325 const float icon_width = (scale * ICON_DEFAULT_WIDTH / 1.4f);
326 const float icon_gap = scale * 3.0f;
327 const float line_gap = scale * 5.0f;
328 const int line_height = BLF_height_max(fstyle->uifont_id);
329 const int descent = BLF_descender(fstyle->uifont_id);
330 const float line1_len = BLF_width(fstyle->uifont_id, hint.c_str(), hint.size());
331 const float line2_len = BLF_width(fstyle->uifont_id, area_name, BLF_DRAW_STR_DUMMY_MAX);
332 const float width = margin + std::max(line1_len, line2_len + icon_width + icon_gap) + margin;
333 const float height = margin + line_height + line_gap + line_height + margin;
334
335 /* Position of this hint relative to the mouse position. */
336 const int left = std::min(x + int(5.0f * UI_SCALE_FAC),
337 WM_window_native_pixel_x(win) - int(width));
338 const int top = std::max(y - int(7.0f * UI_SCALE_FAC), int(height));
339
340 rctf rect;
341 rect.xmin = left;
342 rect.xmax = left + width;
343 rect.ymax = top;
344 rect.ymin = top - height;
346 ui::draw_roundbox_4fv(&rect, true, wcol->roundness * U.widget_unit, col_bg);
347
348 ui::icon_draw_ex(left + margin,
349 top - height + margin + (1.0f * scale),
350 ED_area_icon(source),
351 1.4f / scale,
352 1.0f,
353 0.0f,
354 wcol->text,
355 true,
357
359 BLF_color4fv(fstyle->uifont_id, col_fg);
360
362 fstyle->uifont_id, left + margin, top - margin - line_height + (2.0f * scale), 0.0f);
363 BLF_draw(fstyle->uifont_id, hint.c_str(), hint.size());
364
365 BLF_position(fstyle->uifont_id,
366 left + margin + icon_width + icon_gap,
367 top - height + margin - descent,
368 0.0f);
369 BLF_draw(fstyle->uifont_id, area_name, BLF_DRAW_STR_DUMMY_MAX);
370}
371
372static void screen_draw_area_closed(int xmin, int xmax, int ymin, int ymax, float anim_factor)
373{
374 /* Darken the area. */
375 rctf rect = {float(xmin), float(xmax), float(ymin), float(ymax)};
376 float darken[4] = {0.0f, 0.0f, 0.0f, 0.7f * anim_factor};
378 ui::draw_roundbox_4fv_ex(&rect, darken, nullptr, 1.0f, nullptr, U.pixelsize, EDITORRADIUS);
379}
380
382 const wmWindow *win, ScrArea *sa1, ScrArea *sa2, eScreenDir dir, float anim_factor)
383{
384 if (dir == SCREEN_DIR_NONE || !sa2) {
385 /* Darken source if docking. Done here because it might be a different window.
386 * Do not animate this as we don't want to reset every time we change areas. */
388 sa1->totrct.xmin, sa1->totrct.xmax, sa1->totrct.ymin, sa1->totrct.ymax, 1.0f);
389 return;
390 }
391
392 /* Rect of the combined areas. */
393 const bool vertical = SCREEN_DIR_IS_VERTICAL(dir);
394 rctf combined{};
395 combined.xmin = vertical ? std::max(sa1->totrct.xmin, sa2->totrct.xmin) :
396 std::min(sa1->totrct.xmin, sa2->totrct.xmin);
397 combined.xmax = vertical ? std::min(sa1->totrct.xmax, sa2->totrct.xmax) :
398 std::max(sa1->totrct.xmax, sa2->totrct.xmax);
399 combined.ymin = vertical ? std::min(sa1->totrct.ymin, sa2->totrct.ymin) :
400 std::max(sa1->totrct.ymin, sa2->totrct.ymin);
401 combined.ymax = vertical ? std::max(sa1->totrct.ymax, sa2->totrct.ymax) :
402 std::min(sa1->totrct.ymax, sa2->totrct.ymax);
403
404 int offset1;
405 int offset2;
406 area_getoffsets(sa1, sa2, dir, &offset1, &offset2);
407 if (offset1 < 0 || offset2 > 0) {
408 /* Show partial areas that will be closed. */
409 if (vertical) {
410 if (sa1->totrct.xmin < combined.xmin) {
412 sa1->totrct.xmin, combined.xmin, sa1->totrct.ymin, sa1->totrct.ymax, anim_factor);
413 }
414 if (sa2->totrct.xmin < combined.xmin) {
416 sa2->totrct.xmin, combined.xmin, sa2->totrct.ymin, sa2->totrct.ymax, anim_factor);
417 }
418 if (sa1->totrct.xmax > combined.xmax) {
420 combined.xmax, sa1->totrct.xmax, sa1->totrct.ymin, sa1->totrct.ymax, anim_factor);
421 }
422 if (sa2->totrct.xmax > combined.xmax) {
424 combined.xmax, sa2->totrct.xmax, sa2->totrct.ymin, sa2->totrct.ymax, anim_factor);
425 }
426 }
427 else {
428 if (sa1->totrct.ymin < combined.ymin) {
430 sa1->totrct.xmin, sa1->totrct.xmax, sa1->totrct.ymin, combined.ymin, anim_factor);
431 }
432 if (sa2->totrct.ymin < combined.ymin) {
434 sa2->totrct.xmin, sa2->totrct.xmax, sa2->totrct.ymin, combined.ymin, anim_factor);
435 }
436 if (sa1->totrct.ymax > combined.ymax) {
438 sa1->totrct.xmin, sa1->totrct.xmax, combined.ymax, sa1->totrct.ymax, anim_factor);
439 }
440 if (sa2->totrct.ymax > combined.ymax) {
442 sa2->totrct.xmin, sa2->totrct.xmax, combined.ymax, sa2->totrct.ymax, anim_factor);
443 }
444 }
445 }
446
447 /* Outline the combined area. */
448 draw_roundbox_corner_set(ui::CNR_ALL);
449 float outline[4] = {1.0f, 1.0f, 1.0f, 0.4f * anim_factor};
450 float inner[4] = {1.0f, 1.0f, 1.0f, 0.10f * anim_factor};
451 ui::draw_roundbox_4fv_ex(&combined, inner, nullptr, 1.0f, outline, U.pixelsize, EDITORRADIUS);
452
454 win->runtime->eventstate->xy[0],
455 win->runtime->eventstate->xy[1],
456 sa1,
457 IFACE_("Join Areas"));
458}
459
460static void rounded_corners(rctf rect, float color[4], int corners)
461{
462 GPUVertFormat *format = immVertexFormat();
463 const uint pos = GPU_vertformat_attr_add(format, "pos", gpu::VertAttrType::SFLOAT_32_32);
464
465 const float rad = EDITORRADIUS;
466
467 float vec[4][2] = {
468 {0.195, 0.02},
469 {0.55, 0.169},
470 {0.831, 0.45},
471 {0.98, 0.805},
472 };
473 for (int a = 0; a < 4; a++) {
474 mul_v2_fl(vec[a], rad);
475 }
476
479
480 if (corners & ui::CNR_TOP_LEFT) {
482 immVertex2f(pos, rect.xmin - 1, rect.ymax);
483 immVertex2f(pos, rect.xmin, rect.ymax - rad);
484 for (int a = 0; a < 4; a++) {
485 immVertex2f(pos, rect.xmin + vec[a][1], rect.ymax - rad + vec[a][0]);
486 }
487 immVertex2f(pos, rect.xmin + rad, rect.ymax);
488 immEnd();
489 }
490
491 if (corners & ui::CNR_TOP_RIGHT) {
493 immVertex2f(pos, rect.xmax + 1, rect.ymax);
494 immVertex2f(pos, rect.xmax - rad, rect.ymax);
495 for (int a = 0; a < 4; a++) {
496 immVertex2f(pos, rect.xmax - rad + vec[a][0], rect.ymax - vec[a][1]);
497 }
498 immVertex2f(pos, rect.xmax, rect.ymax - rad);
499 immEnd();
500 }
501
502 if (corners & ui::CNR_BOTTOM_RIGHT) {
504 immVertex2f(pos, rect.xmax + 1, rect.ymin);
505 immVertex2f(pos, rect.xmax, rect.ymin + rad);
506 for (int a = 0; a < 4; a++) {
507 immVertex2f(pos, rect.xmax - vec[a][1], rect.ymin + rad - vec[a][0]);
508 }
509 immVertex2f(pos, rect.xmax - rad, rect.ymin);
510 immEnd();
511 }
512
513 if (corners & ui::CNR_BOTTOM_LEFT) {
515 immVertex2f(pos, rect.xmin - 1, rect.ymin);
516 immVertex2f(pos, rect.xmin + rad, rect.ymin);
517 for (int a = 0; a < 4; a++) {
518 immVertex2f(pos, rect.xmin + rad - vec[a][0], rect.ymin + vec[a][1]);
519 }
520 immVertex2f(pos, rect.xmin, rect.ymin + rad);
521 immEnd();
522 }
523
525}
526
528 ScrArea *source,
529 ScrArea *target,
530 AreaDockTarget dock_target,
531 float factor,
532 int x,
533 int y,
534 float anim_factor)
535{
536 if (dock_target == AreaDockTarget::None) {
537 return;
538 }
539
540 float outline[4] = {1.0f, 1.0f, 1.0f, 0.4f * anim_factor};
541 float inner[4] = {1.0f, 1.0f, 1.0f, 0.1f * anim_factor};
542 float border[4];
544 border[3] *= anim_factor;
546 float half_line_width = float(U.border_width) * UI_SCALE_FAC;
547
548 rctf dest;
549 rctf remainder;
550 BLI_rctf_rcti_copy(&dest, &target->totrct);
551 BLI_rctf_rcti_copy(&remainder, &target->totrct);
552
553 float split;
554 int corners = ui::CNR_NONE;
555
556 if (dock_target == AreaDockTarget::Right) {
557 split = std::min(dest.xmin + target->winx * (1.0f - factor),
558 dest.xmax - AREAMINX * UI_SCALE_FAC);
559 dest.xmin = split + half_line_width;
560 remainder.xmax = split - half_line_width;
562 }
563 else if (dock_target == AreaDockTarget::Left) {
564 split = std::max(dest.xmax - target->winx * (1.0f - factor),
565 dest.xmin + AREAMINX * UI_SCALE_FAC);
566 dest.xmax = split - half_line_width;
567 remainder.xmin = split + half_line_width;
569 }
570 else if (dock_target == AreaDockTarget::Top) {
571 split = std::min(dest.ymin + target->winy * (1.0f - factor),
572 dest.ymax - HEADERY * UI_SCALE_FAC);
573 dest.ymin = split + half_line_width;
574 remainder.ymax = split - half_line_width;
576 }
577 else if (dock_target == AreaDockTarget::Bottom) {
578 split = std::max(dest.ymax - target->winy * (1.0f - factor),
579 dest.ymin + HEADERY * UI_SCALE_FAC);
580 dest.ymax = split - half_line_width;
581 remainder.ymin = split + half_line_width;
583 }
584
585 rounded_corners(dest, border, corners);
586 ui::draw_roundbox_4fv_ex(&dest, inner, nullptr, 1.0f, outline, U.pixelsize, EDITORRADIUS);
587
588 if (dock_target != AreaDockTarget::Center) {
589 /* Darken the split position itself. */
591 dest.xmin = split - half_line_width;
592 dest.xmax = split + half_line_width;
593 }
594 else {
595 dest.ymin = split - half_line_width;
596 dest.ymax = split + half_line_width;
597 }
598 ui::draw_roundbox_4fv(&dest, true, 0.0f, border);
599 }
600
602 x,
603 y,
604 source,
605 dock_target == AreaDockTarget::Center ? IFACE_("Replace this area") :
606 IFACE_("Move area here"));
607}
608
609void screen_draw_split_preview(ScrArea *area, const eScreenAxis dir_axis, const float factor)
610{
611 float outline[4] = {1.0f, 1.0f, 1.0f, 0.4f};
612 float inner[4] = {1.0f, 1.0f, 1.0f, 0.10f};
613 float border[4];
615 draw_roundbox_corner_set(ui::CNR_ALL);
616
617 rctf rect;
618 BLI_rctf_rcti_copy(&rect, &area->totrct);
619
620 if (factor < 0.0001 || factor > 0.9999) {
621 /* Highlight the entire area. */
622 ui::draw_roundbox_4fv_ex(&rect, inner, nullptr, 1.0f, outline, U.pixelsize, EDITORRADIUS);
623 return;
624 }
625
626 float x = (1 - factor) * rect.xmin + factor * rect.xmax;
627 float y = (1 - factor) * rect.ymin + factor * rect.ymax;
628 x = std::clamp(x, rect.xmin, rect.xmax);
629 y = std::clamp(y, rect.ymin, rect.ymax);
630 float half_line_width = float(U.border_width) * UI_SCALE_FAC;
631
632 /* Outlined rectangle to left/above split position. */
633 rect.xmax = (dir_axis == SCREEN_AXIS_V) ? x - half_line_width : rect.xmax;
634 rect.ymax = (dir_axis == SCREEN_AXIS_H) ? y - half_line_width : rect.ymax;
635
636 rounded_corners(rect,
637 border,
640 ui::draw_roundbox_4fv_ex(&rect, inner, nullptr, 1.0f, outline, U.pixelsize, EDITORRADIUS);
641
642 /* Outlined rectangle to right/below split position. */
643 if (dir_axis == SCREEN_AXIS_H) {
644 rect.ymin = y + half_line_width;
645 rect.ymax = area->totrct.ymax;
646 }
647 else {
648 rect.xmin = x + half_line_width;
649 rect.xmax = area->totrct.xmax;
650 }
651
652 rounded_corners(rect,
653 border,
656 ui::draw_roundbox_4fv_ex(&rect, inner, nullptr, 1.0f, outline, U.pixelsize, EDITORRADIUS);
657
658 /* Darken the split position itself. */
659 if (dir_axis == SCREEN_AXIS_H) {
660 rect.ymin = y - half_line_width;
661 rect.ymax = y + half_line_width;
662 }
663 else {
664 rect.xmin = x - half_line_width;
665 rect.xmax = x + half_line_width;
666 }
667 ui::draw_roundbox_4fv(&rect, true, 0.0f, border);
668}
669
680
681static void area_animate_highlight_cb(const wmWindow * /*win*/, void *userdata)
682{
683 const AreaAnimateHighlightData *data = static_cast<const AreaAnimateHighlightData *>(userdata);
684
685 double now = BLI_time_now_seconds();
686 if (now > data->end_time) {
687 WM_draw_cb_exit(data->win, data->draw_callback);
688 MEM_delete(const_cast<AreaAnimateHighlightData *>(data));
689 data = nullptr;
690 return;
691 }
692
693 const float factor = pow((now - data->start_time) / (data->end_time - data->start_time), 2);
694 const bool do_inner = data->inner[3] > 0.0f;
695 const bool do_outline = data->outline[3] > 0.0f;
696
697 float inner_color[4];
698 if (do_inner) {
699 inner_color[0] = data->inner[0];
700 inner_color[1] = data->inner[1];
701 inner_color[2] = data->inner[2];
702 inner_color[3] = (1.0f - factor) * data->inner[3];
703 }
704
705 float outline_color[4];
706 if (do_outline) {
707 outline_color[0] = data->outline[0];
708 outline_color[1] = data->outline[1];
709 outline_color[2] = data->outline[2];
710 outline_color[3] = (1.0f - factor) * data->outline[3];
711 }
712
715 do_inner ? inner_color : nullptr,
716 nullptr,
717 1.0f,
718 do_outline ? outline_color : nullptr,
719 U.pixelsize,
721
722 data->screen->do_refresh = true;
723}
724
726 bScreen *screen,
727 const rcti *rect,
728 float inner[4],
729 float outline[4],
730 float seconds)
731{
732 /* Disabling for now, see #147487. This can cause memory leaks since the
733 * data is only freed when the animation completes, which might not happen
734 * during automated tests. Freeing wmWindow->runtime->drawcalls on window close might
735 * be enough, but will have to be investigated. */
736 return;
737
739 "screen_animate_area_highlight");
740 data->win = win;
741 data->screen = screen;
742 BLI_rctf_rcti_copy(&data->rect, rect);
743 if (inner) {
744 copy_v4_v4(data->inner, inner);
745 }
746 if (outline) {
747 copy_v4_v4(data->outline, outline);
748 }
749 data->start_time = BLI_time_now_seconds();
750 data->end_time = data->start_time + seconds;
752}
753
754} // namespace blender
#define BLF_DRAW_STR_DUMMY_MAX
Definition BLF_api.hh:456
#define M_PI_2
Platform independent time functions.
#define IFACE_(msgid)
#define HEADERY
#define AREAMINX
#define SPACE_TYPE_ANY
#define UI_SCALE_FAC
#define GPU_batch_uniform_1f(batch, name, x)
Definition GPU_batch.hh:267
#define GPU_batch_uniform_4fv(batch, name, val)
Definition GPU_batch.hh:275
#define GPU_batch_uniform_1i(batch, name, x)
Definition GPU_batch.hh:265
#define UI_DEFAULT_TOOLTIP_POINTS
#define UI_FSTYLE_TOOLTIP
#define UI_NO_ICON_OVERLAY_TEXT
#define ICON_DEFAULT_WIDTH
#define ELEM(...)
#define roundf(x)
#define SHRT_MAX
#define pow
float3x3 scale(float3x3 mat, float2 scale)
void split(const std::string &s, const char delim, std::vector< std::string > &tokens)
Definition abc_util.cc:68
void get_color_4fv(int colorid, float col[4])
const bTheme * theme_get()
void icon_draw_ex(float x, float y, int icon_id, float aspect, float alpha, float desaturate, const uchar mono_color[4], bool mono_border, const IconTextOverlay *text_overlay, const bool inverted=false, float scale=1.0f)
void draw_roundbox_corner_set(int type)
void draw_roundbox_4fv_ex(const rctf *rect, const float inner1[4], const float inner2[4], float shade_dir, const float outline[4], float outline_width, float rad)
void draw_roundbox_4fv(const rctf *rect, bool filled, float rad, const float col[4])
BMesh Iterators.
UserDef U
Definition blender.cc:58
void GPU_scissor_test(bool enable)
Definition gpu_state.cc:173
int ED_area_icon(const ScrArea *area)
MINLINE void rgba_uchar_to_float(float r_col[4], const unsigned char col_ub[4])
gpu::Batch * GPU_batch_create_ex(GPUPrimType primitive_type, gpu::VertBuf *vertex_buf, gpu::IndexBuf *index_buf, GPUBatchFlag owns_flag)
Definition gpu_batch.cc:53
uint padding(uint offset, uint alignment)
bool GPU_type_matches_ex(GPUDeviceType device, GPUOSType os, GPUDriverType driver, GPUBackendType backend)
void BLF_position(int fontid, float x, float y, float z)
Definition blf.cc:390
void immEnd()
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
unsigned int uint
Definition BKE_text.h:55
void screen_draw_split_preview(ScrArea *area, const eScreenAxis dir_axis, const float factor)
MINLINE void mul_v2_fl(float r[2], float f)
MINLINE void copy_v2_v2(float r[2], const float a[2])
GPUVertFormat * immVertexFormat()
static void screen_draw_area_closed(int xmin, int xmax, int ymin, int ymax, float anim_factor)
void immBegin(GPUPrimType, uint vertex_len)
StringRefNull ED_area_name(const ScrArea *area)
void BLI_rcti_init_minmax(struct rcti *rect)
Definition rct.cc:488
AZone * ED_area_actionzone_find_xy(ScrArea *area, const int xy[2])
@ GPU_PRIM_TRI_STRIP
static void screen_draw_area_drag_tip(const wmWindow *win, int x, int y, const ScrArea *source, const std::string &hint)
@ TH_EDITOR_OUTLINE_ACTIVE
@ TH_EDITOR_OUTLINE
int WM_window_native_pixel_x(const wmWindow *win)
void immUniformColor4fv(const float rgba[4])
void BLI_rcti_do_minmax_v(struct rcti *rect, const int xy[2])
Definition rct.cc:500
void immUnbindProgram()
void BLI_rctf_rcti_copy(struct rctf *dst, const struct rcti *src)
@ GPU_BLEND_NONE
Definition GPU_state.hh:88
@ GPU_BLEND_ALPHA
Definition GPU_state.hh:90
Global G
Definition blender.cc:57
void WM_draw_cb_exit(wmWindow *win, void *handle)
Definition wm_draw.cc:652
void immBindBuiltinProgram(GPUBuiltinShader shader_id)
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
static void area_animate_highlight_cb(const wmWindow *, void *userdata)
VecBase< int32_t, 2 > int2
void * MEM_new_zeroed(size_t len, const char *str) ATTR_WARN_UNUSED_RESULT ATTR_ALLOC_SIZE(1) ATTR_NONNULL(2)
void immVertex2f(uint attr_id, float x, float y)
BLI_INLINE int BLI_rcti_cent_y(const struct rcti *rct)
Definition BLI_rect.hh:190
BMesh const char void * data
void GPU_vertbuf_attr_set(gpu::VertBuf *, uint a_idx, uint v_idx, const void *data)
void screen_draw_dock_preview(const wmWindow *win, ScrArea *source, ScrArea *target, AreaDockTarget dock_target, float factor, int x, int y, float anim_factor)
void GPU_batch_draw(gpu::Batch *batch)
@ GPU_BATCH_OWNS_VBO
Definition GPU_batch.hh:44
void gpu_batch_presets_register(gpu::Batch *preset_batch)
MINLINE void mul_v2_v2fl(float r[2], const float a[2], float f)
void area_getoffsets(ScrArea *sa_a, ScrArea *sa_b, const eScreenDir dir, int *r_offset1, int *r_offset2)
ScrArea ScrArea * BKE_screen_find_area_xy(const bScreen *screen, int spacetype, const int xy[2]) ATTR_NONNULL(1
Definition screen.cc:1226
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 GPU_batch_program_set_builtin(gpu::Batch *batch, GPUBuiltinShader shader_id)
static gpu::Batch * batch_screen_edges_get(int *corner_len)
static void rounded_corners(rctf rect, float color[4], int corners)
void GPU_scissor(int x, int y, int width, int height)
Definition gpu_state.cc:178
void screen_animate_area_highlight(wmWindow *win, bScreen *screen, const rcti *rect, float inner[4], float outline[4], float seconds)
int BLF_height_max(int fontid) ATTR_WARN_UNUSED_RESULT
Definition blf.cc:883
void GPU_flush()
Definition gpu_state.cc:284
MINLINE float max_ff(float a, float b)
void GPU_vertbuf_data_alloc(gpu::VertBuf &verts, uint v_len)
int BLF_descender(int fontid) ATTR_WARN_UNUSED_RESULT
Definition blf.cc:905
void screen_draw_join_highlight(const wmWindow *win, ScrArea *sa1, ScrArea *sa2, eScreenDir dir, float anim_factor)
@ G_TRANSFORM_WM
void ED_screen_draw_edges(wmWindow *win)
double BLI_time_now_seconds()
Definition time.cc:30
MINLINE void copy_v4_v4(float r[4], const float a[4])
void GPU_blend(GPUBlend blend)
Definition gpu_state.cc:44
BLI_INLINE int BLI_rcti_cent_x(const struct rcti *rct)
Definition BLI_rect.hh:186
void * WM_draw_cb_activate(wmWindow *win, void(*draw)(const wmWindow *win, void *customdata), void *customdata)
Definition wm_draw.cc:639
static void drawscredge_area(const ScrArea &area, float edge_thickness)
Screen edges drawing.
void WM_window_screen_rect_calc(const wmWindow *win, rcti *r_rect)
bScreen * WM_window_get_active_screen(const wmWindow *win)
@ GPU_DEVICE_INTEL_UHD
void screen_draw_move_highlight(const wmWindow *win, bScreen *screen, eScreenAxis dir_axis, float anim_factor)
static void do_vert_pair(gpu::VertBuf *vbo, uint pos, uint *vidx, int corner, int i)
void BLI_rctf_pad(struct rctf *rect, float pad_x, float pad_y)
Definition rct.cc:651
void BLF_color4fv(int fontid, const float rgba[4])
Definition blf.cc:507
void screen_draw_region_scale_highlight(ARegion *region)
#define fabsf
#define sinf
#define cosf
#define CORNER_RESOLUTION
#define SCREEN_DIR_IS_VERTICAL(dir)
#define EDITORRADIUS
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
uiWidgetColors wcol_tooltip
ThemeUI tui
eRegion_Alignment alignment
ListBaseT< ScrArea > areabase
eScreen_State state
struct ARegion * active_region
ListBaseT< struct ScrEdge > edgebase
ListBaseT< struct ScrArea > areabase
ListBaseT< WindowDrawCB > drawcalls
bke::WindowRuntime * runtime
unsigned char inner[4]
unsigned char text[4]