summaryrefslogtreecommitdiff
path: root/grapher/Layouts
diff options
context:
space:
mode:
authorJacob Palecki <[email protected]>2020-07-30 02:00:20 -0700
committerJacob Palecki <[email protected]>2020-07-30 02:00:20 -0700
commitf315e8160e984df93be6667929db34749aa25cfa (patch)
tree19684a4f515fc6185e750d7cca3424fa7d96937b /grapher/Layouts
parentFully use acceloptions (diff)
downloadrawaccel-f315e8160e984df93be6667929db34749aa25cfa.tar.xz
rawaccel-f315e8160e984df93be6667929db34749aa25cfa.zip
Use class heirarchy for layout types
Diffstat (limited to 'grapher/Layouts')
-rw-r--r--grapher/Layouts/ClassicLayout.cs19
-rw-r--r--grapher/Layouts/DefaultLayout.cs20
-rw-r--r--grapher/Layouts/LayoutBase.cs52
-rw-r--r--grapher/Layouts/LinearLayout.cs19
-rw-r--r--grapher/Layouts/LogLayout.cs19
-rw-r--r--grapher/Layouts/NaturalLayout.cs19
-rw-r--r--grapher/Layouts/PowerLayout.cs19
-rw-r--r--grapher/Layouts/SigmoidLayout.cs19
8 files changed, 186 insertions, 0 deletions
diff --git a/grapher/Layouts/ClassicLayout.cs b/grapher/Layouts/ClassicLayout.cs
new file mode 100644
index 0000000..a8fc2bd
--- /dev/null
+++ b/grapher/Layouts/ClassicLayout.cs
@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace grapher.Layouts
+{
+ public class ClassicLayout : LayoutBase
+ {
+ public ClassicLayout()
+ {
+ Name = "Classic";
+ Index = 2;
+ Show = new bool[] { true, true, false };
+ OptionNames = new string[] { Acceleration, Exponent, string.Empty };
+ }
+ }
+}
diff --git a/grapher/Layouts/DefaultLayout.cs b/grapher/Layouts/DefaultLayout.cs
new file mode 100644
index 0000000..2ad3c0e
--- /dev/null
+++ b/grapher/Layouts/DefaultLayout.cs
@@ -0,0 +1,20 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace grapher.Layouts
+{
+ public class DefaultLayout : LayoutBase
+ {
+ public DefaultLayout()
+ {
+ Name = "Off";
+ Index = 0;
+ Show = new bool[] { true, true, true };
+ OptionNames = new string[] { Acceleration, $"{Limit}\\{Exponent}", Midpoint };
+ }
+ }
+}
diff --git a/grapher/Layouts/LayoutBase.cs b/grapher/Layouts/LayoutBase.cs
new file mode 100644
index 0000000..9c60008
--- /dev/null
+++ b/grapher/Layouts/LayoutBase.cs
@@ -0,0 +1,52 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace grapher.Layouts
+{
+ public abstract class LayoutBase
+ {
+ public const string Acceleration = "Acceleration";
+ public const string Scale = "Scale";
+ public const string Exponent = "Exponent";
+ public const string Limit = "Limit";
+ public const string Midpoint = "Midpoint";
+
+ public LayoutBase()
+ {
+ Show = new bool[] { false, false, false };
+ OptionNames = new string[] { string.Empty, string.Empty, string.Empty };
+ }
+
+ /// <summary>
+ /// Gets or sets mapping from acceleration type to identifying integer.
+ /// Must match order in tagged_union in rawaccel.hpp (which is 1-indexed, meaning 0 is off.)
+ /// </summary>
+ public int Index { get; internal set; }
+
+ public string Name { get; internal set; }
+
+ internal bool[] Show { get; set; }
+
+ internal string[] OptionNames { get; set; }
+
+ public void Layout(Option[] options)
+ {
+ // Relies on AccelOptions to keep lengths correct.
+ for (int i = 0; i< options.Length; i++)
+ {
+ if (Show[i])
+ {
+ options[i].Show(OptionNames[i]);
+ }
+ else
+ {
+ options[i].Hide();
+ }
+ }
+
+ }
+ }
+}
diff --git a/grapher/Layouts/LinearLayout.cs b/grapher/Layouts/LinearLayout.cs
new file mode 100644
index 0000000..b500b6b
--- /dev/null
+++ b/grapher/Layouts/LinearLayout.cs
@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace grapher.Layouts
+{
+ public class LinearLayout : LayoutBase
+ {
+ public LinearLayout()
+ {
+ Name = "Linear";
+ Index = 1;
+ Show = new bool[] { true, false, false };
+ OptionNames = new string[] { Acceleration, string.Empty, string.Empty };
+ }
+ }
+}
diff --git a/grapher/Layouts/LogLayout.cs b/grapher/Layouts/LogLayout.cs
new file mode 100644
index 0000000..7c7fd9e
--- /dev/null
+++ b/grapher/Layouts/LogLayout.cs
@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace grapher.Layouts
+{
+ public class LogLayout : LayoutBase
+ {
+ public LogLayout()
+ {
+ Name = "Logarithmic";
+ Index = 4;
+ Show = new bool[] { true, false, false };
+ OptionNames = new string[] { Acceleration, string.Empty, string.Empty };
+ }
+ }
+}
diff --git a/grapher/Layouts/NaturalLayout.cs b/grapher/Layouts/NaturalLayout.cs
new file mode 100644
index 0000000..180a7c0
--- /dev/null
+++ b/grapher/Layouts/NaturalLayout.cs
@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace grapher.Layouts
+{
+ public class NaturalLayout : LayoutBase
+ {
+ public NaturalLayout()
+ {
+ Name = "Natural";
+ Index = 3;
+ Show = new bool[] { true, true, false };
+ OptionNames = new string[] { Acceleration, Limit, string.Empty };
+ }
+ }
+}
diff --git a/grapher/Layouts/PowerLayout.cs b/grapher/Layouts/PowerLayout.cs
new file mode 100644
index 0000000..6d4f5d7
--- /dev/null
+++ b/grapher/Layouts/PowerLayout.cs
@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace grapher.Layouts
+{
+ public class PowerLayout : LayoutBase
+ {
+ public PowerLayout()
+ {
+ Name = "Power";
+ Index = 6;
+ Show = new bool[] { true, true, false };
+ OptionNames = new string[] { Scale, Exponent, string.Empty };
+ }
+ }
+}
diff --git a/grapher/Layouts/SigmoidLayout.cs b/grapher/Layouts/SigmoidLayout.cs
new file mode 100644
index 0000000..88d6c61
--- /dev/null
+++ b/grapher/Layouts/SigmoidLayout.cs
@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace grapher.Layouts
+{
+ public class SigmoidLayout : LayoutBase
+ {
+ public SigmoidLayout()
+ {
+ Name = "Sigmoid";
+ Index = 5;
+ Show = new bool[] { true, true, true };
+ OptionNames = new string[] { Acceleration, Limit, Midpoint };
+ }
+ }
+}