summaryrefslogtreecommitdiff
path: root/grapher/Models
diff options
context:
space:
mode:
authorJacob Palecki <[email protected]>2021-09-14 00:55:21 -0700
committera1xd <[email protected]>2021-09-23 22:34:51 -0400
commit6c037f92a350d8622f3739b1033c909912860d77 (patch)
treed8ddfa354176b0fa43713e47e8424cd466b6eeaa /grapher/Models
parentSome reorganizing (diff)
downloadrawaccel-6c037f92a350d8622f3739b1033c909912860d77.tar.xz
rawaccel-6c037f92a350d8622f3739b1033c909912860d77.zip
Mostly working cap type in GUI
Diffstat (limited to 'grapher/Models')
-rw-r--r--grapher/Models/AccelGUIFactory.cs123
-rw-r--r--grapher/Models/Options/AccelTypeOptions.cs75
-rw-r--r--grapher/Models/Options/Cap/CapOptions.cs107
-rw-r--r--grapher/Models/Options/Cap/CapTypeOptions.cs11
4 files changed, 230 insertions, 86 deletions
diff --git a/grapher/Models/AccelGUIFactory.cs b/grapher/Models/AccelGUIFactory.cs
index 20040fb..156606e 100644
--- a/grapher/Models/AccelGUIFactory.cs
+++ b/grapher/Models/AccelGUIFactory.cs
@@ -2,6 +2,7 @@
using grapher.Models.Devices;
using grapher.Models.Mouse;
using grapher.Models.Options;
+using grapher.Models.Options.Cap;
using grapher.Models.Options.Directionality;
using grapher.Models.Options.LUT;
using grapher.Models.Serialized;
@@ -27,6 +28,8 @@ namespace grapher.Models
ComboBox accelTypeDropY,
ComboBox lutApplyDropdownX,
ComboBox lutApplyDropdownY,
+ ComboBox capTypeDropdownX,
+ ComboBox capTypeDropdownY,
Button writeButton,
ButtonBase toggleButton,
ToolStripMenuItem showVelocityGainToolStripMenuItem,
@@ -43,8 +46,10 @@ namespace grapher.Models
TextBox rotationBox,
TextBox weightBoxX,
TextBox weightBoxY,
- TextBox capBoxX,
- TextBox capBoxY,
+ TextBox inCapBoxX,
+ TextBox inCapBoxY,
+ TextBox outCapBoxX,
+ TextBox outCapBoxY,
TextBox offsetBoxX,
TextBox offsetBoxY,
TextBox accelerationBoxX,
@@ -87,8 +92,12 @@ namespace grapher.Models
Label rotationLabel,
Label weightLabelX,
Label weightLabelY,
- Label capLabelX,
- Label capLabelY,
+ Label inCapLabelX,
+ Label inCapLabelY,
+ Label outCapLabelX,
+ Label outCapLabelY,
+ Label capTypeLabelX,
+ Label capTypeLabelY,
Label offsetLabelX,
Label offsetLabelY,
Label constantOneLabelX,
@@ -118,8 +127,12 @@ namespace grapher.Models
Label rotationActiveLabel,
Label weightActiveXLabel,
Label weightActiveYLabel,
- Label capActiveXLabel,
- Label capActiveYLabel,
+ Label inCapActiveXLabel,
+ Label inCapActiveYLabel,
+ Label outCapActiveXLabel,
+ Label outCapActiveYLabel,
+ Label capTypeActiveXLabel,
+ Label capTypeActiveYLabel,
Label offsetActiveLabelX,
Label offsetActiveLabelY,
Label accelerationActiveLabelX,
@@ -234,24 +247,6 @@ namespace grapher.Models
new ActiveValueLabel(weightActiveYLabel, activeValueTitleY),
"Weight");
- var capX = new Option(
- capBoxX,
- form,
- 0,
- capLabelX,
- 0,
- new ActiveValueLabel(capActiveXLabel, activeValueTitleX),
- "Cap");
-
- var capY = new Option(
- capBoxY,
- form,
- 0,
- capLabelY,
- optionSetYLeft,
- new ActiveValueLabel(capActiveYLabel, activeValueTitleY),
- "Cap");
-
var offsetX = new Option(
offsetBoxX,
form,
@@ -378,6 +373,76 @@ namespace grapher.Models
new ActiveValueLabel(midpointActiveLabelY, activeValueTitleY),
optionSetYLeft);
+ var inCapX = new Option(
+ inCapBoxX,
+ form,
+ 0,
+ inCapLabelX,
+ 0,
+ new ActiveValueLabel(inCapActiveXLabel, activeValueTitleX),
+ "Cap: Input");
+
+ var inCapY = new Option(
+ inCapBoxY,
+ form,
+ 0,
+ inCapLabelY,
+ optionSetYLeft,
+ new ActiveValueLabel(inCapActiveYLabel, activeValueTitleY),
+ "Cap");
+
+ var outCapX = new Option(
+ outCapBoxX,
+ form,
+ 0,
+ outCapLabelX,
+ 0,
+ new ActiveValueLabel(outCapActiveXLabel, activeValueTitleX),
+ "Cap: Input");
+
+ var outCapY = new Option(
+ outCapBoxY,
+ form,
+ 0,
+ outCapLabelY,
+ optionSetYLeft,
+ new ActiveValueLabel(outCapActiveYLabel, activeValueTitleY),
+ "Cap");
+
+ var capTypeX = new CapTypeOptions(
+ capTypeLabelX,
+ capTypeDropdownX,
+ new ActiveValueLabel(capTypeActiveXLabel, activeValueTitleX));
+
+ var capTypeY = new CapTypeOptions(
+ capTypeLabelY,
+ capTypeDropdownY,
+ new ActiveValueLabel(capTypeActiveYLabel, activeValueTitleY));
+
+ var accelCapOptionsX = new CapOptions(
+ capTypeX,
+ inCapX,
+ outCapX,
+ accelerationX);
+
+ var accelCapOptionsY = new CapOptions(
+ capTypeY,
+ inCapY,
+ outCapY,
+ accelerationY);
+
+ var powerCapOptionsX = new CapOptions(
+ capTypeX,
+ inCapX,
+ outCapX,
+ accelerationX);
+
+ var powerCapOptionsY = new CapOptions(
+ capTypeY,
+ inCapY,
+ outCapY,
+ accelerationY);
+
var lpNorm = new Option(
new Field(lpNormBox, form, 2),
lpNormLabel,
@@ -421,12 +486,11 @@ namespace grapher.Models
var accelerationOptionsX = new AccelTypeOptions(
accelTypeDropX,
gainSwitchOptionX,
- accelerationX,
+ accelCapOptionsX,
+ powerCapOptionsX,
decayRateX,
growthRateX,
smoothX,
- scaleX,
- capX,
weightX,
offsetX,
limitX,
@@ -445,12 +509,11 @@ namespace grapher.Models
var accelerationOptionsY = new AccelTypeOptions(
accelTypeDropY,
gainSwitchOptionY,
- accelerationY,
+ accelCapOptionsY,
+ powerCapOptionsY,
decayRateY,
growthRateY,
smoothY,
- scaleY,
- capY,
weightY,
offsetY,
limitY,
diff --git a/grapher/Models/Options/AccelTypeOptions.cs b/grapher/Models/Options/AccelTypeOptions.cs
index eab38a1..9086b41 100644
--- a/grapher/Models/Options/AccelTypeOptions.cs
+++ b/grapher/Models/Options/AccelTypeOptions.cs
@@ -1,5 +1,6 @@
using grapher.Layouts;
using grapher.Models.Options;
+using grapher.Models.Options.Cap;
using grapher.Models.Options.LUT;
using grapher.Models.Serialized;
using System;
@@ -29,12 +30,11 @@ namespace grapher
public AccelTypeOptions(
ComboBox accelDropdown,
CheckBoxOption gainSwitch,
- Option acceleration,
+ CapOptions classicCap,
+ CapOptions powerCap,
Option decayRate,
Option growthRate,
Option smooth,
- Option scale,
- Option cap,
Option weight,
Option offset,
Option limit,
@@ -65,12 +65,11 @@ namespace grapher
AccelDropdown.SelectedIndexChanged += new System.EventHandler(OnIndexChanged);
GainSwitch = gainSwitch;
- Acceleration = acceleration;
DecayRate = decayRate;
GrowthRate = growthRate;
Smooth = smooth;
- Scale = scale;
- Cap = cap;
+ ClassicCap = classicCap;
+ PowerCap = powerCap;
Weight = weight;
Offset = offset;
Limit = limit;
@@ -85,7 +84,7 @@ namespace grapher
AccelTypeActiveValue.Left = AccelDropdown.Left + AccelDropdown.Width;
AccelTypeActiveValue.Height = AccelDropdown.Height;
- GainSwitch.Left = Acceleration.Field.Left;
+ GainSwitch.Left = DecayRate.Field.Left;
LutPanel.Left = AccelDropdown.Left;
LutPanel.Width = AccelDropdown.Width + AccelTypeActiveValue.Width;
@@ -108,17 +107,15 @@ namespace grapher
public ActiveValueLabel AccelTypeActiveValue { get; }
- public Option Acceleration { get; }
-
public Option DecayRate { get; }
public Option GrowthRate { get; }
public Option Smooth { get; }
- public Option Scale { get; }
+ public CapOptions ClassicCap { get; }
- public Option Cap { get; }
+ public CapOptions PowerCap { get; }
public Option Weight { get; }
@@ -228,12 +225,11 @@ namespace grapher
AccelTypeActiveValue.Hide();
GainSwitch.Hide();
- Acceleration.Hide();
DecayRate.Hide();
GrowthRate.Hide();
Smooth.Hide();
- Scale.Hide();
- Cap.Hide();
+ ClassicCap.Hide();
+ PowerCap.Hide();
Weight.Hide();
Offset.Hide();
Limit.Hide();
@@ -263,13 +259,20 @@ namespace grapher
AccelTypeActiveValue.SetValue(AccelerationType.ActiveName);
GainSwitch.SetActiveValue(args.gain);
Weight.SetActiveValue(args.weight);
- Cap.SetActiveValue(args.cap.x);
+ ClassicCap.SetActiveValues(
+ args.acceleration,
+ args.cap.x,
+ args.cap.y,
+ args.capMode);
+ PowerCap.SetActiveValues(
+ args.scale,
+ args.cap.x,
+ args.cap.y,
+ args.capMode);
Offset.SetActiveValue(args.offset);
- Acceleration.SetActiveValue(args.acceleration);
DecayRate.SetActiveValue(args.decayRate);
GrowthRate.SetActiveValue(args.growthRate);
Smooth.SetActiveValue(args.smooth);
- Scale.SetActiveValue(args.scale);
Limit.SetActiveValue((args.mode == AccelMode.motivity) ? args.motivity : args.limit);
PowerClassic.SetActiveValue(args.exponentClassic);
Exponent.SetActiveValue(args.exponentPower);
@@ -286,8 +289,8 @@ namespace grapher
AccelDropdown.Text = Constants.AccelDropDownDefaultFullText;
}
- Left = Acceleration.Left + Constants.DropDownLeftSeparation;
- Width = Acceleration.Width - Constants.DropDownLeftSeparation;
+ Left = DecayRate.Left + Constants.DropDownLeftSeparation;
+ Width = DecayRate.Width - Constants.DropDownLeftSeparation;
LutText.Expand();
HandleLUTOptionsOnResize();
@@ -300,8 +303,8 @@ namespace grapher
AccelDropdown.Text = Constants.AccelDropDownDefaultShortText;
}
- Left = Acceleration.Field.Left;
- Width = Acceleration.Field.Width;
+ Left = DecayRate.Field.Left;
+ Width = DecayRate.Field.Width;
LutText.Shorten();
}
@@ -311,13 +314,23 @@ namespace grapher
args.mode = AccelerationType.Mode;
args.gain = GainSwitch.CheckBox.Checked;
- if (Acceleration.Visible) args.acceleration = Acceleration.Field.Data;
if (DecayRate.Visible) args.decayRate = DecayRate.Field.Data;
if (GrowthRate.Visible) args.growthRate = GrowthRate.Field.Data;
if (Smooth.Visible) args.smooth = Smooth.Field.Data;
- if (Scale.Visible) args.scale = Scale.Field.Data;
- // TODO - make field for output and in_out cap
- if (Cap.Visible) args.cap.x = Cap.Field.Data;
+ if (ClassicCap.Visible)
+ {
+ args.acceleration = ClassicCap.Slope.Field.Data;
+ args.cap.x = ClassicCap.In.Field.Data;
+ args.cap.y = ClassicCap.Out.Field.Data;
+ args.capMode = ClassicCap.CapTypeOptions.GetSelectedCapMode();
+ }
+ if (PowerCap.Visible)
+ {
+ args.scale = ClassicCap.Slope.Field.Data;
+ args.cap.x = PowerCap.In.Field.Data;
+ args.cap.y = PowerCap.Out.Field.Data;
+ args.capMode = PowerCap.CapTypeOptions.GetSelectedCapMode();
+ }
if (Limit.Visible)
{
if (args.mode == AccelMode.motivity)
@@ -354,12 +367,11 @@ namespace grapher
{
AccelTypeActiveValue.Align();
GainSwitch.AlignActiveValues();
- Acceleration.AlignActiveValues();
DecayRate.AlignActiveValues();
GrowthRate.AlignActiveValues();
Smooth.AlignActiveValues();
- Scale.AlignActiveValues();
- Cap.AlignActiveValues();
+ ClassicCap.AlignActiveValues();
+ PowerCap.AlignActiveValues();
Offset.AlignActiveValues();
Weight.AlignActiveValues();
Limit.AlignActiveValues();
@@ -373,7 +385,7 @@ namespace grapher
{
LutText.Left = AccelDropdown.Left;
LutPanel.Left = GainSwitch.Left - 100;
- LutPanel.Width = Acceleration.ActiveValueLabel.CenteringLabel.Right - LutPanel.Left;
+ LutPanel.Width = DecayRate.ActiveValueLabel.CenteringLabel.Right - LutPanel.Left;
LutApply.Left = LutPanel.Left;
LutApply.Width = AccelDropdown.Right - LutPanel.Left;
}
@@ -393,12 +405,11 @@ namespace grapher
AccelerationType.Layout(
GainSwitch,
- Acceleration,
+ ClassicCap,
+ PowerCap,
DecayRate,
GrowthRate,
Smooth,
- Scale,
- Cap,
Weight,
Offset,
Limit,
diff --git a/grapher/Models/Options/Cap/CapOptions.cs b/grapher/Models/Options/Cap/CapOptions.cs
index 2fe44b0..e959dee 100644
--- a/grapher/Models/Options/Cap/CapOptions.cs
+++ b/grapher/Models/Options/Cap/CapOptions.cs
@@ -21,6 +21,11 @@ namespace grapher.Models.Options.Cap
In = capIn;
Out = capOut;
Slope = slope;
+
+ ShouldShow = true;
+ TopElement = Slope;
+ BottomElement = In;
+ CapTypeOptions.OptionsDropdown.SelectedIndexChanged += OnCapTypeDropdownSelectedItemChanged;
}
public CapTypeOptions CapTypeOptions { get; }
@@ -45,17 +50,16 @@ namespace grapher.Models.Options.Cap
public override int Top
{
- get => CapTypeOptions.Top;
+ get => TopElement.Top;
set
{
- CapTypeOptions.Top = value;
- Layout();
+ Layout(value);
}
}
public override int Height
{
- get => BottomElement.Top + BottomElement.Height - CapTypeOptions.Top;
+ get => BottomElement.Top + BottomElement.Height - TopElement.Top;
}
public override int Width
@@ -73,45 +77,100 @@ namespace grapher.Models.Options.Cap
public override bool Visible
{
- get => CapTypeOptions.Visible;
+ get => ShouldShow;
+ }
+
+ private bool ShouldShow { get; set; }
+
+ private IOption BottomElement { get; set; }
+
+ private IOption TopElement { get; set; }
+
+ public override void AlignActiveValues()
+ {
+ Slope.AlignActiveValues();
+ CapTypeOptions.AlignActiveValues();
+ In.AlignActiveValues();
+ Out.AlignActiveValues();
+ }
+
+ public override void Show(string name)
+ {
+ ShouldShow = true;
+ Layout(Top, name);
}
- private Option BottomElement { get; set; }
+ public override void Hide()
+ {
+ ShouldShow = false;
+ CapTypeOptions.Hide();
+ Slope.Hide();
+ In.Hide();
+ Out.Hide();
+ }
- public void Layout()
+ public void SetActiveValues(
+ double scale,
+ double inCap,
+ double outCap,
+ ClassicCapMode capMode)
{
- Layout(CapTypeOptions.Top + CapTypeOptions.Height + Constants.OptionVerticalSeperation);
+ Slope.SetActiveValue(scale);
+ In.SetActiveValue(inCap);
+ Out.SetActiveValue(outCap);
+ CapTypeOptions.SetActiveValue(capMode);
}
- private void Layout(int top)
+ private void Layout(int top, string name = null)
{
switch (CapTypeOptions.SelectedCapType)
{
case CapType.Input:
- Slope.Show();
- In.Show();
- Out.Hide();
+ if (ShouldShow)
+ {
+ Slope.Show();
+ CapTypeOptions.Show(name);
+ In.Show();
+ Out.Hide();
+ }
Slope.Top = top;
- In.SnapTo(Slope);
+ CapTypeOptions.SnapTo(Slope);
+ In.SnapTo(CapTypeOptions);
+
+ TopElement = CapTypeOptions;
BottomElement = In;
break;
case CapType.Output:
- Slope.Show();
- In.Hide();
- Out.Show();
+ if (ShouldShow)
+ {
+ Slope.Show();
+ CapTypeOptions.Show(name);
+ In.Hide();
+ Out.Show();
+ }
Slope.Top = top;
- In.SnapTo(Slope);
- BottomElement = In;
+ CapTypeOptions.SnapTo(Slope);
+ Out.SnapTo(CapTypeOptions);
+
+ TopElement = CapTypeOptions;
+ BottomElement = Out;
break;
case CapType.Both:
- Slope.Hide();
- In.Show();
- Out.Show();
-
- In.Top = top;
+ if (ShouldShow)
+ {
+ CapTypeOptions.Show(name);
+ Slope.Hide();
+ In.Show();
+ Out.Show();
+ }
+
+ CapTypeOptions.Top = top;
+ In.SnapTo(CapTypeOptions);
Out.SnapTo(In);
+
+ TopElement = In;
BottomElement = Out;
break;
}
@@ -119,7 +178,7 @@ namespace grapher.Models.Options.Cap
private void OnCapTypeDropdownSelectedItemChanged(object sender, EventArgs e)
{
- Layout();
+ Layout(Top);
}
private void SetupCapTypeDropdown(ComboBox capTypeDropDown)
diff --git a/grapher/Models/Options/Cap/CapTypeOptions.cs b/grapher/Models/Options/Cap/CapTypeOptions.cs
index 4ea372b..f0c5617 100644
--- a/grapher/Models/Options/Cap/CapTypeOptions.cs
+++ b/grapher/Models/Options/Cap/CapTypeOptions.cs
@@ -97,6 +97,17 @@ namespace grapher.Models.Options.Cap
}
}
+ public ClassicCapMode GetSelectedCapMode()
+ {
+ switch(SelectedCapType)
+ {
+ case CapType.Output: return ClassicCapMode.output;
+ case CapType.Both: return ClassicCapMode.in_out;
+ case CapType.Input:
+ default: return ClassicCapMode.input;
+ }
+ }
+
#endregion Properties
#region Methods