View2D - assorted wip changes (nothing to see here)
This commit is contained in:
@@ -38,11 +38,14 @@
|
||||
/* generic value to use when coordinate lies out of view when converting */
|
||||
#define V2D_IS_CLIPPED 12000
|
||||
|
||||
/* --- Grids --- */
|
||||
/* grid-units (for drawing time) */
|
||||
#define V2D_UNIT_SECONDS 0
|
||||
#define V2D_UNIT_FRAMES 1
|
||||
|
||||
/* grid-units (for drawing values) */
|
||||
#define V2D_UNIT_VALUES 2
|
||||
#define V2D_UNIT_DEGREES 3
|
||||
|
||||
/* clamping of grid values to whole numbers */
|
||||
#define V2D_GRID_CLAMP 0
|
||||
#define V2D_GRID_NOCLAMP 1
|
||||
@@ -53,7 +56,6 @@
|
||||
#define V2D_HORIZONTAL_AXIS (1<<2)
|
||||
#define V2D_VERTICAL_AXIS (1<<3)
|
||||
|
||||
/* --- Scrollers --- */
|
||||
|
||||
/* ------------------------------------------ */
|
||||
/* Macros: */
|
||||
@@ -92,7 +94,7 @@ void UI_view2d_draw_grid(const struct bContext *C, struct View2D *v2d, View2DGri
|
||||
void UI_view2d_free_grid(View2DGrid *grid);
|
||||
|
||||
/* scrollbar drawing */
|
||||
View2DScrollers *UI_view2d_calc_scrollers(const struct bContext *C, struct View2D *v2d, short units, short clamp);
|
||||
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, int flag);
|
||||
void UI_view2d_free_scrollers(View2DScrollers *scrollers);
|
||||
|
||||
|
||||
@@ -628,7 +628,7 @@ struct View2DScrollers {
|
||||
};
|
||||
|
||||
/* Calculate relevant scroller properties */
|
||||
View2DScrollers *UI_view2d_calc_scrollers(const bContext *C, View2D *v2d, short units, short clamp)
|
||||
View2DScrollers *UI_view2d_calc_scrollers(const bContext *C, View2D *v2d, short xunits, short xclamp, short yunits, short yclamp)
|
||||
{
|
||||
View2DScrollers *scrollers;
|
||||
rcti vert, hor;
|
||||
@@ -640,12 +640,14 @@ View2DScrollers *UI_view2d_calc_scrollers(const bContext *C, View2D *v2d, short
|
||||
/* scrollers is allocated here... */
|
||||
scrollers= MEM_callocN(sizeof(View2DScrollers), "View2DScrollers");
|
||||
|
||||
/* slider 'buttons':
|
||||
/* scroller 'buttons':
|
||||
* - These should always remain within the visible region of the scrollbar
|
||||
* - They represent the region of 'tot' that is visible in 'cur'
|
||||
*/
|
||||
/* slider 'button' extents - horizontal */
|
||||
|
||||
/* horizontal scrollers */
|
||||
if (v2d->scroll & (HOR_SCROLL|HOR_SCROLLO)) {
|
||||
/* slider 'button' extents */
|
||||
totsize= v2d->tot.xmax - v2d->tot.xmin;
|
||||
scrollsize= hor.xmax - hor.xmin;
|
||||
|
||||
@@ -661,8 +663,9 @@ View2DScrollers *UI_view2d_calc_scrollers(const bContext *C, View2D *v2d, short
|
||||
scrollers->hor_min= scrollers->hor_max;
|
||||
}
|
||||
|
||||
/* slider 'button' extents - vertical */
|
||||
/* vertical scrollers */
|
||||
if (v2d->scroll & VERT_SCROLL) {
|
||||
/* slider 'button' extents */
|
||||
totsize= v2d->tot.ymax - v2d->tot.ymin;
|
||||
scrollsize= vert.ymax - vert.ymin;
|
||||
|
||||
|
||||
@@ -51,6 +51,32 @@
|
||||
/* ********************************************************* */
|
||||
/* General Polling Funcs */
|
||||
|
||||
/* Check if mouse is within scrollbars
|
||||
* - Returns true or false (1 or 0)
|
||||
*
|
||||
* - x,y = mouse coordinates in screen (not region) space
|
||||
*/
|
||||
static short mouse_in_v2d_scrollers (const bContext *C, View2D *v2d, int x, int y)
|
||||
{
|
||||
ARegion *ar= C->region;
|
||||
int co[2];
|
||||
|
||||
/* clamp x,y to region-coordinates first */
|
||||
// FIXME: is this needed?
|
||||
co[0]= x - ar->winrct.xmin;
|
||||
co[1]= y - ar->winrct.ymin;
|
||||
|
||||
/* check if within scrollbars */
|
||||
if (v2d->scroll & (HOR_SCROLL|HOR_SCROLLO)) {
|
||||
if (IN_2D_HORIZ_SCROLL(v2d, co)) return 1;
|
||||
}
|
||||
if (v2d->scroll & VERT_SCROLL) {
|
||||
if (IN_2D_VERT_SCROLL(v2d, co)) return 1;
|
||||
}
|
||||
|
||||
/* not found */
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* ********************************************************* */
|
||||
@@ -76,6 +102,8 @@ typedef struct v2dViewPanData {
|
||||
/* options for version 1 */
|
||||
int startx, starty; /* mouse x/y values in window when operator was initiated */
|
||||
int lastx, lasty; /* previous x/y values of mouse in window */
|
||||
|
||||
short in_scroller; /* activated in scrollbar */
|
||||
} v2dViewPanData;
|
||||
|
||||
/* initialise panning customdata */
|
||||
|
||||
@@ -423,7 +423,7 @@ 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); // XXX last two vars here are useless
|
||||
scrollers= UI_view2d_calc_scrollers(C, v2d, 0, 0, 0, 0); // XXX last two vars here are useless
|
||||
UI_view2d_draw_scrollers(C, v2d, scrollers, (0));
|
||||
UI_view2d_free_scrollers(scrollers);
|
||||
}
|
||||
|
||||
@@ -152,7 +152,7 @@ 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);
|
||||
scrollers= UI_view2d_calc_scrollers(C, v2d, unit, V2D_GRID_CLAMP, 0, 0);
|
||||
UI_view2d_draw_scrollers(C, v2d, scrollers, (0));
|
||||
UI_view2d_free_scrollers(scrollers);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user