Fix T92427: Adding new nodes does no edge-panning
Unlike translating existing nodes [which disables cursor wrapping and enables edge-panning instead since rBSa1cc7042a74], adding new nodes would still show the old behavior of cursor wrapping. This has been disabled for the case when the node whould be added outside (due to menus overlapping other editors). Now enable edge-panning for adding new nodes as well and make sure this only starts once the mouse has returned into the inside rect once. Maniphest Tasks: T92427 Differential Revision: https://developer.blender.org/D13005
This commit is contained in:
parent
b94447a298
commit
4d605ef2f4
Notes:
blender-bot
2023-02-14 06:00:47 +01:00
Referenced by issue #92427, Nodes teleports when the mouse touches the border of the editor
|
@ -315,6 +315,9 @@ typedef struct View2DEdgePanData {
|
|||
/** View2d we're operating in. */
|
||||
struct View2D *v2d;
|
||||
|
||||
/** Panning should only start once being in the inside rect once (e.g. adding nodes can happen
|
||||
* outside). */
|
||||
bool enabled;
|
||||
/** Inside distance in UI units from the edge of the region within which to start panning. */
|
||||
float inside_pad;
|
||||
/** Outside distance in UI units from the edge of the region at which to stop panning. */
|
||||
|
|
|
@ -92,6 +92,8 @@ void UI_view2d_edge_pan_init(bContext *C,
|
|||
vpd->delay = delay;
|
||||
vpd->zoom_influence = zoom_influence;
|
||||
|
||||
vpd->enabled = false;
|
||||
|
||||
/* Calculate translation factor, based on size of view. */
|
||||
const float winx = (float)(BLI_rcti_size_x(&vpd->region->winrct) + 1);
|
||||
const float winy = (float)(BLI_rcti_size_y(&vpd->region->winrct) + 1);
|
||||
|
@ -227,9 +229,16 @@ void UI_view2d_edge_pan_apply(bContext *C, View2DEdgePanData *vpd, const int xy[
|
|||
BLI_rcti_pad(&inside_rect, -vpd->inside_pad * U.widget_unit, -vpd->inside_pad * U.widget_unit);
|
||||
BLI_rcti_pad(&outside_rect, vpd->outside_pad * U.widget_unit, vpd->outside_pad * U.widget_unit);
|
||||
|
||||
/* Check if we can actually start the edge pan (e.g. adding nodes outside the view will start
|
||||
* disabled). */
|
||||
if (BLI_rcti_isect_pt_v(&inside_rect, xy)) {
|
||||
/* We are inside once, can start. */
|
||||
vpd->enabled = true;
|
||||
}
|
||||
|
||||
int pan_dir_x = 0;
|
||||
int pan_dir_y = 0;
|
||||
if ((vpd->outside_pad == 0) || BLI_rcti_isect_pt_v(&outside_rect, xy)) {
|
||||
if (vpd->enabled && ((vpd->outside_pad == 0) || BLI_rcti_isect_pt_v(&outside_rect, xy))) {
|
||||
/* Find whether the mouse is beyond X and Y edges. */
|
||||
if (xy[0] > inside_rect.xmax) {
|
||||
pan_dir_x = 1;
|
||||
|
|
|
@ -156,6 +156,7 @@ void ED_operatormacros_node(void)
|
|||
OPTYPE_UNDO | OPTYPE_REGISTER);
|
||||
mot = WM_operatortype_macro_define(ot, "TRANSFORM_OT_translate");
|
||||
RNA_boolean_set(mot->ptr, "remove_on_cancel", true);
|
||||
RNA_boolean_set(mot->ptr, "view2d_edge_pan", true);
|
||||
WM_operatortype_macro_define(ot, "NODE_OT_attach");
|
||||
WM_operatortype_macro_define(ot, "NODE_OT_insert_offset");
|
||||
|
||||
|
|
Loading…
Reference in New Issue