forked from blender/blender
main sync #3
@ -1298,11 +1298,9 @@ void UI_panel_category_draw_all(ARegion *region, const char *category_id_active)
|
|||||||
const int roundboxtype = is_left ? (UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT) :
|
const int roundboxtype = is_left ? (UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT) :
|
||||||
(UI_CNR_TOP_RIGHT | UI_CNR_BOTTOM_RIGHT);
|
(UI_CNR_TOP_RIGHT | UI_CNR_BOTTOM_RIGHT);
|
||||||
bool is_alpha;
|
bool is_alpha;
|
||||||
bool do_scaletabs = false;
|
|
||||||
#ifdef USE_FLAT_INACTIVE
|
#ifdef USE_FLAT_INACTIVE
|
||||||
bool is_active_prev = false;
|
bool is_active_prev = false;
|
||||||
#endif
|
#endif
|
||||||
float scaletabs = 1.0f;
|
|
||||||
/* Same for all tabs. */
|
/* Same for all tabs. */
|
||||||
/* Intentionally don't scale by 'px'. */
|
/* Intentionally don't scale by 'px'. */
|
||||||
const int rct_xmin = is_left ? v2d->mask.xmin + 3 : (v2d->mask.xmax - category_tabs_width);
|
const int rct_xmin = is_left ? v2d->mask.xmin + 3 : (v2d->mask.xmax - category_tabs_width);
|
||||||
@ -1344,7 +1342,7 @@ void UI_panel_category_draw_all(ARegion *region, const char *category_id_active)
|
|||||||
BLI_assert(UI_panel_category_is_visible(region));
|
BLI_assert(UI_panel_category_is_visible(region));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Calculate tab rectangle and check if we need to scale down. */
|
/* Calculate tab rectangle for each panel. */
|
||||||
LISTBASE_FOREACH (PanelCategoryDyn *, pc_dyn, ®ion->panels_category) {
|
LISTBASE_FOREACH (PanelCategoryDyn *, pc_dyn, ®ion->panels_category) {
|
||||||
rcti *rct = &pc_dyn->rect;
|
rcti *rct = &pc_dyn->rect;
|
||||||
const char *category_id = pc_dyn->idname;
|
const char *category_id = pc_dyn->idname;
|
||||||
@ -1360,16 +1358,13 @@ void UI_panel_category_draw_all(ARegion *region, const char *category_id_active)
|
|||||||
y_ofs += category_width + tab_v_pad + (tab_v_pad_text * 2);
|
y_ofs += category_width + tab_v_pad + (tab_v_pad_text * 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (y_ofs > BLI_rcti_size_y(&v2d->mask)) {
|
const int max_scroll = max_ii(y_ofs - BLI_rcti_size_y(&v2d->mask), 0);
|
||||||
scaletabs = float(BLI_rcti_size_y(&v2d->mask)) / float(y_ofs);
|
const int scroll = clamp_i(region->category_scroll, 0, max_scroll);
|
||||||
|
region->category_scroll = scroll;
|
||||||
LISTBASE_FOREACH (PanelCategoryDyn *, pc_dyn, ®ion->panels_category) {
|
LISTBASE_FOREACH (PanelCategoryDyn *, pc_dyn, ®ion->panels_category) {
|
||||||
rcti *rct = &pc_dyn->rect;
|
rcti *rct = &pc_dyn->rect;
|
||||||
rct->ymin = ((rct->ymin - v2d->mask.ymax) * scaletabs) + v2d->mask.ymax;
|
rct->ymin += scroll;
|
||||||
rct->ymax = ((rct->ymax - v2d->mask.ymax) * scaletabs) + v2d->mask.ymax;
|
rct->ymax += scroll;
|
||||||
}
|
|
||||||
|
|
||||||
do_scaletabs = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Begin drawing. */
|
/* Begin drawing. */
|
||||||
@ -1405,14 +1400,17 @@ void UI_panel_category_draw_all(ARegion *region, const char *category_id_active)
|
|||||||
|
|
||||||
LISTBASE_FOREACH (PanelCategoryDyn *, pc_dyn, ®ion->panels_category) {
|
LISTBASE_FOREACH (PanelCategoryDyn *, pc_dyn, ®ion->panels_category) {
|
||||||
const rcti *rct = &pc_dyn->rect;
|
const rcti *rct = &pc_dyn->rect;
|
||||||
|
if (rct->ymin > v2d->mask.ymax) {
|
||||||
|
/* Scrolled outside the top of the view, check the next tab. */
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (rct->ymax < v2d->mask.ymin) {
|
||||||
|
/* Scrolled past visible bounds, no need to draw other tabs. */
|
||||||
|
break;
|
||||||
|
}
|
||||||
const char *category_id = pc_dyn->idname;
|
const char *category_id = pc_dyn->idname;
|
||||||
const char *category_id_draw = IFACE_(category_id);
|
const char *category_id_draw = IFACE_(category_id);
|
||||||
const int category_width = BLI_rcti_size_y(rct) - (tab_v_pad_text * 2);
|
|
||||||
size_t category_draw_len = BLF_DRAW_STR_DUMMY_MAX;
|
size_t category_draw_len = BLF_DRAW_STR_DUMMY_MAX;
|
||||||
#if 0
|
|
||||||
int category_width = BLF_width(fontid, category_id_draw, BLF_DRAW_STR_DUMMY_MAX);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
const bool is_active = STREQ(category_id, category_id_active);
|
const bool is_active = STREQ(category_id, category_id_active);
|
||||||
|
|
||||||
GPU_blend(GPU_BLEND_ALPHA);
|
GPU_blend(GPU_BLEND_ALPHA);
|
||||||
@ -1469,11 +1467,6 @@ void UI_panel_category_draw_all(ARegion *region, const char *category_id_active)
|
|||||||
|
|
||||||
/* Tab titles. */
|
/* Tab titles. */
|
||||||
|
|
||||||
if (do_scaletabs) {
|
|
||||||
category_draw_len = BLF_width_to_strlen(
|
|
||||||
fontid, category_id_draw, category_draw_len, category_width, nullptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
BLF_position(fontid, rct->xmax - text_v_ofs, rct->ymin + tab_v_pad_text, 0.0f);
|
BLF_position(fontid, rct->xmax - text_v_ofs, rct->ymin + tab_v_pad_text, 0.0f);
|
||||||
BLF_color3ubv(fontid, is_active ? theme_col_text_hi : theme_col_text);
|
BLF_color3ubv(fontid, is_active ? theme_col_text_hi : theme_col_text);
|
||||||
BLF_draw(fontid, category_id_draw, category_draw_len);
|
BLF_draw(fontid, category_id_draw, category_draw_len);
|
||||||
@ -2255,7 +2248,9 @@ static int ui_handle_panel_category_cycling(const wmEvent *event,
|
|||||||
const char *category = UI_panel_category_active_get(region, false);
|
const char *category = UI_panel_category_active_get(region, false);
|
||||||
if (LIKELY(category)) {
|
if (LIKELY(category)) {
|
||||||
PanelCategoryDyn *pc_dyn = UI_panel_category_find(region, category);
|
PanelCategoryDyn *pc_dyn = UI_panel_category_find(region, category);
|
||||||
if (LIKELY(pc_dyn)) {
|
/* Cyclic behavior between categories
|
||||||
|
* using Ctrl+Tab (+Shift for backwards) or Ctrl+Wheel Up/Down. */
|
||||||
|
if (LIKELY(pc_dyn) && (event->modifier & KM_CTRL)) {
|
||||||
if (is_mousewheel) {
|
if (is_mousewheel) {
|
||||||
/* We can probably get rid of this and only allow Ctrl-Tabbing. */
|
/* We can probably get rid of this and only allow Ctrl-Tabbing. */
|
||||||
pc_dyn = (event->type == WHEELDOWNMOUSE) ? pc_dyn->next : pc_dyn->prev;
|
pc_dyn = (event->type == WHEELDOWNMOUSE) ? pc_dyn->next : pc_dyn->prev;
|
||||||
@ -2276,9 +2271,9 @@ static int ui_handle_panel_category_cycling(const wmEvent *event,
|
|||||||
UI_panel_category_active_set(region, pc_dyn->idname);
|
UI_panel_category_active_set(region, pc_dyn->idname);
|
||||||
ED_region_tag_redraw(region);
|
ED_region_tag_redraw(region);
|
||||||
}
|
}
|
||||||
|
return WM_UI_HANDLER_BREAK;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return WM_UI_HANDLER_BREAK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return WM_UI_HANDLER_CONTINUE;
|
return WM_UI_HANDLER_CONTINUE;
|
||||||
|
@ -82,6 +82,9 @@ struct v2dViewPanData {
|
|||||||
/** event starting pan, for modal exit */
|
/** event starting pan, for modal exit */
|
||||||
int invoke_event;
|
int invoke_event;
|
||||||
|
|
||||||
|
/** Tag if the scroll is done in the category tab. */
|
||||||
|
bool do_category_scroll;
|
||||||
|
|
||||||
/** for MMB in scrollers (old feature in past, but now not that useful) */
|
/** for MMB in scrollers (old feature in past, but now not that useful) */
|
||||||
short in_scroller;
|
short in_scroller;
|
||||||
|
|
||||||
@ -133,6 +136,8 @@ static void view_pan_init(bContext *C, wmOperator *op)
|
|||||||
vpd->facy = BLI_rctf_size_y(&vpd->v2d->cur) / winy;
|
vpd->facy = BLI_rctf_size_y(&vpd->v2d->cur) / winy;
|
||||||
|
|
||||||
vpd->v2d->flag |= V2D_IS_NAVIGATING;
|
vpd->v2d->flag |= V2D_IS_NAVIGATING;
|
||||||
|
|
||||||
|
vpd->do_category_scroll = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* apply transform to view (i.e. adjust 'cur' rect) */
|
/* apply transform to view (i.e. adjust 'cur' rect) */
|
||||||
@ -144,14 +149,19 @@ static void view_pan_apply_ex(bContext *C, v2dViewPanData *vpd, float dx, float
|
|||||||
dx *= vpd->facx;
|
dx *= vpd->facx;
|
||||||
dy *= vpd->facy;
|
dy *= vpd->facy;
|
||||||
|
|
||||||
/* only move view on an axis if change is allowed */
|
if (!vpd->do_category_scroll) {
|
||||||
if ((v2d->keepofs & V2D_LOCKOFS_X) == 0) {
|
/* only move view on an axis if change is allowed */
|
||||||
v2d->cur.xmin += dx;
|
if ((v2d->keepofs & V2D_LOCKOFS_X) == 0) {
|
||||||
v2d->cur.xmax += dx;
|
v2d->cur.xmin += dx;
|
||||||
|
v2d->cur.xmax += dx;
|
||||||
|
}
|
||||||
|
if ((v2d->keepofs & V2D_LOCKOFS_Y) == 0) {
|
||||||
|
v2d->cur.ymin += dy;
|
||||||
|
v2d->cur.ymax += dy;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if ((v2d->keepofs & V2D_LOCKOFS_Y) == 0) {
|
else {
|
||||||
v2d->cur.ymin += dy;
|
vpd->region->category_scroll -= dy;
|
||||||
v2d->cur.ymax += dy;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Inform v2d about changes after this operation. */
|
/* Inform v2d about changes after this operation. */
|
||||||
@ -212,6 +222,8 @@ static int view_pan_invoke(bContext *C, wmOperator *op, const wmEvent *event)
|
|||||||
vpd->starty = vpd->lasty = event->xy[1];
|
vpd->starty = vpd->lasty = event->xy[1];
|
||||||
vpd->invoke_event = event->type;
|
vpd->invoke_event = event->type;
|
||||||
|
|
||||||
|
vpd->do_category_scroll = ED_region_panel_category_gutter_isect_xy(vpd->region, event->xy);
|
||||||
|
|
||||||
if (event->type == MOUSEPAN) {
|
if (event->type == MOUSEPAN) {
|
||||||
RNA_int_set(op->ptr, "deltax", event->prev_xy[0] - event->xy[0]);
|
RNA_int_set(op->ptr, "deltax", event->prev_xy[0] - event->xy[0]);
|
||||||
RNA_int_set(op->ptr, "deltay", event->prev_xy[1] - event->xy[1]);
|
RNA_int_set(op->ptr, "deltay", event->prev_xy[1] - event->xy[1]);
|
||||||
@ -482,6 +494,10 @@ static int view_scrolldown_exec(bContext *C, wmOperator *op)
|
|||||||
return OPERATOR_PASS_THROUGH;
|
return OPERATOR_PASS_THROUGH;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const wmWindow *win = CTX_wm_window(C);
|
||||||
|
vpd->do_category_scroll = ED_region_panel_category_gutter_isect_xy(vpd->region,
|
||||||
|
win->eventstate->xy);
|
||||||
|
|
||||||
/* set RNA-Props */
|
/* set RNA-Props */
|
||||||
RNA_int_set(op->ptr, "deltax", 0);
|
RNA_int_set(op->ptr, "deltax", 0);
|
||||||
RNA_int_set(op->ptr, "deltay", -40);
|
RNA_int_set(op->ptr, "deltay", -40);
|
||||||
@ -529,6 +545,10 @@ static int view_scrollup_exec(bContext *C, wmOperator *op)
|
|||||||
return OPERATOR_PASS_THROUGH;
|
return OPERATOR_PASS_THROUGH;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const wmWindow *win = CTX_wm_window(C);
|
||||||
|
vpd->do_category_scroll = ED_region_panel_category_gutter_isect_xy(vpd->region,
|
||||||
|
win->eventstate->xy);
|
||||||
|
|
||||||
/* set RNA-Props */
|
/* set RNA-Props */
|
||||||
RNA_int_set(op->ptr, "deltax", 0);
|
RNA_int_set(op->ptr, "deltax", 0);
|
||||||
RNA_int_set(op->ptr, "deltay", 40);
|
RNA_int_set(op->ptr, "deltay", 40);
|
||||||
@ -2181,6 +2201,8 @@ static int reset_exec(bContext *C, wmOperator * /*op*/)
|
|||||||
View2D *v2d = ®ion->v2d;
|
View2D *v2d = ®ion->v2d;
|
||||||
const int snap_test = ED_region_snap_size_test(region);
|
const int snap_test = ED_region_snap_size_test(region);
|
||||||
|
|
||||||
|
region->category_scroll = 0;
|
||||||
|
|
||||||
/* zoom 1.0 */
|
/* zoom 1.0 */
|
||||||
const int winx = float(BLI_rcti_size_x(&v2d->mask) + 1);
|
const int winx = float(BLI_rcti_size_x(&v2d->mask) + 1);
|
||||||
const int winy = float(BLI_rcti_size_y(&v2d->mask) + 1);
|
const int winy = float(BLI_rcti_size_y(&v2d->mask) + 1);
|
||||||
|
@ -455,6 +455,10 @@ typedef struct ARegion {
|
|||||||
rcti drawrct;
|
rcti drawrct;
|
||||||
/** Size. */
|
/** Size. */
|
||||||
short winx, winy;
|
short winx, winy;
|
||||||
|
/* This is a Y offset on the panel tabs that represents pixels, where zero represents no scroll -
|
||||||
|
* the first category always shows first at the top. */
|
||||||
|
int category_scroll;
|
||||||
|
char _pad0[4];
|
||||||
|
|
||||||
/** Region is currently visible on screen. */
|
/** Region is currently visible on screen. */
|
||||||
short visible;
|
short visible;
|
||||||
|
Loading…
Reference in New Issue
Block a user