From a21481cbdd9ac3d3ae3d1ce068cae91142ce3461 Mon Sep 17 00:00:00 2001 From: Harley Acheson Date: Mon, 7 Apr 2025 21:15:20 +0200 Subject: [PATCH] UI: Allow Changing Editor Outline Width The gaps between editors need to be selected and manipulated in order to resize areas. How wide these need to be depends on the accuracy and resolution of your pointing device. And also on the fine motor control and visual acuity of the user. If you are using a tablet pen, touch device, or are visually or physically challenged, then you need these gaps to be wider. This PR allows a wide latitude in this. Pull Request: https://projects.blender.org/blender/blender/pulls/126334 --- release/datafiles/userdef/userdef_default.c | 1 + scripts/startup/bl_ui/space_userpref.py | 1 + .../blenloader/intern/versioning_userdef.cc | 4 + source/blender/editors/screen/area.cc | 75 ++++------ source/blender/editors/screen/screen_draw.cc | 140 ++++++++---------- .../blender/editors/screen/screen_geometry.cc | 19 +-- .../blender/editors/screen/screen_intern.hh | 15 +- source/blender/editors/screen/screen_ops.cc | 28 +--- source/blender/makesdna/DNA_screen_types.h | 2 +- source/blender/makesdna/DNA_userdef_types.h | 6 +- source/blender/makesrna/intern/rna_userdef.cc | 5 + 11 files changed, 131 insertions(+), 165 deletions(-) diff --git a/release/datafiles/userdef/userdef_default.c b/release/datafiles/userdef/userdef_default.c index a3e4a659434..468d490bd43 100644 --- a/release/datafiles/userdef/userdef_default.c +++ b/release/datafiles/userdef/userdef_default.c @@ -66,6 +66,7 @@ const UserDef U_default = { .ui_scale = 1.0, .ui_line_width = 0, + .border_width = 2, /** Default so DPI is detected automatically. */ .dpi = 0, diff --git a/scripts/startup/bl_ui/space_userpref.py b/scripts/startup/bl_ui/space_userpref.py index 691447e3e45..e4194bc7775 100644 --- a/scripts/startup/bl_ui/space_userpref.py +++ b/scripts/startup/bl_ui/space_userpref.py @@ -281,6 +281,7 @@ class USERPREF_PT_interface_editors(InterfacePanel, CenterAlignMixIn, Panel): col = layout.column() col.prop(system, "use_region_overlap") col.prop(view, "show_navigate_ui") + col.prop(view, "border_width") col.prop(view, "color_picker_type") col.row().prop(view, "header_align") col.prop(view, "factor_display_type") diff --git a/source/blender/blenloader/intern/versioning_userdef.cc b/source/blender/blenloader/intern/versioning_userdef.cc index abb400179cb..6fb366f3f40 100644 --- a/source/blender/blenloader/intern/versioning_userdef.cc +++ b/source/blender/blenloader/intern/versioning_userdef.cc @@ -1417,6 +1417,10 @@ void blo_do_versions_userdef(UserDef *userdef) userdef->ndof_flag |= NDOF_SHOW_GUIDE_ORBIT_CENTER | NDOF_ORBIT_CENTER_AUTO; } + if (userdef->border_width == 0) { + userdef->border_width = 2; + } + if (!USER_VERSION_ATLEAST(405, 10)) { static const blender::Map keymap_renames = { {"SequencerCommon", "Video Sequence Editor"}, diff --git a/source/blender/editors/screen/area.cc b/source/blender/editors/screen/area.cc index dea9c35f1ae..749a8ad029b 100644 --- a/source/blender/editors/screen/area.cc +++ b/source/blender/editors/screen/area.cc @@ -1803,27 +1803,36 @@ static void region_rect_recursive( memset(®ion->runtime->visible_rect, 0, sizeof(region->runtime->visible_rect)); } -static void area_calc_totrct(ScrArea *area, const rcti *window_rect) +static void area_calc_totrct(const bScreen *screen, ScrArea *area, const rcti *window_rect) { - short px = short(U.pixelsize); + short px = short(std::max(float(U.border_width) * UI_SCALE_FAC, UI_SCALE_FAC)); area->totrct.xmin = area->v1->vec.x; area->totrct.xmax = area->v4->vec.x; area->totrct.ymin = area->v1->vec.y; area->totrct.ymax = area->v2->vec.y; - /* scale down totrct by 1 pixel on all sides not matching window borders */ - if (area->totrct.xmin > window_rect->xmin) { - area->totrct.xmin += px; - } - if (area->totrct.xmax < (window_rect->xmax - 1)) { - area->totrct.xmax -= px; - } - if (area->totrct.ymin > window_rect->ymin) { - area->totrct.ymin += px; - } - if (area->totrct.ymax < (window_rect->ymax - 1)) { - area->totrct.ymax -= px; + /* Scale down totrct by the border size on all sides not at window edges. */ + if (!ED_area_is_global(area) && screen->state != SCREENFULL && + !(screen->temp && BLI_listbase_is_single(&screen->areabase))) + { + if (area->totrct.xmin > window_rect->xmin) { + area->totrct.xmin += px; + } + if (area->totrct.xmax < (window_rect->xmax - 1)) { + area->totrct.xmax -= px; + } + if (area->totrct.ymin > window_rect->ymin) { + area->totrct.ymin += px; + } + + if (area->totrct.ymax < (window_rect->ymax - 1)) { + area->totrct.ymax -= px; + } + else if (!BLI_listbase_is_single(&screen->areabase)) { + /* Small gap below Top Bar. */ + area->totrct.ymax -= U.pixelsize; + } } /* Although the following asserts are correct they lead to a very unstable Blender. * And the asserts would fail even in 2.7x @@ -1971,8 +1980,8 @@ void ED_area_update_region_sizes(wmWindowManager *wm, wmWindow *win, ScrArea *ar const bScreen *screen = WM_window_get_active_screen(win); rcti window_rect; - WM_window_rect_calc(win, &window_rect); - area_calc_totrct(area, &window_rect); + WM_window_screen_rect_calc(win, &window_rect); + area_calc_totrct(screen, area, &window_rect); /* region rect sizes */ rcti rect = area->totrct; @@ -2070,12 +2079,12 @@ void ED_area_init(bContext *C, const wmWindow *win, ScrArea *area) } rcti window_rect; - WM_window_rect_calc(win, &window_rect); + WM_window_screen_rect_calc(win, &window_rect); ED_area_and_region_types_init(area); /* area sizes */ - area_calc_totrct(area, &window_rect); + area_calc_totrct(screen, area, &window_rect); area_regions_poll(C, screen, area); @@ -3549,31 +3558,6 @@ bool ED_region_property_search(const bContext *C, return has_result; } -/** - * The drawable part of the region might be slightly smaller because of area edges. This is - * especially visible for header-like regions, where vertical space around widgets is small, and - * it's quite visible when widgets aren't centered properly. - */ -static void layout_coordinates_correct_for_drawable_rect( - const wmWindow *win, const ScrArea *area, const ARegion *region, int * /*r_xco*/, int *r_yco) -{ - /* Don't do corrections at the window borders where the region rectangles are clipped already. */ - { - rcti win_rect; - WM_window_rect_calc(win, &win_rect); - if (region->winrct.ymin == win_rect.ymin) { - return; - } - if (region->winrct.ymax == (win_rect.ymax - 1)) { - return; - } - } - - if (region->winrct.ymax == area->totrct.ymax) { - *r_yco -= 1; - } -} - void ED_region_header_layout(const bContext *C, ARegion *region) { const uiStyle *style = UI_style_get_dpi(); @@ -3584,13 +3568,10 @@ void ED_region_header_layout(const bContext *C, ARegion *region) const float buttony_scale = buttony / float(UI_UNIT_Y); /* Vertically center buttons. */ - int xco = UI_HEADER_OFFSET; + int xco = int(UI_HEADER_OFFSET); int yco = buttony + (region->winy - buttony) / 2; int maxco = xco; - layout_coordinates_correct_for_drawable_rect( - CTX_wm_window(C), CTX_wm_area(C), region, &xco, &yco); - /* set view2d view matrix for scrolling (without scrollers) */ UI_view2d_view_ortho(®ion->v2d); diff --git a/source/blender/editors/screen/screen_draw.cc b/source/blender/editors/screen/screen_draw.cc index 8e49948bd94..dd515b83c68 100644 --- a/source/blender/editors/screen/screen_draw.cc +++ b/source/blender/editors/screen/screen_draw.cc @@ -92,31 +92,14 @@ static blender::gpu::Batch *batch_screen_edges_get(int *corner_len) #undef CORNER_RESOLUTION -static void drawscredge_area_draw( - int sizex, int sizey, short x1, short y1, short x2, short y2, float edge_thickness) +/** + * \brief Screen edges drawing. + */ +static void drawscredge_area(const ScrArea &area, float edge_thickness) { rctf rect; - BLI_rctf_init(&rect, float(x1), float(x2), float(y1), float(y2)); - - /* right border area */ - if (x2 >= sizex - 1) { - rect.xmax += edge_thickness * 0.5f; - } - - /* left border area */ - if (x1 <= 0) { /* otherwise it draws the emboss of window over */ - rect.xmin -= edge_thickness * 0.5f; - } - - /* top border area */ - if (y2 >= sizey - 1) { - rect.ymax += edge_thickness * 0.5f; - } - - /* bottom border area */ - if (y1 <= 0) { - rect.ymin -= edge_thickness * 0.5f; - } + BLI_rctf_rcti_copy(&rect, &area.totrct); + BLI_rctf_pad(&rect, edge_thickness, edge_thickness); blender::gpu::Batch *batch = batch_screen_edges_get(nullptr); GPU_batch_program_set_builtin(batch, GPU_SHADER_2D_AREA_BORDERS); @@ -124,19 +107,6 @@ static void drawscredge_area_draw( GPU_batch_draw(batch); } -/** - * \brief Screen edges drawing. - */ -static void drawscredge_area(ScrArea *area, int sizex, int sizey, float edge_thickness) -{ - short x1 = area->v1->vec.x; - short y1 = area->v1->vec.y; - short x2 = area->v3->vec.x; - short y2 = area->v3->vec.y; - - drawscredge_area_draw(sizex, sizey, x1, y1, x2, y2, edge_thickness); -} - void ED_screen_draw_edges(wmWindow *win) { bScreen *screen = WM_window_get_active_screen(win); @@ -180,10 +150,6 @@ void ED_screen_draw_edges(wmWindow *win) } } - const blender::int2 win_size = WM_window_native_pixel_size(win); - float col[4], corner_scale, edge_thickness; - int verts_per_corner = 0; - rcti scissor_rect; BLI_rcti_init_minmax(&scissor_rect); LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { @@ -201,61 +167,56 @@ void ED_screen_draw_edges(wmWindow *win) scissor_rect.ymin, BLI_rcti_size_x(&scissor_rect) + 1, BLI_rcti_size_y(&scissor_rect) + 1); + GPU_scissor_test(true); - /* It seems that all areas gets smaller when pixelsize is > 1. - * So in order to avoid missing pixels we just disable de scissors. */ - if (U.pixelsize <= 1.0f) { - GPU_scissor_test(true); - } - + float col[4]; UI_GetThemeColor4fv(TH_EDITOR_BORDER, col); - col[3] = 1.0f; - corner_scale = UI_SCALE_FAC * 8.0f; - edge_thickness = corner_scale * 0.21f; + + const float edge_thickness = float(U.border_width) * UI_SCALE_FAC; + + /* Entire width of the evaluated outline as far as the shader is concerned. */ + const float shader_scale = edge_thickness + EDITORRADIUS; + const float corner_coverage[10] = { + 0.144f, 0.25f, 0.334f, 0.40f, 0.455, 0.5, 0.538, 0.571, 0.6, 0.625f}; + const float shader_width = corner_coverage[U.border_width - 1]; GPU_blend(GPU_BLEND_ALPHA); + int verts_per_corner = 0; blender::gpu::Batch *batch = batch_screen_edges_get(&verts_per_corner); + GPU_batch_program_set_builtin(batch, GPU_SHADER_2D_AREA_BORDERS); GPU_batch_uniform_1i(batch, "cornerLen", verts_per_corner); - GPU_batch_uniform_1f(batch, "scale", corner_scale); - GPU_batch_uniform_1f(batch, "width", 0.2f); + GPU_batch_uniform_1f(batch, "scale", shader_scale); + GPU_batch_uniform_1f(batch, "width", shader_width); GPU_batch_uniform_4fv(batch, "color", col); LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { - drawscredge_area(area, win_size[0], win_size[1], edge_thickness); + drawscredge_area(*area, edge_thickness); } float outline1[4]; float outline2[4]; + rctf bounds; UI_GetThemeColor4fv(TH_EDITOR_OUTLINE, outline1); UI_GetThemeColor4fv(TH_EDITOR_OUTLINE_ACTIVE, outline2); UI_draw_roundbox_corner_set(UI_CNR_ALL); - const float offset = UI_SCALE_FAC * 1.34f; - LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { - rctf rectf2 = {float(area->totrct.xmin) + offset - 1.0f, - float(area->totrct.xmax) - offset + 1.5f, - float(area->totrct.ymin) + offset - 1.0f, - float(area->totrct.ymax) - offset + 1.0f}; - - UI_draw_roundbox_4fv_ex(&rectf2, + BLI_rctf_rcti_copy(&bounds, &area->totrct); + UI_draw_roundbox_4fv_ex(&bounds, nullptr, nullptr, 1.0f, (area == active_area) ? outline2 : outline1, U.pixelsize, - 6.0f * UI_SCALE_FAC); + EDITORRADIUS); } GPU_blend(GPU_BLEND_NONE); - - if (U.pixelsize <= 1.0f) { - GPU_scissor_test(false); - } + GPU_scissor_test(false); } -void screen_draw_move_highlight(bScreen *screen, eScreenAxis dir_axis) +void screen_draw_move_highlight(const wmWindow *win, bScreen *screen, eScreenAxis dir_axis) { rctf rect = {SHRT_MAX, SHRT_MIN, SHRT_MAX, SHRT_MIN}; @@ -274,11 +235,34 @@ void screen_draw_move_highlight(bScreen *screen, eScreenAxis dir_axis) }; } + /* Pull in ends not at window edges. */ + rcti window_rect; + WM_window_screen_rect_calc(win, &window_rect); + const float offset = U.border_width * UI_SCALE_FAC; if (dir_axis == SCREEN_AXIS_H) { - BLI_rctf_pad(&rect, 0.0f, 5.0f * U.pixelsize); + if (rect.xmin > (window_rect.xmin + 2)) { + rect.xmin += offset; + } + if (rect.xmax < (window_rect.xmax - 2)) { + rect.xmax -= offset; + } } else { - BLI_rctf_pad(&rect, 5.0f * U.pixelsize, 0.0f); + if (rect.ymin > (window_rect.ymin + 2)) { + rect.ymin += offset; + } + if (rect.ymax < (window_rect.ymax - 2)) { + rect.ymax -= offset; + } + } + + const float width = std::min(2.0f * U.border_width * UI_SCALE_FAC, 5.0f * UI_SCALE_FAC); + + if (dir_axis == SCREEN_AXIS_H) { + BLI_rctf_pad(&rect, 0.0f, width); + } + else { + BLI_rctf_pad(&rect, width, 0.0f); } float inner[4] = {1.0f, 1.0f, 1.0f, 0.4f}; @@ -287,7 +271,7 @@ void screen_draw_move_highlight(bScreen *screen, eScreenAxis dir_axis) UI_draw_roundbox_corner_set(UI_CNR_ALL); UI_draw_roundbox_4fv_ex( - &rect, inner, nullptr, 1.0f, outline, 4.0f * U.pixelsize, 2.5f * UI_SCALE_FAC); + &rect, inner, nullptr, 1.0f, outline, width - U.pixelsize, 2.5f * UI_SCALE_FAC); } static void screen_draw_area_drag_tip( @@ -357,7 +341,7 @@ static void screen_draw_area_closed(int xmin, int xmax, int ymin, int ymax) rctf rect = {float(xmin), float(xmax), float(ymin), float(ymax)}; float darken[4] = {0.0f, 0.0f, 0.0f, 0.7f}; UI_draw_roundbox_corner_set(UI_CNR_ALL); - UI_draw_roundbox_4fv_ex(&rect, darken, nullptr, 1.0f, nullptr, U.pixelsize, 6 * UI_SCALE_FAC); + UI_draw_roundbox_4fv_ex(&rect, darken, nullptr, 1.0f, nullptr, U.pixelsize, EDITORRADIUS); } void screen_draw_join_highlight(const wmWindow *win, ScrArea *sa1, ScrArea *sa2, eScreenDir dir) @@ -428,7 +412,7 @@ void screen_draw_join_highlight(const wmWindow *win, ScrArea *sa1, ScrArea *sa2, UI_draw_roundbox_corner_set(UI_CNR_ALL); float outline[4] = {1.0f, 1.0f, 1.0f, 0.4f}; float inner[4] = {1.0f, 1.0f, 1.0f, 0.10f}; - UI_draw_roundbox_4fv_ex(&combined, inner, nullptr, 1.0f, outline, U.pixelsize, 6 * UI_SCALE_FAC); + UI_draw_roundbox_4fv_ex(&combined, inner, nullptr, 1.0f, outline, U.pixelsize, EDITORRADIUS); screen_draw_area_drag_tip( win, win->eventstate->xy[0], win->eventstate->xy[1], sa1, IFACE_("Join Areas")); @@ -439,7 +423,7 @@ static void rounded_corners(rctf rect, float color[4], int corners) GPUVertFormat *format = immVertexFormat(); const uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT); - const float rad = 7 * UI_SCALE_FAC; + const float rad = EDITORRADIUS; float vec[4][2] = { {0.195, 0.02}, @@ -518,7 +502,7 @@ void screen_draw_dock_preview(const wmWindow *win, float border[4]; UI_GetThemeColor4fv(TH_EDITOR_BORDER, border); UI_draw_roundbox_corner_set(UI_CNR_ALL); - float half_line_width = 2.0f * U.pixelsize; + float half_line_width = float(U.border_width) * UI_SCALE_FAC; rctf dest; rctf remainder; @@ -558,7 +542,7 @@ void screen_draw_dock_preview(const wmWindow *win, } rounded_corners(dest, border, corners); - UI_draw_roundbox_4fv_ex(&dest, inner, nullptr, 1.0f, outline, U.pixelsize, 6 * UI_SCALE_FAC); + UI_draw_roundbox_4fv_ex(&dest, inner, nullptr, 1.0f, outline, U.pixelsize, EDITORRADIUS); if (dock_target != AreaDockTarget::Center) { /* Darken the split position itself. */ @@ -594,7 +578,7 @@ void screen_draw_split_preview(ScrArea *area, const eScreenAxis dir_axis, const if (factor < 0.0001 || factor > 0.9999) { /* Highlight the entire area. */ - UI_draw_roundbox_4fv_ex(&rect, inner, nullptr, 1.0f, outline, U.pixelsize, 7 * UI_SCALE_FAC); + UI_draw_roundbox_4fv_ex(&rect, inner, nullptr, 1.0f, outline, U.pixelsize, EDITORRADIUS); return; } @@ -602,7 +586,7 @@ void screen_draw_split_preview(ScrArea *area, const eScreenAxis dir_axis, const float y = (1 - factor) * rect.ymin + factor * rect.ymax; x = std::clamp(x, rect.xmin, rect.xmax); y = std::clamp(y, rect.ymin, rect.ymax); - float half_line_width = 2.0f * U.pixelsize; + float half_line_width = float(U.border_width) * UI_SCALE_FAC; /* Outlined rectangle to left/above split position. */ rect.xmax = (dir_axis == SCREEN_AXIS_V) ? x - half_line_width : rect.xmax; @@ -612,7 +596,7 @@ void screen_draw_split_preview(ScrArea *area, const eScreenAxis dir_axis, const border, (dir_axis == SCREEN_AXIS_H) ? UI_CNR_TOP_RIGHT | UI_CNR_TOP_LEFT : UI_CNR_BOTTOM_RIGHT | UI_CNR_TOP_RIGHT); - UI_draw_roundbox_4fv_ex(&rect, inner, nullptr, 1.0f, outline, U.pixelsize, 7 * UI_SCALE_FAC); + UI_draw_roundbox_4fv_ex(&rect, inner, nullptr, 1.0f, outline, U.pixelsize, EDITORRADIUS); /* Outlined rectangle to right/below split position. */ if (dir_axis == SCREEN_AXIS_H) { @@ -628,7 +612,7 @@ void screen_draw_split_preview(ScrArea *area, const eScreenAxis dir_axis, const border, (dir_axis == SCREEN_AXIS_H) ? UI_CNR_BOTTOM_RIGHT | UI_CNR_BOTTOM_LEFT : UI_CNR_BOTTOM_LEFT | UI_CNR_TOP_LEFT); - UI_draw_roundbox_4fv_ex(&rect, inner, nullptr, 1.0f, outline, U.pixelsize, 7 * UI_SCALE_FAC); + UI_draw_roundbox_4fv_ex(&rect, inner, nullptr, 1.0f, outline, U.pixelsize, EDITORRADIUS); /* Darken the split position itself. */ if (dir_axis == SCREEN_AXIS_H) { diff --git a/source/blender/editors/screen/screen_geometry.cc b/source/blender/editors/screen/screen_geometry.cc index 1472e553a8c..4e16f88db4a 100644 --- a/source/blender/editors/screen/screen_geometry.cc +++ b/source/blender/editors/screen/screen_geometry.cc @@ -71,13 +71,9 @@ bool screen_geom_edge_is_horizontal(ScrEdge *se) return (se->v1->vec.y == se->v2->vec.y); } -ScrEdge *screen_geom_area_map_find_active_scredge(const ScrAreaMap *area_map, - const rcti *bounds_rect, - const int mx, - const int my) +ScrEdge *screen_geom_area_map_find_active_scredge( + const ScrAreaMap *area_map, const rcti *bounds_rect, const int mx, const int my, int safety) { - int safety = BORDERPADDING; - CLAMP_MIN(safety, 2); LISTBASE_FOREACH (ScrEdge *, se, &area_map->edgebase) { @@ -121,13 +117,14 @@ ScrEdge *screen_geom_find_active_scredge(const wmWindow *win, rcti screen_rect; WM_window_screen_rect_calc(win, &screen_rect); ScrEdge *se = screen_geom_area_map_find_active_scredge( - AREAMAP_FROM_SCREEN(screen), &screen_rect, mx, my); + AREAMAP_FROM_SCREEN(screen), &screen_rect, mx, my, BORDERPADDING); if (!se) { /* Use entire window size (screen including global areas) for global area edges */ rcti win_rect; WM_window_rect_calc(win, &win_rect); - se = screen_geom_area_map_find_active_scredge(&win->global_areas, &win_rect, mx, my); + se = screen_geom_area_map_find_active_scredge( + &win->global_areas, &win_rect, mx, my, int(BORDERPADDING_GLOBAL)); } return se; } @@ -173,13 +170,13 @@ static bool screen_geom_vertices_scale_pass(const wmWindow *win, /* test for collapsed areas. This could happen in some blender version... */ /* ton: removed option now, it needs Context... */ - int headery = ED_area_headersize() + (U.pixelsize * 2); + int headery = ED_area_headersize(); if (facy > 1) { /* Keep timeline small in video edit workspace. */ LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { if (area->spacetype == SPACE_ACTION && area->v1->vec.y == screen_rect->ymin && - screen_geom_area_height(area) <= headery * facy + 1) + area->winy <= headery * facy) { ScrEdge *se = BKE_screen_find_edge(screen, area->v2, area->v3); if (se) { @@ -205,7 +202,7 @@ static bool screen_geom_vertices_scale_pass(const wmWindow *win, if (facy < 1) { /* make each window at least ED_area_headersize() high */ LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { - if (screen_geom_area_height(area) < headery) { + if (area->winy < headery) { /* lower edge */ ScrEdge *se = BKE_screen_find_edge(screen, area->v4, area->v1); if (se && area->v1 != area->v2) { diff --git a/source/blender/editors/screen/screen_intern.hh b/source/blender/editors/screen/screen_intern.hh index 8f339d0a3d5..67612d1c916 100644 --- a/source/blender/editors/screen/screen_intern.hh +++ b/source/blender/editors/screen/screen_intern.hh @@ -70,7 +70,15 @@ enum class AreaDockTarget { /** * Expanded interaction influence of area borders. */ -#define BORDERPADDING ((4.0f * UI_SCALE_FAC) + U.pixelsize) +#define BORDERPADDING (U.border_width * UI_SCALE_FAC + 3.0f * UI_SCALE_FAC) + +/** + * Number of pixels of the area border corner radius. + */ +#define EDITORRADIUS (6.0f * UI_SCALE_FAC) + +/* Less expansion needed for global edges. */ +#define BORDERPADDING_GLOBAL (3.0f * UI_SCALE_FAC) /* `area.cc` */ @@ -100,7 +108,7 @@ void screen_draw_dock_preview(const wmWindow *win, int y); void screen_draw_split_preview(ScrArea *area, eScreenAxis dir_axis, float factor); -void screen_draw_move_highlight(bScreen *screen, eScreenAxis dir_axis); +void screen_draw_move_highlight(const wmWindow *win, bScreen *screen, eScreenAxis dir_axis); /* `screen_edit.cc` */ @@ -166,7 +174,8 @@ bool screen_geom_edge_is_horizontal(ScrEdge *se); ScrEdge *screen_geom_area_map_find_active_scredge(const ScrAreaMap *area_map, const rcti *bounds_rect, int mx, - int my); + int my, + int safety = BORDERPADDING); /** * Need win size to make sure not to include edges along screen edge. */ diff --git a/source/blender/editors/screen/screen_ops.cc b/source/blender/editors/screen/screen_ops.cc index 0d04b522540..229ca235fea 100644 --- a/source/blender/editors/screen/screen_ops.cc +++ b/source/blender/editors/screen/screen_ops.cc @@ -1735,17 +1735,7 @@ static void area_move_set_limits(wmWindow *win, LISTBASE_FOREACH (ScrArea *, area, &screen->areabase) { if (dir_axis == SCREEN_AXIS_H) { - int areamin = ED_area_headersize(); - - if (area->v1->vec.y > window_rect.ymin) { - areamin += U.pixelsize; - } - if (area->v2->vec.y < (window_rect.ymax - 1)) { - areamin += U.pixelsize; - } - - int y1 = screen_geom_area_height(area) - areamin - int(U.pixelsize); - + const int y1 = area->winy - ED_area_headersize(); /* if top or down edge selected, test height */ if (area->v1->editflag && area->v4->editflag) { *bigger = min_ii(*bigger, y1); @@ -1755,17 +1745,7 @@ static void area_move_set_limits(wmWindow *win, } } else { - int areamin = AREAMINX * UI_SCALE_FAC; - - if (area->v1->vec.x > window_rect.xmin) { - areamin += U.pixelsize; - } - if (area->v4->vec.x < (window_rect.xmax - 1)) { - areamin += U.pixelsize; - } - - int x1 = screen_geom_area_width(area) - areamin - int(U.pixelsize); - + const int x1 = area->winx - (AREAMINX * UI_SCALE_FAC); /* if left or right edge selected, test width */ if (area->v1->editflag && area->v2->editflag) { *bigger = min_ii(*bigger, x1); @@ -1777,11 +1757,11 @@ static void area_move_set_limits(wmWindow *win, } } -static void area_move_draw_cb(const wmWindow * /*win*/, void *userdata) +static void area_move_draw_cb(const wmWindow *win, void *userdata) { const wmOperator *op = static_cast(userdata); const sAreaMoveData *md = static_cast(op->customdata); - screen_draw_move_highlight(md->screen, md->dir_axis); + screen_draw_move_highlight(win, md->screen, md->dir_axis); } /* validate selection inside screen, set variables OK */ diff --git a/source/blender/makesdna/DNA_screen_types.h b/source/blender/makesdna/DNA_screen_types.h index fb156052ff0..15163fa610d 100644 --- a/source/blender/makesdna/DNA_screen_types.h +++ b/source/blender/makesdna/DNA_screen_types.h @@ -576,7 +576,7 @@ enum { AREA_FLAG_OFFSCREEN = (1 << 9), }; -#define AREAGRID 4 +#define AREAGRID 1 #define AREAMINX 29 #define HEADER_PADDING_Y 6 #define HEADERY (20 + HEADER_PADDING_Y) diff --git a/source/blender/makesdna/DNA_userdef_types.h b/source/blender/makesdna/DNA_userdef_types.h index 1d8ea7c1431..6f2e58ad759 100644 --- a/source/blender/makesdna/DNA_userdef_types.h +++ b/source/blender/makesdna/DNA_userdef_types.h @@ -856,7 +856,11 @@ typedef struct UserDef { short versions; short dbl_click_time; - char _pad0[3]; + char _pad0[2]; + + /** Space around each area. Inter-editor gap width. */ + char border_width; + char mini_axis_type; /** #eUserpref_UI_Flag. */ int uiflag; diff --git a/source/blender/makesrna/intern/rna_userdef.cc b/source/blender/makesrna/intern/rna_userdef.cc index f43052a2fb2..e7fd92c6136 100644 --- a/source/blender/makesrna/intern/rna_userdef.cc +++ b/source/blender/makesrna/intern/rna_userdef.cc @@ -5148,6 +5148,11 @@ static void rna_def_userdef_view(BlenderRNA *brna) RNA_def_property_ui_range(prop, 0.5f, 3.0f, 1, 2); RNA_def_property_update(prop, 0, "rna_userdef_gpu_update"); + prop = RNA_def_property(srna, "border_width", PROP_INT, PROP_NONE); + RNA_def_property_ui_text(prop, "Border Width", "Size of the padding around each editor."); + RNA_def_property_range(prop, 1.0f, 10.f); + RNA_def_property_update(prop, 0, "rna_userdef_gpu_update"); + prop = RNA_def_property(srna, "ui_line_width", PROP_ENUM, PROP_NONE); RNA_def_property_enum_items(prop, line_width); RNA_def_property_ui_text(