Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/interface/interface_panel.c
| Show First 20 Lines • Show All 1,378 Lines • ▼ Show 20 Lines | |||||
| /** | /** | ||||
| * Draw vertical tabs on the left side of the region, | * Draw vertical tabs on the left side of the region, | ||||
| * one tab per category. | * one tab per category. | ||||
| */ | */ | ||||
| void UI_panel_category_draw_all(ARegion *ar, const char *category_id_active) | void UI_panel_category_draw_all(ARegion *ar, const char *category_id_active) | ||||
| { | { | ||||
| /* no tab outlines for */ | /* no tab outlines for */ | ||||
| #define USE_FLAT_INACTIVE | // #define USE_FLAT_INACTIVE | ||||
| View2D *v2d = &ar->v2d; | View2D *v2d = &ar->v2d; | ||||
campbellbarton: This gives: `error: "UI_PANEL_CATEGORY_MARGIN_WIDTH" redefined` even without the error changing… | |||||
| uiStyle *style = UI_GetStyle(); | uiStyle *style = UI_GetStyle(); | ||||
| const uiFontStyle *fstyle = &style->widget; | const uiFontStyle *fstyle = &style->widget; | ||||
| const int fontid = fstyle->uifont_id; | const int fontid = fstyle->uifont_id; | ||||
| short fstyle_points = fstyle->points; | short fstyle_points = fstyle->points; | ||||
| PanelCategoryDyn *pc_dyn; | PanelCategoryDyn *pc_dyn; | ||||
| const float aspect = ((uiBlock *)ar->uiblocks.first)->aspect; | const float aspect = ((uiBlock *)ar->uiblocks.first)->aspect; | ||||
| const float zoom = 1.0f / aspect; | const float zoom = 1.0f / aspect; | ||||
Not Done Inline ActionsDon't really like to scale the zoom like this, its error prone since the aspect and the zoom become out of sync and we can't use the aspect in some places we might want to. The values (tab_v_pad_text, tab_curve_radius) etc should be adjusted instead. campbellbarton: Don't really like to scale the zoom like this, its error prone since the aspect and the zoom… | |||||
Not Done Inline ActionsThanks! Will play with that. carter2422: Thanks! Will play with that. | |||||
| const int px = max_ii(1.0, (int)U.pixelsize + 0.5f); | const int px = max_ii(1.0, (int)U.pixelsize + 0.5f); | ||||
| const int category_tabs_width = UI_PANEL_CATEGORY_MARGIN_WIDTH * zoom; | const int category_tabs_width = UI_PANEL_CATEGORY_MARGIN_WIDTH * zoom; | ||||
| const float dpi_fac = UI_DPI_FAC; | const float dpi_fac = UI_DPI_FAC; | ||||
| const int tab_v_pad_text = (2 + ((px * 3) * dpi_fac)) * zoom; /* pading of tabs around text */ | const int tab_v_pad_text = (2 + ((px * 3) * dpi_fac)) * zoom; /* pading of tabs around text */ | ||||
| const int tab_v_pad = (4 + (2 * px * dpi_fac)) * zoom; /* padding between tabs */ | const int tab_v_pad = (4 + (2 * px * dpi_fac)) * zoom; /* padding between tabs */ | ||||
| const float tab_curve_radius = ((px * 3) * dpi_fac) * zoom; | const float tab_curve_radius = ((px * 3) * dpi_fac) * zoom; | ||||
| const int roundboxtype = UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT; | const int roundboxtype = UI_CNR_TOP_LEFT | UI_CNR_BOTTOM_LEFT; | ||||
| bool do_scaletabs = false; | bool do_scaletabs = false; | ||||
| Show All 20 Lines | #endif | ||||
| unsigned char theme_col_tab_divider[4]; /* line that divides tabs from the main area */ | unsigned char theme_col_tab_divider[4]; /* line that divides tabs from the main area */ | ||||
| unsigned char theme_col_tab_highlight[4]; | unsigned char theme_col_tab_highlight[4]; | ||||
| unsigned char theme_col_tab_highlight_inactive[4]; | unsigned char theme_col_tab_highlight_inactive[4]; | ||||
| UI_GetThemeColor4ubv(TH_BACK, theme_col_back); | UI_GetThemeColor4ubv(TH_BACK, theme_col_back); | ||||
| UI_GetThemeColor4ubv(TH_TEXT, theme_col_text); | UI_GetThemeColor4ubv(TH_TEXT, theme_col_text); | ||||
| UI_GetThemeColor4ubv(TH_TEXT_HI, theme_col_text_hi); | UI_GetThemeColor4ubv(TH_TEXT_HI, theme_col_text_hi); | ||||
| UI_GetThemeColor4ubv(TH_BACK, theme_col_tab_bg); | |||||
| //blend_color_interpolate_byte(theme_col_tab_bg, theme_col_back, theme_col_text, 1.0F); | |||||
| blend_color_interpolate_byte(theme_col_tab_bg, theme_col_back, theme_col_text, 0.12f); | blend_color_interpolate_byte(theme_col_tab_inactive, theme_col_back, theme_col_text, 0.25f); | ||||
| blend_color_interpolate_byte(theme_col_tab_inactive, theme_col_back, theme_col_text, 0.1f); | |||||
| blend_color_interpolate_byte(theme_col_tab_outline, theme_col_back, theme_col_text, 0.3f); | blend_color_interpolate_byte(theme_col_tab_outline, theme_col_back, theme_col_text, 0.3f); | ||||
| blend_color_interpolate_byte(theme_col_tab_divider, theme_col_back, theme_col_text, 0.3f); | blend_color_interpolate_byte(theme_col_tab_divider, theme_col_back, theme_col_text, 0.3f); | ||||
| blend_color_interpolate_byte(theme_col_tab_highlight, theme_col_back, theme_col_text_hi, 0.2f); | blend_color_interpolate_byte(theme_col_tab_highlight, theme_col_back, theme_col_text_hi, 0.2f); | ||||
| blend_color_interpolate_byte(theme_col_tab_highlight_inactive, theme_col_tab_inactive, theme_col_text_hi, 0.12f); | blend_color_interpolate_byte(theme_col_tab_highlight_inactive, theme_col_tab_inactive, theme_col_text_hi, 0.12f); | ||||
| if (fstyle->kerning == 1) { | if (fstyle->kerning == 1) { | ||||
| BLF_enable(fstyle->uifont_id, BLF_KERNING_DEFAULT); | BLF_enable(fstyle->uifont_id, BLF_KERNING_DEFAULT); | ||||
| Show All 37 Lines | #endif | ||||
| } | } | ||||
| /* begin drawing */ | /* begin drawing */ | ||||
| glEnable(GL_LINE_SMOOTH); | glEnable(GL_LINE_SMOOTH); | ||||
| /* draw the background */ | /* draw the background */ | ||||
| glColor3ubv(theme_col_tab_bg); | glColor3ubv(theme_col_tab_bg); | ||||
| //glColor4f(1.0f, 1.0f, 1.0f, 1.0f); | |||||
| glRecti(v2d->mask.xmin, v2d->mask.ymin, v2d->mask.xmin + category_tabs_width, v2d->mask.ymax); | glRecti(v2d->mask.xmin, v2d->mask.ymin, v2d->mask.xmin + category_tabs_width, v2d->mask.ymax); | ||||
| for (pc_dyn = ar->panels_category.first; pc_dyn; pc_dyn = pc_dyn->next) { | for (pc_dyn = ar->panels_category.first; pc_dyn; pc_dyn = pc_dyn->next) { | ||||
| const rcti *rct = &pc_dyn->rect; | const rcti *rct = &pc_dyn->rect; | ||||
| 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); | ||||
| int category_width = BLI_rcti_size_y(rct) - (tab_v_pad_text * 2); | 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; | ||||
| Show All 38 Lines | #endif | ||||
| if (do_scaletabs) { | if (do_scaletabs) { | ||||
| category_draw_len = BLF_width_to_strlen(fontid, category_id_draw, category_draw_len, | category_draw_len = BLF_width_to_strlen(fontid, category_id_draw, category_draw_len, | ||||
| category_width, NULL); | category_width, NULL); | ||||
| } | } | ||||
| 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); | ||||
| /* tab titles */ | |||||
| { | |||||
| glColor3ubv(theme_col_text); | glColor3ubv(theme_col_text); | ||||
| /* draw white shadow to give text more depth */ | |||||
| BLF_enable(fontid, BLF_SHADOW); | |||||
| BLF_shadow(fontid, 3, 1.0f, 1.0f, 1.0f, 0.25f); | |||||
| BLF_shadow_offset(fontid, -1, -1); | |||||
| } | |||||
| BLF_draw(fontid, category_id_draw, category_draw_len); | BLF_draw(fontid, category_id_draw, category_draw_len); | ||||
| glDisable(GL_BLEND); | glDisable(GL_BLEND); | ||||
| /* tab blackline remaining (last tab) */ | /* tab blackline remaining (last tab) */ | ||||
| if (pc_dyn->prev == NULL) { | if (pc_dyn->prev == NULL) { | ||||
| glColor3ubv(theme_col_tab_divider); | glColor3ubv(theme_col_tab_divider); | ||||
| glRecti(v2d->mask.xmin + category_tabs_width - px, | glRecti(v2d->mask.xmin + category_tabs_width - px, | ||||
| rct->ymax + px, | rct->ymax + px, | ||||
| v2d->mask.xmin + category_tabs_width, | v2d->mask.xmin + category_tabs_width, | ||||
| ▲ Show 20 Lines • Show All 309 Lines • Show Last 20 Lines | |||||
This gives: error: "UI_PANEL_CATEGORY_MARGIN_WIDTH" redefined even without the error changing here will cause overlap, need to change the one in UI_interface.h:180