UI: add ui_window_to_block_rctf, ui_window_to_region_rcti

This commit is contained in:
Campbell Barton 2019-04-23 16:39:14 +10:00
parent 4d5e83f608
commit 310f288bb0
2 changed files with 23 additions and 0 deletions

View File

@ -213,6 +213,16 @@ void ui_window_to_block_fl(const ARegion *ar, uiBlock *block, float *x, float *y
}
}
void ui_window_to_block_rctf(const struct ARegion *ar,
uiBlock *block,
rctf *rct_dst,
const rctf *rct_src)
{
*rct_dst = *rct_src;
ui_window_to_block_fl(ar, block, &rct_dst->xmin, &rct_dst->ymin);
ui_window_to_block_fl(ar, block, &rct_dst->xmax, &rct_dst->ymax);
}
void ui_window_to_block(const ARegion *ar, uiBlock *block, int *x, int *y)
{
float fx, fy;
@ -232,6 +242,14 @@ void ui_window_to_region(const ARegion *ar, int *x, int *y)
*y -= ar->winrct.ymin;
}
void ui_window_to_region_rcti(const ARegion *ar, rcti *rect_dst, const rcti *rct_src)
{
rect_dst->xmin = rct_src->xmin - ar->winrct.xmin;
rect_dst->xmax = rct_src->xmax - ar->winrct.xmin;
rect_dst->ymin = rct_src->ymin - ar->winrct.ymin;
rect_dst->ymax = rct_src->ymax - ar->winrct.ymin;
}
void ui_region_to_window(const ARegion *ar, int *x, int *y)
{
*x += ar->winrct.xmin;

View File

@ -460,7 +460,12 @@ extern void ui_block_to_window_rctf(const struct ARegion *ar,
extern float ui_block_to_window_scale(const struct ARegion *ar, uiBlock *block);
extern void ui_window_to_block_fl(const struct ARegion *ar, uiBlock *block, float *x, float *y);
extern void ui_window_to_block(const struct ARegion *ar, uiBlock *block, int *x, int *y);
extern void ui_window_to_block_rctf(const struct ARegion *ar,
uiBlock *block,
rctf *rct_dst,
const rctf *rct_src);
extern void ui_window_to_region(const ARegion *ar, int *x, int *y);
extern void ui_window_to_region_rcti(const ARegion *ar, rcti *rect_dst, const rcti *rct_src);
extern void ui_region_to_window(const struct ARegion *ar, int *x, int *y);
extern void ui_region_winrct_get_no_margin(const struct ARegion *ar, struct rcti *r_rect);