diff options
| author | Jacob Palecki <[email protected]> | 2020-09-07 15:19:39 -0700 |
|---|---|---|
| committer | Jacob Palecki <[email protected]> | 2020-09-07 15:19:39 -0700 |
| commit | aff3a066575f4bfa429f67a5104a1fcffc5f326e (patch) | |
| tree | 975c8cf984e97d818ebf530b68a246f4a4b1aefb /grapher/Layouts/LayoutBase.cs | |
| parent | Pass args by ref for setting (diff) | |
| download | rawaccel-aff3a066575f4bfa429f67a5104a1fcffc5f326e.tar.xz rawaccel-aff3a066575f4bfa429f67a5104a1fcffc5f326e.zip | |
Refactor type options
Diffstat (limited to 'grapher/Layouts/LayoutBase.cs')
| -rw-r--r-- | grapher/Layouts/LayoutBase.cs | 86 |
1 files changed, 68 insertions, 18 deletions
diff --git a/grapher/Layouts/LayoutBase.cs b/grapher/Layouts/LayoutBase.cs index daac6f1..629b0a4 100644 --- a/grapher/Layouts/LayoutBase.cs +++ b/grapher/Layouts/LayoutBase.cs @@ -1,4 +1,5 @@ -using System; +using grapher.Models.Options; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -20,9 +21,13 @@ namespace grapher.Layouts public LayoutBase() { - ShowOptions = new bool[] { false, false, false, false, true, true }; - ShowOptionsXY = new bool[] { true, true }; - OptionNames = new string[] { string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty }; + AccelLayout = new OptionLayout(false, string.Empty); + CapLayout = new OptionLayout(false, string.Empty); + WeightLayout = new OptionLayout(false, string.Empty); + OffsetLayout = new OptionLayout(false, string.Empty); + LimExpLayout = new OptionLayout(false, string.Empty); + MidpointLayout = new OptionLayout(false, string.Empty); + ButtonEnabled = true; } @@ -34,30 +39,75 @@ namespace grapher.Layouts public string Name { get; internal set; } - internal bool[] ShowOptions { get; set; } + protected bool ButtonEnabled { get; set; } + + protected OptionLayout AccelLayout { get; set; } + + protected OptionLayout CapLayout { get; set; } + + protected OptionLayout WeightLayout { get; set; } - internal bool[] ShowOptionsXY { get; set; } + protected OptionLayout OffsetLayout { get; set; } - internal string[] OptionNames { get; set; } + protected OptionLayout LimExpLayout { get; set; } - internal bool ButtonEnabled { get; set; } + protected OptionLayout MidpointLayout { get; set; } - public void Layout(Option[] options, Button button) + public void Layout( + IOption accelOption, + IOption capOption, + IOption weightOption, + IOption offsetOption, + IOption limExpOption, + IOption midpointOption, + Button button, + int top) { - // Relies on AccelOptions to keep lengths correct. - for (int i = 0; i < options.Length; i++) + AccelLayout.Layout(accelOption); + CapLayout.Layout(capOption); + WeightLayout.Layout(weightOption); + OffsetLayout.Layout(offsetOption); + LimExpLayout.Layout(limExpOption); + MidpointLayout.Layout(midpointOption); + + button.Enabled = ButtonEnabled; + + IOption previous = null; + foreach (var option in new IOption[] { accelOption, capOption, weightOption, offsetOption, limExpOption, midpointOption}) { - if (ShowOptions[i]) + if (option.Visible) { - options[i].Show(OptionNames[i]); - } - else - { - options[i].Hide(); + if (previous != null) + { + option.SnapTo(previous); + } + else + { + option.Top = top; + } + + previous = option; } } + } - button.Enabled = ButtonEnabled; + public void Layout( + IOption accelOption, + IOption capOption, + IOption weightOption, + IOption offsetOption, + IOption limExpOption, + IOption midpointOption, + Button button) + { + Layout(accelOption, + capOption, + weightOption, + offsetOption, + limExpOption, + midpointOption, + button, + accelOption.Top); } } } |