Cleanup: Remove unused variables for horizontal panels

Continuing the work of eb9055a572, remove remaining unecessary
variables and arguments that were related tabbing and horizontal
alignment of panels. For example, "vertical" was always true, and
removing that exposed other unused variables.
This commit is contained in:
Hans Goudey 2020-08-19 18:55:04 -04:00
parent 50b435cbaa
commit 940b239ad4
Notes: blender-bot 2023-02-14 00:06:52 +01:00
Referenced by commit f364d181e3, UI: Fix collapsed panels not drawing header buttons
Referenced by issue #101913, Regression: panels in the properties panel lose their place when scrolling one of the other property panels.
Referenced by issue #82769, Crash rendering particle animation with particle caches [disk cache works though]
Referenced by issue #79944, Tooltip that appears on adding meshes, moving, etc. is called "redo" when minimised.
Referenced by issue #79945, Gizmos don't work in Edit Mode
Referenced by issue #79951, Blender 2.91 Alpha crash related to GPU_shader_create_from_python
6 changed files with 20 additions and 73 deletions

View File

@ -81,18 +81,12 @@ void ED_region_tag_refresh_ui(struct ARegion *region);
void ED_region_tag_redraw_editor_overlays(struct ARegion *region);
void ED_region_panels_init(struct wmWindowManager *wm, struct ARegion *region);
void ED_region_panels_ex(const struct bContext *C,
struct ARegion *region,
const char *contexts[],
int contextnr,
const bool vertical);
void ED_region_panels_ex(const struct bContext *C, struct ARegion *region, const char *contexts[]);
void ED_region_panels(const struct bContext *C, struct ARegion *region);
void ED_region_panels_layout_ex(const struct bContext *C,
struct ARegion *region,
struct ListBase *paneltypes,
const char *contexts[],
int contextnr,
const bool vertical,
const char *category_override);
void ED_region_panels_layout(const struct bContext *C, struct ARegion *region);

View File

@ -2575,7 +2575,6 @@ static void ed_panel_draw(const bContext *C,
Panel *panel,
int w,
int em,
bool vertical,
char *unique_panel_str)
{
const uiStyle *style = UI_style_get_dpi();
@ -2597,7 +2596,7 @@ static void ed_panel_draw(const bContext *C,
int xco, yco, h = 0;
int headerend = w - UI_UNIT_X;
if (pt->draw_header_preset && !(pt->flag & PNL_NO_HEADER) && (open || vertical)) {
if (pt->draw_header_preset && !(pt->flag & PNL_NO_HEADER) && open) {
/* for preset menu */
panel->layout = UI_block_layout(block,
UI_LAYOUT_HORIZONTAL,
@ -2616,7 +2615,7 @@ static void ed_panel_draw(const bContext *C,
panel->layout = NULL;
}
if (pt->draw_header && !(pt->flag & PNL_NO_HEADER) && (open || vertical)) {
if (pt->draw_header && !(pt->flag & PNL_NO_HEADER) && open) {
int labelx, labely;
UI_panel_label_offset(block, &labelx, &labely);
@ -2693,8 +2692,7 @@ static void ed_panel_draw(const bContext *C,
Panel *child_panel = UI_panel_find_by_type(&panel->children, child_pt);
if (child_pt->draw && (!child_pt->poll || child_pt->poll(C, child_pt))) {
ed_panel_draw(
C, region, &panel->children, child_pt, child_panel, w, em, vertical, unique_panel_str);
ed_panel_draw(C, region, &panel->children, child_pt, child_panel, w, em, unique_panel_str);
}
}
}
@ -2711,8 +2709,6 @@ void ED_region_panels_layout_ex(const bContext *C,
ARegion *region,
ListBase *paneltypes,
const char *contexts[],
int contextnr,
const bool vertical,
const char *category_override)
{
/* collect panels to draw */
@ -2763,25 +2759,13 @@ void ED_region_panels_layout_ex(const bContext *C,
const int category_tabs_width = UI_PANEL_CATEGORY_MARGIN_WIDTH;
int margin_x = 0;
const bool region_layout_based = region->flag & RGN_FLAG_DYNAMIC_SIZE;
const bool is_context_new = (contextnr != -1) ? UI_view2d_tab_set(v2d, contextnr) : false;
bool update_tot_size = true;
/* before setting the view */
if (vertical) {
/* only allow scrolling in vertical direction */
v2d->keepofs |= V2D_LOCKOFS_X | V2D_KEEPOFS_Y;
v2d->keepofs &= ~(V2D_LOCKOFS_Y | V2D_KEEPOFS_X);
v2d->scroll &= ~V2D_SCROLL_BOTTOM;
v2d->scroll |= V2D_SCROLL_RIGHT;
}
else {
/* for now, allow scrolling in both directions (since layouts are optimized for vertical,
* they often don't fit in horizontal layout)
*/
v2d->keepofs &= ~(V2D_LOCKOFS_X | V2D_LOCKOFS_Y | V2D_KEEPOFS_X | V2D_KEEPOFS_Y);
v2d->scroll |= V2D_SCROLL_BOTTOM;
v2d->scroll &= ~V2D_SCROLL_RIGHT;
}
/* only allow scrolling in vertical direction */
v2d->keepofs |= V2D_LOCKOFS_X | V2D_KEEPOFS_Y;
v2d->keepofs &= ~(V2D_LOCKOFS_Y | V2D_KEEPOFS_X);
v2d->scroll &= ~V2D_SCROLL_BOTTOM;
v2d->scroll |= V2D_SCROLL_RIGHT;
/* collect categories */
if (use_category_tabs) {
@ -2806,14 +2790,8 @@ void ED_region_panels_layout_ex(const bContext *C,
}
}
if (vertical) {
w = BLI_rctf_size_x(&v2d->cur);
em = (region->type->prefsizex) ? 10 : 20; /* works out to 10*UI_UNIT_X or 20*UI_UNIT_X */
}
else {
w = UI_PANEL_WIDTH;
em = (region->type->prefsizex) ? 10 : 20;
}
w = BLI_rctf_size_x(&v2d->cur);
em = (region->type->prefsizex) ? 10 : 20; /* works out to 10*UI_UNIT_X or 20*UI_UNIT_X */
w -= margin_x;
int w_box_panel = w - UI_PANEL_BOX_STYLE_MARGIN * 2.0f;
@ -2852,7 +2830,6 @@ void ED_region_panels_layout_ex(const bContext *C,
panel,
(pt->flag & PNL_DRAW_BOX) ? w_box_panel : w,
em,
vertical,
NULL);
}
@ -2886,7 +2863,6 @@ void ED_region_panels_layout_ex(const bContext *C,
panel,
(panel->type->flag & PNL_DRAW_BOX) ? w_box_panel : w,
em,
vertical,
unique_panel_str);
}
}
@ -2914,7 +2890,7 @@ void ED_region_panels_layout_ex(const bContext *C,
y = fabsf(region->sizey * UI_DPI_FAC - 1);
}
}
else if (vertical) {
else {
/* We always keep the scroll offset -
* so the total view gets increased with the scrolled away part. */
if (v2d->cur.ymax < -FLT_EPSILON) {
@ -2929,19 +2905,6 @@ void ED_region_panels_layout_ex(const bContext *C,
y = -y;
}
else {
/* don't jump back when panels close or hide */
if (!is_context_new) {
if (v2d->tot.xmax > v2d->winx) {
x = max_ii(x, 0);
}
else {
x = max_ii(x, v2d->cur.xmax);
}
}
y = -y;
}
if (update_tot_size) {
/* this also changes the 'cur' */
@ -2955,8 +2918,7 @@ void ED_region_panels_layout_ex(const bContext *C,
void ED_region_panels_layout(const bContext *C, ARegion *region)
{
bool vertical = true;
ED_region_panels_layout_ex(C, region, &region->type->paneltypes, NULL, -1, vertical, NULL);
ED_region_panels_layout_ex(C, region, &region->type->paneltypes, NULL, NULL);
}
void ED_region_panels_draw(const bContext *C, ARegion *region)
@ -3000,12 +2962,10 @@ void ED_region_panels_draw(const bContext *C, ARegion *region)
UI_view2d_scrollers_draw(v2d, mask);
}
void ED_region_panels_ex(
const bContext *C, ARegion *region, const char *contexts[], int contextnr, const bool vertical)
void ED_region_panels_ex(const bContext *C, ARegion *region, const char *contexts[])
{
/* TODO: remove? */
ED_region_panels_layout_ex(
C, region, &region->type->paneltypes, contexts, contextnr, vertical, NULL);
ED_region_panels_layout_ex(C, region, &region->type->paneltypes, contexts, NULL);
ED_region_panels_draw(C, region);
}

View File

@ -292,9 +292,7 @@ static void buttons_main_region_layout_properties(const bContext *C,
break;
}
const bool vertical = true;
ED_region_panels_layout_ex(
C, region, &region->type->paneltypes, contexts, sbuts->mainb, vertical, NULL);
ED_region_panels_layout_ex(C, region, &region->type->paneltypes, contexts, NULL);
}
static void buttons_main_region_layout(const bContext *C, ARegion *region)

View File

@ -836,9 +836,7 @@ static void image_buttons_region_layout(const bContext *C, ARegion *region)
break;
}
const bool vertical = true;
ED_region_panels_layout_ex(
C, region, &region->type->paneltypes, contexts_base, -1, vertical, NULL);
ED_region_panels_layout_ex(C, region, &region->type->paneltypes, contexts_base, NULL);
}
static void image_buttons_region_draw(const bContext *C, ARegion *region)

View File

@ -141,8 +141,7 @@ static void userpref_main_region_layout(const bContext *C, ARegion *region)
BLI_str_tolower_ascii(id_lower, strlen(id_lower));
}
ED_region_panels_layout_ex(
C, region, &region->type->paneltypes, contexts, U.space_data.section_active, true, NULL);
ED_region_panels_layout_ex(C, region, &region->type->paneltypes, contexts, NULL);
}
static void userpref_operatortypes(void)

View File

@ -1323,9 +1323,7 @@ void ED_view3d_buttons_region_layout_ex(const bContext *C,
paneltypes = &art->paneltypes;
}
const bool vertical = true;
ED_region_panels_layout_ex(
C, region, paneltypes, contexts_base, -1, vertical, category_override);
ED_region_panels_layout_ex(C, region, paneltypes, contexts_base, category_override);
}
static void view3d_buttons_region_layout(const bContext *C, ARegion *region)
@ -1453,7 +1451,7 @@ static void view3d_tools_region_init(wmWindowManager *wm, ARegion *region)
static void view3d_tools_region_draw(const bContext *C, ARegion *region)
{
ED_region_panels_ex(C, region, (const char *[]){CTX_data_mode_string(C), NULL}, -1, true);
ED_region_panels_ex(C, region, (const char *[]){CTX_data_mode_string(C), NULL});
}
/* area (not region) level listener */