示例#1
0
        public override uint MouseMove(MouseEventArgs e, Point lastMousePos, GL_ControlBase control)
        {
            uint var = 0;

            foreach (IEditableObject obj in GetObjects())
            {
                var |= obj.MouseMove(e, lastMousePos, control);
            }

            foreach (AbstractGlDrawable obj in StaticObjects)
            {
                var |= obj.MouseMove(e, lastMousePos, control);
            }

            if (SelectionTransformAction != NoAction || CurrentAction != null)
            {
                SelectionTransformAction.UpdateMousePos(e.Location);
                CurrentAction?.UpdateMousePos(e.Location);

                var |= REDRAW | NO_CAMERA_ACTION;

                var &= ~REPICK;
            }
            else
            {
                if (e.Button == MouseButtons.Left && WinInput.Keyboard.IsKeyDown(WinInput.Key.LeftAlt))
                {
                    if (WinInput.Keyboard.IsKeyDown(WinInput.Key.LeftShift))
                    {
                        Hovered?.Deselect(HoveredPart, control);
                    }
                    else
                    {
                        Hovered?.Select(HoveredPart, control);
                    }

                    SelectionChanged?.Invoke(this, new EventArgs());

                    var |= NO_CAMERA_ACTION | FORCE_REENTER;
                }
                var |= REPICK;
            }
            return(var);
        }
示例#2
0
        public override uint MouseClick(MouseEventArgs e, GL_ControlBase control)
        {
            uint var = 0;

            foreach (IEditableObject obj in GetObjects())
            {
                var |= obj.MouseClick(e, control);
            }

            bool shift             = WinInput.Keyboard.IsKeyDown(WinInput.Key.LeftShift);
            bool hoveredIsSelected = Hovered != null && Hovered.IsSelected(HoveredPart);
            bool nothingHovered    = Hovered == null;

            /*
             * Selecting Objects:
             *
             * If the object is not selected, select it
             * If another object is selected, deselect the old object, and select the new one
             * UNLESS [SHIFT] is being pressed
             * If [SHIFT] is being pressed, select the new object, but DON'T deselect the old object
             *
             * If an object that is already selected is clicked, deselect it
             * If multiple objects are selected, deselect all of them
             * UNLESS [SHIFT] is being pressed
             * If [SHIFt] is being pressed, only deselect the one object, leave the rest alone
             *
             * If nothing is being selected, and [SHIFT] isn't pressed, de-select everything
             */
            if (e.Button == MouseButtons.Left)
            {
                if (nothingHovered)
                {
                    if (!shift)
                    {
                        foreach (IEditableObject obj in GetObjects())
                        {
                            obj.DeselectAll(control);
                        }
                        SelectionChanged?.Invoke(this, new EventArgs());
                    }
                }
                else if (multiSelect)
                {
                    if (hoveredIsSelected)
                    {
                        if (shift)
                        {
                            //remove from selection
                            Hovered.Deselect(HoveredPart, control);
                            SelectionChanged?.Invoke(this, new EventArgs());
                        }
                        else
                        {
                            foreach (IEditableObject obj in GetObjects())
                            {
                                obj.DeselectAll(control);
                            }
                            SelectionChanged?.Invoke(this, new EventArgs());
                        }
                    }
                    else
                    {
                        if (shift)
                        {
                            //add to selection
                            Hovered.Select(HoveredPart, control);
                            SelectionChanged?.Invoke(this, new EventArgs());
                        }
                        else
                        {
                            //change selection
                            foreach (IEditableObject obj in GetObjects())
                            {
                                obj.DeselectAll(control);
                            }
                            Hovered.Select(HoveredPart, control);
                            SelectionChanged?.Invoke(this, new EventArgs());
                        }
                    }
                }
                else
                {
                    if (hoveredIsSelected)
                    {
                        //remove from selection
                        Hovered.Deselect(HoveredPart, control);
                        SelectionChanged?.Invoke(this, new EventArgs());
                    }
                    else
                    {
                        //change selection
                        foreach (IEditableObject obj in GetObjects())
                        {
                            obj.DeselectAll(control);
                        }
                        Hovered.Select(HoveredPart, control);
                        SelectionChanged?.Invoke(this, new EventArgs());
                    }
                }
            }

            foreach (AbstractGlDrawable obj in StaticObjects)
            {
                var |= obj.MouseClick(e, control);
            }

            var |= REDRAW;
            var |= FORCE_REENTER;

            return(var);
        }