Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/interface/interface_panel.c
| Show First 20 Lines • Show All 615 Lines • ▼ Show 20 Lines | static void ui_draw_panel_dragwidget(uint pos, uint col, const rctf *rect) | ||||
| } | } | ||||
| immEnd(); | immEnd(); | ||||
| } | } | ||||
| /* For button layout next to label. */ | /* For button layout next to label. */ | ||||
| void UI_panel_label_offset(uiBlock *block, int *x, int *y) | void UI_panel_label_offset(uiBlock *block, int *x, int *y) | ||||
| { | { | ||||
| Panel *panel = block->panel; | Panel *panel = block->panel; | ||||
| uiStyle *style = UI_style_get_dpi(); | |||||
| const bool is_subpanel = (panel->type && panel->type->parent); | const bool is_subpanel = (panel->type && panel->type->parent); | ||||
| *x = UI_UNIT_X * 1.1f; | *x = UI_UNIT_X * 1.0f; | ||||
| *y = (UI_UNIT_Y * 1.1f) + style->panelspace; | *y = UI_UNIT_Y * 1.5f; | ||||
| if (is_subpanel) { | if (is_subpanel) { | ||||
| *x += 5.0f / block->aspect; | *x += 5.0f / block->aspect; | ||||
| } | } | ||||
| } | } | ||||
| static void ui_draw_aligned_panel_header( | static void ui_draw_aligned_panel_header( | ||||
| uiStyle *style, uiBlock *block, const rcti *rect, char dir, | uiStyle *style, uiBlock *block, const rcti *rect, char dir, | ||||
| const bool show_background) | const bool show_background) | ||||
| { | { | ||||
| Panel *panel = block->panel; | Panel *panel = block->panel; | ||||
| rcti hrect; | rcti hrect; | ||||
| int pnl_icons; | int pnl_icons; | ||||
| const char *activename = panel->drawname[0] ? panel->drawname : panel->panelname; | const char *activename = panel->drawname[0] ? panel->drawname : panel->panelname; | ||||
| const bool is_subpanel = (panel->type && panel->type->parent); | const bool is_subpanel = (panel->type && panel->type->parent); | ||||
| uiFontStyle *fontstyle = (is_subpanel) ? &style->widgetlabel : &style->paneltitle; | uiFontStyle *fontstyle = (is_subpanel) ? &style->widgetlabel : &style->paneltitle; | ||||
| uchar col_title[4]; | uchar col_title[4]; | ||||
| /* + 0.001f to avoid flirting with float inaccuracy */ | /* + 0.001f to avoid flirting with float inaccuracy */ | ||||
| if (panel->control & UI_PNL_CLOSE) | if (panel->control & UI_PNL_CLOSE) | ||||
| pnl_icons = (panel->labelofs + 2 * PNL_ICON + 5) / block->aspect + 0.001f; | pnl_icons = (panel->labelofs + (2.0f * PNL_ICON)) / block->aspect + 0.001f; | ||||
| else | else | ||||
| pnl_icons = (panel->labelofs + PNL_ICON + 5) / block->aspect + 0.001f; | pnl_icons = (panel->labelofs + (1.1f * PNL_ICON)) / block->aspect + 0.001f; | ||||
| /* draw text label */ | /* draw text label */ | ||||
| panel_title_color_get(show_background, col_title); | panel_title_color_get(show_background, col_title); | ||||
| col_title[3] = 255; | col_title[3] = 255; | ||||
| hrect = *rect; | hrect = *rect; | ||||
| if (dir == 'h') { | if (dir == 'h') { | ||||
| hrect.xmin = rect->xmin + pnl_icons; | hrect.xmin = rect->xmin + pnl_icons; | ||||
| hrect.ymin += 2.0f / block->aspect; | hrect.ymin -= 2.0f / block->aspect; | ||||
| UI_fontstyle_draw( | UI_fontstyle_draw( | ||||
| fontstyle, &hrect, activename, col_title, | fontstyle, &hrect, activename, col_title, | ||||
| &(struct uiFontStyleDraw_Params) { .align = UI_STYLE_TEXT_LEFT, }); | &(struct uiFontStyleDraw_Params) { .align = UI_STYLE_TEXT_LEFT, }); | ||||
| } | } | ||||
| else { | else { | ||||
| /* ignore 'pnl_icons', otherwise the text gets offset horizontally | /* ignore 'pnl_icons', otherwise the text gets offset horizontally | ||||
| * + 0.001f to avoid flirting with float inaccuracy | * + 0.001f to avoid flirting with float inaccuracy | ||||
| */ | */ | ||||
| ▲ Show 20 Lines • Show All 89 Lines • ▼ Show 20 Lines | if (is_closed_x == false) { | ||||
| if (show_drag) { | if (show_drag) { | ||||
| uint col; | uint col; | ||||
| GPUVertFormat *format = immVertexFormat(); | GPUVertFormat *format = immVertexFormat(); | ||||
| pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | ||||
| col = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); | col = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); | ||||
| /* itemrect smaller */ | /* itemrect smaller */ | ||||
| itemrect.xmax = headrect.xmax - 5.0f / block->aspect; | itemrect.xmax = headrect.xmax - (0.2f * UI_UNIT_X); | ||||
| itemrect.xmin = itemrect.xmax - BLI_rcti_size_y(&headrect); | itemrect.xmin = itemrect.xmax - BLI_rcti_size_y(&headrect); | ||||
| itemrect.ymin = headrect.ymin; | itemrect.ymin = headrect.ymin; | ||||
| itemrect.ymax = headrect.ymax; | itemrect.ymax = headrect.ymax; | ||||
| BLI_rctf_scale(&itemrect, 0.7f); | BLI_rctf_scale(&itemrect, 0.7f); | ||||
| immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR); | immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR); | ||||
| ui_draw_panel_dragwidget(pos, col, &itemrect); | ui_draw_panel_dragwidget(pos, col, &itemrect); | ||||
| immUnbindProgram(); | immUnbindProgram(); | ||||
| ▲ Show 20 Lines • Show All 55 Lines • ▼ Show 20 Lines | if (panel->control & UI_PNL_CLOSE) { | ||||
| immUniformColor3ubv(col_title); | immUniformColor3ubv(col_title); | ||||
| ui_draw_x_icon(pos, rect->xmin + 2 + ofsx, rect->ymax + 2); | ui_draw_x_icon(pos, rect->xmin + 2 + ofsx, rect->ymax + 2); | ||||
| immUnbindProgram(); | immUnbindProgram(); | ||||
| } | } | ||||
| /* draw collapse icon */ | /* draw collapse icon */ | ||||
| /* itemrect smaller */ | /* itemrect smaller */ | ||||
| itemrect.xmin = titlerect.xmin + 3.0f / block->aspect; | itemrect.xmin = titlerect.xmin; | ||||
| itemrect.xmax = itemrect.xmin + BLI_rcti_size_y(&titlerect); | itemrect.xmax = itemrect.xmin + BLI_rcti_size_y(&titlerect); | ||||
| itemrect.ymin = titlerect.ymin; | itemrect.ymin = titlerect.ymin; | ||||
| itemrect.ymax = titlerect.ymax; | itemrect.ymax = titlerect.ymax; | ||||
| BLI_rctf_scale(&itemrect, 0.25f); | BLI_rctf_scale(&itemrect, 0.25f); | ||||
| { | { | ||||
| float tria_color[4]; | float tria_color[4]; | ||||
| ▲ Show 20 Lines • Show All 1,607 Lines • Show Last 20 Lines | |||||