Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/interface/interface_panel.c
| Show First 20 Lines • Show All 1,488 Lines • ▼ Show 20 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); | glEnable(GL_BLEND); | ||||
campbellbarton: suggest to have an `is_alpha` bool var, before using `glEnable(GL_BLEND);`, this can be enabled… | |||||
carter2422Unsubmitted Not Done Inline ActionsGood call, will see what I can do. carter2422: Good call, will see what I can do. | |||||
| 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); | ||||
| glDisable(GL_BLEND); | |||||
| 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 outline */ | ||||
| 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); | 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); | glColor4ubv(theme_col_tab_outline); | ||||
| ui_panel_category_draw_tab(GL_LINE_STRIP, rct->xmin, rct->ymin, rct->xmax, rct->ymax, | glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); | ||||
| tab_curve_radius, roundboxtype, true, false, | ui_panel_category_draw_tab(GL_LINE_STRIP, rct->xmin - px, rct->ymin - px, rct->xmax - px, rct->ymax + px, | ||||
| is_active ? theme_col_back : theme_col_tab_inactive); | tab_curve_radius, roundboxtype, true, true, NULL); | ||||
| glShadeModel(GL_FLAT); | |||||
| /* tab highlight (3d look), commenting out for now for a cleaner look */ | |||||
campbellbartonAuthorUnsubmitted Not Done Inline Actionsis this intended to be part of the patch? campbellbarton: is this intended to be part of the patch? | |||||
carter2422Unsubmitted 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. | |||||
| // 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); | |||||
| 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, | ||||
| v2d->mask.xmin + category_tabs_width, | v2d->mask.xmin + category_tabs_width, | ||||
| rct->ymax + tab_v_pad); | rct->ymax + tab_v_pad); | ||||
| } | } | ||||
| 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 */ | /* tab titles */ | ||||
| glColor3ubv(is_active ? theme_col_text_hi : theme_col_text); | |||||
| /* draw white shadow to give text more depth */ | |||||
| glColor3ubv(theme_col_text); | |||||
| /* main tab title */ | |||||
| 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, | ||||
| ▲ Show 20 Lines • Show All 316 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)