Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/screen/screen_draw.c
| Show First 20 Lines • Show All 92 Lines • ▼ Show 20 Lines | |||||
| GPU_blend(GPU_BLEND_NONE); | GPU_blend(GPU_BLEND_NONE); | ||||
| if (U.pixelsize <= 1.0f) { | if (U.pixelsize <= 1.0f) { | ||||
| GPU_scissor_test(false); | GPU_scissor_test(false); | ||||
| } | } | ||||
| } | } | ||||
| void screen_draw_join_highlight(ScrArea *sa1, ScrArea *sa2) | void screen_draw_join_highlight(ScrArea *sa1, ScrArea *sa2, eScreenDir dir) | ||||
| { | { | ||||
| const eScreenDir dir = area_getorientation(sa1, sa2); | if (dir == SCREEN_DIR_NONE || !sa2) { | ||||
| if (dir == SCREEN_DIR_NONE) { | /* Darken source if docking. Done here because might be a different window. */ | ||||
| rctf rect; | |||||
| BLI_rctf_rcti_copy(&rect, &sa1->totrct); | |||||
| float darken[4] = {0.0f, 0.0f, 0.0f, 0.8f}; | |||||
| UI_draw_roundbox_corner_set(UI_CNR_ALL); | |||||
| UI_draw_roundbox_4fv_ex(&rect, darken, NULL, 1.0f, NULL, U.pixelsize, 6 * U.pixelsize); | |||||
| return; | return; | ||||
| } | } | ||||
| /* Rect of the combined areas. */ | /* Rect of the combined areas. */ | ||||
| const bool vertical = SCREEN_DIR_IS_VERTICAL(dir); | const bool vertical = SCREEN_DIR_IS_VERTICAL(dir); | ||||
| const rctf combined = { | const rctf combined = { | ||||
| .xmin = vertical ? MAX2(sa1->totrct.xmin, sa2->totrct.xmin) : | .xmin = vertical ? MAX2(sa1->totrct.xmin, sa2->totrct.xmin) : | ||||
| MIN2(sa1->totrct.xmin, sa2->totrct.xmin), | MIN2(sa1->totrct.xmin, sa2->totrct.xmin), | ||||
| .xmax = vertical ? MIN2(sa1->totrct.xmax, sa2->totrct.xmax) : | .xmax = vertical ? MIN2(sa1->totrct.xmax, sa2->totrct.xmax) : | ||||
| MAX2(sa1->totrct.xmax, sa2->totrct.xmax), | MAX2(sa1->totrct.xmax, sa2->totrct.xmax), | ||||
| .ymin = vertical ? MIN2(sa1->totrct.ymin, sa2->totrct.ymin) : | .ymin = vertical ? MIN2(sa1->totrct.ymin, sa2->totrct.ymin) : | ||||
| MAX2(sa1->totrct.ymin, sa2->totrct.ymin), | MAX2(sa1->totrct.ymin, sa2->totrct.ymin), | ||||
| .ymax = vertical ? MAX2(sa1->totrct.ymax, sa2->totrct.ymax) : | .ymax = vertical ? MAX2(sa1->totrct.ymax, sa2->totrct.ymax) : | ||||
| MIN2(sa1->totrct.ymax, sa2->totrct.ymax), | MIN2(sa1->totrct.ymax, sa2->totrct.ymax), | ||||
| }; | }; | ||||
| uint pos_id = GPU_vertformat_attr_add( | |||||
| immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | |||||
| immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); | |||||
| GPU_blend(GPU_BLEND_ALPHA); | |||||
| /* Highlight source (sa1) within combined area. */ | |||||
| immUniformColor4fv((const float[4]){1.0f, 1.0f, 1.0f, 0.10f}); | |||||
| immRectf(pos_id, | |||||
| MAX2(sa1->totrct.xmin, combined.xmin), | |||||
| MAX2(sa1->totrct.ymin, combined.ymin), | |||||
| MIN2(sa1->totrct.xmax, combined.xmax), | |||||
| MIN2(sa1->totrct.ymax, combined.ymax)); | |||||
| /* Highlight destination (sa2) within combined area. */ | |||||
| immUniformColor4fv((const float[4]){0.0f, 0.0f, 0.0f, 0.25f}); | |||||
| immRectf(pos_id, | |||||
| MAX2(sa2->totrct.xmin, combined.xmin), | |||||
| MAX2(sa2->totrct.ymin, combined.ymin), | |||||
| MIN2(sa2->totrct.xmax, combined.xmax), | |||||
| MIN2(sa2->totrct.ymax, combined.ymax)); | |||||
| int offset1; | int offset1; | ||||
| int offset2; | int offset2; | ||||
| area_getoffsets(sa1, sa2, dir, &offset1, &offset2); | area_getoffsets(sa1, sa2, dir, &offset1, &offset2); | ||||
| if (offset1 < 0 || offset2 > 0) { | if (offset1 < 0 || offset2 > 0) { | ||||
| /* Show partial areas that will be closed. */ | /* Show partial areas that will be closed. */ | ||||
| uint pos_id = GPU_vertformat_attr_add( | |||||
| immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | |||||
| immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); | |||||
| GPU_blend(GPU_BLEND_ALPHA); | |||||
| immUniformColor4fv((const float[4]){0.0f, 0.0f, 0.0f, 0.8f}); | immUniformColor4fv((const float[4]){0.0f, 0.0f, 0.0f, 0.8f}); | ||||
| if (vertical) { | if (vertical) { | ||||
| if (sa1->totrct.xmin < combined.xmin) { | if (sa1->totrct.xmin < combined.xmin) { | ||||
| immRectf(pos_id, sa1->totrct.xmin, sa1->totrct.ymin, combined.xmin, sa1->totrct.ymax); | immRectf(pos_id, sa1->totrct.xmin, sa1->totrct.ymin, combined.xmin, sa1->totrct.ymax); | ||||
| } | } | ||||
| if (sa2->totrct.xmin < combined.xmin) { | if (sa2->totrct.xmin < combined.xmin) { | ||||
| immRectf(pos_id, sa2->totrct.xmin, sa2->totrct.ymin, combined.xmin, sa2->totrct.ymax); | immRectf(pos_id, sa2->totrct.xmin, sa2->totrct.ymin, combined.xmin, sa2->totrct.ymax); | ||||
| } | } | ||||
| Show All 13 Lines | |||||
| } | } | ||||
| if (sa1->totrct.ymax > combined.ymax) { | if (sa1->totrct.ymax > combined.ymax) { | ||||
| immRectf(pos_id, sa1->totrct.xmin, sa1->totrct.ymax, sa1->totrct.xmax, combined.ymax); | immRectf(pos_id, sa1->totrct.xmin, sa1->totrct.ymax, sa1->totrct.xmax, combined.ymax); | ||||
| } | } | ||||
| if (sa2->totrct.ymax > combined.ymax) { | if (sa2->totrct.ymax > combined.ymax) { | ||||
| immRectf(pos_id, sa2->totrct.xmin, sa2->totrct.ymax, sa2->totrct.xmax, combined.ymax); | immRectf(pos_id, sa2->totrct.xmin, sa2->totrct.ymax, sa2->totrct.xmax, combined.ymax); | ||||
| } | } | ||||
| } | } | ||||
| immUnbindProgram(); | |||||
| GPU_blend(GPU_BLEND_NONE); | |||||
| } | } | ||||
| immUnbindProgram(); | |||||
| GPU_blend(GPU_BLEND_NONE); | |||||
| /* Outline the combined area. */ | /* Outline the combined area. */ | ||||
| UI_draw_roundbox_corner_set(UI_CNR_ALL); | UI_draw_roundbox_corner_set(UI_CNR_ALL); | ||||
| UI_draw_roundbox_4fv(&combined, false, 7 * U.pixelsize, (float[4]){1.0f, 1.0f, 1.0f, 0.8f}); | float outline[4] = {1.0f, 1.0f, 1.0f, 0.4f}; | ||||
| float inner[4] = {1.0f, 1.0f, 1.0f, 0.15f}; | |||||
| UI_draw_roundbox_4fv_ex(&combined, inner, NULL, 1.0f, outline, U.pixelsize, 6 * U.pixelsize); | |||||
| UI_draw_box_shadow(&combined, 128); | |||||
| } | |||||
| void screen_draw_dock_preview(const struct wmWindow *win, | |||||
| struct ScrArea *area, | |||||
| eAreaDockTarget dock_target, | |||||
| float factor) | |||||
| { | |||||
| rctf dest; | |||||
| BLI_rctf_rcti_copy(&dest, &area->totrct); | |||||
| if (dock_target == DOCKING_RIGHT) { | |||||
| dest.xmin = MIN2(dest.xmin + area->winx * (1.0f - factor), dest.xmax - AREAMINX * U.dpi_fac); | |||||
| } | |||||
| else if (dock_target == DOCKING_LEFT) { | |||||
| dest.xmax = MAX2(dest.xmax - area->winx * (1.0f - factor), dest.xmin + AREAMINX * U.dpi_fac); | |||||
| } | |||||
| else if (dock_target == DOCKING_TOP) { | |||||
| dest.ymin = MIN2(dest.ymin + area->winy * (1.0f - factor), dest.ymax - HEADERY * U.dpi_fac); | |||||
| } | |||||
| else if (dock_target == DOCKING_BOTTOM) { | |||||
| dest.ymax = MAX2(dest.ymax - area->winy * (1.0f - factor), dest.ymin + HEADERY * U.dpi_fac); | |||||
| } | |||||
| UI_draw_roundbox_corner_set(UI_CNR_ALL); | |||||
| float inner[4] = {1.0f, 1.0f, 1.0f, 0.15f}; | |||||
| float outline[4] = {1.0f, 1.0f, 1.0f, 0.4f}; | |||||
| UI_draw_roundbox_4fv_ex(&dest, | |||||
| (dock_target == DOCKING_NONE) ? NULL : inner, | |||||
| NULL, | |||||
| 1.0f, | |||||
| outline, | |||||
| U.pixelsize, | |||||
| 6 * U.pixelsize); | |||||
| UI_draw_box_shadow(&dest, 128); | |||||
| } | } | ||||
| void screen_draw_split_preview(ScrArea *area, const eScreenAxis dir_axis, const float fac) | void screen_draw_split_preview(ScrArea *area, const eScreenAxis dir_axis, const float fac) | ||||
| { | { | ||||
| uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | uint pos = GPU_vertformat_attr_add(immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | ||||
| immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); | immBindBuiltinProgram(GPU_SHADER_3D_UNIFORM_COLOR); | ||||
| /* Split-point. */ | /* Split-point. */ | ||||
| ▲ Show 20 Lines • Show All 92 Lines • Show Last 20 Lines | |||||