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;
214 bool tot_changed =
false, do_init;
260 tot_changed = do_init;
276 tot_changed = do_init;
301 tot_changed = do_init;
326 const float panelzoom = (style) ? style->
panelzoom : 1.0f;
335 v2d->
cur.
xmax = (winx)*panelzoom;
338 v2d->
cur.
ymin = (-winy) * panelzoom;
380 float totwidth, totheight, curwidth, curheight, width, height;
423 if (width < FLT_MIN) {
426 if (height < FLT_MIN) {
442 oldzoom = v2d->
oldwinx / curwidth;
444 if (oldzoom != zoom) {
445 width *= zoom / oldzoom;
450 zoom = winy / height;
451 oldzoom = v2d->
oldwiny / curheight;
453 if (oldzoom != zoom) {
454 height *= zoom / oldzoom;
465 const float zoom = winx / width;
466 if (zoom < v2d->minzoom) {
469 else if (zoom > v2d->
maxzoom) {
476 const float zoom = winy / height;
477 if (zoom < v2d->minzoom) {
480 else if (zoom > v2d->
maxzoom) {
494 bool do_x =
false, do_y =
false, do_cur;
495 float curRatio, winRatio;
507 curRatio = height / width;
508 winRatio = winy / winx;
521 else if (winRatio > curRatio) {
540 if (winx < v2d->oldwinx) {
541 const float temp = v2d->
oldwinx - winx;
552 width = height / winRatio;
561 if (winy < v2d->oldwiny) {
562 const float temp = v2d->
oldwiny - winy;
576 height = width * winRatio;
587 if ((width != curwidth) || (height != curheight)) {
591 if (width != curwidth) {
607 cur->
xmin = temp - dh;
608 cur->
xmax = temp + dh;
611 if (height != curheight) {
627 cur->
ymin = temp - dh;
628 cur->
ymax = temp + dh;
642 if ((curwidth > totwidth) &&
672 if ((cur->
xmin - temp) < tot->
xmin) {
698 diff = curwidth * 0.5f;
717 if ((cur->
xmin - temp) < tot->
xmin) {
732 if ((curheight > totheight) &&
755 diff = curheight * 0.5f;
872 if (v2dcur != ®ion->v2d) {
877 region->v2d.cur.ymin = v2dcur->
cur.
ymin;
878 region->v2d.cur.ymax = v2dcur->
cur.
ymax;
882 v2dcur->
cur.
ymin = region->v2d.cur.ymin;
883 v2dcur->
cur.
ymax = region->v2d.cur.ymax;
901 if (v2dcur != ®ion->v2d) {
906 region->v2d.cur.xmin = v2dcur->
cur.
xmin;
907 region->v2d.cur.xmax = v2dcur->
cur.
xmax;
911 v2dcur->
cur.
xmin = region->v2d.cur.xmin;
912 v2dcur->
cur.
xmax = region->v2d.cur.xmax;
945 const float dx = width / 2.0f;
964 const float dy = height / 2.0f;
977 height =
abs(height);
979 if (
ELEM(0, width, height)) {
982 printf(
"Error: View2D totRect set exiting: v2d=%p width=%d height=%d\n",
1003 const float dx =
float(width) / 2.0f;
1022 const float dy =
float(height) / 2.0f;
1043 if (
G.is_rendering) {
1062 *r_curmasked = v2d->
cur;
1070 if (sizex > 0.0f && sizey > 0.0f) {
1096 const float eps = 0.001f;
1097 float xofs = 0.0f, yofs = 0.0f;
1164 wmOrtho2(0.0f,
float(width), 0.0f,
float(height));
1177 const View2D *v2d,
int colorid,
float step,
int level_size,
int totlevels)
1180 if (totlevels == 0) {
1186 uchar grid_line_color[3];
1189 uint vertex_count = 4;
1203 for (
int level = 0; level < totlevels; level++) {
1212 float start = i * lstep;
1214 for (; start < v2d->
cur.
xmax; start += lstep, i++) {
1215 if (i == 0 || (level < totlevels - 1 && i % level_size == 0)) {
1231 for (; start < v2d->
cur.
ymax; start += lstep, i++) {
1232 if (i == 0 || (level < totlevels - 1 && i % level_size == 0)) {
1242 lstep *= level_size;
1248 colorid,
TH_GRID, 0.5f, -18 + ((totlevels - 1) * -6), grid_line_color);
1265 const float step,
const float min,
const float max,
float *r_start,
int *r_count)
1268 if (*r_start < 0.0f) {
1275 if (*r_start >
max) {
1279 *r_count = (
max - *r_start) / step + 1;
1284 const int grid_color_id,
1285 const float min_step,
1286 const int grid_subdivisions)
1288 BLI_assert(grid_subdivisions >= 0 && grid_subdivisions < 4);
1289 if (grid_subdivisions == 0) {
1301 const float min_point_size = 2.0f *
U.pixelsize;
1302 const float point_size_factor = 1.5f;
1303 const float max_point_size = point_size_factor * min_point_size;
1306 const int subdivision_scale = 5;
1308 const float view_level =
logf(min_step / zoom_x) /
logf(subdivision_scale);
1309 const int largest_visible_level =
int(view_level);
1311 for (
int level_offset = 0; level_offset <= grid_subdivisions; level_offset++) {
1312 const int level = largest_visible_level - level_offset;
1318 const float level_scale =
powf(subdivision_scale, level);
1319 const float point_size_precise = min_point_size * level_scale * zoom_x;
1320 const float point_size_draw =
ceilf(
1321 clamp_f(point_size_precise, min_point_size, max_point_size));
1324 const float point_size_offset = (point_size_draw / 2.0f) -
U.pixelsize;
1328 const float alpha =
pow2f(point_size_precise / point_size_draw);
1331 const float alpha_cutoff = 0.01f;
1332 if (alpha < alpha_cutoff) {
1335 const float alpha_clamped =
clamp_f((1.0f + alpha_cutoff) * alpha - alpha_cutoff, 0.0f, 1.0f);
1339 const bool last_level = level_offset == grid_subdivisions;
1340 const float subdivision_fade = last_level ? (1.0f -
fractf(view_level)) : 1.0f;
1344 color[3] = alpha_clamped * subdivision_fade;
1346 const float step = min_step * level_scale;
1355 if (count_x == 0 || count_y == 0) {
1365 for (
int i_y = 0; i_y < count_y; i_y++) {
1366 const float y = start_y + step * i_y;
1367 for (
int i_x = 0; i_x < count_x; i_x++) {
1368 const float x = start_x + step * i_x;
1389 float fac1, fac2, totsize, scrollsize;
1406 smaller =
int(0.1f *
U.widget_unit);
1408 hor.
ymin += smaller;
1411 hor.
ymax -= smaller;
1415 vert.
xmin += smaller;
1418 vert.
xmax -= smaller;
1425 r_scrollers->
vert = vert;
1426 r_scrollers->
hor = hor;
1438 if (totsize == 0.0f) {
1476 if (totsize == 0.0f) {
1520 uchar scrollers_back_color[4];
1526 vert = scrollers.
vert;
1527 hor = scrollers.
hor;
1533 const float alpha_fac = ((v2d->
alpha_hor / 255.0f) * (1.0f - alpha_min)) + alpha_min;
1544 wcol.
inner[3] *= alpha_fac;
1545 wcol.
item[3] *= alpha_fac;
1570 const float alpha_fac = ((v2d->
alpha_vert / 255.0f) * (1.0f - alpha_min)) + alpha_min;
1580 wcol.
inner[3] *= alpha_fac;
1581 wcol.
item[3] *= alpha_fac;
1626 if (columnwidth > 0) {
1628 *r_column =
floorf((viewx - startx) / columnwidth);
1636 if (rowheight > 0) {
1638 *r_row =
floorf((starty - viewy) / rowheight);
1664 const View2D *v2d,
float x,
float y,
float *r_view_x,
float *r_view_y)
1677 (cur_size[0] * (rect_src->
xmin - v2d->
mask.
xmin) / mask_size[0]));
1679 (cur_size[0] * (rect_src->
xmax - v2d->
mask.
xmin) / mask_size[0]));
1681 (cur_size[1] * (rect_src->
ymin - v2d->
mask.
ymin) / mask_size[1]));
1683 (cur_size[1] * (rect_src->
ymax - v2d->
mask.
ymin) / mask_size[1]));
1698 const View2D *v2d,
float x,
float y,
int *r_region_x,
int *r_region_y)
1705 if ((
x >= 0.0f) && (
x <= 1.0f) && (
y >= 0.0f) && (
y <= 1.0f)) {
1719 const View2D *v2d,
float x,
float y,
int *r_region_x,
int *r_region_y)
1735 const View2D *v2d,
float x,
float y,
float *r_region_x,
float *r_region_y)
1747 const float xy_a[2],
1748 const float xy_b[2],
1753 rect_unit.
xmin = rect_unit.
ymin = 0.0f;
1754 rect_unit.
xmax = rect_unit.
ymax = 1.0f;
1757 const float s_a[2] = {
1761 const float s_b[2] = {
1767 r_region_a[0] = r_region_b[0] = r_region_a[1] = r_region_b[1] =
V2D_IS_CLIPPED;
1826 if (((rect_tmp.
xmax < 0.0f) || (rect_tmp.
xmin > 1.0f) || (rect_tmp.
ymax < 0.0f) ||
1827 (rect_tmp.
ymin > 1.0f)) == 0)
1855 if (area ==
nullptr) {
1858 if (region ==
nullptr) {
1861 return &(region->
v2d);
1869 if (area ==
nullptr) {
1872 if (region ==
nullptr) {
1877 return region_win ? &(region_win->
v2d) :
nullptr;
1879 return &(region->
v2d);
1954 if (xfac != -1.0f) {
1956 const float xmin = v2d->
tot.
xmin;
1957 const float xmax = v2d->
tot.
xmax - xsize;
1959 v2d->
cur.
xmin = (xmin * (1.0f - xfac)) + (xmax * xfac);
1963 if (yfac != -1.0f) {
1965 const float ymin = v2d->
tot.
ymin;
1966 const float ymax = v2d->
tot.
ymax - ysize;
1968 v2d->
cur.
ymin = (ymin * (1.0f - yfac)) + (ymax * yfac);
1980 v2d->
cur.
ymax = roundf(v2d->
cur.
ymax / page_size_y) * page_size_y;
2025 rcti rect_region = *rect;
2044 int scroll_dummy = 0;
2050 int scroll_dummy = 0;
2085 const int alloc_len = str_len + 1;
2098 memset(&v2s->
rect, 0,
sizeof(v2s->
rect));
2100 v2s->
mval[0] = mval[0];
2101 v2s->
mval[1] = mval[1];
2103 memcpy(v2s->
str,
str, alloc_len);
2115 const int alloc_len = str_len + 1;
2133 memcpy(v2s->
str,
str, alloc_len);
2140 int col_pack_prev = 0;
2158 if (col_pack_prev != v2s->
col.
pack) {
2160 col_pack_prev = v2s->
col.
pack;
2166 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)
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, int option)
void BLF_enable(int fontid, int option)
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)
void unit_m4(float m[4][4])
void * BLI_memarena_alloc(struct MemArena *ma, size_t size) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1) ATTR_MALLOC ATTR_ALLOC_SIZE(2)
void BLI_memarena_free(struct MemArena *ma) ATTR_NONNULL(1)
struct 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_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_SCROLL_HORIZONTAL_FULLR
@ V2D_SCROLL_HORIZONTAL_HIDE
@ V2D_SCROLL_VERTICAL_FULLR
@ V2D_SCROLL_VERTICAL_HIDE
@ V2D_SCROLL_VERTICAL_HANDLES
@ V2D_SCROLL_HORIZONTAL_HANDLES
@ V2D_VIEWSYNC_SCREEN_TIME
@ V2D_VIEWSYNC_AREA_VERTICAL
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)
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Brightness Control the brightness and contrast of the input color Vector Map input vector components with curves Camera Retrieve information about the camera and how it relates to the current shading point s position Clamp a value between a minimum and a maximum Vector Perform vector math operation Invert Invert a color
const uiStyle * UI_style_get()
void UI_draw_widget_scroll(uiWidgetColors *wcol, const rcti *rect, const rcti *slider, int state)
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)
draw_view in_light_buf[] float
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
IMETHOD Vector diff(const Vector &a, const Vector &b, double dt)
MINLINE float fractf(float a)
ccl_device_inline float2 fmod(const float2 a, const float b)
ccl_device_inline float2 fabs(const float2 a)
ccl_device_inline float3 ceil(const float3 a)
ccl_device_inline float4 mask(const int4 mask, const float4 a)
void(* on_view2d_changed)(const bContext *C, ARegion *region)
struct ARegionType * type
uiWidgetColors wcol_scroll
unsigned char widget_emboss[4]
union View2DString::@255132311327275077075273105072153113125144146057 col
ccl_device_inline int abs(int x)
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)
void UI_view2d_scrollers_draw_ex(View2D *v2d, const rcti *mask_custom, bool use_full_hide)
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)