Blender V5.0
view2d.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 <algorithm>
10#include <cfloat>
11#include <climits>
12#include <cmath>
13#include <cstring>
14
15#include "MEM_guardedalloc.h"
16
17#include "DNA_userdef_types.h"
18
19#include "BLI_link_utils.h"
20#include "BLI_listbase.h"
21#include "BLI_math_matrix.h"
22#include "BLI_memarena.h"
23#include "BLI_rect.h"
24#include "BLI_utildefines.h"
25
26#include "BKE_context.hh"
27#include "BKE_global.hh"
28#include "BKE_screen.hh"
29
30#include "GPU_immediate.hh"
31#include "GPU_matrix.hh"
32#include "GPU_state.hh"
33
34#include "WM_api.hh"
35
36#include "BLF_api.hh"
37
38#include "ED_screen.hh"
39
40#include "UI_interface.hh"
41#include "UI_view2d.hh"
42
43#include "view2d_intern.hh"
44
45static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize);
46
47/* -------------------------------------------------------------------- */
50
52{
53 const float min = float(INT_MIN);
54 const float max = float(INT_MAX);
55
56 if (UNLIKELY(f < min)) {
57 return min;
58 }
59 if (UNLIKELY(f > max)) {
60 return int(max);
61 }
62 return int(f);
63}
64
69BLI_INLINE void clamp_rctf_to_rcti(rcti *dst, const rctf *src)
70{
71 dst->xmin = clamp_float_to_int(src->xmin);
72 dst->xmax = clamp_float_to_int(src->xmax);
73 dst->ymin = clamp_float_to_int(src->ymin);
74 dst->ymax = clamp_float_to_int(src->ymax);
75}
76
77float view2d_page_size_y(const View2D &v2d)
78{
79 return v2d.page_size_y ? v2d.page_size_y : BLI_rcti_size_y(&v2d.mask);
80}
81
82/* XXX still unresolved: scrolls hide/unhide vs region mask handling */
83/* XXX there's V2D_SCROLL_HORIZONTAL_HIDE and V2D_SCROLL_HORIZONTAL_FULLR ... */
84
86
87/* -------------------------------------------------------------------- */
90
98static int view2d_scroll_mapped(int scroll)
99{
100 if (scroll & V2D_SCROLL_HORIZONTAL_FULLR) {
101 scroll &= ~V2D_SCROLL_HORIZONTAL;
102 }
103 if (scroll & V2D_SCROLL_VERTICAL_FULLR) {
104 scroll &= ~V2D_SCROLL_VERTICAL;
105 }
106 return scroll;
107}
108
109void UI_view2d_mask_from_win(const View2D *v2d, rcti *r_mask)
110{
111 r_mask->xmin = 0;
112 r_mask->ymin = 0;
113 r_mask->xmax = v2d->winx - 1; /* -1 yes! masks are pixels */
114 r_mask->ymax = v2d->winy - 1;
115}
116
122static void view2d_masks(View2D *v2d, const rcti *mask_scroll)
123{
124 int scroll;
125
126 /* mask - view frame */
127 UI_view2d_mask_from_win(v2d, &v2d->mask);
128 if (mask_scroll == nullptr) {
129 mask_scroll = &v2d->mask;
130 }
131
132 /* check size if hiding flag is set: */
135 if (BLI_rctf_size_x(&v2d->tot) > BLI_rctf_size_x(&v2d->cur)) {
137 }
138 else {
140 }
141 }
142 }
143 if (v2d->scroll & V2D_SCROLL_VERTICAL_HIDE) {
144 if (!(v2d->scroll & V2D_SCROLL_VERTICAL_HANDLES)) {
145 if (BLI_rctf_size_y(&v2d->tot) + 0.01f > BLI_rctf_size_y(&v2d->cur)) {
147 }
148 else {
150 }
151 }
152 }
153
154 /* Do not use mapped scroll here because we want to update scroller rects
155 * even if they are not displayed. For initialization purposes. See #75003. */
156 scroll = v2d->scroll;
157
158 /* Scrollers are based off region-size:
159 * - they can only be on one to two edges of the region they define
160 * - if they overlap, they must not occupy the corners (which are reserved for other widgets)
161 */
162 if (scroll) {
163 float scroll_width, scroll_height;
164
165 UI_view2d_scroller_size_get(v2d, false, &scroll_width, &scroll_height);
166
167 /* vertical scroller */
168 if (scroll & V2D_SCROLL_LEFT) {
169 /* on left-hand edge of region */
170 v2d->vert = *mask_scroll;
171 v2d->vert.xmax = v2d->vert.xmin + scroll_width;
172 }
173 else if (scroll & V2D_SCROLL_RIGHT) {
174 /* on right-hand edge of region */
175 v2d->vert = *mask_scroll;
176 v2d->vert.xmax++; /* one pixel extra... was leaving a minor gap... */
177 v2d->vert.xmin = v2d->vert.xmax - scroll_width;
178 }
179
180 /* horizontal scroller */
181 if (scroll & V2D_SCROLL_BOTTOM) {
182 /* on bottom edge of region */
183 v2d->hor = *mask_scroll;
184 v2d->hor.ymax = scroll_height;
185 }
186 else if (scroll & V2D_SCROLL_TOP) {
187 /* on upper edge of region */
188 v2d->hor = *mask_scroll;
189 v2d->hor.ymin = v2d->hor.ymax - scroll_height;
190 }
191
192 /* Adjust horizontal scroller to avoid interfering with splitter areas. */
193 if (scroll & V2D_SCROLL_HORIZONTAL) {
196 }
197
198 /* Adjust vertical scroller to avoid horizontal scrollers and splitter areas. */
199 if (scroll & V2D_SCROLL_VERTICAL) {
200 /* Note that top splitter areas are in the header,
201 * outside of `mask_scroll`, so we can ignore them. */
202 v2d->vert.ymin += UI_AZONESPOTH;
203 if (scroll & V2D_SCROLL_BOTTOM) {
204 /* on bottom edge of region */
205 v2d->vert.ymin = max_ii(v2d->hor.ymax, v2d->vert.ymin);
206 }
207 else if (scroll & V2D_SCROLL_TOP) {
208 /* on upper edge of region */
209 v2d->vert.ymax = v2d->hor.ymin;
210 }
211 }
212 }
213}
214
216
217/* -------------------------------------------------------------------- */
220
221void UI_view2d_region_reinit(View2D *v2d, short type, int winx, int winy)
222{
223 bool tot_changed = false, do_init;
224 const uiStyle *style = UI_style_get();
225
226 do_init = (v2d->flag & V2D_IS_INIT) == 0;
227
228 /* see eView2D_CommonViewTypes in UI_view2d.hh for available view presets */
229 switch (type) {
230 /* 'standard view' - optimum setup for 'standard' view behavior,
231 * that should be used new views as basis for their
232 * own unique View2D settings, which should be used instead of this in most cases...
233 */
235 /* for now, aspect ratio should be maintained,
236 * and zoom is clamped within sane default limits */
238 v2d->minzoom = 0.01f;
239 v2d->maxzoom = 1000.0f;
240
241 /* View2D tot rect and cur should be same size,
242 * and aligned using 'standard' OpenGL coordinates for now:
243 * - region can resize 'tot' later to fit other data
244 * - keeptot is only within bounds, as strict locking is not that critical
245 * - view is aligned for (0,0) -> (winx-1, winy-1) setup
246 */
249 if (do_init) {
250 v2d->tot.xmin = v2d->tot.ymin = 0.0f;
251 v2d->tot.xmax = float(winx - 1);
252 v2d->tot.ymax = float(winy - 1);
253
254 v2d->cur = v2d->tot;
255 }
256 /* scrollers - should we have these by default? */
257 /* XXX for now, we don't override this, or set it either! */
258 break;
259 }
260 /* 'list/channel view' - zoom, aspect ratio, and alignment restrictions are set here */
261 case V2D_COMMONVIEW_LIST: {
262 /* zoom + aspect ratio are locked */
264 v2d->minzoom = v2d->maxzoom = 1.0f;
265
266 /* tot rect has strictly regulated placement, and must only occur in +/- quadrant */
269 tot_changed = do_init;
270
271 /* scroller settings are currently not set here... that is left for regions... */
272 break;
273 }
274 /* 'stack view' - practically the same as list/channel view,
275 * except is located in the pos y half instead.
276 * Zoom, aspect ratio, and alignment restrictions are set here. */
278 /* zoom + aspect ratio are locked */
280 v2d->minzoom = v2d->maxzoom = 1.0f;
281
282 /* tot rect has strictly regulated placement, and must only occur in +/+ quadrant */
285 tot_changed = do_init;
286
287 /* scroller settings are currently not set here... that is left for regions... */
288 break;
289 }
290 /* 'header' regions - zoom, aspect ratio,
291 * alignment, and panning restrictions are set here */
293 /* zoom + aspect ratio are locked */
295 v2d->minzoom = v2d->maxzoom = 1.0f;
296
297 if (do_init) {
298 v2d->tot.xmin = 0.0f;
299 v2d->tot.xmax = winx;
300 v2d->tot.ymin = 0.0f;
301 v2d->tot.ymax = winy;
302 v2d->cur = v2d->tot;
303
304 v2d->min[0] = v2d->max[0] = float(winx - 1);
305 v2d->min[1] = v2d->max[1] = float(winy - 1);
306 }
307 /* tot rect has strictly regulated placement, and must only occur in +/+ quadrant */
310 tot_changed = do_init;
311
312 /* panning in y-axis is prohibited */
313 v2d->keepofs = V2D_LOCKOFS_Y;
314
315 /* absolutely no scrollers allowed */
316 v2d->scroll = 0;
317 break;
318 }
319 /* panels view, with horizontal/vertical align */
321
322 /* for now, aspect ratio should be maintained,
323 * and zoom is clamped within sane default limits */
325 v2d->minzoom = 0.5f;
326 v2d->maxzoom = 2.0f;
327
330
331 /* NOTE: scroll is being flipped in #ED_region_panels() drawing. */
333
334 if (do_init) {
335 const float panelzoom = (style) ? style->panelzoom : 1.0f;
336
337 v2d->tot.xmin = 0.0f;
338 v2d->tot.xmax = winx;
339
340 v2d->tot.ymax = 0.0f;
341 v2d->tot.ymin = -winy;
342
343 v2d->cur.xmin = 0.0f;
344 v2d->cur.xmax = (winx)*panelzoom;
345
346 v2d->cur.ymax = 0.0f;
347 v2d->cur.ymin = (-winy) * panelzoom;
348 }
349 break;
350 }
351 /* other view types are completely defined using their own settings already */
352 default:
353 /* we don't do anything here,
354 * as settings should be fine, but just make sure that rect */
355 break;
356 }
357
358 /* set initialized flag so that View2D doesn't get reinitialized next time again */
359 v2d->flag |= V2D_IS_INIT;
360
361 /* store view size */
362 v2d->winx = winx;
363 v2d->winy = winy;
364
365 view2d_masks(v2d, nullptr);
366
367 if (do_init) {
368 /* Visible by default. */
369 v2d->alpha_hor = v2d->alpha_vert = 255;
370 }
371
372 /* set 'tot' rect before setting cur? */
373 /* XXX confusing stuff here still */
374 if (tot_changed) {
375 view2d_totRect_set_resize(v2d, winx, winy, !do_init);
376 }
377 else {
379 }
380}
381
386static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize)
387{
388 /* NOTE: #calculateZfac uses this logic, keep in sync. */
389 float totwidth, totheight, curwidth, curheight, width, height;
390 float winx, winy;
391 rctf *cur, *tot;
392
393 /* use mask as size of region that View2D resides in, as it takes into account
394 * scroll-bars already - keep in sync with `zoomx/zoomy` in #view_zoomstep_apply_ex! */
395 winx = float(BLI_rcti_size_x(&v2d->mask) + 1);
396 winy = float(BLI_rcti_size_y(&v2d->mask) + 1);
397
398 /* get pointers to rcts for less typing */
399 cur = &v2d->cur;
400 tot = &v2d->tot;
401
402 /* we must satisfy the following constraints (in decreasing order of importance):
403 * - alignment restrictions are respected
404 * - cur must not fall outside of tot
405 * - axis locks (zoom and offset) must be maintained
406 * - zoom must not be excessive (check either sizes or zoom values)
407 * - aspect ratio should be respected (NOTE: this is quite closely related to zoom too)
408 */
409
410 /* Step 1: if keepzoom, adjust the sizes of the rects only
411 * - firstly, we calculate the sizes of the rects
412 * - curwidth and curheight are saved as reference... modify width and height values here
413 */
414 totwidth = BLI_rctf_size_x(tot);
415 totheight = BLI_rctf_size_y(tot);
416 /* Keep in sync with `zoomx/zoomy` in #view_zoomstep_apply_ex! */
417 curwidth = width = BLI_rctf_size_x(cur);
418 curheight = height = BLI_rctf_size_y(cur);
419
420 /* if zoom is locked, size on the appropriate axis is reset to mask size */
421 if (v2d->keepzoom & V2D_LOCKZOOM_X) {
422 width = winx;
423 }
424 if (v2d->keepzoom & V2D_LOCKZOOM_Y) {
425 height = winy;
426 }
427
428 /* values used to divide, so make it safe
429 * NOTE: width and height must use FLT_MIN instead of 1, otherwise it is impossible to
430 * get enough resolution in Graph Editor for editing some curves
431 */
432 if (width < FLT_MIN) {
433 width = 1;
434 }
435 if (height < FLT_MIN) {
436 height = 1;
437 }
438 winx = std::max<float>(winx, 1);
439 winy = std::max<float>(winy, 1);
440 if (v2d->oldwinx == 0) {
441 v2d->oldwinx = winx;
442 }
443 if (v2d->oldwiny == 0) {
444 v2d->oldwiny = winy;
445 }
446
447 /* V2D_KEEPZOOM indicates that zoom level should be preserved when the window size changes. */
448 if (resize && (v2d->keepzoom & V2D_KEEPZOOM)) {
449 float zoom, oldzoom;
450
451 if ((v2d->keepzoom & V2D_LOCKZOOM_X) == 0) {
452 zoom = winx / width;
453 oldzoom = v2d->oldwinx / curwidth;
454
455 if (oldzoom != zoom) {
456 width *= zoom / oldzoom;
457 }
458 }
459
460 if ((v2d->keepzoom & V2D_LOCKZOOM_Y) == 0) {
461 zoom = winy / height;
462 oldzoom = v2d->oldwiny / curheight;
463
464 if (oldzoom != zoom) {
465 height *= zoom / oldzoom;
466 }
467 }
468 }
469 /* keepzoom (V2D_LIMITZOOM set), indicates that zoom level on each axis must not exceed limits
470 * NOTE: in general, it is not expected that the lock-zoom will be used in conjunction with this
471 */
472 else if (v2d->keepzoom & V2D_LIMITZOOM) {
473
474 /* check if excessive zoom on x-axis */
475 if ((v2d->keepzoom & V2D_LOCKZOOM_X) == 0) {
476 const float zoom = winx / width;
477 if (zoom < v2d->minzoom) {
478 width = winx / v2d->minzoom;
479 }
480 else if (zoom > v2d->maxzoom) {
481 width = winx / v2d->maxzoom;
482 }
483 }
484
485 /* check if excessive zoom on y-axis */
486 if ((v2d->keepzoom & V2D_LOCKZOOM_Y) == 0) {
487 const float zoom = winy / height;
488 if (zoom < v2d->minzoom) {
489 height = winy / v2d->minzoom;
490 }
491 else if (zoom > v2d->maxzoom) {
492 height = winy / v2d->maxzoom;
493 }
494 }
495 }
496 else {
497 /* make sure sizes don't exceed that of the min/max sizes
498 * (even though we're not doing zoom clamping) */
499 CLAMP(width, v2d->min[0], v2d->max[0]);
500 CLAMP(height, v2d->min[1], v2d->max[1]);
501 }
502
503 /* check if we should restore aspect ratio (if view size changed) */
504 if (v2d->keepzoom & V2D_KEEPASPECT) {
505 bool do_x = false, do_y = false, do_cur;
506 float curRatio, winRatio;
507
508 /* when a window edge changes, the aspect ratio can't be used to
509 * find which is the best new 'cur' rect. that's why it stores 'old'
510 */
511 if (winx != v2d->oldwinx) {
512 do_x = true;
513 }
514 if (winy != v2d->oldwiny) {
515 do_y = true;
516 }
517
518 curRatio = height / width;
519 winRatio = winy / winx;
520
521 /* Both sizes change (area/region maximized). */
522 if (do_x == do_y) {
523 if (do_x && do_y) {
524 /* here is 1,1 case, so all others must be 0,0 */
525 if (fabsf(winx - v2d->oldwinx) > fabsf(winy - v2d->oldwiny)) {
526 do_y = false;
527 }
528 else {
529 do_x = false;
530 }
531 }
532 else if (winRatio > curRatio) {
533 do_x = false;
534 }
535 else {
536 do_x = true;
537 }
538 }
539 do_cur = do_x;
540 // do_win = do_y; /* UNUSED. */
541
542 if (do_cur) {
543 if ((v2d->keeptot == V2D_KEEPTOT_STRICT) && (winx != v2d->oldwinx)) {
544 /* Special exception for Outliner (and later channel-lists):
545 * - The view may be moved left to avoid contents
546 * being pushed out of view when view shrinks.
547 * - The keeptot code will make sure cur->xmin will not be less than tot->xmin
548 * (which cannot be allowed).
549 * - width is not adjusted for changed ratios here.
550 */
551 if (winx < v2d->oldwinx) {
552 const float temp = v2d->oldwinx - winx;
553
554 cur->xmin -= temp;
555 cur->xmax -= temp;
556
557 /* Width does not get modified, as keep-aspect here is just set to make
558 * sure visible area adjusts to changing view shape! */
559 }
560 }
561 else {
562 /* portrait window: correct for x */
563 width = height / winRatio;
564 }
565 }
566 else {
567 if ((v2d->keeptot == V2D_KEEPTOT_STRICT) && (winy != v2d->oldwiny)) {
568 /* special exception for Outliner (and later channel-lists):
569 * - Currently, no actions need to be taken here...
570 */
571
572 if (winy < v2d->oldwiny) {
573 const float temp = v2d->oldwiny - winy;
574
575 if (v2d->align & V2D_ALIGN_NO_NEG_Y) {
576 cur->ymin -= temp;
577 cur->ymax -= temp;
578 }
579 else { /* Assume V2D_ALIGN_NO_POS_Y or combination */
580 cur->ymin += temp;
581 cur->ymax += temp;
582 }
583 }
584 }
585 else {
586 /* landscape window: correct for y */
587 height = width * winRatio;
588 }
589 }
590 }
591
592 /* Store region size for next time. */
593 v2d->oldwinx = short(winx);
594 v2d->oldwiny = short(winy);
595
596 /* Step 2: apply new sizes to cur rect,
597 * but need to take into account alignment settings here... */
598 const bool do_keepofs = resize || !(v2d->flag & V2D_ZOOM_IGNORE_KEEPOFS);
599 if ((width != curwidth) || (height != curheight)) {
600 float temp, dh;
601
602 /* Resize from center-point, unless otherwise specified. */
603 if (width != curwidth) {
604 if (v2d->keepofs & V2D_LOCKOFS_X) {
605 cur->xmax += width - BLI_rctf_size_x(cur);
606 }
607 else if ((v2d->keepofs & V2D_KEEPOFS_X) && do_keepofs) {
608 if (v2d->align & V2D_ALIGN_NO_POS_X) {
609 cur->xmin -= width - BLI_rctf_size_x(cur);
610 }
611 else {
612 cur->xmax += width - BLI_rctf_size_x(cur);
613 }
614 }
615 else {
616 temp = BLI_rctf_cent_x(cur);
617 dh = width * 0.5f;
618
619 cur->xmin = temp - dh;
620 cur->xmax = temp + dh;
621 }
622 }
623 if (height != curheight) {
624 if (v2d->keepofs & V2D_LOCKOFS_Y) {
625 cur->ymax += height - BLI_rctf_size_y(cur);
626 }
627 else if ((v2d->keepofs & V2D_KEEPOFS_Y) && do_keepofs) {
628 if (v2d->align & V2D_ALIGN_NO_POS_Y) {
629 cur->ymin -= height - BLI_rctf_size_y(cur);
630 }
631 else {
632 cur->ymax += height - BLI_rctf_size_y(cur);
633 }
634 }
635 else {
636 temp = BLI_rctf_cent_y(cur);
637 dh = height * 0.5f;
638
639 cur->ymin = temp - dh;
640 cur->ymax = temp + dh;
641 }
642 }
643 }
644
645 /* Step 3: adjust so that it doesn't fall outside of bounds of 'tot' */
646 if (v2d->keeptot) {
647 float temp, diff;
648
649 /* recalculate extents of cur */
650 curwidth = BLI_rctf_size_x(cur);
651 curheight = BLI_rctf_size_y(cur);
652
653 /* width */
654 if ((curwidth > totwidth) &&
656 {
657 /* if zoom doesn't have to be maintained, just clamp edges */
658 cur->xmin = std::max(cur->xmin, tot->xmin);
659 cur->xmax = std::min(cur->xmax, tot->xmax);
660 }
661 else if (v2d->keeptot == V2D_KEEPTOT_STRICT) {
662 /* This is an exception for the outliner (and later channel-lists, headers)
663 * - must clamp within tot rect (absolutely no excuses)
664 * --> therefore, cur->xmin must not be less than tot->xmin
665 */
666 if (cur->xmin < tot->xmin) {
667 /* move cur across so that it sits at minimum of tot */
668 temp = tot->xmin - cur->xmin;
669
670 cur->xmin += temp;
671 cur->xmax += temp;
672 }
673 else if (cur->xmax > tot->xmax) {
674 /* - only offset by difference of cur-xmax and tot-xmax if that would not move
675 * cur-xmin to lie past tot-xmin
676 * - otherwise, simply shift to tot-xmin???
677 */
678 temp = cur->xmax - tot->xmax;
679
680 if ((cur->xmin - temp) < tot->xmin) {
681 /* only offset by difference from cur-min and tot-min */
682 temp = cur->xmin - tot->xmin;
683
684 cur->xmin -= temp;
685 cur->xmax -= temp;
686 }
687 else {
688 cur->xmin -= temp;
689 cur->xmax -= temp;
690 }
691 }
692 }
693 else {
694 /* This here occurs when:
695 * - width too big, but maintaining zoom (i.e. widths cannot be changed)
696 * - width is OK, but need to check if outside of boundaries
697 *
698 * So, resolution is to just shift view by the gap between the extremities.
699 * We favor moving the 'minimum' across, as that's origin for most things.
700 * (XXX: in the past, max was favored... if there are bugs, swap!)
701 */
702 if ((cur->xmin < tot->xmin) && (cur->xmax > tot->xmax)) {
703 /* outside boundaries on both sides,
704 * so take middle-point of tot, and place in balanced way */
705 temp = BLI_rctf_cent_x(tot);
706 diff = curwidth * 0.5f;
707
708 cur->xmin = temp - diff;
709 cur->xmax = temp + diff;
710 }
711 else if (cur->xmin < tot->xmin) {
712 /* move cur across so that it sits at minimum of tot */
713 temp = tot->xmin - cur->xmin;
714
715 cur->xmin += temp;
716 cur->xmax += temp;
717 }
718 else if (cur->xmax > tot->xmax) {
719 /* - only offset by difference of cur-xmax and tot-xmax if that would not move
720 * cur-xmin to lie past tot-xmin
721 * - otherwise, simply shift to tot-xmin???
722 */
723 temp = cur->xmax - tot->xmax;
724
725 if ((cur->xmin - temp) < tot->xmin) {
726 /* only offset by difference from cur-min and tot-min */
727 temp = cur->xmin - tot->xmin;
728
729 cur->xmin -= temp;
730 cur->xmax -= temp;
731 }
732 else {
733 cur->xmin -= temp;
734 cur->xmax -= temp;
735 }
736 }
737 }
738
739 /* height */
740 if ((curheight > totheight) &&
742 {
743 /* if zoom doesn't have to be maintained, just clamp edges */
744 cur->ymin = std::max(cur->ymin, tot->ymin);
745 cur->ymax = std::min(cur->ymax, tot->ymax);
746 }
747 else {
748 /* This here occurs when:
749 * - height too big, but maintaining zoom (i.e. heights cannot be changed)
750 * - height is OK, but need to check if outside of boundaries
751 *
752 * So, resolution is to just shift view by the gap between the extremities.
753 * We favor moving the 'minimum' across, as that's origin for most things.
754 */
755 if ((cur->ymin < tot->ymin) && (cur->ymax > tot->ymax)) {
756 /* outside boundaries on both sides,
757 * so take middle-point of tot, and place in balanced way */
758 temp = BLI_rctf_cent_y(tot);
759 diff = curheight * 0.5f;
760
761 cur->ymin = temp - diff;
762 cur->ymax = temp + diff;
763 }
764 else if (cur->ymin < tot->ymin) {
765 /* there's still space remaining, so shift up */
766 temp = tot->ymin - cur->ymin;
767
768 cur->ymin += temp;
769 cur->ymax += temp;
770 }
771 else if (cur->ymax > tot->ymax) {
772 /* there's still space remaining, so shift down */
773 temp = cur->ymax - tot->ymax;
774
775 cur->ymin -= temp;
776 cur->ymax -= temp;
777 }
778 }
779 }
780
781 /* Step 4: Make sure alignment restrictions are respected */
782 if (v2d->align) {
783 /* If alignment flags are set (but keeptot is not), they must still be respected, as although
784 * they don't specify any particular bounds to stay within, they do define ranges which are
785 * invalid.
786 *
787 * Here, we only check to make sure that on each axis, the 'cur' rect doesn't stray into these
788 * invalid zones, otherwise we offset.
789 */
790
791 /* handle width - posx and negx flags are mutually exclusive, so watch out */
792 if ((v2d->align & V2D_ALIGN_NO_POS_X) && !(v2d->align & V2D_ALIGN_NO_NEG_X)) {
793 /* width is in negative-x half */
794 if (v2d->cur.xmax > 0) {
795 v2d->cur.xmin -= v2d->cur.xmax;
796 v2d->cur.xmax = 0.0f;
797 }
798 }
799 else if ((v2d->align & V2D_ALIGN_NO_NEG_X) && !(v2d->align & V2D_ALIGN_NO_POS_X)) {
800 /* width is in positive-x half */
801 if (v2d->cur.xmin < 0) {
802 v2d->cur.xmax -= v2d->cur.xmin;
803 v2d->cur.xmin = 0.0f;
804 }
805 }
806
807 /* handle height - posx and negx flags are mutually exclusive, so watch out */
808 if ((v2d->align & V2D_ALIGN_NO_POS_Y) && !(v2d->align & V2D_ALIGN_NO_NEG_Y)) {
809 /* height is in negative-y half */
810 if (v2d->cur.ymax > 0) {
811 v2d->cur.ymin -= v2d->cur.ymax;
812 v2d->cur.ymax = 0.0f;
813 }
814 }
815 else if ((v2d->align & V2D_ALIGN_NO_NEG_Y) && !(v2d->align & V2D_ALIGN_NO_POS_Y)) {
816 /* height is in positive-y half */
817 if (v2d->cur.ymin < 0) {
818 v2d->cur.ymax -= v2d->cur.ymin;
819 v2d->cur.ymin = 0.0f;
820 }
821 }
822 }
823
824 /* set masks */
825 view2d_masks(v2d, nullptr);
826}
827
832
834{
836
837 ARegion *region = CTX_wm_region(C);
838
839 if (region->runtime->type->on_view2d_changed != nullptr) {
840 region->runtime->type->on_view2d_changed(C, region);
841 }
842}
843
845{
846 const float cur_height_y = BLI_rctf_size_y(&v2d->cur);
847
848 if (BLI_rctf_size_y(&v2d->cur) > BLI_rctf_size_y(&v2d->tot)) {
849 v2d->cur.ymin = -cur_height_y;
850 v2d->cur.ymax = 0;
851 }
852 else if (v2d->cur.ymin < v2d->tot.ymin) {
853 v2d->cur.ymin = v2d->tot.ymin;
854 v2d->cur.ymax = v2d->cur.ymin + cur_height_y;
855 }
856}
857
858/* ------------------ */
859
864
865void UI_view2d_sync(bScreen *screen, ScrArea *area, View2D *v2dcur, int flag)
866{
867 /* don't continue if no view syncing to be done */
869 return;
870 }
871
872 /* check if doing within area syncing (i.e. channels/vertical) */
873 if ((v2dcur->flag & V2D_VIEWSYNC_AREA_VERTICAL) && (area)) {
874 LISTBASE_FOREACH (ARegion *, region, &area->regionbase) {
875 /* don't operate on self */
876 if (v2dcur != &region->v2d) {
877 /* only if view has vertical locks enabled */
878 if (region->v2d.flag & V2D_VIEWSYNC_AREA_VERTICAL) {
879 if (flag == V2D_LOCK_COPY) {
880 /* other views with locks on must copy active */
881 region->v2d.cur.ymin = v2dcur->cur.ymin;
882 region->v2d.cur.ymax = v2dcur->cur.ymax;
883 }
884 else { /* V2D_LOCK_SET */
885 /* active must copy others */
886 v2dcur->cur.ymin = region->v2d.cur.ymin;
887 v2dcur->cur.ymax = region->v2d.cur.ymax;
888 }
889
890 /* region possibly changed, so refresh */
892 }
893 }
894 }
895 }
896
897 /* check if doing whole screen syncing (i.e. time/horizontal) */
898 if ((v2dcur->flag & V2D_VIEWSYNC_SCREEN_TIME) && (screen)) {
899 LISTBASE_FOREACH (ScrArea *, area_iter, &screen->areabase) {
900 if (!UI_view2d_area_supports_sync(area_iter)) {
901 continue;
902 }
903 LISTBASE_FOREACH (ARegion *, region, &area_iter->regionbase) {
904 /* don't operate on self */
905 if (v2dcur != &region->v2d) {
906 /* only if view has horizontal locks enabled */
907 if (region->v2d.flag & V2D_VIEWSYNC_SCREEN_TIME) {
908 if (flag == V2D_LOCK_COPY) {
909 /* other views with locks on must copy active */
910 region->v2d.cur.xmin = v2dcur->cur.xmin;
911 region->v2d.cur.xmax = v2dcur->cur.xmax;
912 }
913 else { /* V2D_LOCK_SET */
914 /* active must copy others */
915 v2dcur->cur.xmin = region->v2d.cur.xmin;
916 v2dcur->cur.xmax = region->v2d.cur.xmax;
917 }
918
919 /* region possibly changed, so refresh */
921 }
922 }
923 }
924 }
925 }
926}
927
929{
930 float width, height;
931
932 /* assume width and height of 'cur' rect by default, should be same size as mask */
933 width = float(BLI_rcti_size_x(&v2d->mask) + 1);
934 height = float(BLI_rcti_size_y(&v2d->mask) + 1);
935
936 /* handle width - posx and negx flags are mutually exclusive, so watch out */
937 if ((v2d->align & V2D_ALIGN_NO_POS_X) && !(v2d->align & V2D_ALIGN_NO_NEG_X)) {
938 /* width is in negative-x half */
939 v2d->cur.xmin = -width;
940 v2d->cur.xmax = 0.0f;
941 }
942 else if ((v2d->align & V2D_ALIGN_NO_NEG_X) && !(v2d->align & V2D_ALIGN_NO_POS_X)) {
943 /* width is in positive-x half */
944 v2d->cur.xmin = 0.0f;
945 v2d->cur.xmax = width;
946 }
947 else {
948 /* width is centered around (x == 0) */
949 const float dx = width / 2.0f;
950
951 v2d->cur.xmin = -dx;
952 v2d->cur.xmax = dx;
953 }
954
955 /* handle height - posx and negx flags are mutually exclusive, so watch out */
956 if ((v2d->align & V2D_ALIGN_NO_POS_Y) && !(v2d->align & V2D_ALIGN_NO_NEG_Y)) {
957 /* height is in negative-y half */
958 v2d->cur.ymin = -height;
959 v2d->cur.ymax = 0.0f;
960 }
961 else if ((v2d->align & V2D_ALIGN_NO_NEG_Y) && !(v2d->align & V2D_ALIGN_NO_POS_Y)) {
962 /* height is in positive-y half */
963 v2d->cur.ymin = 0.0f;
964 v2d->cur.ymax = height;
965 }
966 else {
967 /* height is centered around (y == 0) */
968 const float dy = height / 2.0f;
969
970 v2d->cur.ymin = -dy;
971 v2d->cur.ymax = dy;
972 }
973}
974
975/* ------------------ */
976
977void view2d_totRect_set_resize(View2D *v2d, int width, int height, bool resize)
978{
979 /* don't do anything if either value is 0 */
980 width = abs(width);
981 height = abs(height);
982
983 if (ELEM(0, width, height)) {
984 if (G.debug & G_DEBUG) {
985 /* XXX: temp debug info. */
986 printf("Error: View2D totRect set exiting: v2d=%p width=%d height=%d\n",
987 (void *)v2d,
988 width,
989 height);
990 }
991 return;
992 }
993
994 /* handle width - posx and negx flags are mutually exclusive, so watch out */
995 if ((v2d->align & V2D_ALIGN_NO_POS_X) && !(v2d->align & V2D_ALIGN_NO_NEG_X)) {
996 /* width is in negative-x half */
997 v2d->tot.xmin = float(-width);
998 v2d->tot.xmax = 0.0f;
999 }
1000 else if ((v2d->align & V2D_ALIGN_NO_NEG_X) && !(v2d->align & V2D_ALIGN_NO_POS_X)) {
1001 /* width is in positive-x half */
1002 v2d->tot.xmin = 0.0f;
1003 v2d->tot.xmax = float(width);
1004 }
1005 else {
1006 /* width is centered around (x == 0) */
1007 const float dx = float(width) / 2.0f;
1008
1009 v2d->tot.xmin = -dx;
1010 v2d->tot.xmax = dx;
1011 }
1012
1013 /* handle height - posx and negx flags are mutually exclusive, so watch out */
1014 if ((v2d->align & V2D_ALIGN_NO_POS_Y) && !(v2d->align & V2D_ALIGN_NO_NEG_Y)) {
1015 /* height is in negative-y half */
1016 v2d->tot.ymin = float(-height);
1017 v2d->tot.ymax = 0.0f;
1018 }
1019 else if ((v2d->align & V2D_ALIGN_NO_NEG_Y) && !(v2d->align & V2D_ALIGN_NO_POS_Y)) {
1020 /* height is in positive-y half */
1021 v2d->tot.ymin = 0.0f;
1022 v2d->tot.ymax = float(height);
1023 }
1024 else {
1025 /* height is centered around (y == 0) */
1026 const float dy = float(height) / 2.0f;
1027
1028 v2d->tot.ymin = -dy;
1029 v2d->tot.ymax = dy;
1030 }
1031
1032 /* make sure that 'cur' rect is in a valid state as a result of these changes */
1034}
1035
1036void UI_view2d_totRect_set(View2D *v2d, int width, int height)
1037{
1038 view2d_totRect_set_resize(v2d, width, height, false);
1039}
1040
1042{
1043 /* TODO(sergey): This way we avoid threading conflict with sequencer rendering
1044 * text strip. But ideally we want to make glyph cache to be fully safe
1045 * for threading.
1046 */
1047 if (G.is_rendering) {
1048 return;
1049 }
1050 /* While scaling we can accumulate fonts at many sizes (~20 or so).
1051 * Not an issue with embedded font, but can use over 500Mb with i18n ones! See #38244. */
1052
1053 /* NOTE: only some views draw text, we could check for this case to avoid cleaning cache. */
1055}
1056
1058
1059/* -------------------------------------------------------------------- */
1062
1063/* mapping function to ensure 'cur' draws extended over the area where sliders are */
1064static void view2d_map_cur_using_mask(const View2D *v2d, rctf *r_curmasked)
1065{
1066 *r_curmasked = v2d->cur;
1067
1068 if (view2d_scroll_mapped(v2d->scroll)) {
1069 const float sizex = BLI_rcti_size_x(&v2d->mask);
1070 const float sizey = BLI_rcti_size_y(&v2d->mask);
1071
1072 /* prevent tiny or narrow regions to get
1073 * invalid coordinates - mask can get negative even... */
1074 if (sizex > 0.0f && sizey > 0.0f) {
1075 const float dx = BLI_rctf_size_x(&v2d->cur) / (sizex + 1);
1076 const float dy = BLI_rctf_size_y(&v2d->cur) / (sizey + 1);
1077
1078 if (v2d->mask.xmin != 0) {
1079 r_curmasked->xmin -= dx * float(v2d->mask.xmin);
1080 }
1081 if (v2d->mask.xmax + 1 != v2d->winx) {
1082 r_curmasked->xmax += dx * float(v2d->winx - v2d->mask.xmax - 1);
1083 }
1084
1085 if (v2d->mask.ymin != 0) {
1086 r_curmasked->ymin -= dy * float(v2d->mask.ymin);
1087 }
1088 if (v2d->mask.ymax + 1 != v2d->winy) {
1089 r_curmasked->ymax += dy * float(v2d->winy - v2d->mask.ymax - 1);
1090 }
1091 }
1092 }
1093}
1094
1096{
1097 rctf curmasked;
1098 const int sizex = BLI_rcti_size_x(&v2d->mask);
1099 const int sizey = BLI_rcti_size_y(&v2d->mask);
1100 const float eps = 0.001f;
1101 float xofs = 0.0f, yofs = 0.0f;
1102
1103 /* Pixel offsets (-GLA_PIXEL_OFS) are needed to get 1:1
1104 * correspondence with pixels for smooth UI drawing,
1105 * but only applied where requested.
1106 */
1107 /* XXX(@brecht): instead of zero at least use a tiny offset, otherwise
1108 * pixel rounding is effectively random due to float inaccuracy */
1109 if (sizex > 0) {
1110 xofs = eps * BLI_rctf_size_x(&v2d->cur) / sizex;
1111 }
1112 if (sizey > 0) {
1113 yofs = eps * BLI_rctf_size_y(&v2d->cur) / sizey;
1114 }
1115
1116 /* apply mask-based adjustments to cur rect (due to scrollers),
1117 * to eliminate scaling artifacts */
1118 view2d_map_cur_using_mask(v2d, &curmasked);
1119
1120 BLI_rctf_translate(&curmasked, -xofs, -yofs);
1121
1122 /* XXX ton: this flag set by outliner, for icons */
1123 if (v2d->flag & V2D_PIXELOFS_X) {
1124 curmasked.xmin = floorf(curmasked.xmin) - (eps + xofs);
1125 curmasked.xmax = floorf(curmasked.xmax) - (eps + xofs);
1126 }
1127 if (v2d->flag & V2D_PIXELOFS_Y) {
1128 curmasked.ymin = floorf(curmasked.ymin) - (eps + yofs);
1129 curmasked.ymax = floorf(curmasked.ymax) - (eps + yofs);
1130 }
1131
1132 /* set matrix on all appropriate axes */
1133 wmOrtho2(curmasked.xmin, curmasked.xmax, curmasked.ymin, curmasked.ymax);
1134}
1135
1136void UI_view2d_view_orthoSpecial(ARegion *region, View2D *v2d, const bool xaxis)
1137{
1138 rctf curmasked;
1139 float xofs, yofs;
1140
1141 /* Pixel offsets (-GLA_PIXEL_OFS) are needed to get 1:1
1142 * correspondence with pixels for smooth UI drawing,
1143 * but only applied where requested.
1144 */
1145 /* XXX(ton): temp. */
1146 xofs = 0.0f; // (v2d->flag & V2D_PIXELOFS_X) ? GLA_PIXEL_OFS : 0.0f;
1147 yofs = 0.0f; // (v2d->flag & V2D_PIXELOFS_Y) ? GLA_PIXEL_OFS : 0.0f;
1148
1149 /* apply mask-based adjustments to cur rect (due to scrollers),
1150 * to eliminate scaling artifacts */
1151 view2d_map_cur_using_mask(v2d, &curmasked);
1152
1153 /* only set matrix with 'cur' coordinates on relevant axes */
1154 if (xaxis) {
1155 wmOrtho2(curmasked.xmin - xofs, curmasked.xmax - xofs, -yofs, region->winy - yofs);
1156 }
1157 else {
1158 wmOrtho2(-xofs, region->winx - xofs, curmasked.ymin - yofs, curmasked.ymax - yofs);
1159 }
1160}
1161
1163{
1164 ARegion *region = CTX_wm_region(C);
1165 const int width = BLI_rcti_size_x(&region->winrct) + 1;
1166 const int height = BLI_rcti_size_y(&region->winrct) + 1;
1167
1168 wmOrtho2(0.0f, float(width), 0.0f, float(height));
1170
1171 // ED_region_pixelspace(CTX_wm_region(C));
1172}
1173
1175
1176/* -------------------------------------------------------------------- */
1179
1181 const View2D *v2d, int colorid, float step, int level_size, int totlevels)
1182{
1183 /* Exit if there is nothing to draw */
1184 if (totlevels == 0) {
1185 return;
1186 }
1187
1188 int offset = -10;
1189 float lstep = step;
1190 uchar grid_line_color[3];
1191
1192 /* Make an estimate of at least how many vertices will be needed */
1193 uint vertex_count = 4;
1194 vertex_count += 2 * (int((v2d->cur.xmax - v2d->cur.xmin) / lstep) + 1);
1195 vertex_count += 2 * (int((v2d->cur.ymax - v2d->cur.ymin) / lstep) + 1);
1196
1199 format, "pos", blender::gpu::VertAttrType::SFLOAT_32_32);
1200 uint color = GPU_vertformat_attr_add(format, "color", blender::gpu::VertAttrType::UNORM_8_8_8_8);
1201
1202 GPU_line_width(1.0f);
1203
1205 immBeginAtMost(GPU_PRIM_LINES, vertex_count);
1206
1207 for (int level = 0; level < totlevels; level++) {
1208 /* Blend the background color (colorid) with the grid color, to avoid either too low contrast
1209 * or high contrast grid lines. This only has an effect if colorid != TH_GRID. */
1210 UI_GetThemeColorBlendShade3ubv(colorid, TH_GRID, 0.25f, offset, grid_line_color);
1211
1212 int i = int(v2d->cur.xmin / lstep);
1213 if (v2d->cur.xmin > 0.0f) {
1214 i++;
1215 }
1216 float start = i * lstep;
1217
1218 for (; start < v2d->cur.xmax; start += lstep, i++) {
1219 if (i == 0 || (level < totlevels - 1 && i % level_size == 0)) {
1220 continue;
1221 }
1222
1223 immAttrSkip(color);
1224 immVertex2f(pos, start, v2d->cur.ymin);
1225 immAttr4ub(color, UNPACK3(grid_line_color), 255);
1226 immVertex2f(pos, start, v2d->cur.ymax);
1227 }
1228
1229 i = int(v2d->cur.ymin / lstep);
1230 if (v2d->cur.ymin > 0.0f) {
1231 i++;
1232 }
1233 start = i * lstep;
1234
1235 for (; start < v2d->cur.ymax; start += lstep, i++) {
1236 if (i == 0 || (level < totlevels - 1 && i % level_size == 0)) {
1237 continue;
1238 }
1239
1240 immAttrSkip(color);
1241 immVertex2f(pos, v2d->cur.xmin, start);
1242 immAttr4ub(color, UNPACK3(grid_line_color), 255);
1243 immVertex2f(pos, v2d->cur.xmax, start);
1244 }
1245
1246 lstep *= level_size;
1247 offset -= 6;
1248 }
1249
1250 /* X and Y axis */
1252 colorid, TH_GRID, 0.5f, -18 + ((totlevels - 1) * -6), grid_line_color);
1253
1254 immAttrSkip(color);
1255 immVertex2f(pos, 0.0f, v2d->cur.ymin);
1256 immAttr4ub(color, UNPACK3(grid_line_color), 255);
1257 immVertex2f(pos, 0.0f, v2d->cur.ymax);
1258
1259 immAttrSkip(color);
1260 immVertex2f(pos, v2d->cur.xmin, 0.0f);
1261 immAttr4ub(color, UNPACK3(grid_line_color), 255);
1262 immVertex2f(pos, v2d->cur.xmax, 0.0f);
1263
1264 immEnd();
1266}
1267
1269 const float step, const float min, const float max, float *r_start, int *r_count)
1270{
1271 *r_start = min;
1272 if (*r_start < 0.0f) {
1273 *r_start += -fmod(min, step);
1274 }
1275 else {
1276 *r_start += step - fabs(fmod(min, step));
1277 }
1278
1279 if (*r_start > max) {
1280 *r_count = 0;
1281 }
1282 else {
1283 *r_count = (max - *r_start) / step + 1;
1284 }
1285}
1286
1288 const int grid_color_id,
1289 const float min_step,
1290 const int grid_subdivisions)
1291{
1292 BLI_assert(grid_subdivisions >= 0 && grid_subdivisions < 4);
1293 if (grid_subdivisions == 0) {
1294 return;
1295 }
1296
1297 const float zoom_x = float(BLI_rcti_size_x(&v2d->mask) + 1) / BLI_rctf_size_x(&v2d->cur);
1298
1301 format, "pos", blender::gpu::VertAttrType::SFLOAT_32_32);
1304
1305 /* Scaling the dots fully with the zoom looks too busy, but a bit of size variation is nice. */
1306 const float min_point_size = 2.0f * U.pixelsize;
1307 const float point_size_factor = 1.5f;
1308 const float max_point_size = point_size_factor * min_point_size;
1309
1310 /* Each consecutive grid level is five times larger than the previous. */
1311 const int subdivision_scale = 5;
1312
1313 const float view_level = logf(min_step / zoom_x) / logf(subdivision_scale);
1314 const int largest_visible_level = int(view_level);
1315
1316 for (int level_offset = 0; level_offset <= grid_subdivisions; level_offset++) {
1317 const int level = largest_visible_level - level_offset;
1318
1319 if (level < 0) {
1320 break;
1321 }
1322
1323 const float level_scale = powf(subdivision_scale, level);
1324 const float point_size_precise = min_point_size * level_scale * zoom_x;
1325 const float point_size_draw = ceilf(
1326 clamp_f(point_size_precise, min_point_size, max_point_size));
1327
1328 /* Offset point by this amount to better align centers as size changes. */
1329 const float point_size_offset = (point_size_draw / 2.0f) - U.pixelsize;
1330
1331 /* To compensate the for the clamped point_size we adjust the alpha to make the overall
1332 * brightness of the grid background more consistent. */
1333 const float alpha = pow2f(point_size_precise / point_size_draw);
1334
1335 /* Make sure we don't draw points once the alpha gets too low. */
1336 const float alpha_cutoff = 0.01f;
1337 if (alpha < alpha_cutoff) {
1338 break;
1339 }
1340 const float alpha_clamped = clamp_f((1.0f + alpha_cutoff) * alpha - alpha_cutoff, 0.0f, 1.0f);
1341
1342 /* If we have don't draw enough subdivision levels so they fade out naturally, we apply an
1343 * additional fade to the last level to avoid pop in. */
1344 const bool last_level = level_offset == grid_subdivisions;
1345 const float subdivision_fade = last_level ? (1.0f - fractf(view_level)) : 1.0f;
1346
1347 float color[4];
1348 UI_GetThemeColor3fv(grid_color_id, color);
1349 color[3] = alpha_clamped * subdivision_fade;
1350
1351 const float step = min_step * level_scale;
1352 int count_x;
1353 float start_x;
1354
1355 /* Count points that fit in viewport. */
1356 grid_axis_start_and_count(step, v2d->cur.xmin, v2d->cur.xmax, &start_x, &count_x);
1357 int count_y;
1358 float start_y;
1359 grid_axis_start_and_count(step, v2d->cur.ymin, v2d->cur.ymax, &start_y, &count_y);
1360 if (count_x == 0 || count_y == 0) {
1361 continue;
1362 }
1363
1364 immUniform1f("size", point_size_draw);
1365 immUniform4fv("color", color);
1366 immBegin(GPU_PRIM_POINTS, count_x * count_y);
1367
1368 /* Theoretically drawing on top of lower grid levels could be avoided, but it would also
1369 * increase the complexity of this loop, which isn't worth the time at the moment. */
1370 for (int i_y = 0; i_y < count_y; i_y++) {
1371 const float y = start_y + step * i_y;
1372 for (int i_x = 0; i_x < count_x; i_x++) {
1373 const float x = start_x + step * i_x;
1374 immVertex2f(pos, x + point_size_offset, y + point_size_offset);
1375 }
1376 }
1377
1378 immEnd();
1379 }
1380
1383}
1384
1386
1387/* -------------------------------------------------------------------- */
1390
1391void view2d_scrollers_calc(View2D *v2d, const rcti *mask_custom, View2DScrollers *r_scrollers)
1392{
1393 rcti vert, hor;
1394 float fac1, fac2, totsize, scrollsize;
1395 const int scroll = view2d_scroll_mapped(v2d->scroll);
1396
1397 /* Always update before drawing (for dynamically sized scrollers). */
1398 view2d_masks(v2d, mask_custom);
1399
1400 vert = v2d->vert;
1401 hor = v2d->hor;
1402
1403 /* Pad scroll-bar drawing away from region edges. */
1404 const int edge_pad = int(0.1f * U.widget_unit);
1405 if (scroll & V2D_SCROLL_BOTTOM) {
1406 hor.ymin += edge_pad;
1407 }
1408 else {
1409 hor.ymax -= edge_pad;
1410 }
1411
1412 if (scroll & V2D_SCROLL_LEFT) {
1413 vert.xmin += edge_pad;
1414 }
1415 else {
1416 vert.xmax -= edge_pad;
1417 }
1418
1421
1422 /* store in scrollers, used for drawing */
1423 r_scrollers->vert = vert;
1424 r_scrollers->hor = hor;
1425
1426 /* scroller 'buttons':
1427 * - These should always remain within the visible region of the scroll-bar
1428 * - They represent the region of 'tot' that is visible in 'cur'
1429 */
1430
1431 /* horizontal scrollers */
1432 if (scroll & V2D_SCROLL_HORIZONTAL) {
1433 /* scroller 'button' extents */
1434 totsize = BLI_rctf_size_x(&v2d->tot);
1435 scrollsize = float(BLI_rcti_size_x(&hor));
1436 if (totsize == 0.0f) {
1437 totsize = 1.0f; /* avoid divide by zero */
1438 }
1439
1440 fac1 = (v2d->cur.xmin - v2d->tot.xmin) / totsize;
1441 if (fac1 <= 0.0f) {
1442 r_scrollers->hor_min = hor.xmin;
1443 }
1444 else {
1445 r_scrollers->hor_min = int(hor.xmin + (fac1 * scrollsize));
1446 }
1447
1448 fac2 = (v2d->cur.xmax - v2d->tot.xmin) / totsize;
1449 if (fac2 >= 1.0f) {
1450 r_scrollers->hor_max = hor.xmax;
1451 }
1452 else {
1453 r_scrollers->hor_max = int(hor.xmin + (fac2 * scrollsize));
1454 }
1455
1456 /* prevent inverted sliders */
1457 r_scrollers->hor_min = std::min(r_scrollers->hor_min, r_scrollers->hor_max);
1458 /* prevent sliders from being too small to grab */
1459 if ((r_scrollers->hor_max - r_scrollers->hor_min) < V2D_SCROLL_THUMB_SIZE_MIN) {
1460 r_scrollers->hor_max = r_scrollers->hor_min + V2D_SCROLL_THUMB_SIZE_MIN;
1461
1462 CLAMP(r_scrollers->hor_max, hor.xmin + V2D_SCROLL_THUMB_SIZE_MIN, hor.xmax);
1463 CLAMP(r_scrollers->hor_min, hor.xmin, hor.xmax - V2D_SCROLL_THUMB_SIZE_MIN);
1464 }
1465 }
1466
1467 /* vertical scrollers */
1468 if (scroll & V2D_SCROLL_VERTICAL) {
1469 /* scroller 'button' extents */
1470 totsize = BLI_rctf_size_y(&v2d->tot);
1471 scrollsize = float(BLI_rcti_size_y(&vert));
1472 if (totsize == 0.0f) {
1473 totsize = 1.0f; /* avoid divide by zero */
1474 }
1475
1476 fac1 = (v2d->cur.ymin - v2d->tot.ymin) / totsize;
1477 if (fac1 <= 0.0f) {
1478 r_scrollers->vert_min = vert.ymin;
1479 }
1480 else {
1481 r_scrollers->vert_min = int(vert.ymin + (fac1 * scrollsize));
1482 }
1483
1484 fac2 = (v2d->cur.ymax - v2d->tot.ymin) / totsize;
1485 if (fac2 >= 1.0f) {
1486 r_scrollers->vert_max = vert.ymax;
1487 }
1488 else {
1489 r_scrollers->vert_max = int(vert.ymin + (fac2 * scrollsize));
1490 }
1491
1492 /* prevent inverted sliders */
1493 r_scrollers->vert_min = std::min(r_scrollers->vert_min, r_scrollers->vert_max);
1494 /* prevent sliders from being too small to grab */
1495 if ((r_scrollers->vert_max - r_scrollers->vert_min) < V2D_SCROLL_THUMB_SIZE_MIN) {
1496 r_scrollers->vert_max = r_scrollers->vert_min + V2D_SCROLL_THUMB_SIZE_MIN;
1497
1498 CLAMP(r_scrollers->vert_max, vert.ymin + V2D_SCROLL_THUMB_SIZE_MIN, vert.ymax);
1499 CLAMP(r_scrollers->vert_min, vert.ymin, vert.ymax - V2D_SCROLL_THUMB_SIZE_MIN);
1500 }
1501 }
1502}
1503
1504void UI_view2d_scrollers_draw(View2D *v2d, const rcti *mask_custom)
1505{
1506 View2DScrollers scrollers;
1507 view2d_scrollers_calc(v2d, mask_custom, &scrollers);
1508 bTheme *btheme = UI_GetTheme();
1509 rcti vert, hor;
1510 const int scroll = view2d_scroll_mapped(v2d->scroll);
1511 const char emboss_alpha = btheme->tui.widget_emboss[3];
1512 const float alpha_min = V2D_SCROLL_MIN_ALPHA;
1513
1514 uchar scrollers_back_color[4];
1515
1516 /* Color for scroll-bar backs. */
1517 UI_GetThemeColor4ubv(TH_BACK, scrollers_back_color);
1518
1519 /* make copies of rects for less typing */
1520 vert = scrollers.vert;
1521 hor = scrollers.hor;
1522
1523 /* Horizontal scroll-bar. */
1524 if (scroll & V2D_SCROLL_HORIZONTAL) {
1525 uiWidgetColors wcol = btheme->tui.wcol_scroll;
1526 /* 0..255 -> min...1 */
1527 const float alpha_fac = ((v2d->alpha_hor / 255.0f) * (1.0f - alpha_min)) + alpha_min;
1528 rcti slider;
1529 int state;
1530
1531 slider.xmin = scrollers.hor_min;
1532 slider.xmax = scrollers.hor_max;
1533 slider.ymin = hor.ymin;
1534 slider.ymax = hor.ymax;
1535
1537
1538 /* In the case that scroll-bar track is invisible, range from 0 ->`final_alpha` instead to
1539 * avoid errors with users trying to click into the underlying view. */
1540 if (wcol.inner[3] == 0) {
1541 const float final_alpha = 0.25f;
1542 wcol.inner[3] = final_alpha * v2d->alpha_hor;
1543 }
1544 else {
1545 wcol.inner[3] *= alpha_fac;
1546 }
1547 wcol.item[3] *= alpha_fac;
1548 wcol.outline[3] = 0;
1549 btheme->tui.widget_emboss[3] = 0; /* will be reset later */
1550
1551 /* show zoom handles if:
1552 * - zooming on x-axis is allowed (no scroll otherwise)
1553 * - slider bubble is large enough (no overdraw confusion)
1554 * - scale is shown on the scroller
1555 * (workaround to make sure that button windows don't show these,
1556 * and only the time-grids with their zoom-ability can do so).
1557 */
1558 if ((v2d->keepzoom & V2D_LOCKZOOM_X) == 0 && (v2d->scroll & V2D_SCROLL_HORIZONTAL_HANDLES) &&
1560 {
1562 }
1563
1564 UI_draw_widget_scroll(&wcol, &hor, &slider, state);
1565 }
1566
1567 /* Vertical scroll-bar. */
1568 if (scroll & V2D_SCROLL_VERTICAL) {
1569 uiWidgetColors wcol = btheme->tui.wcol_scroll;
1570 rcti slider;
1571 /* 0..255 -> min...1 */
1572 const float alpha_fac = ((v2d->alpha_vert / 255.0f) * (1.0f - alpha_min)) + alpha_min;
1573 int state;
1574
1575 slider.xmin = vert.xmin;
1576 slider.xmax = vert.xmax;
1577 slider.ymin = scrollers.vert_min;
1578 slider.ymax = scrollers.vert_max;
1579
1581
1582 /* In the case that scroll-bar track is invisible, range from 0 ->`final_alpha` instead to
1583 * avoid errors with users trying to click into the underlying view. */
1584 if (wcol.inner[3] == 0) {
1585 const float final_alpha = 0.25f;
1586 wcol.inner[3] = final_alpha * v2d->alpha_vert;
1587 }
1588 else {
1589 wcol.inner[3] *= alpha_fac;
1590 }
1591 wcol.item[3] *= alpha_fac;
1592 wcol.outline[3] = 0;
1593 btheme->tui.widget_emboss[3] = 0; /* will be reset later */
1594
1595 /* show zoom handles if:
1596 * - zooming on y-axis is allowed (no scroll otherwise)
1597 * - slider bubble is large enough (no overdraw confusion)
1598 * - scale is shown on the scroller
1599 * (workaround to make sure that button windows don't show these,
1600 * and only the time-grids with their zoomability can do so)
1601 */
1602 if ((v2d->keepzoom & V2D_LOCKZOOM_Y) == 0 && (v2d->scroll & V2D_SCROLL_VERTICAL_HANDLES) &&
1604 {
1606 }
1607
1608 UI_draw_widget_scroll(&wcol, &vert, &slider, state);
1609 }
1610
1611 /* Was changed above, so reset. */
1612 btheme->tui.widget_emboss[3] = emboss_alpha;
1613}
1614
1616
1617/* -------------------------------------------------------------------- */
1620
1621void UI_view2d_listview_view_to_cell(float columnwidth,
1622 float rowheight,
1623 float startx,
1624 float starty,
1625 float viewx,
1626 float viewy,
1627 int *r_column,
1628 int *r_row)
1629{
1630 if (r_column) {
1631 if (columnwidth > 0) {
1632 /* Columns go from left to right (x increases). */
1633 *r_column = floorf((viewx - startx) / columnwidth);
1634 }
1635 else {
1636 *r_column = 0;
1637 }
1638 }
1639
1640 if (r_row) {
1641 if (rowheight > 0) {
1642 /* Rows got from top to bottom (y decreases). */
1643 *r_row = floorf((starty - viewy) / rowheight);
1644 }
1645 else {
1646 *r_row = 0;
1647 }
1648 }
1649}
1650
1652
1653/* -------------------------------------------------------------------- */
1656
1657float UI_view2d_region_to_view_x(const View2D *v2d, float x)
1658{
1659 return (v2d->cur.xmin +
1660 (BLI_rctf_size_x(&v2d->cur) * (x - v2d->mask.xmin) / BLI_rcti_size_x(&v2d->mask)));
1661}
1662float UI_view2d_region_to_view_y(const View2D *v2d, float y)
1663{
1664 return (v2d->cur.ymin +
1665 (BLI_rctf_size_y(&v2d->cur) * (y - v2d->mask.ymin) / BLI_rcti_size_y(&v2d->mask)));
1666}
1667
1669 const View2D *v2d, float x, float y, float *r_view_x, float *r_view_y)
1670{
1671 *r_view_x = UI_view2d_region_to_view_x(v2d, x);
1672 *r_view_y = UI_view2d_region_to_view_y(v2d, y);
1673}
1674
1675void UI_view2d_region_to_view_rctf(const View2D *v2d, const rctf *rect_src, rctf *rect_dst)
1676{
1677 const float cur_size[2] = {BLI_rctf_size_x(&v2d->cur), BLI_rctf_size_y(&v2d->cur)};
1678 const float mask_size[2] = {float(BLI_rcti_size_x(&v2d->mask)),
1679 float(BLI_rcti_size_y(&v2d->mask))};
1680
1681 rect_dst->xmin = (v2d->cur.xmin +
1682 (cur_size[0] * (rect_src->xmin - v2d->mask.xmin) / mask_size[0]));
1683 rect_dst->xmax = (v2d->cur.xmin +
1684 (cur_size[0] * (rect_src->xmax - v2d->mask.xmin) / mask_size[0]));
1685 rect_dst->ymin = (v2d->cur.ymin +
1686 (cur_size[1] * (rect_src->ymin - v2d->mask.ymin) / mask_size[1]));
1687 rect_dst->ymax = (v2d->cur.ymin +
1688 (cur_size[1] * (rect_src->ymax - v2d->mask.ymin) / mask_size[1]));
1689}
1690
1691float UI_view2d_view_to_region_x(const View2D *v2d, float x)
1692{
1693 return (v2d->mask.xmin + (((x - v2d->cur.xmin) / BLI_rctf_size_x(&v2d->cur)) *
1694 float(BLI_rcti_size_x(&v2d->mask) + 1)));
1695}
1696float UI_view2d_view_to_region_y(const View2D *v2d, float y)
1697{
1698 return (v2d->mask.ymin + (((y - v2d->cur.ymin) / BLI_rctf_size_y(&v2d->cur)) *
1699 float(BLI_rcti_size_y(&v2d->mask) + 1)));
1700}
1701
1703 const View2D *v2d, float x, float y, int *r_region_x, int *r_region_y)
1704{
1705 /* express given coordinates as proportional values */
1706 x = (x - v2d->cur.xmin) / BLI_rctf_size_x(&v2d->cur);
1707 y = (y - v2d->cur.ymin) / BLI_rctf_size_y(&v2d->cur);
1708
1709 /* check if values are within bounds */
1710 if ((x >= 0.0f) && (x <= 1.0f) && (y >= 0.0f) && (y <= 1.0f)) {
1711 *r_region_x = int(v2d->mask.xmin + (x * BLI_rcti_size_x(&v2d->mask)));
1712 *r_region_y = int(v2d->mask.ymin + (y * BLI_rcti_size_y(&v2d->mask)));
1713
1714 return true;
1715 }
1716
1717 /* set initial value in case coordinate lies outside of bounds */
1718 *r_region_x = *r_region_y = V2D_IS_CLIPPED;
1719
1720 return false;
1721}
1722
1724 const View2D *v2d, float x, float y, int *r_region_x, int *r_region_y)
1725{
1726 /* Step 1: express given coordinates as proportional values. */
1727 x = (x - v2d->cur.xmin) / BLI_rctf_size_x(&v2d->cur);
1728 y = (y - v2d->cur.ymin) / BLI_rctf_size_y(&v2d->cur);
1729
1730 /* Step 2: convert proportional distances to screen coordinates. */
1731 x = v2d->mask.xmin + (x * BLI_rcti_size_x(&v2d->mask));
1732 y = v2d->mask.ymin + (y * BLI_rcti_size_y(&v2d->mask));
1733
1734 /* Although we don't clamp to lie within region bounds, we must avoid exceeding size of ints. */
1735 *r_region_x = clamp_float_to_int(x);
1736 *r_region_y = clamp_float_to_int(y);
1737}
1738
1740 const View2D *v2d, float x, float y, float *r_region_x, float *r_region_y)
1741{
1742 /* express given coordinates as proportional values */
1743 x = (x - v2d->cur.xmin) / BLI_rctf_size_x(&v2d->cur);
1744 y = (y - v2d->cur.ymin) / BLI_rctf_size_y(&v2d->cur);
1745
1746 /* convert proportional distances to screen coordinates */
1747 *r_region_x = v2d->mask.xmin + (x * BLI_rcti_size_x(&v2d->mask));
1748 *r_region_y = v2d->mask.ymin + (y * BLI_rcti_size_y(&v2d->mask));
1749}
1750
1752 const float xy_a[2],
1753 const float xy_b[2],
1754 int r_region_a[2],
1755 int r_region_b[2])
1756{
1757 rctf rect_unit;
1758 rect_unit.xmin = rect_unit.ymin = 0.0f;
1759 rect_unit.xmax = rect_unit.ymax = 1.0f;
1760
1761 /* Express given coordinates as proportional values. */
1762 const float s_a[2] = {
1763 (xy_a[0] - v2d->cur.xmin) / BLI_rctf_size_x(&v2d->cur),
1764 (xy_a[1] - v2d->cur.ymin) / BLI_rctf_size_y(&v2d->cur),
1765 };
1766 const float s_b[2] = {
1767 (xy_b[0] - v2d->cur.xmin) / BLI_rctf_size_x(&v2d->cur),
1768 (xy_b[1] - v2d->cur.ymin) / BLI_rctf_size_y(&v2d->cur),
1769 };
1770
1771 /* Set initial value in case coordinates lie outside bounds. */
1772 r_region_a[0] = r_region_b[0] = r_region_a[1] = r_region_b[1] = V2D_IS_CLIPPED;
1773
1774 if (BLI_rctf_isect_segment(&rect_unit, s_a, s_b)) {
1775 r_region_a[0] = int(v2d->mask.xmin + (s_a[0] * BLI_rcti_size_x(&v2d->mask)));
1776 r_region_a[1] = int(v2d->mask.ymin + (s_a[1] * BLI_rcti_size_y(&v2d->mask)));
1777 r_region_b[0] = int(v2d->mask.xmin + (s_b[0] * BLI_rcti_size_x(&v2d->mask)));
1778 r_region_b[1] = int(v2d->mask.ymin + (s_b[1] * BLI_rcti_size_y(&v2d->mask)));
1779
1780 return true;
1781 }
1782
1783 return false;
1784}
1785
1786void UI_view2d_view_to_region_rcti(const View2D *v2d, const rctf *rect_src, rcti *rect_dst)
1787{
1788 const float cur_size[2] = {BLI_rctf_size_x(&v2d->cur), BLI_rctf_size_y(&v2d->cur)};
1789 const float mask_size[2] = {float(BLI_rcti_size_x(&v2d->mask)),
1790 float(BLI_rcti_size_y(&v2d->mask))};
1791 rctf rect_tmp;
1792
1793 /* Step 1: express given coordinates as proportional values. */
1794 rect_tmp.xmin = (rect_src->xmin - v2d->cur.xmin) / cur_size[0];
1795 rect_tmp.xmax = (rect_src->xmax - v2d->cur.xmin) / cur_size[0];
1796 rect_tmp.ymin = (rect_src->ymin - v2d->cur.ymin) / cur_size[1];
1797 rect_tmp.ymax = (rect_src->ymax - v2d->cur.ymin) / cur_size[1];
1798
1799 /* Step 2: convert proportional distances to screen coordinates. */
1800 rect_tmp.xmin = v2d->mask.xmin + (rect_tmp.xmin * mask_size[0]);
1801 rect_tmp.xmax = v2d->mask.xmin + (rect_tmp.xmax * mask_size[0]);
1802 rect_tmp.ymin = v2d->mask.ymin + (rect_tmp.ymin * mask_size[1]);
1803 rect_tmp.ymax = v2d->mask.ymin + (rect_tmp.ymax * mask_size[1]);
1804
1805 clamp_rctf_to_rcti(rect_dst, &rect_tmp);
1806}
1807
1808void UI_view2d_view_to_region_m4(const View2D *v2d, float matrix[4][4])
1809{
1810 rctf mask;
1811 unit_m4(matrix);
1812 BLI_rctf_rcti_copy(&mask, &v2d->mask);
1814}
1815
1816bool UI_view2d_view_to_region_rcti_clip(const View2D *v2d, const rctf *rect_src, rcti *rect_dst)
1817{
1818 const float cur_size[2] = {BLI_rctf_size_x(&v2d->cur), BLI_rctf_size_y(&v2d->cur)};
1819 const float mask_size[2] = {float(BLI_rcti_size_x(&v2d->mask) + 1),
1820 float(BLI_rcti_size_y(&v2d->mask) + 1)};
1821 rctf rect_tmp;
1822
1823 BLI_assert(rect_src->xmin <= rect_src->xmax && rect_src->ymin <= rect_src->ymax);
1824
1825 /* Step 1: express given coordinates as proportional values. */
1826 rect_tmp.xmin = (rect_src->xmin - v2d->cur.xmin) / cur_size[0];
1827 rect_tmp.xmax = (rect_src->xmax - v2d->cur.xmin) / cur_size[0];
1828 rect_tmp.ymin = (rect_src->ymin - v2d->cur.ymin) / cur_size[1];
1829 rect_tmp.ymax = (rect_src->ymax - v2d->cur.ymin) / cur_size[1];
1830
1831 if (((rect_tmp.xmax < 0.0f) || (rect_tmp.xmin > 1.0f) || (rect_tmp.ymax < 0.0f) ||
1832 (rect_tmp.ymin > 1.0f)) == 0)
1833 {
1834 /* Step 2: convert proportional distances to screen coordinates. */
1835 rect_tmp.xmin = v2d->mask.xmin + (rect_tmp.xmin * mask_size[0]);
1836 rect_tmp.xmax = v2d->mask.ymin + (rect_tmp.xmax * mask_size[0]);
1837 rect_tmp.ymin = v2d->mask.ymin + (rect_tmp.ymin * mask_size[1]);
1838 rect_tmp.ymax = v2d->mask.ymin + (rect_tmp.ymax * mask_size[1]);
1839
1840 clamp_rctf_to_rcti(rect_dst, &rect_tmp);
1841
1842 return true;
1843 }
1844
1845 rect_dst->xmin = rect_dst->xmax = rect_dst->ymin = rect_dst->ymax = V2D_IS_CLIPPED;
1846 return false;
1847}
1848
1850
1851/* -------------------------------------------------------------------- */
1854
1856{
1857 ScrArea *area = CTX_wm_area(C);
1858 ARegion *region = CTX_wm_region(C);
1859
1860 if (area == nullptr) {
1861 return nullptr;
1862 }
1863 if (region == nullptr) {
1864 return nullptr;
1865 }
1866 return &(region->v2d);
1867}
1868
1870{
1871 ScrArea *area = CTX_wm_area(C);
1872 ARegion *region = CTX_wm_region(C);
1873
1874 if (area == nullptr) {
1875 return nullptr;
1876 }
1877 if (region == nullptr) {
1878 return nullptr;
1879 }
1880 if (region->regiontype != RGN_TYPE_WINDOW) {
1882 return region_win ? &(region_win->v2d) : nullptr;
1883 }
1884 return &(region->v2d);
1885}
1886
1887void UI_view2d_scroller_size_get(const View2D *v2d, bool mapped, float *r_x, float *r_y)
1888{
1889 const int scroll = (mapped) ? view2d_scroll_mapped(v2d->scroll) : v2d->scroll;
1890
1891 if (r_x) {
1892 if (scroll & V2D_SCROLL_VERTICAL) {
1894 *r_x = ((*r_x - V2D_SCROLL_MIN_WIDTH) * (v2d->alpha_vert / 255.0f)) + V2D_SCROLL_MIN_WIDTH;
1895 }
1896 else {
1897 *r_x = 0;
1898 }
1899 }
1900 if (r_y) {
1901 if (scroll & V2D_SCROLL_HORIZONTAL) {
1904 *r_y = ((*r_y - V2D_SCROLL_MIN_WIDTH) * (v2d->alpha_hor / 255.0f)) + V2D_SCROLL_MIN_WIDTH;
1905 }
1906 else {
1907 *r_y = 0;
1908 }
1909 }
1910}
1911
1912void UI_view2d_scale_get(const View2D *v2d, float *r_x, float *r_y)
1913{
1914 if (r_x) {
1915 *r_x = UI_view2d_scale_get_x(v2d);
1916 }
1917 if (r_y) {
1918 *r_y = UI_view2d_scale_get_y(v2d);
1919 }
1920}
1922{
1923 return BLI_rcti_size_x(&v2d->mask) / BLI_rctf_size_x(&v2d->cur);
1924}
1926{
1927 return BLI_rcti_size_y(&v2d->mask) / BLI_rctf_size_y(&v2d->cur);
1928}
1929void UI_view2d_scale_get_inverse(const View2D *v2d, float *r_x, float *r_y)
1930{
1931 if (r_x) {
1932 *r_x = BLI_rctf_size_x(&v2d->cur) / BLI_rcti_size_x(&v2d->mask);
1933 }
1934 if (r_y) {
1935 *r_y = BLI_rctf_size_y(&v2d->cur) / BLI_rcti_size_y(&v2d->mask);
1936 }
1937}
1938
1939void UI_view2d_center_get(const View2D *v2d, float *r_x, float *r_y)
1940{
1941 /* get center */
1942 if (r_x) {
1943 *r_x = BLI_rctf_cent_x(&v2d->cur);
1944 }
1945 if (r_y) {
1946 *r_y = BLI_rctf_cent_y(&v2d->cur);
1947 }
1948}
1949void UI_view2d_center_set(View2D *v2d, float x, float y)
1950{
1951 BLI_rctf_recenter(&v2d->cur, x, y);
1952
1953 /* make sure that 'cur' rect is in a valid state as a result of these changes */
1955}
1956
1957void UI_view2d_offset(View2D *v2d, float xfac, float yfac)
1958{
1959 if (xfac != -1.0f) {
1960 const float xsize = BLI_rctf_size_x(&v2d->cur);
1961 const float xmin = v2d->tot.xmin;
1962 const float xmax = v2d->tot.xmax - xsize;
1963
1964 v2d->cur.xmin = (xmin * (1.0f - xfac)) + (xmax * xfac);
1965 v2d->cur.xmax = v2d->cur.xmin + xsize;
1966 }
1967
1968 if (yfac != -1.0f) {
1969 const float ysize = BLI_rctf_size_y(&v2d->cur);
1970 const float ymin = v2d->tot.ymin;
1971 const float ymax = v2d->tot.ymax - ysize;
1972
1973 v2d->cur.ymin = (ymin * (1.0f - yfac)) + (ymax * yfac);
1974 v2d->cur.ymax = v2d->cur.ymin + ysize;
1975 }
1976
1978}
1979
1981{
1982 const float cur_size_y = BLI_rctf_size_y(&v2d->cur);
1983 const float page_size_y = view2d_page_size_y(*v2d);
1984
1985 v2d->cur.ymax = roundf(v2d->cur.ymax / page_size_y) * page_size_y;
1986 v2d->cur.ymin = v2d->cur.ymax - cur_size_y;
1987
1989}
1990
1992 const View2D *v2d,
1993 const int xy[2],
1994 int *r_scroll)
1995{
1996 const int scroll = view2d_scroll_mapped(v2d->scroll);
1997 *r_scroll = scroll;
1998
1999 if (scroll) {
2000 /* Move to region-coordinates. */
2001 const int co[2] = {
2002 xy[0] - region->winrct.xmin,
2003 xy[1] - region->winrct.ymin,
2004 };
2005 if (scroll & V2D_SCROLL_HORIZONTAL) {
2006 if (IN_2D_HORIZ_SCROLL(v2d, co)) {
2007 return 'h';
2008 }
2009 }
2010 if (scroll & V2D_SCROLL_VERTICAL) {
2011 if (IN_2D_VERT_SCROLL(v2d, co)) {
2012 return 'v';
2013 }
2014 }
2015 }
2016
2017 return 0;
2018}
2019
2021 const View2D *v2d,
2022 const rcti *rect,
2023 int *r_scroll)
2024{
2025 const int scroll = view2d_scroll_mapped(v2d->scroll);
2026 *r_scroll = scroll;
2027
2028 if (scroll) {
2029 /* Move to region-coordinates. */
2030 rcti rect_region = *rect;
2031 BLI_rcti_translate(&rect_region, -region->winrct.xmin, region->winrct.ymin);
2032 if (scroll & V2D_SCROLL_HORIZONTAL) {
2033 if (IN_2D_HORIZ_SCROLL_RECT(v2d, &rect_region)) {
2034 return 'h';
2035 }
2036 }
2037 if (scroll & V2D_SCROLL_VERTICAL) {
2038 if (IN_2D_VERT_SCROLL_RECT(v2d, &rect_region)) {
2039 return 'v';
2040 }
2041 }
2042 }
2043
2044 return 0;
2045}
2046
2047char UI_view2d_mouse_in_scrollers(const ARegion *region, const View2D *v2d, const int xy[2])
2048{
2049 int scroll_dummy = 0;
2050 return UI_view2d_mouse_in_scrollers_ex(region, v2d, xy, &scroll_dummy);
2051}
2052
2053char UI_view2d_rect_in_scrollers(const ARegion *region, const View2D *v2d, const rcti *rect)
2054{
2055 int scroll_dummy = 0;
2056 return UI_view2d_rect_in_scrollers_ex(region, v2d, rect, &scroll_dummy);
2057}
2058
2060
2061/* -------------------------------------------------------------------- */
2064
2067 union {
2069 int pack;
2072 int mval[2];
2073
2074 /* str is allocated past the end */
2075 char str[0];
2076};
2077
2078/* assumes caches are used correctly, so for time being no local storage in v2d */
2080static View2DString *g_v2d_strings = nullptr;
2081
2083 View2D *v2d, float x, float y, const char *str, size_t str_len, const uchar col[4])
2084{
2085 int mval[2];
2086
2087 BLI_assert(str_len == strlen(str));
2088
2089 if (UI_view2d_view_to_region_clip(v2d, x, y, &mval[0], &mval[1])) {
2090 const int alloc_len = str_len + 1;
2091
2092 if (g_v2d_strings_arena == nullptr) {
2094 }
2095
2096 View2DString *v2s = static_cast<View2DString *>(
2098
2100
2101 v2s->col.pack = *((const int *)col);
2102
2103 v2s->rect = rcti{};
2104
2105 v2s->mval[0] = mval[0];
2106 v2s->mval[1] = mval[1];
2107
2108 memcpy(v2s->str, str, alloc_len);
2109 }
2110}
2111
2113 View2D *v2d, const rctf *rect_view, const char *str, size_t str_len, const uchar col[4])
2114{
2115 rcti rect;
2116
2117 BLI_assert(str_len == strlen(str));
2118
2119 if (UI_view2d_view_to_region_rcti_clip(v2d, rect_view, &rect)) {
2120 const int alloc_len = str_len + 1;
2121
2122 if (g_v2d_strings_arena == nullptr) {
2124 }
2125
2126 View2DString *v2s = static_cast<View2DString *>(
2128
2130
2131 v2s->col.pack = *((const int *)col);
2132
2133 v2s->rect = rect;
2134
2135 v2s->mval[0] = v2s->rect.xmin;
2136 v2s->mval[1] = v2s->rect.ymin;
2137
2138 memcpy(v2s->str, str, alloc_len);
2139 }
2140}
2141
2143{
2144 View2DString *v2s;
2145 int col_pack_prev = 0;
2146
2147 /* investigate using BLF_ascender() */
2148 const int font_id = BLF_default();
2149
2151 const float default_height = g_v2d_strings ? BLF_height(font_id, "28", 3) : 0.0f;
2152
2154
2155 for (v2s = g_v2d_strings; v2s; v2s = v2s->next) {
2156 int xofs = 0, yofs;
2157
2158 yofs = ceil(0.5f * (BLI_rcti_size_y(&v2s->rect) - default_height));
2159 yofs = std::max(yofs, 1);
2160
2161 if (col_pack_prev != v2s->col.pack) {
2162 BLF_color4ubv(font_id, v2s->col.ub);
2163 col_pack_prev = v2s->col.pack;
2164 }
2165
2166 /* Don't use clipping if `v2s->rect` is not set. */
2167 if (BLI_rcti_size_x(&v2s->rect) == 0 && BLI_rcti_size_y(&v2s->rect) == 0) {
2168 BLF_draw_default(float(v2s->mval[0] + xofs),
2169 float(v2s->mval[1] + yofs),
2170 0.0,
2171 v2s->str,
2173 }
2174 else {
2175 BLF_enable(font_id, BLF_CLIPPING);
2177 font_id, v2s->rect.xmin - 4, v2s->rect.ymin - 4, v2s->rect.xmax + 4, v2s->rect.ymax + 4);
2179 v2s->rect.xmin + xofs, v2s->rect.ymin + yofs, 0.0f, v2s->str, BLF_DRAW_STR_DUMMY_MAX);
2180 BLF_disable(font_id, BLF_CLIPPING);
2181 }
2182 }
2183 g_v2d_strings = nullptr;
2184
2185 if (g_v2d_strings_arena) {
2187 g_v2d_strings_arena = nullptr;
2188 }
2189}
2190
ScrArea * CTX_wm_area(const bContext *C)
ARegion * CTX_wm_region(const bContext *C)
@ G_DEBUG
ARegion * BKE_area_find_region_type(const ScrArea *area, int region_type)
Definition screen.cc:846
int BLF_set_default()
void BLF_enable(int fontid, FontFlags flag)
Definition blf.cc:320
float BLF_height(int fontid, const char *str, size_t str_len, ResultBLF *r_info=nullptr) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(2)
Definition blf.cc:837
void BLF_clipping(int fontid, int xmin, int ymin, int xmax, int ymax)
Definition blf.cc:912
#define BLF_DRAW_STR_DUMMY_MAX
Definition BLF_api.hh:440
int BLF_default()
void BLF_cache_clear()
Definition blf.cc:98
void BLF_disable(int fontid, FontFlags flag)
Definition blf.cc:329
void BLF_color4ubv(int fontid, const unsigned char rgba[4])
Definition blf.cc:452
void BLF_draw_default(float x, float y, float z, const char *str, size_t str_len) ATTR_NONNULL()
@ BLF_CLIPPING
Definition BLF_enums.hh:34
#define BLI_assert(a)
Definition BLI_assert.h:46
#define BLI_INLINE
#define LISTBASE_FOREACH(type, var, list)
MINLINE float pow2f(float x)
MINLINE float clamp_f(float value, float min, float max)
MINLINE int max_ii(int a, int b)
void unit_m4(float m[4][4])
MemArena * BLI_memarena_new(size_t bufsize, const char *name) ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL ATTR_NONNULL(2) ATTR_MALLOC
void BLI_memarena_free(MemArena *ma) ATTR_NONNULL(1)
void * BLI_memarena_alloc(MemArena *ma, size_t size) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC ATTR_ALLOC_SIZE(2)
void BLI_rctf_translate(struct rctf *rect, float x, float y)
Definition rct.cc:573
BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
Definition BLI_rect.h:198
BLI_INLINE float BLI_rctf_cent_y(const struct rctf *rct)
Definition BLI_rect.h:189
BLI_INLINE float BLI_rctf_cent_x(const struct rctf *rct)
Definition BLI_rect.h:185
void BLI_rcti_translate(struct rcti *rect, int x, int y)
Definition rct.cc:566
void BLI_rctf_transform_calc_m4_pivot_min(const rctf *dst, const rctf *src, float matrix[4][4])
Definition rct.cc:551
bool BLI_rctf_isect_segment(const struct rctf *rect, const float s1[2], const float s2[2])
void BLI_rctf_recenter(struct rctf *rect, float x, float y)
Definition rct.cc:602
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
Definition BLI_rect.h:194
void BLI_rctf_rcti_copy(struct rctf *dst, const struct rcti *src)
BLI_INLINE float BLI_rctf_size_x(const struct rctf *rct)
Definition BLI_rect.h:202
BLI_INLINE float BLI_rctf_size_y(const struct rctf *rct)
Definition BLI_rect.h:206
unsigned char uchar
unsigned int uint
#define CLAMP(a, b, c)
#define CLAMP_MAX(a, c)
#define UNPACK3(a)
#define UNLIKELY(x)
#define ELEM(...)
@ RGN_TYPE_WINDOW
@ SPACE_CLIP
@ SPACE_ACTION
@ SPACE_NLA
@ SPACE_SEQ
@ SPACE_GRAPH
@ V2D_LOCKOFS_X
@ V2D_LOCKOFS_Y
@ V2D_KEEPOFS_Y
@ V2D_KEEPOFS_X
@ V2D_VIEWSYNC_SCREEN_TIME
@ V2D_PIXELOFS_X
@ V2D_IS_INIT
@ V2D_ZOOM_IGNORE_KEEPOFS
@ V2D_PIXELOFS_Y
@ V2D_VIEWSYNC_AREA_VERTICAL
@ V2D_KEEPTOT_BOUNDS
@ V2D_KEEPTOT_STRICT
@ V2D_LIMITZOOM
@ V2D_LOCKZOOM_X
@ V2D_KEEPZOOM
@ V2D_KEEPASPECT
@ V2D_LOCKZOOM_Y
@ V2D_SCROLL_V_ACTIVE
@ V2D_SCROLL_H_ACTIVE
@ V2D_SCROLL_LEFT
@ V2D_SCROLL_HORIZONTAL_FULLR
@ V2D_SCROLL_HORIZONTAL_HIDE
@ V2D_SCROLL_VERTICAL_FULLR
@ V2D_SCROLL_VERTICAL_HIDE
@ V2D_SCROLL_HORIZONTAL
@ V2D_SCROLL_TOP
@ V2D_SCROLL_VERTICAL_HANDLES
@ V2D_SCROLL_RIGHT
@ V2D_SCROLL_BOTTOM
@ V2D_SCROLL_HORIZONTAL_HANDLES
@ V2D_SCROLL_VERTICAL
@ V2D_ALIGN_NO_NEG_X
@ V2D_ALIGN_NO_NEG_Y
@ V2D_ALIGN_NO_POS_Y
@ V2D_ALIGN_NO_POS_X
void ED_region_tag_redraw_no_rebuild(ARegion *region)
Definition area.cc:638
void immEnd()
void immUnbindProgram()
void immBindBuiltinProgram(GPUBuiltinShader shader_id)
void immAttr4ub(uint attr_id, unsigned char r, unsigned char g, unsigned char b, unsigned char a)
void immAttrSkip(uint attr_id)
void immVertex2f(uint attr_id, float x, float y)
void immBeginAtMost(GPUPrimType, uint max_vertex_len)
void immUniform1f(const char *name, float x)
GPUVertFormat * immVertexFormat()
void immUniform4fv(const char *name, const float data[4])
void immBegin(GPUPrimType, uint vertex_len)
void GPU_matrix_identity_set()
@ GPU_PRIM_LINES
@ GPU_PRIM_POINTS
@ GPU_SHADER_2D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_AA
@ GPU_SHADER_3D_FLAT_COLOR
void GPU_program_point_size(bool enable)
Definition gpu_state.cc:180
void GPU_line_width(float width)
Definition gpu_state.cc:166
uint GPU_vertformat_attr_add(GPUVertFormat *format, blender::StringRef name, blender::gpu::VertAttrType type)
Read Guarded memory(de)allocation.
#define MEM_SIZE_OPTIMAL(size)
#define C
Definition RandGen.cpp:29
@ UI_SCROLL_PRESSED
@ UI_SCROLL_ARROWS
const uiStyle * UI_style_get()
#define UI_AZONESPOTW_RIGHT
void UI_draw_widget_scroll(uiWidgetColors *wcol, const rcti *rect, const rcti *slider, int state)
#define UI_AZONESPOTW_LEFT
#define UI_AZONESPOTH
void UI_GetThemeColor3fv(int colorid, float col[3])
@ TH_GRID
@ TH_BACK
void UI_GetThemeColorBlendShade3ubv(int colorid1, int colorid2, float fac, int offset, unsigned char col[3])
bTheme * UI_GetTheme()
void UI_GetThemeColor4ubv(int colorid, unsigned char col[4])
#define V2D_SCROLL_HEIGHT
Definition UI_view2d.hh:53
#define V2D_LOCK_COPY
Definition UI_view2d.hh:85
#define V2D_SCROLL_MIN_ALPHA
Definition UI_view2d.hh:57
#define V2D_SCROLL_HANDLE_HEIGHT
Definition UI_view2d.hh:67
#define V2D_SCROLL_THUMB_SIZE_MIN
Definition UI_view2d.hh:74
#define IN_2D_HORIZ_SCROLL(v2d, co)
Definition UI_view2d.hh:95
#define V2D_SCROLL_WIDTH
Definition UI_view2d.hh:54
#define V2D_SCROLL_HANDLE_WIDTH
Definition UI_view2d.hh:68
#define IN_2D_VERT_SCROLL(v2d, co)
Definition UI_view2d.hh:94
#define IN_2D_VERT_SCROLL_RECT(v2d, rct)
Definition UI_view2d.hh:97
#define V2D_SCROLL_HANDLE_SIZE_HOTSPOT
Definition UI_view2d.hh:71
#define V2D_SCROLL_MIN_WIDTH
Definition UI_view2d.hh:60
@ V2D_COMMONVIEW_LIST
Definition UI_view2d.hh:35
@ V2D_COMMONVIEW_STACK
Definition UI_view2d.hh:37
@ V2D_COMMONVIEW_HEADER
Definition UI_view2d.hh:39
@ V2D_COMMONVIEW_STANDARD
Definition UI_view2d.hh:33
@ V2D_COMMONVIEW_PANELS_UI
Definition UI_view2d.hh:41
#define V2D_IS_CLIPPED
Definition UI_view2d.hh:21
#define IN_2D_HORIZ_SCROLL_RECT(v2d, rct)
Definition UI_view2d.hh:98
#define U
nullptr float
#define logf(x)
#define powf(x, y)
#define roundf(x)
#define str(s)
IMETHOD Vector diff(const Vector &a, const Vector &b, double dt)
Definition frames.inl:1166
uint pos
uint col
#define printf(...)
#define abs
#define ceil
VecBase< float, D > step(VecOp< float, D >, VecOp< float, D >) RET
format
ccl_device_inline float2 fmod(const float2 a, const float b)
ccl_device_inline float2 fabs(const float2 a)
ccl_device_inline float2 mask(const MaskType mask, const float2 a)
static ulong state[N]
#define G(x, y, z)
const btScalar eps
Definition poly34.cpp:11
#define floorf
#define fabsf
#define fractf
#define ceilf
#define min(a, b)
Definition sort.cc:36
ARegionRuntimeHandle * runtime
ListBase regionbase
uiWidgetColors wcol_scroll
unsigned char widget_emboss[4]
char str[0]
Definition view2d.cc:2075
int mval[2]
Definition view2d.cc:2072
union View2DString::@363032360175340070343016305341060250364033113022 col
View2DString * next
Definition view2d.cc:2066
uchar ub[4]
Definition view2d.cc:2068
char alpha_vert
float minzoom
short keeptot
short scroll_ui
short oldwiny
float max[2]
short keepzoom
short keepofs
float min[2]
short oldwinx
float maxzoom
float page_size_y
ListBase areabase
ThemeUI tui
float xmax
float xmin
float ymax
float ymin
int ymin
int ymax
int xmin
int xmax
float panelzoom
unsigned char inner[4]
unsigned char outline[4]
unsigned char item[4]
i
Definition text_draw.cc:230
max
Definition text_draw.cc:251
char UI_view2d_rect_in_scrollers(const ARegion *region, const View2D *v2d, const rcti *rect)
Definition view2d.cc:2053
void UI_view2d_curRect_validate(View2D *v2d)
Definition view2d.cc:828
void view2d_totRect_set_resize(View2D *v2d, int width, int height, bool resize)
Definition view2d.cc:977
void UI_view2d_sync(bScreen *screen, ScrArea *area, View2D *v2dcur, int flag)
Definition view2d.cc:865
static void grid_axis_start_and_count(const float step, const float min, const float max, float *r_start, int *r_count)
Definition view2d.cc:1268
View2D * UI_view2d_fromcontext_rwin(const bContext *C)
Definition view2d.cc:1869
void UI_view2d_scale_get_inverse(const View2D *v2d, float *r_x, float *r_y)
Definition view2d.cc:1929
void UI_view2d_curRect_reset(View2D *v2d)
Definition view2d.cc:928
static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize)
Definition view2d.cc:386
bool UI_view2d_view_to_region_segment_clip(const View2D *v2d, const float xy_a[2], const float xy_b[2], int r_region_a[2], int r_region_b[2])
Definition view2d.cc:1751
void UI_view2d_region_to_view(const View2D *v2d, float x, float y, float *r_view_x, float *r_view_y)
Definition view2d.cc:1668
void UI_view2d_view_orthoSpecial(ARegion *region, View2D *v2d, const bool xaxis)
Definition view2d.cc:1136
char UI_view2d_mouse_in_scrollers(const ARegion *region, const View2D *v2d, const int xy[2])
Definition view2d.cc:2047
void UI_view2d_multi_grid_draw(const View2D *v2d, int colorid, float step, int level_size, int totlevels)
Definition view2d.cc:1180
static View2DString * g_v2d_strings
Definition view2d.cc:2080
float view2d_page_size_y(const View2D &v2d)
Definition view2d.cc:77
void UI_view2d_view_to_region_rcti(const View2D *v2d, const rctf *rect_src, rcti *rect_dst)
Definition view2d.cc:1786
bool UI_view2d_view_to_region_clip(const View2D *v2d, float x, float y, int *r_region_x, int *r_region_y)
Definition view2d.cc:1702
bool UI_view2d_view_to_region_rcti_clip(const View2D *v2d, const rctf *rect_src, rcti *rect_dst)
Definition view2d.cc:1816
char UI_view2d_mouse_in_scrollers_ex(const ARegion *region, const View2D *v2d, const int xy[2], int *r_scroll)
Definition view2d.cc:1991
void UI_view2d_curRect_clamp_y(View2D *v2d)
Definition view2d.cc:844
void UI_view2d_dot_grid_draw(const View2D *v2d, const int grid_color_id, const float min_step, const int grid_subdivisions)
Definition view2d.cc:1287
void UI_view2d_scrollers_draw(View2D *v2d, const rcti *mask_custom)
Definition view2d.cc:1504
BLI_INLINE void clamp_rctf_to_rcti(rcti *dst, const rctf *src)
Definition view2d.cc:69
void UI_view2d_view_restore(const bContext *C)
Definition view2d.cc:1162
void UI_view2d_region_reinit(View2D *v2d, short type, int winx, int winy)
Definition view2d.cc:221
void UI_view2d_curRect_changed(const bContext *C, View2D *v2d)
Definition view2d.cc:833
void UI_view2d_text_cache_draw(ARegion *region)
Definition view2d.cc:2142
float UI_view2d_region_to_view_y(const View2D *v2d, float y)
Definition view2d.cc:1662
void UI_view2d_totRect_set(View2D *v2d, int width, int height)
Definition view2d.cc:1036
void UI_view2d_region_to_view_rctf(const View2D *v2d, const rctf *rect_src, rctf *rect_dst)
Definition view2d.cc:1675
static int view2d_scroll_mapped(int scroll)
Definition view2d.cc:98
float UI_view2d_view_to_region_y(const View2D *v2d, float y)
Definition view2d.cc:1696
void UI_view2d_listview_view_to_cell(float columnwidth, float rowheight, float startx, float starty, float viewx, float viewy, int *r_column, int *r_row)
Definition view2d.cc:1621
void UI_view2d_center_get(const View2D *v2d, float *r_x, float *r_y)
Definition view2d.cc:1939
void UI_view2d_view_ortho(const View2D *v2d)
Definition view2d.cc:1095
static MemArena * g_v2d_strings_arena
Definition view2d.cc:2079
void UI_view2d_view_to_region(const View2D *v2d, float x, float y, int *r_region_x, int *r_region_y)
Definition view2d.cc:1723
View2D * UI_view2d_fromcontext(const bContext *C)
Definition view2d.cc:1855
float UI_view2d_scale_get_y(const View2D *v2d)
Definition view2d.cc:1925
void UI_view2d_scroller_size_get(const View2D *v2d, bool mapped, float *r_x, float *r_y)
Definition view2d.cc:1887
void UI_view2d_offset(View2D *v2d, float xfac, float yfac)
Definition view2d.cc:1957
void UI_view2d_scale_get(const View2D *v2d, float *r_x, float *r_y)
Definition view2d.cc:1912
bool UI_view2d_area_supports_sync(ScrArea *area)
Definition view2d.cc:860
void UI_view2d_mask_from_win(const View2D *v2d, rcti *r_mask)
Definition view2d.cc:109
char UI_view2d_rect_in_scrollers_ex(const ARegion *region, const View2D *v2d, const rcti *rect, int *r_scroll)
Definition view2d.cc:2020
void UI_view2d_view_to_region_m4(const View2D *v2d, float matrix[4][4])
Definition view2d.cc:1808
void UI_view2d_view_to_region_fl(const View2D *v2d, float x, float y, float *r_region_x, float *r_region_y)
Definition view2d.cc:1739
void UI_view2d_text_cache_add(View2D *v2d, float x, float y, const char *str, size_t str_len, const uchar col[4])
Definition view2d.cc:2082
void UI_view2d_offset_y_snap_to_closest_page(View2D *v2d)
Definition view2d.cc:1980
void UI_view2d_center_set(View2D *v2d, float x, float y)
Definition view2d.cc:1949
float UI_view2d_region_to_view_x(const View2D *v2d, float x)
Definition view2d.cc:1657
float UI_view2d_view_to_region_x(const View2D *v2d, float x)
Definition view2d.cc:1691
void UI_view2d_zoom_cache_reset()
Definition view2d.cc:1041
void view2d_scrollers_calc(View2D *v2d, const rcti *mask_custom, View2DScrollers *r_scrollers)
Definition view2d.cc:1391
static void view2d_map_cur_using_mask(const View2D *v2d, rctf *r_curmasked)
Definition view2d.cc:1064
BLI_INLINE int clamp_float_to_int(const float f)
Definition view2d.cc:51
static void view2d_masks(View2D *v2d, const rcti *mask_scroll)
Definition view2d.cc:122
void UI_view2d_text_cache_add_rectf(View2D *v2d, const rctf *rect_view, const char *str, size_t str_len, const uchar col[4])
Definition view2d.cc:2112
float UI_view2d_scale_get_x(const View2D *v2d)
Definition view2d.cc:1921
int xy[2]
Definition wm_draw.cc:178
void wmOrtho2(float x1, float x2, float y1, float y2)
void wmOrtho2_region_pixelspace(const ARegion *region)
uint8_t flag
Definition wm_window.cc:145