Пример #1
0
 internal DragEvent(Draggable draggable)
 {
     this.draggable = draggable;
 }
Пример #2
0
        internal Toolbar(Mode mode = Mode.TOOLBAR, Toolbar parentToolbar = null, RelativePosition preferredRelativePosition = RelativePosition.DEFAULT)
        {
            this.mode = mode;
            this.parentToolbar = parentToolbar;
            this.relativePosition = preferredRelativePosition;

            visibleButtons = new VisibleButtons(buttons, isEffectivelyUserVisible);

            autoHideUnimportantButtonAlpha.a = 0.4f;

            rect = new Rectangle(new Rect(DEFAULT_X, DEFAULT_Y, DEFAULT_WIDTH, float.MinValue));

            if (mode == Mode.TOOLBAR) {
                dropdownMenuButton = Button.createToolbarDropdown();
                dropdownMenuButton.OnClick += (e) => toggleDropdownMenu();
                buttons.Add(dropdownMenuButton);

                draggable = new Draggable(rect, PADDING, (pos) => !dropdownMenuButtonContains(pos) && !resizable.HandleRect.Contains(pos));
                resizable = new Resizable(rect, PADDING, (pos) => !dropdownMenuButtonContains(pos));
                draggable.OnDrag += (e) => {
                    resizable.Enabled = !draggable.Dragging;
                    toolbarDrag();
                };
                resizable.OnDrag += (e) => {
                    draggable.Enabled = !resizable.Dragging;
                    toolbarResize();
                };
                CursorGrabbing.Instance.add(draggable);
                CursorGrabbing.Instance.add(resizable);

                CursorGrabbing.Instance.add(this);

                ToolbarManager.InternalInstance.OnCommandAdded += updateVisibleButtons;
            } else {
                showBorder = parentToolbar.showBorder;
                useKSPSkin_ = parentToolbar.UseKSPSkin;
            }
        }
Пример #3
0
 internal DragEvent(Draggable draggable)
 {
     this.draggable = draggable;
 }
Пример #4
0
        private void hookButtonOrderDraggables(bool enabled)
        {
            if (enabled) {
                calculateButtonPositions((button, pos) => {
                    if (!button.Equals(dropdownMenuButton)) {
                        Rectangle buttonRect = new Rectangle(new Rect(rect.x + pos.x, rect.y + pos.y, button.Size.x, button.Size.y));
                        Draggable draggable = new Draggable(buttonRect, 0, null);
                        draggable.Enabled = true;
                        draggable.OnDrag += buttonDrag;
                        buttonOrderDraggables.Add(draggable, buttonRect);
                    }
                });

                buttonOrderDropMarker = new DropMarker();
            } else {
                foreach (Draggable d in buttonOrderDraggables.Keys) {
                    d.OnDrag -= buttonDrag;
                }
                buttonOrderDraggables.Clear();
                buttonOrderDropMarker = null;
            }
            draggedButton = null;
        }
Пример #5
0
        internal Toolbar(Mode mode = Mode.TOOLBAR, Toolbar parentToolbar = null)
        {
            this.mode = mode;
            this.parentToolbar = parentToolbar;

            autoHideUnimportantButtonAlpha.a = 0.4f;

            rect = new Rectangle(new Rect(DEFAULT_X, DEFAULT_Y, DEFAULT_WIDTH, float.MinValue));

            if (mode == Mode.TOOLBAR) {
                dropdownMenuButton = Button.createToolbarDropdown();
                dropdownMenuButton.OnClick += (e) => toggleDropdownMenu();
                buttons.Add(dropdownMenuButton);

                setupConfigureVisibleButtonsButton();

                draggable = new Draggable(rect, PADDING, (pos) => !dropdownMenuButtonContains(pos) && !resizable.HandleRect.Contains(pos));
                resizable = new Resizable(rect, PADDING, (pos) => !dropdownMenuButtonContains(pos));
                draggable.OnDrag += (e) => {
                    resizable.Enabled = !draggable.Dragging;
                    toolbarDrag();
                };
                resizable.OnDrag += (e) => {
                    draggable.Enabled = !resizable.Dragging;
                    toolbarResize();
                };
                CursorGrabbing.Instance.add(draggable);
                CursorGrabbing.Instance.add(resizable);

                CursorGrabbing.Instance.add(this);
            } else {
                showBorder = parentToolbar.showBorder;
                useKSPSkin_ = parentToolbar.UseKSPSkin;
            }
        }