public override uint MouseDown(MouseEventArgs e, GL_ControlBase control) { bool TryGetActionType(MouseButtons button, out DragActionType dragActionType) { if (e.Button == MouseButtons.Left) { dragActionType = DragActionType.TRANSLATE; return(true); } else if (e.Button == MouseButtons.Right) { dragActionType = DragActionType.ROTATE; return(true); } else if (e.Button == MouseButtons.Middle) { bool ctrl = WinInput.Keyboard.IsKeyDown(WinInput.Key.LeftCtrl); dragActionType = ctrl ? DragActionType.SCALE_INDIVIDUAL : DragActionType.SCALE; return(true); } dragActionType = DragActionType.NONE; return(false); } uint var = 0; { if (CurrentAction == NoAction && ExclusiveAction == NoAction && Hovered != null && TryGetActionType(e.Button, out DragActionType dragActionType)) { Hovered.StartDragging(dragActionType, HoveredPart, this); } else { var |= REDRAW_PICKING; var |= FORCE_REENTER; CurrentAction = NoAction; //abort current action ExclusiveAction = NoAction; } } foreach (AbstractGlDrawable obj in StaticObjects) { var |= obj.MouseDown(e, control); } foreach (IEditableObject obj in GetObjects()) { var |= obj.MouseDown(e, control); } return(var); }
public override uint MouseDown(MouseEventArgs e, GL_ControlBase control) { bool TryGetActionType(out DragActionType dragActionType) { if (e.Button == MouseButtons.Left) { dragActionType = DragActionType.TRANSLATE; return(true); } else if (e.Button == MouseButtons.Right) { dragActionType = DragActionType.ROTATE; return(true); } else if (e.Button == MouseButtons.Middle) { bool ctrl = WinInput.Keyboard.IsKeyDown(WinInput.Key.LeftCtrl); dragActionType = ctrl ? DragActionType.SCALE_INDIVIDUAL : DragActionType.SCALE; return(true); } dragActionType = DragActionType.NONE; return(false); } uint var = 0; { var buttons = OpenTK.Input.Mouse.GetCursorState(); if (SelectionTransformAction == NoAction && CurrentAction == null && Hovered != null && TryGetActionType(out DragActionType dragActionType)) { if (!WinInput.Keyboard.IsKeyDown(WinInput.Key.LeftAlt)) { Hovered.StartDragging(dragActionType, HoveredPart, this); } } else if (buttons.RightButton == OpenTK.Input.ButtonState.Pressed || //the right mouse button is pressed or (int)buttons.LeftButton + (int)buttons.RightButton + (int)buttons.MiddleButton >= 2) //atleast 2 buttons are pressed at once { var |= REDRAW_PICKING; var |= FORCE_REENTER; if (SelectionTransformAction != NoAction) { EndUndoCollection(); } if (SelectionTransformAction != NoAction || CurrentAction != null) { control.CameraTarget = actionStartCamTarget; } SelectionTransformAction = NoAction; //abort current action CurrentAction?.Cancel(); CurrentAction = null; } } foreach (AbstractGlDrawable obj in StaticObjects) { var |= obj.MouseDown(e, control); } foreach (IEditableObject obj in GetObjects()) { var |= obj.MouseDown(e, control); } return(var); }