Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/interface/interface_panel.c
| Context not available. | |||||
| #include "UI_interface_icons.h" | #include "UI_interface_icons.h" | ||||
| #include "UI_resources.h" | #include "UI_resources.h" | ||||
| #include "GPU_immediate.h" | |||||
| #include "interface_intern.h" | #include "interface_intern.h" | ||||
| /*********************** defines and structs ************************/ | /*********************** defines and structs ************************/ | ||||
| Context not available. | |||||
| int mode, float minx, float miny, float maxx, float maxy, float rad, | int mode, float minx, float miny, float maxx, float maxy, float rad, | ||||
| int roundboxtype, | int roundboxtype, | ||||
| const bool use_highlight, const bool use_shadow, | const bool use_highlight, const bool use_shadow, | ||||
| const unsigned char highlight_fade[3]) | const unsigned char highlight_fade[3], | ||||
| const unsigned char color[3]) | |||||
| { | { | ||||
| float vec[4][2] = { | float vec[4][2] = { | ||||
| {0.195, 0.02}, | {0.195, 0.02}, | ||||
| Context not available. | |||||
| {0.98, 0.805}}; | {0.98, 0.805}}; | ||||
| int a; | int a; | ||||
| VertexFormat *format = immVertexFormat(); | |||||
| unsigned pos = add_attrib(format, "pos", GL_FLOAT, 2, KEEP_FLOAT); | |||||
| /* mult */ | /* mult */ | ||||
| for (a = 0; a < 4; a++) { | for (a = 0; a < 4; a++) { | ||||
| mul_v2_fl(vec[a], rad); | mul_v2_fl(vec[a], rad); | ||||
| } | } | ||||
| glBegin(mode); | if (mode == GL_POLYGON) { | ||||
| mode = GL_TRIANGLE_FAN; | |||||
| } | |||||
Severin: Just wondering, is this just for forcing non-`GL_POLYGON` drawing? Couldn't we simply add a… | |||||
merwinUnsubmitted Not Done Inline ActionsLeave this exactly as it is -- using TRIANGLE_FAN for POLYGON. No need to add assert because I have plans for this... merwin: Leave this exactly as it is -- using TRIANGLE_FAN for POLYGON. No need to add assert because I… | |||||
| immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); | |||||
| immUniformColor3ubv(color); | |||||
| immBeginAtMost(mode, 24); | |||||
| /* start with corner right-top */ | /* start with corner right-top */ | ||||
| if (use_highlight) { | if (use_highlight) { | ||||
| if (roundboxtype & UI_CNR_TOP_RIGHT) { | if (roundboxtype & UI_CNR_TOP_RIGHT) { | ||||
| glVertex2f(maxx, maxy - rad); | immVertex2f(pos, maxx, maxy - rad); | ||||
| for (a = 0; a < 4; a++) { | for (a = 0; a < 4; a++) { | ||||
| glVertex2f(maxx - vec[a][1], maxy - rad + vec[a][0]); | immVertex2f(pos, maxx - vec[a][1], maxy - rad + vec[a][0]); | ||||
| } | } | ||||
| glVertex2f(maxx - rad, maxy); | immVertex2f(pos, maxx - rad, maxy); | ||||
| } | } | ||||
| else { | else { | ||||
| glVertex2f(maxx, maxy); | immVertex2f(pos, maxx, maxy); | ||||
| } | } | ||||
| /* corner left-top */ | /* corner left-top */ | ||||
| if (roundboxtype & UI_CNR_TOP_LEFT) { | if (roundboxtype & UI_CNR_TOP_LEFT) { | ||||
| glVertex2f(minx + rad, maxy); | immVertex2f(pos, minx + rad, maxy); | ||||
| for (a = 0; a < 4; a++) { | for (a = 0; a < 4; a++) { | ||||
| glVertex2f(minx + rad - vec[a][0], maxy - vec[a][1]); | immVertex2f(pos, minx + rad - vec[a][0], maxy - vec[a][1]); | ||||
| } | } | ||||
| glVertex2f(minx, maxy - rad); | immVertex2f(pos, minx, maxy - rad); | ||||
| } | } | ||||
| else { | else { | ||||
| glVertex2f(minx, maxy); | immVertex2f(pos, minx, maxy); | ||||
| } | } | ||||
| } | } | ||||
| if (use_highlight && !use_shadow) { | if (use_highlight && !use_shadow) { | ||||
| if (highlight_fade) { | if (highlight_fade) { | ||||
| glColor3ubv(highlight_fade); | immUniformColor3ubv(highlight_fade); | ||||
SeverinUnsubmitted Not Done Inline ActionsIf color can change, using uniforms seems wrong? Severin: If color can change, using uniforms seems wrong? | |||||
merwinUnsubmitted Not Done Inline ActionsNice catch! We have to immEnd, then ... do something else to get the smooth highlight. merwin: Nice catch! We have to immEnd, then ... do something else to get the smooth highlight. | |||||
kgeogeoAuthorUnsubmitted Not Done Inline ActionsIn fact there is only one immend used in the same time, because after this one there's a return, it go out of the function, so the second immend is not executed. it was so before anyway. kgeogeo: In fact there is only one immend used in the same time, because after this one there's a… | |||||
merwinUnsubmitted Not Done Inline ActionsThis is correct, End & Unbind before returning. merwin: This is correct, End & Unbind before returning. | |||||
| } | } | ||||
| glVertex2f(minx, miny + rad); | immVertex2f(pos, minx, miny + rad); | ||||
| glEnd(); | immEnd(); | ||||
| immUnbindProgram(); | |||||
| return; | return; | ||||
| } | } | ||||
| /* corner left-bottom */ | /* corner left-bottom */ | ||||
| if (roundboxtype & UI_CNR_BOTTOM_LEFT) { | if (roundboxtype & UI_CNR_BOTTOM_LEFT) { | ||||
| glVertex2f(minx, miny + rad); | immVertex2f(pos, minx, miny + rad); | ||||
| for (a = 0; a < 4; a++) { | for (a = 0; a < 4; a++) { | ||||
| glVertex2f(minx + vec[a][1], miny + rad - vec[a][0]); | immVertex2f(pos, minx + vec[a][1], miny + rad - vec[a][0]); | ||||
| } | } | ||||
| glVertex2f(minx + rad, miny); | immVertex2f(pos, minx + rad, miny); | ||||
| } | } | ||||
| else { | else { | ||||
| glVertex2f(minx, miny); | immVertex2f(pos, minx, miny); | ||||
| } | } | ||||
| /* corner right-bottom */ | /* corner right-bottom */ | ||||
| if (roundboxtype & UI_CNR_BOTTOM_RIGHT) { | if (roundboxtype & UI_CNR_BOTTOM_RIGHT) { | ||||
| glVertex2f(maxx - rad, miny); | immVertex2f(pos, maxx - rad, miny); | ||||
| for (a = 0; a < 4; a++) { | for (a = 0; a < 4; a++) { | ||||
| glVertex2f(maxx - rad + vec[a][0], miny + vec[a][1]); | immVertex2f(pos, maxx - rad + vec[a][0], miny + vec[a][1]); | ||||
| } | } | ||||
| glVertex2f(maxx, miny + rad); | immVertex2f(pos, maxx, miny + rad); | ||||
| } | } | ||||
| else { | else { | ||||
| glVertex2f(maxx, miny); | immVertex2f(pos, maxx, miny); | ||||
| } | } | ||||
| glEnd(); | immEnd(); | ||||
| immUnbindProgram(); | |||||
| } | } | ||||
| Context not available. | |||||
| if (is_active) | if (is_active) | ||||
| #endif | #endif | ||||
| { | { | ||||
| glColor3ubv(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, | ||||
| is_active ? theme_col_tab_active : theme_col_tab_inactive); | |||||
| /* tab outline */ | /* tab outline */ | ||||
| glColor3ubv(theme_col_tab_outline); | |||||
| 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, theme_col_tab_outline); | ||||
| /* tab highlight (3d look) */ | /* tab highlight (3d look) */ | ||||
| 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, | ui_panel_category_draw_tab(GL_LINE_STRIP, rct->xmin, rct->ymin, rct->xmax, rct->ymax, | ||||
| tab_curve_radius, roundboxtype, true, false, | tab_curve_radius, roundboxtype, true, false, | ||||
| is_active ? theme_col_back : theme_col_tab_inactive); | is_active ? theme_col_back : theme_col_tab_inactive, | ||||
| is_active ? theme_col_tab_highlight : theme_col_tab_highlight_inactive); | |||||
| } | } | ||||
| /* tab blackline */ | /* tab blackline */ | ||||
| Context not available. | |||||
Just wondering, is this just for forcing non-GL_POLYGON drawing? Couldn't we simply add a BLI_assert for this?