protected internal override void OnCursorMove(CursorInputEventArgs e) { base.OnCursorMove(e); // get position of mouse as co-ordinates local to this window. var localMousePos = CoordConverter.ScreenToWindow(this, e.Position); // handle dragging if (_dragging) { DoDragging(localMousePos); } // not dragging else { // if mouse button is down (but we're not yet being dragged) if (_leftPointerHeld) { if (IsDraggingThresholdExceeded(localMousePos)) { // Trigger the event OnDragStarted(new WindowEventArgs(this)); } } } }
protected internal override void OnCursorPressHold(CursorInputEventArgs e) { // base class processing base.OnCursorPressHold(e); if (e.Source == CursorInputSource.Left) { // ensure all inputs come to us for now if (CaptureInput()) { // get position of mouse as co-ordinates local to this window. var localPos = CoordConverter.ScreenToWindow(this, e.Position); // store drag point for possible sizing or moving operation. _dragPoint = localPos; // if the mouse is in the sizing area if (_splitterHover) { if (IsSizingEnabled()) { // setup the 'dragging' state variables _dragSizing = true; } } else { _segmentPushed = true; } } ++e.handled; } }
protected internal override void OnCursorPressHold(CursorInputEventArgs e) { // default processing (this is now essential as it controls event firing). base.OnCursorPressHold(e); if (e.Source == CursorInputSource.Left) { if (IsSizingEnabled()) { // get position of mouse as co-ordinates local to this window. var localPos = CoordConverter.ScreenToWindow(this, e.Position); // if the mouse is on the sizing border if (GetSizingBorderAtPoint(localPos) != SizingLocation.SizingNone) { // ensure all inputs come to us for now if (CaptureInput()) { // setup the 'dragging' state variables _beingSized = true; _dragPoint = localPos; // do drag-sizing started notification OnDragSizingStarted(new WindowEventArgs(this)); ++e.handled; } } } } }
protected internal override void OnCursorMove(CursorInputEventArgs e) { // default processing base.OnCursorMove(e); // only react if we are being dragged if (_beingDragged) { var parentSize = GetParentPixelSize(); var delta = CoordConverter.ScreenToWindow(this, e.Position); var hmin = _horzMin; var hmax = _horzMax; var vmin = _vertMin; var vmax = _vertMax; // calculate amount of movement delta -= _dragPoint; delta.X /= parentSize.Width; delta.Y /= parentSize.Height; // // Calculate new (pixel) position for thumb // var newPos = GetPosition(); if (_horzFree) { newPos.d_x.d_scale += delta.X; // limit value to within currently set range newPos.d_x.d_scale = (newPos.d_x.d_scale < hmin) ? hmin : (newPos.d_x.d_scale > hmax) ? hmax : newPos.d_x.d_scale; } if (_vertFree) { newPos.d_y.d_scale += delta.Y; // limit new position to within currently set range newPos.d_y.d_scale = (newPos.d_y.d_scale < vmin) ? vmin : (newPos.d_y.d_scale > vmax) ? vmax : newPos.d_y.d_scale; } // update thumb position if needed if (newPos != GetPosition()) { SetPosition(newPos); // send notification as required if (_hotTrack) { OnThumbPositionChanged(new WindowEventArgs(this)); } } } ++e.handled; }
protected internal override void OnCursorMove(CursorInputEventArgs e) { // default processing (this is now essential as it controls event firing). base.OnCursorMove(e); // if we are not the window containing the mouse, do NOT change the cursor if (GetGUIContext().GetWindowContainingCursor() != this) { return; } if (IsSizingEnabled()) { var localMousePos = CoordConverter.ScreenToWindow(this, e.Position); if (_beingSized) { var dragEdge = GetSizingBorderAtPoint(_dragPoint); // calculate sizing deltas... var deltaX = localMousePos.X - _dragPoint.X; var deltaY = localMousePos.Y - _dragPoint.Y; var newArea = d_area; var topLeftSizing = false; // size left or right edges if (IsLeftSizingLocation(dragEdge)) { topLeftSizing |= MoveLeftEdge(deltaX, ref newArea); } else if (IsRightSizingLocation(dragEdge)) { topLeftSizing |= MoveRightEdge(deltaX, ref newArea); } // size top or bottom edges if (IsTopSizingLocation(dragEdge)) { topLeftSizing |= MoveTopEdge(deltaY, ref newArea); } else if (IsBottomSizingLocation(dragEdge)) { topLeftSizing |= MoveBottomEdge(deltaY, ref newArea); } SetAreaImpl(newArea.d_min, newArea.Size, topLeftSizing); } else { SetCursorForPoint(localMousePos); } } // mark event as handled ++e.handled; }
protected internal override void OnCursorPressHold(CursorInputEventArgs e) { // default processing base.OnCursorPressHold(e); if (e.Source == CursorInputSource.Left) { // initialise the dragging state _beingDragged = true; _dragPoint = CoordConverter.ScreenToWindow(this, e.Position); // trigger tracking started event OnThumbTrackStarted(new WindowEventArgs(this)); ++e.handled; } }
// TODO: Destructor for Titlebar base class. // TODO: virtual ~Titlebar() {} protected internal override void OnCursorMove(CursorInputEventArgs e) { // Base class processing. base.OnCursorMove(e); if (_dragging && (d_parent != null)) { var delta = CoordConverter.ScreenToWindow(this, e.Position); // calculate amount that window has been moved delta -= _dragPoint; // move the window. *** Again: Titlebar objects should only be attached to FrameWindow derived classes. *** ((FrameWindow)d_parent).OffsetPixelPosition(delta); ++e.handled; } }
/// <summary> /// Immediately pick up the DragContainer and optionally set the sticky /// mode in order to allow this to happen. Any current interaction /// (i.e. mouse capture) will be interrupted. /// </summary> /// <param name="forceSticky"> /// - true to automatically enable the sticky mode in order to facilitate picking up the DragContainer. /// - false to ignore the pick up request if the sticky mode is not alraedy enabled (default). /// </param> /// <returns> /// - true if the DragContainer was successfully picked up. /// - false if the DragContainer was not picked up. /// </returns> public bool PickUp(bool forceSticky = false) { // check if we're already picked up or if dragging is disabled. if (_pickedUp || !_draggingEnabled) { return(true); } // see if we need to force sticky mode switch if (!_stickyMode && forceSticky) { SetStickyModeEnabled(true); } // can only pick up if sticky if (_stickyMode) { // force immediate release of any current input capture (unless it's us) if (GetCaptureWindow() != null && GetCaptureWindow() != this) { GetCaptureWindow().ReleaseInput(); } // activate ourselves and try to capture input Activate(); if (CaptureInput()) { // set the dragging point to the centre of the container. _dragPoint.d_x = UDim.Absolute(d_pixelSize.Width / 2); _dragPoint.d_y = UDim.Absolute(d_pixelSize.Height / 2); // initialise the dragging state InitialiseDragging(); // get position of mouse as co-ordinates local to this window. var localMousePos = CoordConverter.ScreenToWindow(this, GetGUIContext().GetCursor().GetPosition()); DoDragging(localMousePos); _pickedUp = true; } } return(_pickedUp); }
protected internal override void OnCursorPressHold(CursorInputEventArgs e) { base.OnCursorPressHold(e); if (e.Source == CursorInputSource.Left) { // ensure all inputs come to us for now if (CaptureInput()) { // get position of mouse as co-ordinates local to this window. var localPos = CoordConverter.ScreenToWindow(this, e.Position); // store drag point for possible sizing or moving operation. _dragPoint.d_x = UDim.Absolute(localPos.X); _dragPoint.d_y = UDim.Absolute(localPos.Y); _leftPointerHeld = true; } ++e.handled; } }
protected internal override void OnCursorPressHold(CursorInputEventArgs e) { // Base class processing base.OnCursorPressHold(e); if (e.Source == CursorInputSource.Left) { if ((d_parent != null) && _dragEnabled) { // we want all cursor inputs from now on if (CaptureInput()) { // initialise the dragging state _dragging = true; _dragPoint = CoordConverter.ScreenToWindow(this, e.Position); // store old constraint area _oldCursorArea = GetGUIContext().GetCursor().GetConstraintArea(); // setup new constraint area to be the intersection of the old area and our grand-parent's clipped inner-area Rectf constrainArea; if ((d_parent == null) || (GetParent().GetParent() == null)) { var screen = new Rectf(Lunatics.Mathematics.Vector2.Zero, GetRootContainerSize()); constrainArea = screen.GetIntersection(_oldCursorArea); } else { constrainArea = GetParent().GetParent().GetInnerRectClipper().GetIntersection(_oldCursorArea); } GetGUIContext().GetCursor().SetConstraintArea(constrainArea); } } ++e.handled; } }
public override ModelIndex IndexAt(Lunatics.Mathematics.Vector2 position) { if (d_itemModel == null) { return(new ModelIndex()); } //TODO: add prepareForLayout() as a cheaper operation alternative? PrepareForRender(); var windowPosition = CoordConverter.ScreenToWindow(this, position); var renderArea = GetViewRenderer().GetViewRenderArea(); if (!renderArea.IsPointInRect(windowPosition)) { return(new ModelIndex()); } var curHeight = renderArea.d_min.Y - GetVertScrollbar().GetScrollPosition(); //TODO: start only on the visible area for (var index = 0; index < d_sortedItems.Count; ++index) { var item = d_sortedItems[index]; var size = item.d_size; var nextHeight = curHeight + size.Height; if (windowPosition.Y >= curHeight && windowPosition.Y <= nextHeight) { return(item.d_index); } curHeight = nextHeight; } return(new ModelIndex()); }
private ModelIndex IndexAtWithAction(Lunatics.Mathematics.Vector2 position, Action <TreeViewItemRenderingState, bool> action) { if (d_itemModel == null) { return(new ModelIndex()); } //TODO: add prepareForLayout() as a cheaper operation alternative? PrepareForRender(); var windowPosition = CoordConverter.ScreenToWindow(this, position); var renderArea = GetViewRenderer().GetViewRenderArea(); if (!renderArea.IsPointInRect(windowPosition)) { return(new ModelIndex()); } var curHeight = renderArea.d_min.Y - GetVertScrollbar().GetScrollPosition(); var handled = false; return(IndexAtRecursive(d_rootItemState, ref curHeight, windowPosition, ref handled, action)); }
protected internal override void OnCursorMove(CursorInputEventArgs e) { // base class processing base.OnCursorMove(e); // convert mouse position to something local var localMousePos = CoordConverter.ScreenToWindow(this, e.Position); if (_dragSizing) { // handle drag sizing DoDragSizing(localMousePos); } else if (_dragMoving) { // handle drag moving DoDragMoving(localMousePos); } else if (IsHit(e.Position)) { // not sizing, is mouse in the widget area? // mouse in sizing area & sizing is enabled if ((localMousePos.X > (d_pixelSize.Width - _splitterSize)) && _sizingEnabled) { InitSizingHoverState(); } // mouse not in sizing area and/or sizing not enabled else { InitSegmentHoverState(); // if we are pushed but not yet drag moving if (_segmentPushed && !_dragMoving) { if (IsDragMoveThresholdExceeded(localMousePos)) { InitDragMoving(); } } } } else { // mouse is no longer within the widget area... // only change settings if change is required if (_splitterHover) { _splitterHover = false; GetGUIContext().GetCursor().SetImage(GetCursor()); Invalidate(false); } // reset segment hover state if not already done. if (_segmentHover) { _segmentHover = false; Invalidate(false); } } ++e.handled; }