Cleanup: rename 2D scroll defines
- Use `V2D_SCROLL_` prefix. - Use more descriptive names.
This commit is contained in:
@@ -60,17 +60,18 @@ enum eView2D_CommonViewTypes {
|
||||
|
||||
/* ------ Defines for Scrollers ----- */
|
||||
|
||||
/* scroller area */
|
||||
/** Scroll bar area. */
|
||||
#define V2D_SCROLL_HEIGHT (0.45f * U.widget_unit)
|
||||
#define V2D_SCROLL_WIDTH (0.45f * U.widget_unit)
|
||||
/* For scrollers with scale handlers */
|
||||
#define V2D_SCROLL_HEIGHT_HANDLES (0.6f * U.widget_unit)
|
||||
#define V2D_SCROLL_WIDTH_HANDLES (0.6f * U.widget_unit)
|
||||
/** Scroll bars with 'handles' used for scale (zoom). */
|
||||
#define V2D_SCROLL_HANDLE_HEIGHT (0.6f * U.widget_unit)
|
||||
#define V2D_SCROLL_HANDLE_WIDTH (0.6f * U.widget_unit)
|
||||
|
||||
/* scroller 'handles' hotspot radius for mouse */
|
||||
#define V2D_SCROLLER_HANDLE_SIZE (0.6f * U.widget_unit)
|
||||
/** Scroll bar with 'handles' hot-spot radius for cursor proximity. */
|
||||
#define V2D_SCROLL_HANDLE_SIZE_HOTSPOT (0.6f * U.widget_unit)
|
||||
|
||||
#define V2D_MIN_SCROLLER_SIZE (50.0 * UI_DPI_FAC)
|
||||
/** Don't allow scroll thumb to show below this size (so it's never too small to click on). */
|
||||
#define V2D_SCROLL_THUMB_SIZE_MIN (50.0 * UI_DPI_FAC)
|
||||
|
||||
/* ------ Define for UI_view2d_sync ----- */
|
||||
|
||||
|
||||
@@ -167,10 +167,10 @@ static void view2d_masks(View2D *v2d, bool check_scrollers, const rcti *mask_scr
|
||||
*/
|
||||
if (scroll) {
|
||||
const int scroll_width = (v2d->scroll & V2D_SCROLL_VERTICAL_HANDLES) ?
|
||||
V2D_SCROLL_WIDTH_HANDLES :
|
||||
V2D_SCROLL_HANDLE_WIDTH :
|
||||
V2D_SCROLL_WIDTH;
|
||||
const int scroll_height = (v2d->scroll & V2D_SCROLL_HORIZONTAL_HANDLES) ?
|
||||
V2D_SCROLL_HEIGHT_HANDLES :
|
||||
V2D_SCROLL_HANDLE_HEIGHT :
|
||||
V2D_SCROLL_HEIGHT;
|
||||
|
||||
/* vertical scroller */
|
||||
@@ -1463,8 +1463,8 @@ View2DScrollers *UI_view2d_scrollers_calc(View2D *v2d, const rcti *mask_custom)
|
||||
vert.xmax -= smaller;
|
||||
}
|
||||
|
||||
CLAMP(vert.ymin, vert.ymin, vert.ymax - V2D_SCROLLER_HANDLE_SIZE);
|
||||
CLAMP(hor.xmin, hor.xmin, hor.xmax - V2D_SCROLLER_HANDLE_SIZE);
|
||||
CLAMP(vert.ymin, vert.ymin, vert.ymax - V2D_SCROLL_HANDLE_SIZE_HOTSPOT);
|
||||
CLAMP(hor.xmin, hor.xmin, hor.xmax - V2D_SCROLL_HANDLE_SIZE_HOTSPOT);
|
||||
|
||||
/* store in scrollers, used for drawing */
|
||||
scrollers->vert = vert;
|
||||
@@ -1505,11 +1505,11 @@ View2DScrollers *UI_view2d_scrollers_calc(View2D *v2d, const rcti *mask_custom)
|
||||
scrollers->hor_min = scrollers->hor_max;
|
||||
}
|
||||
/* prevent sliders from being too small to grab */
|
||||
if ((scrollers->hor_max - scrollers->hor_min) < V2D_MIN_SCROLLER_SIZE) {
|
||||
scrollers->hor_max = scrollers->hor_min + V2D_MIN_SCROLLER_SIZE;
|
||||
if ((scrollers->hor_max - scrollers->hor_min) < V2D_SCROLL_THUMB_SIZE_MIN) {
|
||||
scrollers->hor_max = scrollers->hor_min + V2D_SCROLL_THUMB_SIZE_MIN;
|
||||
|
||||
CLAMP(scrollers->hor_max, hor.xmin + V2D_MIN_SCROLLER_SIZE, hor.xmax);
|
||||
CLAMP(scrollers->hor_min, hor.xmin, hor.xmax - V2D_MIN_SCROLLER_SIZE);
|
||||
CLAMP(scrollers->hor_max, hor.xmin + V2D_SCROLL_THUMB_SIZE_MIN, hor.xmax);
|
||||
CLAMP(scrollers->hor_min, hor.xmin, hor.xmax - V2D_SCROLL_THUMB_SIZE_MIN);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1543,11 +1543,11 @@ View2DScrollers *UI_view2d_scrollers_calc(View2D *v2d, const rcti *mask_custom)
|
||||
scrollers->vert_min = scrollers->vert_max;
|
||||
}
|
||||
/* prevent sliders from being too small to grab */
|
||||
if ((scrollers->vert_max - scrollers->vert_min) < V2D_MIN_SCROLLER_SIZE) {
|
||||
scrollers->vert_max = scrollers->vert_min + V2D_MIN_SCROLLER_SIZE;
|
||||
if ((scrollers->vert_max - scrollers->vert_min) < V2D_SCROLL_THUMB_SIZE_MIN) {
|
||||
scrollers->vert_max = scrollers->vert_min + V2D_SCROLL_THUMB_SIZE_MIN;
|
||||
|
||||
CLAMP(scrollers->vert_max, vert.ymin + V2D_MIN_SCROLLER_SIZE, vert.ymax);
|
||||
CLAMP(scrollers->vert_min, vert.ymin, vert.ymax - V2D_MIN_SCROLLER_SIZE);
|
||||
CLAMP(scrollers->vert_max, vert.ymin + V2D_SCROLL_THUMB_SIZE_MIN, vert.ymax);
|
||||
CLAMP(scrollers->vert_min, vert.ymin, vert.ymax - V2D_SCROLL_THUMB_SIZE_MIN);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1597,7 +1597,7 @@ void UI_view2d_scrollers_draw(View2D *v2d, View2DScrollers *vs)
|
||||
* and only the time-grids with their zoomability can do so)
|
||||
*/
|
||||
if ((v2d->keepzoom & V2D_LOCKZOOM_X) == 0 && (v2d->scroll & V2D_SCROLL_HORIZONTAL_HANDLES) &&
|
||||
(BLI_rcti_size_x(&slider) > V2D_SCROLLER_HANDLE_SIZE)) {
|
||||
(BLI_rcti_size_x(&slider) > V2D_SCROLL_HANDLE_SIZE_HOTSPOT)) {
|
||||
state |= UI_SCROLL_ARROWS;
|
||||
}
|
||||
|
||||
@@ -1631,7 +1631,7 @@ void UI_view2d_scrollers_draw(View2D *v2d, View2DScrollers *vs)
|
||||
* and only the time-grids with their zoomability can do so)
|
||||
*/
|
||||
if ((v2d->keepzoom & V2D_LOCKZOOM_Y) == 0 && (v2d->scroll & V2D_SCROLL_VERTICAL_HANDLES) &&
|
||||
(BLI_rcti_size_y(&slider) > V2D_SCROLLER_HANDLE_SIZE)) {
|
||||
(BLI_rcti_size_y(&slider) > V2D_SCROLL_HANDLE_SIZE_HOTSPOT)) {
|
||||
state |= UI_SCROLL_ARROWS;
|
||||
}
|
||||
|
||||
|
||||
@@ -1719,14 +1719,14 @@ static short mouse_in_scroller_handle(int mouse, int sc_min, int sc_max, int sh_
|
||||
|
||||
/* check if mouse is in or past either handle */
|
||||
/* TODO: check if these extents are still valid or not */
|
||||
in_max = ((mouse >= (sh_max - V2D_SCROLLER_HANDLE_SIZE)) &&
|
||||
(mouse <= (sh_max + V2D_SCROLLER_HANDLE_SIZE)));
|
||||
in_min = ((mouse <= (sh_min + V2D_SCROLLER_HANDLE_SIZE)) &&
|
||||
(mouse >= (sh_min - V2D_SCROLLER_HANDLE_SIZE)));
|
||||
in_bar = ((mouse < (sh_max - V2D_SCROLLER_HANDLE_SIZE)) &&
|
||||
(mouse > (sh_min + V2D_SCROLLER_HANDLE_SIZE)));
|
||||
out_min = mouse < (sh_min - V2D_SCROLLER_HANDLE_SIZE);
|
||||
out_max = mouse > (sh_max + V2D_SCROLLER_HANDLE_SIZE);
|
||||
in_max = ((mouse >= (sh_max - V2D_SCROLL_HANDLE_SIZE_HOTSPOT)) &&
|
||||
(mouse <= (sh_max + V2D_SCROLL_HANDLE_SIZE_HOTSPOT)));
|
||||
in_min = ((mouse <= (sh_min + V2D_SCROLL_HANDLE_SIZE_HOTSPOT)) &&
|
||||
(mouse >= (sh_min - V2D_SCROLL_HANDLE_SIZE_HOTSPOT)));
|
||||
in_bar = ((mouse < (sh_max - V2D_SCROLL_HANDLE_SIZE_HOTSPOT)) &&
|
||||
(mouse > (sh_min + V2D_SCROLL_HANDLE_SIZE_HOTSPOT)));
|
||||
out_min = mouse < (sh_min - V2D_SCROLL_HANDLE_SIZE_HOTSPOT);
|
||||
out_max = mouse > (sh_max + V2D_SCROLL_HANDLE_SIZE_HOTSPOT);
|
||||
|
||||
if (in_bar) {
|
||||
return SCROLLHANDLE_BAR;
|
||||
|
||||
@@ -411,7 +411,7 @@ void timeline_draw_cache(SpaceAction *saction, Object *ob, Scene *scene)
|
||||
}
|
||||
|
||||
GPU_matrix_push();
|
||||
GPU_matrix_translate_2f(0.0, (float)V2D_SCROLL_HEIGHT_HANDLES + yoffs);
|
||||
GPU_matrix_translate_2f(0.0, (float)V2D_SCROLL_HANDLE_HEIGHT + yoffs);
|
||||
GPU_matrix_scale_2f(1.0, cache_draw_height);
|
||||
|
||||
switch (pid->type) {
|
||||
|
||||
@@ -961,7 +961,7 @@ static void draw_seq_strip(const bContext *C,
|
||||
x1 = seq->startdisp + handsize_clamped;
|
||||
x2 = seq->enddisp - handsize_clamped;
|
||||
|
||||
float scroller_vert_xoffs = (V2D_SCROLL_WIDTH_HANDLES + SEQ_SCROLLER_TEXT_OFFSET) * pixelx;
|
||||
float scroller_vert_xoffs = (V2D_SCROLL_HANDLE_WIDTH + SEQ_SCROLLER_TEXT_OFFSET) * pixelx;
|
||||
|
||||
/* info text on the strip */
|
||||
if (x1 < v2d->cur.xmin + scroller_vert_xoffs) {
|
||||
@@ -1847,7 +1847,7 @@ static bool draw_cache_view_cb(
|
||||
color[2] = 0.2f;
|
||||
stripe_ht = UI_view2d_region_to_view_y(v2d, 4.0f * UI_DPI_FAC * U.pixelsize) -
|
||||
v2d->cur.ymin;
|
||||
stripe_bot = UI_view2d_region_to_view_y(v2d, V2D_SCROLL_HEIGHT_HANDLES);
|
||||
stripe_bot = UI_view2d_region_to_view_y(v2d, V2D_SCROLL_HANDLE_HEIGHT);
|
||||
stripe_top = stripe_bot + stripe_ht;
|
||||
break;
|
||||
}
|
||||
@@ -1931,7 +1931,7 @@ static void draw_cache_view(const bContext *C)
|
||||
CLAMP_MIN(stripe_offs, stripe_ht / 2);
|
||||
|
||||
if (scene->ed->cache_flag & SEQ_CACHE_VIEW_FINAL_OUT) {
|
||||
stripe_bot = UI_view2d_region_to_view_y(v2d, V2D_SCROLL_HEIGHT_HANDLES);
|
||||
stripe_bot = UI_view2d_region_to_view_y(v2d, V2D_SCROLL_HANDLE_HEIGHT);
|
||||
stripe_top = stripe_bot + stripe_ht;
|
||||
float bg_color[4] = {1.0f, 0.4f, 0.2f, 0.1f};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user