summaryrefslogtreecommitdiff
path: root/grapher/Layouts
diff options
context:
space:
mode:
authorJacob Palecki <[email protected]>2020-09-07 15:19:39 -0700
committerJacob Palecki <[email protected]>2020-09-07 15:19:39 -0700
commitaff3a066575f4bfa429f67a5104a1fcffc5f326e (patch)
tree975c8cf984e97d818ebf530b68a246f4a4b1aefb /grapher/Layouts
parentPass args by ref for setting (diff)
downloadrawaccel-aff3a066575f4bfa429f67a5104a1fcffc5f326e.tar.xz
rawaccel-aff3a066575f4bfa429f67a5104a1fcffc5f326e.zip
Refactor type options
Diffstat (limited to 'grapher/Layouts')
-rw-r--r--grapher/Layouts/ClassicLayout.cs9
-rw-r--r--grapher/Layouts/DefaultLayout.cs9
-rw-r--r--grapher/Layouts/LayoutBase.cs86
-rw-r--r--grapher/Layouts/LinearLayout.cs9
-rw-r--r--grapher/Layouts/NaturalGainLayout.cs9
-rw-r--r--grapher/Layouts/NaturalLayout.cs9
-rw-r--r--grapher/Layouts/OffLayout.cs9
-rw-r--r--grapher/Layouts/OptionLayout.cs41
-rw-r--r--grapher/Layouts/PowerLayout.cs9
-rw-r--r--grapher/Layouts/SigmoidGainLayout.cs9
10 files changed, 165 insertions, 34 deletions
diff --git a/grapher/Layouts/ClassicLayout.cs b/grapher/Layouts/ClassicLayout.cs
index f7766f0..d02e11c 100644
--- a/grapher/Layouts/ClassicLayout.cs
+++ b/grapher/Layouts/ClassicLayout.cs
@@ -14,8 +14,13 @@ namespace grapher.Layouts
{
Name = "Classic";
Index = (int)AccelMode.classic;
- ShowOptions = new bool[] { true, true, true, false, true, true };
- OptionNames = new string[] { Offset, Acceleration, Exponent, string.Empty, Cap, Weight };
+
+ AccelLayout = new OptionLayout(true, Acceleration);
+ CapLayout = new OptionLayout(true, Cap);
+ WeightLayout = new OptionLayout(true, Weight);
+ OffsetLayout = new OptionLayout(true, Offset);
+ LimExpLayout = new OptionLayout(true, Exponent);
+ MidpointLayout = new OptionLayout(false, string.Empty);
}
}
}
diff --git a/grapher/Layouts/DefaultLayout.cs b/grapher/Layouts/DefaultLayout.cs
index cb1994f..d9e1413 100644
--- a/grapher/Layouts/DefaultLayout.cs
+++ b/grapher/Layouts/DefaultLayout.cs
@@ -16,9 +16,14 @@ namespace grapher.Layouts
{
Name = "Default";
Index = (int)AccelMode.noaccel;
- ShowOptions = new bool[] { true, true, true, true, true };
- OptionNames = new string[] { Offset, Acceleration, $"{Limit}\\{Exponent}", Midpoint, Cap, Weight };
ButtonEnabled = false;
+
+ AccelLayout = new OptionLayout(true, Acceleration);
+ CapLayout = new OptionLayout(true, Cap);
+ WeightLayout = new OptionLayout(true, Weight);
+ OffsetLayout = new OptionLayout(true, Offset);
+ LimExpLayout = new OptionLayout(true, $"{Limit}\\{Exponent}");
+ MidpointLayout = new OptionLayout(true, Midpoint);
}
}
}
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);
}
}
}
diff --git a/grapher/Layouts/LinearLayout.cs b/grapher/Layouts/LinearLayout.cs
index 8b1d444..b5c6434 100644
--- a/grapher/Layouts/LinearLayout.cs
+++ b/grapher/Layouts/LinearLayout.cs
@@ -14,8 +14,13 @@ namespace grapher.Layouts
{
Name = "Linear";
Index = (int)AccelMode.linear;
- ShowOptions = new bool[] { true, true, false, false, true, true };
- OptionNames = new string[] { Offset, Acceleration, string.Empty, string.Empty, Cap, Weight };
+
+ AccelLayout = new OptionLayout(true, Acceleration);
+ CapLayout = new OptionLayout(true, Cap);
+ WeightLayout = new OptionLayout(false, string.Empty);
+ OffsetLayout = new OptionLayout(true, Offset);
+ LimExpLayout = new OptionLayout(false, string.Empty);
+ MidpointLayout = new OptionLayout(false, string.Empty);
}
}
}
diff --git a/grapher/Layouts/NaturalGainLayout.cs b/grapher/Layouts/NaturalGainLayout.cs
index 0f9caf0..ae73c80 100644
--- a/grapher/Layouts/NaturalGainLayout.cs
+++ b/grapher/Layouts/NaturalGainLayout.cs
@@ -14,8 +14,13 @@ namespace grapher.Layouts
{
Name = "NaturalGain";
Index = (int)AccelMode.naturalgain;
- ShowOptions = new bool[] { true, true, true, false, false, true };
- OptionNames = new string[] { Offset, Acceleration, Limit, string.Empty, string.Empty, Weight};
+
+ AccelLayout = new OptionLayout(true, Acceleration);
+ CapLayout = new OptionLayout(false, string.Empty);
+ WeightLayout = new OptionLayout(false, string.Empty);
+ OffsetLayout = new OptionLayout(true, Offset);
+ LimExpLayout = new OptionLayout(true, Limit);
+ MidpointLayout = new OptionLayout(false, string.Empty);
}
}
}
diff --git a/grapher/Layouts/NaturalLayout.cs b/grapher/Layouts/NaturalLayout.cs
index caa77bd..0923e1d 100644
--- a/grapher/Layouts/NaturalLayout.cs
+++ b/grapher/Layouts/NaturalLayout.cs
@@ -14,8 +14,13 @@ namespace grapher.Layouts
{
Name = "Natural";
Index = (int)AccelMode.natural;
- ShowOptions = new bool[] { true, true, true, false, false, true };
- OptionNames = new string[] { Offset, Acceleration, Limit, string.Empty, string.Empty, Weight };
+
+ AccelLayout = new OptionLayout(true, Acceleration);
+ CapLayout = new OptionLayout(false, string.Empty);
+ WeightLayout = new OptionLayout(false, string.Empty);
+ OffsetLayout = new OptionLayout(true, Offset);
+ LimExpLayout = new OptionLayout(true, Limit);
+ MidpointLayout = new OptionLayout(false, string.Empty);
}
}
}
diff --git a/grapher/Layouts/OffLayout.cs b/grapher/Layouts/OffLayout.cs
index 1c37026..2a2f414 100644
--- a/grapher/Layouts/OffLayout.cs
+++ b/grapher/Layouts/OffLayout.cs
@@ -14,9 +14,14 @@ namespace grapher.Layouts
{
Name = "Off";
Index = (int)AccelMode.noaccel;
- ShowOptions = new bool[] { false, false, false, false, false, false };
- OptionNames = new string[] { string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty };
ButtonEnabled = true;
+
+ 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);
}
}
}
diff --git a/grapher/Layouts/OptionLayout.cs b/grapher/Layouts/OptionLayout.cs
new file mode 100644
index 0000000..2f29706
--- /dev/null
+++ b/grapher/Layouts/OptionLayout.cs
@@ -0,0 +1,41 @@
+using grapher.Models.Options;
+
+namespace grapher.Layouts
+{
+ public class OptionLayout
+ {
+ #region Constructors
+
+ public OptionLayout(bool show, string name)
+ {
+ Show = show;
+ Name = name;
+ }
+
+ #endregion Constructors
+
+ #region Properties
+
+ private bool Show { get; }
+
+ private string Name { get; }
+
+ #endregion Properties
+
+ #region Methods
+
+ public void Layout(IOption option)
+ {
+ if (Show)
+ {
+ option.Show(Name);
+ }
+ else
+ {
+ option.Hide();
+ }
+ }
+
+ #endregion Methods
+ }
+}
diff --git a/grapher/Layouts/PowerLayout.cs b/grapher/Layouts/PowerLayout.cs
index 699536f..4438c1a 100644
--- a/grapher/Layouts/PowerLayout.cs
+++ b/grapher/Layouts/PowerLayout.cs
@@ -14,8 +14,13 @@ namespace grapher.Layouts
{
Name = "Power";
Index = (int)AccelMode.power;
- ShowOptions = new bool[] { true, true, true, false, true, true };
- OptionNames = new string[] { Offset, Scale, Exponent, string.Empty, Cap, Weight };
+
+ AccelLayout = new OptionLayout(true, Acceleration);
+ CapLayout = new OptionLayout(true, Cap);
+ WeightLayout = new OptionLayout(true, Weight);
+ OffsetLayout = new OptionLayout(true, Offset);
+ LimExpLayout = new OptionLayout(true, Limit);
+ MidpointLayout = new OptionLayout(false, string.Empty);
}
}
}
diff --git a/grapher/Layouts/SigmoidGainLayout.cs b/grapher/Layouts/SigmoidGainLayout.cs
index 3897477..1704071 100644
--- a/grapher/Layouts/SigmoidGainLayout.cs
+++ b/grapher/Layouts/SigmoidGainLayout.cs
@@ -14,8 +14,13 @@ namespace grapher.Layouts
{
Name = "SigmoidGain";
Index = (int)AccelMode.sigmoidgain;
- ShowOptions = new bool[] { true, true, true, true, false, true };
- OptionNames = new string[] { Offset, Acceleration, Limit, Midpoint, string.Empty, Weight };
+
+ AccelLayout = new OptionLayout(true, Acceleration);
+ CapLayout = new OptionLayout(false, string.Empty);
+ WeightLayout = new OptionLayout(false, string.Empty);
+ OffsetLayout = new OptionLayout(true, Offset);
+ LimExpLayout = new OptionLayout(true, Limit);
+ MidpointLayout = new OptionLayout(true, Midpoint);
}
}
}