summaryrefslogtreecommitdiff
path: root/grapher/Models
diff options
context:
space:
mode:
authorJacob Palecki <[email protected]>2021-06-30 00:01:26 -0700
committerJacob Palecki <[email protected]>2021-06-30 00:01:26 -0700
commitabbe20f63aded56c4714766ca1b93183eafa062a (patch)
tree4b1a6e91b7c8c4fa3f017e4fc6880b932fb93dca /grapher/Models
parentFix high DPI issue (diff)
downloadrawaccel-abbe20f63aded56c4714766ca1b93183eafa062a.tar.xz
rawaccel-abbe20f63aded56c4714766ca1b93183eafa062a.zip
Add class for LUT apply type
Diffstat (limited to 'grapher/Models')
-rw-r--r--grapher/Models/Options/AccelTypeOptions.cs7
-rw-r--r--grapher/Models/Options/CapOptions.cs221
-rw-r--r--grapher/Models/Options/LUT/LutApplyOptions.cs176
3 files changed, 183 insertions, 221 deletions
diff --git a/grapher/Models/Options/AccelTypeOptions.cs b/grapher/Models/Options/AccelTypeOptions.cs
index 74e748a..cc2480c 100644
--- a/grapher/Models/Options/AccelTypeOptions.cs
+++ b/grapher/Models/Options/AccelTypeOptions.cs
@@ -119,6 +119,8 @@ namespace grapher
public LUTPanelOptions LutPanel { get; }
+ public LutApplyOptions LutApply { get; }
+
public LayoutBase AccelerationType
{
get
@@ -207,6 +209,7 @@ namespace grapher
Midpoint.Hide();
LutText.Hide();
LutPanel.Hide();
+ LutApply.Hide();
}
public void Show()
@@ -234,6 +237,7 @@ namespace grapher
Limit.SetActiveValue(args.limit);
Exponent.SetActiveValue(args.exponent);
Midpoint.SetActiveValue(args.midpoint);
+ LutApply.SetActiveValue(args.tableData.velocity);
}
public void ShowFull()
@@ -291,6 +295,7 @@ namespace grapher
if (Offset.Visible) args.offset = Offset.Field.Data;
if (Midpoint.Visible) args.midpoint = Midpoint.Field.Data;
if (Weight.Visible) args.weight = Weight.Field.Data;
+ if (LutApply.Visible) args.tableData.velocity = LutApply.ApplyType == LutApplyOptions.LutApplyType.Velocity;
}
public override void AlignActiveValues()
@@ -305,6 +310,7 @@ namespace grapher
Limit.AlignActiveValues();
Exponent.AlignActiveValues();
Midpoint.AlignActiveValues();
+ LutApply.AlignActiveValues();
}
private void OnIndexChanged(object sender, EventArgs e)
@@ -332,6 +338,7 @@ namespace grapher
Midpoint,
LutText,
LutPanel,
+ LutApply,
top);
}
diff --git a/grapher/Models/Options/CapOptions.cs b/grapher/Models/Options/CapOptions.cs
deleted file mode 100644
index b4afa5c..0000000
--- a/grapher/Models/Options/CapOptions.cs
+++ /dev/null
@@ -1,221 +0,0 @@
-using grapher.Models.Options;
-using System;
-using System.Windows.Forms;
-
-namespace grapher
-{
- public class CapOptions : OptionBase
- {
- #region Constants
-
-
- #endregion Constants
-
- #region Constructors
-
- public CapOptions(
- ToolStripMenuItem velocityGainCapCheck,
- ToolStripMenuItem legacyCapCheck,
- Option capOption)
- {
-
- VelocityGainCapCheck = velocityGainCapCheck;
- LegacyCapCheck = legacyCapCheck;
- CapOption = capOption;
-
- LegacyCapCheck.Click += new System.EventHandler(OnSensitivityCapCheckClick);
- VelocityGainCapCheck.Click += new System.EventHandler(OnVelocityGainCapCheckClick);
-
- LegacyCapCheck.CheckedChanged += new System.EventHandler(OnSensitivityCapCheckedChange);
- VelocityGainCapCheck.CheckedChanged += new System.EventHandler(OnVelocityGainCapCheckedChange);
-
- EnableVelocityGainCap();
- }
-
- #endregion Constructors
-
- #region Properties
-
- public ToolStripMenuItem LegacyCapCheck { get; }
-
- public ToolStripMenuItem VelocityGainCapCheck { get; }
-
- public Option CapOption { get; }
-
- public bool IsSensitivityGain { get; private set; }
-
- public double SensitivityCap {
- get
- {
- if (IsSensitivityGain)
- {
- return CapOption.Field.Data;
- }
- else
- {
- return 0;
- }
- }
- }
-
- public double VelocityGainCap {
- get
- {
- if (IsSensitivityGain)
- {
- return 0;
- }
- else
- {
- return CapOption.Field.Data;
- }
- }
- }
-
- public override int Top
- {
- get
- {
- return CapOption.Top;
- }
- set
- {
- CapOption.Top = value;
- }
- }
-
- public override int Height
- {
- get
- {
- return CapOption.Height;
- }
- }
-
- public override int Left
- {
- get
- {
- return CapOption.Left;
- }
- set
- {
- CapOption.Left = value;
- }
- }
-
- public override int Width
- {
- get
- {
- return CapOption.Width;
- }
- set
- {
- CapOption.Width = value;
- }
- }
-
- public override bool Visible
- {
- get
- {
- return CapOption.Visible;
- }
- }
-
- #endregion Properties
-
- #region Methods
-
- public override void Hide()
- {
- CapOption.Hide();
- }
-
- public void Show()
- {
- CapOption.Show();
- }
-
- public override void Show(string name)
- {
- CapOption.Show(name);
- }
-
- public void SnapTo(Option option)
- {
- Top = option.Top + option.Height + Constants.OptionVerticalSeperation;
- }
-
-
- public void SetActiveValues(double cap, bool legacyCap)
- {
- if (!legacyCap)
- {
- CapOption.ActiveValueLabel.FormatString = Constants.GainCapFormatString;
- CapOption.ActiveValueLabel.Prefix = "Gain";
- }
- else
- {
- CapOption.ActiveValueLabel.FormatString = Constants.DefaultActiveValueFormatString;
- CapOption.ActiveValueLabel.Prefix = string.Empty;
- }
-
- CapOption.SetActiveValue(cap);
- }
-
- public override void AlignActiveValues()
- {
- CapOption.AlignActiveValues();
- }
-
- void OnSensitivityCapCheckClick(object sender, EventArgs e)
- {
- if (!LegacyCapCheck.Checked)
- {
- VelocityGainCapCheck.Checked = false;
- LegacyCapCheck.Checked = true;
- }
- }
-
- void OnVelocityGainCapCheckClick(object sender, EventArgs e)
- {
- if (!VelocityGainCapCheck.Checked)
- {
- VelocityGainCapCheck.Checked = true;
- LegacyCapCheck.Checked = false;
- }
- }
-
- void OnSensitivityCapCheckedChange(object sender, EventArgs e)
- {
- if (LegacyCapCheck.Checked)
- {
- EnableSensitivityCap();
- }
- }
-
- void OnVelocityGainCapCheckedChange(object sender, EventArgs e)
- {
- if (VelocityGainCapCheck.Checked)
- {
- EnableVelocityGainCap();
- }
- }
-
- void EnableSensitivityCap()
- {
- IsSensitivityGain = true;
- CapOption.SetName("Sensitivity Cap");
- }
-
- void EnableVelocityGainCap()
- {
- IsSensitivityGain = false;
- CapOption.SetName("Velocity Gain Cap");
- }
-
- #endregion Methods
- }
-}
diff --git a/grapher/Models/Options/LUT/LutApplyOptions.cs b/grapher/Models/Options/LUT/LutApplyOptions.cs
new file mode 100644
index 0000000..6ea7412
--- /dev/null
+++ b/grapher/Models/Options/LUT/LutApplyOptions.cs
@@ -0,0 +1,176 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace grapher.Models.Options.LUT
+{
+ public class LutApplyOptions : OptionBase
+ {
+ public const string LUTApplyOptionsLabelText = "Apply as:";
+
+ public enum LutApplyType
+ {
+ Sensitivity,
+ Velocity
+ }
+
+ public class LutApplyOption
+ {
+ public LutApplyType Type { get; set; }
+
+ public string Name => Type.ToString();
+ }
+
+ public static readonly LutApplyOption Sensitivity = new LutApplyOption
+ {
+ Type = LutApplyType.Sensitivity,
+ };
+
+ public static readonly LutApplyOption Velocity = new LutApplyOption
+ {
+ Type = LutApplyType.Velocity,
+ };
+
+ public LutApplyOptions(
+ Label label,
+ ComboBox applyOptionsDropdown,
+ ActiveValueLabel lutApplyActiveValue)
+ {
+ ApplyOptions = applyOptionsDropdown;
+ ApplyOptions.Items.Clear();
+ ApplyOptions.Items.AddRange(
+ new LutApplyOption[]
+ {
+ Sensitivity,
+ Velocity,
+ });
+
+ Label = label;
+ Label.Text = LUTApplyOptionsLabelText;
+
+ ActiveValueLabel = lutApplyActiveValue;
+ }
+
+ public LutApplyType ApplyType { get => ApplyOption.Type; }
+
+ public LutApplyOption ApplyOption {
+ get
+ {
+ return ApplyOptions.SelectedItem as LutApplyOption;
+ }
+ set
+ {
+ ApplyOptions.SelectedItem = value;
+ }
+ }
+
+ public Label Label { get; }
+
+ public ActiveValueLabel ActiveValueLabel { get; }
+
+ public ComboBox ApplyOptions { get; }
+
+ public override bool Visible
+ {
+ get
+ {
+ return Label.Visible || ShouldShow;
+ }
+ }
+
+ public override int Left
+ {
+ get
+ {
+ return Label.Left;
+ }
+ set
+ {
+ Label.Left = value;
+ ApplyOptions.Left = Label.Left + Label.Width + Constants.OptionLabelBoxSeperation;
+ }
+ }
+
+ public override int Height
+ {
+ get
+ {
+ return Label.Height;
+ }
+ }
+
+ public override int Top
+ {
+ get
+ {
+ return Label.Top;
+ }
+ set
+ {
+ Label.Top = value;
+ ApplyOptions.Top = value;
+ ActiveValueLabel.Top = value;
+ }
+ }
+
+ public override int Width
+ {
+ get
+ {
+ return Label.Width;
+ }
+ set
+ {
+ ApplyOptions.Width = value - Label.Width - Constants.OptionLabelBoxSeperation;
+ }
+ }
+
+ private bool ShouldShow { get; set; }
+
+ public override void Hide()
+ {
+ Label.Hide();
+ ApplyOptions.Hide();
+ ShouldShow = false;
+ }
+
+ public override void Show(string labelText)
+ {
+ Label.Show();
+
+ if (!string.IsNullOrWhiteSpace(labelText))
+ {
+ Label.Text = labelText;
+ }
+
+ ApplyOptions.Show();
+ ShouldShow = true;
+ }
+
+ public override void AlignActiveValues()
+ {
+ ActiveValueLabel.Align();
+ }
+
+ public void SetActiveValue(bool applyAsVelocity)
+ {
+ ApplyOption = ApplyOptionFromSettings(applyAsVelocity);
+ ActiveValueLabel.SetValue(ApplyOption.Name);
+ }
+
+ public LutApplyOption ApplyOptionFromSettings(bool applyAsVelocity)
+ {
+ if (applyAsVelocity)
+ {
+ return Velocity;
+ }
+ else
+ {
+ return Sensitivity;
+ }
+ }
+ }
+}