diff options
Diffstat (limited to 'source/blender/editors/interface')
20 files changed, 865 insertions, 399 deletions
diff --git a/source/blender/editors/interface/interface.c b/source/blender/editors/interface/interface.c index 3e01c5f356f..37c56d454bb 100644 --- a/source/blender/editors/interface/interface.c +++ b/source/blender/editors/interface/interface.c @@ -280,7 +280,7 @@ static void ui_update_window_matrix(const wmWindow *window, const ARegion *regio /* window matrix and aspect */ if (region && region->visible) { /* Get projection matrix which includes View2D translation and zoom. */ - gpuGetProjectionMatrix(block->winmat); + GPU_matrix_projection_get(block->winmat); block->aspect = 2.0f / fabsf(region->winx * block->winmat[0][0]); } else { @@ -1448,9 +1448,9 @@ void UI_block_draw(const bContext *C, uiBlock *block) ui_but_to_pixelrect(&rect, ar, block, NULL); /* pixel space for AA widgets */ - gpuPushProjectionMatrix(); - gpuPushMatrix(); - gpuLoadIdentity(); + GPU_matrix_push_projection(); + GPU_matrix_push(); + GPU_matrix_identity_set(); wmOrtho2_region_pixelspace(ar); @@ -1485,8 +1485,8 @@ void UI_block_draw(const bContext *C, uiBlock *block) BLF_batch_draw_end(); /* restore matrix */ - gpuPopProjectionMatrix(); - gpuPopMatrix(); + GPU_matrix_pop_projection(); + GPU_matrix_pop(); } static void ui_block_message_subscribe(ARegion *ar, struct wmMsgBus *mbus, uiBlock *block) diff --git a/source/blender/editors/interface/interface_context_menu.c b/source/blender/editors/interface/interface_context_menu.c index 240649c8ab0..d00ab70562c 100644 --- a/source/blender/editors/interface/interface_context_menu.c +++ b/source/blender/editors/interface/interface_context_menu.c @@ -715,7 +715,7 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but) } /* Show header tools for header buttons. */ - if (ui_block_is_menu(but->block) == false) { + if (ui_block_is_popup_any(but->block) == false) { ARegion *ar = CTX_wm_region(C); if (ar && (ar->regiontype == RGN_TYPE_HEADER)) { uiItemMenuF(layout, IFACE_("Header"), ICON_NONE, ED_screens_header_tools_menu_create, NULL); diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index 51f2c7e8ece..6a304a8150e 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -130,19 +130,19 @@ void UI_draw_roundbox_aa(bool filled, float minx, float miny, float maxx, float /* WATCH: This is assuming the ModelViewProjectionMatrix is area pixel space. * If it has been scaled, then it's no longer valid. */ - Gwn_Batch *batch = ui_batch_roundbox_get(filled, true); - GWN_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_BASE); - GWN_batch_uniform_4fv_array(batch, "parameters", 11, (float *)&widget_params); - GWN_batch_draw(batch); + GPUBatch *batch = ui_batch_roundbox_get(filled, true); + GPU_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_BASE); + GPU_batch_uniform_4fv_array(batch, "parameters", 11, (float *)&widget_params); + GPU_batch_draw(batch); } else { /* plain antialiased unfilled box */ GPU_line_smooth(true); - Gwn_Batch *batch = ui_batch_roundbox_get(filled, false); - GWN_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_BASE); - GWN_batch_uniform_4fv_array(batch, "parameters", 11, (float *)&widget_params); - GWN_batch_draw(batch); + GPUBatch *batch = ui_batch_roundbox_get(filled, false); + GPU_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_BASE); + GPU_batch_uniform_4fv_array(batch, "parameters", 11, (float *)&widget_params); + GPU_batch_draw(batch); GPU_line_smooth(false); } @@ -159,8 +159,8 @@ void UI_draw_roundbox_4fv(bool filled, float minx, float miny, float maxx, float }; int a; - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); /* mult */ for (a = 0; a < 7; a++) { @@ -176,7 +176,7 @@ void UI_draw_roundbox_4fv(bool filled, float minx, float miny, float maxx, float immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4fv(col); - immBegin(filled ? GWN_PRIM_TRI_FAN : GWN_PRIM_LINE_LOOP, vert_len); + immBegin(filled ? GPU_PRIM_TRI_FAN : GPU_PRIM_LINE_LOOP, vert_len); /* start with corner right-bottom */ if (roundboxtype & UI_CNR_BOTTOM_RIGHT) { immVertex2f(pos, maxx - rad, miny); @@ -244,10 +244,10 @@ void UI_draw_roundbox_4fv(bool filled, float minx, float miny, float maxx, float .alpha_discard = 1.0f, }; - Gwn_Batch *batch = ui_batch_roundbox_get(filled, false); - GWN_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_BASE); - GWN_batch_uniform_4fv_array(batch, "parameters", 11, (float *)&widget_params); - GWN_batch_draw(batch); + GPUBatch *batch = ui_batch_roundbox_get(filled, false); + GPU_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_BASE); + GPU_batch_uniform_4fv_array(batch, "parameters", 11, (float *)&widget_params); + GPU_batch_draw(batch); } #if 0 @@ -280,9 +280,9 @@ void UI_draw_roundbox_shade_x( int vert_count = 0; int a; - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR); @@ -304,7 +304,7 @@ void UI_draw_roundbox_shade_x( vert_count += (roundboxtype & UI_CNR_TOP_LEFT) ? 9 : 1; vert_count += (roundboxtype & UI_CNR_BOTTOM_LEFT) ? 9 : 1; - immBegin(filled ? GWN_PRIM_TRI_FAN : GWN_PRIM_LINE_LOOP, vert_count); + immBegin(filled ? GPU_PRIM_TRI_FAN : GPU_PRIM_LINE_LOOP, vert_count); /* start with corner right-bottom */ if (roundboxtype & UI_CNR_BOTTOM_RIGHT) { @@ -404,10 +404,10 @@ void UI_draw_roundbox_shade_x( .alpha_discard = 1.0f, }; - Gwn_Batch *batch = ui_batch_roundbox_get(filled, false); - GWN_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_BASE); - GWN_batch_uniform_4fv_array(batch, "parameters", 11, (float *)&widget_params); - GWN_batch_draw(batch); + GPUBatch *batch = ui_batch_roundbox_get(filled, false); + GPU_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_BASE); + GPU_batch_uniform_4fv_array(batch, "parameters", 11, (float *)&widget_params); + GPU_batch_draw(batch); } #if 0 /* unused */ @@ -432,9 +432,9 @@ void UI_draw_roundbox_shade_y( mul_v2_fl(vec[a], rad); } - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR); @@ -452,7 +452,7 @@ void UI_draw_roundbox_shade_y( vert_count += (roundboxtype & UI_CNR_TOP_LEFT) ? 9 : 1; vert_count += (roundboxtype & UI_CNR_BOTTOM_LEFT) ? 9 : 1; - immBegin(filled ? GWN_PRIM_TRI_FAN : GWN_PRIM_LINE_LOOP, vert_count); + immBegin(filled ? GPU_PRIM_TRI_FAN : GPU_PRIM_LINE_LOOP, vert_count); /* start with corner right-bottom */ if (roundboxtype & UI_CNR_BOTTOM_RIGHT) { @@ -535,8 +535,8 @@ void UI_draw_text_underline(int pos_x, int pos_y, int len, int height, const flo { int ofs_y = 4 * U.pixelsize; - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4fv(color); @@ -550,9 +550,9 @@ void UI_draw_text_underline(int pos_x, int pos_y, int len, int height, const flo /* based on UI_draw_roundbox_gl_mode, check on making a version which allows us to skip some sides */ void ui_draw_but_TAB_outline(const rcti *rect, float rad, unsigned char highlight[3], unsigned char highlight_fade[3]) { - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint col = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint col = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 3, GPU_FETCH_INT_TO_FLOAT_UNIT); /* add a 1px offset, looks nicer */ const int minx = rect->xmin + U.pixelsize, maxx = rect->xmax - U.pixelsize; const int miny = rect->ymin + U.pixelsize, maxy = rect->ymax - U.pixelsize; @@ -571,7 +571,7 @@ void ui_draw_but_TAB_outline(const rcti *rect, float rad, unsigned char highligh } immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR); - immBeginAtMost(GWN_PRIM_LINE_STRIP, 25); + immBeginAtMost(GPU_PRIM_LINE_STRIP, 25); immAttrib3ubv(col, highlight); @@ -685,8 +685,8 @@ void ui_draw_but_IMAGE(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSED(w * * \Note This functionn is to be used with the 2D dashed shader enabled. * - * \param pos is a PRIM_FLOAT, 2, GWN_FETCH_FLOAT vertex attrib - * \param line_origin is a PRIM_FLOAT, 2, GWN_FETCH_FLOAT vertex attrib + * \param pos is a PRIM_FLOAT, 2, GPU_FETCH_FLOAT vertex attrib + * \param line_origin is a PRIM_FLOAT, 2, GPU_FETCH_FLOAT vertex attrib * * The next 4 parameters are the offsets for the view, not the zones. */ @@ -749,7 +749,7 @@ static void histogram_draw_one( /* curve outline */ GPU_line_width(1.5); - immBegin(GWN_PRIM_LINE_STRIP, res); + immBegin(GPU_PRIM_LINE_STRIP, res); for (int i = 0; i < res; i++) { float x2 = x + i * (w / (float)res); immVertex2f(pos_attrib, x2, y + (data[i] * h)); @@ -758,7 +758,7 @@ static void histogram_draw_one( } else { /* under the curve */ - immBegin(GWN_PRIM_TRI_STRIP, res * 2); + immBegin(GPU_PRIM_TRI_STRIP, res * 2); immVertex2f(pos_attrib, x, y); immVertex2f(pos_attrib, x, y + (data[0] * h)); for (int i = 1; i < res; i++) { @@ -772,7 +772,7 @@ static void histogram_draw_one( immUniformColor4f(0.0f, 0.0f, 0.0f, 0.25f); GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); - immBegin(GWN_PRIM_LINE_STRIP, res); + immBegin(GPU_PRIM_LINE_STRIP, res); for (int i = 0; i < res; i++) { float x2 = x + i * (w / (float)res); immVertex2f(pos_attrib, x2, y + (data[i] * h)); @@ -818,8 +818,8 @@ void ui_draw_but_HISTOGRAM(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUS (rect.xmax + 1) - (rect.xmin - 1), (rect.ymax + 1) - (rect.ymin - 1)); - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -833,7 +833,7 @@ void ui_draw_but_HISTOGRAM(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUS immUniformColor4f(1.0f, 1.0f, 1.0f, 0.5f); } - immBegin(GWN_PRIM_LINES, 4); + immBegin(GPU_PRIM_LINES, 4); immVertex2f(pos, rect.xmin, rect.ymin + fac * h); immVertex2f(pos, rect.xmax, rect.ymin + fac * h); @@ -869,21 +869,21 @@ void ui_draw_but_HISTOGRAM(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUS static void waveform_draw_one(float *waveform, int nbr, const float col[3]) { - Gwn_VertFormat format = {0}; - uint pos_id = GWN_vertformat_attr_add(&format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat format = {0}; + uint pos_id = GPU_vertformat_attr_add(&format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(&format); - GWN_vertbuf_data_alloc(vbo, nbr); + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(&format); + GPU_vertbuf_data_alloc(vbo, nbr); - GWN_vertbuf_attr_fill(vbo, pos_id, waveform); + GPU_vertbuf_attr_fill(vbo, pos_id, waveform); - /* TODO store the Gwn_Batch inside the scope */ - Gwn_Batch *batch = GWN_batch_create_ex(GWN_PRIM_POINTS, vbo, NULL, GWN_BATCH_OWNS_VBO); - GWN_batch_program_set_builtin(batch, GPU_SHADER_2D_UNIFORM_COLOR); - GWN_batch_uniform_4f(batch, "color", col[0], col[1], col[2], 1.0f); - GWN_batch_draw(batch); + /* TODO store the GPUBatch inside the scope */ + GPUBatch *batch = GPU_batch_create_ex(GPU_PRIM_POINTS, vbo, NULL, GPU_BATCH_OWNS_VBO); + GPU_batch_program_set_builtin(batch, GPU_SHADER_2D_UNIFORM_COLOR); + GPU_batch_uniform_4f(batch, "color", col[0], col[1], col[2], 1.0f); + GPU_batch_draw(batch); - GWN_batch_discard(batch); + GPU_batch_discard(batch); } void ui_draw_but_WAVEFORM(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti *recti) @@ -957,15 +957,15 @@ void ui_draw_but_WAVEFORM(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSE GPU_blend(true); GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4f(1.0f, 1.0f, 1.0f, 0.08f); /* draw grid lines here */ - immBegin(GWN_PRIM_LINES, 12); + immBegin(GPU_PRIM_LINES, 12); for (int i = 0; i < 6; i++) { immVertex2f(pos, rect.xmin + 22, yofs + (i * 0.2f) * h); @@ -976,7 +976,7 @@ void ui_draw_but_WAVEFORM(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSE /* 3 vertical separation */ if (scopes->wavefrm_mode != SCOPES_WAVEFRM_LUMA) { - immBegin(GWN_PRIM_LINES, 4); + immBegin(GPU_PRIM_LINES, 4); for (int i = 1; i < 3; i++) { immVertex2f(pos, rect.xmin + i * w3, rect.ymin); @@ -987,7 +987,7 @@ void ui_draw_but_WAVEFORM(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSE } /* separate min max zone on the right */ - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2f(pos, rect.xmin + w, rect.ymin); immVertex2f(pos, rect.xmin + w, rect.ymax); immEnd(); @@ -995,7 +995,7 @@ void ui_draw_but_WAVEFORM(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSE /* 16-235-240 level in case of ITU-R BT601/709 */ immUniformColor4f(1.0f, 0.4f, 0.0f, 0.2f); if (ELEM(scopes->wavefrm_mode, SCOPES_WAVEFRM_YCC_601, SCOPES_WAVEFRM_YCC_709)) { - immBegin(GWN_PRIM_LINES, 8); + immBegin(GPU_PRIM_LINES, 8); immVertex2f(pos, rect.xmin + 22, yofs + h * 16.0f / 255.0f); immVertex2f(pos, rect.xmax + 1, yofs + h * 16.0f / 255.0f); @@ -1013,7 +1013,7 @@ void ui_draw_but_WAVEFORM(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSE } /* 7.5 IRE black point level for NTSC */ if (scopes->wavefrm_mode == SCOPES_WAVEFRM_LUMA) { - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2f(pos, rect.xmin, yofs + h * 0.075f); immVertex2f(pos, rect.xmax + 1, yofs + h * 0.075f); immEnd(); @@ -1027,13 +1027,13 @@ void ui_draw_but_WAVEFORM(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSE if (scopes->wavefrm_mode == SCOPES_WAVEFRM_LUMA) { float col[3] = {alpha, alpha, alpha}; - gpuPushMatrix(); - gpuTranslate2f(rect.xmin, yofs); - gpuScale2f(w, h); + GPU_matrix_push(); + GPU_matrix_translate_2f(rect.xmin, yofs); + GPU_matrix_scale_2f(w, h); waveform_draw_one(scopes->waveform_1, scopes->waveform_tot, col); - gpuPopMatrix(); + GPU_matrix_pop(); /* min max */ immUniformColor3f(0.5f, 0.5f, 0.5f); @@ -1042,22 +1042,22 @@ void ui_draw_but_WAVEFORM(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSE CLAMP(min, rect.ymin, rect.ymax); CLAMP(max, rect.ymin, rect.ymax); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2f(pos, rect.xmax - 3, min); immVertex2f(pos, rect.xmax - 3, max); immEnd(); } /* RGB (3 channel) */ else if (scopes->wavefrm_mode == SCOPES_WAVEFRM_RGB) { - gpuPushMatrix(); - gpuTranslate2f(rect.xmin, yofs); - gpuScale2f(w, h); + GPU_matrix_push(); + GPU_matrix_translate_2f(rect.xmin, yofs); + GPU_matrix_scale_2f(w, h); waveform_draw_one(scopes->waveform_1, scopes->waveform_tot, colors_alpha[0]); waveform_draw_one(scopes->waveform_2, scopes->waveform_tot, colors_alpha[1]); waveform_draw_one(scopes->waveform_3, scopes->waveform_tot, colors_alpha[2]); - gpuPopMatrix(); + GPU_matrix_pop(); } /* PARADE / YCC (3 channels) */ else if (ELEM(scopes->wavefrm_mode, @@ -1069,19 +1069,19 @@ void ui_draw_but_WAVEFORM(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSE { int rgb = (scopes->wavefrm_mode == SCOPES_WAVEFRM_RGB_PARADE); - gpuPushMatrix(); - gpuTranslate2f(rect.xmin, yofs); - gpuScale2f(w3, h); + GPU_matrix_push(); + GPU_matrix_translate_2f(rect.xmin, yofs); + GPU_matrix_scale_2f(w3, h); waveform_draw_one(scopes->waveform_1, scopes->waveform_tot, (rgb) ? colors_alpha[0] : colorsycc_alpha[0]); - gpuTranslate2f(1.0f, 0.0f); + GPU_matrix_translate_2f(1.0f, 0.0f); waveform_draw_one(scopes->waveform_2, scopes->waveform_tot, (rgb) ? colors_alpha[1] : colorsycc_alpha[1]); - gpuTranslate2f(1.0f, 0.0f); + GPU_matrix_translate_2f(1.0f, 0.0f); waveform_draw_one(scopes->waveform_3, scopes->waveform_tot, (rgb) ? colors_alpha[2] : colorsycc_alpha[2]); - gpuPopMatrix(); + GPU_matrix_pop(); } /* min max */ @@ -1096,7 +1096,7 @@ void ui_draw_but_WAVEFORM(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UNUSE CLAMP(min, rect.ymin, rect.ymax); CLAMP(max, rect.ymin, rect.ymax); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2f(pos, rect.xmin + w + 2 + c * 2, min); immVertex2f(pos, rect.xmin + w + 2 + c * 2, max); immEnd(); @@ -1140,7 +1140,7 @@ static void vectorscope_draw_target(unsigned int pos, float centerx, float cente immUniformColor4f(1.0f, 1.0f, 1.0f, 0.12f); dangle = DEG2RADF(2.5f); dampli = 2.5f / 200.0f; - immBegin(GWN_PRIM_LINE_LOOP, 4); + immBegin(GPU_PRIM_LINE_LOOP, 4); immVertex2f(pos, polar_to_x(centerx, diam, tampli + dampli, tangle + dangle), polar_to_y(centery, diam, tampli + dampli, tangle + dangle)); immVertex2f(pos, polar_to_x(centerx, diam, tampli - dampli, tangle + dangle), polar_to_y(centery, diam, tampli - dampli, tangle + dangle)); immVertex2f(pos, polar_to_x(centerx, diam, tampli - dampli, tangle - dangle), polar_to_y(centery, diam, tampli - dampli, tangle - dangle)); @@ -1152,22 +1152,22 @@ static void vectorscope_draw_target(unsigned int pos, float centerx, float cente dampli = 0.2f * tampli; dangle2 = DEG2RADF(5.0f); dampli2 = 0.5f * dampli; - immBegin(GWN_PRIM_LINE_STRIP, 3); + immBegin(GPU_PRIM_LINE_STRIP, 3); immVertex2f(pos, polar_to_x(centerx, diam, tampli + dampli - dampli2, tangle + dangle), polar_to_y(centery, diam, tampli + dampli - dampli2, tangle + dangle)); immVertex2f(pos, polar_to_x(centerx, diam, tampli + dampli, tangle + dangle), polar_to_y(centery, diam, tampli + dampli, tangle + dangle)); immVertex2f(pos, polar_to_x(centerx, diam, tampli + dampli, tangle + dangle - dangle2), polar_to_y(centery, diam, tampli + dampli, tangle + dangle - dangle2)); immEnd(); - immBegin(GWN_PRIM_LINE_STRIP, 3); + immBegin(GPU_PRIM_LINE_STRIP, 3); immVertex2f(pos, polar_to_x(centerx, diam, tampli - dampli + dampli2, tangle + dangle), polar_to_y(centery, diam, tampli - dampli + dampli2, tangle + dangle)); immVertex2f(pos, polar_to_x(centerx, diam, tampli - dampli, tangle + dangle), polar_to_y(centery, diam, tampli - dampli, tangle + dangle)); immVertex2f(pos, polar_to_x(centerx, diam, tampli - dampli, tangle + dangle - dangle2), polar_to_y(centery, diam, tampli - dampli, tangle + dangle - dangle2)); immEnd(); - immBegin(GWN_PRIM_LINE_STRIP, 3); + immBegin(GPU_PRIM_LINE_STRIP, 3); immVertex2f(pos, polar_to_x(centerx, diam, tampli - dampli + dampli2, tangle - dangle), polar_to_y(centery, diam, tampli - dampli + dampli2, tangle - dangle)); immVertex2f(pos, polar_to_x(centerx, diam, tampli - dampli, tangle - dangle), polar_to_y(centery, diam, tampli - dampli, tangle - dangle)); immVertex2f(pos, polar_to_x(centerx, diam, tampli - dampli, tangle - dangle + dangle2), polar_to_y(centery, diam, tampli - dampli, tangle - dangle + dangle2)); immEnd(); - immBegin(GWN_PRIM_LINE_STRIP, 3); + immBegin(GPU_PRIM_LINE_STRIP, 3); immVertex2f(pos, polar_to_x(centerx, diam, tampli + dampli - dampli2, tangle - dangle), polar_to_y(centery, diam, tampli + dampli - dampli2, tangle - dangle)); immVertex2f(pos, polar_to_x(centerx, diam, tampli + dampli, tangle - dangle), polar_to_y(centery, diam, tampli + dampli, tangle - dangle)); immVertex2f(pos, polar_to_x(centerx, diam, tampli + dampli, tangle - dangle + dangle2), polar_to_y(centery, diam, tampli + dampli, tangle - dangle + dangle2)); @@ -1215,15 +1215,15 @@ void ui_draw_but_VECTORSCOPE(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UN (rect.xmax + 1) - (rect.xmin - 1), (rect.ymax + 1) - (rect.ymin - 1)); - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4f(1.0f, 1.0f, 1.0f, 0.08f); /* draw grid elements */ /* cross */ - immBegin(GWN_PRIM_LINES, 4); + immBegin(GPU_PRIM_LINES, 4); immVertex2f(pos, centerx - (diam * 0.5f) - 5, centery); immVertex2f(pos, centerx + (diam * 0.5f) + 5, centery); @@ -1236,7 +1236,7 @@ void ui_draw_but_VECTORSCOPE(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UN /* circles */ for (int j = 0; j < 5; j++) { const int increment = 15; - immBegin(GWN_PRIM_LINE_LOOP, (int)(360 / increment)); + immBegin(GPU_PRIM_LINE_LOOP, (int)(360 / increment)); for (int i = 0; i <= 360 - increment; i += increment) { const float a = DEG2RADF((float)i); const float r = (j + 1) * 0.1f; @@ -1247,7 +1247,7 @@ void ui_draw_but_VECTORSCOPE(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UN /* skin tone line */ immUniformColor4f(1.0f, 0.4f, 0.0f, 0.2f); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2f(pos, polar_to_x(centerx, diam, 0.5f, skin_rad), polar_to_y(centery, diam, 0.5f, skin_rad)); immVertex2f(pos, polar_to_x(centerx, diam, 0.1f, skin_rad), polar_to_y(centery, diam, 0.1f, skin_rad)); immEnd(); @@ -1263,13 +1263,13 @@ void ui_draw_but_VECTORSCOPE(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *UN glBlendFunc(GL_ONE, GL_ONE); GPU_point_size(1.0); - gpuPushMatrix(); - gpuTranslate2f(centerx, centery); - gpuScaleUniform(diam); + GPU_matrix_push(); + GPU_matrix_translate_2f(centerx, centery); + GPU_matrix_scale_1f(diam); waveform_draw_one(scopes->vecscope, scopes->waveform_tot, col); - gpuPopMatrix(); + GPU_matrix_pop(); } immUnbindProgram(); @@ -1284,7 +1284,7 @@ static void ui_draw_colorband_handle_tri_hlight(unsigned int pos, float x1, floa { GPU_line_smooth(true); - immBegin(GWN_PRIM_LINE_STRIP, 3); + immBegin(GPU_PRIM_LINE_STRIP, 3); immVertex2f(pos, x1 + halfwidth, y1); immVertex2f(pos, x1, y1 + height); immVertex2f(pos, x1 - halfwidth, y1); @@ -1297,7 +1297,7 @@ static void ui_draw_colorband_handle_tri(unsigned int pos, float x1, float y1, f { glEnable(fill ? GL_POLYGON_SMOOTH : GL_LINE_SMOOTH); - immBegin(fill ? GWN_PRIM_TRIS : GWN_PRIM_LINE_LOOP, 3); + immBegin(fill ? GPU_PRIM_TRIS : GPU_PRIM_LINE_LOOP, 3); immVertex2f(pos, x1 + halfwidth, y1); immVertex2f(pos, x1, y1 + height); immVertex2f(pos, x1 - halfwidth, y1); @@ -1308,7 +1308,7 @@ static void ui_draw_colorband_handle_tri(unsigned int pos, float x1, float y1, f static void ui_draw_colorband_handle_box(unsigned int pos, float x1, float y1, float x2, float y2, bool fill) { - immBegin(fill ? GWN_PRIM_TRI_FAN : GWN_PRIM_LINE_LOOP, 4); + immBegin(fill ? GPU_PRIM_TRI_FAN : GPU_PRIM_LINE_LOOP, 4); immVertex2f(pos, x1, y1); immVertex2f(pos, x1, y2); immVertex2f(pos, x2, y2); @@ -1348,7 +1348,7 @@ static void ui_draw_colorband_handle( immUniformArray4fv("colors", (float *)(float[][4]){{0.8f, 0.8f, 0.8f, 1.0f}, {0.0f, 0.0f, 0.0f, 1.0f}}, 2); immUniform1f("dash_width", active ? 4.0f : 2.0f); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2f(shdr_pos, x, y1); immVertex2f(shdr_pos, x, y2); immEnd(); @@ -1419,8 +1419,8 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti float sizey_solid = sizey * 0.25f; float y1 = rect->ymin; - Gwn_VertFormat *format = immVertexFormat(); - pos_id = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + pos_id = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_CHECKER); /* Drawing the checkerboard. */ @@ -1432,8 +1432,8 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti /* New format */ format = immVertexFormat(); - pos_id = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - col_id = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); + pos_id = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + col_id = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR); /* layer: color ramp */ @@ -1447,7 +1447,7 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti v1[1] = y1 + sizey_solid; v2[1] = rect->ymax; - immBegin(GWN_PRIM_TRI_STRIP, (sizex + 1) * 2); + immBegin(GPU_PRIM_TRI_STRIP, (sizex + 1) * 2); for (int a = 0; a <= sizex; a++) { float pos = ((float)a) / sizex; BKE_colorband_evaluate(coba, pos, colf); @@ -1466,7 +1466,7 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti v1[1] = y1; v2[1] = y1 + sizey_solid; - immBegin(GWN_PRIM_TRI_STRIP, (sizex + 1) * 2); + immBegin(GPU_PRIM_TRI_STRIP, (sizex + 1) * 2); for (int a = 0; a <= sizex; a++) { float pos = ((float)a) / sizex; BKE_colorband_evaluate(coba, pos, colf); @@ -1487,7 +1487,7 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti /* New format */ format = immVertexFormat(); - pos_id = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + pos_id = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); /* layer: box outline */ @@ -1498,14 +1498,14 @@ void ui_draw_but_COLORBAND(uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti GPU_blend(true); immUniformColor4f(0.0f, 0.0f, 0.0f, 0.5f); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2f(pos_id, x1, y1); immVertex2f(pos_id, x1 + sizex, y1); immEnd(); immUniformColor4f(1.0f, 1.0f, 1.0f, 0.25f); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2f(pos_id, x1, y1 - 1); immVertex2f(pos_id, x1 + sizex, y1 - 1); immEnd(); @@ -1548,28 +1548,28 @@ void ui_draw_but_UNITVEC(uiBut *but, uiWidgetColors *wcol, const rcti *rect) ui_but_v3_get(but, light); /* transform to button */ - gpuPushMatrix(); + GPU_matrix_push(); if (BLI_rcti_size_x(rect) < BLI_rcti_size_y(rect)) size = 0.5f * BLI_rcti_size_x(rect); else size = 0.5f * BLI_rcti_size_y(rect); - gpuTranslate2f(rect->xmin + 0.5f * BLI_rcti_size_x(rect), rect->ymin + 0.5f * BLI_rcti_size_y(rect)); - gpuScaleUniform(size); + GPU_matrix_translate_2f(rect->xmin + 0.5f * BLI_rcti_size_x(rect), rect->ymin + 0.5f * BLI_rcti_size_y(rect)); + GPU_matrix_scale_1f(size); - Gwn_Batch *sphere = GPU_batch_preset_sphere(2); - GWN_batch_program_set_builtin(sphere, GPU_SHADER_SIMPLE_LIGHTING); - GWN_batch_uniform_4f(sphere, "color", diffuse[0], diffuse[1], diffuse[2], 1.0f); - GWN_batch_uniform_3fv(sphere, "light", light); - GWN_batch_draw(sphere); + GPUBatch *sphere = GPU_batch_preset_sphere(2); + GPU_batch_program_set_builtin(sphere, GPU_SHADER_SIMPLE_LIGHTING); + GPU_batch_uniform_4f(sphere, "color", diffuse[0], diffuse[1], diffuse[2], 1.0f); + GPU_batch_uniform_3fv(sphere, "light", light); + GPU_batch_draw(sphere); /* restore */ glDisable(GL_CULL_FACE); /* AA circle */ - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor3ubv((unsigned char *)wcol->inner); @@ -1580,7 +1580,7 @@ void ui_draw_but_UNITVEC(uiBut *but, uiWidgetColors *wcol, const rcti *rect) GPU_line_smooth(false); /* matrix after circle */ - gpuPopMatrix(); + GPU_matrix_pop(); immUnbindProgram(); } @@ -1599,7 +1599,7 @@ static void ui_draw_but_curve_grid(unsigned int pos, const rcti *rect, float zoo floorf((rect->xmax - fx) / dx) + 1.0f + floorf((rect->ymax - fy) / dy) + 1.0f); - immBegin(GWN_PRIM_LINES, (int)line_count * 2); + immBegin(GPU_PRIM_LINES, (int)line_count * 2); while (fx < rect->xmax) { immVertex2f(pos, fx, rect->ymin); immVertex2f(pos, fx, rect->ymax); @@ -1675,8 +1675,8 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, const rcti GPU_line_width(1.0f); - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); /* backdrop */ @@ -1712,7 +1712,7 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, const rcti ui_draw_but_curve_grid(pos, rect, zoomx, zoomy, offsx, offsy, 1.0f); /* axes */ gl_shaded_color((unsigned char *)wcol->inner, -50); - immBegin(GWN_PRIM_LINES, 4); + immBegin(GPU_PRIM_LINES, 4); immVertex2f(pos, rect->xmin, rect->ymin + zoomy * (-offsy)); immVertex2f(pos, rect->xmax, rect->ymin + zoomy * (-offsy)); immVertex2f(pos, rect->xmin + zoomx * (-offsx), rect->ymin); @@ -1725,7 +1725,7 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, const rcti #if 0 if (cumap->flag & CUMA_DRAW_CFRA) { immUniformColor3ub(0x60, 0xc0, 0x40); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2f(pos, rect->xmin + zoomx * (cumap->sample[0] - offsx), rect->ymin); immVertex2f(pos, rect->xmin + zoomx * (cumap->sample[0] - offsx), rect->ymax); immEnd(); @@ -1734,7 +1734,7 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, const rcti /* sample option */ if (cumap->flag & CUMA_DRAW_SAMPLE) { - immBegin(GWN_PRIM_LINES, 2); /* will draw one of the following 3 lines */ + immBegin(GPU_PRIM_LINES, 2); /* will draw one of the following 3 lines */ if (but->a1 == UI_GRAD_H) { float tsample[3]; float hsv[3]; @@ -1770,7 +1770,7 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, const rcti immUniformColor3ubv((unsigned char *)wcol->item); GPU_line_smooth(true); GPU_blend(true); - immBegin(GWN_PRIM_LINE_STRIP, (CM_TABLE + 1) + 2); + immBegin(GPU_PRIM_LINE_STRIP, (CM_TABLE + 1) + 2); if (cuma->table == NULL) curvemapping_changed(cumap, false); @@ -1807,13 +1807,13 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, const rcti /* the points, use aspect to make them visible on edges */ format = immVertexFormat(); - pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint col = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); + pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint col = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR); cmp = cuma->curve; GPU_point_size(3.0f); - immBegin(GWN_PRIM_POINTS, cuma->totpoint); + immBegin(GPU_PRIM_POINTS, cuma->totpoint); for (int a = 0; a < cuma->totpoint; a++) { float color[4]; if (cmp[a].flag & CUMA_SELECT) @@ -1833,7 +1833,7 @@ void ui_draw_but_CURVE(ARegion *ar, uiBut *but, uiWidgetColors *wcol, const rcti /* outline */ format = immVertexFormat(); - pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor3ubv((unsigned char *)wcol->outline); @@ -1900,7 +1900,7 @@ void ui_draw_but_TRACKPREVIEW(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *U } if (!ok && scopes->track_preview) { - gpuPushMatrix(); + GPU_matrix_push(); /* draw content of pattern area */ GPU_scissor(rect.xmin, rect.ymin, scissor[2], scissor[3]); @@ -1919,23 +1919,23 @@ void ui_draw_but_TRACKPREVIEW(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *U immDrawPixelsTex(&state, rect.xmin, rect.ymin + 1, drawibuf->x, drawibuf->y, GL_RGBA, GL_UNSIGNED_BYTE, GL_LINEAR, drawibuf->rect, 1.0f, 1.0f, NULL); /* draw cross for pixel position */ - gpuTranslate2f(rect.xmin + scopes->track_pos[0], rect.ymin + scopes->track_pos[1]); + GPU_matrix_translate_2f(rect.xmin + scopes->track_pos[0], rect.ymin + scopes->track_pos[1]); GPU_scissor( rect.xmin, rect.ymin, BLI_rctf_size_x(&rect), BLI_rctf_size_y(&rect)); - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint col = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint col = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR); UI_GetThemeColor4fv(TH_SEL_MARKER, col_sel); UI_GetThemeColor4fv(TH_MARKER_OUTLINE, col_outline); /* Do stipple cross with geometry */ - immBegin(GWN_PRIM_LINES, 7 * 2 * 2); + immBegin(GPU_PRIM_LINES, 7 * 2 * 2); float pos_sel[8] = {-10.0f, -7.0f, -4.0f, -1.0f, 2.0f, 5.0f, 8.0f, 11.0f}; for (int axe = 0; axe < 2; ++axe) { for (int i = 0; i < 7; ++i) { @@ -1958,7 +1958,7 @@ void ui_draw_but_TRACKPREVIEW(ARegion *UNUSED(ar), uiBut *but, uiWidgetColors *U immUnbindProgram(); } - gpuPopMatrix(); + GPU_matrix_pop(); ok = true; } @@ -2018,13 +2018,13 @@ void ui_draw_but_NODESOCKET(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol float x = 0.5f * (recti->xmin + recti->xmax); float y = 0.5f * (recti->ymin + recti->ymax); - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4ubv(but->col); GPU_blend(true); - immBegin(GWN_PRIM_TRI_FAN, 16); + immBegin(GPU_PRIM_TRI_FAN, 16); for (int a = 0; a < 16; a++) immVertex2f(pos, x + size * si[a], y + size * co[a]); immEnd(); @@ -2032,7 +2032,7 @@ void ui_draw_but_NODESOCKET(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol immUniformColor4ub(0, 0, 0, 150); GPU_line_width(1); GPU_line_smooth(true); - immBegin(GWN_PRIM_LINE_LOOP, 16); + immBegin(GPU_PRIM_LINE_LOOP, 16); for (int a = 0; a < 16; a++) immVertex2f(pos, x + size * si[a], y + size * co[a]); immEnd(); @@ -2115,13 +2115,13 @@ void UI_draw_box_shadow(unsigned char alpha, float minx, float miny, float maxx, { GPU_blend(true); - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT); immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR); - immBegin(GWN_PRIM_TRIS, 54); + immBegin(GPU_PRIM_TRIS, 54); /* accumulated outline boxes to make shade not linear, is more pleasant */ ui_shadowbox(pos, color, minx, miny, maxx, maxy, 11.0, (20 * alpha) >> 8); @@ -2186,11 +2186,11 @@ void ui_draw_dropshadow(const rctf *rct, float radius, float aspect, float alpha .alpha_discard = 1.0f, }; - Gwn_Batch *batch = ui_batch_roundbox_shadow_get(); - GWN_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_SHADOW); - GWN_batch_uniform_4fv_array(batch, "parameters", 4, (float *)&widget_params); - GWN_batch_uniform_1f(batch, "alpha", 1.0f - visibility); - GWN_batch_draw(batch); + GPUBatch *batch = ui_batch_roundbox_shadow_get(); + GPU_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_SHADOW); + GPU_batch_uniform_4fv_array(batch, "parameters", 4, (float *)&widget_params); + GPU_batch_uniform_1f(batch, "alpha", 1.0f - visibility); + GPU_batch_draw(batch); /* outline emphasis */ GPU_line_smooth(true); diff --git a/source/blender/editors/interface/interface_eyedropper.c b/source/blender/editors/interface/interface_eyedropper.c index eb8fff471e2..424019995ad 100644 --- a/source/blender/editors/interface/interface_eyedropper.c +++ b/source/blender/editors/interface/interface_eyedropper.c @@ -82,6 +82,7 @@ wmKeyMap *eyedropper_modal_keymap(wmKeyConfig *keyconf) /* assign to operators */ WM_modalkeymap_assign(keymap, "UI_OT_eyedropper_colorband"); WM_modalkeymap_assign(keymap, "UI_OT_eyedropper_color"); + WM_modalkeymap_assign(keymap, "UI_OT_eyedropper_color_crypto"); WM_modalkeymap_assign(keymap, "UI_OT_eyedropper_id"); WM_modalkeymap_assign(keymap, "UI_OT_eyedropper_depth"); WM_modalkeymap_assign(keymap, "UI_OT_eyedropper_driver"); diff --git a/source/blender/editors/interface/interface_eyedropper_color.c b/source/blender/editors/interface/interface_eyedropper_color.c index 73efc59feb7..bcce70d9d8a 100644 --- a/source/blender/editors/interface/interface_eyedropper_color.c +++ b/source/blender/editors/interface/interface_eyedropper_color.c @@ -36,6 +36,7 @@ #include "DNA_screen_types.h" #include "BLI_math_vector.h" +#include "BLI_string.h" #include "BKE_context.h" #include "BKE_main.h" @@ -72,6 +73,8 @@ typedef struct Eyedropper { bool accum_start; /* has mouse been pressed */ float accum_col[3]; int accum_tot; + + bool accumulate; /* Color picking for cryptomatte, without accumulation. */ } Eyedropper; static bool eyedropper_init(bContext *C, wmOperator *op) @@ -80,6 +83,7 @@ static bool eyedropper_init(bContext *C, wmOperator *op) Eyedropper *eye; op->customdata = eye = MEM_callocN(sizeof(Eyedropper), "Eyedropper"); + eye->accumulate = !STREQ(op->type->idname, "UI_OT_eyedropper_color_crypto"); UI_context_active_but_prop_get(C, &eye->ptr, &eye->prop, &eye->index); @@ -207,29 +211,30 @@ static void eyedropper_color_set(bContext *C, Eyedropper *eye, const float col[3 RNA_property_update(C, &eye->ptr, eye->prop); } -/* set sample from accumulated values */ -static void eyedropper_color_set_accum(bContext *C, Eyedropper *eye) -{ - float col[3]; - mul_v3_v3fl(col, eye->accum_col, 1.0f / (float)eye->accum_tot); - eyedropper_color_set(C, eye, col); -} - -/* single point sample & set */ static void eyedropper_color_sample(bContext *C, Eyedropper *eye, int mx, int my) { + /* Accumulate color. */ float col[3]; eyedropper_color_sample_fl(C, mx, my, col); - eyedropper_color_set(C, eye, col); -} -static void eyedropper_color_sample_accum(bContext *C, Eyedropper *eye, int mx, int my) -{ - float col[3]; - eyedropper_color_sample_fl(C, mx, my, col); - /* delay linear conversion */ - add_v3_v3(eye->accum_col, col); - eye->accum_tot++; + if (eye->accumulate) { + add_v3_v3(eye->accum_col, col); + eye->accum_tot++; + } + else { + copy_v3_v3(eye->accum_col, col); + eye->accum_tot = 1; + } + + /* Apply to property. */ + float accum_col[3]; + if (eye->accum_tot > 1) { + mul_v3_v3fl(accum_col, eye->accum_col, 1.0f / (float)eye->accum_tot); + } + else { + copy_v3_v3(accum_col, eye->accum_col); + } + eyedropper_color_set(C, eye, accum_col); } static void eyedropper_cancel(bContext *C, wmOperator *op) @@ -254,29 +259,24 @@ static int eyedropper_modal(bContext *C, wmOperator *op, const wmEvent *event) if (eye->accum_tot == 0) { eyedropper_color_sample(C, eye, event->x, event->y); } - else { - eyedropper_color_set_accum(C, eye); - } eyedropper_exit(C, op); return OPERATOR_FINISHED; case EYE_MODAL_SAMPLE_BEGIN: /* enable accum and make first sample */ eye->accum_start = true; - eyedropper_color_sample_accum(C, eye, event->x, event->y); + eyedropper_color_sample(C, eye, event->x, event->y); break; case EYE_MODAL_SAMPLE_RESET: eye->accum_tot = 0; zero_v3(eye->accum_col); - eyedropper_color_sample_accum(C, eye, event->x, event->y); - eyedropper_color_set_accum(C, eye); + eyedropper_color_sample(C, eye, event->x, event->y); break; } } - else if (event->type == MOUSEMOVE) { + else if (ELEM(event->type, MOUSEMOVE, INBETWEEN_MOUSEMOVE)) { if (eye->accum_start) { /* button is pressed so keep sampling */ - eyedropper_color_sample_accum(C, eye, event->x, event->y); - eyedropper_color_set_accum(C, eye); + eyedropper_color_sample(C, eye, event->x, event->y); } } @@ -297,7 +297,7 @@ static int eyedropper_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED( } else { eyedropper_exit(C, op); - return OPERATOR_CANCELLED; + return OPERATOR_PASS_THROUGH; } } @@ -315,26 +315,15 @@ static int eyedropper_exec(bContext *C, wmOperator *op) return OPERATOR_FINISHED; } else { - return OPERATOR_CANCELLED; + return OPERATOR_PASS_THROUGH; } } static bool eyedropper_poll(bContext *C) { - PointerRNA ptr; - PropertyRNA *prop; - int index_dummy; - uiBut *but; - - /* Only color buttons */ - if ((CTX_wm_window(C) != NULL) && - (but = UI_context_active_but_prop_get(C, &ptr, &prop, &index_dummy)) && - (but->type == UI_BTYPE_COLOR)) - { - return 1; - } - - return 0; + /* Actual test for active button happens later, since we don't + * know which one is active until mouse over. */ + return (CTX_wm_window(C) != NULL); } void UI_OT_eyedropper_color(wmOperatorType *ot) @@ -353,6 +342,22 @@ void UI_OT_eyedropper_color(wmOperatorType *ot) /* flags */ ot->flag = OPTYPE_BLOCKING | OPTYPE_INTERNAL; +} + +void UI_OT_eyedropper_color_crypto(wmOperatorType *ot) +{ + /* identifiers */ + ot->name = "Cryptomatte Eyedropper"; + ot->idname = "UI_OT_eyedropper_color_crypto"; + ot->description = "Pick a color from Cryptomatte node Pick output image"; - /* properties */ + /* api callbacks */ + ot->invoke = eyedropper_invoke; + ot->modal = eyedropper_modal; + ot->cancel = eyedropper_cancel; + ot->exec = eyedropper_exec; + ot->poll = eyedropper_poll; + + /* flags */ + ot->flag = OPTYPE_BLOCKING | OPTYPE_INTERNAL; } diff --git a/source/blender/editors/interface/interface_icons.c b/source/blender/editors/interface/interface_icons.c index 62413e2434c..4f77b797ec0 100644 --- a/source/blender/editors/interface/interface_icons.c +++ b/source/blender/editors/interface/interface_icons.c @@ -47,6 +47,7 @@ #include "DNA_brush_types.h" #include "DNA_curve_types.h" #include "DNA_dynamicpaint_types.h" +#include "DNA_gpencil_types.h" #include "DNA_object_types.h" #include "DNA_screen_types.h" #include "DNA_space_types.h" @@ -109,6 +110,7 @@ typedef void (*VectorDrawFunc)(int x, int y, int w, int h, float alpha); #define ICON_TYPE_VECTOR 4 #define ICON_TYPE_GEOM 5 #define ICON_TYPE_EVENT 6 /* draw keymap entries using custom renderer. */ +#define ICON_TYPE_GPLAYER 7 typedef struct DrawInfo { int type; @@ -250,11 +252,11 @@ static void vicon_small_tri_right_draw(int x, int y, int w, int UNUSED(h), float viconutil_set_point(pts[1], cx - d2, cy - d); viconutil_set_point(pts[2], cx + d2, cy); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4f(0.2f, 0.2f, 0.2f, alpha); - immBegin(GWN_PRIM_TRIS, 3); + immBegin(GPU_PRIM_TRIS, 3); immVertex2iv(pos, pts[0]); immVertex2iv(pos, pts[1]); immVertex2iv(pos, pts[2]); @@ -280,15 +282,15 @@ static void vicon_keytype_draw_wrapper(int x, int y, int w, int h, float alpha, int xco = x + w / 2; int yco = y + h / 2; - Gwn_VertFormat *format = immVertexFormat(); - uint pos_id = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint size_id = GWN_vertformat_attr_add(format, "size", GWN_COMP_F32, 1, GWN_FETCH_FLOAT); - uint color_id = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); - uint outline_color_id = GWN_vertformat_attr_add(format, "outlineColor", GWN_COMP_U8, 4, GWN_FETCH_INT_TO_FLOAT_UNIT); + GPUVertFormat *format = immVertexFormat(); + uint pos_id = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint size_id = GPU_vertformat_attr_add(format, "size", GPU_COMP_F32, 1, GPU_FETCH_FLOAT); + uint color_id = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT); + uint outline_color_id = GPU_vertformat_attr_add(format, "outlineColor", GPU_COMP_U8, 4, GPU_FETCH_INT_TO_FLOAT_UNIT); immBindBuiltinProgram(GPU_SHADER_KEYFRAME_DIAMOND); GPU_enable_program_point_size(); - immBegin(GWN_PRIM_POINTS, 1); + immBegin(GPU_PRIM_POINTS, 1); /* draw keyframe * - size: 0.6 * h (found out experimentally... dunno why!) @@ -343,7 +345,7 @@ static void vicon_colorset_draw(int index, int x, int y, int w, int h, float UNU const int b = x + w / 3 * 2; const int c = x + w; - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); /* XXX: Include alpha into this... */ @@ -391,6 +393,28 @@ DEF_VICON_COLORSET_DRAW_NTH(20, 19) #undef DEF_VICON_COLORSET_DRAW_NTH +/* Dynamically render icon instead of rendering a plain color to a texture/buffer + * This is mot strictly a "vicon", as it needs access to icon->obj to get the color info, + * but it works in a very similar way. + */ +static void vicon_gplayer_color_draw(Icon *icon, int x, int y, int w, int h) +{ + bGPDlayer *gpl = (bGPDlayer *)icon->obj; + + /* Just draw a colored rect - Like for vicon_colorset_draw() */ + /* TODO: Make this have rounded corners, and maybe be a bit smaller. + * However, UI_draw_roundbox_aa() draws the colors too dark, so can't be used. + */ + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); + immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); + + immUniformColor3fv(gpl->color); + immRecti(pos, x, y, x + w - 1, y + h - 1); + + immUnbindProgram(); +} + + #ifndef WITH_HEADLESS static void init_brush_icons(void) @@ -443,6 +467,30 @@ static void init_brush_icons(void) INIT_BRUSH_ICON(ICON_BRUSH_ROTATE, twist); INIT_BRUSH_ICON(ICON_BRUSH_VERTEXDRAW, vertexdraw); + /* grease pencil sculpt */ + INIT_BRUSH_ICON(ICON_GPBRUSH_SMOOTH, gp_brush_smooth); + INIT_BRUSH_ICON(ICON_GPBRUSH_THICKNESS, gp_brush_thickness); + INIT_BRUSH_ICON(ICON_GPBRUSH_STRENGTH, gp_brush_strength); + INIT_BRUSH_ICON(ICON_GPBRUSH_GRAB, gp_brush_grab); + INIT_BRUSH_ICON(ICON_GPBRUSH_PUSH, gp_brush_push); + INIT_BRUSH_ICON(ICON_GPBRUSH_TWIST, gp_brush_twist); + INIT_BRUSH_ICON(ICON_GPBRUSH_PINCH, gp_brush_pinch); + INIT_BRUSH_ICON(ICON_GPBRUSH_RANDOMIZE, gp_brush_randomize); + INIT_BRUSH_ICON(ICON_GPBRUSH_CLONE, gp_brush_clone); + INIT_BRUSH_ICON(ICON_GPBRUSH_WEIGHT, gp_brush_weight); + + /* grease pencil drawing brushes */ + INIT_BRUSH_ICON(ICON_GPBRUSH_PENCIL, gp_brush_pencil); + INIT_BRUSH_ICON(ICON_GPBRUSH_PEN, gp_brush_pen); + INIT_BRUSH_ICON(ICON_GPBRUSH_INK, gp_brush_ink); + INIT_BRUSH_ICON(ICON_GPBRUSH_INKNOISE, gp_brush_inknoise); + INIT_BRUSH_ICON(ICON_GPBRUSH_BLOCK, gp_brush_block); + INIT_BRUSH_ICON(ICON_GPBRUSH_MARKER, gp_brush_marker); + INIT_BRUSH_ICON(ICON_GPBRUSH_FILL, gp_brush_fill); + INIT_BRUSH_ICON(ICON_GPBRUSH_ERASE_SOFT, gp_brush_erase_soft); + INIT_BRUSH_ICON(ICON_GPBRUSH_ERASE_HARD, gp_brush_erase_hard); + INIT_BRUSH_ICON(ICON_GPBRUSH_ERASE_STROKE, gp_brush_erase_stroke); + #undef INIT_BRUSH_ICON } @@ -877,6 +925,9 @@ static DrawInfo *icon_create_drawinfo(Icon *icon) else if (icon_data_type == ICON_DATA_STUDIOLIGHT) { di->type = ICON_TYPE_BUFFER; } + else if (icon_data_type == ICON_DATA_GPLAYER) { + di->type = ICON_TYPE_GPLAYER; + } else { BLI_assert(0); } @@ -934,9 +985,8 @@ int UI_icon_get_height(int icon_id) return 0; } -void UI_icons_init(int first_dyn_id) +void UI_icons_init() { - BKE_icons_init(first_dyn_id); #ifndef WITH_HEADLESS init_iconfile_list(&iconfilelist); init_internal_icons(); @@ -1262,7 +1312,7 @@ static void icon_draw_cache_flush_ex(void) glUniform1i(img_loc, 0); glUniform4fv(data_loc, ICON_DRAW_CACHE_SIZE * 3, (float *)g_icon_draw_cache.drawcall_cache); - GWN_draw_primitive(GWN_PRIM_TRIS, 6 * g_icon_draw_cache.calls); + GPU_draw_primitive(GPU_PRIM_TRIS, 6 * g_icon_draw_cache.calls); glBindTexture(GL_TEXTURE_2D, 0); @@ -1292,7 +1342,7 @@ static void icon_draw_texture_cached( { float mvp[4][4]; - gpuGetModelViewProjectionMatrix(mvp); + GPU_matrix_model_view_projection_get(mvp); IconDrawCall *call = &g_icon_draw_cache.drawcall_cache[g_icon_draw_cache.calls]; g_icon_draw_cache.calls++; @@ -1342,14 +1392,14 @@ static void icon_draw_texture( GPUShader *shader = GPU_shader_get_builtin_shader(GPU_SHADER_2D_IMAGE_RECT_COLOR); GPU_shader_bind(shader); - if (rgb) glUniform4f(GPU_shader_get_builtin_uniform(shader, GWN_UNIFORM_COLOR), rgb[0], rgb[1], rgb[2], alpha); - else glUniform4f(GPU_shader_get_builtin_uniform(shader, GWN_UNIFORM_COLOR), alpha, alpha, alpha, alpha); + if (rgb) glUniform4f(GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_COLOR), rgb[0], rgb[1], rgb[2], alpha); + else glUniform4f(GPU_shader_get_builtin_uniform(shader, GPU_UNIFORM_COLOR), alpha, alpha, alpha, alpha); glUniform1i(GPU_shader_get_uniform(shader, "image"), 0); glUniform4f(GPU_shader_get_uniform(shader, "rect_icon"), x1, y1, x2, y2); glUniform4f(GPU_shader_get_uniform(shader, "rect_geom"), x, y, x + w, y + h); - GWN_draw_primitive(GWN_PRIM_TRI_STRIP, 4); + GPU_draw_primitive(GPU_PRIM_TRI_STRIP, 4); glBindTexture(GL_TEXTURE_2D, 0); } @@ -1485,6 +1535,15 @@ static void icon_draw_size( GPU_blend_set_func_separate(GPU_SRC_ALPHA, GPU_ONE_MINUS_SRC_ALPHA, GPU_ONE, GPU_ONE_MINUS_SRC_ALPHA); } } + else if (di->type == ICON_TYPE_GPLAYER) { + BLI_assert(icon->obj != NULL); + + /* We need to flush widget base first to ensure correct ordering. */ + UI_widgetbase_draw_cache_flush(); + + /* Just draw a colored rect - Like for vicon_colorset_draw() */ + vicon_gplayer_color_draw(icon, (int)x, (int)y, w, h); + } } static void ui_id_preview_image_render_size( @@ -1577,7 +1636,45 @@ static int ui_id_brush_get_icon(const bContext *C, ID *id) } /* reset the icon */ - if (mode == OB_MODE_SCULPT) { + if (ob->mode & OB_MODE_GPENCIL_PAINT) { + switch (br->gpencil_settings->icon_id) { + case GP_BRUSH_ICON_PENCIL: + br->id.icon_id = ICON_GPBRUSH_PENCIL; + break; + case GP_BRUSH_ICON_PEN: + br->id.icon_id = ICON_GPBRUSH_PEN; + break; + case GP_BRUSH_ICON_INK: + br->id.icon_id = ICON_GPBRUSH_INK; + break; + case GP_BRUSH_ICON_INKNOISE: + br->id.icon_id = ICON_GPBRUSH_INKNOISE; + break; + case GP_BRUSH_ICON_BLOCK: + br->id.icon_id = ICON_GPBRUSH_BLOCK; + break; + case GP_BRUSH_ICON_MARKER: + br->id.icon_id = ICON_GPBRUSH_MARKER; + break; + case GP_BRUSH_ICON_FILL: + br->id.icon_id = ICON_GPBRUSH_FILL; + break; + case GP_BRUSH_ICON_ERASE_SOFT: + br->id.icon_id = ICON_GPBRUSH_ERASE_SOFT; + break; + case GP_BRUSH_ICON_ERASE_HARD: + br->id.icon_id = ICON_GPBRUSH_ERASE_HARD; + break; + case GP_BRUSH_ICON_ERASE_STROKE: + br->id.icon_id = ICON_GPBRUSH_ERASE_STROKE; + break; + default: + br->id.icon_id = ICON_GPBRUSH_PEN; + break; + } + return id->icon_id; + } + else if (mode == OB_MODE_SCULPT) { items = rna_enum_brush_sculpt_tool_items; tool = br->sculpt_tool; } diff --git a/source/blender/editors/interface/interface_icons_event.c b/source/blender/editors/interface/interface_icons_event.c index dc444b98b2c..fabf5f9bf48 100644 --- a/source/blender/editors/interface/interface_icons_event.c +++ b/source/blender/editors/interface/interface_icons_event.c @@ -136,8 +136,8 @@ static void icon_draw_rect_input_line_prim( { glEnable(GL_LINE_SMOOTH); glEnable(GL_BLEND); - BLI_assert(ELEM(prim, GWN_PRIM_LINE_LOOP, GWN_PRIM_LINE_STRIP)); - const uint pos_id = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + BLI_assert(ELEM(prim, GPU_PRIM_LINE_LOOP, GPU_PRIM_LINE_STRIP)); + const uint pos_id = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4fv(color); immBegin(prim, lines_len); @@ -289,7 +289,7 @@ void icon_draw_rect_input( else if (event_type == SPACEKEY) { const uchar lines[] = {60, 118, 60, 60, 195, 60, 195, 118}; icon_draw_rect_input_line_prim( - &rect, color, GWN_PRIM_LINE_STRIP, + &rect, color, GPU_PRIM_LINE_STRIP, (const void *)lines, ARRAY_SIZE(lines) / 2); } } diff --git a/source/blender/editors/interface/interface_intern.h b/source/blender/editors/interface/interface_intern.h index ffc389c6dfd..f7507223f31 100644 --- a/source/blender/editors/interface/interface_intern.h +++ b/source/blender/editors/interface/interface_intern.h @@ -752,9 +752,9 @@ enum { ROUNDBOX_TRIA_MAX, /* don't use */ }; -struct Gwn_Batch *ui_batch_roundbox_get(bool filled, bool antialiased); -struct Gwn_Batch *ui_batch_roundbox_widget_get(int tria); -struct Gwn_Batch *ui_batch_roundbox_shadow_get(void); +struct GPUBatch *ui_batch_roundbox_get(bool filled, bool antialiased); +struct GPUBatch *ui_batch_roundbox_widget_get(int tria); +struct GPUBatch *ui_batch_roundbox_shadow_get(void); void ui_draw_anti_tria_rect(const rctf *rect, char dir, const float color[4]); void ui_draw_menu_back(struct uiStyle *style, uiBlock *block, rcti *rect); @@ -780,7 +780,7 @@ void ui_draw_preview_item(struct uiFontStyle *fstyle, rcti *rect, const char *na #define UI_POPUP_MENU_TOP (int)(8 * UI_DPI_FAC) #define UI_PIXEL_AA_JITTER 8 -const float ui_pixel_jitter[UI_PIXEL_AA_JITTER][2]; +extern const float ui_pixel_jitter[UI_PIXEL_AA_JITTER][2]; /* interface_style.c */ void uiStyleInit(void); @@ -831,7 +831,9 @@ bool ui_but_is_toggle(const uiBut *but); bool ui_but_is_popover_once_compat(const uiBut *but); extern bool ui_block_is_menu(const uiBlock *block) ATTR_WARN_UNUSED_RESULT; +extern bool ui_block_is_popover(const uiBlock *block) ATTR_WARN_UNUSED_RESULT; extern bool ui_block_is_pie_menu(const uiBlock *block) ATTR_WARN_UNUSED_RESULT; +extern bool ui_block_is_popup_any(const uiBlock *block) ATTR_WARN_UNUSED_RESULT; /* interface_context_menu.c */ bool ui_popup_context_menu_for_button(struct bContext *C, uiBut *but); @@ -843,6 +845,7 @@ struct wmKeyMap *eyedropper_colorband_modal_keymap(struct wmKeyConfig *keyconf); /* interface_eyedropper_color.c */ void UI_OT_eyedropper_color(struct wmOperatorType *ot); +void UI_OT_eyedropper_color_crypto(struct wmOperatorType *ot); /* interface_eyedropper_colorband.c */ void UI_OT_eyedropper_colorband(struct wmOperatorType *ot); diff --git a/source/blender/editors/interface/interface_layout.c b/source/blender/editors/interface/interface_layout.c index 82ed4c5acba..f143d418fe3 100644 --- a/source/blender/editors/interface/interface_layout.c +++ b/source/blender/editors/interface/interface_layout.c @@ -1244,7 +1244,15 @@ void uiItemsFullEnumO( bool free; if (ui_layout_is_radial(layout)) { + /* XXX: While "_all()" guarantees spatial stability, it's bad when an enum has > 8 items total, + * but only a small subset will ever be shown at once (e.g. Mode Switch menu, after the + * introduction of GP editing modes) + */ +#if 0 RNA_property_enum_items_gettexted_all(block->evil_C, &ptr, prop, &item_array, &totitem, &free); +#else + RNA_property_enum_items_gettexted(block->evil_C, &ptr, prop, &item_array, &totitem, &free); +#endif } else { RNA_property_enum_items_gettexted(block->evil_C, &ptr, prop, &item_array, &totitem, &free); diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c index 96128aa29f0..ae0fe912f95 100644 --- a/source/blender/editors/interface/interface_ops.c +++ b/source/blender/editors/interface/interface_ops.c @@ -1243,7 +1243,7 @@ static void UI_OT_reloadtranslation(wmOperatorType *ot) ot->exec = reloadtranslation_exec; } -bool UI_drop_color_poll(struct bContext *C, wmDrag *drag, const wmEvent *UNUSED(event)) +bool UI_drop_color_poll(struct bContext *C, wmDrag *drag, const wmEvent *UNUSED(event), const char **UNUSED(tooltip)) { /* should only return true for regions that include buttons, for now * return true always */ @@ -1359,6 +1359,7 @@ void ED_operatortypes_ui(void) /* external */ WM_operatortype_append(UI_OT_eyedropper_color); + WM_operatortype_append(UI_OT_eyedropper_color_crypto); WM_operatortype_append(UI_OT_eyedropper_colorband); WM_operatortype_append(UI_OT_eyedropper_colorband_point); WM_operatortype_append(UI_OT_eyedropper_id); diff --git a/source/blender/editors/interface/interface_panel.c b/source/blender/editors/interface/interface_panel.c index 79d92eedfa3..aa67d58fd57 100644 --- a/source/blender/editors/interface/interface_panel.c +++ b/source/blender/editors/interface/interface_panel.c @@ -454,9 +454,9 @@ static void ui_offset_panel_block(uiBlock *block) /* triangle 'icon' for panel header */ void UI_draw_icon_tri(float x, float y, char dir, const float color[4]) { - float f3 = 0.15 * U.widget_unit; - float f5 = 0.25 * U.widget_unit; - float f7 = 0.35 * U.widget_unit; + float f3 = 0.05 * U.widget_unit; + float f5 = 0.15 * U.widget_unit; + float f7 = 0.25 * U.widget_unit; if (dir == 'h') { UI_draw_anti_tria(x - f3, y - f5, x - f3, y + f5, x + f7, y, color); @@ -478,7 +478,7 @@ static void ui_draw_anti_x(unsigned int pos, float x1, float y1, float x2, float GPU_line_width(2.0); - immBegin(GWN_PRIM_LINES, 4); + immBegin(GPU_PRIM_LINES, 4); immVertex2f(pos, x1, y1); immVertex2f(pos, x2, y2); @@ -519,7 +519,7 @@ static void ui_draw_panel_scalewidget(unsigned int pos, const rcti *rect) GPU_blend(true); immUniformColor4ub(255, 255, 255, 50); - immBegin(GWN_PRIM_LINES, 4); + immBegin(GPU_PRIM_LINES, 4); immVertex2f(pos, xmin, ymin); immVertex2f(pos, xmax, ymax); @@ -531,7 +531,7 @@ static void ui_draw_panel_scalewidget(unsigned int pos, const rcti *rect) immUniformColor4ub(0, 0, 0, 50); - immBegin(GWN_PRIM_LINES, 4); + immBegin(GPU_PRIM_LINES, 4); immVertex2f(pos, xmin, ymin + 1); immVertex2f(pos, xmax, ymax + 1); @@ -584,7 +584,7 @@ static void ui_draw_panel_dragwidget(unsigned int pos, unsigned int col, const r UI_GetThemeColorShade4fv(TH_PANEL_BACK, -col_tint, col_dark); /* draw multiple boxes */ - immBegin(GWN_PRIM_TRIS, 4 * 2 * (6 * 2)); + immBegin(GPU_PRIM_TRIS, 4 * 2 * (6 * 2)); for (i_x = 0; i_x < 4; i_x++) { for (i_y = 0; i_y < 2; i_y++) { const int x_co = (x_min + x_ofs) + (i_x * (box_size + box_margin)); @@ -677,7 +677,7 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, const rcti *rect, con titlerect.xmin += 5.0f / block->aspect; } - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); if (!is_subpanel) { @@ -691,7 +691,7 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, const rcti *rect, con immUniformThemeColor(TH_PANEL_HEADER); immRectf(pos, minx, headrect.ymin, maxx, y); - immBegin(GWN_PRIM_LINES, 4); + immBegin(GPU_PRIM_LINES, 4); immVertex2f(pos, minx, y); immVertex2f(pos, maxx, y); @@ -729,9 +729,9 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, const rcti *rect, con if (show_drag) { uint col; - Gwn_VertFormat *format = immVertexFormat(); - pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - col = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + col = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); /* itemrect smaller */ itemrect.xmax = headrect.xmax - 5.0f / block->aspect; @@ -745,7 +745,7 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, const rcti *rect, con immUnbindProgram(); /* Restore format for the following draws. */ - pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); } } @@ -758,7 +758,7 @@ void ui_draw_aligned_panel(uiStyle *style, uiBlock *block, const rcti *rect, con else if (is_closed_x) { /* draw vertical title */ ui_draw_aligned_panel_header(style, block, &headrect, 'v'); - pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); } /* an open panel */ else { @@ -1700,9 +1700,9 @@ static void ui_panel_category_draw_tab( {0.98, 0.805}}; int a; - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 3, GPU_FETCH_INT_TO_FLOAT_UNIT); /* mult */ for (a = 0; a < 4; a++) { @@ -1724,7 +1724,7 @@ static void ui_panel_category_draw_tab( immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR); - immBegin(filled ? GWN_PRIM_TRI_FAN : GWN_PRIM_LINE_STRIP, vert_len); + immBegin(filled ? GPU_PRIM_TRI_FAN : GPU_PRIM_LINE_STRIP, vert_len); /* start with corner right-top */ if (use_highlight) { @@ -1929,7 +1929,7 @@ void UI_panel_category_draw_all(ARegion *ar, const char *category_id_active) /* begin drawing */ GPU_line_smooth(true); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); /* draw the background */ @@ -1991,7 +1991,7 @@ void UI_panel_category_draw_all(ARegion *ar, const char *category_id_active) /* tab blackline */ if (!is_active) { - pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor3ubv(theme_col_tab_divider); @@ -2022,7 +2022,7 @@ void UI_panel_category_draw_all(ARegion *ar, const char *category_id_active) GPU_blend(false); /* tab blackline remaining (last tab) */ - pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); if (pc_dyn->prev == NULL) { immUniformColor3ubv(theme_col_tab_divider); diff --git a/source/blender/editors/interface/interface_query.c b/source/blender/editors/interface/interface_query.c index 66f63fef82d..d0f7e1341de 100644 --- a/source/blender/editors/interface/interface_query.c +++ b/source/blender/editors/interface/interface_query.c @@ -109,11 +109,25 @@ bool ui_block_is_menu(const uiBlock *block) ((block->flag & UI_BLOCK_KEEP_OPEN) == 0)); } +bool ui_block_is_popover(const uiBlock *block) +{ + return (block->flag & UI_BLOCK_POPOVER) != 0; +} + bool ui_block_is_pie_menu(const uiBlock *block) { return ((block->flag & UI_BLOCK_RADIAL) != 0); } +bool ui_block_is_popup_any(const uiBlock *block) +{ + return ( + ui_block_is_menu(block) || + ui_block_is_popover(block) || + ui_block_is_pie_menu(block) + ); +} + bool UI_block_is_empty(const uiBlock *block) { for (const uiBut *but = block->buttons.first; but; but = but->next) { diff --git a/source/blender/editors/interface/interface_region_tooltip.c b/source/blender/editors/interface/interface_region_tooltip.c index fae547d460c..97f501b7448 100644 --- a/source/blender/editors/interface/interface_region_tooltip.c +++ b/source/blender/editors/interface/interface_region_tooltip.c @@ -615,7 +615,7 @@ static uiTooltipData *ui_tooltip_data_from_button(bContext *C, uiBut *but) } } -static uiTooltipData *ui_tooltip_data_from_gizmo(bContext *C, wmGizmo *mpr) +static uiTooltipData *ui_tooltip_data_from_gizmo(bContext *C, wmGizmo *gz) { uiTooltipData *data = MEM_callocN(sizeof(uiTooltipData), "uiTooltipData"); @@ -623,23 +623,23 @@ static uiTooltipData *ui_tooltip_data_from_gizmo(bContext *C, wmGizmo *mpr) /* Operator Actions */ { - bool use_drag = mpr->drag_part != -1 && mpr->highlight_part != mpr->drag_part; + bool use_drag = gz->drag_part != -1 && gz->highlight_part != gz->drag_part; const struct { int part; const char *prefix; } mpop_actions[] = { { - .part = mpr->highlight_part, + .part = gz->highlight_part, .prefix = use_drag ? TIP_("Click") : NULL, }, { - .part = use_drag ? mpr->drag_part : -1, + .part = use_drag ? gz->drag_part : -1, .prefix = use_drag ? TIP_("Drag") : NULL, }, }; for (int i = 0; i < ARRAY_SIZE(mpop_actions); i++) { - wmGizmoOpElem *mpop = (mpop_actions[i].part != -1) ? WM_gizmo_operator_get(mpr, mpop_actions[i].part) : NULL; + wmGizmoOpElem *mpop = (mpop_actions[i].part != -1) ? WM_gizmo_operator_get(gz, mpop_actions[i].part) : NULL; if (mpop != NULL) { /* Description */ const char *info = RNA_struct_ui_description(mpop->type->srna); @@ -691,13 +691,13 @@ static uiTooltipData *ui_tooltip_data_from_gizmo(bContext *C, wmGizmo *mpr) } /* Property Actions */ - if (mpr->type->target_property_defs_len) { - wmGizmoProperty *mpr_prop_array = WM_gizmo_target_property_array(mpr); - for (int i = 0; i < mpr->type->target_property_defs_len; i++) { + if (gz->type->target_property_defs_len) { + wmGizmoProperty *gz_prop_array = WM_gizmo_target_property_array(gz); + for (int i = 0; i < gz->type->target_property_defs_len; i++) { /* TODO(campbell): function callback descriptions. */ - wmGizmoProperty *mpr_prop = &mpr_prop_array[i]; - if (mpr_prop->prop != NULL) { - const char *info = RNA_property_ui_description(mpr_prop->prop); + wmGizmoProperty *gz_prop = &gz_prop_array[i]; + if (gz_prop->prop != NULL) { + const char *info = RNA_property_ui_description(gz_prop->prop); if (info && info[0]) { uiTooltipField *field = text_field_add( data, &(uiTooltipFormat){ @@ -934,13 +934,13 @@ ARegion *UI_tooltip_create_from_button(bContext *C, ARegion *butregion, uiBut *b return ui_tooltip_create_with_data(C, data, init_position, aspect); } -ARegion *UI_tooltip_create_from_gizmo(bContext *C, wmGizmo *mpr) +ARegion *UI_tooltip_create_from_gizmo(bContext *C, wmGizmo *gz) { wmWindow *win = CTX_wm_window(C); const float aspect = 1.0f; float init_position[2]; - uiTooltipData *data = ui_tooltip_data_from_gizmo(C, mpr); + uiTooltipData *data = ui_tooltip_data_from_gizmo(C, gz); if (data == NULL) { return NULL; } diff --git a/source/blender/editors/interface/interface_style.c b/source/blender/editors/interface/interface_style.c index 36ad516bf7f..ed4c766c596 100644 --- a/source/blender/editors/interface/interface_style.c +++ b/source/blender/editors/interface/interface_style.c @@ -522,6 +522,35 @@ void uiStyleInit(void) BLF_size(blf_mono_font, 12 * U.pixelsize, 72); + /* Set default flags based on UI preferences (not render fonts) */ + { + int flag_enable = 0, flag_disable = 0; + if ((U.text_render & USER_TEXT_DISABLE_HINTING) == 0) { + flag_enable |= BLF_HINTING; + } + else { + flag_disable |= BLF_HINTING; + } + + if (U.text_render & USER_TEXT_DISABLE_AA) { + flag_enable |= BLF_MONOCHROME; + } + else { + flag_disable |= BLF_MONOCHROME; + } + + for (font = U.uifonts.first; font; font = font->next) { + if (font->blf_id != -1) { + BLF_enable(font->blf_id, flag_enable); + BLF_disable(font->blf_id, flag_disable); + } + } + if (blf_mono_font != -1) { + BLF_enable(blf_mono_font, flag_enable); + BLF_disable(blf_mono_font, flag_disable); + } + } + /** * Second for rendering else we get threading problems, * diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 6110d5f3466..e81ad1428d1 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -39,6 +39,8 @@ #include "DNA_object_force_types.h" #include "DNA_brush_types.h" #include "DNA_texture_types.h" +#include "DNA_gpencil_modifier_types.h" +#include "DNA_shader_fx_types.h" #include "BLI_utildefines.h" #include "BLI_alloca.h" @@ -57,6 +59,7 @@ #include "BKE_colortools.h" #include "BKE_context.h" #include "BKE_global.h" +#include "BKE_gpencil_modifier.h" #include "BKE_idcode.h" #include "BKE_idprop.h" #include "BKE_layer.h" @@ -71,6 +74,7 @@ #include "BKE_paint.h" #include "BKE_report.h" #include "BKE_screen.h" +#include "BKE_shader_fx.h" #include "DEG_depsgraph.h" #include "DEG_depsgraph_build.h" @@ -110,7 +114,7 @@ static void template_add_button_search_menu( const bContext *C, uiLayout *layout, uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, uiBlockCreateFunc block_func, void *block_argN, const char * const tip, - const bool use_previews, const bool editable) + const bool use_previews, const bool editable, const bool live_icon) { PointerRNA active_ptr = RNA_property_pointer_get(ptr, prop); ID *id = (active_ptr.data && RNA_struct_is_ID(active_ptr.type)) ? active_ptr.data : NULL; @@ -146,7 +150,14 @@ static void template_add_button_search_menu( } else { but = uiDefBlockButN(block, block_func, block_argN, "", 0, 0, UI_UNIT_X * 1.6, UI_UNIT_Y, tip); - ui_def_but_icon(but, RNA_struct_ui_icon(type), UI_HAS_ICON); + + if (live_icon) { + int icon = id ? ui_id_icon_get(C, id, false) : RNA_struct_ui_icon(type); + ui_def_but_icon(but, icon, UI_HAS_ICON | UI_BUT_ICON_PREVIEW); + } + else { + ui_def_but_icon(but, RNA_struct_ui_icon(type), UI_HAS_ICON); + } if (id) { /* default dragging of icon for id browse buttons */ UI_but_drag_set_id(but, id); @@ -162,7 +173,8 @@ static uiBlock *template_common_search_menu( const bContext *C, ARegion *region, uiButSearchFunc search_func, void *search_arg, uiButHandleFunc handle_func, void *active_item, - const int preview_rows, const int preview_cols) + const int preview_rows, const int preview_cols, + float scale) { static char search[256]; wmWindow *win = CTX_wm_window(C); @@ -177,8 +189,8 @@ static uiBlock *template_common_search_menu( /* preview thumbnails */ if (preview_rows > 0 && preview_cols > 0) { - const int w = 4 * U.widget_unit * preview_cols; - const int h = 5 * U.widget_unit * preview_rows; + const int w = 4 * U.widget_unit * preview_cols * scale; + const int h = 5 * U.widget_unit * preview_rows * scale; /* fake button, it holds space for search items */ uiDefBut(block, UI_BTYPE_LABEL, 0, "", 10, 26, w, h, NULL, 0, 0, 0, 0, NULL); @@ -237,6 +249,7 @@ typedef struct TemplateID { short filter; int prv_rows, prv_cols; bool preview; + float scale; } TemplateID; /* Search browse menu, assign */ @@ -382,7 +395,7 @@ static uiBlock *id_search_menu(bContext *C, ARegion *ar, void *arg_litem) return template_common_search_menu( C, ar, id_search_cb_p, &template_ui, template_ID_set_property_cb, active_item_ptr.data, - template_ui.prv_rows, template_ui.prv_cols); + template_ui.prv_rows, template_ui.prv_cols, template_ui.scale); } /************************ ID Template ***************************/ @@ -630,7 +643,8 @@ static uiBut *template_id_def_new_but( static void template_ID( bContext *C, uiLayout *layout, TemplateID *template_ui, StructRNA *type, int flag, - const char *newop, const char *openop, const char *unlinkop) + const char *newop, const char *openop, const char *unlinkop, + const bool live_icon) { uiBut *but; uiBlock *block; @@ -655,7 +669,7 @@ static void template_ID( template_add_button_search_menu( C, layout, block, &template_ui->ptr, template_ui->prop, id_search_menu, MEM_dupallocN(template_ui), TIP_(template_id_browse_tip(type)), - use_previews, editable); + use_previews, editable, live_icon); } /* text button with name */ @@ -860,7 +874,8 @@ static void ui_template_id( uiLayout *layout, bContext *C, PointerRNA *ptr, const char *propname, const char *newop, const char *openop, const char *unlinkop, - int flag, int prv_rows, int prv_cols, int filter, bool use_tabs) + int flag, int prv_rows, int prv_cols, int filter, bool use_tabs, + float scale, bool live_icon) { TemplateID *template_ui; PropertyRNA *prop; @@ -879,6 +894,7 @@ static void ui_template_id( template_ui->prop = prop; template_ui->prv_rows = prv_rows; template_ui->prv_cols = prv_cols; + template_ui->scale = scale; if ((flag & UI_ID_PIN) == 0) { template_ui->filter = filter; @@ -907,7 +923,7 @@ static void ui_template_id( } else { uiLayoutRow(layout, true); - template_ID(C, layout, template_ui, type, flag, newop, openop, unlinkop); + template_ID(C, layout, template_ui, type, flag, newop, openop, unlinkop, live_icon); } } @@ -916,13 +932,14 @@ static void ui_template_id( void uiTemplateID( uiLayout *layout, bContext *C, PointerRNA *ptr, const char *propname, const char *newop, - const char *openop, const char *unlinkop, int filter) + const char *openop, const char *unlinkop, + int filter, const bool live_icon) { ui_template_id( layout, C, ptr, propname, newop, openop, unlinkop, UI_ID_BROWSE | UI_ID_RENAME | UI_ID_DELETE, - 0, 0, filter, false); + 0, 0, filter, false, 1.0f, live_icon); } void uiTemplateIDBrowse( @@ -933,7 +950,7 @@ void uiTemplateIDBrowse( layout, C, ptr, propname, newop, openop, unlinkop, UI_ID_BROWSE | UI_ID_RENAME, - 0, 0, filter, false); + 0, 0, filter, false, 1.0f, false); } void uiTemplateIDPreview( @@ -944,7 +961,18 @@ void uiTemplateIDPreview( layout, C, ptr, propname, newop, openop, unlinkop, UI_ID_BROWSE | UI_ID_RENAME | UI_ID_DELETE | UI_ID_PREVIEWS, - rows, cols, filter, false); + rows, cols, filter, false, 1.0f, false); +} + +void uiTemplateGpencilColorPreview( + uiLayout *layout, bContext *C, PointerRNA *ptr, const char *propname, + int rows, int cols, float scale, int filter) +{ + ui_template_id( + layout, C, ptr, propname, + NULL, NULL, NULL, + UI_ID_BROWSE | UI_ID_PREVIEWS | UI_ID_DELETE, + rows, cols, filter, false, scale < 0.5f ? 0.5f : scale, false); } /** @@ -960,7 +988,7 @@ void uiTemplateIDTabs( layout, C, ptr, propname, newop, openop, unlinkop, UI_ID_BROWSE | UI_ID_RENAME | UI_ID_DELETE, - 0, 0, filter, true); + 0, 0, filter, true, 1.0f, false); } /************************ ID Chooser Template ***************************/ @@ -1057,12 +1085,12 @@ static uiBlock *template_search_menu(bContext *C, ARegion *region, void *arg_tem return template_common_search_menu( C, region, ui_rna_collection_search_cb, &template_search, template_search_handle_cb, active_ptr.data, - template_search.preview_rows, template_search.preview_cols); + template_search.preview_rows, template_search.preview_cols, 1.0f); } static void template_search_add_button_searchmenu( const bContext *C, uiLayout *layout, uiBlock *block, - TemplateSearch *template_search, const bool editable) + TemplateSearch *template_search, const bool editable, const bool live_icon) { const char *ui_description = RNA_property_ui_description(template_search->search_data.target_prop); @@ -1070,7 +1098,7 @@ static void template_search_add_button_searchmenu( C, layout, block, &template_search->search_data.target_ptr, template_search->search_data.target_prop, template_search_menu, MEM_dupallocN(template_search), ui_description, - template_search->use_previews, editable); + template_search->use_previews, editable, live_icon); } static void template_search_add_button_name( @@ -1116,7 +1144,7 @@ static void template_search_buttons( uiLayoutRow(layout, true); UI_block_align_begin(block); - template_search_add_button_searchmenu(C, layout, block, template_search, editable); + template_search_add_button_searchmenu(C, layout, block, template_search, editable, false); template_search_add_button_name(block, &active_ptr, type); template_search_add_button_operator(block, newop, WM_OP_INVOKE_DEFAULT, ICON_ZOOMIN, editable); template_search_add_button_operator(block, unlinkop, WM_OP_INVOKE_REGION_WIN, ICON_X, editable); @@ -1539,14 +1567,250 @@ uiLayout *uiTemplateModifier(uiLayout *layout, bContext *C, PointerRNA *ptr) return NULL; } +/************************ Grease Pencil Modifier Template *************************/ -/************************ Redo Buttons Template *************************/ +static uiLayout *gpencil_draw_modifier( + uiLayout *layout, Object *ob, + GpencilModifierData *md) +{ + const GpencilModifierTypeInfo *mti = BKE_gpencil_modifierType_getInfo(md->type); + PointerRNA ptr; + uiBlock *block; + uiLayout *box, *column, *row, *sub; + uiLayout *result = NULL; + + /* create RNA pointer */ + RNA_pointer_create(&ob->id, &RNA_GpencilModifier, md, &ptr); + + column = uiLayoutColumn(layout, true); + uiLayoutSetContextPointer(column, "modifier", &ptr); + + /* rounded header ------------------------------------------------------------------- */ + box = uiLayoutBox(column); + + row = uiLayoutRow(box, false); + block = uiLayoutGetBlock(row); + + UI_block_emboss_set(block, UI_EMBOSS_NONE); + /* Open/Close ................................. */ + uiItemR(row, &ptr, "show_expanded", 0, "", ICON_NONE); + + /* modifier-type icon */ + uiItemL(row, "", RNA_struct_ui_icon(ptr.type)); + UI_block_emboss_set(block, UI_EMBOSS); + + /* modifier name */ + if (mti->isDisabled && mti->isDisabled(md, 0)) { + uiLayoutSetRedAlert(row, true); + } + uiItemR(row, &ptr, "name", 0, "", ICON_NONE); + uiLayoutSetRedAlert(row, false); + + /* mode enabling buttons */ + UI_block_align_begin(block); + uiItemR(row, &ptr, "show_render", 0, "", ICON_NONE); + uiItemR(row, &ptr, "show_viewport", 0, "", ICON_NONE); -static bool template_operator_redo_property_buts_poll(PointerRNA *UNUSED(ptr), PropertyRNA *prop) + if (mti->flags & eGpencilModifierTypeFlag_SupportsEditmode) { + sub = uiLayoutRow(row, true); + uiLayoutSetActive(sub, false); + uiItemR(sub, &ptr, "show_in_editmode", 0, "", ICON_NONE); + } + + UI_block_align_end(block); + + /* Up/Down + Delete ........................... */ + UI_block_align_begin(block); + uiItemO(row, "", ICON_TRIA_UP, "OBJECT_OT_gpencil_modifier_move_up"); + uiItemO(row, "", ICON_TRIA_DOWN, "OBJECT_OT_gpencil_modifier_move_down"); + UI_block_align_end(block); + + UI_block_emboss_set(block, UI_EMBOSS_NONE); + uiItemO(row, "", ICON_X, "OBJECT_OT_gpencil_modifier_remove"); + UI_block_emboss_set(block, UI_EMBOSS); + + /* modifier settings (under the header) --------------------------------------------------- */ + if (md->mode & eGpencilModifierMode_Expanded) { + /* apply/convert/copy */ + box = uiLayoutBox(column); + row = uiLayoutRow(box, false); + + /* only here obdata, the rest of modifiers is ob level */ + UI_block_lock_set(block, BKE_object_obdata_is_libdata(ob), ERROR_LIBDATA_MESSAGE); + + uiLayoutSetOperatorContext(row, WM_OP_INVOKE_DEFAULT); + uiItemEnumO(row, "OBJECT_OT_gpencil_modifier_apply", CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Apply"), + 0, "apply_as", MODIFIER_APPLY_DATA); + + uiItemO(row, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Copy"), ICON_NONE, + "OBJECT_OT_gpencil_modifier_copy"); + + /* result is the layout block inside the box, that we return so that modifier settings can be drawn */ + result = uiLayoutColumn(box, false); + block = uiLayoutAbsoluteBlock(box); + } + + /* error messages */ + if (md->error) { + box = uiLayoutBox(column); + row = uiLayoutRow(box, false); + uiItemL(row, md->error, ICON_ERROR); + } + + return result; +} + +uiLayout *uiTemplateGpencilModifier(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) { - return (RNA_property_tags(prop) & OP_PROP_TAG_ADVANCED) == 0; + Object *ob; + GpencilModifierData *md, *vmd; + int i; + + /* verify we have valid data */ + if (!RNA_struct_is_a(ptr->type, &RNA_GpencilModifier)) { + RNA_warning("Expected modifier on object"); + return NULL; + } + + ob = ptr->id.data; + md = ptr->data; + + if (!ob || !(GS(ob->id.name) == ID_OB)) { + RNA_warning("Expected modifier on object"); + return NULL; + } + + UI_block_lock_set(uiLayoutGetBlock(layout), (ob && ID_IS_LINKED(ob)), ERROR_LIBDATA_MESSAGE); + + /* find modifier and draw it */ + vmd = ob->greasepencil_modifiers.first; + for (i = 0; vmd; i++, vmd = vmd->next) { + if (md == vmd) + return gpencil_draw_modifier(layout, ob, md); + } + + return NULL; } +/************************ Shader FX Template *************************/ + +static uiLayout *gpencil_draw_shaderfx(uiLayout *layout, Object *ob, + ShaderFxData *md) +{ + const ShaderFxTypeInfo *mti = BKE_shaderfxType_getInfo(md->type); + PointerRNA ptr; + uiBlock *block; + uiLayout *box, *column, *row, *sub; + uiLayout *result = NULL; + + /* create RNA pointer */ + RNA_pointer_create(&ob->id, &RNA_ShaderFx, md, &ptr); + + column = uiLayoutColumn(layout, true); + uiLayoutSetContextPointer(column, "shaderfx", &ptr); + + /* rounded header ------------------------------------------------------------------- */ + box = uiLayoutBox(column); + + row = uiLayoutRow(box, false); + block = uiLayoutGetBlock(row); + + UI_block_emboss_set(block, UI_EMBOSS_NONE); + /* Open/Close ................................. */ + uiItemR(row, &ptr, "show_expanded", 0, "", ICON_NONE); + + /* shader-type icon */ + uiItemL(row, "", RNA_struct_ui_icon(ptr.type)); + UI_block_emboss_set(block, UI_EMBOSS); + + /* effect name */ + if (mti->isDisabled && mti->isDisabled(md, 0)) { + uiLayoutSetRedAlert(row, true); + } + uiItemR(row, &ptr, "name", 0, "", ICON_NONE); + uiLayoutSetRedAlert(row, false); + + /* mode enabling buttons */ + UI_block_align_begin(block); + uiItemR(row, &ptr, "show_render", 0, "", ICON_NONE); + uiItemR(row, &ptr, "show_viewport", 0, "", ICON_NONE); + + if (mti->flags & eShaderFxTypeFlag_SupportsEditmode) { + sub = uiLayoutRow(row, true); + uiLayoutSetActive(sub, false); + uiItemR(sub, &ptr, "show_in_editmode", 0, "", ICON_NONE); + } + + UI_block_align_end(block); + + /* Up/Down + Delete ........................... */ + UI_block_align_begin(block); + uiItemO(row, "", ICON_TRIA_UP, "OBJECT_OT_shaderfx_move_up"); + uiItemO(row, "", ICON_TRIA_DOWN, "OBJECT_OT_shaderfx_move_down"); + UI_block_align_end(block); + + UI_block_emboss_set(block, UI_EMBOSS_NONE); + uiItemO(row, "", ICON_X, "OBJECT_OT_shaderfx_remove"); + UI_block_emboss_set(block, UI_EMBOSS); + + /* effect settings (under the header) --------------------------------------------------- */ + if (md->mode & eShaderFxMode_Expanded) { + /* apply/convert/copy */ + box = uiLayoutBox(column); + row = uiLayoutRow(box, false); + + /* only here obdata, the rest of effect is ob level */ + UI_block_lock_set(block, BKE_object_obdata_is_libdata(ob), ERROR_LIBDATA_MESSAGE); + + /* result is the layout block inside the box, that we return so that effect settings can be drawn */ + result = uiLayoutColumn(box, false); + block = uiLayoutAbsoluteBlock(box); + } + + /* error messages */ + if (md->error) { + box = uiLayoutBox(column); + row = uiLayoutRow(box, false); + uiItemL(row, md->error, ICON_ERROR); + } + + return result; +} + +uiLayout *uiTemplateShaderFx(uiLayout *layout, bContext *UNUSED(C), PointerRNA *ptr) +{ + Object *ob; + ShaderFxData *fx, *vfx; + int i; + + /* verify we have valid data */ + if (!RNA_struct_is_a(ptr->type, &RNA_ShaderFx)) { + RNA_warning("Expected shader fx on object"); + return NULL; + } + + ob = ptr->id.data; + fx = ptr->data; + + if (!ob || !(GS(ob->id.name) == ID_OB)) { + RNA_warning("Expected shader fx on object"); + return NULL; + } + + UI_block_lock_set(uiLayoutGetBlock(layout), (ob && ID_IS_LINKED(ob)), ERROR_LIBDATA_MESSAGE); + + /* find modifier and draw it */ + vfx = ob->shader_fx.first; + for (i = 0; vfx; i++, vfx = vfx->next) { + if (fx == vfx) + return gpencil_draw_shaderfx(layout, ob, fx); + } + + return NULL; +} + +/************************ Redo Buttons Template *************************/ + static void template_operator_redo_property_buts_draw( const bContext *C, wmOperator *op, uiLayout *layout, int layout_flags, @@ -1560,8 +1824,9 @@ static void template_operator_redo_property_buts_draw( else { /* Might want to make label_align adjustable somehow. */ eAutoPropButsReturn return_info = uiTemplateOperatorPropertyButs( - C, layout, op, r_has_advanced ? template_operator_redo_property_buts_poll : NULL, - UI_BUT_LABEL_ALIGN_NONE, layout_flags); + C, layout, op, + UI_BUT_LABEL_ALIGN_NONE, + layout_flags); if (return_info & UI_PROP_BUTS_ANY_FAILED_CHECK) { if (r_has_advanced) { *r_has_advanced = true; @@ -3043,6 +3308,24 @@ void uiTemplatePalette(uiLayout *layout, PointerRNA *ptr, const char *propname, } } +void uiTemplateCryptoPicker(uiLayout *layout, PointerRNA *ptr, const char *propname) +{ + PropertyRNA *prop = RNA_struct_find_property(ptr, propname); + uiBlock *block; + uiBut *but; + + if (!prop) { + RNA_warning("property not found: %s.%s", RNA_struct_identifier(ptr->type), propname); + return; + } + + block = uiLayoutGetBlock(layout); + + but = uiDefIconTextButO(block, UI_BTYPE_BUT, "UI_OT_eyedropper_color_crypto", WM_OP_INVOKE_DEFAULT, ICON_EYEDROPPER, RNA_property_ui_name(prop), 0, 0, UI_UNIT_X, UI_UNIT_Y, RNA_property_ui_description(prop)); + but->rnapoin = *ptr; + but->rnaprop = prop; + but->rnaindex = -1; +} /********************* Layer Buttons Template ************************/ @@ -3930,13 +4213,30 @@ static void ui_layout_operator_buts__reset_cb(bContext *UNUSED(C), void *op_pt, } #endif +struct uiTemplateOperatorPropertyPollParam { + const bContext *C; + wmOperator *op; + short flag; +}; + +static bool ui_layout_operator_buts_poll_property( + struct PointerRNA *UNUSED(ptr), struct PropertyRNA *prop, void *user_data) +{ + struct uiTemplateOperatorPropertyPollParam *params = user_data; + if ((params->flag & UI_TEMPLATE_OP_PROPS_HIDE_ADVANCED) && + (RNA_property_tags(prop) & OP_PROP_TAG_ADVANCED)) + { + return false; + } + return params->op->type->poll_property(params->C, params->op, prop); +} + /** * Draw Operator property buttons for redoing execution with different settings. * This function does not initialize the layout, functions can be called on the layout before and after. */ eAutoPropButsReturn uiTemplateOperatorPropertyButs( const bContext *C, uiLayout *layout, wmOperator *op, - bool (*check_prop)(struct PointerRNA *, struct PropertyRNA *), const eButLabelAlign label_align, const short flag) { uiBlock *block = uiLayoutGetBlock(layout); @@ -3995,13 +4295,18 @@ eAutoPropButsReturn uiTemplateOperatorPropertyButs( else { wmWindowManager *wm = CTX_wm_manager(C); PointerRNA ptr; + struct uiTemplateOperatorPropertyPollParam user_data = {.C = C, .op = op, .flag = flag}; RNA_pointer_create(&wm->id, op->type->srna, op->properties, &ptr); uiLayoutSetPropSep(layout, true); /* main draw call */ - return_info = uiDefAutoButsRNA(layout, &ptr, check_prop, label_align, (flag & UI_TEMPLATE_OP_PROPS_COMPACT)); + return_info = uiDefAutoButsRNA( + layout, &ptr, + op->type->poll_property ? ui_layout_operator_buts_poll_property : NULL, + op->type->poll_property ? &user_data : NULL, + label_align, (flag & UI_TEMPLATE_OP_PROPS_COMPACT)); if ((return_info & UI_PROP_BUTS_NONE_ADDED) && (flag & UI_TEMPLATE_OP_PROPS_SHOW_EMPTY)) { uiItemL(layout, IFACE_("No Properties"), ICON_NONE); @@ -4588,7 +4893,7 @@ void uiTemplateCacheFile(uiLayout *layout, bContext *C, PointerRNA *ptr, const c uiLayoutSetContextPointer(layout, "edit_cachefile", &fileptr); - uiTemplateID(layout, C, ptr, propname, NULL, "CACHEFILE_OT_open", NULL, UI_TEMPLATE_ID_FILTER_ALL); + uiTemplateID(layout, C, ptr, propname, NULL, "CACHEFILE_OT_open", NULL, UI_TEMPLATE_ID_FILTER_ALL, false); if (!file) { return; diff --git a/source/blender/editors/interface/interface_utils.c b/source/blender/editors/interface/interface_utils.c index d080397c488..60aa79e1093 100644 --- a/source/blender/editors/interface/interface_utils.c +++ b/source/blender/editors/interface/interface_utils.c @@ -159,7 +159,7 @@ uiBut *uiDefAutoButR(uiBlock *block, PointerRNA *ptr, PropertyRNA *prop, int ind */ eAutoPropButsReturn uiDefAutoButsRNA( uiLayout *layout, PointerRNA *ptr, - bool (*check_prop)(PointerRNA *, PropertyRNA *), + bool (*check_prop)(PointerRNA *ptr, PropertyRNA *prop, void *user_data), void *user_data, const eButLabelAlign label_align, const bool compact) { eAutoPropButsReturn return_info = UI_PROP_BUTS_NONE_ADDED; @@ -174,7 +174,7 @@ eAutoPropButsReturn uiDefAutoButsRNA( if (flag & PROP_HIDDEN) { continue; } - if (check_prop && check_prop(ptr, prop) == 0) { + if (check_prop && check_prop(ptr, prop, user_data) == 0) { return_info |= UI_PROP_BUTS_ANY_FAILED_CHECK; continue; } diff --git a/source/blender/editors/interface/interface_widgets.c b/source/blender/editors/interface/interface_widgets.c index fea88388be7..019aabdb466 100644 --- a/source/blender/editors/interface/interface_widgets.c +++ b/source/blender/editors/interface/interface_widgets.c @@ -247,22 +247,22 @@ static const int tria_vcount[ROUNDBOX_TRIA_MAX] = { }; static struct { - Gwn_Batch *roundbox_widget[ROUNDBOX_TRIA_MAX]; + GPUBatch *roundbox_widget[ROUNDBOX_TRIA_MAX]; - Gwn_Batch *roundbox_simple; - Gwn_Batch *roundbox_simple_aa; - Gwn_Batch *roundbox_simple_outline; - Gwn_Batch *roundbox_shadow; + GPUBatch *roundbox_simple; + GPUBatch *roundbox_simple_aa; + GPUBatch *roundbox_simple_outline; + GPUBatch *roundbox_shadow; - Gwn_VertFormat format; + GPUVertFormat format; uint vflag_id; } g_ui_batch_cache = {{0}}; -static Gwn_VertFormat *vflag_format(void) +static GPUVertFormat *vflag_format(void) { if (g_ui_batch_cache.format.attr_len == 0) { - Gwn_VertFormat *format = &g_ui_batch_cache.format; - g_ui_batch_cache.vflag_id = GWN_vertformat_attr_add(format, "vflag", GWN_COMP_U32, 1, GWN_FETCH_INT); + GPUVertFormat *format = &g_ui_batch_cache.format; + g_ui_batch_cache.vflag_id = GPU_vertformat_attr_add(format, "vflag", GPU_COMP_U32, 1, GPU_FETCH_INT); } return &g_ui_batch_cache.format; } @@ -273,17 +273,17 @@ static Gwn_VertFormat *vflag_format(void) #define NO_AA WIDGET_AA_JITTER static void set_roundbox_vertex_data( - Gwn_VertBufRaw *vflag_step, uint32_t d) + GPUVertBufRaw *vflag_step, uint32_t d) { - uint32_t *data = GWN_vertbuf_raw_step(vflag_step); + uint32_t *data = GPU_vertbuf_raw_step(vflag_step); *data = d; } static uint32_t set_roundbox_vertex( - Gwn_VertBufRaw *vflag_step, + GPUVertBufRaw *vflag_step, int corner_id, int corner_v, int jit_v, bool inner, bool emboss, int color) { - uint32_t *data = GWN_vertbuf_raw_step(vflag_step); + uint32_t *data = GPU_vertbuf_raw_step(vflag_step); *data = corner_id; *data |= corner_v << 2; *data |= jit_v << 6; @@ -294,10 +294,10 @@ static uint32_t set_roundbox_vertex( } static uint32_t set_tria_vertex( - Gwn_VertBufRaw *vflag_step, + GPUVertBufRaw *vflag_step, int tria_type, int tria_v, int tria_id, int jit_v) { - uint32_t *data = GWN_vertbuf_raw_step(vflag_step); + uint32_t *data = GPU_vertbuf_raw_step(vflag_step); if (ELEM(tria_type, ROUNDBOX_TRIA_ARROWS)) { tria_v += tria_id * tria_vcount[ROUNDBOX_TRIA_ARROWS]; } @@ -308,7 +308,7 @@ static uint32_t set_tria_vertex( return *data; } -static void roundbox_batch_add_tria(Gwn_VertBufRaw *vflag_step, int tria, uint32_t last_data) +static void roundbox_batch_add_tria(GPUVertBufRaw *vflag_step, int tria, uint32_t last_data) { const int tria_num = ELEM(tria, ROUNDBOX_TRIA_CHECK, ROUNDBOX_TRIA_HOLD_ACTION_ARROW, ROUNDBOX_TRIA_MENU) ? 1 : 2; /* for each tria */ @@ -324,12 +324,12 @@ static void roundbox_batch_add_tria(Gwn_VertBufRaw *vflag_step, int tria, uint32 } } -Gwn_Batch *ui_batch_roundbox_widget_get(int tria) +GPUBatch *ui_batch_roundbox_widget_get(int tria) { if (g_ui_batch_cache.roundbox_widget[tria] == NULL) { uint32_t last_data; - Gwn_VertBufRaw vflag_step; - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(vflag_format()); + GPUVertBufRaw vflag_step; + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(vflag_format()); int vcount = WIDGET_SIZE_MAX; /* inner */ vcount += 2; /* restart */ vcount += ((WIDGET_SIZE_MAX + 1) * 2) * WIDGET_AA_JITTER; /* outline (edges) */ @@ -341,8 +341,8 @@ Gwn_Batch *ui_batch_roundbox_widget_get(int tria) vcount += (tria_vcount[tria] + 2) * WIDGET_AA_JITTER; /* tria2 */ } } - GWN_vertbuf_data_alloc(vbo, vcount); - GWN_vertbuf_attr_get_raw_data(vbo, g_ui_batch_cache.vflag_id, &vflag_step); + GPU_vertbuf_data_alloc(vbo, vcount); + GPU_vertbuf_attr_get_raw_data(vbo, g_ui_batch_cache.vflag_id, &vflag_step); /* Inner */ for (int c1 = 0, c2 = 3; c1 < 2; c1++, c2--) { for (int a1 = 0, a2 = WIDGET_CURVE_RESOLU -1; a2 >= 0; a1++, a2--) { @@ -383,15 +383,15 @@ Gwn_Batch *ui_batch_roundbox_widget_get(int tria) if (tria) { roundbox_batch_add_tria(&vflag_step, tria, last_data); } - g_ui_batch_cache.roundbox_widget[tria] = GWN_batch_create_ex(GWN_PRIM_TRI_STRIP, vbo, NULL, GWN_BATCH_OWNS_VBO); + g_ui_batch_cache.roundbox_widget[tria] = GPU_batch_create_ex(GPU_PRIM_TRI_STRIP, vbo, NULL, GPU_BATCH_OWNS_VBO); gpu_batch_presets_register(g_ui_batch_cache.roundbox_widget[tria]); } return g_ui_batch_cache.roundbox_widget[tria]; } -Gwn_Batch *ui_batch_roundbox_get(bool filled, bool antialiased) +GPUBatch *ui_batch_roundbox_get(bool filled, bool antialiased) { - Gwn_Batch **batch = NULL; + GPUBatch **batch = NULL; if (filled) { if (antialiased) @@ -408,13 +408,13 @@ Gwn_Batch *ui_batch_roundbox_get(bool filled, bool antialiased) if (*batch == NULL) { uint32_t last_data; - Gwn_VertBufRaw vflag_step; - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(vflag_format()); + GPUVertBufRaw vflag_step; + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(vflag_format()); int vcount = WIDGET_SIZE_MAX; vcount += (filled) ? 2 : 0; vcount *= (antialiased) ? WIDGET_AA_JITTER : 1; - GWN_vertbuf_data_alloc(vbo, vcount); - GWN_vertbuf_attr_get_raw_data(vbo, g_ui_batch_cache.vflag_id, &vflag_step); + GPU_vertbuf_data_alloc(vbo, vcount); + GPU_vertbuf_attr_get_raw_data(vbo, g_ui_batch_cache.vflag_id, &vflag_step); if (filled) { for (int j = 0; j < WIDGET_AA_JITTER; j++) { @@ -435,7 +435,7 @@ Gwn_Batch *ui_batch_roundbox_get(bool filled, bool antialiased) break; } } - *batch = GWN_batch_create_ex(GWN_PRIM_TRI_STRIP, vbo, NULL, GWN_BATCH_OWNS_VBO); + *batch = GPU_batch_create_ex(GPU_PRIM_TRI_STRIP, vbo, NULL, GPU_BATCH_OWNS_VBO); } else { for (int j = 0; j < WIDGET_AA_JITTER; j++) { @@ -451,7 +451,7 @@ Gwn_Batch *ui_batch_roundbox_get(bool filled, bool antialiased) break; } } - *batch = GWN_batch_create_ex(GWN_PRIM_LINE_LOOP, vbo, NULL, GWN_BATCH_OWNS_VBO); + *batch = GPU_batch_create_ex(GPU_PRIM_LINE_LOOP, vbo, NULL, GPU_BATCH_OWNS_VBO); } gpu_batch_presets_register(*batch); @@ -459,15 +459,15 @@ Gwn_Batch *ui_batch_roundbox_get(bool filled, bool antialiased) return *batch; } -Gwn_Batch *ui_batch_roundbox_shadow_get(void) +GPUBatch *ui_batch_roundbox_shadow_get(void) { if (g_ui_batch_cache.roundbox_shadow == NULL) { uint32_t last_data; - Gwn_VertBufRaw vflag_step; - Gwn_VertBuf *vbo = GWN_vertbuf_create_with_format(vflag_format()); + GPUVertBufRaw vflag_step; + GPUVertBuf *vbo = GPU_vertbuf_create_with_format(vflag_format()); int vcount = (WIDGET_SIZE_MAX + 1) * 2 + 2 + WIDGET_SIZE_MAX; - GWN_vertbuf_data_alloc(vbo, vcount); - GWN_vertbuf_attr_get_raw_data(vbo, g_ui_batch_cache.vflag_id, &vflag_step); + GPU_vertbuf_data_alloc(vbo, vcount); + GPU_vertbuf_attr_get_raw_data(vbo, g_ui_batch_cache.vflag_id, &vflag_step); for (int c = 0; c < 4; c++) { for (int a = 0; a < WIDGET_CURVE_RESOLU; a++) { @@ -488,7 +488,7 @@ Gwn_Batch *ui_batch_roundbox_shadow_get(void) set_roundbox_vertex(&vflag_step, c2, a2, NO_AA, true, false, INNER); } } - g_ui_batch_cache.roundbox_shadow = GWN_batch_create_ex(GWN_PRIM_TRI_STRIP, vbo, NULL, GWN_BATCH_OWNS_VBO); + g_ui_batch_cache.roundbox_shadow = GPU_batch_create_ex(GPU_PRIM_TRI_STRIP, vbo, NULL, GPU_BATCH_OWNS_VBO); gpu_batch_presets_register(g_ui_batch_cache.roundbox_shadow); } return g_ui_batch_cache.roundbox_shadow; @@ -513,11 +513,11 @@ void UI_draw_anti_tria(float x1, float y1, float x2, float y2, float x3, float y GPU_blend(true); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4fv(draw_color); - immBegin(GWN_PRIM_TRIS, 3 * WIDGET_AA_JITTER); + immBegin(GPU_PRIM_TRIS, 3 * WIDGET_AA_JITTER); /* for each AA step */ for (int j = 0; j < WIDGET_AA_JITTER; j++) { @@ -556,14 +556,14 @@ void UI_draw_anti_fan(float tri_array[][2], unsigned int length, const float col GPU_blend(true); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4fv(draw_color); /* for each AA step */ for (int j = 0; j < WIDGET_AA_JITTER; j++) { - immBegin(GWN_PRIM_TRI_FAN, length); + immBegin(GPU_PRIM_TRI_FAN, length); immVertex2f(pos, tri_array[0][0], tri_array[0][1]); immVertex2f(pos, tri_array[1][0], tri_array[1][1]); @@ -1083,8 +1083,8 @@ static void widgetbase_set_uniform_colors_ubv( #define MAX_WIDGET_BASE_BATCH 6 #define MAX_WIDGET_PARAMETERS 11 -struct { - Gwn_Batch *batch; /* Batch type */ +static struct { + GPUBatch *batch; /* Batch type */ uiWidgetBaseParameters params[MAX_WIDGET_BASE_BATCH]; int count; bool enabled; @@ -1097,22 +1097,22 @@ void UI_widgetbase_draw_cache_flush(void) if (g_widget_base_batch.count == 0) return; - Gwn_Batch *batch = g_widget_base_batch.batch; + GPUBatch *batch = g_widget_base_batch.batch; if (g_widget_base_batch.count == 1) { /* draw single */ - GWN_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_BASE); - GWN_batch_uniform_4fv_array(batch, "parameters", MAX_WIDGET_PARAMETERS, (float *)g_widget_base_batch.params); - GWN_batch_uniform_3fv(batch, "checkerColorAndSize", checker_params); - GWN_batch_draw(batch); + GPU_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_BASE); + GPU_batch_uniform_4fv_array(batch, "parameters", MAX_WIDGET_PARAMETERS, (float *)g_widget_base_batch.params); + GPU_batch_uniform_3fv(batch, "checkerColorAndSize", checker_params); + GPU_batch_draw(batch); } else { - GWN_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_BASE_INST); - GWN_batch_uniform_4fv_array(batch, "parameters", MAX_WIDGET_PARAMETERS * MAX_WIDGET_BASE_BATCH, + GPU_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_BASE_INST); + GPU_batch_uniform_4fv_array(batch, "parameters", MAX_WIDGET_PARAMETERS * MAX_WIDGET_BASE_BATCH, (float *)g_widget_base_batch.params); - GWN_batch_uniform_3fv(batch, "checkerColorAndSize", checker_params); - gpuBindMatrices(batch->interface); - GWN_batch_draw_range_ex(batch, 0, g_widget_base_batch.count, true); - GWN_batch_program_use_end(batch); + GPU_batch_uniform_3fv(batch, "checkerColorAndSize", checker_params); + GPU_matrix_bind(batch->interface); + GPU_batch_draw_range_ex(batch, 0, g_widget_base_batch.count, true); + GPU_batch_program_use_end(batch); } g_widget_base_batch.count = 0; } @@ -1135,7 +1135,7 @@ void UI_widgetbase_draw_cache_end(void) GPU_blend(false); } -static void draw_widgetbase_batch(Gwn_Batch *batch, uiWidgetBase *wtb) +static void draw_widgetbase_batch(GPUBatch *batch, uiWidgetBase *wtb) { wtb->uniform_params.tria1_size = wtb->tria1.size; wtb->uniform_params.tria2_size = wtb->tria2.size; @@ -1171,10 +1171,10 @@ static void draw_widgetbase_batch(Gwn_Batch *batch, uiWidgetBase *wtb) else { float checker_params[3] = {UI_ALPHA_CHECKER_DARK / 255.0f, UI_ALPHA_CHECKER_LIGHT / 255.0f, 8.0f}; /* draw single */ - GWN_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_BASE); - GWN_batch_uniform_4fv_array(batch, "parameters", 11, (float *)&wtb->uniform_params); - GWN_batch_uniform_3fv(batch, "checkerColorAndSize", checker_params); - GWN_batch_draw(batch); + GPU_batch_program_set_builtin(batch, GPU_SHADER_2D_WIDGET_BASE); + GPU_batch_uniform_4fv_array(batch, "parameters", 11, (float *)&wtb->uniform_params); + GPU_batch_uniform_3fv(batch, "checkerColorAndSize", checker_params); + GPU_batch_draw(batch); } } @@ -1228,7 +1228,7 @@ static void widgetbase_draw(uiWidgetBase *wtb, const uiWidgetColors *wcol) if (inner_col1[3] || inner_col2[3] || outline_col[3] || emboss_col[3] || tria_col[3] || alpha_check) { widgetbase_set_uniform_colors_ubv(wtb, inner_col1, inner_col2, outline_col, emboss_col, tria_col, alpha_check); - Gwn_Batch *roundbox_batch = ui_batch_roundbox_widget_get(wtb->tria1.type); + GPUBatch *roundbox_batch = ui_batch_roundbox_widget_get(wtb->tria1.type); draw_widgetbase_batch(roundbox_batch, wtb); } @@ -1494,7 +1494,7 @@ float UI_text_clip_middle_ex( rpart = rpart_buf; } - l_end = BLF_width_to_strlen(fstyle->uifont_id, str, max_len, parts_strwidth, &rpart_width); + l_end = BLF_width_to_strlen(fstyle->uifont_id, str, max_len, parts_strwidth, NULL); if (l_end < 10 || min_ff(parts_strwidth, strwidth - okwidth) < minwidth) { /* If we really have no place, or we would clip a very small piece of string in the middle, * only show start of string. @@ -1504,7 +1504,7 @@ float UI_text_clip_middle_ex( else { size_t r_offset, r_len; - r_offset = BLF_width_to_rstrlen(fstyle->uifont_id, str, max_len, parts_strwidth, &rpart_width); + r_offset = BLF_width_to_rstrlen(fstyle->uifont_id, str, max_len, parts_strwidth, NULL); r_len = strlen(str + r_offset) + 1; /* +1 for the trailing '\0'. */ if (l_end + sep_len + r_len + rpart_len > max_len) { @@ -1525,6 +1525,7 @@ float UI_text_clip_middle_ex( if (rpart) { /* Add back preserved right part to our shorten str. */ memcpy(str + final_lpart_len, rpart, rpart_len + 1); /* +1 for trailing '\0'. */ + okwidth += rpart_width; } strwidth = BLF_width(fstyle->uifont_id, str, max_len); @@ -1836,7 +1837,7 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b selwidth_draw = BLF_width(fstyle->uifont_id, drawstr + but->ofs, but->selend - but->ofs); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4ubv((unsigned char *)wcol->item); @@ -1872,7 +1873,7 @@ static void widget_draw_text(uiFontStyle *fstyle, uiWidgetColors *wcol, uiBut *b UI_widgetbase_draw_cache_flush(); GPU_blend(false); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_I32, 2, GWN_FETCH_INT_TO_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_I32, 2, GPU_FETCH_INT_TO_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor3f(0.2f, 0.6f, 0.9f); @@ -2423,7 +2424,7 @@ static void widget_softshadow(const rcti *rect, int roundboxalign, const float r /* we draw a number of increasing size alpha quad strips */ alphastep = 3.0f * btheme->tui.menu_shadow_fac / radout; - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -2475,7 +2476,7 @@ static void widget_menu_back(uiWidgetColors *wcol, rcti *rect, int flag, int dir static void ui_hsv_cursor(float x, float y) { - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -2571,13 +2572,13 @@ static void ui_draw_but_HSVCIRCLE(uiBut *but, uiWidgetColors *wcol, const rcti * ui_color_picker_to_rgb(0.0f, 0.0f, hsv[2], colcent, colcent + 1, colcent + 2); - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR); - immBegin(GWN_PRIM_TRI_FAN, tot + 2); + immBegin(GPU_PRIM_TRI_FAN, tot + 2); immAttrib3fv(color, colcent); immVertex2f(pos, centx, centy); @@ -2598,7 +2599,7 @@ static void ui_draw_but_HSVCIRCLE(uiBut *but, uiWidgetColors *wcol, const rcti * /* fully rounded outline */ format = immVertexFormat(); - pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); @@ -2682,12 +2683,12 @@ void ui_draw_gradient(const rcti *rect, const float hsv[3], const int type, cons } /* old below */ - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint col = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 4, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint col = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 4, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_SMOOTH_COLOR); - immBegin(GWN_PRIM_TRIS, steps * 3 * 6); + immBegin(GPU_PRIM_TRIS, steps * 3 * 6); for (dx = 0.0f; dx < 0.999f; dx += color_step) { /* 0.999 = prevent float inaccuracy for steps */ const float dx_next = dx + color_step; @@ -2843,7 +2844,7 @@ static void ui_draw_but_HSVCUBE(uiBut *but, const rcti *rect) ui_hsv_cursor(x, y); /* outline */ - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor3ub(0, 0, 0); imm_draw_box_wire_2d(pos, (rect->xmin), (rect->ymin), (rect->xmax), (rect->ymax)); @@ -2940,14 +2941,14 @@ static void ui_draw_separator(const rcti *rect, uiWidgetColors *wcol) 30 }; - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); GPU_blend(true); immUniformColor4ubv(col); GPU_line_width(1.0f); - immBegin(GWN_PRIM_LINES, 2); + immBegin(GPU_PRIM_LINES, 2); immVertex2f(pos, rect->xmin, y); immVertex2f(pos, rect->xmax, y); immEnd(); @@ -3402,11 +3403,11 @@ static void widget_swatch(uiBut *but, uiWidgetColors *wcol, rcti *rect, int stat UI_widgetbase_draw_cache_flush(); GPU_blend(false); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor3f(bw, bw, bw); - immBegin(GWN_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.5f * height); immVertex2f(pos, rect->xmin + 0.5f * width, rect->ymin + 0.9f * height); @@ -3783,7 +3784,7 @@ static void widget_draw_extra_mask(const bContext *C, uiBut *but, uiWidgetType * /* note: drawextra can change rect +1 or -1, to match round errors of existing previews */ but->block->drawextra(C, but->poin, but->block->drawextra_arg1, but->block->drawextra_arg2, rect); - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); /* make mask to draw over image */ @@ -4420,11 +4421,11 @@ static void ui_draw_popover_back_impl( /* Draw popover arrow (top/bottom) */ if (ELEM(direction, UI_DIR_UP, UI_DIR_DOWN)) { - uint pos = GWN_vertformat_attr_add(immVertexFormat(), "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4ubv((unsigned char *)wcol->inner); GPU_blend(true); - immBegin(GWN_PRIM_TRIS, 3); + immBegin(GPU_PRIM_TRIS, 3); if (direction == UI_DIR_DOWN) { const float y = rect->ymax; immVertex2f(pos, cent_x - unit_half, y); @@ -4476,10 +4477,10 @@ static void draw_disk_shaded( unsigned char r_col[4]; unsigned int pos, col; - Gwn_VertFormat *format = immVertexFormat(); - pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); if (shaded) { - col = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 4, GWN_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); } else { @@ -4487,7 +4488,7 @@ static void draw_disk_shaded( immUniformColor4ubv((unsigned char *)col1); } - immBegin(GWN_PRIM_TRI_STRIP, subd * 2); + immBegin(GPU_PRIM_TRI_STRIP, subd * 2); for (i = 0; i < subd; i++) { float a; @@ -4532,8 +4533,8 @@ void ui_draw_pie_center(uiBlock *block) float angle = atan2f(pie_dir[1], pie_dir[0]); float range = (block->pie_data.flags & UI_PIE_DEGREES_RANGE_LARGE) ? M_PI_2 : M_PI_4; - gpuPushMatrix(); - gpuTranslate2f(cx, cy); + GPU_matrix_push(); + GPU_matrix_translate_2f(cx, cy); GPU_blend(true); if (btheme->tui.wcol_pie_menu.shaded) { @@ -4556,8 +4557,8 @@ void ui_draw_pie_center(uiBlock *block) } } - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); immUniformColor4ubv((unsigned char *)btheme->tui.wcol_pie_menu.outline); @@ -4579,7 +4580,7 @@ void ui_draw_pie_center(uiBlock *block) } GPU_blend(false); - gpuPopMatrix(); + GPU_matrix_pop(); } diff --git a/source/blender/editors/interface/resources.c b/source/blender/editors/interface/resources.c index 47d664eaeb2..72023ebf2ae 100644 --- a/source/blender/editors/interface/resources.c +++ b/source/blender/editors/interface/resources.c @@ -83,7 +83,7 @@ static struct bThemeState g_theme_state = { void ui_resources_init(void) { - UI_icons_init(BIFICONID_LAST); + UI_icons_init(); } void ui_resources_free(void) @@ -1536,15 +1536,6 @@ void init_userdef_do_versions(Main *bmain) #undef USER_VERSION_ATLEAST #define USER_VERSION_ATLEAST(ver, subver) MAIN_VERSION_ATLEAST((&(U)), ver, subver) - - if (!USER_VERSION_ATLEAST(269, 9)) { - /* grease pencil - new layer color */ - if (U.gpencil_new_layer_col[3] < 0.1f) { - /* defaults to black, but must at least be visible! */ - U.gpencil_new_layer_col[3] = 0.9f; - } - } - if (!USER_VERSION_ATLEAST(271, 5)) { U.pie_menu_radius = 100; U.pie_menu_threshold = 12; @@ -1582,6 +1573,17 @@ void init_userdef_do_versions(Main *bmain) for (bTheme *btheme = U.themes.first; btheme; btheme = btheme->next) { memcpy(btheme, &U_theme_default, sizeof(*btheme)); } + + /* Annotations - new layer color + * Replace anything that used to be set if it looks like was left + * on the old default (i.e. black), which most users used + */ + if ((U.gpencil_new_layer_col[3] < 0.1f) || (U.gpencil_new_layer_col[0] < 0.1f)) { + /* - New color matches the annotation pencil icon + * - Non-full alpha looks better! + */ + ARRAY_SET_ITEMS(U.gpencil_new_layer_col, 0.38f, 0.61f, 0.78f, 0.9f); + } } /** diff --git a/source/blender/editors/interface/view2d.c b/source/blender/editors/interface/view2d.c index 1b449877abe..3a527712367 100644 --- a/source/blender/editors/interface/view2d.c +++ b/source/blender/editors/interface/view2d.c @@ -1151,7 +1151,7 @@ void UI_view2d_view_restore(const bContext *C) int height = BLI_rcti_size_y(&ar->winrct) + 1; wmOrtho2(0.0f, (float)width, 0.0f, (float)height); - gpuLoadIdentity(); + GPU_matrix_identity_set(); // ED_region_pixelspace(CTX_wm_region(C)); } @@ -1338,12 +1338,12 @@ void UI_view2d_grid_draw(View2D *v2d, View2DGrid *grid, int flag) if (vertex_count == 0) return; - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 3, GPU_FETCH_INT_TO_FLOAT_UNIT); immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR); - immBegin(GWN_PRIM_LINES, vertex_count); + immBegin(GPU_PRIM_LINES, vertex_count); /* vertical lines */ if (flag & V2D_VERTICAL_LINES) { @@ -1480,15 +1480,15 @@ void UI_view2d_constant_grid_draw(View2D *v2d, float step) count_y = (v2d->cur.ymax - start_y) / step + 1; if (count_x > 0 || count_y > 0) { - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_F32, 3, GWN_FETCH_FLOAT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_F32, 3, GPU_FETCH_FLOAT); float theme_color[3]; UI_GetThemeColorShade3fv(TH_BACK, -10, theme_color); immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR); - immBegin(GWN_PRIM_LINES, count_x * 2 + count_y * 2 + 4); + immBegin(GPU_PRIM_LINES, count_x * 2 + count_y * 2 + 4); immAttrib3fv(color, theme_color); for (int i = 0; i < count_x ; start_x += step, i++) { @@ -1531,14 +1531,14 @@ void UI_view2d_multi_grid_draw(View2D *v2d, int colorid, float step, int level_s vertex_count += 2 * ((int)((v2d->cur.xmax - v2d->cur.xmin) / lstep) + 1); vertex_count += 2 * ((int)((v2d->cur.ymax - v2d->cur.ymin) / lstep) + 1); - Gwn_VertFormat *format = immVertexFormat(); - uint pos = GWN_vertformat_attr_add(format, "pos", GWN_COMP_F32, 2, GWN_FETCH_FLOAT); - uint color = GWN_vertformat_attr_add(format, "color", GWN_COMP_U8, 3, GWN_FETCH_INT_TO_FLOAT_UNIT); + GPUVertFormat *format = immVertexFormat(); + uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); + uint color = GPU_vertformat_attr_add(format, "color", GPU_COMP_U8, 3, GPU_FETCH_INT_TO_FLOAT_UNIT); GPU_line_width(1.0f); immBindBuiltinProgram(GPU_SHADER_2D_FLAT_COLOR); - immBeginAtMost(GWN_PRIM_LINES, vertex_count); + immBeginAtMost(GPU_PRIM_LINES, vertex_count); for (int level = 0; level < totlevels; ++level) { UI_GetThemeColorShade3ubv(colorid, offset, grid_line_color); diff --git a/source/blender/editors/interface/view2d_ops.c b/source/blender/editors/interface/view2d_ops.c index dfc401c1635..1c56dabb396 100644 --- a/source/blender/editors/interface/view2d_ops.c +++ b/source/blender/editors/interface/view2d_ops.c @@ -354,7 +354,7 @@ static int view_scrollright_exec(bContext *C, wmOperator *op) } /* set RNA-Props - only movement in positive x-direction */ - RNA_int_set(op->ptr, "deltax", 20); + RNA_int_set(op->ptr, "deltax", 40); RNA_int_set(op->ptr, "deltay", 0); /* apply movement, then we're done */ @@ -398,7 +398,7 @@ static int view_scrollleft_exec(bContext *C, wmOperator *op) } /* set RNA-Props - only movement in negative x-direction */ - RNA_int_set(op->ptr, "deltax", -20); + RNA_int_set(op->ptr, "deltax", -40); RNA_int_set(op->ptr, "deltay", 0); /* apply movement, then we're done */ |