58 if (f <
min) [[unlikely]] {
61 if (f >
max) [[unlikely]] {
130 if (mask_scroll ==
nullptr) {
131 mask_scroll = &v2d->
mask;
165 float scroll_width, scroll_height;
172 v2d->
vert = *mask_scroll;
177 v2d->
vert = *mask_scroll;
185 v2d->
hor = *mask_scroll;
190 v2d->
hor = *mask_scroll;
225 bool tot_changed =
false, do_init;
271 tot_changed = do_init;
287 tot_changed = do_init;
312 tot_changed = do_init;
337 const float panelzoom = (style) ? style->
panelzoom : 1.0f;
346 v2d->
cur.
xmax = (winx)*panelzoom;
349 v2d->
cur.
ymin = (-winy) * panelzoom;
391 float curwidth, curheight, width, height;
437 winx = std::max<float>(winx, 1);
438 winy = std::max<float>(winy, 1);
452 oldzoom = v2d->
oldwinx / curwidth;
454 if (oldzoom != zoom) {
455 width *= zoom / oldzoom;
460 zoom = winy / height;
461 oldzoom = v2d->
oldwiny / curheight;
463 if (oldzoom != zoom) {
464 height *= zoom / oldzoom;
475 const float zoom = winx / width;
476 if (zoom < v2d->minzoom) {
479 else if (zoom > v2d->
maxzoom) {
486 const float zoom = winy / height;
487 if (zoom < v2d->minzoom) {
490 else if (zoom > v2d->
maxzoom) {
504 bool do_x =
false, do_y =
false, do_cur;
505 float curRatio, winRatio;
517 curRatio = height / width;
518 winRatio = winy / winx;
531 else if (winRatio > curRatio) {
550 if (winx < v2d->oldwinx) {
551 const float temp = v2d->
oldwinx - winx;
562 width = height / winRatio;
567 height = width * winRatio;
578 if ((width != curwidth) || (height != curheight)) {
582 if (width != curwidth) {
598 cur->
xmin = temp - dh;
599 cur->
xmax = temp + dh;
602 if (height != curheight) {
618 cur->
ymin = temp - dh;
619 cur->
ymax = temp + dh;
636 if ((curwidth > totwidth) &&
662 if ((cur->
xmin - temp) < tot->
xmin) {
688 diff = curwidth * 0.5f;
707 if ((cur->
xmin - temp) < tot->
xmin) {
722 if ((curheight > totheight) &&
741 diff = curheight * 0.5f;
861 if (v2dcur != ®ion.
v2d) {
890 if (v2dcur != ®ion.
v2d) {
934 const float dx = width / 2.0f;
953 const float dy = height / 2.0f;
966 height =
abs(height);
968 if (
ELEM(0, width, height)) {
971 printf(
"Error: View2D totRect set exiting: v2d=%p width=%d height=%d\n",
972 static_cast<void *
>(v2d),
992 const float dx =
float(width) / 2.0f;
1011 const float dy =
float(height) / 2.0f;
1032 if (
G.is_rendering) {
1051 *r_curmasked = v2d->
cur;
1059 if (sizex > 0.0f && sizey > 0.0f) {
1085 const float eps = 0.001f;
1086 float xofs = 0.0f, yofs = 0.0f;
1153 wmOrtho2(0.0f,
float(width), 0.0f,
float(height));
1166 const View2D *v2d,
int colorid,
float step,
int level_size,
int totlevels)
1169 if (totlevels == 0) {
1175 uchar grid_line_color[3];
1178 uint vertex_count = 4;
1179 vertex_count += 2 * (int((v2d->
cur.
xmax - v2d->
cur.
xmin) / lstep) + 1);
1180 vertex_count += 2 * (int((v2d->
cur.
ymax - v2d->
cur.
ymin) / lstep) + 1);
1191 for (
int level = 0; level < totlevels; level++) {
1196 int i = int(v2d->
cur.
xmin / lstep);
1200 float start = i * lstep;
1202 for (; start < v2d->
cur.
xmax; start += lstep, i++) {
1203 if (i == 0 || (level < totlevels - 1 && i % level_size == 0)) {
1213 i = int(v2d->
cur.
ymin / lstep);
1219 for (; start < v2d->
cur.
ymax; start += lstep, i++) {
1220 if (i == 0 || (level < totlevels - 1 && i % level_size == 0)) {
1230 lstep *= level_size;
1236 colorid,
TH_GRID, 0.5f, -18 + ((totlevels - 1) * -6), grid_line_color);
1253 const float step,
const float min,
const float max,
float *r_start,
int *r_count)
1256 if (*r_start < 0.0f) {
1263 if (*r_start >
max) {
1267 *r_count = (
max - *r_start) /
step + 1;
1272 const int grid_color_id,
1273 const float min_step,
1274 const int grid_subdivisions)
1276 BLI_assert(grid_subdivisions >= 0 && grid_subdivisions < 4);
1277 if (grid_subdivisions == 0) {
1289 const float min_point_size = 2.0f *
U.pixelsize;
1290 const float point_size_factor = 1.5f;
1291 const float max_point_size = point_size_factor * min_point_size;
1294 const int subdivision_scale = 5;
1296 const float view_level =
logf(min_step / zoom_x) /
logf(subdivision_scale);
1297 const int largest_visible_level = int(view_level);
1299 for (
int level_offset = 0; level_offset <= grid_subdivisions; level_offset++) {
1300 const int level = largest_visible_level - level_offset;
1306 const float level_scale =
powf(subdivision_scale, level);
1307 const float point_size_precise = min_point_size * level_scale * zoom_x;
1308 const float point_size_draw =
ceilf(
1309 clamp_f(point_size_precise, min_point_size, max_point_size));
1312 const float point_size_offset = (point_size_draw / 2.0f) -
U.pixelsize;
1316 const float alpha =
pow2f(point_size_precise / point_size_draw);
1319 const float alpha_cutoff = 0.01f;
1320 if (alpha < alpha_cutoff) {
1323 const float alpha_clamped =
clamp_f((1.0f + alpha_cutoff) * alpha - alpha_cutoff, 0.0f, 1.0f);
1327 const bool last_level = level_offset == grid_subdivisions;
1328 const float subdivision_fade = last_level ? (1.0f -
fractf(view_level)) : 1.0f;
1332 color[3] = alpha_clamped * subdivision_fade;
1334 const float step = min_step * level_scale;
1343 if (count_x == 0 || count_y == 0) {
1353 for (
int i_y = 0; i_y < count_y; i_y++) {
1354 const float y = start_y +
step * i_y;
1355 for (
int i_x = 0; i_x < count_x; i_x++) {
1356 const float x = start_x +
step * i_x;
1357 immVertex2f(pos,
x + point_size_offset,
y + point_size_offset);
1377 float fac1, fac2, totsize, scrollsize;
1387 const int edge_pad = int(0.1f *
U.widget_unit);
1389 hor.
ymin += edge_pad;
1392 hor.
ymax -= edge_pad;
1396 vert.xmin += edge_pad;
1399 vert.xmax -= edge_pad;
1406 r_scrollers->
vert = vert;
1407 r_scrollers->
hor = hor;
1419 if (totsize == 0.0f) {
1428 r_scrollers->
hor_min = int(hor.
xmin + (fac1 * scrollsize));
1436 r_scrollers->
hor_max = int(hor.
xmin + (fac2 * scrollsize));
1455 if (totsize == 0.0f) {
1464 r_scrollers->
vert_min = int(vert.ymin + (fac1 * scrollsize));
1472 r_scrollers->
vert_max = int(vert.ymin + (fac2 * scrollsize));
1497 uchar scrollers_back_color[4];
1503 vert = scrollers.
vert;
1504 hor = scrollers.
hor;
1510 const float alpha_fac = ((v2d->
alpha_hor / 255.0f) * (1.0f - alpha_min)) + alpha_min;
1523 if (wcol.
inner[3] == 0) {
1524 const float final_alpha = 0.25f;
1528 wcol.
inner[3] *= alpha_fac;
1530 wcol.
item[3] *= alpha_fac;
1532 const_cast<bTheme *
>(btheme)->tui.widget_emboss[3] = 0;
1555 const float alpha_fac = ((v2d->
alpha_vert / 255.0f) * (1.0f - alpha_min)) + alpha_min;
1558 slider.
xmin = vert.xmin;
1559 slider.
xmax = vert.xmax;
1567 if (wcol.
inner[3] == 0) {
1568 const float final_alpha = 0.25f;
1572 wcol.
inner[3] *= alpha_fac;
1574 wcol.
item[3] *= alpha_fac;
1576 const_cast<bTheme *
>(btheme)->tui.widget_emboss[3] = 0;
1595 const_cast<bTheme *
>(btheme)->tui.widget_emboss[3] = emboss_alpha;
1614 if (columnwidth > 0) {
1616 *r_column =
floorf((viewx - startx) / columnwidth);
1624 if (rowheight > 0) {
1626 *r_row =
floorf((starty - viewy) / rowheight);
1664 (cur_size[0] * (rect_src->
xmin - v2d->
mask.
xmin) / mask_size[0]));
1666 (cur_size[0] * (rect_src->
xmax - v2d->
mask.
xmin) / mask_size[0]));
1668 (cur_size[1] * (rect_src->
ymin - v2d->
mask.
ymin) / mask_size[1]));
1670 (cur_size[1] * (rect_src->
ymax - v2d->
mask.
ymin) / mask_size[1]));
1685 const View2D *v2d,
float x,
float y,
int *r_region_x,
int *r_region_y)
1692 if ((
x >= 0.0f) && (
x <= 1.0f) && (
y >= 0.0f) && (
y <= 1.0f)) {
1721 const View2D *v2d,
float x,
float y,
float *r_region_x,
float *r_region_y)
1733 const float xy_a[2],
1734 const float xy_b[2],
1739 rect_unit.
xmin = rect_unit.
ymin = 0.0f;
1740 rect_unit.
xmax = rect_unit.
ymax = 1.0f;
1743 const float s_a[2] = {
1747 const float s_b[2] = {
1753 r_region_a[0] = r_region_b[0] = r_region_a[1] = r_region_b[1] =
V2D_IS_CLIPPED;
1812 if (((rect_tmp.
xmax < 0.0f) || (rect_tmp.
xmin > 1.0f) || (rect_tmp.
ymax < 0.0f) ||
1813 (rect_tmp.
ymin > 1.0f)) == 0)
1841 if (area ==
nullptr) {
1844 if (region ==
nullptr) {
1847 return &(region->
v2d);
1855 if (area ==
nullptr) {
1858 if (region ==
nullptr) {
1863 return region_win ? &(region_win->
v2d) :
nullptr;
1865 return &(region->
v2d);
1956 if (xfac != -1.0f) {
1958 const float xmin = v2d->
tot.
xmin;
1959 const float xmax = v2d->
tot.
xmax - xsize;
1961 v2d->
cur.
xmin = (xmin * (1.0f - xfac)) + (xmax * xfac);
1965 if (yfac != -1.0f) {
1967 const float ymin = v2d->
tot.
ymin;
1968 const float ymax = v2d->
tot.
ymax - ysize;
1970 v2d->
cur.
ymin = (ymin * (1.0f - yfac)) + (ymax * yfac);
2027 rcti rect_region = *rect;
2046 int scroll_dummy = 0;
2052 int scroll_dummy = 0;
2080 View2D *v2d,
float x,
float y,
const char *
str,
size_t str_len,
const uchar col[4])
2087 const int alloc_len = str_len + 1;
2098 v2s->
col.pack = *(
reinterpret_cast<const int *
>(col));
2102 v2s->
mval[0] = mval[0];
2103 v2s->
mval[1] = mval[1];
2105 memcpy(v2s->
str,
str, alloc_len);
2110 View2D *v2d,
const rctf *rect_view,
const char *
str,
size_t str_len,
const uchar col[4])
2117 const int alloc_len = str_len + 1;
2128 v2s->
col.pack = *(
reinterpret_cast<const int *
>(col));
2135 memcpy(v2s->
str,
str, alloc_len);
2142 int col_pack_prev = 0;
2156 yofs = std::max(yofs, 1);
2158 if (col_pack_prev != v2s->
col.pack) {
2160 col_pack_prev = v2s->
col.pack;
2166 float(v2s->
mval[1] + yofs),
#define BLF_DRAW_STR_DUMMY_MAX
Single link-list utility macros. (header only API).
#define BLI_LINKS_PREPEND(list, link)
Read Blender memory allocation and freeing.
#define UI_AZONESPOTW_RIGHT
#define UI_AZONESPOTW_LEFT
#define V2D_SCROLL_HEIGHT
#define V2D_SCROLL_MIN_ALPHA
#define V2D_SCROLL_HANDLE_HEIGHT
#define V2D_SCROLL_THUMB_SIZE_MIN
#define IN_2D_HORIZ_SCROLL(v2d, co)
#define V2D_SCROLL_HANDLE_WIDTH
#define IN_2D_VERT_SCROLL(v2d, co)
#define IN_2D_VERT_SCROLL_RECT(v2d, rct)
#define V2D_SCROLL_HANDLE_SIZE_HOTSPOT
#define V2D_SCROLL_MIN_WIDTH
#define IN_2D_HORIZ_SCROLL_RECT(v2d, rct)
#define MEM_SIZE_OPTIMAL(size)
IMETHOD Vector diff(const Vector &a, const Vector &b, double dt)
VecBase< float, D > step(VecOp< float, D >, VecOp< float, D >) RET
ccl_device_inline dual3 fabs(const ccl_private dual3 &a)
ccl_device_inline float2 fmod(const float2 a, const float b)
void get_color_4ubv(int colorid, unsigned char col[4])
void get_color_3fv(int colorid, float col[3])
void get_color_blend_shade_3ubv(int colorid1, int colorid2, float fac, int offset, unsigned char col[3])
const bTheme * theme_get()
char char char char void view2d_text_cache_add(View2D *v2d, float x, float y, const char *str, size_t str_len, const unsigned char col[4])
static void view2d_masks(View2D *v2d, const rcti *mask_scroll)
static View2DString * g_v2d_strings
void view2d_view_to_region_fl(const View2D *v2d, float x, float y, float *r_region_x, float *r_region_y) ATTR_NONNULL()
void view2d_view_ortho(const View2D *v2d)
void view2d_totRect_set(View2D *v2d, int width, int height)
BLI_INLINE void clamp_rctf_to_rcti(rcti *dst, const rctf *src)
void view2d_curRect_validate(View2D *v2d)
const uiStyle * style_get()
BLI_INLINE int clamp_float_to_int(const float f)
void view2d_offset_y_snap_to_closest_page(View2D *v2d)
float view2d_pixel_size_get_y(const View2D *v2d)
void view2d_view_restore(const bContext *C)
void view2d_region_reinit(View2D *v2d, short type, int winx, int winy)
bool view2d_view_to_region_rcti_clip(const View2D *v2d, const rctf *rect_src, rcti *rect_dst) ATTR_NONNULL()
float view2d_view_to_region_y(const View2D *v2d, float y)
void view2d_scrollers_calc(View2D *v2d, const rcti *mask_custom, View2DScrollers *r_scrollers)
void view2d_mask_from_win(const View2D *v2d, rcti *r_mask)
void view2d_view_to_region_rcti(const View2D *v2d, const rctf *rect_src, rcti *rect_dst) ATTR_NONNULL()
void view2d_text_cache_draw(ARegion *region)
char char view2d_mouse_in_scrollers(const ARegion *region, const View2D *v2d, const int xy[2]) ATTR_NONNULL(1
void view2d_view_to_region(const View2D *v2d, float x, float y, int *r_region_x, int *r_region_y) ATTR_NONNULL()
void view2d_center_set(View2D *v2d, float x, float y)
void view2d_curRect_reset(View2D *v2d)
bool 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]) ATTR_NONNULL()
void view2d_scrollers_draw(View2D *v2d, const rcti *mask_custom)
View2D * view2d_fromcontext_rwin(const bContext *C)
float view2d_scale_get_y(const View2D *v2d)
void view2d_region_to_view(const View2D *v2d, float x, float y, float *r_view_x, float *r_view_y) ATTR_NONNULL()
void view2d_pixel_size_get(const View2D *v2d, float *r_x, float *r_y)
void draw_widget_scroll(uiWidgetColors *wcol, const rcti *rect, const rcti *slider, int state)
void view2d_scroller_size_get(const View2D *v2d, bool mapped, float *r_x, float *r_y)
void view2d_dot_grid_draw(const View2D *v2d, int grid_color_id, float min_step, int grid_subdivisions)
bool view2d_view_to_region_clip(const View2D *v2d, float x, float y, int *r_region_x, int *r_region_y) ATTR_NONNULL()
void view2d_text_cache_add_rectf(View2D *v2d, const rctf *rect_view, const char *str, size_t str_len, const unsigned char col[4])
float view2d_region_to_view_x(const View2D *v2d, float x)
float view2d_region_to_view_y(const View2D *v2d, float y)
void view2d_listview_view_to_cell(float columnwidth, float rowheight, float startx, float starty, float viewx, float viewy, int *r_column, int *r_row)
float view2d_pixel_size_get_x(const View2D *v2d)
void view2d_center_get(const View2D *v2d, float *r_x, float *r_y)
void view2d_curRect_clamp_y(View2D *v2d)
char view2d_mouse_in_scrollers_ex(const ARegion *region, const View2D *v2d, const int xy[2], int *r_scroll) ATTR_NONNULL(1
static int view2d_scroll_mapped(int scroll)
void view2d_sync(bScreen *screen, ScrArea *area, View2D *v2dcur, int flag)
float view2d_scale_get_x(const View2D *v2d)
void view2d_curRect_changed(const bContext *C, View2D *v2d)
float view2d_page_size_y(const View2D &v2d)
void view2d_region_to_view_rctf(const View2D *v2d, const rctf *rect_src, rctf *rect_dst) ATTR_NONNULL()
void view2d_view_to_region_m4(const View2D *v2d, float matrix[4][4]) ATTR_NONNULL()
static void view2d_curRect_validate_resize(View2D *v2d, bool resize)
static void view2d_map_cur_using_mask(const View2D *v2d, rctf *r_curmasked)
@ V2D_COMMONVIEW_STANDARD
@ V2D_COMMONVIEW_PANELS_UI
View2D * view2d_fromcontext(const bContext *C)
void view2d_totRect_set_resize(View2D *v2d, int width, int height, bool resize)
static MemArena * g_v2d_strings_arena
char char char view2d_rect_in_scrollers_ex(const ARegion *region, const View2D *v2d, const rcti *rect, int *r_scroll) ATTR_NONNULL(1
static void grid_axis_start_and_count(const float step, const float min, const float max, float *r_start, int *r_count)
char char char char view2d_rect_in_scrollers(const ARegion *region, const View2D *v2d, const rcti *rect) ATTR_NONNULL(1
void view2d_multi_grid_draw(const View2D *v2d, int colorid, float step, int level_size, int totlevels)
void view2d_scale_get(const View2D *v2d, float *r_x, float *r_y)
bool view2d_area_supports_sync(ScrArea *area)
void view2d_view_orthoSpecial(ARegion *region, View2D *v2d, bool xaxis)
void view2d_size_x_set(View2D *v2d, float size_x)
void view2d_zoom_cache_reset()
void view2d_offset(View2D *v2d, float xfac, float yfac)
float view2d_view_to_region_x(const View2D *v2d, float x)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
ScrArea * CTX_wm_area(const bContext *C)
void wmOrtho2_region_pixelspace(const ARegion *region)
MemArena * BLI_memarena_new(size_t bufsize, const char *name) ATTR_WARN_UNUSED_RESULT ATTR_RETURNS_NONNULL ATTR_NONNULL(2) ATTR_MALLOC
void BLI_rctf_recenter(struct rctf *rect, float x, float y)
@ V2D_VIEWSYNC_SCREEN_TIME
@ V2D_ZOOM_IGNORE_KEEPOFS
@ V2D_VIEWSYNC_AREA_VERTICAL
void immBeginAtMost(GPUPrimType, uint max_vertex_len)
void GPU_matrix_identity_set()
void immAttrSkip(uint attr_id)
GPUVertFormat * immVertexFormat()
void BLI_rctf_resize(struct rctf *rect, float x, float y)
void immBegin(GPUPrimType, uint vertex_len)
MINLINE float fractf(float a)
MINLINE int max_ii(int a, int b)
void BLF_disable(int fontid, FontFlags flag)
void BLI_rctf_rcti_copy(struct rctf *dst, const struct rcti *src)
MINLINE float pow2f(float x)
void GPU_line_width(float width)
void wmOrtho2(float x1, float x2, float y1, float y2)
void immBindBuiltinProgram(GPUBuiltinShader shader_id)
BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
void immUniform1f(const char *name, float x)
void immVertex2f(uint attr_id, float x, float y)
@ GPU_SHADER_2D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_AA
@ GPU_SHADER_3D_FLAT_COLOR
void immUniform4fv(const char *name, const float data[4])
BLI_INLINE float BLI_rctf_size_y(const struct rctf *rct)
float BLF_height(int fontid, const char *str, size_t str_len, ResultBLF *r_info=nullptr) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(2)
void BLI_rcti_translate(struct rcti *rect, int x, int y)
void unit_m4(float m[4][4])
void BLF_clipping(int fontid, int xmin, int ymin, int xmax, int ymax)
void GPU_program_point_size(bool enable)
uint GPU_vertformat_attr_add(GPUVertFormat *format, StringRef name, gpu::VertAttrType type)
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
void BLF_color4ubv(int fontid, const unsigned char rgba[4])
void immAttr4ub(uint attr_id, unsigned char r, unsigned char g, unsigned char b, unsigned char a)
void * BLI_memarena_alloc(MemArena *ma, size_t size) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC ATTR_ALLOC_SIZE(2)
void BLF_draw_default(float x, float y, float z, const char *str, size_t str_len) ATTR_NONNULL()
ARegion * BKE_area_find_region_type(const ScrArea *area, int region_type)
@ V2D_SCROLL_VERTICAL_FULLR
@ V2D_SCROLL_VERTICAL_HIDE
@ V2D_SCROLL_HORIZONTAL_HIDE
@ V2D_SCROLL_HORIZONTAL_HANDLES
@ V2D_SCROLL_VERTICAL_HANDLES
@ V2D_SCROLL_HORIZONTAL_FULLR
BLI_INLINE float BLI_rctf_size_x(const struct rctf *rct)
BLI_INLINE float BLI_rctf_cent_y(const struct rctf *rct)
void BLI_rctf_transform_calc_m4_pivot_min(const rctf *dst, const rctf *src, float matrix[4][4])
void BLI_rctf_translate(struct rctf *rect, float x, float y)
ARegion * CTX_wm_region(const bContext *C)
bool BLI_rctf_isect_segment(const struct rctf *rect, const float s1[2], const float s2[2])
void ED_region_tag_redraw_no_rebuild(ARegion *region)
BLI_INLINE float BLI_rctf_cent_x(const struct rctf *rct)
void BLF_enable(int fontid, FontFlags flag)
void BLI_memarena_free(MemArena *ma) ATTR_NONNULL(1)
MINLINE float clamp_f(float value, float min, float max)
KERNEL_FEATURE_LIGHT_PASSES KERNEL_FEATURE_PATH_GUIDING float
uiWidgetColors wcol_scroll
unsigned char widget_emboss[4]
void(*) on_view2d_changed(const bContext *C, ARegion *region)
bke::ARegionRuntime * runtime
ListBaseT< ARegion > regionbase
eView2D_KeepZoom keepzoom
eView2D_ScrollUI scroll_ui
ListBaseT< struct ScrArea > areabase
struct ARegionType * type
union blender::ui::View2DString::@104124004337164152147207341016017141020021230132 col