diff options
| author | Jacob Palecki <[email protected]> | 2020-09-07 19:13:30 -0700 |
|---|---|---|
| committer | Jacob Palecki <[email protected]> | 2020-09-07 19:13:30 -0700 |
| commit | 0fb1013f66026c696fec6469c02aba1c91711289 (patch) | |
| tree | 5a8a93de6c372195504bf17156f106835cc3a6b7 | |
| parent | Refactor type options (diff) | |
| download | rawaccel-0fb1013f66026c696fec6469c02aba1c91711289.tar.xz rawaccel-0fb1013f66026c696fec6469c02aba1c91711289.zip | |
Fix some separation bugs
| -rw-r--r-- | grapher/Constants/Constants.cs | 51 | ||||
| -rw-r--r-- | grapher/Models/Options/AccelTypeOptions.cs | 39 | ||||
| -rw-r--r-- | grapher/Models/Options/CapOptions.cs | 4 | ||||
| -rw-r--r-- | grapher/Models/Options/IOption.cs | 2 | ||||
| -rw-r--r-- | grapher/Models/Options/OffsetOptions.cs | 4 | ||||
| -rw-r--r-- | grapher/Models/Options/Option.cs | 4 | ||||
| -rw-r--r-- | grapher/Models/Options/OptionBase.cs | 11 |
7 files changed, 73 insertions, 42 deletions
diff --git a/grapher/Constants/Constants.cs b/grapher/Constants/Constants.cs index 3d19b21..c7ca617 100644 --- a/grapher/Constants/Constants.cs +++ b/grapher/Constants/Constants.cs @@ -11,18 +11,6 @@ namespace grapher { #region Constants - /// <summary> Vertical separation between charts, in pixels. </summary> - public const int ChartSeparationVertical = 10; - - /// <summary> Default name of settings file. </summary> - public const string DefaultSettingsFileName = @"settings.json"; - - /// <summary> Needed to show full contents in form. Unsure why. </summary> - public const int FormHeightPadding = 35; - - /// <summary> Format string for gain cap active value label. </summary> - public const string GainCapFormatString = "0.##"; - /// <summary> DPI by which charts are scaled if none is set by user. </summary> public const int DefaultDPI = 1200; @@ -38,23 +26,17 @@ namespace grapher /// <summary> Ratio of max (X, Y) used in "by component" calulations to those used in "whole vector" calculations. </summary> public const double XYToCombinedRatio = 1.4; + /// <summary> Possible options to display in a layout. </summary> + public const int PossibleOptionsCount = 6; + /// <summary> Separation between X and Y active value labels, in pixels. </summary> public const int ActiveLabelXYSeparation = 2; - /// <summary> Format string for shortened x and y textboxes. </summary> - public const string ShortenedFormatString = "0.###"; - - /// <summary> Format string for default active value labels. </summary> - public const string DefaultActiveValueFormatString = "0.######"; - - /// <summary> Format string for default textboxes. </summary> - public const string DefaultFieldFormatString = "0.#########"; - - /// <summary> Possible options to display in a layout. </summary> - public const int PossibleOptionsCount = 6; + /// <summary> Vertical separation between charts, in pixels. </summary> + public const int ChartSeparationVertical = 10; - /// <summary> Possible x/y options to display in a layout. </summary> - public const int PossibleOptionsXYCount = 0; + /// <summary> Needed to show full contents in form. Unsure why. </summary> + public const int FormHeightPadding = 35; /// <summary> Horizontal separation between charts, in pixels. </summary> public const int ChartSeparationHorizontal = 10; @@ -68,14 +50,33 @@ namespace grapher /// <summary> Default horizontal separation between an option's label and box, in pixels. </summary> public const int OptionVerticalSeperation = 4; + /// <summary> Horizonatl separation between left side of single dropdown and left side of labels beneath dropdown </summary> + public const int DropDownLeftSeparation = 10; + + /// <summary> Format string for shortened x and y textboxes. </summary> + public const string ShortenedFormatString = "0.###"; + + /// <summary> Format string for default active value labels. </summary> + public const string DefaultActiveValueFormatString = "0.######"; + + /// <summary> Format string for default textboxes. </summary> + public const string DefaultFieldFormatString = "0.#########"; + /// <summary> Format string for shortened x and y fields. </summary> public const string ShortenedFieldFormatString = "0.###"; + /// <summary> Format string for gain cap active value label. </summary> + public const string GainCapFormatString = "0.##"; + /// <summary> Format string for shortened x and y dropdowns. </summary> public const string AccelDropDownDefaultFullText = "Acceleration Type"; /// <summary> Format string for default dropdowns. </summary> public const string AccelDropDownDefaultShortText = "Accel Type"; + + /// <summary> Default name of settings file. </summary> + public const string DefaultSettingsFileName = @"settings.json"; + #endregion Constants #region ReadOnly diff --git a/grapher/Models/Options/AccelTypeOptions.cs b/grapher/Models/Options/AccelTypeOptions.cs index 878c955..a5ed474 100644 --- a/grapher/Models/Options/AccelTypeOptions.cs +++ b/grapher/Models/Options/AccelTypeOptions.cs @@ -10,7 +10,7 @@ using System.Windows.Forms; namespace grapher { - public class AccelTypeOptions + public class AccelTypeOptions : OptionBase { #region Fields @@ -102,7 +102,7 @@ namespace grapher private IEnumerable<OptionBase> Options { get; } - public int Top + public override int Top { get { @@ -115,19 +115,15 @@ namespace grapher } } - public int Height + public override int Height { get { return AccelDropdown.Height; } - set - { - AccelDropdown.Height = value; - } } - public int Left + public override int Left { get { @@ -139,7 +135,7 @@ namespace grapher } } - public int Width + public override int Width { get { @@ -151,13 +147,21 @@ namespace grapher } } + public override bool Visible + { + get + { + return AccelDropdown.Visible; + } + } + private bool ShowingDefault { get; set; } #endregion Properties #region Methods - public void Hide() + public override void Hide() { AccelDropdown.Hide(); @@ -175,6 +179,11 @@ namespace grapher Layout(); } + public override void Show(string name) + { + Show(); + } + public void SetActiveValues(int index, AccelArgs args) { var name = AccelerationTypes.Where(t => t.Value.Index == index).FirstOrDefault().Value.Name; @@ -195,8 +204,8 @@ namespace grapher AccelDropdown.Text = Constants.AccelDropDownDefaultFullText; } - Left = Acceleration.Left; - Width = Acceleration.Width; + Left = Acceleration.Left + Constants.DropDownLeftSeparation; + Width = Acceleration.Width - Constants.DropDownLeftSeparation; } public void ShowShortened() @@ -236,14 +245,14 @@ namespace grapher private void OnIndexChanged(object sender, EventArgs e) { var accelerationTypeString = AccelDropdown.SelectedItem.ToString(); - Layout(accelerationTypeString); + Layout(accelerationTypeString, Beneath); ShowingDefault = false; } - private void Layout(string type) + private void Layout(string type, int top = -1) { AccelerationType = AccelerationTypes[type]; - Layout(); + Layout(top); } private void Layout(int top = -1) diff --git a/grapher/Models/Options/CapOptions.cs b/grapher/Models/Options/CapOptions.cs index cf587c7..a44b536 100644 --- a/grapher/Models/Options/CapOptions.cs +++ b/grapher/Models/Options/CapOptions.cs @@ -114,6 +114,10 @@ namespace grapher { return CapOption.Width; } + set + { + CapOption.Width = value; + } } public override bool Visible diff --git a/grapher/Models/Options/IOption.cs b/grapher/Models/Options/IOption.cs index 71ac5e4..b387971 100644 --- a/grapher/Models/Options/IOption.cs +++ b/grapher/Models/Options/IOption.cs @@ -15,6 +15,8 @@ namespace grapher.Models.Options int Left { get; } int Width { get; } + + int Beneath { get; } bool Visible { get; } diff --git a/grapher/Models/Options/OffsetOptions.cs b/grapher/Models/Options/OffsetOptions.cs index fbc6898..ffcb862 100644 --- a/grapher/Models/Options/OffsetOptions.cs +++ b/grapher/Models/Options/OffsetOptions.cs @@ -103,6 +103,10 @@ namespace grapher.Models.Options { return OffsetOption.Width; } + set + { + OffsetOption.Width = value; + } } public override bool Visible diff --git a/grapher/Models/Options/Option.cs b/grapher/Models/Options/Option.cs index 68ecf66..5355a8a 100644 --- a/grapher/Models/Options/Option.cs +++ b/grapher/Models/Options/Option.cs @@ -110,6 +110,10 @@ namespace grapher { return Field.Left + Field.Width - Label.Left; } + set + { + Field.Width = value; + } } public override bool Visible diff --git a/grapher/Models/Options/OptionBase.cs b/grapher/Models/Options/OptionBase.cs index 9fba72f..7fb7c0e 100644 --- a/grapher/Models/Options/OptionBase.cs +++ b/grapher/Models/Options/OptionBase.cs @@ -14,7 +14,14 @@ namespace grapher.Models.Options public abstract int Left { get; set; } - public abstract int Width { get; } + public abstract int Width { get; set; } + + public int Beneath { + get + { + return Top + Height + Constants.OptionVerticalSeperation; + } + } public abstract bool Visible { get; } @@ -24,7 +31,7 @@ namespace grapher.Models.Options public virtual void SnapTo(IOption option) { - Top = option.Top + option.Height + Constants.OptionVerticalSeperation; + Top = option.Beneath; } } } |