Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/screen/area.c
| Show First 20 Lines • Show All 2,604 Lines • ▼ Show 20 Lines | |||||
| static void ed_panel_draw(const bContext *C, | static void ed_panel_draw(const bContext *C, | ||||
| ARegion *region, | ARegion *region, | ||||
| ListBase *lb, | ListBase *lb, | ||||
| PanelType *pt, | PanelType *pt, | ||||
| Panel *panel, | Panel *panel, | ||||
| int w, | int w, | ||||
| int em, | int em, | ||||
| char *unique_panel_str, | char *unique_panel_str, | ||||
| const char *search_filter, | const char *search_filter) | ||||
| bool search_only) | |||||
| { | { | ||||
| const uiStyle *style = UI_style_get_dpi(); | const uiStyle *style = UI_style_get_dpi(); | ||||
| /* Draw panel. */ | /* Draw panel. */ | ||||
| char block_name[BKE_ST_MAXNAME + INSTANCED_PANEL_UNIQUE_STR_LEN]; | char block_name[BKE_ST_MAXNAME + INSTANCED_PANEL_UNIQUE_STR_LEN]; | ||||
| strncpy(block_name, pt->idname, BKE_ST_MAXNAME); | strncpy(block_name, pt->idname, BKE_ST_MAXNAME); | ||||
| if (unique_panel_str != NULL) { | if (unique_panel_str != NULL) { | ||||
| /* Instanced panels should have already been added at this point. */ | /* Instanced panels should have already been added at this point. */ | ||||
| strncat(block_name, unique_panel_str, INSTANCED_PANEL_UNIQUE_STR_LEN); | strncat(block_name, unique_panel_str, INSTANCED_PANEL_UNIQUE_STR_LEN); | ||||
| } | } | ||||
| uiBlock *block = UI_block_begin(C, region, block_name, UI_EMBOSS); | uiBlock *block = UI_block_begin(C, region, block_name, UI_EMBOSS); | ||||
| UI_block_set_search_only(block, search_only); | |||||
| bool open; | bool open; | ||||
| panel = UI_panel_begin(region, lb, block, pt, panel, &open); | panel = UI_panel_begin(region, lb, block, pt, panel, &open); | ||||
| const bool search_filter_active = search_filter != NULL && search_filter[0] != '\0'; | const bool search_filter_active = search_filter != NULL && search_filter[0] != '\0'; | ||||
| /* bad fixed values */ | /* bad fixed values */ | ||||
| int xco, yco, h = 0; | int xco, yco, h = 0; | ||||
| int headerend = w - UI_UNIT_X; | int headerend = w - UI_UNIT_X; | ||||
| UI_panel_header_buttons_begin(panel); | |||||
| if (pt->draw_header_preset && !(pt->flag & PNL_NO_HEADER)) { | if (pt->draw_header_preset && !(pt->flag & PNL_NO_HEADER)) { | ||||
| /* for preset menu */ | /* for preset menu */ | ||||
| panel->layout = UI_block_layout(block, | panel->layout = UI_block_layout(block, | ||||
| UI_LAYOUT_HORIZONTAL, | UI_LAYOUT_HORIZONTAL, | ||||
| UI_LAYOUT_HEADER, | UI_LAYOUT_HEADER, | ||||
| 0, | 0, | ||||
| (UI_UNIT_Y * 1.1f) + style->panelspace, | (UI_UNIT_Y * 1.1f) + style->panelspace, | ||||
| UI_UNIT_Y, | UI_UNIT_Y, | ||||
| 1, | 1, | ||||
| 0, | 0, | ||||
| style); | style); | ||||
| uiLayoutRootSetSearchOnly(panel->layout, search_only); | |||||
| pt->draw_header_preset(C, panel); | pt->draw_header_preset(C, panel); | ||||
| UI_block_apply_search_filter(block, search_filter); | UI_block_apply_search_filter(block, search_filter); | ||||
| UI_block_layout_resolve(block, &xco, &yco); | UI_block_layout_resolve(block, &xco, &yco); | ||||
| UI_block_translate(block, headerend - xco, 0); | UI_block_translate(block, headerend - xco, 0); | ||||
| panel->layout = NULL; | panel->layout = NULL; | ||||
| } | } | ||||
| Show All 15 Lines | if (pt->flag & PNL_LAYOUT_HEADER_EXPAND) { | ||||
| style); | style); | ||||
| panel->layout = uiLayoutRow(layout, false); | panel->layout = uiLayoutRow(layout, false); | ||||
| } | } | ||||
| /* Regular case: Normal panel with fixed size buttons. */ | /* Regular case: Normal panel with fixed size buttons. */ | ||||
| else { | else { | ||||
| panel->layout = UI_block_layout( | panel->layout = UI_block_layout( | ||||
| block, UI_LAYOUT_HORIZONTAL, UI_LAYOUT_HEADER, labelx, labely, UI_UNIT_Y, 1, 0, style); | block, UI_LAYOUT_HORIZONTAL, UI_LAYOUT_HEADER, labelx, labely, UI_UNIT_Y, 1, 0, style); | ||||
| } | } | ||||
| uiLayoutRootSetSearchOnly(panel->layout, search_only); | |||||
| pt->draw_header(C, panel); | pt->draw_header(C, panel); | ||||
| UI_block_apply_search_filter(block, search_filter); | UI_block_apply_search_filter(block, search_filter); | ||||
| UI_block_layout_resolve(block, &xco, &yco); | UI_block_layout_resolve(block, &xco, &yco); | ||||
| panel->labelofs = xco - labelx; | panel->labelofs = xco - labelx; | ||||
| panel->layout = NULL; | panel->layout = NULL; | ||||
| } | } | ||||
| else { | else { | ||||
| panel->labelofs = 0; | panel->labelofs = 0; | ||||
| } | } | ||||
| UI_panel_header_buttons_end(panel); | |||||
| if (open || search_filter_active) { | if (open || search_filter_active) { | ||||
| short panelContext; | short panelContext; | ||||
| /* panel context can either be toolbar region or normal panels region */ | /* panel context can either be toolbar region or normal panels region */ | ||||
| if (pt->flag & PNL_LAYOUT_VERT_BAR) { | if (pt->flag & PNL_LAYOUT_VERT_BAR) { | ||||
| panelContext = UI_LAYOUT_VERT_BAR; | panelContext = UI_LAYOUT_VERT_BAR; | ||||
| } | } | ||||
| Show All 9 Lines | panel->layout = UI_block_layout(block, | ||||
| panelContext, | panelContext, | ||||
| (pt->flag & PNL_LAYOUT_VERT_BAR) ? 0 : style->panelspace, | (pt->flag & PNL_LAYOUT_VERT_BAR) ? 0 : style->panelspace, | ||||
| 0, | 0, | ||||
| (pt->flag & PNL_LAYOUT_VERT_BAR) ? 0 : | (pt->flag & PNL_LAYOUT_VERT_BAR) ? 0 : | ||||
| w - 2 * style->panelspace, | w - 2 * style->panelspace, | ||||
| em, | em, | ||||
| 0, | 0, | ||||
| style); | style); | ||||
| uiLayoutRootSetSearchOnly(panel->layout, search_only || !open); | |||||
| pt->draw(C, panel); | pt->draw(C, panel); | ||||
| UI_block_apply_search_filter(block, search_filter); | UI_block_apply_search_filter(block, search_filter); | ||||
| UI_block_layout_resolve(block, &xco, &yco); | UI_block_layout_resolve(block, &xco, &yco); | ||||
| panel->layout = NULL; | panel->layout = NULL; | ||||
| if (yco != 0) { | if (yco != 0) { | ||||
| Show All 13 Lines | LISTBASE_FOREACH (LinkData *, link, &pt->children) { | ||||
| ed_panel_draw(C, | ed_panel_draw(C, | ||||
| region, | region, | ||||
| &panel->children, | &panel->children, | ||||
| child_pt, | child_pt, | ||||
| child_panel, | child_panel, | ||||
| w, | w, | ||||
| em, | em, | ||||
| unique_panel_str, | unique_panel_str, | ||||
| search_filter, | search_filter); | ||||
| !open); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| UI_panel_end(region, block, w, h, open); | UI_panel_end(panel, w, h); | ||||
| } | } | ||||
| /** | /** | ||||
| * Check whether a panel should be added to the region's panel layout. | * Check whether a panel should be added to the region's panel layout. | ||||
| */ | */ | ||||
| static bool panel_add_check(const bContext *C, | static bool panel_add_check(const bContext *C, | ||||
| const WorkSpace *workspace, | const WorkSpace *workspace, | ||||
| const char *contexts[], | const char *contexts[], | ||||
| ▲ Show 20 Lines • Show All 153 Lines • ▼ Show 20 Lines | for (LinkNode *pt_link = panel_types_stack; pt_link; pt_link = pt_link->next) { | ||||
| ed_panel_draw(C, | ed_panel_draw(C, | ||||
| region, | region, | ||||
| ®ion->panels, | ®ion->panels, | ||||
| pt, | pt, | ||||
| panel, | panel, | ||||
| (pt->flag & PNL_DRAW_BOX) ? w_box_panel : w, | (pt->flag & PNL_DRAW_BOX) ? w_box_panel : w, | ||||
| em, | em, | ||||
| NULL, | NULL, | ||||
| search_filter, | search_filter); | ||||
| false); | |||||
| } | } | ||||
| /* Draw "polyinstantaited" panels that don't have a 1 to 1 correspondence with their types. */ | /* Draw "polyinstantaited" panels that don't have a 1 to 1 correspondence with their types. */ | ||||
| if (has_instanced_panel) { | if (has_instanced_panel) { | ||||
| LISTBASE_FOREACH (Panel *, panel, ®ion->panels) { | LISTBASE_FOREACH (Panel *, panel, ®ion->panels) { | ||||
| if (panel->type == NULL) { | if (panel->type == NULL) { | ||||
| continue; /* Some panels don't have a type. */ | continue; /* Some panels don't have a type. */ | ||||
| } | } | ||||
| Show All 17 Lines | LISTBASE_FOREACH (Panel *, panel, ®ion->panels) { | ||||
| ed_panel_draw(C, | ed_panel_draw(C, | ||||
| region, | region, | ||||
| ®ion->panels, | ®ion->panels, | ||||
| panel->type, | panel->type, | ||||
| panel, | panel, | ||||
| (panel->type->flag & PNL_DRAW_BOX) ? w_box_panel : w, | (panel->type->flag & PNL_DRAW_BOX) ? w_box_panel : w, | ||||
| em, | em, | ||||
| unique_panel_str, | unique_panel_str, | ||||
| search_filter, | search_filter); | ||||
| false); | |||||
| } | } | ||||
| } | } | ||||
| /* align panels and return size */ | /* align panels and return size */ | ||||
| UI_panels_end(C, region, &x, &y); | UI_panels_end(C, region, &x, &y); | ||||
| /* before setting the view */ | /* before setting the view */ | ||||
| if (region_layout_based) { | if (region_layout_based) { | ||||
| ▲ Show 20 Lines • Show All 982 Lines • Show Last 20 Lines | |||||