diff options
| author | Jacob Palecki <[email protected]> | 2020-09-02 01:02:51 -0700 |
|---|---|---|
| committer | Jacob Palecki <[email protected]> | 2020-09-02 01:02:51 -0700 |
| commit | 5b9b8ed308e7a8cefbd27b2db72d33d7b002e223 (patch) | |
| tree | 0d66b20cb15f95ac795247da90d3eb1d85a54d58 /grapher/Models/Options | |
| parent | Small fixes, correctly align labels and boxes (diff) | |
| download | rawaccel-5b9b8ed308e7a8cefbd27b2db72d33d7b002e223.tar.xz rawaccel-5b9b8ed308e7a8cefbd27b2db72d33d7b002e223.zip | |
Move optionsets to applyoptions
Diffstat (limited to 'grapher/Models/Options')
| -rw-r--r-- | grapher/Models/Options/AccelOptionSet.cs | 17 | ||||
| -rw-r--r-- | grapher/Models/Options/AccelTypeOptions.cs | 26 | ||||
| -rw-r--r-- | grapher/Models/Options/ApplyOptions.cs | 79 |
3 files changed, 101 insertions, 21 deletions
diff --git a/grapher/Models/Options/AccelOptionSet.cs b/grapher/Models/Options/AccelOptionSet.cs index e2f2bf7..46b6e3e 100644 --- a/grapher/Models/Options/AccelOptionSet.cs +++ b/grapher/Models/Options/AccelOptionSet.cs @@ -69,15 +69,16 @@ namespace grapher.Models.Options } } - public void SetTitleMode() + public void SetTitleMode(string title) { if (!IsTitleMode) { IsTitleMode = true; + TitleLabel.Text = title; AccelTypeOptions.Left = Acceleration.Field.Left; AccelTypeOptions.Width = Acceleration.Field.Width; - AccelTypeOptions.ShowFullText(); + AccelTypeOptions.ShowShortenedText(); DisplayTitle(); } } @@ -86,12 +87,6 @@ namespace grapher.Models.Options { TitleLabel.Hide(); AccelTypeOptions.Hide(); - Acceleration.Hide(); - Cap.Hide(); - Weight.Hide(); - Offset.Hide(); - LimitOrExponent.Hide(); - Midpoint.Hide(); } public void Show() @@ -102,12 +97,6 @@ namespace grapher.Models.Options } AccelTypeOptions.Show(); - Acceleration.Show(); - Cap.Show(); - Weight.Show(); - Offset.Show(); - LimitOrExponent.Show(); - Midpoint.Show(); } public void DisplayTitle() diff --git a/grapher/Models/Options/AccelTypeOptions.cs b/grapher/Models/Options/AccelTypeOptions.cs index 2359b8d..5342f4b 100644 --- a/grapher/Models/Options/AccelTypeOptions.cs +++ b/grapher/Models/Options/AccelTypeOptions.cs @@ -62,7 +62,15 @@ namespace grapher public ComboBox AccelDropdown { get; } - public int AccelerationIndex { get; private set; } + public int AccelerationIndex + { + get + { + return AccelerationType.Index; + } + } + + public LayoutBase AccelerationType { get; private set; } public ActiveValueLabel ActiveValueLabel { get; } @@ -125,11 +133,17 @@ namespace grapher public void Hide() { AccelDropdown.Hide(); + + foreach(var option in Options) + { + option.Hide(); + } } public void Show() { AccelDropdown.Show(); + Layout(); } public void SetActiveValue(int index) @@ -163,9 +177,13 @@ namespace grapher private void Layout(string type) { - var accelerationType = AccelerationTypes[type]; - AccelerationIndex = accelerationType.Index; - accelerationType.Layout(Options, WriteButton); + AccelerationType = AccelerationTypes[type]; + Layout(); + } + + private void Layout() + { + AccelerationType.Layout(Options, WriteButton); } #endregion Methods diff --git a/grapher/Models/Options/ApplyOptions.cs b/grapher/Models/Options/ApplyOptions.cs index 703f0d5..0241fdf 100644 --- a/grapher/Models/Options/ApplyOptions.cs +++ b/grapher/Models/Options/ApplyOptions.cs @@ -1,4 +1,5 @@ -using System; +using grapher.Models.Serialized; +using System; using System.Collections.Generic; using System.Linq; using System.Text; @@ -14,7 +15,10 @@ namespace grapher.Models.Options public ApplyOptions( ToolStripMenuItem wholeVectorMenuItem, - ToolStripMenuItem byComponentMenuItem) + ToolStripMenuItem byComponentMenuItem, + CheckBox byComponentVectorXYLock, + AccelOptionSet optionSetX, + AccelOptionSet optionSetY) { WholeVectorMenuItem = wholeVectorMenuItem; ByComponentVectorMenuItem = byComponentMenuItem; @@ -25,6 +29,14 @@ namespace grapher.Models.Options WholeVectorMenuItem.CheckedChanged += new System.EventHandler(OnWholeCheckedChange); ByComponentVectorMenuItem.CheckedChanged += new System.EventHandler(OnByComponentCheckedChange); + ByComponentVectorXYLock = byComponentVectorXYLock; + OptionSetX = optionSetX; + OptionSetY = optionSetY; + + ByComponentVectorXYLock.CheckedChanged += new System.EventHandler(OnByComponentXYLockChecked); + ByComponentVectorXYLock.Checked = false; + ByComponentVectorXYLock.Checked = true; + IsWhole = false; } @@ -36,18 +48,54 @@ namespace grapher.Models.Options public ToolStripMenuItem ByComponentVectorMenuItem { get; } + public CheckBox ByComponentVectorXYLock { get; } + + public AccelOptionSet OptionSetX { get; } + + public AccelOptionSet OptionSetY { get; } + public bool IsWhole { get; private set; } #endregion Properties #region Methods - public void SetActive(bool isWhole) + public Vec2<AccelMode> GetModes() + { + var xMode = (AccelMode)OptionSetX.AccelTypeOptions.AccelerationIndex; + + return new Vec2<AccelMode> + { + x = xMode, + y = ByComponentVectorXYLock.Checked ? xMode : (AccelMode)OptionSetY.AccelTypeOptions.AccelerationIndex + }; + } + + public Vec2<AccelArgs> GetArgs() + { + var xArgs = OptionSetX.GenerateArgs(); + + return new Vec2<AccelArgs> + { + x = xArgs, + y = ByComponentVectorXYLock.Checked ? xArgs : OptionSetY.GenerateArgs() + }; + + } + + public void SetActiveValues(int xMode, int yMode, AccelArgs xArgs, AccelArgs yArgs, bool isWhole) { + OptionSetX.SetActiveValues(xMode, xArgs); + OptionSetY.SetActiveValues(yMode, yArgs); WholeVectorMenuItem.Checked = isWhole; ByComponentVectorMenuItem.Checked = !isWhole; } + public void SetActiveValues(DriverSettings settings) + { + SetActiveValues((int)settings.modes.x, (int)settings.modes.y, settings.args.x, settings.args.y, settings.combineMagnitudes); + } + public void OnWholeClicked(object sender, EventArgs e) { if (!WholeVectorMenuItem.Checked) @@ -82,6 +130,31 @@ namespace grapher.Models.Options } } + public void ShowWholeOptionSet() + { + OptionSetX.SetTitleMode("X = Y"); + OptionSetY.Hide(); + } + + public void ShowByComponentSets() + { + OptionSetX.SetTitleMode("X"); + OptionSetY.SetTitleMode("Y"); + OptionSetY.Show(); + } + + private void OnByComponentXYLockChecked(object sender, EventArgs e) + { + if (ByComponentVectorXYLock.Checked) + { + ShowWholeOptionSet(); + } + else + { + ShowByComponentSets(); + } + } + public void EnableWholeApplication() { IsWhole = true; |