예제 #1
0
        public bool CheckboxLabeled(string label, bool value, string tooltip = null, bool enabled = true)
        {
            GUIPlus.SetEnabledColor(enabled);
            var previous = value;

            CheckboxLabeled(label, ref value, tooltip);
            GUIPlus.ResetColor();

            return(enabled ? value : previous);
        }
예제 #2
0
        public void TextStyleEditor(TextStyle style, bool enabled = true)
        {
            GUIPlus.SetEnabledColor(enabled);

            Label(style.Label.Bold());
            RangeSlider(style.Size, enabled);
            RangeSlider(style.Height, enabled);

            GUIPlus.ResetColor();
        }
예제 #3
0
        public void RangeSlider(RangeOption range, bool enabled = true)
        {
            GUIPlus.SetEnabledColor(enabled);

            var grid = GetRect(Text.LineHeight).GetHGrid(ElementPadding, LabelWidth, ValueWidth, -1f);

            GUIPlus.DrawText(grid[1], range.Label);
            GUIPlus.DrawText(grid[2], range.ToString());

            var value = Mathf.RoundToInt(Widgets.HorizontalSlider(grid[3], range.Value, range.Min, range.Max, true));

            if (enabled)
            {
                range.Value = value;
            }

            GUIPlus.DrawTooltip(grid[0], range.Tooltip, true);
            Gap(verticalSpacing);

            GUIPlus.ResetColor();
        }
예제 #4
0
 public void BoolToggle(BoolOption option, bool enabled = true)
 {
     GUIPlus.SetEnabledColor(enabled);
     option.Value = CheckboxLabeled(option.Label, option.Value, option.Tooltip, enabled);
     GUIPlus.ResetColor();
 }
예제 #5
0
        public void RangeSliderEntry(RangeOption range, ref string text, int id, bool enabled = true)
        {
            GUIPlus.SetEnabledColor(enabled);

            var grid = GetRect(Text.LineHeight).GetHGrid(ElementPadding, LabelWidth, ValueWidth, -1f);

            GUIPlus.DrawText(grid[1], range.Label);

            var entryName = "RangeSliderEntry_Text" + id;
            var isFocused = GUI.GetNameOfFocusedControl() == entryName;

            if (!isFocused)
            {
                text = range.Value.ToString();
            }

            GUI.SetNextControlName(entryName);
            var newText = Widgets.TextField(grid[2], text, 5, RangeSliderEntryRegex);

            if (enabled)
            {
                text = newText;
            }

            var textValue = text.ToInt();

            if (textValue.HasValue)
            {
                if (textValue.Value < range.Min)
                {
                    range.Value = range.Min;
                }
                else if (textValue.Value > range.Max)
                {
                    range.Value = range.Max;
                }
                else
                {
                    range.Value = textValue.Value;
                }
            }

            var sliderName = "RangeSliderEntry_Slider" + id;

            GUI.SetNextControlName(sliderName);
            var sliderValue = Mathf.RoundToInt(Widgets.HorizontalSlider(grid[3], range.Value, range.Min, range.Max, true));

            if (enabled && range.Value != sliderValue)
            {
                range.Value = sliderValue;
                text        = range.Value.ToString();
            }
            if (Widgets.ButtonInvisible(grid[3]))
            {
                GUI.FocusControl(sliderName);
            }

            GUIPlus.DrawTooltip(grid[0], range.Tooltip, true);
            Gap(verticalSpacing);

            GUIPlus.ResetColor();
        }