UI: Improvement to Screen Area Options Menu Invoke Area Join

Right-clicking on an edge between editors, the "Screen Area Options"
menu has a number of items including for Area Join.  When docking is
NOT enabled this gives the prior behavior of interactive join where
you can change direction and requires Enter to confirm.  If docking
is enabled then there are instead instant join options but now with
a specific icon for each direction.

Pull Request: https://projects.blender.org/blender/blender/pulls/126616
This commit is contained in:
Harley Acheson
2024-08-22 20:25:51 +02:00
committed by Harley Acheson
parent 1d1ea87617
commit 810687ad5b
7 changed files with 93 additions and 36 deletions

View File

@@ -0,0 +1 @@
<svg id="svg4" height="1600" viewBox="0 0 1600 1600" width="1600" xmlns="http://www.w3.org/2000/svg" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"><sodipodi:namedview pagecolor="#303030" showgrid="true"><inkscape:grid id="grid5" units="px" spacingx="100" spacingy="100" color="#4772b3" opacity="0.2" visible="true" /></sodipodi:namedview><g fill="#fff"><path id="path1" d="m6.5006767 3c-.2761 0-.5.2238603-.5.5v9.997623c0 .2761.2239.5.5.5h9.9993233c.2761 0 .5-.2239.5-.5v-9.997623c0-.2761397-.2239-.5-.5-.5zm.5 1h8.9993233v8.997623h-8.9993233z" transform="matrix(100 0 0 100 -200 -200)"/><path id="path2-9-4" d="m4.0492005 5.9332297h1.0000662l.0003895-1h-1.5004557c-.27614 0-.5.22386-.5.5v10.9978893c0 .2761.22386.5.5.5h11.0024605c.27614 0 .5-.2239.5-.5v-1.499741s-1-.0026-1 .0017v.998001h-10.0024605z" opacity=".75" transform="matrix(100 0 0 100 -204.91635 -193.22509)"/></g></svg>

After

Width:  |  Height:  |  Size: 965 B

View File

@@ -0,0 +1 @@
<svg id="svg6" height="1600" viewBox="0 0 1600 1600" width="1600" xmlns="http://www.w3.org/2000/svg" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"><sodipodi:namedview pagecolor="#303030" showgrid="true"><inkscape:grid id="grid5" units="px" spacingx="100" spacingy="100" color="#4772b3" opacity="0.2" visible="true" /></sodipodi:namedview><g id="g6" fill="#fff" transform="matrix(0 1 -1 0 1600 0)"><g id="g5" enable-background="new" transform="matrix(100 0 0 -100 -200 1800)"><path id="path1" d="m13 4h3v12h-3v-1.5c0-.2761-.2239-.5-.5-.5s-.5.2239-.5.5v2c0 .2761.2239.5.5.5h4c.2761 0 .5-.2239.5-.5v-13c0-.27614-.2239-.5-.5-.5h-4c-.2761 0-.5.22386-.5.5v2c0 .27614.2239.5.5.5s.5-.22386.5-.5z" opacity=".6"/><path id="path2" d="m4.16667 16v-12h4.83333v1h1v-1.5c0-.27614-.26117-.5-.58333-.5h-5.83334c-.32216 0-.58333.22386-.58333.5v13c0 .2761.26117.5.58333.5h5.83334c.32216 0 .58333-.2239.58333-.5v-1.5h-1v1z"/><path id="path3" d="m9 12h1v2h-1z"/><path id="path4" d="m10 6h-1v2h1z"/><path id="path5" d="m14.8536 9.64645-2-2c-.0905-.09049-.2155-.14645-.3536-.14645-.2761 0-.5.22385-.5.5v1.5h-5v1h5v1.5c0 .2761.2239.5.5.5.1381 0 .2631-.056.3536-.1464l2-2c.0904-.0905.1464-.2155.1464-.3536 0-.13808-.056-.26308-.1464-.35355z"/></g></g></svg>

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@@ -0,0 +1 @@
<svg id="svg6" height="1600" viewBox="0 0 1600 1600" width="1600" xmlns="http://www.w3.org/2000/svg" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"><sodipodi:namedview pagecolor="#303030" showgrid="true"><inkscape:grid id="grid5" units="px" spacingx="100" spacingy="100" color="#4772b3" opacity="0.2" visible="true" /></sodipodi:namedview><g id="g6" fill="#fff" transform="matrix(-1 0 0 -1 1600 1600)"><g id="g5" enable-background="new" transform="matrix(100 0 0 -100 -200 1800)"><path id="path1" d="m13 4h3v12h-3v-1.5c0-.2761-.2239-.5-.5-.5s-.5.2239-.5.5v2c0 .2761.2239.5.5.5h4c.2761 0 .5-.2239.5-.5v-13c0-.27614-.2239-.5-.5-.5h-4c-.2761 0-.5.22386-.5.5v2c0 .27614.2239.5.5.5s.5-.22386.5-.5z" opacity=".6"/><path id="path2" d="m4.16667 16v-12h4.83333v1h1v-1.5c0-.27614-.26117-.5-.58333-.5h-5.83334c-.32216 0-.58333.22386-.58333.5v13c0 .2761.26117.5.58333.5h5.83334c.32216 0 .58333-.2239.58333-.5v-1.5h-1v1z"/><path id="path3" d="m9 12h1v2h-1z"/><path id="path4" d="m10 6h-1v2h1z"/><path id="path5" d="m14.8536 9.64645-2-2c-.0905-.09049-.2155-.14645-.3536-.14645-.2761 0-.5.22385-.5.5v1.5h-5v1h5v1.5c0 .2761.2239.5.5.5.1381 0 .2631-.056.3536-.1464l2-2c.0904-.0905.1464-.2155.1464-.3536 0-.13808-.056-.26308-.1464-.35355z"/></g></g></svg>

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@@ -0,0 +1 @@
<svg id="svg6" height="1600" viewBox="0 0 1600 1600" width="1600" xmlns="http://www.w3.org/2000/svg" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"><sodipodi:namedview pagecolor="#303030" showgrid="true"><inkscape:grid id="grid5" units="px" spacingx="100" spacingy="100" color="#4772b3" opacity="0.2" visible="true" /></sodipodi:namedview><g id="g6" fill="#fff" transform="matrix(0 -1 1 0 0 1600)"><g id="g5" enable-background="new" transform="matrix(100 0 0 -100 -200 1800)"><path id="path1" d="m13 4h3v12h-3v-1.5c0-.2761-.2239-.5-.5-.5s-.5.2239-.5.5v2c0 .2761.2239.5.5.5h4c.2761 0 .5-.2239.5-.5v-13c0-.27614-.2239-.5-.5-.5h-4c-.2761 0-.5.22386-.5.5v2c0 .27614.2239.5.5.5s.5-.22386.5-.5z" opacity=".6"/><path id="path2" d="m4.16667 16v-12h4.83333v1h1v-1.5c0-.27614-.26117-.5-.58333-.5h-5.83334c-.32216 0-.58333.22386-.58333.5v13c0 .2761.26117.5.58333.5h5.83334c.32216 0 .58333-.2239.58333-.5v-1.5h-1v1z"/><path id="path3" d="m9 12h1v2h-1z"/><path id="path4" d="m10 6h-1v2h1z"/><path id="path5" d="m14.8536 9.64645-2-2c-.0905-.09049-.2155-.14645-.3536-.14645-.2761 0-.5.22385-.5.5v1.5h-5v1h5v1.5c0 .2761.2239.5.5.5.1381 0 .2631-.056.3536-.1464l2-2c.0904-.0905.1464-.2155.1464-.3536 0-.13808-.056-.26308-.1464-.35355z"/></g></g></svg>

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@@ -177,7 +177,11 @@ if(WITH_BLENDER)
anim_data
antialiased
append_blend
area_dock
area_join
area_join_down
area_join_left
area_join_up
area_swap
armature_data
arrow_leftright

View File

@@ -396,7 +396,11 @@ DEF_ICON(FORCE_DRAG)
DEF_ICON(FORCE_FLUIDFLOW)
DEF_ICON(RIGID_BODY)
DEF_ICON(RIGID_BODY_CONSTRAINT)
DEF_ICON(AREA_DOCK)
DEF_ICON(AREA_JOIN)
DEF_ICON(AREA_JOIN_DOWN)
DEF_ICON(AREA_JOIN_LEFT)
DEF_ICON(AREA_JOIN_UP)
DEF_ICON(AREA_SWAP)
DEF_ICON(SPLIT_HORIZONTAL)
DEF_ICON(SPLIT_VERTICAL)

View File

@@ -3741,7 +3741,26 @@ static int area_join_invoke(bContext *C, wmOperator *op, const wmEvent *event)
return OPERATOR_RUNNING_MODAL;
}
return OPERATOR_CANCELLED;
if (ISMOUSE(event->type)) {
if (!area_join_init(C, op, nullptr, nullptr)) {
return OPERATOR_CANCELLED;
}
}
else if (U.experimental.use_docking) {
/* Keyboard shortcut to docking. We just need the active area. */
ScrArea *sa1 = CTX_wm_area(C);
if (!sa1 || ED_area_is_global(sa1) || !area_join_init(C, op, sa1, nullptr)) {
return OPERATOR_CANCELLED;
}
}
sAreaJoinData *jd = (sAreaJoinData *)op->customdata;
jd->start_x = event->xy[0];
jd->start_y = event->xy[1];
jd->draw_callback = WM_draw_cb_activate(CTX_wm_window(C), area_join_draw_cb, op);
WM_event_add_modal_handler(C, op);
return OPERATOR_RUNNING_MODAL;
}
/* Apply the docking of the area. */
@@ -4262,12 +4281,26 @@ static int screen_area_options_invoke(bContext *C, wmOperator *op, const wmEvent
/* Join needs two very similar areas. */
if (sa1 && sa2) {
eScreenDir dir = area_getorientation(sa1, sa2);
if (dir != SCREEN_DIR_NONE) {
if (!U.experimental.use_docking && dir != SCREEN_DIR_NONE) {
uiItemFullO(layout,
"SCREEN_OT_area_join",
IFACE_("Join Areas"),
ICON_AREA_JOIN,
nullptr,
WM_OP_INVOKE_DEFAULT,
UI_ITEM_NONE,
&ptr);
RNA_int_set_array(&ptr, "source_xy", blender::int2{sa2->totrct.xmin, sa2->totrct.ymin});
RNA_int_set_array(&ptr, "target_xy", blender::int2{sa1->totrct.xmin, sa1->totrct.ymin});
uiItemS(layout);
}
else if (U.experimental.use_docking && dir != SCREEN_DIR_NONE) {
uiItemFullO(layout,
"SCREEN_OT_area_join",
(ELEM(dir, SCREEN_DIR_N, SCREEN_DIR_S)) ? IFACE_("Join Up") :
IFACE_("Join Right"),
ICON_AREA_JOIN,
ELEM(dir, SCREEN_DIR_N, SCREEN_DIR_S) ? ICON_AREA_JOIN_UP : ICON_AREA_JOIN,
nullptr,
WM_OP_EXEC_DEFAULT,
UI_ITEM_NONE,
@@ -4275,15 +4308,15 @@ static int screen_area_options_invoke(bContext *C, wmOperator *op, const wmEvent
RNA_int_set_array(&ptr, "source_xy", blender::int2{sa2->totrct.xmin, sa2->totrct.ymin});
RNA_int_set_array(&ptr, "target_xy", blender::int2{sa1->totrct.xmin, sa1->totrct.ymin});
uiItemFullO(layout,
"SCREEN_OT_area_join",
(ELEM(dir, SCREEN_DIR_N, SCREEN_DIR_S)) ? IFACE_("Join Down") :
IFACE_("Join Left"),
ICON_AREA_JOIN,
nullptr,
WM_OP_EXEC_DEFAULT,
UI_ITEM_NONE,
&ptr);
uiItemFullO(
layout,
"SCREEN_OT_area_join",
(ELEM(dir, SCREEN_DIR_N, SCREEN_DIR_S)) ? IFACE_("Join Down") : IFACE_("Join Left"),
ELEM(dir, SCREEN_DIR_N, SCREEN_DIR_S) ? ICON_AREA_JOIN_DOWN : ICON_AREA_JOIN_LEFT,
nullptr,
WM_OP_EXEC_DEFAULT,
UI_ITEM_NONE,
&ptr);
RNA_int_set_array(&ptr, "source_xy", blender::int2{sa1->totrct.xmin, sa1->totrct.ymin});
RNA_int_set_array(&ptr, "target_xy", blender::int2{sa2->totrct.xmin, sa2->totrct.ymin});
@@ -4849,31 +4882,43 @@ static void screen_area_menu_items(ScrArea *area, uiLayout *layout)
/* Mouse position as if in middle of area. */
const int loc[2] = {BLI_rcti_cent_x(&area->totrct), BLI_rcti_cent_y(&area->totrct)};
/* Vertical Split */
uiItemFullO(layout,
"SCREEN_OT_area_split",
IFACE_("Vertical Split"),
ICON_SPLIT_VERTICAL,
nullptr,
WM_OP_INVOKE_DEFAULT,
UI_ITEM_NONE,
&ptr);
if (U.experimental.use_docking) {
uiItemFullO(layout,
"SCREEN_OT_area_join",
IFACE_("Move/Split Area"),
ICON_AREA_DOCK,
nullptr,
WM_OP_INVOKE_DEFAULT,
UI_ITEM_NONE,
&ptr);
RNA_int_set_array(&ptr, "source_xy", loc);
}
else {
/* Vertical Split */
uiItemFullO(layout,
"SCREEN_OT_area_split",
IFACE_("Vertical Split"),
ICON_SPLIT_VERTICAL,
nullptr,
WM_OP_INVOKE_DEFAULT,
UI_ITEM_NONE,
&ptr);
RNA_int_set_array(&ptr, "cursor", loc);
RNA_enum_set(&ptr, "direction", SCREEN_AXIS_V);
RNA_int_set_array(&ptr, "cursor", loc);
RNA_enum_set(&ptr, "direction", SCREEN_AXIS_V);
/* Horizontal Split */
uiItemFullO(layout,
"SCREEN_OT_area_split",
IFACE_("Horizontal Split"),
ICON_SPLIT_HORIZONTAL,
nullptr,
WM_OP_INVOKE_DEFAULT,
UI_ITEM_NONE,
&ptr);
RNA_int_set_array(&ptr, "cursor", &loc[0]);
RNA_enum_set(&ptr, "direction", SCREEN_AXIS_H);
/* Horizontal Split */
uiItemFullO(layout,
"SCREEN_OT_area_split",
IFACE_("Horizontal Split"),
ICON_SPLIT_HORIZONTAL,
nullptr,
WM_OP_INVOKE_DEFAULT,
UI_ITEM_NONE,
&ptr);
RNA_int_set_array(&ptr, "cursor", &loc[0]);
RNA_enum_set(&ptr, "direction", SCREEN_AXIS_H);
}
uiItemS(layout);
@@ -4896,7 +4941,7 @@ static void screen_area_menu_items(ScrArea *area, uiLayout *layout)
uiItemO(layout, nullptr, ICON_NONE, "SCREEN_OT_area_dupli");
uiItemS(layout);
uiItemO(layout, nullptr, ICON_NONE, "SCREEN_OT_area_close");
uiItemO(layout, nullptr, ICON_X, "SCREEN_OT_area_close");
}
void ED_screens_header_tools_menu_create(bContext *C, uiLayout *layout, void * /*arg*/)