128 if (mask_scroll ==
nullptr) {
129 mask_scroll = &v2d->
mask;
163 float scroll_width, scroll_height;
170 v2d->
vert = *mask_scroll;
175 v2d->
vert = *mask_scroll;
183 v2d->
hor = *mask_scroll;
188 v2d->
hor = *mask_scroll;
223 bool tot_changed =
false, do_init;
269 tot_changed = do_init;
285 tot_changed = do_init;
310 tot_changed = do_init;
335 const float panelzoom = (style) ? style->
panelzoom : 1.0f;
344 v2d->
cur.
xmax = (winx)*panelzoom;
347 v2d->
cur.
ymin = (-winy) * panelzoom;
389 float totwidth, totheight, curwidth, curheight, width, height;
432 if (width < FLT_MIN) {
435 if (height < FLT_MIN) {
438 winx = std::max<float>(winx, 1);
439 winy = std::max<float>(winy, 1);
453 oldzoom = v2d->
oldwinx / curwidth;
455 if (oldzoom != zoom) {
456 width *= zoom / oldzoom;
461 zoom = winy / height;
462 oldzoom = v2d->
oldwiny / curheight;
464 if (oldzoom != zoom) {
465 height *= zoom / oldzoom;
476 const float zoom = winx / width;
477 if (zoom < v2d->minzoom) {
480 else if (zoom > v2d->
maxzoom) {
487 const float zoom = winy / height;
488 if (zoom < v2d->minzoom) {
491 else if (zoom > v2d->
maxzoom) {
505 bool do_x =
false, do_y =
false, do_cur;
506 float curRatio, winRatio;
518 curRatio = height / width;
519 winRatio = winy / winx;
532 else if (winRatio > curRatio) {
551 if (winx < v2d->oldwinx) {
552 const float temp = v2d->
oldwinx - winx;
563 width = height / winRatio;
572 if (winy < v2d->oldwiny) {
573 const float temp = v2d->
oldwiny - winy;
587 height = width * winRatio;
599 if ((width != curwidth) || (height != curheight)) {
603 if (width != curwidth) {
619 cur->
xmin = temp - dh;
620 cur->
xmax = temp + dh;
623 if (height != curheight) {
639 cur->
ymin = temp - dh;
640 cur->
ymax = temp + dh;
654 if ((curwidth > totwidth) &&
680 if ((cur->
xmin - temp) < tot->
xmin) {
706 diff = curwidth * 0.5f;
725 if ((cur->
xmin - temp) < tot->
xmin) {
740 if ((curheight > totheight) &&
759 diff = curheight * 0.5f;
839 if (region->
runtime->type->on_view2d_changed !=
nullptr) {
840 region->
runtime->type->on_view2d_changed(
C, region);
876 if (v2dcur != ®ion->v2d) {
881 region->v2d.cur.ymin = v2dcur->
cur.
ymin;
882 region->v2d.cur.ymax = v2dcur->
cur.
ymax;
886 v2dcur->
cur.
ymin = region->v2d.cur.ymin;
887 v2dcur->
cur.
ymax = region->v2d.cur.ymax;
905 if (v2dcur != ®ion->v2d) {
910 region->v2d.cur.xmin = v2dcur->
cur.
xmin;
911 region->v2d.cur.xmax = v2dcur->
cur.
xmax;
915 v2dcur->
cur.
xmin = region->v2d.cur.xmin;
916 v2dcur->
cur.
xmax = region->v2d.cur.xmax;
949 const float dx = width / 2.0f;
968 const float dy = height / 2.0f;
981 height =
abs(height);
983 if (
ELEM(0, width, height)) {
986 printf(
"Error: View2D totRect set exiting: v2d=%p width=%d height=%d\n",
1007 const float dx =
float(width) / 2.0f;
1026 const float dy =
float(height) / 2.0f;
1047 if (
G.is_rendering) {
1066 *r_curmasked = v2d->
cur;
1074 if (sizex > 0.0f && sizey > 0.0f) {
1100 const float eps = 0.001f;
1101 float xofs = 0.0f, yofs = 0.0f;
1168 wmOrtho2(0.0f,
float(width), 0.0f,
float(height));
1181 const View2D *v2d,
int colorid,
float step,
int level_size,
int totlevels)
1184 if (totlevels == 0) {
1190 uchar grid_line_color[3];
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);
1199 format,
"pos", blender::gpu::VertAttrType::SFLOAT_32_32);
1207 for (
int level = 0; level < totlevels; level++) {
1212 int i = int(v2d->
cur.
xmin / lstep);
1216 float start =
i * lstep;
1218 for (; start < v2d->
cur.
xmax; start += lstep,
i++) {
1219 if (
i == 0 || (level < totlevels - 1 &&
i % level_size == 0)) {
1235 for (; start < v2d->
cur.
ymax; start += lstep,
i++) {
1236 if (
i == 0 || (level < totlevels - 1 &&
i % level_size == 0)) {
1246 lstep *= level_size;
1252 colorid,
TH_GRID, 0.5f, -18 + ((totlevels - 1) * -6), grid_line_color);
1269 const float step,
const float min,
const float max,
float *r_start,
int *r_count)
1272 if (*r_start < 0.0f) {
1279 if (*r_start >
max) {
1283 *r_count = (
max - *r_start) /
step + 1;
1288 const int grid_color_id,
1289 const float min_step,
1290 const int grid_subdivisions)
1292 BLI_assert(grid_subdivisions >= 0 && grid_subdivisions < 4);
1293 if (grid_subdivisions == 0) {
1301 format,
"pos", blender::gpu::VertAttrType::SFLOAT_32_32);
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;
1311 const int subdivision_scale = 5;
1313 const float view_level =
logf(min_step / zoom_x) /
logf(subdivision_scale);
1314 const int largest_visible_level = int(view_level);
1316 for (
int level_offset = 0; level_offset <= grid_subdivisions; level_offset++) {
1317 const int level = largest_visible_level - level_offset;
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));
1329 const float point_size_offset = (point_size_draw / 2.0f) -
U.pixelsize;
1333 const float alpha =
pow2f(point_size_precise / point_size_draw);
1336 const float alpha_cutoff = 0.01f;
1337 if (alpha < alpha_cutoff) {
1340 const float alpha_clamped =
clamp_f((1.0f + alpha_cutoff) * alpha - alpha_cutoff, 0.0f, 1.0f);
1344 const bool last_level = level_offset == grid_subdivisions;
1345 const float subdivision_fade = last_level ? (1.0f -
fractf(view_level)) : 1.0f;
1349 color[3] = alpha_clamped * subdivision_fade;
1351 const float step = min_step * level_scale;
1360 if (count_x == 0 || count_y == 0) {
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;
1394 float fac1, fac2, totsize, scrollsize;
1404 const int edge_pad = int(0.1f *
U.widget_unit);
1406 hor.
ymin += edge_pad;
1409 hor.
ymax -= edge_pad;
1413 vert.
xmin += edge_pad;
1416 vert.
xmax -= edge_pad;
1423 r_scrollers->
vert = vert;
1424 r_scrollers->
hor = hor;
1436 if (totsize == 0.0f) {
1445 r_scrollers->
hor_min = int(hor.
xmin + (fac1 * scrollsize));
1453 r_scrollers->
hor_max = int(hor.
xmin + (fac2 * scrollsize));
1472 if (totsize == 0.0f) {
1481 r_scrollers->
vert_min = int(vert.
ymin + (fac1 * scrollsize));
1489 r_scrollers->
vert_max = int(vert.
ymin + (fac2 * scrollsize));
1514 uchar scrollers_back_color[4];
1520 vert = scrollers.
vert;
1521 hor = scrollers.
hor;
1527 const float alpha_fac = ((v2d->
alpha_hor / 255.0f) * (1.0f - alpha_min)) + alpha_min;
1540 if (wcol.
inner[3] == 0) {
1541 const float final_alpha = 0.25f;
1545 wcol.
inner[3] *= alpha_fac;
1547 wcol.
item[3] *= alpha_fac;
1572 const float alpha_fac = ((v2d->
alpha_vert / 255.0f) * (1.0f - alpha_min)) + alpha_min;
1584 if (wcol.
inner[3] == 0) {
1585 const float final_alpha = 0.25f;
1589 wcol.
inner[3] *= alpha_fac;
1591 wcol.
item[3] *= alpha_fac;
1631 if (columnwidth > 0) {
1633 *r_column =
floorf((viewx - startx) / columnwidth);
1641 if (rowheight > 0) {
1643 *r_row =
floorf((starty - viewy) / rowheight);
1669 const View2D *v2d,
float x,
float y,
float *r_view_x,
float *r_view_y)
1682 (cur_size[0] * (rect_src->
xmin - v2d->
mask.
xmin) / mask_size[0]));
1684 (cur_size[0] * (rect_src->
xmax - v2d->
mask.
xmin) / mask_size[0]));
1686 (cur_size[1] * (rect_src->
ymin - v2d->
mask.
ymin) / mask_size[1]));
1688 (cur_size[1] * (rect_src->
ymax - v2d->
mask.
ymin) / mask_size[1]));
1703 const View2D *v2d,
float x,
float y,
int *r_region_x,
int *r_region_y)
1710 if ((
x >= 0.0f) && (
x <= 1.0f) && (
y >= 0.0f) && (
y <= 1.0f)) {
1724 const View2D *v2d,
float x,
float y,
int *r_region_x,
int *r_region_y)
1740 const View2D *v2d,
float x,
float y,
float *r_region_x,
float *r_region_y)
1752 const float xy_a[2],
1753 const float xy_b[2],
1758 rect_unit.
xmin = rect_unit.
ymin = 0.0f;
1759 rect_unit.
xmax = rect_unit.
ymax = 1.0f;
1762 const float s_a[2] = {
1766 const float s_b[2] = {
1772 r_region_a[0] = r_region_b[0] = r_region_a[1] = r_region_b[1] =
V2D_IS_CLIPPED;
1831 if (((rect_tmp.
xmax < 0.0f) || (rect_tmp.
xmin > 1.0f) || (rect_tmp.
ymax < 0.0f) ||
1832 (rect_tmp.
ymin > 1.0f)) == 0)
1860 if (area ==
nullptr) {
1863 if (region ==
nullptr) {
1866 return &(region->
v2d);
1874 if (area ==
nullptr) {
1877 if (region ==
nullptr) {
1882 return region_win ? &(region_win->
v2d) :
nullptr;
1884 return &(region->
v2d);
1959 if (xfac != -1.0f) {
1961 const float xmin = v2d->
tot.
xmin;
1962 const float xmax = v2d->
tot.
xmax - xsize;
1964 v2d->
cur.
xmin = (xmin * (1.0f - xfac)) + (xmax * xfac);
1968 if (yfac != -1.0f) {
1970 const float ymin = v2d->
tot.
ymin;
1971 const float ymax = v2d->
tot.
ymax - ysize;
1973 v2d->
cur.
ymin = (ymin * (1.0f - yfac)) + (ymax * yfac);
2030 rcti rect_region = *rect;
2049 int scroll_dummy = 0;
2055 int scroll_dummy = 0;
2090 const int alloc_len = str_len + 1;
2105 v2s->
mval[0] = mval[0];
2106 v2s->
mval[1] = mval[1];
2108 memcpy(v2s->
str,
str, alloc_len);
2120 const int alloc_len = str_len + 1;
2138 memcpy(v2s->
str,
str, alloc_len);
2145 int col_pack_prev = 0;
2159 yofs = std::max(yofs, 1);
2161 if (col_pack_prev != v2s->
col.
pack) {
2163 col_pack_prev = v2s->
col.
pack;
2169 float(v2s->
mval[1] + yofs),
ScrArea * CTX_wm_area(const bContext *C)
ARegion * CTX_wm_region(const bContext *C)
ARegion * BKE_area_find_region_type(const ScrArea *area, int region_type)
void BLF_enable(int fontid, FontFlags flag)
float BLF_height(int fontid, const char *str, size_t str_len, ResultBLF *r_info=nullptr) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(2)
void BLF_clipping(int fontid, int xmin, int ymin, int xmax, int ymax)
#define BLF_DRAW_STR_DUMMY_MAX
void BLF_disable(int fontid, FontFlags flag)
void BLF_color4ubv(int fontid, const unsigned char rgba[4])
void BLF_draw_default(float x, float y, float z, const char *str, size_t str_len) ATTR_NONNULL()
Single link-list utility macros. (header only API).
#define BLI_LINKS_PREPEND(list, link)
#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)
BLI_INLINE int BLI_rcti_size_y(const struct rcti *rct)
BLI_INLINE float BLI_rctf_cent_y(const struct rctf *rct)
BLI_INLINE float BLI_rctf_cent_x(const struct rctf *rct)
void BLI_rcti_translate(struct rcti *rect, int x, int y)
void BLI_rctf_transform_calc_m4_pivot_min(const rctf *dst, const rctf *src, float matrix[4][4])
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)
BLI_INLINE int BLI_rcti_size_x(const struct rcti *rct)
void BLI_rctf_rcti_copy(struct rctf *dst, const struct rcti *src)
BLI_INLINE float BLI_rctf_size_x(const struct rctf *rct)
BLI_INLINE float BLI_rctf_size_y(const struct rctf *rct)
@ V2D_VIEWSYNC_SCREEN_TIME
@ V2D_ZOOM_IGNORE_KEEPOFS
@ V2D_VIEWSYNC_AREA_VERTICAL
@ V2D_SCROLL_HORIZONTAL_FULLR
@ V2D_SCROLL_HORIZONTAL_HIDE
@ V2D_SCROLL_VERTICAL_FULLR
@ V2D_SCROLL_VERTICAL_HIDE
@ V2D_SCROLL_VERTICAL_HANDLES
@ V2D_SCROLL_HORIZONTAL_HANDLES
void ED_region_tag_redraw_no_rebuild(ARegion *region)
void GPU_matrix_identity_set()
@ GPU_SHADER_2D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_AA
@ GPU_SHADER_3D_FLAT_COLOR
void GPU_program_point_size(bool enable)
void GPU_line_width(float width)
Read Guarded memory(de)allocation.
#define MEM_SIZE_OPTIMAL(size)
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
void UI_GetThemeColor3fv(int colorid, float col[3])
void UI_GetThemeColorBlendShade3ubv(int colorid1, int colorid2, float fac, int offset, unsigned char col[3])
void UI_GetThemeColor4ubv(int colorid, unsigned char col[4])
#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
@ V2D_COMMONVIEW_STANDARD
@ V2D_COMMONVIEW_PANELS_UI
#define IN_2D_HORIZ_SCROLL_RECT(v2d, rct)
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 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)
ARegionRuntimeHandle * runtime
uiWidgetColors wcol_scroll
unsigned char widget_emboss[4]
union View2DString::@363032360175340070343016305341060250364033113022 col
char UI_view2d_rect_in_scrollers(const ARegion *region, const View2D *v2d, const rcti *rect)
void UI_view2d_curRect_validate(View2D *v2d)
void view2d_totRect_set_resize(View2D *v2d, int width, int height, bool resize)
void UI_view2d_sync(bScreen *screen, ScrArea *area, View2D *v2dcur, int flag)
static void grid_axis_start_and_count(const float step, const float min, const float max, float *r_start, int *r_count)
View2D * UI_view2d_fromcontext_rwin(const bContext *C)
void UI_view2d_scale_get_inverse(const View2D *v2d, float *r_x, float *r_y)
void UI_view2d_curRect_reset(View2D *v2d)
static void ui_view2d_curRect_validate_resize(View2D *v2d, bool resize)
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])
void UI_view2d_region_to_view(const View2D *v2d, float x, float y, float *r_view_x, float *r_view_y)
void UI_view2d_view_orthoSpecial(ARegion *region, View2D *v2d, const bool xaxis)
char UI_view2d_mouse_in_scrollers(const ARegion *region, const View2D *v2d, const int xy[2])
void UI_view2d_multi_grid_draw(const View2D *v2d, int colorid, float step, int level_size, int totlevels)
static View2DString * g_v2d_strings
float view2d_page_size_y(const View2D &v2d)
void UI_view2d_view_to_region_rcti(const View2D *v2d, const rctf *rect_src, rcti *rect_dst)
bool UI_view2d_view_to_region_clip(const View2D *v2d, float x, float y, int *r_region_x, int *r_region_y)
bool UI_view2d_view_to_region_rcti_clip(const View2D *v2d, const rctf *rect_src, rcti *rect_dst)
char UI_view2d_mouse_in_scrollers_ex(const ARegion *region, const View2D *v2d, const int xy[2], int *r_scroll)
void UI_view2d_curRect_clamp_y(View2D *v2d)
void UI_view2d_dot_grid_draw(const View2D *v2d, const int grid_color_id, const float min_step, const int grid_subdivisions)
void UI_view2d_scrollers_draw(View2D *v2d, const rcti *mask_custom)
BLI_INLINE void clamp_rctf_to_rcti(rcti *dst, const rctf *src)
void UI_view2d_view_restore(const bContext *C)
void UI_view2d_region_reinit(View2D *v2d, short type, int winx, int winy)
void UI_view2d_curRect_changed(const bContext *C, View2D *v2d)
void UI_view2d_text_cache_draw(ARegion *region)
float UI_view2d_region_to_view_y(const View2D *v2d, float y)
void UI_view2d_totRect_set(View2D *v2d, int width, int height)
void UI_view2d_region_to_view_rctf(const View2D *v2d, const rctf *rect_src, rctf *rect_dst)
static int view2d_scroll_mapped(int scroll)
float UI_view2d_view_to_region_y(const View2D *v2d, float y)
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)
void UI_view2d_center_get(const View2D *v2d, float *r_x, float *r_y)
void UI_view2d_view_ortho(const View2D *v2d)
static MemArena * g_v2d_strings_arena
void UI_view2d_view_to_region(const View2D *v2d, float x, float y, int *r_region_x, int *r_region_y)
View2D * UI_view2d_fromcontext(const bContext *C)
float UI_view2d_scale_get_y(const View2D *v2d)
void UI_view2d_scroller_size_get(const View2D *v2d, bool mapped, float *r_x, float *r_y)
void UI_view2d_offset(View2D *v2d, float xfac, float yfac)
void UI_view2d_scale_get(const View2D *v2d, float *r_x, float *r_y)
bool UI_view2d_area_supports_sync(ScrArea *area)
void UI_view2d_mask_from_win(const View2D *v2d, rcti *r_mask)
char UI_view2d_rect_in_scrollers_ex(const ARegion *region, const View2D *v2d, const rcti *rect, int *r_scroll)
void UI_view2d_view_to_region_m4(const View2D *v2d, float matrix[4][4])
void UI_view2d_view_to_region_fl(const View2D *v2d, float x, float y, float *r_region_x, float *r_region_y)
void UI_view2d_text_cache_add(View2D *v2d, float x, float y, const char *str, size_t str_len, const uchar col[4])
void UI_view2d_offset_y_snap_to_closest_page(View2D *v2d)
void UI_view2d_center_set(View2D *v2d, float x, float y)
float UI_view2d_region_to_view_x(const View2D *v2d, float x)
float UI_view2d_view_to_region_x(const View2D *v2d, float x)
void UI_view2d_zoom_cache_reset()
void view2d_scrollers_calc(View2D *v2d, const rcti *mask_custom, View2DScrollers *r_scrollers)
static void view2d_map_cur_using_mask(const View2D *v2d, rctf *r_curmasked)
BLI_INLINE int clamp_float_to_int(const float f)
static void view2d_masks(View2D *v2d, const rcti *mask_scroll)
void UI_view2d_text_cache_add_rectf(View2D *v2d, const rctf *rect_view, const char *str, size_t str_len, const uchar col[4])
float UI_view2d_scale_get_x(const View2D *v2d)
void wmOrtho2(float x1, float x2, float y1, float y2)
void wmOrtho2_region_pixelspace(const ARegion *region)