Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/screen/screen_draw.c
| Show First 20 Lines • Show All 231 Lines • ▼ Show 20 Lines | |||||
| } | } | ||||
| /** | /** | ||||
| * Visual indication of the two areas involved in a proposed join. | * Visual indication of the two areas involved in a proposed join. | ||||
| * | * | ||||
| * \param sa1: Area from which the resultant originates. | * \param sa1: Area from which the resultant originates. | ||||
| * \param sa2: Target area that will be replaced. | * \param sa2: Target area that will be replaced. | ||||
| */ | */ | ||||
| void ED_screen_draw_join_highlight(ScrArea *sa1, ScrArea *sa2) | void screen_draw_join_highlight(ScrArea *sa1, ScrArea *sa2) | ||||
| { | { | ||||
| int dir = area_getorientation(sa1, sa2); | const eScreenDir dir = area_getorientation(sa1, sa2); | ||||
| if (dir == -1) { | if (dir == SCREEN_DIR_NONE) { | ||||
| return; | return; | ||||
| } | } | ||||
| /* Rect of the combined areas.*/ | /* Rect of the combined areas.*/ | ||||
| bool vertical = ELEM(dir, 1, 3); | const bool vertical = SCREEN_DIR_IS_VERTICAL(dir); | ||||
| rctf combined = {.xmin = vertical ? MAX2(sa1->totrct.xmin, sa2->totrct.xmin) : | const rctf combined = { | ||||
| .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( | uint pos_id = GPU_vertformat_attr_add( | ||||
| immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | immVertexFormat(), "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); | ||||
| immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); | immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); | ||||
| GPU_blend(GPU_BLEND_ALPHA); | GPU_blend(GPU_BLEND_ALPHA); | ||||
| /* Highlight source (sa1) within combined area. */ | /* Highlight source (sa1) within combined area. */ | ||||
| immUniformColor4fv((const float[4]){1.0f, 1.0f, 1.0f, 0.10f}); | immUniformColor4fv((const float[4]){1.0f, 1.0f, 1.0f, 0.10f}); | ||||
| ▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Lines | void screen_draw_join_highlight(ScrArea *sa1, ScrArea *sa2) | ||||
| immUnbindProgram(); | immUnbindProgram(); | ||||
| GPU_blend(GPU_BLEND_NONE); | 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}); | UI_draw_roundbox_4fv(&combined, false, 7 * U.pixelsize, (float[4]){1.0f, 1.0f, 1.0f, 0.8f}); | ||||
| } | } | ||||
| void ED_screen_draw_split_preview(ScrArea *area, const int dir, 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_2D_UNIFORM_COLOR); | immBindBuiltinProgram(GPU_SHADER_2D_UNIFORM_COLOR); | ||||
| /* Split-point. */ | /* Split-point. */ | ||||
| GPU_blend(GPU_BLEND_ALPHA); | GPU_blend(GPU_BLEND_ALPHA); | ||||
| immUniformColor4ub(255, 255, 255, 100); | immUniformColor4ub(255, 255, 255, 100); | ||||
| immBegin(GPU_PRIM_LINES, 2); | immBegin(GPU_PRIM_LINES, 2); | ||||
| if (dir == 'h') { | if (dir_axis == SCREEN_AXIS_H) { | ||||
| const float y = (1 - fac) * area->totrct.ymin + fac * area->totrct.ymax; | const float y = (1 - fac) * area->totrct.ymin + fac * area->totrct.ymax; | ||||
| immVertex2f(pos, area->totrct.xmin, y); | immVertex2f(pos, area->totrct.xmin, y); | ||||
| immVertex2f(pos, area->totrct.xmax, y); | immVertex2f(pos, area->totrct.xmax, y); | ||||
| immEnd(); | immEnd(); | ||||
| immUniformColor4ub(0, 0, 0, 100); | immUniformColor4ub(0, 0, 0, 100); | ||||
| immBegin(GPU_PRIM_LINES, 2); | immBegin(GPU_PRIM_LINES, 2); | ||||
| immVertex2f(pos, area->totrct.xmin, y + 1); | immVertex2f(pos, area->totrct.xmin, y + 1); | ||||
| immVertex2f(pos, area->totrct.xmax, y + 1); | immVertex2f(pos, area->totrct.xmax, y + 1); | ||||
| immEnd(); | immEnd(); | ||||
| } | } | ||||
| else { | else { | ||||
| BLI_assert(dir == 'v'); | BLI_assert(dir_axis == SCREEN_AXIS_V); | ||||
| const float x = (1 - fac) * area->totrct.xmin + fac * area->totrct.xmax; | const float x = (1 - fac) * area->totrct.xmin + fac * area->totrct.xmax; | ||||
| immVertex2f(pos, x, area->totrct.ymin); | immVertex2f(pos, x, area->totrct.ymin); | ||||
| immVertex2f(pos, x, area->totrct.ymax); | immVertex2f(pos, x, area->totrct.ymax); | ||||
| immEnd(); | immEnd(); | ||||
| immUniformColor4ub(0, 0, 0, 100); | immUniformColor4ub(0, 0, 0, 100); | ||||
| ▲ Show 20 Lines • Show All 103 Lines • Show Last 20 Lines | |||||