public OpenTK.Vector3 FullWidthVector3Input(OpenTK.Vector3 vec, string name,
                                                    float increment = 1, int incrementDragDivider = 8, float min = float.MinValue, float max = float.MaxValue, bool wrapAround = false)
        {
            currentY += beforeTwoLineSpacing;

            NumberInputInfo input = new NumberInputInfo(increment, incrementDragDivider, min, max, wrapAround);

            const int nameWidth = 13;
            int       width     = (usableWidth - margin * 2 - fullWidthSpace * 2) / 3;

            g.DrawString(name, HeadingFont, SystemBrushes.ControlText, margin, currentY);
            currentY += rowHeight;

            DrawText(margin, currentY, "X");
            vec.X = NumericInputField(margin + nameWidth, currentY, width - nameWidth, vec.X, input, true);

            DrawText(10 + width + fullWidthSpace, currentY, "Y");
            vec.Y = NumericInputField(margin + nameWidth + width + fullWidthSpace, currentY, width - nameWidth, vec.Y, input, true);

            DrawText(10 + width * 2 + fullWidthSpace * 2, currentY, "Z");
            vec.Z = NumericInputField(margin + nameWidth + width * 2 + fullWidthSpace * 2, currentY, width - nameWidth, vec.Z, input, true);


            currentY += rowHeight;
            return(vec);
        }
        public OpenTK.Vector3 Vector3Input(OpenTK.Vector3 vec, string name,
                                           float increment = 1, int incrementDragDivider = 8, float min = float.MinValue, float max = float.MaxValue, bool wrapAround = false)
        {
            NumberInputInfo input = new NumberInputInfo(increment, incrementDragDivider, min, max, wrapAround);

            DrawText(margin, currentY, name);

            vec.X = NumericInputField(usableWidth - margin - fieldWidth * 3 - fieldSpace * 2, currentY, fieldWidth, vec.X, input, true);
            vec.Y = NumericInputField(usableWidth - margin - fieldWidth * 2 - fieldSpace * 1, currentY, fieldWidth, vec.Y, input, true);
            vec.Z = NumericInputField(usableWidth - margin - fieldWidth, currentY, fieldWidth, vec.Z, input, true);


            currentY += rowHeight;
            return(vec);
        }
Exemple #3
0
        public OpenTK.Vector3 Vector3Input(OpenTK.Vector3 vec, string name,
                                           float increment = 1, int incrementDragDivider = 8, float min = float.MinValue, float max = float.MaxValue, bool wrapAround = false)
        {
            NumberInputInfo input = new NumberInputInfo(increment, incrementDragDivider, min, max, wrapAround);

            g.SetClip(nameClipping);

            DrawText(margin, currentY, name);

            g.ResetClip();

            vec.X = NumericInputField(usableWidth - margin - fieldWidth * 4 - fieldSpace * 3, currentY, fieldWidth, vec.X, input, true);
            vec.Y = NumericInputField(usableWidth - margin - fieldWidth * 3 - fieldSpace * 2, currentY, fieldWidth, vec.Y, input, true);
            vec.Z = NumericInputField(usableWidth - margin - fieldWidth * 2 - fieldSpace * 1, currentY, fieldWidth, vec.Z, input, true);

            int copyBtnX = usableWidth - margin - fieldWidth;

            g.SetClip(contentClipping);

            if (ImageButton(copyBtnX, currentY, Properties.Resources.CopyIcon, Properties.Resources.CopyIconClick, Properties.Resources.CopyIconHover))
            {
                Clipboard.SetText($"{vec.X},{vec.Y},{vec.Z}");
            }

            if (clipboardVectorSize == 3)
            {
                if (eventType == EventType.DRAG_START && new Rectangle(copyBtnX + copyBtnImageWidth, currentY, copyBtnImageWidth, 15).Contains(mousePos))
                {
                    changeTypes |= VALUE_CHANGE_START;
                }

                if (ImageButton(copyBtnX + copyBtnImageWidth, currentY, Properties.Resources.PasteIcon, Properties.Resources.PasteIconClick, Properties.Resources.PasteIconHover))
                {
                    vec.X = clipboardNumbers[0];
                    vec.Y = clipboardNumbers[1];
                    vec.Z = clipboardNumbers[2];

                    changeTypes |= VALUE_SET;
                }
            }

            g.ResetClip();

            currentY += rowHeight;
            return(vec);
        }
        protected float NumericInputField(int x, int y, int width, float number, NumberInputInfo info, bool isCentered)
        {
            if (focusedIndex == index)
            {
                UpdateTextbox(x, y, width);
            }

            switch (eventType)
            {
            case EventType.CLICK:
                if (new Rectangle(x + 1, y + 1, width - 1, textBoxHeight - 2).Contains(mousePos))
                {
                    DrawField(x, y, width, "", SystemBrushes.Highlight, SystemBrushes.ControlLightLight, isCentered);
                    PrepareFieldForInput(x, y, width, number.ToString(), isCentered);
                    valueChangeEvents |= VALUE_CHANGE_START;

                    eventType = EventType.DRAW;     //Click Handled
                }
                else
                {
                    DrawField(x, y, width, number.ToString(), SystemBrushes.InactiveCaption, SystemBrushes.ControlLightLight, isCentered);
                }

                break;

            case EventType.DRAG_START:
                if (focusedIndex == index)
                {
                    DrawField(x, y, width, "", SystemBrushes.Highlight, SystemBrushes.ControlLightLight, isCentered);
                }
                else
                {
                    DrawField(x, y, width, number.ToString(), SystemBrushes.InactiveCaption, SystemBrushes.ControlLightLight, isCentered);

                    if (new Rectangle(x + 1, y + 1, width - 1, textBoxHeight - 2).Contains(mousePos))
                    {
                        dragIndex          = index;
                        valueBeforeDrag    = number;
                        valueChangeEvents |= VALUE_CHANGE_START;
                    }
                }

                break;

            case EventType.DRAG:
                if (dragIndex == index)
                {
                    valueChangeEvents |= VALUE_CHANGED;
                    number             = Clamped(valueBeforeDrag + (mousePos.X - dragStarPos.X) / info.incrementDragDivider * info.increment,
                                                 info.min, info.max, info.wrapAround);
                }
                if (focusedIndex == index)
                {
                    DrawField(x, y, width, "", SystemBrushes.Highlight, SystemBrushes.ControlLightLight, isCentered);
                }
                else
                {
                    DrawField(x, y, width, number.ToString(), SystemBrushes.InactiveCaption, SystemBrushes.ControlLightLight, isCentered);
                }

                break;

            case EventType.DRAG_END:
                if (dragIndex == index)
                {
                    valueChangeEvents |= VALUE_SET;
                    dragIndex          = -1;
                }

                if (focusedIndex == index)
                {
                    DrawField(x, y, width, "", SystemBrushes.Highlight, SystemBrushes.ControlLightLight, isCentered);
                }
                else
                {
                    DrawField(x, y, width, number.ToString(), SystemBrushes.InactiveCaption, SystemBrushes.ControlLightLight, isCentered);
                }

                break;

            case EventType.LOST_FOCUS:
                if (focusedIndex == index && float.TryParse(textBox1.Text, out float parsed))
                {
                    valueChangeEvents |= VALUE_SET;
                    number             = Clamped(parsed, info.min, info.max, info.wrapAround);
                }

                if (focusedIndex == index)
                {
                    DrawField(x, y, width, "", SystemBrushes.Highlight, SystemBrushes.ControlLightLight, isCentered);
                }
                else
                {
                    DrawField(x, y, width, number.ToString(), SystemBrushes.InactiveCaption, SystemBrushes.ControlLightLight, isCentered);
                }

                break;

            case EventType.DRAG_ABORT:
                if (dragIndex == index)
                {
                    valueChangeEvents |= VALUE_CHANGED;
                    number             = valueBeforeDrag;
                    dragIndex          = -1;
                }
                if (focusedIndex == index)
                {
                    DrawField(x, y, width, "", SystemBrushes.Highlight, SystemBrushes.ControlLightLight, isCentered);
                }
                else
                {
                    DrawField(x, y, width, number.ToString(), SystemBrushes.InactiveCaption, SystemBrushes.ControlLightLight, isCentered);
                }

                break;

            default:     //EventType.DRAW
                if (focusedIndex == index)
                {
                    DrawField(x, y, width, "", SystemBrushes.Highlight, SystemBrushes.ControlLightLight, isCentered);
                }
                else
                {
                    DrawField(x, y, width, number.ToString(), SystemBrushes.InactiveCaption, SystemBrushes.ControlLightLight, isCentered);
                }

                break;
            }

            index++;
            return(number);
        }