public void OnMouseMove( dfControl control, dfMouseEventArgs args ) { if( animating || !dragging ) return; this.momentum = ( momentum + args.MoveDelta.Scale( 1, -1 ) ) * 0.5f; args.Use(); if( args.Buttons.IsSet( dfMouseButtons.Left ) ) { var ray = args.Ray; var distance = 0f; var direction = Camera.main.transform.TransformDirection( Vector3.back ); var plane = new Plane( direction, lastPosition ); plane.Raycast( ray, out distance ); var pos = ( ray.origin + ray.direction * distance ).Quantize( control.PixelsToUnits() ); var offset = pos - lastPosition; var transformPos = ( control.transform.position + offset ).Quantize( control.PixelsToUnits() ); control.transform.position = transformPos; lastPosition = pos; } }
protected internal override void OnMouseMove( dfMouseEventArgs args ) { args.Use(); if( args.Buttons.IsSet( dfMouseButtons.Left ) ) { var ray = args.Ray; var distance = 0f; var direction = GetCamera().transform.TransformDirection( Vector3.back ); var plane = new Plane( direction, lastPosition ); plane.Raycast( ray, out distance ); var pos = ( ray.origin + ray.direction * distance ).Quantize( parent.PixelsToUnits() ); var offset = pos - lastPosition; var transformPos = ( parent.transform.position + offset ).Quantize( parent.PixelsToUnits() ); parent.transform.position = transformPos; lastPosition = pos; } base.OnMouseMove( args ); }
public void OnMouseDown( dfControl control, dfMouseEventArgs args ) { if( !args.Used && args.Buttons == dfMouseButtons.Middle ) { if( contextMenu.IsOpen ) { contextMenu.Close(); return; } args.Use(); var hitPosition = control.GetHitPosition( args ); var host = contextMenu.host; host.RelativePosition = hitPosition - host.Size * 0.5f; host.BringToFront(); host.Show(); host.Focus(); contextMenu.Open(); } }
public void HelpClicked(dfControl control, dfMouseEventArgs args) { args.Use(); TextAsset description = Resources.Load<TextAsset>("Descriptions/" + bi.className); GameObject prefab = (GameObject)Resources.Load("Prefabs/Buildings/" + bi.className); Dialog.Instance.SetDialog(bi.buildingName, description.text, "Continue", true, false,prefab); }
protected internal override void OnMouseDown(dfMouseEventArgs args) { base.GetRootContainer().BringToFront(); args.Use(); Plane plane = new Plane(this.parent.transform.TransformDirection(Vector3.back), this.parent.transform.position); Ray ray = args.Ray; float single = 0f; plane.Raycast(args.Ray, out single); this.lastPosition = ray.origin + (ray.direction * single); base.OnMouseDown(args); }
void OnMouseWheel( dfControl sender, dfMouseEventArgs args ) { if( args.Used ) return; args.Use(); if( args.WheelDelta > 0 ) SelectPrevious(); else SelectNext(); }
protected internal override void OnMouseDown( dfMouseEventArgs args ) { GetRootContainer().BringToFront(); args.Use(); var plane = new Plane( parent.transform.TransformDirection( Vector3.back ), parent.transform.position ); var ray = args.Ray; var distance = 0f; plane.Raycast( args.Ray, out distance ); lastPosition = ( ray.origin + ray.direction * distance ); base.OnMouseDown( args ); }
public void OnMouseDown( dfControl control, dfMouseEventArgs args ) { control.BringToFront(); animating = false; momentum = Vector2.zero; dragging = true; args.Use(); var plane = new Plane( control.transform.TransformDirection( Vector3.back ), control.transform.position ); var ray = args.Ray; var distance = 0f; plane.Raycast( args.Ray, out distance ); lastPosition = ( ray.origin + ray.direction * distance ); }
protected internal override void OnMouseMove(dfMouseEventArgs args) { args.Use(); if (args.Buttons.IsSet(dfMouseButtons.Left)) { Ray ray = args.Ray; float single = 0f; Vector3 vector3 = base.GetCamera().transform.TransformDirection(Vector3.back); Plane plane = new Plane(vector3, this.lastPosition); plane.Raycast(ray, out single); Vector3 vector31 = (ray.origin + (ray.direction * single)).Quantize(this.parent.PixelsToUnits()); Vector3 vector32 = vector31 - this.lastPosition; Vector3 vector33 = (this.parent.transform.position + vector32).Quantize(this.parent.PixelsToUnits()); this.parent.transform.position = vector33; this.lastPosition = vector31; } base.OnMouseMove(args); }
protected internal override void OnMouseMove( dfMouseEventArgs args ) { if( !args.Buttons.IsSet( dfMouseButtons.Left ) ) { base.OnMouseMove( args ); return; } this.Value = getValueFromMouseEvent( args ); args.Use(); Signal( "OnMouseMove", this, args ); raiseMouseMoveEvent( args ); }
protected internal override void OnMouseDown( dfMouseEventArgs args ) { if( args.Source != this ) { base.OnMouseDown( args ); return; } var setCursorPosition = !ReadOnly && args.Buttons.IsSet( dfMouseButtons.Left ) && ( ( !HasFocus && !SelectOnFocus ) || ( Time.realtimeSinceStartup - whenGotFocus ) > 0.25f ); if( setCursorPosition ) { var index = getCharIndexOfMouse( args ); if( index != cursorIndex ) { cursorIndex = index; cursorShown = true; Invalidate(); args.Use(); } mouseSelectionAnchor = cursorIndex; selectionStart = selectionEnd = cursorIndex; if( Time.realtimeSinceStartup - tripleClickTimer < 0.25f ) { SelectAll(); tripleClickTimer = 0f; } } base.OnMouseDown( args ); }
protected internal override void OnMouseMove( dfMouseEventArgs args ) { if( args is dfTouchEventArgs || isMouseDown ) { if( !args.Used && ( args.Position - touchStartPosition ).magnitude > 5 ) { var delta = args.MoveDelta.Scale( -1, 1 ); // Calculate the effective screen size var manager = GetManager(); var screenSize = manager.GetScreenSize(); // Obtain a reference to the camera used to render this control var renderCamera = manager.RenderCamera; // Scale the movement amount by the difference between the "virtual" // screen size and the real screen size delta.x = screenSize.x * ( delta.x / renderCamera.pixelWidth ); delta.y = screenSize.y * ( delta.y / renderCamera.pixelHeight ); // Set the new scroll position and momentum ScrollPosition += delta; scrollMomentum = ( scrollMomentum + delta ) * 0.5f; args.Use(); } } base.OnMouseMove( args ); }
protected internal override void OnMouseUp( dfMouseEventArgs args ) { //Parent.PerformLayout(); Parent.MakePixelPerfect(); args.Use(); base.OnMouseUp( args ); }
protected internal override void OnMouseDown( dfMouseEventArgs args ) { args.Use(); var plane = new Plane( parent.transform.TransformDirection( Vector3.back ), parent.transform.position ); var ray = args.Ray; var distance = 0f; plane.Raycast( args.Ray, out distance ); mouseAnchorPos = ( ray.origin + ray.direction * distance ); startSize = parent.Size; startPosition = parent.RelativePosition; #region Calculate the min and max edge positions minEdgePos = startPosition; maxEdgePos = (Vector2)startPosition + startSize; var minSize = parent.CalculateMinimumSize(); var maxSize = parent.MaximumSize; if( maxSize.magnitude <= float.Epsilon ) { maxSize = Vector2.one * 2048; } if( ( Edges & ResizeEdge.Left ) == ResizeEdge.Left ) { minEdgePos.x = maxEdgePos.x - maxSize.x; maxEdgePos.x = maxEdgePos.x - minSize.x; } else if( ( Edges & ResizeEdge.Right ) == ResizeEdge.Right ) { minEdgePos.x = startPosition.x + minSize.x; maxEdgePos.x = startPosition.x + maxSize.x; } if( ( Edges & ResizeEdge.Top ) == ResizeEdge.Top ) { minEdgePos.y = maxEdgePos.y - maxSize.y; maxEdgePos.y = maxEdgePos.y - minSize.y; } else if( ( Edges & ResizeEdge.Bottom ) == ResizeEdge.Bottom ) { minEdgePos.y = startPosition.y + minSize.y; maxEdgePos.y = startPosition.y + maxSize.y; } #endregion }
protected internal override void OnMouseWheel(dfMouseEventArgs args) { dfScrollbar value = this; value.Value = value.Value + this.IncrementAmount * -args.WheelDelta; args.Use(); base.Signal("OnMouseWheel", new object[] { args }); }
void ResetButton_MouseHover(dfControl control, dfMouseEventArgs mouseEvent) { // print("ResetButton_MouseHover"); mouseEvent.Use(); updateTipText(TipState.ResetButton); }
protected internal override void OnMouseMove(dfMouseEventArgs args) { if (args.Source == this.incButton || args.Source == this.decButton) { return; } if (args.Source != this.track && args.Source != this.thumb || !args.Buttons.IsSet(dfMouseButtons.Left)) { base.OnMouseMove(args); return; } this.Value = Mathf.Max(this.minValue, this.getValueFromMouseEvent(args) - this.scrollSize * 0.5f); args.Use(); base.Signal("OnMouseMove", new object[] { args }); }
protected internal override void OnMouseDown( dfMouseEventArgs args ) { if( args.Buttons.IsSet( dfMouseButtons.Left ) ) this.Focus(); if( args.Source == incButton || args.Source == decButton ) return; if( ( args.Source != track && args.Source != thumb ) || !args.Buttons.IsSet( dfMouseButtons.Left ) ) { base.OnMouseDown( args ); return; } if( args.Source == this.thumb ) { // Find the point where the ray intersects the thumb RaycastHit hitInfo; thumb.collider.Raycast( args.Ray, out hitInfo, 1000f ); // Calculate the thumb's center in global space var thumbCenter = thumb.transform.position + thumb.Pivot.TransformToCenter( thumb.Size * PixelsToUnits() ); // Calculate the offset between the intersect point and the // thumb's upper left corner so that the thumb can always // be positioned relative to the mouse while dragging this.thumbMouseOffset = ( thumbCenter - hitInfo.point ); } else { updateFromTrackClick( args ); } args.Use(); Signal( "OnMouseDown", args ); }
private void incrementPressed(dfControl sender, dfMouseEventArgs args) { if (args.Buttons.IsSet(dfMouseButtons.Left)) { dfScrollbar value = this; value.Value = value.Value + this.IncrementAmount; args.Use(); } }
protected internal override void OnMouseHover( dfMouseEventArgs args ) { var ignoreEvent = args.Source == this.incButton || args.Source == this.decButton || args.Source == this.thumb; if( ignoreEvent ) return; if( ( args.Source != track ) || !args.Buttons.IsSet( dfMouseButtons.Left ) ) { base.OnMouseHover( args ); return; } updateFromTrackClick( args ); args.Use(); Signal( "OnMouseHover", args ); }
void OnClick( dfControl sender, dfMouseEventArgs args ) { AddMessage( "New test message added to the list at " + DateTime.Now ); args.Use(); }
protected internal override void OnMouseMove( dfMouseEventArgs args ) { // Don't care about mouse movement over increment or // decrement buttons if( args.Source == this.incButton || args.Source == this.decButton ) return; if( ( args.Source != track && args.Source != thumb ) || !args.Buttons.IsSet( dfMouseButtons.Left ) ) { base.OnMouseMove( args ); return; } // Attempt to center the thumb on the mouse position this.Value = Mathf.Max( minValue, getValueFromMouseEvent( args ) - scrollSize * 0.5f ); args.Use(); Signal( "OnMouseMove", args ); }
protected internal override void OnMouseMove( dfMouseEventArgs args ) { if( !args.Buttons.IsSet( dfMouseButtons.Left ) || Edges == ResizeEdge.None ) return; args.Use(); var ray = args.Ray; var distance = 0f; var direction = this.GetCamera().transform.TransformDirection( Vector3.back ); var plane = new Plane( direction, mouseAnchorPos ); plane.Raycast( ray, out distance ); var p2u = this.PixelsToUnits(); var pos = ( ray.origin + ray.direction * distance ); var offset = ( ( pos - mouseAnchorPos ) / p2u ); // Flip Y axis for screen coordinates offset.y *= -1; var left = startPosition.x; var top = startPosition.y; var right = left + startSize.x; var bottom = top + startSize.y; if( ( Edges & ResizeEdge.Left ) == ResizeEdge.Left ) { left = Mathf.Min( maxEdgePos.x, Mathf.Max( minEdgePos.x, left + offset.x ) ); } else if( ( Edges & ResizeEdge.Right ) == ResizeEdge.Right ) { right = Mathf.Min( maxEdgePos.x, Mathf.Max( minEdgePos.x, right + offset.x ) ); } if( ( Edges & ResizeEdge.Top ) == ResizeEdge.Top ) { top = Mathf.Min( maxEdgePos.y, Mathf.Max( minEdgePos.y, top + offset.y ) ); } else if( ( Edges & ResizeEdge.Bottom ) == ResizeEdge.Bottom ) { bottom = Mathf.Min( maxEdgePos.y, Mathf.Max( minEdgePos.y, bottom + offset.y ) ); } parent.Size = new Vector2( right - left, bottom - top ); parent.RelativePosition = new Vector3( left, top, 0 ); if( parent.GetManager().PixelPerfectMode ) { parent.MakePixelPerfect(); } }
protected internal override void OnMouseWheel( dfMouseEventArgs args ) { this.Value += IncrementAmount * -args.WheelDelta; args.Use(); Signal( "OnMouseWheel", args ); }
protected internal override void OnMouseWheel( dfMouseEventArgs args ) { try { if( args.Used || !allowScrolling ) return; var wheelAmount = this.UseScrollMomentum ? 1 : 3; var amount = vertScrollbar != null ? vertScrollbar.IncrementAmount : FontSize * wheelAmount; ScrollPosition = new Vector2( scrollPosition.x, scrollPosition.y - amount * args.WheelDelta ); scrollMomentum = new Vector2( 0, -amount * args.WheelDelta ); args.Use(); Signal( "OnMouseWheel", args ); } finally { base.OnMouseWheel( args ); } }
private void incrementPressed( dfControl sender, dfMouseEventArgs args ) { if( args.Buttons.IsSet( dfMouseButtons.Left ) ) { Value += IncrementAmount; args.Use(); } }
protected internal override void OnMouseWheel( dfMouseEventArgs args ) { try { if( args.Used ) return; var amount = wheelDirection == dfControlOrientation.Horizontal ? horzScroll != null ? horzScroll.IncrementAmount : scrollWheelAmount : vertScroll != null ? vertScroll.IncrementAmount : scrollWheelAmount; if( wheelDirection == dfControlOrientation.Horizontal ) { ScrollPosition = new Vector2( scrollPosition.x - amount * args.WheelDelta, scrollPosition.y ); scrollMomentum = new Vector2( -amount * args.WheelDelta, 0 ); } else { ScrollPosition = new Vector2( scrollPosition.x, scrollPosition.y - amount * args.WheelDelta ); scrollMomentum = new Vector2( 0, -amount * args.WheelDelta ); } args.Use(); Signal( "OnMouseWheel", this, args ); } finally { base.OnMouseWheel( args ); } }
protected internal override void OnMouseDown(dfMouseEventArgs args) { RaycastHit raycastHit; if (args.Buttons.IsSet(dfMouseButtons.Left)) { base.Focus(); } if (args.Source == this.incButton || args.Source == this.decButton) { return; } if (args.Source != this.track && args.Source != this.thumb || !args.Buttons.IsSet(dfMouseButtons.Left)) { base.OnMouseDown(args); return; } if (args.Source != this.thumb) { this.updateFromTrackClick(args); } else { this.thumb.collider.Raycast(args.Ray, out raycastHit, 1000f); Vector3 center = this.thumb.transform.position + this.thumb.Pivot.TransformToCenter(this.thumb.Size * base.PixelsToUnits()); this.thumbMouseOffset = center - raycastHit.point; } args.Use(); base.Signal("OnMouseDown", new object[] { args }); }
protected internal override void OnMouseMove( dfMouseEventArgs args ) { if( args.Source != this ) { base.OnMouseMove( args ); return; } if( !ReadOnly && HasFocus && args.Buttons.IsSet( dfMouseButtons.Left ) ) { var index = getCharIndexOfMouse( args ); if( index != cursorIndex ) { cursorIndex = index; cursorShown = true; Invalidate(); args.Use(); selectionStart = Mathf.Min( mouseSelectionAnchor, index ); selectionEnd = Mathf.Max( mouseSelectionAnchor, index ); return; } } base.OnMouseMove( args ); }
protected internal override void OnMouseHover(dfMouseEventArgs args) { if ((args.Source == this.incButton || args.Source == this.decButton ? true : args.Source == this.thumb)) { return; } if (args.Source != this.track || !args.Buttons.IsSet(dfMouseButtons.Left)) { base.OnMouseHover(args); return; } this.updateFromTrackClick(args); args.Use(); base.Signal("OnMouseHover", new object[] { args }); }
protected internal override void OnMouseWheel( dfMouseEventArgs args ) { var orientationDir = ( orientation == dfControlOrientation.Horizontal ) ? -1 : 1; this.Value += ( scrollSize * args.WheelDelta ) * orientationDir; args.Use(); Signal( "OnMouseWheel", args ); raiseMouseWheelEvent( args ); }
protected internal override void OnMouseWheel(dfMouseEventArgs args) { this.SelectedIndex = Mathf.Max(0, this.SelectedIndex - Mathf.RoundToInt(args.WheelDelta)); args.Use(); base.OnMouseWheel(args); }