View2D: Renamed a few API methods to follow standard naming conventions, and added define to use when an argument to these methods is irrelevant.
This commit is contained in:
parent
d2bfb9ae1d
commit
b7fc71a3e2
@ -38,6 +38,9 @@
|
||||
/* generic value to use when coordinate lies out of view when converting */
|
||||
#define V2D_IS_CLIPPED 12000
|
||||
|
||||
/* 'dummy' argument to pass when argument is irrelevant */
|
||||
#define V2D_ARG_DUMMY -1
|
||||
|
||||
/* grid-units (for drawing time) */
|
||||
#define V2D_UNIT_SECONDS 0
|
||||
#define V2D_UNIT_FRAMES 1
|
||||
@ -84,7 +87,6 @@ typedef struct View2DScrollers View2DScrollers;
|
||||
/* Prototypes: */
|
||||
|
||||
/* refresh and validation (of view rects) */
|
||||
// XXX rename these...
|
||||
void UI_view2d_size_update(struct View2D *v2d, int winx, int winy);
|
||||
void UI_view2d_status_enforce(struct View2D *v2d);
|
||||
|
||||
@ -97,14 +99,14 @@ void UI_view2d_view_orthoSpecial(const struct bContext *C, struct View2D *v2d, s
|
||||
void UI_view2d_view_restore(const struct bContext *C);
|
||||
|
||||
/* grid drawing */
|
||||
View2DGrid *UI_view2d_calc_grid(const struct bContext *C, struct View2D *v2d, short unit, short clamp, int winx, int winy);
|
||||
void UI_view2d_draw_grid(const struct bContext *C, struct View2D *v2d, View2DGrid *grid, int flag);
|
||||
void UI_view2d_free_grid(View2DGrid *grid);
|
||||
View2DGrid *UI_view2d_grid_calc(const struct bContext *C, struct View2D *v2d, short unit, short clamp, int winx, int winy);
|
||||
void UI_view2d_grid_draw(const struct bContext *C, struct View2D *v2d, View2DGrid *grid, int flag);
|
||||
void UI_view2d_grid_free(View2DGrid *grid);
|
||||
|
||||
/* scrollbar drawing */
|
||||
View2DScrollers *UI_view2d_calc_scrollers(const struct bContext *C, struct View2D *v2d, short xunits, short xclamp, short yunits, short yclamp);
|
||||
void UI_view2d_draw_scrollers(const struct bContext *C, struct View2D *v2d, View2DScrollers *scrollers);
|
||||
void UI_view2d_free_scrollers(View2DScrollers *scrollers);
|
||||
View2DScrollers *UI_view2d_scrollers_calc(const struct bContext *C, struct View2D *v2d, short xunits, short xclamp, short yunits, short yclamp);
|
||||
void UI_view2d_scrollers_draw(const struct bContext *C, struct View2D *v2d, View2DScrollers *scrollers);
|
||||
void UI_view2d_scrollers_free(View2DScrollers *scrollers);
|
||||
|
||||
/* coordinate conversion */
|
||||
void UI_view2d_region_to_view(struct View2D *v2d, int x, int y, float *viewx, float *viewy);
|
||||
|
@ -552,7 +552,7 @@ static void step_to_grid(float *step, int *power, int unit)
|
||||
|
||||
/* Intialise settings necessary for drawing gridlines in a 2d-view
|
||||
* - Currently, will return pointer to View2DGrid struct that needs to
|
||||
* be freed with UI_view2d_free_grid()
|
||||
* be freed with UI_view2d_grid_free()
|
||||
* - Is used for scrollbar drawing too (for units drawing)
|
||||
*
|
||||
* - unit = V2D_UNIT_* grid steps in seconds or frames
|
||||
@ -560,7 +560,7 @@ static void step_to_grid(float *step, int *power, int unit)
|
||||
* - winx = width of region we're drawing to
|
||||
* - winy = height of region we're drawing into
|
||||
*/
|
||||
View2DGrid *UI_view2d_calc_grid(const bContext *C, View2D *v2d, short unit, short clamp, int winx, int winy)
|
||||
View2DGrid *UI_view2d_grid_calc(const bContext *C, View2D *v2d, short unit, short clamp, int winx, int winy)
|
||||
{
|
||||
View2DGrid *grid;
|
||||
float space, pixels, seconddiv;
|
||||
@ -616,7 +616,7 @@ View2DGrid *UI_view2d_calc_grid(const bContext *C, View2D *v2d, short unit, shor
|
||||
}
|
||||
|
||||
/* Draw gridlines in the given 2d-region */
|
||||
void UI_view2d_draw_grid(const bContext *C, View2D *v2d, View2DGrid *grid, int flag)
|
||||
void UI_view2d_grid_draw(const bContext *C, View2D *v2d, View2DGrid *grid, int flag)
|
||||
{
|
||||
float vec1[2], vec2[2];
|
||||
int a, step;
|
||||
@ -724,7 +724,7 @@ void UI_view2d_draw_grid(const bContext *C, View2D *v2d, View2DGrid *grid, int f
|
||||
}
|
||||
|
||||
/* free temporary memory used for drawing grid */
|
||||
void UI_view2d_free_grid(View2DGrid *grid)
|
||||
void UI_view2d_grid_free(View2DGrid *grid)
|
||||
{
|
||||
MEM_freeN(grid);
|
||||
}
|
||||
@ -745,7 +745,7 @@ struct View2DScrollers {
|
||||
};
|
||||
|
||||
/* Calculate relevant scroller properties */
|
||||
View2DScrollers *UI_view2d_calc_scrollers(const bContext *C, View2D *v2d, short xunits, short xclamp, short yunits, short yclamp)
|
||||
View2DScrollers *UI_view2d_scrollers_calc(const bContext *C, View2D *v2d, short xunits, short xclamp, short yunits, short yclamp)
|
||||
{
|
||||
View2DScrollers *scrollers;
|
||||
rcti vert, hor;
|
||||
@ -764,7 +764,7 @@ View2DScrollers *UI_view2d_calc_scrollers(const bContext *C, View2D *v2d, short
|
||||
|
||||
/* horizontal scrollers */
|
||||
if (v2d->scroll & (V2D_SCROLL_HORIZONTAL|V2D_SCROLL_HORIZONTAL_O)) {
|
||||
/* slider 'button' extents */
|
||||
/* scroller 'button' extents */
|
||||
totsize= v2d->tot.xmax - v2d->tot.xmin;
|
||||
scrollsize= hor.xmax - hor.xmin;
|
||||
|
||||
@ -782,7 +782,7 @@ View2DScrollers *UI_view2d_calc_scrollers(const bContext *C, View2D *v2d, short
|
||||
|
||||
/* vertical scrollers */
|
||||
if (v2d->scroll & V2D_SCROLL_VERTICAL) {
|
||||
/* slider 'button' extents */
|
||||
/* scroller 'button' extents */
|
||||
totsize= v2d->tot.ymax - v2d->tot.ymin;
|
||||
scrollsize= vert.ymax - vert.ymin;
|
||||
|
||||
@ -808,9 +808,9 @@ View2DScrollers *UI_view2d_calc_scrollers(const bContext *C, View2D *v2d, short
|
||||
|
||||
/* calculate grid */
|
||||
if (v2d->scroll & V2D_SCROLL_SCALE_HORIZONTAL)
|
||||
scrollers->grid= UI_view2d_calc_grid(C, v2d, xunits, xclamp, (hor.xmax - hor.xmin), (vert.ymax - vert.ymin));
|
||||
scrollers->grid= UI_view2d_grid_calc(C, v2d, xunits, xclamp, (hor.xmax - hor.xmin), (vert.ymax - vert.ymin));
|
||||
else if (v2d->scroll & V2D_SCROLL_SCALE_VERTICAL)
|
||||
scrollers->grid= UI_view2d_calc_grid(C, v2d, yunits, yclamp, (hor.xmax - hor.xmin), (vert.ymax - vert.ymin));
|
||||
scrollers->grid= UI_view2d_grid_calc(C, v2d, yunits, yclamp, (hor.xmax - hor.xmin), (vert.ymax - vert.ymin));
|
||||
}
|
||||
|
||||
/* return scrollers */
|
||||
@ -925,7 +925,7 @@ static void scroll_printstr(View2DScrollers *scrollers, float x, float y, float
|
||||
|
||||
|
||||
/* Draw scrollbars in the given 2d-region */
|
||||
void UI_view2d_draw_scrollers(const bContext *C, View2D *v2d, View2DScrollers *scrollers)
|
||||
void UI_view2d_scrollers_draw(const bContext *C, View2D *v2d, View2DScrollers *scrollers)
|
||||
{
|
||||
const int darker= -40, dark= 0, light= 20, lighter= 50;
|
||||
rcti vert, hor;
|
||||
@ -1088,7 +1088,7 @@ void UI_view2d_draw_scrollers(const bContext *C, View2D *v2d, View2DScrollers *s
|
||||
}
|
||||
|
||||
/* free temporary memory used for drawing scrollers */
|
||||
void UI_view2d_free_scrollers(View2DScrollers *scrollers)
|
||||
void UI_view2d_scrollers_free(View2DScrollers *scrollers)
|
||||
{
|
||||
/* need to free grid as well... */
|
||||
if (scrollers->grid) MEM_freeN(scrollers->grid);
|
||||
|
@ -403,7 +403,6 @@ static void outliner_main_area_draw(const bContext *C, ARegion *ar)
|
||||
/* update size of tot-rect (extents of data/viewable area) */
|
||||
UI_view2d_totRect_set(v2d, width, height);
|
||||
|
||||
|
||||
rct.xmin= 0;
|
||||
rct.ymin= -height;
|
||||
rct.xmax= width;
|
||||
@ -425,9 +424,9 @@ static void outliner_main_area_draw(const bContext *C, ARegion *ar)
|
||||
UI_view2d_view_restore(C);
|
||||
|
||||
/* scrollers */
|
||||
scrollers= UI_view2d_calc_scrollers(C, v2d, 0, 0, 0, 0);
|
||||
UI_view2d_draw_scrollers(C, v2d, scrollers);
|
||||
UI_view2d_free_scrollers(scrollers);
|
||||
scrollers= UI_view2d_scrollers_calc(C, v2d, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY, V2D_ARG_DUMMY);
|
||||
UI_view2d_scrollers_draw(C, v2d, scrollers);
|
||||
UI_view2d_scrollers_free(scrollers);
|
||||
}
|
||||
|
||||
static void outliner_main_area_free(ARegion *ar)
|
||||
|
@ -138,9 +138,9 @@ static void time_main_area_draw(const bContext *C, ARegion *ar)
|
||||
|
||||
/* grid */
|
||||
unit= (stime->flag & TIME_DRAWFRAMES)? V2D_UNIT_FRAMES: V2D_UNIT_SECONDS;
|
||||
grid= UI_view2d_calc_grid(C, v2d, unit, V2D_GRID_CLAMP, winx, winy);
|
||||
UI_view2d_draw_grid(C, v2d, grid, (V2D_VERTICAL_LINES|V2D_VERTICAL_AXIS));
|
||||
UI_view2d_free_grid(grid);
|
||||
grid= UI_view2d_grid_calc(C, v2d, unit, V2D_GRID_CLAMP, winx, winy);
|
||||
UI_view2d_grid_draw(C, v2d, grid, (V2D_VERTICAL_LINES|V2D_VERTICAL_AXIS));
|
||||
UI_view2d_grid_free(grid);
|
||||
|
||||
/* current frame */
|
||||
time_draw_cfra_time(C, stime, ar);
|
||||
@ -153,9 +153,9 @@ static void time_main_area_draw(const bContext *C, ARegion *ar)
|
||||
UI_view2d_view_restore(C);
|
||||
|
||||
/* scrollers */
|
||||
scrollers= UI_view2d_calc_scrollers(C, v2d, unit, V2D_GRID_CLAMP, 0, 0);
|
||||
UI_view2d_draw_scrollers(C, v2d, scrollers);
|
||||
UI_view2d_free_scrollers(scrollers);
|
||||
scrollers= UI_view2d_scrollers_calc(C, v2d, unit, V2D_GRID_CLAMP, V2D_ARG_DUMMY, V2D_ARG_DUMMY);
|
||||
UI_view2d_scrollers_draw(C, v2d, scrollers);
|
||||
UI_view2d_scrollers_free(scrollers);
|
||||
}
|
||||
|
||||
static void time_main_area_listener(ARegion *ar, wmNotifier *wmn)
|
||||
|
Loading…
Reference in New Issue
Block a user