Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/interface/interface_widgets.c
| Show First 20 Lines • Show All 527 Lines • ▼ Show 20 Lines | static void draw_anti_tria( | ||||
| copy_v4_v4(draw_color, color); | copy_v4_v4(draw_color, color); | ||||
| /* NOTE: This won't give back the original color. */ | /* NOTE: This won't give back the original color. */ | ||||
| draw_color[3] *= 1.0f / WIDGET_AA_JITTER; | draw_color[3] *= 1.0f / WIDGET_AA_JITTER; | ||||
| GPU_blend(GPU_BLEND_ALPHA); | GPU_blend(GPU_BLEND_ALPHA); | ||||
| const uint pos = GPU_vertformat_attr_add( | const uint pos = GPU_vertformat_attr_add( | ||||
| immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | ||||
| immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); | immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); | ||||
| immUniformColor4fv(draw_color); | immUniformColor4fv(draw_color); | ||||
| immBegin(GPU_PRIM_TRIS, 3 * WIDGET_AA_JITTER); | immBegin(GPU_PRIM_TRIS, 3 * WIDGET_AA_JITTER); | ||||
| /* for each AA step */ | /* for each AA step */ | ||||
| for (int j = 0; j < WIDGET_AA_JITTER; j++) { | for (int j = 0; j < WIDGET_AA_JITTER; j++) { | ||||
| immVertex2f(pos, tri_arr[0][0] + jit[j][0], tri_arr[0][1] + jit[j][1]); | immVertex2f(pos, tri_arr[0][0] + jit[j][0], tri_arr[0][1] + jit[j][1]); | ||||
| immVertex2f(pos, tri_arr[1][0] + jit[j][0], tri_arr[1][1] + jit[j][1]); | immVertex2f(pos, tri_arr[1][0] + jit[j][0], tri_arr[1][1] + jit[j][1]); | ||||
| ▲ Show 20 Lines • Show All 1,429 Lines • ▼ Show 20 Lines | if ((but->selend - but->selsta) > 0) { | ||||
| else { | else { | ||||
| selsta_draw = 0; | selsta_draw = 0; | ||||
| } | } | ||||
| selwidth_draw = BLF_width(fstyle->uifont_id, drawstr + but->ofs, but->selend - but->ofs); | selwidth_draw = BLF_width(fstyle->uifont_id, drawstr + but->ofs, but->selend - but->ofs); | ||||
| uint pos = GPU_vertformat_attr_add( | uint pos = GPU_vertformat_attr_add( | ||||
| immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); | immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); | ||||
| immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); | immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); | ||||
| rcti selection_shape; | rcti selection_shape; | ||||
| selection_shape.xmin = rect->xmin + selsta_draw; | selection_shape.xmin = rect->xmin + selsta_draw; | ||||
| selection_shape.xmax = min_ii(rect->xmin + selwidth_draw, rect->xmax - 2); | selection_shape.xmax = min_ii(rect->xmin + selwidth_draw, rect->xmax - 2); | ||||
| selection_shape.ymin = rect->ymin + U.pixelsize; | selection_shape.ymin = rect->ymin + U.pixelsize; | ||||
| selection_shape.ymax = rect->ymax - U.pixelsize; | selection_shape.ymax = rect->ymax - U.pixelsize; | ||||
| immUniformColor4ubv(wcol->item); | immUniformColor4ubv(wcol->item); | ||||
| immRecti(pos, | immRecti(pos, | ||||
| Show All 35 Lines | if (but->pos >= but->ofs) { | ||||
| } | } | ||||
| /* We are drawing on top of widget bases. Flush cache. */ | /* We are drawing on top of widget bases. Flush cache. */ | ||||
| GPU_blend(GPU_BLEND_ALPHA); | GPU_blend(GPU_BLEND_ALPHA); | ||||
| UI_widgetbase_draw_cache_flush(); | UI_widgetbase_draw_cache_flush(); | ||||
| GPU_blend(GPU_BLEND_NONE); | GPU_blend(GPU_BLEND_NONE); | ||||
| uint pos = GPU_vertformat_attr_add( | uint pos = GPU_vertformat_attr_add( | ||||
| immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); | immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); | ||||
| immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); | immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); | ||||
| immUniformThemeColor(TH_WIDGET_TEXT_CURSOR); | immUniformThemeColor(TH_WIDGET_TEXT_CURSOR); | ||||
| /* Shape of the cursor for drawing. */ | /* Shape of the cursor for drawing. */ | ||||
| rcti but_cursor_shape; | rcti but_cursor_shape; | ||||
| but_cursor_shape.xmin = (rect->xmin + t) - U.pixelsize; | but_cursor_shape.xmin = (rect->xmin + t) - U.pixelsize; | ||||
| but_cursor_shape.ymin = rect->ymin + U.pixelsize; | but_cursor_shape.ymin = rect->ymin + U.pixelsize; | ||||
| but_cursor_shape.xmax = (rect->xmin + t) + U.pixelsize; | but_cursor_shape.xmax = (rect->xmin + t) + U.pixelsize; | ||||
| ▲ Show 20 Lines • Show All 726 Lines • ▼ Show 20 Lines | const int totvert = round_box_shadow_edges(wtb.inner_v, | ||||
| 0.0f); | 0.0f); | ||||
| /* we draw a number of increasing size alpha quad strips */ | /* we draw a number of increasing size alpha quad strips */ | ||||
| const float alphastep = 3.0f * btheme->tui.menu_shadow_fac / radout; | const float alphastep = 3.0f * btheme->tui.menu_shadow_fac / radout; | ||||
| const uint pos = GPU_vertformat_attr_add( | const uint pos = GPU_vertformat_attr_add( | ||||
| immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | ||||
| immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); | immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); | ||||
| for (int step = 1; step <= (int)radout; step++) { | for (int step = 1; step <= (int)radout; step++) { | ||||
| const float expfac = sqrtf(step / radout); | const float expfac = sqrtf(step / radout); | ||||
| round_box_shadow_edges(wtb.outer_v, &rect1, radin, UI_CNR_ALL, (float)step); | round_box_shadow_edges(wtb.outer_v, &rect1, radin, UI_CNR_ALL, (float)step); | ||||
| immUniformColor4f(0.0f, 0.0f, 0.0f, alphastep * (1.0f - expfac)); | immUniformColor4f(0.0f, 0.0f, 0.0f, alphastep * (1.0f - expfac)); | ||||
| Show All 39 Lines | |||||
| } | } | ||||
| static void ui_hsv_cursor(const float x, const float y, const float zoom) | static void ui_hsv_cursor(const float x, const float y, const float zoom) | ||||
| { | { | ||||
| const float radius = zoom * 3.0f * U.pixelsize; | const float radius = zoom * 3.0f * U.pixelsize; | ||||
| const uint pos = GPU_vertformat_attr_add( | const uint pos = GPU_vertformat_attr_add( | ||||
| immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | ||||
| immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); | immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); | ||||
| immUniformColor3f(1.0f, 1.0f, 1.0f); | immUniformColor3f(1.0f, 1.0f, 1.0f); | ||||
| imm_draw_circle_fill_2d(pos, x, y, radius, 8); | imm_draw_circle_fill_2d(pos, x, y, radius, 8); | ||||
| GPU_blend(GPU_BLEND_ALPHA); | GPU_blend(GPU_BLEND_ALPHA); | ||||
| GPU_line_smooth(true); | GPU_line_smooth(true); | ||||
| immUniformColor3f(0.0f, 0.0f, 0.0f); | immUniformColor3f(0.0f, 0.0f, 0.0f); | ||||
| imm_draw_circle_wire_2d(pos, x, y, radius, 12); | imm_draw_circle_wire_2d(pos, x, y, radius, 12); | ||||
| ▲ Show 20 Lines • Show All 117 Lines • ▼ Show 20 Lines | static void ui_draw_but_HSVCIRCLE(uiBut *but, const uiWidgetColors *wcol, const rcti *rect) | ||||
| } | } | ||||
| immEnd(); | immEnd(); | ||||
| immUnbindProgram(); | immUnbindProgram(); | ||||
| /* fully rounded outline */ | /* fully rounded 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_3D_UNIFORM_COLOR); | ||||
| GPU_blend(GPU_BLEND_ALPHA); | GPU_blend(GPU_BLEND_ALPHA); | ||||
| GPU_line_smooth(true); | GPU_line_smooth(true); | ||||
| immUniformColor3ubv(wcol->outline); | immUniformColor3ubv(wcol->outline); | ||||
| imm_draw_circle_wire_2d(pos, centx, centy, radius, tot); | imm_draw_circle_wire_2d(pos, centx, centy, radius, tot); | ||||
| immUnbindProgram(); | immUnbindProgram(); | ||||
| ▲ Show 20 Lines • Show All 245 Lines • ▼ Show 20 Lines | static void ui_draw_but_HSVCUBE(uiBut *but, const rcti *rect) | ||||
| const float zoom = 1.0f / but->block->aspect; | const float zoom = 1.0f / but->block->aspect; | ||||
| ui_hsv_cursor(x, y, zoom); | ui_hsv_cursor(x, y, zoom); | ||||
| /* outline */ | /* outline */ | ||||
| const uint pos = GPU_vertformat_attr_add( | const uint pos = GPU_vertformat_attr_add( | ||||
| immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | ||||
| immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); | immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); | ||||
| immUniformColor3ub(0, 0, 0); | immUniformColor3ub(0, 0, 0); | ||||
| 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(); | ||||
| } | } | ||||
| /* vertical 'value' slider, using new widget code */ | /* vertical 'value' slider, using new widget code */ | ||||
| static void ui_draw_but_HSV_v(uiBut *but, const rcti *rect) | static void ui_draw_but_HSV_v(uiBut *but, const rcti *rect) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Lines | const uchar col[4] = { | ||||
| wcol->text[0], | wcol->text[0], | ||||
| wcol->text[1], | wcol->text[1], | ||||
| wcol->text[2], | wcol->text[2], | ||||
| 30, | 30, | ||||
| }; | }; | ||||
| const uint pos = GPU_vertformat_attr_add( | const uint pos = GPU_vertformat_attr_add( | ||||
| immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | ||||
| immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); | immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); | ||||
| GPU_blend(GPU_BLEND_ALPHA); | GPU_blend(GPU_BLEND_ALPHA); | ||||
| immUniformColor4ubv(col); | immUniformColor4ubv(col); | ||||
| GPU_line_width(1.0f); | GPU_line_width(1.0f); | ||||
| immBegin(GPU_PRIM_LINES, 2); | immBegin(GPU_PRIM_LINES, 2); | ||||
| immVertex2f(pos, rect->xmin, y); | immVertex2f(pos, rect->xmin, y); | ||||
| immVertex2f(pos, rect->xmax, y); | immVertex2f(pos, rect->xmax, y); | ||||
| ▲ Show 20 Lines • Show All 598 Lines • ▼ Show 20 Lines | if (color_but->is_pallete_color && | ||||
| /* We are drawing on top of widget bases. Flush cache. */ | /* We are drawing on top of widget bases. Flush cache. */ | ||||
| GPU_blend(GPU_BLEND_ALPHA); | GPU_blend(GPU_BLEND_ALPHA); | ||||
| UI_widgetbase_draw_cache_flush(); | UI_widgetbase_draw_cache_flush(); | ||||
| GPU_blend(GPU_BLEND_NONE); | GPU_blend(GPU_BLEND_NONE); | ||||
| const uint pos = GPU_vertformat_attr_add( | const uint pos = GPU_vertformat_attr_add( | ||||
| immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | ||||
| immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); | immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); | ||||
| immUniformColor3f(bw, bw, bw); | immUniformColor3f(bw, bw, bw); | ||||
| immBegin(GPU_PRIM_TRIS, 3); | immBegin(GPU_PRIM_TRIS, 3); | ||||
| immVertex2f(pos, rect->xmin + 0.1f * width, rect->ymin + 0.9f * height); | immVertex2f(pos, rect->xmin + 0.1f * width, rect->ymin + 0.9f * height); | ||||
| immVertex2f(pos, rect->xmin + 0.1f * width, rect->ymin + 0.5f * height); | immVertex2f(pos, rect->xmin + 0.1f * width, rect->ymin + 0.5f * height); | ||||
| immVertex2f(pos, rect->xmin + 0.5f * width, rect->ymin + 0.9f * height); | immVertex2f(pos, rect->xmin + 0.5f * width, rect->ymin + 0.9f * height); | ||||
| immEnd(); | immEnd(); | ||||
| ▲ Show 20 Lines • Show All 449 Lines • ▼ Show 20 Lines | static void widget_draw_extra_mask(const bContext *C, uiBut *but, uiWidgetType *wt, rcti *rect) | ||||
| if (but->block->drawextra) { | if (but->block->drawextra) { | ||||
| /* NOTE: drawextra can change rect +1 or -1, to match round errors of existing previews. */ | /* NOTE: drawextra can change rect +1 or -1, to match round errors of existing previews. */ | ||||
| but->block->drawextra( | but->block->drawextra( | ||||
| C, but->poin, but->block->drawextra_arg1, but->block->drawextra_arg2, rect); | C, but->poin, but->block->drawextra_arg1, but->block->drawextra_arg2, rect); | ||||
| const uint pos = GPU_vertformat_attr_add( | const uint pos = GPU_vertformat_attr_add( | ||||
| immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | ||||
| immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); | immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); | ||||
| /* make mask to draw over image */ | /* make mask to draw over image */ | ||||
| uchar col[4]; | uchar col[4]; | ||||
| UI_GetThemeColor3ubv(TH_BACK, col); | UI_GetThemeColor3ubv(TH_BACK, col); | ||||
| immUniformColor3ubv(col); | immUniformColor3ubv(col); | ||||
| round_box__edges(&wtb, UI_CNR_ALL, rect, 0.0f, rad); | round_box__edges(&wtb, UI_CNR_ALL, rect, 0.0f, rad); | ||||
| widgetbase_outline(&wtb, pos); | widgetbase_outline(&wtb, pos); | ||||
| ▲ Show 20 Lines • Show All 679 Lines • ▼ Show 20 Lines | /* Extracted from 'widget_menu_back', keep separate to avoid menu changes breaking popovers */ | ||||
| wtb.draw_emboss = false; | wtb.draw_emboss = false; | ||||
| widgetbase_draw(&wtb, wcol); | widgetbase_draw(&wtb, wcol); | ||||
| } | } | ||||
| /* Draw popover arrow (top/bottom) */ | /* Draw popover arrow (top/bottom) */ | ||||
| if (ELEM(direction, UI_DIR_UP, UI_DIR_DOWN)) { | if (ELEM(direction, UI_DIR_UP, UI_DIR_DOWN)) { | ||||
| const uint pos = GPU_vertformat_attr_add( | const uint pos = GPU_vertformat_attr_add( | ||||
| immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | ||||
| immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); | immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); | ||||
| const bool is_down = (direction == UI_DIR_DOWN); | const bool is_down = (direction == UI_DIR_DOWN); | ||||
| const int sign = is_down ? 1 : -1; | const int sign = is_down ? 1 : -1; | ||||
| float y = is_down ? rect->ymax : rect->ymin; | float y = is_down ? rect->ymax : rect->ymin; | ||||
| GPU_blend(GPU_BLEND_ALPHA); | GPU_blend(GPU_BLEND_ALPHA); | ||||
| immBegin(GPU_PRIM_TRIS, 3); | immBegin(GPU_PRIM_TRIS, 3); | ||||
| immUniformColor4ubv(wcol->outline); | immUniformColor4ubv(wcol->outline); | ||||
| ▲ Show 20 Lines • Show All 62 Lines • ▼ Show 20 Lines | static void draw_disk_shaded(float start, | ||||
| uint col; | uint col; | ||||
| GPUVertFormat *format = immVertexFormat(); | GPUVertFormat *format = immVertexFormat(); | ||||
| const uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | const uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | ||||
| if (shaded) { | if (shaded) { | ||||
| col = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT); | col = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT); | ||||
| immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR); | immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR); | ||||
| } | } | ||||
| else { | else { | ||||
| immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); | immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); | ||||
| immUniformColor4ubv(col1); | immUniformColor4ubv(col1); | ||||
| } | } | ||||
| immBegin(GPU_PRIM_TRI_STRIP, subd * 2); | immBegin(GPU_PRIM_TRI_STRIP, subd * 2); | ||||
| for (int i = 0; i < subd; i++) { | for (int i = 0; i < subd; i++) { | ||||
| const float a = start + ((i) / (float)(subd - 1)) * angle; | const float a = start + ((i) / (float)(subd - 1)) * angle; | ||||
| const float s = sinf(a); | const float s = sinf(a); | ||||
| const float c = cosf(a); | const float c = cosf(a); | ||||
| ▲ Show 20 Lines • Show All 94 Lines • ▼ Show 20 Lines | else { | ||||
| btheme->tui.wcol_pie_menu.inner_sel, | btheme->tui.wcol_pie_menu.inner_sel, | ||||
| NULL, | NULL, | ||||
| false); | false); | ||||
| } | } | ||||
| } | } | ||||
| GPUVertFormat *format = immVertexFormat(); | GPUVertFormat *format = immVertexFormat(); | ||||
| const uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | const uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | ||||
| immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); | immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); | ||||
| immUniformColor4ubv(btheme->tui.wcol_pie_menu.outline); | immUniformColor4ubv(btheme->tui.wcol_pie_menu.outline); | ||||
| imm_draw_circle_wire_2d(pos, 0.0f, 0.0f, pie_radius_internal, subd); | imm_draw_circle_wire_2d(pos, 0.0f, 0.0f, pie_radius_internal, subd); | ||||
| imm_draw_circle_wire_2d(pos, 0.0f, 0.0f, pie_radius_external, subd); | imm_draw_circle_wire_2d(pos, 0.0f, 0.0f, pie_radius_external, subd); | ||||
| immUnbindProgram(); | immUnbindProgram(); | ||||
| if (U.pie_menu_confirm > 0 && | if (U.pie_menu_confirm > 0 && | ||||
| ▲ Show 20 Lines • Show All 296 Lines • Show Last 20 Lines | |||||