diff options
| author | Jacob Palecki <[email protected]> | 2020-09-08 00:51:05 -0700 |
|---|---|---|
| committer | Jacob Palecki <[email protected]> | 2020-09-08 00:51:05 -0700 |
| commit | f2322540dd904474587ddebfa8d96dc66a902530 (patch) | |
| tree | cb1b8c5f4324acbb3586dfcac442d950c1f0a886 | |
| parent | Add chart resize (diff) | |
| download | rawaccel-f2322540dd904474587ddebfa8d96dc66a902530.tar.xz rawaccel-f2322540dd904474587ddebfa8d96dc66a902530.zip | |
Alignment for whole mode works
| -rw-r--r-- | grapher/Constants/Constants.cs | 4 | ||||
| -rw-r--r-- | grapher/Form1.Designer.cs | 1 | ||||
| -rw-r--r-- | grapher/Form1.cs | 7 | ||||
| -rw-r--r-- | grapher/Models/AccelGUI.cs | 20 | ||||
| -rw-r--r-- | grapher/Models/AccelGUIFactory.cs | 9 | ||||
| -rw-r--r-- | grapher/Models/Options/AccelOptionSet.cs | 35 | ||||
| -rw-r--r-- | grapher/Models/Options/AccelTypeOptions.cs | 35 | ||||
| -rw-r--r-- | grapher/Models/Options/ActiveValueLabel.cs | 12 | ||||
| -rw-r--r-- | grapher/Models/Options/ActiveValueLabelXY.cs | 27 | ||||
| -rw-r--r-- | grapher/Models/Options/ApplyOptions.cs | 54 | ||||
| -rw-r--r-- | grapher/Models/Options/CapOptions.cs | 5 | ||||
| -rw-r--r-- | grapher/Models/Options/OffsetOptions.cs | 5 | ||||
| -rw-r--r-- | grapher/Models/Options/Option.cs | 10 | ||||
| -rw-r--r-- | grapher/Models/Options/OptionBase.cs | 2 | ||||
| -rw-r--r-- | grapher/Models/Options/OptionXY.cs | 5 |
15 files changed, 174 insertions, 57 deletions
diff --git a/grapher/Constants/Constants.cs b/grapher/Constants/Constants.cs index 9367fd1..887c8aa 100644 --- a/grapher/Constants/Constants.cs +++ b/grapher/Constants/Constants.cs @@ -54,10 +54,10 @@ namespace grapher public const int DropDownLeftSeparation = 10; /// <summary> Width of charts when widened </summary> - public const int WideChartWidth = 810; + public const int WideChartWidth = 723; /// <summary> Width of charts when widened </summary> - public const int WideChartLeft = 270; + public const int WideChartLeft = 333; /// <summary> Width of charts when narrowed </summary> public const int NarrowChartWidth = 698; diff --git a/grapher/Form1.Designer.cs b/grapher/Form1.Designer.cs index e60b74c..6ad2953 100644 --- a/grapher/Form1.Designer.cs +++ b/grapher/Form1.Designer.cs @@ -1131,7 +1131,6 @@ namespace grapher private System.Windows.Forms.ToolStripMenuItem offsetStyleToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem gainOffsetToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem legacyOffsetToolStripMenuItem; - private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem2; private System.Windows.Forms.Label ActiveValueTitleY; } } diff --git a/grapher/Form1.cs b/grapher/Form1.cs index a4c32cd..1bdb05c 100644 --- a/grapher/Form1.cs +++ b/grapher/Form1.cs @@ -37,11 +37,6 @@ namespace grapher throw; } - ActiveValueTitle.AutoSize = false; - ActiveValueTitle.Left = accelerationBoxY.Left + accelerationBoxY.Width; - ActiveValueTitle.Width = AccelerationChart.Left - ActiveValueTitle.Left; - ActiveValueTitle.TextAlign = ContentAlignment.MiddleCenter; - AccelGUI = AccelGUIFactory.Construct( this, activeAccel, @@ -82,6 +77,7 @@ namespace grapher midpointBoxY, sensXYLock, ByComponentXYLock, + LockXYLabel, sensitivityLabel, rotationLabel, weightLabelX, @@ -97,6 +93,7 @@ namespace grapher constantThreeLabelX, constantThreeLabelY, ActiveValueTitle, + ActiveValueTitleY, SensitivityActiveXLabel, SensitivityActiveYLabel, RotationActiveLabel, diff --git a/grapher/Models/AccelGUI.cs b/grapher/Models/AccelGUI.cs index e9e925f..36938b6 100644 --- a/grapher/Models/AccelGUI.cs +++ b/grapher/Models/AccelGUI.cs @@ -25,8 +25,6 @@ namespace grapher AccelCharts accelCharts, SettingsManager settings, ApplyOptions applyOptions, - OptionXY sensitivity, - Option rotation, Button writeButton, Label mouseMoveLabel, ToolStripMenuItem scaleMenuItem) @@ -35,8 +33,6 @@ namespace grapher AccelCalculator = accelCalculator; AccelCharts = accelCharts; ApplyOptions = applyOptions; - Sensitivity = sensitivity; - Rotation = rotation; WriteButton = writeButton; ScaleMenuItem = scaleMenuItem; Settings = settings; @@ -62,10 +58,6 @@ namespace grapher public ApplyOptions ApplyOptions { get; } - public OptionXY Sensitivity { get; } - - public Option Rotation { get; } - public Button WriteButton { get; } public MouseWatcher MouseWatcher { get; } @@ -80,11 +72,11 @@ namespace grapher { var settings = new DriverSettings { - rotation = Rotation.Field.Data, + rotation = ApplyOptions.Rotation.Field.Data, sensitivity = new Vec2<double> { - x = Sensitivity.Fields.X, - y = Sensitivity.Fields.Y + x = ApplyOptions.Sensitivity.Fields.X, + y = ApplyOptions.Sensitivity.Fields.Y }, combineMagnitudes = ApplyOptions.IsWhole, modes = ApplyOptions.GetModes(), @@ -120,11 +112,7 @@ namespace grapher public void UpdateShownActiveValues() { - var settings = Settings.RawAccelSettings.AccelerationSettings; - - Sensitivity.SetActiveValues(settings.sensitivity.x, settings.sensitivity.y); - Rotation.SetActiveValue(settings.rotation); - ApplyOptions.SetActiveValues(settings); + ApplyOptions.SetActiveValues(Settings.RawAccelSettings.AccelerationSettings); } private void OnScaleMenuItemClick(object sender, EventArgs e) diff --git a/grapher/Models/AccelGUIFactory.cs b/grapher/Models/AccelGUIFactory.cs index 7dbf200..05cea70 100644 --- a/grapher/Models/AccelGUIFactory.cs +++ b/grapher/Models/AccelGUIFactory.cs @@ -55,6 +55,7 @@ namespace grapher.Models TextBox midpointBoxY, CheckBox sensXYLock, CheckBox byComponentXYLock, + Label lockXYLabel, Label sensitivityLabel, Label rotationLabel, Label weightLabelX, @@ -70,6 +71,7 @@ namespace grapher.Models Label constantThreeLabelX, Label constantThreeLabelY, Label activeValueTitle, + Label activeValueTitleY, Label sensitivityActiveXLabel, Label sensitivityActiveYLabel, Label rotationActiveLabel, @@ -255,11 +257,13 @@ namespace grapher.Models var optionsSetX = new AccelOptionSet( optionSetXTitle, + activeValueTitle, rotationBox.Top + rotationBox.Height + Constants.OptionVerticalSeperation, accelerationOptionsX); var optionsSetY = new AccelOptionSet( optionSetYTitle, + activeValueTitleY, rotationBox.Top + rotationBox.Height + Constants.OptionVerticalSeperation, accelerationOptionsY); @@ -269,6 +273,9 @@ namespace grapher.Models byComponentXYLock, optionsSetX, optionsSetY, + sensitivity, + rotation, + lockXYLabel, accelCharts); var accelCalculator = new AccelCalculator( @@ -287,8 +294,6 @@ namespace grapher.Models accelCharts, settings, applyOptions, - sensitivity, - rotation, writeButton, mouseLabel, scaleMenuItem); diff --git a/grapher/Models/Options/AccelOptionSet.cs b/grapher/Models/Options/AccelOptionSet.cs index 8c7b303..2a1436f 100644 --- a/grapher/Models/Options/AccelOptionSet.cs +++ b/grapher/Models/Options/AccelOptionSet.cs @@ -1,6 +1,7 @@ using grapher.Models.Serialized; using System; using System.Collections.Generic; +using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -11,24 +12,31 @@ namespace grapher.Models.Options public class AccelOptionSet { public AccelOptionSet( - Label titleLabel, + Label title, + Label activeValuesTitle, int topAnchor, AccelTypeOptions accelTypeOptions) { - TitleLabel = titleLabel; + OptionsTitle = title; + ActiveValuesTitle = activeValuesTitle; TopAnchor = topAnchor; Options = accelTypeOptions; + ActiveValuesTitle.AutoSize = false; + ActiveValuesTitle.TextAlign = ContentAlignment.MiddleCenter; + Options.ShowFull(); - TitleLabel.Top = TopAnchor; + OptionsTitle.Top = TopAnchor; IsTitleMode = true; SetRegularMode(); } public int TopAnchor { get; } - public Label TitleLabel { get; } + public Label OptionsTitle { get; } + + public Label ActiveValuesTitle { get; } public AccelTypeOptions Options { get; } @@ -48,7 +56,7 @@ namespace grapher.Models.Options public void SetTitleMode(string title) { - TitleLabel.Text = title; + OptionsTitle.Text = title; if (!IsTitleMode) { @@ -61,7 +69,8 @@ namespace grapher.Models.Options public void Hide() { - TitleLabel.Hide(); + OptionsTitle.Hide(); + ActiveValuesTitle.Hide(); Options.Hide(); } @@ -69,22 +78,23 @@ namespace grapher.Models.Options { if (IsTitleMode) { - TitleLabel.Show(); + OptionsTitle.Show(); } + ActiveValuesTitle.Show(); Options.Show(); } public void DisplayTitle() { - TitleLabel.Show(); + OptionsTitle.Show(); - Options.Top = TitleLabel.Top + TitleLabel.Height + Constants.OptionVerticalSeperation; + Options.Top = OptionsTitle.Top + OptionsTitle.Height + Constants.OptionVerticalSeperation; } public void HideTitle() { - TitleLabel.Hide(); + OptionsTitle.Hide(); Options.Top = TopAnchor; } @@ -103,5 +113,10 @@ namespace grapher.Models.Options { Options.SetActiveValues(mode, args); } + + public void AlignActiveValuesByTitle() + { + Options.AlignActiveValues(ActiveValuesTitle.Width); + } } } diff --git a/grapher/Models/Options/AccelTypeOptions.cs b/grapher/Models/Options/AccelTypeOptions.cs index a5ed474..6a5dbc8 100644 --- a/grapher/Models/Options/AccelTypeOptions.cs +++ b/grapher/Models/Options/AccelTypeOptions.cs @@ -38,7 +38,7 @@ namespace grapher Option limitOrExponent, Option midpoint, Button writeButton, - ActiveValueLabel activeValueLabel) + ActiveValueLabel accelTypeActiveValue) { AccelDropdown = accelDropdown; AccelDropdown.Items.Clear(); @@ -52,17 +52,7 @@ namespace grapher LimitOrExponent = limitOrExponent; Midpoint = midpoint; WriteButton = writeButton; - ActiveValueLabel = activeValueLabel; - - Options = new List<OptionBase> - { - Acceleration, - Cap, - Offset, - Weight, - LimitOrExponent, - Midpoint, - }; + AccelTypeActiveValue = accelTypeActiveValue; Layout("Off"); ShowingDefault = true; @@ -86,7 +76,7 @@ namespace grapher public LayoutBase AccelerationType { get; private set; } - public ActiveValueLabel ActiveValueLabel { get; } + public ActiveValueLabel AccelTypeActiveValue { get; } public Option Acceleration { get; } @@ -100,8 +90,6 @@ namespace grapher public Option Midpoint { get; } - private IEnumerable<OptionBase> Options { get; } - public override int Top { get @@ -111,6 +99,7 @@ namespace grapher set { AccelDropdown.Top = value; + AccelTypeActiveValue.Top = value; Layout(value + AccelDropdown.Height + Constants.OptionVerticalSeperation); } } @@ -132,6 +121,7 @@ namespace grapher set { AccelDropdown.Left = value; + AccelTypeActiveValue.Left = AccelDropdown.Left + Width; } } @@ -144,6 +134,7 @@ namespace grapher set { AccelDropdown.Width = value; + AccelTypeActiveValue.Left = Left + AccelDropdown.Width; } } @@ -187,7 +178,7 @@ namespace grapher public void SetActiveValues(int index, AccelArgs args) { var name = AccelerationTypes.Where(t => t.Value.Index == index).FirstOrDefault().Value.Name; - ActiveValueLabel.SetValue(name); + AccelTypeActiveValue.SetValue(name); Weight.SetActiveValue(args.weight); Cap.SetActiveValues(args.gainCap, args.scaleCap, args.gainCap > 0); @@ -242,6 +233,18 @@ namespace grapher return args; } + public override void AlignActiveValues(int width) + { + AccelTypeActiveValue.Width = width; + + Acceleration.AlignActiveValues(width); + Cap.AlignActiveValues(width); + Offset.AlignActiveValues(width); + Weight.AlignActiveValues(width); + LimitOrExponent.AlignActiveValues(width); + Midpoint.AlignActiveValues(width); + } + private void OnIndexChanged(object sender, EventArgs e) { var accelerationTypeString = AccelDropdown.SelectedItem.ToString(); diff --git a/grapher/Models/Options/ActiveValueLabel.cs b/grapher/Models/Options/ActiveValueLabel.cs index d2b43ab..39af325 100644 --- a/grapher/Models/Options/ActiveValueLabel.cs +++ b/grapher/Models/Options/ActiveValueLabel.cs @@ -91,6 +91,18 @@ namespace grapher.Models.Options } } + public int Top + { + get + { + return ValueLabel.Top; + } + set + { + ValueLabel.Top = value; + } + } + #endregion Properties #region Methods diff --git a/grapher/Models/Options/ActiveValueLabelXY.cs b/grapher/Models/Options/ActiveValueLabelXY.cs index c8caddf..3f94847 100644 --- a/grapher/Models/Options/ActiveValueLabelXY.cs +++ b/grapher/Models/Options/ActiveValueLabelXY.cs @@ -43,9 +43,9 @@ namespace grapher.Models.Options public bool Combined { get; private set; } - private int FullWidth { get; } + private int FullWidth { get; set; } - private int ShortenedWidth { get; } + private int ShortenedWidth { get; set; } #endregion Properties @@ -93,6 +93,29 @@ namespace grapher.Models.Options Combined = false; } + public void AlignActiveValues(int width) + { + Align(width); + + if (Combined) + { + X.Width = FullWidth; + } + else + { + X.Width = ShortenedWidth; + } + } + + private void Align (int width) + { + FullWidth = width; + ShortenedWidth = (FullWidth - Constants.ActiveLabelXYSeparation) / 2; + + Y.Left = X.Left + ShortenedWidth + Constants.ActiveLabelXYSeparation; + Y.Width = ShortenedWidth; + } + #endregion Methods } } diff --git a/grapher/Models/Options/ApplyOptions.cs b/grapher/Models/Options/ApplyOptions.cs index 96d598d..76a3bb8 100644 --- a/grapher/Models/Options/ApplyOptions.cs +++ b/grapher/Models/Options/ApplyOptions.cs @@ -1,6 +1,7 @@ using grapher.Models.Serialized; using System; using System.Collections.Generic; +using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; @@ -19,6 +20,9 @@ namespace grapher.Models.Options CheckBox byComponentVectorXYLock, AccelOptionSet optionSetX, AccelOptionSet optionSetY, + OptionXY sensitivity, + Option rotation, + Label lockXYLabel, AccelCharts accelCharts) { WholeVectorMenuItem = wholeVectorMenuItem; @@ -33,8 +37,14 @@ namespace grapher.Models.Options ByComponentVectorXYLock = byComponentVectorXYLock; OptionSetX = optionSetX; OptionSetY = optionSetY; + Sensitivity = sensitivity; + Rotation = rotation; + LockXYLabel = lockXYLabel; AccelCharts = accelCharts; + LockXYLabel.AutoSize = false; + LockXYLabel.TextAlign = ContentAlignment.MiddleCenter; + ByComponentVectorXYLock.CheckedChanged += new System.EventHandler(OnByComponentXYLockChecked); ByComponentVectorXYLock.Checked = true; @@ -55,8 +65,16 @@ namespace grapher.Models.Options public AccelOptionSet OptionSetY { get; } + public OptionXY Sensitivity { get; } + + public Option Rotation { get; } + public AccelCharts AccelCharts { get; } + public Label ActiveValueTitleY { get; } + + public Label LockXYLabel { get; } + public bool IsWhole { get; private set; } #endregion Properties @@ -86,8 +104,18 @@ namespace grapher.Models.Options } - public void SetActiveValues(int xMode, int yMode, AccelArgs xArgs, AccelArgs yArgs, bool isWhole) + public void SetActiveValues( + double xSens, + double ySens, + double rotation, + int xMode, + int yMode, + AccelArgs xArgs, + AccelArgs yArgs, + bool isWhole) { + Sensitivity.SetActiveValues(xSens, ySens); + Rotation.SetActiveValue(rotation); OptionSetX.SetActiveValues(xMode, xArgs); OptionSetY.SetActiveValues(yMode, yArgs); WholeVectorMenuItem.Checked = isWhole; @@ -96,7 +124,15 @@ namespace grapher.Models.Options public void SetActiveValues(DriverSettings settings) { - SetActiveValues((int)settings.modes.x, (int)settings.modes.y, settings.args.x, settings.args.y, settings.combineMagnitudes); + SetActiveValues( + settings.sensitivity.x, + settings.sensitivity.x, + settings.rotation, + (int)settings.modes.x, + (int)settings.modes.y, + settings.args.x, + settings.args.y, + settings.combineMagnitudes); } public void OnWholeClicked(object sender, EventArgs e) @@ -135,6 +171,7 @@ namespace grapher.Models.Options OptionSetX.SetRegularMode(); OptionSetY.Hide(); AccelCharts.SetWidened(); + SetActiveTitlesWhole(); } public void ShowByComponentAsOneSet() @@ -186,6 +223,19 @@ namespace grapher.Models.Options ShowByComponentSet(); } + private void SetActiveTitlesWhole() + { + OptionSetX.ActiveValuesTitle.Left = OptionSetX.Options.Left + OptionSetX.Options.Width; + LockXYLabel.Width = (AccelCharts.SensitivityChart.Left - OptionSetX.ActiveValuesTitle.Left) / 2; + OptionSetX.ActiveValuesTitle.Width = LockXYLabel.Width; + LockXYLabel.Left = OptionSetX.ActiveValuesTitle.Left + OptionSetX.ActiveValuesTitle.Width; + Sensitivity.Fields.LockCheckBox.Left = LockXYLabel.Left + LockXYLabel.Width / 2 - Sensitivity.Fields.LockCheckBox.Width / 2; + ByComponentVectorXYLock.Left = Sensitivity.Fields.LockCheckBox.Left; + OptionSetX.AlignActiveValuesByTitle(); + Sensitivity.AlignActiveValues(OptionSetX.ActiveValuesTitle.Width); + Rotation.AlignActiveValues(OptionSetX.ActiveValuesTitle.Width); + } + #endregion Methods } } diff --git a/grapher/Models/Options/CapOptions.cs b/grapher/Models/Options/CapOptions.cs index a44b536..064a521 100644 --- a/grapher/Models/Options/CapOptions.cs +++ b/grapher/Models/Options/CapOptions.cs @@ -173,6 +173,11 @@ namespace grapher } } + public override void AlignActiveValues(int width) + { + CapOption.AlignActiveValues(width); + } + void OnSensitivityCapCheckClick(object sender, EventArgs e) { if (!LegacyCapCheck.Checked) diff --git a/grapher/Models/Options/OffsetOptions.cs b/grapher/Models/Options/OffsetOptions.cs index ffcb862..8942b0c 100644 --- a/grapher/Models/Options/OffsetOptions.cs +++ b/grapher/Models/Options/OffsetOptions.cs @@ -144,6 +144,11 @@ namespace grapher.Models.Options } } + public override void AlignActiveValues(int width) + { + OffsetOption.AlignActiveValues(width); + } + public void OnVelocityGainOffsetClick(object sender, EventArgs e) { if (!VelocityGainOffsetCheck.Checked) diff --git a/grapher/Models/Options/Option.cs b/grapher/Models/Options/Option.cs index 3c7b2ec..fd4a6fe 100644 --- a/grapher/Models/Options/Option.cs +++ b/grapher/Models/Options/Option.cs @@ -26,6 +26,8 @@ namespace grapher label.AutoSize = false; label.Width = Field.Left - left - Constants.OptionLabelBoxSeperation; label.TextAlign = System.Drawing.ContentAlignment.MiddleRight; + + ActiveValueLabel.Left = Field.Left + Field.Width; } public Option( @@ -82,6 +84,7 @@ namespace grapher { Field.Top = value; Label.Top = value; + ActiveValueLabel.Top = value; } } @@ -163,7 +166,12 @@ namespace grapher Show(); } - + + public override void AlignActiveValues(int width) + { + ActiveValueLabel.Width = width; + } + #endregion Methods } } diff --git a/grapher/Models/Options/OptionBase.cs b/grapher/Models/Options/OptionBase.cs index 7fb7c0e..d9ca952 100644 --- a/grapher/Models/Options/OptionBase.cs +++ b/grapher/Models/Options/OptionBase.cs @@ -29,6 +29,8 @@ namespace grapher.Models.Options public abstract void Hide(); + public abstract void AlignActiveValues(int width); + public virtual void SnapTo(IOption option) { Top = option.Beneath; diff --git a/grapher/Models/Options/OptionXY.cs b/grapher/Models/Options/OptionXY.cs index c1fd0b7..372bbe9 100644 --- a/grapher/Models/Options/OptionXY.cs +++ b/grapher/Models/Options/OptionXY.cs @@ -77,6 +77,11 @@ namespace grapher ActiveValueLabels.SetValues(x, y); } + public void AlignActiveValues(int width) + { + ActiveValueLabels.AlignActiveValues(width); + } + public void Hide() { Fields.Hide(); |