Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/interface/interface_draw.c
| Show First 20 Lines • Show All 2,239 Lines • ▼ Show 20 Lines | void ui_draw_but_CURVEPROFILE(ARegion *region, | ||||
| /* Create array of the positions of the table's points. */ | /* Create array of the positions of the table's points. */ | ||||
| float(*table_coords)[2] = MEM_mallocN(sizeof(*table_coords) * tot_points, "table x coords"); | float(*table_coords)[2] = MEM_mallocN(sizeof(*table_coords) * tot_points, "table x coords"); | ||||
| for (uint i = 0; i < (uint)PROF_TABLE_LEN(profile->path_len); | for (uint i = 0; i < (uint)PROF_TABLE_LEN(profile->path_len); | ||||
| i++) { /* Only add the points from the table here. */ | i++) { /* Only add the points from the table here. */ | ||||
| table_coords[i][0] = pts[i].x; | table_coords[i][0] = pts[i].x; | ||||
| table_coords[i][1] = pts[i].y; | table_coords[i][1] = pts[i].y; | ||||
| } | } | ||||
| /* Add extra points just outside the viewport, for the fill. | |||||
| * Using coordinates slightly outside the view port ensures we don't | |||||
| * have stray triangles cutting across the view. See: T84183 | |||||
| */ | |||||
| if (add_left_tri && add_bottom_tri) { | if (add_left_tri && add_bottom_tri) { | ||||
| /* Add left side, bottom left corner, and bottom side points. */ | /* Add left side, bottom left corner, and bottom side points. */ | ||||
| table_coords[tot_points - 3][0] = profile->view_rect.xmin; | table_coords[tot_points - 3][0] = profile->view_rect.xmin - 1; | ||||
| table_coords[tot_points - 3][1] = 1.0f; | table_coords[tot_points - 3][1] = 1.0f; | ||||
| table_coords[tot_points - 2][0] = profile->view_rect.xmin; | table_coords[tot_points - 2][0] = profile->view_rect.xmin - 1; | ||||
| table_coords[tot_points - 2][1] = profile->view_rect.ymin; | table_coords[tot_points - 2][1] = profile->view_rect.ymin - 1; | ||||
| table_coords[tot_points - 1][0] = 1.0f; | table_coords[tot_points - 1][0] = 1.0f; | ||||
| table_coords[tot_points - 1][1] = profile->view_rect.ymin; | table_coords[tot_points - 1][1] = profile->view_rect.ymin - 1; | ||||
| } | } | ||||
| else if (add_left_tri) { | else if (add_left_tri) { | ||||
| /* Add the left side and bottom left corner points. */ | /* Add the left side and bottom left corner points. */ | ||||
| table_coords[tot_points - 2][0] = profile->view_rect.xmin; | table_coords[tot_points - 2][0] = profile->view_rect.xmin - 1; | ||||
| table_coords[tot_points - 2][1] = 1.0f; | table_coords[tot_points - 2][1] = 1.0f; | ||||
| table_coords[tot_points - 1][0] = profile->view_rect.xmin; | table_coords[tot_points - 1][0] = profile->view_rect.xmin - 1; | ||||
| table_coords[tot_points - 1][1] = 0.0f; | table_coords[tot_points - 1][1] = -1.0f; | ||||
| } | } | ||||
| else if (add_bottom_tri) { | else if (add_bottom_tri) { | ||||
| /* Add the bottom side and bottom left corner points. */ | /* Add the bottom side and bottom left corner points. */ | ||||
| table_coords[tot_points - 2][0] = 0.0f; | table_coords[tot_points - 2][0] = -1.0f; | ||||
| table_coords[tot_points - 2][1] = profile->view_rect.ymin; | table_coords[tot_points - 2][1] = profile->view_rect.ymin - 1; | ||||
| table_coords[tot_points - 1][0] = 1.0f; | table_coords[tot_points - 1][0] = 1.0f; | ||||
| table_coords[tot_points - 1][1] = profile->view_rect.ymin; | table_coords[tot_points - 1][1] = profile->view_rect.ymin - 1; | ||||
| } | } | ||||
| else { | else { | ||||
| /* Just add the bottom corner point. Side points would be redundant anyway. */ | /* Just add the bottom corner point. Side points would be redundant anyway. */ | ||||
| table_coords[tot_points - 1][0] = 0.0f; | table_coords[tot_points - 1][0] = -1.0f; | ||||
| table_coords[tot_points - 1][1] = 0.0f; | table_coords[tot_points - 1][1] = -1.0f; | ||||
| } | } | ||||
| /* Calculate the table point indices of the triangles for the profile's fill. */ | /* Calculate the table point indices of the triangles for the profile's fill. */ | ||||
| uint(*tri_indices)[3] = MEM_mallocN(sizeof(*tri_indices) * tot_triangles, "return tri indices"); | uint(*tri_indices)[3] = MEM_mallocN(sizeof(*tri_indices) * tot_triangles, "return tri indices"); | ||||
| BLI_polyfill_calc(table_coords, tot_points, -1, tri_indices); | BLI_polyfill_calc(table_coords, tot_points, -1, tri_indices); | ||||
| /* Draw the triangles for the profile fill. */ | /* Draw the triangles for the profile fill. */ | ||||
| immUniformColor3ubvAlpha((const uchar *)wcol->item, 128); | immUniformColor3ubvAlpha((const uchar *)wcol->item, 128); | ||||
| ▲ Show 20 Lines • Show All 139 Lines • ▼ Show 20 Lines | void ui_draw_but_CURVEPROFILE(ARegion *region, | ||||
| /* Outline */ | /* Outline */ | ||||
| format = immVertexFormat(); | 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); | ||||
| immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); | immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); | ||||
| immUniformColor3ubv((const uchar *)wcol->outline); | immUniformColor3ubv((const uchar *)wcol->outline); | ||||
| imm_draw_box_wire_2d(pos, rect->xmin, rect->ymin, rect->xmax, rect->ymax); | imm_draw_box_wire_2d(pos, rect->xmin, rect->ymin, rect->xmax, rect->ymax); | ||||
| immUnbindProgram(); | immUnbindProgram(); | ||||
| } | } | ||||
| void ui_draw_but_TRACKPREVIEW(ARegion *UNUSED(region), | void ui_draw_but_TRACKPREVIEW(ARegion *UNUSED(region), | ||||
| uiBut *but, | uiBut *but, | ||||
| const uiWidgetColors *UNUSED(wcol), | const uiWidgetColors *UNUSED(wcol), | ||||
| const rcti *recti) | const rcti *recti) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 327 Lines • Show Last 20 Lines | |||||