Exemple #1
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;
            }
        }
Exemple #2
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;
            }
        }