Code cleanup: view2d api naming
This commit is contained in:
@@ -67,7 +67,7 @@ static void draw_cfra_number(Scene *scene, View2D *v2d, const float cfra, const
|
||||
short slen;
|
||||
|
||||
/* because the frame number text is subject to the same scaling as the contents of the view */
|
||||
UI_view2d_getscale(v2d, &xscale, &yscale);
|
||||
UI_view2d_scale_get(v2d, &xscale, &yscale);
|
||||
glScalef(1.0f / xscale, 1.0f, 1.0f);
|
||||
|
||||
/* get timecode string
|
||||
|
||||
@@ -322,7 +322,7 @@ static void draw_marker(View2D *v2d, TimeMarker *marker, int cfra, int flag)
|
||||
|
||||
/* no time correction for framelen! space is drawn with old values */
|
||||
ypixels = BLI_rcti_size_y(&v2d->mask);
|
||||
UI_view2d_getscale(v2d, &xscale, &yscale);
|
||||
UI_view2d_scale_get(v2d, &xscale, &yscale);
|
||||
|
||||
glScalef(1.0f / xscale, 1.0f, 1.0f);
|
||||
|
||||
|
||||
@@ -580,7 +580,7 @@ static void draw_keylist(View2D *v2d, DLRBT_Tree *keys, DLRBT_Tree *blocks, floa
|
||||
glEnable(GL_BLEND);
|
||||
|
||||
/* get View2D scaling factor */
|
||||
UI_view2d_getscale(v2d, &xscale, NULL);
|
||||
UI_view2d_scale_get(v2d, &xscale, NULL);
|
||||
|
||||
/* locked channels are less strongly shown, as feedback for locked channels in DopeSheet */
|
||||
/* TODO: allow this opacity factor to be themed? */
|
||||
|
||||
@@ -210,19 +210,21 @@ bool UI_view2d_view_to_region_rcti_clip(struct View2D *v2d, const struct rctf *
|
||||
struct View2D *UI_view2d_fromcontext(const struct bContext *C);
|
||||
struct View2D *UI_view2d_fromcontext_rwin(const struct bContext *C);
|
||||
|
||||
void UI_view2d_getscale(struct View2D *v2d, float *x, float *y);
|
||||
void UI_view2d_getscale_inverse(struct View2D *v2d, float *x, float *y);
|
||||
void UI_view2d_scale_get(struct View2D *v2d, float *x, float *y);
|
||||
void UI_view2d_scale_get_inverse(struct View2D *v2d, float *x, float *y);
|
||||
|
||||
void UI_view2d_getcenter(struct View2D *v2d, float *x, float *y);
|
||||
void UI_view2d_setcenter(struct View2D *v2d, float x, float y);
|
||||
void UI_view2d_center_get(struct View2D *v2d, float *x, float *y);
|
||||
void UI_view2d_center_set(struct View2D *v2d, float x, float y);
|
||||
|
||||
void UI_view2d_offset(struct View2D *v2d, float xfac, float yfac);
|
||||
|
||||
short UI_view2d_mouse_in_scrollers(const struct bContext *C, struct View2D *v2d, int x, int y);
|
||||
|
||||
/* cached text drawing in v2d, to allow pixel-aligned draw as post process */
|
||||
void UI_view2d_text_cache_add(struct View2D *v2d, float x, float y, const char *str, size_t str_len, const char col[4]);
|
||||
void UI_view2d_text_cache_rectf(struct View2D *v2d, const struct rctf *rect_view, const char *str, size_t str_len, const char col[4]);
|
||||
void UI_view2d_text_cache_add(struct View2D *v2d, float x, float y,
|
||||
const char *str, size_t str_len, const char col[4]);
|
||||
void UI_view2d_text_cache_add_rectf(struct View2D *v2d, const struct rctf *rect_view,
|
||||
const char *str, size_t str_len, const char col[4]);
|
||||
void UI_view2d_text_cache_draw(struct ARegion *ar);
|
||||
|
||||
/* operators */
|
||||
|
||||
@@ -2182,13 +2182,13 @@ View2D *UI_view2d_fromcontext_rwin(const bContext *C)
|
||||
*
|
||||
* - x,y = scale on each axis
|
||||
*/
|
||||
void UI_view2d_getscale(View2D *v2d, float *x, float *y)
|
||||
void UI_view2d_scale_get(View2D *v2d, float *x, float *y)
|
||||
{
|
||||
if (x) *x = BLI_rcti_size_x(&v2d->mask) / BLI_rctf_size_x(&v2d->cur);
|
||||
if (y) *y = BLI_rcti_size_y(&v2d->mask) / BLI_rctf_size_y(&v2d->cur);
|
||||
}
|
||||
/* Same as UI_view2d_getscale() - 1.0f / x, y */
|
||||
void UI_view2d_getscale_inverse(View2D *v2d, float *x, float *y)
|
||||
/* Same as UI_view2d_scale_get() - 1.0f / x, y */
|
||||
void UI_view2d_scale_get_inverse(View2D *v2d, float *x, float *y)
|
||||
{
|
||||
if (x) *x = BLI_rctf_size_x(&v2d->cur) / BLI_rcti_size_x(&v2d->mask);
|
||||
if (y) *y = BLI_rctf_size_y(&v2d->cur) / BLI_rcti_size_y(&v2d->mask);
|
||||
@@ -2197,13 +2197,13 @@ void UI_view2d_getscale_inverse(View2D *v2d, float *x, float *y)
|
||||
/* Simple functions for consistent center offset access.
|
||||
* Used by node editor to shift view center for each individual node tree.
|
||||
*/
|
||||
void UI_view2d_getcenter(struct View2D *v2d, float *x, float *y)
|
||||
void UI_view2d_center_get(struct View2D *v2d, float *x, float *y)
|
||||
{
|
||||
/* get center */
|
||||
if (x) *x = BLI_rctf_cent_x(&v2d->cur);
|
||||
if (y) *y = BLI_rctf_cent_y(&v2d->cur);
|
||||
}
|
||||
void UI_view2d_setcenter(struct View2D *v2d, float x, float y)
|
||||
void UI_view2d_center_set(struct View2D *v2d, float x, float y)
|
||||
{
|
||||
BLI_rctf_recenter(&v2d->cur, x, y);
|
||||
|
||||
@@ -2286,7 +2286,8 @@ typedef struct View2DString {
|
||||
static MemArena *g_v2d_strings_arena = NULL;
|
||||
static View2DString *g_v2d_strings = NULL;
|
||||
|
||||
void UI_view2d_text_cache_add(View2D *v2d, float x, float y, const char *str, size_t str_len, const char col[4])
|
||||
void UI_view2d_text_cache_add(View2D *v2d, float x, float y,
|
||||
const char *str, size_t str_len, const char col[4])
|
||||
{
|
||||
int mval[2];
|
||||
|
||||
@@ -2316,7 +2317,8 @@ void UI_view2d_text_cache_add(View2D *v2d, float x, float y, const char *str, si
|
||||
}
|
||||
|
||||
/* no clip (yet) */
|
||||
void UI_view2d_text_cache_rectf(View2D *v2d, const rctf *rect_view, const char *str, size_t str_len, const char col[4])
|
||||
void UI_view2d_text_cache_add_rectf(View2D *v2d, const rctf *rect_view,
|
||||
const char *str, size_t str_len, const char col[4])
|
||||
{
|
||||
rcti rect;
|
||||
|
||||
|
||||
@@ -622,7 +622,7 @@ void ED_mask_draw(const bContext *C,
|
||||
|
||||
ED_mask_get_size(sa, &width, &height);
|
||||
ED_mask_get_aspect(sa, ar, &aspx, &aspy);
|
||||
UI_view2d_getscale(&ar->v2d, &xscale, &yscale);
|
||||
UI_view2d_scale_get(&ar->v2d, &xscale, &yscale);
|
||||
|
||||
draw_masklays(C, mask, draw_flag, draw_type, width, height, xscale * aspx, yscale * aspy);
|
||||
}
|
||||
|
||||
@@ -326,7 +326,7 @@ void ED_mask_pixelspace_factor(ScrArea *sa, ARegion *ar, float *scalex, float *s
|
||||
SpaceClip *sc = sa->spacedata.first;
|
||||
float aspx, aspy;
|
||||
|
||||
UI_view2d_getscale(&ar->v2d, scalex, scaley);
|
||||
UI_view2d_scale_get(&ar->v2d, scalex, scaley);
|
||||
ED_space_clip_get_aspect(sc, &aspx, &aspy);
|
||||
|
||||
*scalex *= aspx;
|
||||
@@ -343,7 +343,7 @@ void ED_mask_pixelspace_factor(ScrArea *sa, ARegion *ar, float *scalex, float *s
|
||||
SpaceImage *sima = sa->spacedata.first;
|
||||
float aspx, aspy;
|
||||
|
||||
UI_view2d_getscale(&ar->v2d, scalex, scaley);
|
||||
UI_view2d_scale_get(&ar->v2d, scalex, scaley);
|
||||
ED_space_image_get_aspect(sima, &aspx, &aspy);
|
||||
|
||||
*scalex *= aspx;
|
||||
|
||||
@@ -193,7 +193,7 @@ void clip_draw_dopesheet_main(SpaceClip *sc, ARegion *ar, Scene *scene)
|
||||
|
||||
y = (float) CHANNEL_FIRST;
|
||||
|
||||
UI_view2d_getscale(v2d, &xscale, &yscale);
|
||||
UI_view2d_scale_get(v2d, &xscale, &yscale);
|
||||
|
||||
/* setup colors for regular and selected strips */
|
||||
UI_GetThemeColor3fv(TH_STRIP, strip);
|
||||
|
||||
@@ -168,7 +168,7 @@ static void draw_tracks_motion_curves(View2D *v2d, SpaceClip *sc)
|
||||
userdata.hsize = UI_GetThemeValuef(TH_HANDLE_VERTEX_SIZE);
|
||||
userdata.sel = false;
|
||||
userdata.act_track = act_track;
|
||||
UI_view2d_getscale(v2d, &userdata.xscale, &userdata.yscale);
|
||||
UI_view2d_scale_get(v2d, &userdata.xscale, &userdata.yscale);
|
||||
clip_graph_tracking_values_iterate(sc,
|
||||
(sc->flag & SC_SHOW_GRAPH_SEL_ONLY) != 0,
|
||||
(sc->flag & SC_SHOW_GRAPH_HIDDEN) != 0,
|
||||
|
||||
@@ -316,7 +316,7 @@ void clip_draw_cfra(SpaceClip *sc, ARegion *ar, Scene *scene)
|
||||
UI_view2d_view_orthoSpecial(ar, v2d, 1);
|
||||
|
||||
/* because the frame number text is subject to the same scaling as the contents of the view */
|
||||
UI_view2d_getscale(v2d, &xscale, &yscale);
|
||||
UI_view2d_scale_get(v2d, &xscale, &yscale);
|
||||
glScalef(1.0f / xscale, 1.0f, 1.0f);
|
||||
|
||||
ED_region_cache_draw_curfra_label(sc->user.framenr, (float)sc->user.framenr * xscale, 18);
|
||||
|
||||
@@ -215,7 +215,7 @@ static void draw_fcurve_vertices_handles(FCurve *fcu, SpaceIpo *sipo, View2D *v2
|
||||
|
||||
/* get view settings */
|
||||
hsize = UI_GetThemeValuef(TH_HANDLE_VERTEX_SIZE) * U.pixelsize;
|
||||
UI_view2d_getscale(v2d, &xscale, &yscale);
|
||||
UI_view2d_scale_get(v2d, &xscale, &yscale);
|
||||
|
||||
/* Compensate OGL scale sued for unit mapping, so circle will be circle, not ellipse */
|
||||
yscale *= units_scale;
|
||||
@@ -456,7 +456,7 @@ static void draw_fcurve_samples(SpaceIpo *sipo, ARegion *ar, FCurve *fcu)
|
||||
|
||||
/* get view settings */
|
||||
hsize = UI_GetThemeValuef(TH_VERTEX_SIZE);
|
||||
UI_view2d_getscale(&ar->v2d, &xscale, &yscale);
|
||||
UI_view2d_scale_get(&ar->v2d, &xscale, &yscale);
|
||||
|
||||
/* set vertex color */
|
||||
if (fcu->flag & (FCURVE_ACTIVE | FCURVE_SELECTED)) UI_ThemeColor(TH_TEXT_HI);
|
||||
|
||||
@@ -132,7 +132,7 @@ static void nla_action_draw_keyframes(AnimData *adt, bAction *act, View2D *v2d,
|
||||
|
||||
|
||||
/* get View2D scaling factor */
|
||||
UI_view2d_getscale(v2d, &xscale, NULL);
|
||||
UI_view2d_scale_get(v2d, &xscale, NULL);
|
||||
|
||||
/* for now, color is hardcoded to be black */
|
||||
glColor3f(0.0f, 0.0f, 0.0f);
|
||||
@@ -471,7 +471,7 @@ static void nla_draw_strip_text(AnimData *adt, NlaTrack *nlt, NlaStrip *strip, i
|
||||
rect.ymax = ymaxc;
|
||||
|
||||
/* add this string to the cache of texts to draw */
|
||||
UI_view2d_text_cache_rectf(v2d, &rect, str, str_len, col);
|
||||
UI_view2d_text_cache_add_rectf(v2d, &rect, str, str_len, col);
|
||||
}
|
||||
|
||||
/* add frame extents to cache of text-strings to draw in pixelspace
|
||||
|
||||
@@ -1204,7 +1204,7 @@ static void snode_setup_v2d(SpaceNode *snode, ARegion *ar, const float center[2]
|
||||
View2D *v2d = &ar->v2d;
|
||||
|
||||
/* shift view to node tree center */
|
||||
UI_view2d_setcenter(v2d, center[0], center[1]);
|
||||
UI_view2d_center_set(v2d, center[0], center[1]);
|
||||
UI_view2d_view_ortho(v2d);
|
||||
|
||||
/* aspect+font, set each time */
|
||||
@@ -1289,7 +1289,7 @@ void drawnodespace(const bContext *C, ARegion *ar)
|
||||
path = snode->treepath.last;
|
||||
|
||||
/* current View2D center, will be set temporarily for parent node trees */
|
||||
UI_view2d_getcenter(v2d, ¢er[0], ¢er[1]);
|
||||
UI_view2d_center_get(v2d, ¢er[0], ¢er[1]);
|
||||
|
||||
/* store new view center in path and current edittree */
|
||||
copy_v2_v2(path->view_center, center);
|
||||
|
||||
@@ -401,7 +401,7 @@ static void node_area_listener(bScreen *sc, ScrArea *sa, wmNotifier *wmn)
|
||||
bNodeTreePath *path = snode->treepath.last;
|
||||
/* shift view to node tree center */
|
||||
if (ar && path)
|
||||
UI_view2d_setcenter(&ar->v2d, path->view_center[0], path->view_center[1]);
|
||||
UI_view2d_center_set(&ar->v2d, path->view_center[0], path->view_center[1]);
|
||||
|
||||
ED_area_tag_refresh(sa);
|
||||
break;
|
||||
|
||||
@@ -625,7 +625,7 @@ static void draw_seq_text(View2D *v2d, Sequence *seq, float x1, float x2, float
|
||||
rect.xmax = x2;
|
||||
rect.ymax = y2;
|
||||
|
||||
UI_view2d_text_cache_rectf(v2d, &rect, str, str_len, col);
|
||||
UI_view2d_text_cache_add_rectf(v2d, &rect, str, str_len, col);
|
||||
}
|
||||
|
||||
/* draws a shaded strip, made from gradient + flat color + gradient */
|
||||
|
||||
@@ -3773,7 +3773,7 @@ static void createTransGraphEditData(bContext *C, TransInfo *t)
|
||||
float xscale, yscale;
|
||||
|
||||
/* apply scale factors to x and y axes of space-conversion matrices */
|
||||
UI_view2d_getscale(v2d, &xscale, &yscale);
|
||||
UI_view2d_scale_get(v2d, &xscale, &yscale);
|
||||
|
||||
/* mtx is data to global (i.e. view) conversion */
|
||||
mul_v3_fl(mtx[0], xscale);
|
||||
|
||||
@@ -73,7 +73,7 @@ void draw_image_cursor(ARegion *ar, const float cursor[2])
|
||||
{
|
||||
float zoom[2], x_fac, y_fac;
|
||||
|
||||
UI_view2d_getscale_inverse(&ar->v2d, &zoom[0], &zoom[1]);
|
||||
UI_view2d_scale_get_inverse(&ar->v2d, &zoom[0], &zoom[1]);
|
||||
|
||||
mul_v2_fl(zoom, 256.0f * UI_DPI_FAC);
|
||||
x_fac = zoom[0];
|
||||
|
||||
Reference in New Issue
Block a user