Пример #1
0
        public static bool OnMouseButton(Controls.Control hoveredControl, int x, int y, bool down)
        {
            if (!down)
            {
                m_LastPressedControl = null;

                // Not carrying anything, allow normal actions
                if (CurrentPackage == null)
                    return false;

                // We were carrying something, drop it.
                onDrop(x, y);
                return true;
            }

            if (hoveredControl == null)
                return false;
            if (!hoveredControl.DragAndDrop_Draggable())
                return false;

            // Store the last clicked on control. Don't do anything yet,
            // we'll check it in OnMouseMoved, and if it moves further than
            // x pixels with the mouse down, we'll start to drag.
            m_LastPressedPos = new Vector2i(x, y);
            m_LastPressedControl = hoveredControl;

            return false;
        }
Пример #2
0
        public static void ControlDeleted(Controls.Control control)
        {
            if (SourceControl == control)
            {
                SourceControl = null;
                CurrentPackage = null;
                HoveredControl = null;
                m_LastPressedControl = null;
            }

            if (m_LastPressedControl == control)
                m_LastPressedControl = null;

            if (HoveredControl == control)
                HoveredControl = null;

            if (m_NewHoveredControl == control)
                m_NewHoveredControl = null;
        }
Пример #3
0
        private static void UpdateHoveredControl(Controls.Control control, int x, int y)
        {
            //
            // We use this global variable to represent our hovered control
            // That way, if the new hovered control gets deleted in one of the
            // Hover callbacks, we won't be left with a hanging pointer.
            // This isn't ideal - but it's minimal.
            //
            m_NewHoveredControl = control;

            // Nothing to change..
            if (HoveredControl == m_NewHoveredControl)
                return;

            // We changed - tell the old hovered control that it's no longer hovered.
            if (HoveredControl != null && HoveredControl != m_NewHoveredControl)
                HoveredControl.DragAndDrop_HoverLeave(CurrentPackage);

            // If we're hovering where the control came from, just forget it.
            // By changing it to null here we're not going to show any error cursors
            // it will just do nothing if you drop it.
            if (m_NewHoveredControl == SourceControl)
                m_NewHoveredControl = null;

            // Check to see if the new potential control can accept this type of package.
            // If not, ignore it and show an error cursor.
            while (m_NewHoveredControl != null && !m_NewHoveredControl.DragAndDrop_CanAcceptPackage(CurrentPackage))
            {
                // We can't drop on this control, so lets try to drop
                // onto its parent..
                m_NewHoveredControl = m_NewHoveredControl.Parent;

                // Its parents are dead. We can't drop it here.
                // Show the NO WAY cursor.
                if (m_NewHoveredControl == null)
                {
                    Platform.Neutral.SetCursor(Cursors.No);
                }
            }

            // Become out new hovered control
            HoveredControl = m_NewHoveredControl;

            // If we exist, tell us that we've started hovering.
            if (HoveredControl != null)
            {
                HoveredControl.DragAndDrop_HoverEnter(CurrentPackage, x, y);
            }

            m_NewHoveredControl = null;
        }
Пример #4
0
        private static bool onDrop(int x, int y)
        {
            bool success = false;

            if (HoveredControl != null)
            {
                HoveredControl.DragAndDrop_HoverLeave(CurrentPackage);
                success = HoveredControl.DragAndDrop_HandleDrop(CurrentPackage, x, y);
            }

            // Report back to the source control, to tell it if we've been successful.
            SourceControl.DragAndDrop_EndDragging(success, x, y);

            CurrentPackage = null;
            SourceControl = null;

            return true;
        }
Пример #5
0
        private static bool ShouldStartDraggingControl( int x, int y )
        {
            // We're not holding a control down..
            if (m_LastPressedControl == null)
                return false;

            // Not been dragged far enough
            int length = Math.Abs(x - m_LastPressedPos.X) + Math.Abs(y - m_LastPressedPos.Y);
            if (length < 5)
                return false;

            // Create the dragging package

            CurrentPackage = m_LastPressedControl.DragAndDrop_GetPackage(m_LastPressedPos.X, m_LastPressedPos.Y);

            // We didn't create a package!
            if (CurrentPackage == null)
            {
                m_LastPressedControl = null;
                SourceControl = null;
                return false;
            }

            // Now we're dragging something!
            SourceControl = m_LastPressedControl;
            InputHandler.MouseFocus = null;
            m_LastPressedControl = null;
            CurrentPackage.DrawControl = null;

            // Some controls will want to decide whether they should be dragged at that moment.
            // This function is for them (it defaults to true)
            if (!SourceControl.DragAndDrop_ShouldStartDrag())
            {
                SourceControl = null;
                CurrentPackage = null;
                return false;
            }

            SourceControl.DragAndDrop_StartDragging(CurrentPackage, m_LastPressedPos.X, m_LastPressedPos.Y);

            return true;
        }
Пример #6
0
 public void SetPropertyControl(Controls.Control control, EditorWindow owner)
 {
     selectedControl = control;
     selectedOwner = owner;
     propertyGridControl1.SelectedObject = control;
 }
Пример #7
0
        public static bool Start(Controls.Control control, Package package)
        {
            if (CurrentPackage != null)
            {
                return false;
            }

            CurrentPackage = package;
            SourceControl = control;
            return true;
        }
Пример #8
0
 public override void DrawSliderButton(Controls.Control control, bool depressed, bool horizontal)
 {
     DrawButton(control, depressed, control.IsHovered, control.IsDisabled);
 }
Пример #9
0
 public override void DrawCategoryHolder(Controls.Control control)
 {
     // todo
 }
Пример #10
0
 public override void DrawStatusBar(Controls.Control control)
 {
     // todo
 }
Пример #11
0
 public override void DrawMenuRightArrow(Controls.Control control)
 {
     DrawArrowRight(control.RenderBounds);
 }
Пример #12
0
 public override void DrawComboBox(Controls.Control control, bool down, bool open)
 {
     DrawTextBox(control);
 }
Пример #13
0
 public override void DrawScrollBarBar(Controls.Control control, bool depressed, bool hovered, bool horizontal)
 {
     //TODO: something specialized
     DrawButton(control, depressed, hovered, false);
 }
Пример #14
0
 public override void DrawWindowCloseButton(Controls.Control control, bool depressed, bool hovered, bool disabled)
 {
     // TODO
     DrawButton(control, depressed, hovered, disabled);
 }
Пример #15
0
 private void but_ButtonPressed(Controls.Control sender)
 {
     _result = (MessageBoxResult)sender.Tag;
     Close();
 }
Пример #16
0
 /// <summary>Initializes a new control event args instance</summary>
 /// <param name="control">Control to provide to the subscribers of the event</param>
 public ControlEventArgs(Controls.Control control)
 {
     this.control = control;
 }