/// <summary> /// Add a new stroke to multi stroke /// </summary> private void CreateNewStroke(Vector2 point) { if (limitType != GestureLimitType.Unlimited && !limitedDrawAreaRect.Contains(point)) { return; } if (isRecognized) { ClearGesture(); } lastPoint = Vector2.zero; currentStrokeID++; vertexCount = 0; GameObject newStroke = new GameObject(); newStroke.name = "Stroke " + currentStrokeID; newStroke.transform.parent = this.transform; currentStrokeRenderer = newStroke.AddComponent <LineRenderer>(); currentStrokeRenderer.SetVertexCount(0); currentStrokeRenderer.material = lineMaterial; currentStrokeRenderer.SetColors(startColor, endColor); currentStrokeRenderer.SetWidth(startThickness, endThickness); strokes.Add(newStroke); RegisterPoint(point); }
/// <summary> /// Adds a control instance to this window. All controls must be reference-unique, or this /// method will throw an ArgumentException. This method will also throw an ArgumentExeption /// if the control is too large to fit on the screen. A newly added control may receive /// a MouseEnter message if the mouse is within it's region, and will always receive a /// SettingUp message if it hasn't received one previously. /// </summary> /// <param name="control"></param> /// <returns></returns> /// <exception cref="System.ArgumentException">Thrown when the specified <paramref name="control"/> /// is already contained by this window.</exception> public bool AddControl(Control control) { if (ContainsControl(control) || controlAddList.Contains(control)) { throw new ArgumentException("CurrentWindow already contians an instance of this control"); } this.controlAddList.Add(control); control.ParentWindow = this; bool atRequestedPos = CheckNewlyAddedControlPosition(control); if (!atRequestedPos) { if (!ScreenRect.Contains(control.ScreenRect.TopLeft) || !ScreenRect.Contains(control.ScreenRect.BottomRight.Shift(-1, -1))) { throw new ArgumentException("The specified control is too large to fit on the screen."); } } CheckNewlyAddedControlMessages(control); control.Pigments = new PigmentMap(Pigments, control.PigmentOverrides); if (!control.IsSetup) { control.OnSettingUp(); } control.OnAdded(); OnAdded(new EventArgs <Component>(control)); return(atRequestedPos); }
/// <summary> /// Adds a control instance to this window. All controls must be reference-unique, or this /// method will throw an ArgumentException. This method will also throw an ArgumentExeption /// if the control is too large to fit on the screen. A newly added control may receive /// a MouseEnter message if the mouse is within it's region, and will always receive a /// SettingUp message if it hasn't received one previously. /// </summary> /// <param name="control"></param> /// <returns></returns> /// <exception cref="System.ArgumentException">Thrown when the specified <paramref name="control"/> /// is already contained by this window.</exception> public bool AddControl(Control control) { if (ContainsControl(control) || controlAddList.Contains(control)) { throw new ArgumentException("CurrentWindow already contians an instance of this control"); } this.controlAddList.Add(control); bool atRequestedPos = CheckNewlyAddedControlPosition(control); if (!atRequestedPos) { if (!ScreenRect.Contains(control.ScreenRect.UpperLeft) || !ScreenRect.Contains(control.ScreenRect.LowerRight)) { throw new ArgumentException("The specified control is too large to fit on the screen."); } } CheckNewlyAddedControlMessages(control); control.ParentWindow = this; control.Pigments = new PigmentMap(Pigments, control.PigmentOverrides); if (!control.isSetup) { control.OnSettingUp(); } return(atRequestedPos); }
/// <summary> /// Update visual feedback based on the current screen position of the mouse. /// </summary> /// <param name="screenPt">Latest mouse screen position.</param> /// <param name="dragFeedback">Type of drag feedback required.</param> public DragTarget Feedback(Point screenPt, PaletteDragFeedback dragFeedback) { if (ScreenRect.Contains(screenPt)) { // Create the docking indicators the first time needed _indicators ??= dragFeedback switch { PaletteDragFeedback.Rounded => new DropDockingIndicatorsRounded(_paletteDragDrop, _renderer, _hintToTarget.ContainsKey(DragTargetHint.EdgeLeft), _hintToTarget.ContainsKey(DragTargetHint.EdgeRight), _hintToTarget.ContainsKey(DragTargetHint.EdgeTop), _hintToTarget.ContainsKey(DragTargetHint.EdgeBottom), _hintToTarget.ContainsKey(DragTargetHint.Transfer)), _ => new DropDockingIndicatorsSquare(_paletteDragDrop, _renderer, _hintToTarget.ContainsKey(DragTargetHint.EdgeLeft), _hintToTarget.ContainsKey(DragTargetHint.EdgeRight), _hintToTarget.ContainsKey(DragTargetHint.EdgeTop), _hintToTarget.ContainsKey(DragTargetHint.EdgeBottom), _hintToTarget.ContainsKey(DragTargetHint.Transfer)) }; // Ensure window is Displayed in correct location _indicators.ShowRelative(ScreenRect); // Hit test against indicators and update display return(_indicators.ScreenMouseMove(screenPt) switch { 0x0040 => _hintToTarget[DragTargetHint.EdgeLeft], 0x0080 => _hintToTarget[DragTargetHint.EdgeRight], 0x0100 => _hintToTarget[DragTargetHint.EdgeTop], 0x0200 => _hintToTarget[DragTargetHint.EdgeBottom], 0x0400 => _hintToTarget[DragTargetHint.Transfer], _ => null // Mouse is not over any of the targets });
public void Update(GameTime time, IMouseManager mouse, IKeyboardManager keyboard) { IsHovered = ScreenRect.Contains(mouse.Position); if (IsHovered) { if (mouse.IsScrollWheelUp()) { OnMouseWheel(mouse.ScrollWheelDelta); if (MouseWheel != null) { MouseWheel(mouse.ScrollWheelDelta); } } else if (mouse.IsScrollWheelDown()) { OnMouseWheel(mouse.ScrollWheelDelta); if (MouseWheel != null) { MouseWheel(mouse.ScrollWheelDelta); } } if (mouse.IsButtonPressed(MouseButton.Left)) { OnMouseClick(MouseButton.Left); if (Clicked != null) { Clicked(); } if (MouseClicked != null) { MouseClicked(MouseButton.Left); } } if (mouse.IsButtonPressed(MouseButton.Middle)) { OnMouseClick(MouseButton.Middle); if (MouseClicked != null) { MouseClicked(MouseButton.Middle); } } if (mouse.IsButtonPressed(MouseButton.Right)) { OnMouseClick(MouseButton.Right); if (MouseClicked != null) { MouseClicked(MouseButton.Right); } } } OnUpdate(time, mouse, keyboard); }
public override HitTestResults HitTest(SKPointI point) { if (!ScreenRect.Contains(point)) { return(null); } for (int i = 0; i < MaxNumberOfSkills; ++i) { SKRect buttonRect = RectForSkill(i); buttonRect.Offset(Position.X, Position.Y); if (buttonRect.Contains(point)) { return(new HitTestResults(this, i)); } } return(null); }
/// <summary> /// Update visual feedback based on the current screen position of the mouse. /// </summary> /// <param name="screenPt">Latest mouse screen position.</param> /// <param name="dragFeedback">Type of drag feedback required.</param> public DragTarget Feedback(Point screenPt, PaletteDragFeedback dragFeedback) { if (ScreenRect.Contains(screenPt)) { // Create the docking indicators the first time needed if (_indicators == null) { switch (dragFeedback) { case PaletteDragFeedback.Rounded: _indicators = new DropDockingIndicatorsRounded(_paletteDragDrop, _renderer, _hintToTarget.ContainsKey(DragTargetHint.EdgeLeft), _hintToTarget.ContainsKey(DragTargetHint.EdgeRight), _hintToTarget.ContainsKey(DragTargetHint.EdgeTop), _hintToTarget.ContainsKey(DragTargetHint.EdgeBottom), _hintToTarget.ContainsKey(DragTargetHint.Transfer)); break; case PaletteDragFeedback.Square: default: _indicators = new DropDockingIndicatorsSquare(_paletteDragDrop, _renderer, _hintToTarget.ContainsKey(DragTargetHint.EdgeLeft), _hintToTarget.ContainsKey(DragTargetHint.EdgeRight), _hintToTarget.ContainsKey(DragTargetHint.EdgeTop), _hintToTarget.ContainsKey(DragTargetHint.EdgeBottom), _hintToTarget.ContainsKey(DragTargetHint.Transfer)); break; } } // Ensure window is displayed in correct location _indicators.ShowRelative(ScreenRect); // Hit test against indicators and update display switch (_indicators.ScreenMouseMove(screenPt)) { case 0x0040: return(_hintToTarget[DragTargetHint.EdgeLeft]); case 0x0080: return(_hintToTarget[DragTargetHint.EdgeRight]); case 0x0100: return(_hintToTarget[DragTargetHint.EdgeTop]); case 0x0200: return(_hintToTarget[DragTargetHint.EdgeBottom]); case 0x0400: return(_hintToTarget[DragTargetHint.Transfer]); default: // Mouse is not over any of the targets return(null); } } else { if (_indicators != null) { _indicators.MouseReset(); _indicators.Hide(); } // Mouse is not over any of the targets return(null); } }
/// <summary> /// Tests if a given screen point is inside this control /// </summary> /// <param name="p"></param> /// <returns></returns> public bool PointInControl(Vector2 p) { return(ScreenRect.Contains(ViewportToAbsolutePosition(p))); }