Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/interface/interface_panel.c
| Show First 20 Lines • Show All 1,420 Lines • ▼ Show 20 Lines | #endif | ||||
| /* Tab colors */ | /* Tab colors */ | ||||
| unsigned char theme_col_tab_bg[4]; | unsigned char theme_col_tab_bg[4]; | ||||
| unsigned char theme_col_tab_active[4]; | unsigned char theme_col_tab_active[4]; | ||||
| unsigned char theme_col_tab_inactive[4]; | unsigned char theme_col_tab_inactive[4]; | ||||
| /* Secondary theme colors */ | /* Secondary theme colors */ | ||||
| unsigned char theme_col_tab_outline[4]; | unsigned char theme_col_tab_outline[4]; | ||||
| 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_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_TAB_BACK, theme_col_tab_bg); | UI_GetThemeColor4ubv(TH_TAB_BACK, theme_col_tab_bg); | ||||
| UI_GetThemeColor4ubv(TH_TAB_ACTIVE, theme_col_tab_active); | UI_GetThemeColor4ubv(TH_TAB_ACTIVE, theme_col_tab_active); | ||||
| UI_GetThemeColor4ubv(TH_TAB_INACTIVE, theme_col_tab_inactive); | UI_GetThemeColor4ubv(TH_TAB_INACTIVE, theme_col_tab_inactive); | ||||
| UI_GetThemeColor4ubv(TH_TAB_OUTLINE, theme_col_tab_outline); | UI_GetThemeColor4ubv(TH_TAB_OUTLINE, theme_col_tab_outline); | ||||
| blend_color_interpolate_byte(theme_col_tab_divider, theme_col_back, theme_col_tab_outline, 0.3f); | blend_color_interpolate_byte(theme_col_tab_divider, theme_col_back, theme_col_tab_outline, 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_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); | ||||
| } | } | ||||
| BLF_enable(fontid, BLF_ROTATION); | BLF_enable(fontid, BLF_ROTATION); | ||||
| BLF_rotation(fontid, M_PI / 2); | BLF_rotation(fontid, M_PI / 2); | ||||
| //uiStyleFontSet(&style->widget); | //uiStyleFontSet(&style->widget); | ||||
| Show All 34 Lines | if (y_ofs > BLI_rcti_size_y(&v2d->mask)) { | ||||
| do_scaletabs = true; | do_scaletabs = true; | ||||
| } | } | ||||
| /* begin drawing */ | /* begin drawing */ | ||||
| glEnable(GL_LINE_SMOOTH); | glEnable(GL_LINE_SMOOTH); | ||||
| /* draw the background */ | /* draw the background */ | ||||
| glColor3ubv(theme_col_tab_bg); | if (ar->overlap && (theme_col_tab_bg[3] != 255)) { | ||||
campbellbarton: suggest to have an `is_alpha` bool var, before using `glEnable(GL_BLEND);`, this can be enabled… | |||||
Not Done Inline ActionsGood call, will see what I can do. carter2422: Good call, will see what I can do. | |||||
| glEnable(GL_BLEND); | |||||
| glColor4ubv(theme_col_tab_bg); | |||||
| glRecti(v2d->mask.xmin, v2d->mask.ymin, v2d->mask.xmin + category_tabs_width, v2d->mask.ymax); | |||||
| glDisable(GL_BLEND); | |||||
| } | |||||
| else { | |||||
| glColor4ubv(theme_col_tab_bg); | |||||
| 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; | ||||
| // int category_width = BLF_width(fontid, category_id_draw, BLF_DRAW_STR_DUMMY_MAX); | // int category_width = BLF_width(fontid, category_id_draw, BLF_DRAW_STR_DUMMY_MAX); | ||||
| const bool is_active = STREQ(category_id, category_id_active); | const bool is_active = STREQ(category_id, category_id_active); | ||||
| glEnable(GL_BLEND); | glEnable(GL_BLEND); | ||||
| #ifdef USE_FLAT_INACTIVE | #ifdef USE_FLAT_INACTIVE | ||||
| if (is_active) | if (is_active) | ||||
| #endif | #endif | ||||
| { | { | ||||
| glColor3ubv(is_active ? theme_col_tab_active : theme_col_tab_inactive); | glColor4ubv(is_active ? theme_col_tab_active : theme_col_tab_inactive); | ||||
| ui_panel_category_draw_tab(GL_POLYGON, rct->xmin, rct->ymin, rct->xmax, rct->ymax, | ui_panel_category_draw_tab(GL_POLYGON, rct->xmin, rct->ymin, rct->xmax, rct->ymax, | ||||
| tab_curve_radius - px, roundboxtype, true, true, NULL); | tab_curve_radius - px, roundboxtype, true, true, NULL); | ||||
| /* tab outline */ | /* tab outlines */ | ||||
| glColor3ubv(theme_col_tab_outline); | /* secondary active outline in the case of transparent tabs */ | ||||
| if (is_active) { | |||||
| glColor3ubv(theme_col_tab_divider); | |||||
| glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); | |||||
| ui_panel_category_draw_tab(GL_LINE_STRIP, rct->xmin - px, rct->ymin - px, rct->xmax - px, rct->ymax + px, | |||||
| tab_curve_radius, roundboxtype, true, true, NULL); | |||||
| } | |||||
| /* main outline */ | |||||
| glColor4ubv(theme_col_tab_outline); | |||||
| glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); | glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); | ||||
| ui_panel_category_draw_tab(GL_LINE_STRIP, rct->xmin - px, rct->ymin - px, rct->xmax - px, rct->ymax + px, | ui_panel_category_draw_tab(GL_LINE_STRIP, rct->xmin - px, rct->ymin - px, rct->xmax - px, rct->ymax + px, | ||||
| tab_curve_radius, roundboxtype, true, true, NULL); | tab_curve_radius, roundboxtype, true, true, NULL); | ||||
| /* tab highlight (3d look) */ | |||||
| glShadeModel(GL_SMOOTH); | |||||
| glColor3ubv(is_active ? theme_col_tab_highlight : theme_col_tab_highlight_inactive); | |||||
| ui_panel_category_draw_tab(GL_LINE_STRIP, rct->xmin, rct->ymin, rct->xmax, rct->ymax, | |||||
| tab_curve_radius, roundboxtype, true, false, | |||||
| is_active ? theme_col_back : theme_col_tab_inactive); | |||||
| glShadeModel(GL_FLAT); | |||||
| glShadeModel(GL_FLAT); | |||||
Not Done Inline Actionsis this intended to be part of the patch? campbellbarton: is this intended to be part of the patch? | |||||
Not Done Inline ActionsYes, the highlight does not play nice with the alpha (gets very bright) and stands out weird. It also gives the tabs a more messy look, even though it adds more depth. I commented it out for now to give the tabs a cleaner look, that also works better with the transparency. Eventually what I would like to do, though, is work on the overall widget styles to support both Embossed and Flat styles. Billrey's mockups show the flat very nicely. Thoughts? carter2422: Yes, the highlight does not play nice with the alpha (gets very bright) and stands out weird. | |||||
| glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); | glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); | ||||
| } | } | ||||
| /* tab blackline */ | /* tab blackline */ | ||||
| if (!is_active) { | if (!is_active) { | ||||
| 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->ymin - tab_v_pad, | rct->ymin - tab_v_pad, | ||||
| ▲ Show 20 Lines • Show All 341 Lines • Show Last 20 Lines | |||||
suggest to have an is_alpha bool var, before using glEnable(GL_BLEND);, this can be enabled only when the region is using alpha/overlap.
If alpha support becomes more involved, it means the code which handles alpha overlap is isolated and not running when its not needed. (fine to keep glColor4's though, not much point to check alpha there)