/// <inheritdoc /> public override DragDropEffect OnDragMove(ref Vector2 location, DragData data) { var result = base.OnDragMove(ref location, data); if (_dragScripts.HasValidDrag) { result = _dragScripts.Effect; } return(result); }
/// <inheritdoc /> public override DragDropEffect OnDragMove(ref Vector2 location, DragData data) { var result = base.OnDragMove(ref location, data); if (result == DragDropEffect.None && _dragOverItems.HasValidDrag) { result = _dragOverItems.Effect; } return(result); }
public void CalculateScale() { DragData firstDrag = drags[0]; DragData secondDrag = drags[1]; float distanceStart = Vector3.Distance(firstDrag.scalePoint, secondDrag.scalePoint); float distanceNow = Vector3.Distance(firstDrag.currentPosition, secondDrag.currentPosition); scalePercentage = distanceNow / distanceStart; transform.localScale = dragOriginalScale * scalePercentage; }
/// <inheritdoc /> public override DragDropEffect OnDragMove(ref Vector2 location, DragData data) { var result = base.OnDragEnter(ref location, data); if (result == DragDropEffect.None) { result = _currentDragEffect; } return(result); }
/// <inheritdoc /> public override DragDropEffect OnDragEnter(ref Vector2 location, DragData data) { var result = base.OnDragEnter(ref location, data); if (result != DragDropEffect.None) { return(result); } return(DragHandlers.OnDragEnter(data)); }
/// <inheritdoc /> public override DragDropEffect OnDragMove(ref Float2 location, DragData data) { var result = base.OnDragMove(ref location, data); if (result != DragDropEffect.None) { return(result); } return(_dragHandlers.Effect); }
/// <summary> /// Dispatches a `drop` event. /// </summary> /// <param name="x">x coordinate</param> /// <param name="y">y coordinate</param> /// <param name="data">Drag data containing items and operations mask.</param> /// <returns>A Task that resolves when the message was confirmed by the browser</returns> public Task DropAsync(decimal x, decimal y, DragData data) => _client.SendAsync( "Input.dispatchDragEvent", new InputDispatchDragEventRequest { Type = DragEventType.Drop, X = x, Y = y, Modifiers = _keyboard.Modifiers, Data = data, });
/// <summary> /// Starts the drag and drop operation. /// </summary> /// <param name="data">The data.</param> public void DoDragDrop(DragData data) { if (data is DragDataText text) { DoDragDrop(text.Text); } else { throw new NotImplementedException("Only DragDataText drag and drop is supported."); } }
public async void DropDataAsync(DragData data) { var storage = (IBlobStorage)data.Properties["storage"]; var blobs = (List <Blob>)data.Properties["blobs"]; if (await DialogService?.AskYesNoAsync("Copy Files", $"Copy {"item".ToQuantity(blobs.Count)} to {Account.DisplayName}{FolderPath}?")) { var copyTask = new CopyFilesTask(storage, blobs, Storage, FolderPath); await TaskService.ScheduleAsync(copyTask); } }
public override DragAndDropVisualMode DoDrag(TreeViewItem parentNode, TreeViewItem targetNode, bool perform, TreeViewDragging.DropPosition dragPos) { DragData genericData = DragAndDrop.GetGenericData("AudioMixerDragging") as DragData; if (genericData != null) { List <AudioMixerItem> draggedItems = genericData.m_DraggedItems; AudioMixerItem item = parentNode as AudioMixerItem; if ((item != null) && (genericData != null)) { if (< > f__am$cache0 == null) {
private void RotateAroundTransform(DragData drag) { // In order to add two quaternion rotations correctly you multiply them. // To subtract you need to multiply by the inverse. Quaternion rotationDelta = ( Snap.LocalRotationOfWorldRotation(mesh.transform, drag.transform.rotation) * Quaternion.Inverse(Snap.LocalRotationOfWorldRotation(mesh.transform, drag.startTransformRotation)) ); Quaternion snappedRotationDelta = Snap.RotationDelta(rotationDelta); transform.position = Snap.RotateAroundPivot(mesh.transform, transform.position, drag.transform.position, snappedRotationDelta); }
public int DragsIndexOfControllerIndex(int controllerIndex) { for (int i = 0; i < drags.Count; i++) { DragData drag = drags[i]; if (drag.controllerIndex == controllerIndex) { return(i); } } return(-1); }
/// <inheritdoc /> public override DragDropEffect OnDragDrop(ref Vector2 location, DragData data) { var result = base.OnDragDrop(ref location, data); if (result != DragDropEffect.None) return result; // Check if drag sth Vector3 hitLocation = ViewPosition; SceneGraphNode hit = null; if (_dragHandlers.HasValidDrag()) { // Get mouse ray and try to hit any object var ray = ConvertMouseToRay(ref location); hit = _window.Graph.Root.RayCast(ref ray, out var closest, SceneGraphNode.RayCastData.FlagTypes.SkipColliders); if (hit != null) { // Use hit location hitLocation = ray.Position + ray.Direction * closest; } else { // Use area in front of the viewport hitLocation = ViewPosition + ViewDirection * 100; } } // Drag assets if (_dragAssets.HasValidDrag) { result = _dragAssets.Effect; // Process items for (int i = 0; i < _dragAssets.Objects.Count; i++) { var item = _dragAssets.Objects[i]; Spawn(item, hit, ref hitLocation); } } // Drag actor type else if (_dragActorType.HasValidDrag) { result = _dragActorType.Effect; // Process items for (int i = 0; i < _dragActorType.Objects.Count; i++) { var item = _dragActorType.Objects[i]; Spawn(item, hit, ref hitLocation); } } return result; }
/// <inheritdoc /> public override DragDropEffect OnDragDrop(ref Vector2 location, DragData data) { ClearDragEffects(); var result = base.OnDragDrop(ref location, data); if (result != DragDropEffect.None) { return(result); } // Check if drag sth Vector3 hitLocation = ViewPosition; SceneGraphNode hit = null; if (DragHandlers.HasValidDrag()) { GetHitLocation(ref location, out hit, out hitLocation); } // Drag assets if (_dragAssets.HasValidDrag) { result = _dragAssets.Effect; // Process items for (int i = 0; i < _dragAssets.Objects.Count; i++) { var item = _dragAssets.Objects[i]; Spawn(item, hit, ref hitLocation); } } // Drag actor type else if (_dragActorType.HasValidDrag) { result = _dragActorType.Effect; // Process items for (int i = 0; i < _dragActorType.Objects.Count; i++) { var item = _dragActorType.Objects[i]; Spawn(item, hit, ref hitLocation); } } DragHandlers.OnDragDrop(new DragDropEventArgs() { Hit = hit, HitLocation = hitLocation }); return(result); }
public int DragsIndexOfControllerIndex(int controllerIndex) { //Debug.Log("DragsIndexOfControllerIndex["+ GetInstanceID()+"] drags.Count=" + drags.Count + ",controllerIndex=" + controllerIndex); for (int i = 0; i < drags.Count; i++) { DragData drag = drags[i]; if (drag.controllerIndex == controllerIndex) { return(i); } } return(-1); }
/// <summary> /// Drag handler. /// </summary> private void PerformDrag(DragData dragData) { PerformDragInternal(dragData); // Save this for spinning. m_lastDragDataQueue.Enqueue(dragData); if (m_lastDragDataQueue.Count > m_numToAverage) { m_lastDragDataQueue.Dequeue(); } m_glControl.Invalidate(); }
/// <inheritdoc /> public override DragDropEffect OnDragMove(ref Vector2 location, DragData data) { var result = base.OnDragMove(ref location, data); if (result != DragDropEffect.None) { return(result); } var dragEffect = _dragHandlers.Effect(); return(dragEffect ?? DragDropEffect.None); }
public static void DoDrag(DragData data) { if ([email protected]() == data.to.FirstElement) { return; // элемент сам на себя } var name = $"{GetOperaionName(data.Mode)} {[email protected]} -> {data.to.Container.Header.Header}"; var undoChain = new UndoChain(name); undoChain.Add(UndoCollectionScopeFactory.CreateScope([email protected])); undoChain.Add(UndoCollectionScopeFactory.CreateScope(data.to.Container)); var mode = data.Mode; if ([email protected] is SmartFiled && !(data.to.Container is WorkSpace)) { mode = SwapMode.Copy; // не удаляем поля при перетаскивании на элементы } switch (mode) { case SwapMode.Copy: { var clone = [email protected](e => e.GetClone()); data.to.Add(clone); break; } case SwapMode.Replace: { [email protected](data.from.Elements); data.to.Add([email protected]); break; } case SwapMode.Swap: { if (data.to.FirstElement.GetType() != typeof(Tag) || data.to.Container.GetType() != typeof(SmartFiled)) { data.to.Remove(data.to.Elements); } if ([email protected]() != typeof(Tag) || [email protected]() != typeof(SmartFiled)) { data.from.Remove([email protected]); } data.to.Add([email protected]); [email protected](data.to.Elements); break; } } WorkSpace.Instance.Undo.AddScope(undoChain); }
/// <summary> /// Called when drag enter. /// </summary> /// <param name="data">The data.</param> /// <returns>The result.</returns> public DragDropEffect?OnDragEnter(/*ref Vector2 location, */ DragData data) { DragDropEffect?effect = null; foreach (var dragHelper in _dragHelpers) { if (dragHelper.OnDragEnter(data)) { effect = dragHelper.Effect; } } return(effect); }
/// <inheritdoc /> public override DragDropEffect OnDragDrop(ref Vector2 location, DragData data) { var result = base.OnDragDrop(ref location, data); if (_dragScriptItems.HasValidDrag) { result = _dragScriptItems.Effect; AddScripts(_dragScriptItems.Objects); } _dragScriptItems.OnDragDrop(); return(result); }
public void OnDragToTarget(DragData data) { if (_IsReady) { if (IsDraggedIconTheSameAsThisIcon(data)) { CreateFullCharacterAndMoveIconBackToOrigin(data); } } else { Logging.Log <ReplaceIconWithCharacter>("Not configured so could not handle end of drag"); } }
private void AssociatedObject_Drop(object sender, DragEventArgs e) { #if alldbg || dbg DesktopPanelTool.Lib.Debug.WriteLine($"dropping"); #endif if (DropHandlerCommand != null) { var dragComponentData = new DragData(e.Data, e, AssociatedObject); if (DropHandlerCommand.CanExecute(dragComponentData)) { DropHandlerCommand.Execute(dragComponentData); } } }
/// <inheritdoc /> public override DragDropEffect OnDragEnter(ref Vector2 location, DragData data) { var result = base.OnDragEnter(ref location, data); if (result == DragDropEffect.None) { if (_dragOverItems.OnDragEnter(data, ValidateDragItemFunc)) { result = _dragOverItems.Effect; } } return(result); }
/// <inheritdoc /> public override DragDropEffect OnDragEnter(ref Vector2 location, DragData data) { var result = base.OnDragEnter(ref location, data); if (_dragScriptItems == null) { _dragScriptItems = new DragScriptItems(); } if (_dragScriptItems.OnDragEnter(data, ValidateScript)) { result = _dragScriptItems.Effect; } return(result); }
/// <inheritdoc /> public override DragDropEffect OnDragMove(ref Vector2 location, DragData data) { ClearDragEffects(); var result = base.OnDragMove(ref location, data); if (result != DragDropEffect.None) { return(result); } SetDragEffects(ref location); return(DragHandlers.Effect); }
/// <inheritdoc /> public override DragDropEffect OnDragEnter(ref Float2 location, DragData data) { base.OnDragEnter(ref location, data); if (_dragOverItems == null) { _dragOverItems = new DragItems(ValidateDragItem); } _dragOverItems.OnDragEnter(data); var result = GetDragEffect(data); _validDragOver = result != DragDropEffect.None; return(result); }
/// <summary> /// Called when drag enter. /// </summary> /// <param name="data">The data.</param> /// <returns>The result.</returns> public DragDropEffect OnDragEnter(/*ref Vector2 location, */ DragData data) { DragDropEffect effect = DragDropEffect.None; for (var i = 0; i < Count; i++) { var dragHelper = this[i]; if (dragHelper.OnDragEnter(data)) { effect = dragHelper.Effect; } } return(effect); }
/// <summary> /// Called when drag enters. /// </summary> /// <param name="data">The data.</param> /// <param name="validateFunc">The validate function. Check if gathered object is valid to drop it.</param> /// <returns>True if drag event is valid and can be performed, otherwise false.</returns> public bool OnDragEnter(DragData data, Func <string, bool> validateFunc) { if (data == null || validateFunc == null) { throw new ArgumentNullException(); } Parameter = null; if (data is DragDataText text) { GetherObjects(text, validateFunc); } return(HasValidDrag); }
/// <inheritdoc /> public override DragDropEffect OnDragMove(ref Vector2 location, DragData data) { var result = base.OnDragMove(ref location, data); if (result != DragDropEffect.None) { return(result); } if (TrySelectTabUnderLocation(ref location)) { return(DragDropEffect.Move); } return(DragDropEffect.None); }
public int FindOrCreateDragsIndexOfControllerIndex(int controllerIndex) { int index = DragsIndexOfControllerIndex(controllerIndex); if (index == -1) { DragData drag = new DragData(); drag.controllerIndex = controllerIndex; drags.Add(drag); return(drags.Count - 1); } else { return(index); } }
public DragDropEffects StartDrag (IntPtr handle, object data, DragDropEffects allowed_effects) { drag_data = new DragData (); drag_data.Window = handle; drag_data.State = DragState.Beginning; drag_data.MouseState = XplatUIX11.MouseState; drag_data.Data = data; drag_data.SupportedTypes = DetermineSupportedTypes (data); drag_data.AllowedEffects = allowed_effects; drag_data.Action = ActionFromEffect (allowed_effects); if (CursorNo == null) { // Make sure the cursors are created CursorNo = new Cursor (typeof (X11Dnd), "DnDNo.cur"); CursorCopy = new Cursor (typeof (X11Dnd), "DnDCopy.cur"); CursorMove = new Cursor (typeof (X11Dnd), "DnDMove.cur"); CursorLink = new Cursor (typeof (X11Dnd), "DnDLink.cur"); } drag_data.LastTopLevel = IntPtr.Zero; control = null; System.Windows.Forms.MSG msg = new MSG(); object queue_id = XplatUI.StartLoop (Thread.CurrentThread); Timer timer = new Timer (); timer.Tick += new EventHandler (DndTickHandler); timer.Interval = 100; int suc; drag_data.State = DragState.Dragging; suc = XplatUIX11.XSetSelectionOwner (display, XdndSelection, drag_data.Window, IntPtr.Zero); if (suc == 0) { Console.Error.WriteLine ("Could not take ownership of XdndSelection aborting drag."); drag_data.Reset (); return DragDropEffects.None; } drag_data.State = DragState.Dragging; drag_data.CurMousePos = new Point (); source = toplevel = target = IntPtr.Zero; dropped = false; tracking = true; motion_poll = -1; timer.Start (); // Send Enter to the window initializing the dnd operation - which initializes the data SendEnter (drag_data.Window, drag_data.Window, drag_data.SupportedTypes); drag_data.LastTopLevel = toplevel; while (tracking && XplatUI.GetMessage (queue_id, ref msg, IntPtr.Zero, 0, 0)) { if (msg.message >= Msg.WM_KEYFIRST && msg.message <= Msg.WM_KEYLAST) { HandleKeyMessage (msg); } else { switch (msg.message) { case Msg.WM_LBUTTONUP: case Msg.WM_RBUTTONUP: case Msg.WM_MBUTTONUP: if (msg.message == Msg.WM_LBUTTONDOWN && drag_data.MouseState != MouseButtons.Left) break;; if (msg.message == Msg.WM_RBUTTONDOWN && drag_data.MouseState != MouseButtons.Right) break; if (msg.message == Msg.WM_MBUTTONDOWN && drag_data.MouseState != MouseButtons.Middle) break; HandleButtonUpMsg (); // We don't want to dispatch button up neither (Match .Net) // Thus we have to remove capture by ourselves RemoveCapture (msg.hwnd); continue; case Msg.WM_MOUSEMOVE: motion_poll = 0; drag_data.CurMousePos.X = Control.LowOrder ((int) msg.lParam.ToInt32 ()); drag_data.CurMousePos.Y = Control.HighOrder ((int) msg.lParam.ToInt32 ()); HandleMouseOver (); // We don't want to dispatch mouse move continue; } XplatUI.DispatchMessage (ref msg); } } timer.Stop (); // If the target is a mwf control, return until DragEnter/DragLeave has been fired, // which means the respective -already sent- dnd ClientMessages have been received and handled. if (control != null) Application.DoEvents (); if (!dropped) return DragDropEffects.None; if (drag_event != null) return drag_event.Effect; // Fallback. return DragDropEffects.None; }
public void Draw(Rect fullRect) { Rect listRect; if (ShowSortPane) { var releaseSkin = _pmSettings.ReleasesPane; var searchRect = new Rect(fullRect.xMin, fullRect.yMin, fullRect.width, releaseSkin.IconRowHeight); DrawSearchPane(searchRect); listRect = Rect.MinMaxRect( fullRect.xMin, fullRect.yMin + releaseSkin.IconRowHeight, fullRect.xMax, fullRect.yMax); } else { listRect = fullRect; } var searchFilter = _model.SearchFilter.Trim().ToLowerInvariant(); var visibleEntries = _entries.Where(x => x.Name.ToLowerInvariant().Contains(searchFilter)).ToList(); var viewRect = new Rect(0, 0, listRect.width - 30.0f, visibleEntries.Count * _settings.ItemHeight); var isListUnderMouse = listRect.Contains(Event.current.mousePosition); ImguiUtil.DrawColoredQuad(listRect, GetListBackgroundColor(isListUnderMouse)); switch (Event.current.type) { case EventType.MouseUp: { // Clear our drag info in DragAndDrop so that we know that we are not dragging DragAndDrop.PrepareStartDrag(); break; } case EventType.DragPerform: // Drag has completed { if (isListUnderMouse) { DragAndDrop.AcceptDrag(); var receivedDragData = DragAndDrop.GetGenericData(DragId) as DragData; if (receivedDragData != null) { DragAndDrop.PrepareStartDrag(); _manager.OnDragDrop(receivedDragData, this); } } break; } case EventType.MouseDrag: { if (isListUnderMouse) { var existingDragData = DragAndDrop.GetGenericData(DragId) as DragData; if (existingDragData != null) { DragAndDrop.StartDrag("Dragging List Element"); Event.current.Use(); } } break; } case EventType.DragUpdated: { if (isListUnderMouse) { var existingDragData = DragAndDrop.GetGenericData(DragId) as DragData; if (existingDragData != null && (_manager != null && _manager.IsDragAllowed(existingDragData, this))) { DragAndDrop.visualMode = DragAndDropVisualMode.Copy; Event.current.Use(); } else { DragAndDrop.visualMode = DragAndDropVisualMode.Rejected; } } break; } case EventType.ContextClick: { if (isListUnderMouse) { _manager.OpenContextMenu(this); Event.current.Use(); } break; } } bool clickedItem = false; float yPos = 0; _model.ScrollPos = GUI.BeginScrollView(listRect, _model.ScrollPos, viewRect); { foreach (var entry in visibleEntries) { var labelRect = new Rect(0, yPos, listRect.width, _settings.ItemHeight); bool isItemUnderMouse = labelRect.Contains(Event.current.mousePosition); Color itemColor; if (entry.IsSelected) { itemColor = _settings.Theme.ListItemSelectedColor; } else { itemColor = GUI.enabled && isItemUnderMouse ? _settings.Theme.ListItemHoverColor : _settings.Theme.ListItemColor; } ImguiUtil.DrawColoredQuad(labelRect, itemColor); switch (Event.current.type) { case EventType.MouseUp: { if (isItemUnderMouse && Event.current.button == 0) { if (!Event.current.shift && !Event.current.control) { _manager.ClearSelected(); ClickSelect(entry); } } break; } case EventType.MouseDown: { if (isItemUnderMouse) { // Unfocus on text field GUI.FocusControl(null); clickedItem = true; ClickSelect(entry); if (Event.current.button == 0) { DragAndDrop.PrepareStartDrag(); var dragData = new DragData() { Entries = GetSelected(), SourceList = this, }; DragAndDrop.SetGenericData(DragId, dragData); DragAndDrop.objectReferences = new UnityEngine.Object[0]; } Event.current.Use(); } break; } } GUI.Label(labelRect, entry.Name, _settings.ItemTextStyle); yPos += _settings.ItemHeight; } } GUI.EndScrollView(); if (Event.current.type == EventType.MouseDown && Event.current.button == 0 && !clickedItem && isListUnderMouse) { // Unfocus on text field GUI.FocusControl(null); _manager.ClearSelected(); } }