diff options
| author | Jacob Palecki <[email protected]> | 2021-07-01 19:13:12 -0700 |
|---|---|---|
| committer | Jacob Palecki <[email protected]> | 2021-07-01 19:13:12 -0700 |
| commit | ac0a6eb86c8d783c21cb246d688a221913b15789 (patch) | |
| tree | 9b4021b1ab0401191a228dd6539612b2f72ae936 /grapher/Models/Options | |
| parent | Better-written LUT panels (diff) | |
| download | rawaccel-ac0a6eb86c8d783c21cb246d688a221913b15789.tar.xz rawaccel-ac0a6eb86c8d783c21cb246d688a221913b15789.zip | |
Mostly working
Diffstat (limited to 'grapher/Models/Options')
| -rw-r--r-- | grapher/Models/Options/AccelTypeOptions.cs | 14 | ||||
| -rw-r--r-- | grapher/Models/Options/LUT/LUTPanelOptions.cs | 53 | ||||
| -rw-r--r-- | grapher/Models/Options/LUT/LutApplyOptions.cs | 3 | ||||
| -rw-r--r-- | grapher/Models/Options/TextOption.cs | 6 |
4 files changed, 37 insertions, 39 deletions
diff --git a/grapher/Models/Options/AccelTypeOptions.cs b/grapher/Models/Options/AccelTypeOptions.cs index 08ab111..f43d955 100644 --- a/grapher/Models/Options/AccelTypeOptions.cs +++ b/grapher/Models/Options/AccelTypeOptions.cs @@ -166,6 +166,9 @@ namespace grapher set { AccelDropdown.Left = value; + LutText.Left = value; + LutPanel.Left = value; + LutApply.Left = value; } } @@ -178,6 +181,9 @@ namespace grapher set { AccelDropdown.Width = value; + LutText.Width = value; + LutPanel.Width = value; + LutApply.Width = value; } } @@ -239,7 +245,7 @@ namespace grapher Limit.SetActiveValue(args.limit); Exponent.SetActiveValue(args.exponent); Midpoint.SetActiveValue(args.midpoint); - LutPanel.SetActiveValues(args.tableData.points); + LutPanel.SetActiveValues(args.tableData.points, args.tableData.length); LutApply.SetActiveValue(args.tableData.velocity); } @@ -298,6 +304,12 @@ 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 (LutPanel.Visible) + { + (var points, var length) = LutPanel.GetPoints(); + args.tableData.points = points; + args.tableData.length = length; + } if (LutApply.Visible) args.tableData.velocity = LutApply.ApplyType == LutApplyOptions.LutApplyType.Velocity; } diff --git a/grapher/Models/Options/LUT/LUTPanelOptions.cs b/grapher/Models/Options/LUT/LUTPanelOptions.cs index 6425d91..6b13cdc 100644 --- a/grapher/Models/Options/LUT/LUTPanelOptions.cs +++ b/grapher/Models/Options/LUT/LUTPanelOptions.cs @@ -13,17 +13,14 @@ namespace grapher.Models.Options.LUT public const int PanelPadding = 5; public const int PanelHeight = 100; - public LUTPanelOptions(Panel activePanel, RichTextBox pointsTextBox) + public LUTPanelOptions(RichTextBox pointsTextBox, RichTextBox activeValuesTextBox) { PointsTextBox = pointsTextBox; + PointsTextBox.Height = PanelHeight; - ActivePanel = activePanel; - ActivePanel.Height = PanelHeight; - ActivePanel.Paint += Panel_Paint; - - ActiveValuesTextBox = new RichTextBox(); + ActiveValuesTextBox = activeValuesTextBox; + ActiveValuesTextBox.Height = PanelHeight; ActiveValuesTextBox.ReadOnly = true; - ActivePanel.Controls.Add(ActiveValuesTextBox); } public RichTextBox PointsTextBox @@ -36,11 +33,6 @@ namespace grapher.Models.Options.LUT get; } - public Panel ActivePanel - { - get; - } - public override bool Visible { get @@ -58,7 +50,7 @@ namespace grapher.Models.Options.LUT set { PointsTextBox.Top = value; - ActivePanel.Top = value; + ActiveValuesTextBox.Top = value; } } @@ -93,7 +85,7 @@ namespace grapher.Models.Options.LUT { var panelWidth = value / 2 - PanelPadding; PointsTextBox.Width = panelWidth; - ActivePanel.Width = panelWidth; + ActiveValuesTextBox.Width = panelWidth; AlignActivePanelToPointsTextBox(); } } @@ -103,14 +95,14 @@ namespace grapher.Models.Options.LUT public override void Hide() { PointsTextBox.Hide(); - ActivePanel.Hide(); + ActiveValuesTextBox.Hide(); ShouldShow = false; } public override void Show(string name) { PointsTextBox.Show(); - ActivePanel.Show(); + ActiveValuesTextBox.Show(); ShouldShow = true; } @@ -119,11 +111,11 @@ namespace grapher.Models.Options.LUT // Nothing to do here. } - public void SetActiveValues(IEnumerable<Vec2<float>> activePoints) + public void SetActiveValues(IEnumerable<Vec2<float>> activePoints, int length) { - if (activePoints.Any() && activePoints.First().x != 0) + if (length > 0 && activePoints.First().x != 0) { - ActiveValuesTextBox.Text = PointsToActiveValuesText(activePoints); + ActiveValuesTextBox.Text = PointsToActiveValuesText(activePoints, length); } else { @@ -131,12 +123,12 @@ namespace grapher.Models.Options.LUT } } - public Vec2<float>[] GetPoints() + public (Vec2<float>[], int length) GetPoints() { return UserTextToPoints(PointsTextBox.Text); } - private static Vec2<float>[] UserTextToPoints(string userText) + private static (Vec2<float>[], int length) UserTextToPoints(string userText) { if (string.IsNullOrWhiteSpace(userText)) { @@ -145,7 +137,7 @@ namespace grapher.Models.Options.LUT Vec2<float>[] points = new Vec2<float>[256]; - var userTextSplit = userText.Split(';'); + var userTextSplit = userText.Trim().Trim(';').Split(';'); int index = 0; float lastX = 0; @@ -201,32 +193,25 @@ namespace grapher.Models.Options.LUT index++; } - return points; + return (points, userTextSplit.Length); } private void AlignActivePanelToPointsTextBox() { - ActivePanel.Left = PointsTextBox.Right + PanelPadding; + ActiveValuesTextBox.Left = PointsTextBox.Right + PanelPadding; } - private string PointsToActiveValuesText(IEnumerable<Vec2<float>> points) + private string PointsToActiveValuesText(IEnumerable<Vec2<float>> points, int length) { StringBuilder builder = new StringBuilder(); - foreach(var point in points) + for(int i = 0; i < length; i++) { + var point = points.ElementAt(i); builder.AppendLine($"{point.x},{point.y};"); } return builder.ToString(); } - - private void Panel_Paint(object sender, PaintEventArgs e) - { - Color col = Color.DarkGray; - ButtonBorderStyle bbs = ButtonBorderStyle.Dashed; - int thickness = 2; - ControlPaint.DrawBorder(e.Graphics, ActivePanel.ClientRectangle, col, thickness, bbs, col, thickness, bbs, col, thickness, bbs, col, thickness, bbs); - } } } diff --git a/grapher/Models/Options/LUT/LutApplyOptions.cs b/grapher/Models/Options/LUT/LutApplyOptions.cs index 6ea7412..f71c1e2 100644 --- a/grapher/Models/Options/LUT/LutApplyOptions.cs +++ b/grapher/Models/Options/LUT/LutApplyOptions.cs @@ -22,6 +22,8 @@ namespace grapher.Models.Options.LUT public LutApplyType Type { get; set; } public string Name => Type.ToString(); + + public override string ToString() => Name; } public static readonly LutApplyOption Sensitivity = new LutApplyOption @@ -50,6 +52,7 @@ namespace grapher.Models.Options.LUT Label = label; Label.Text = LUTApplyOptionsLabelText; + Label.Width = 45; ActiveValueLabel = lutApplyActiveValue; } diff --git a/grapher/Models/Options/TextOption.cs b/grapher/Models/Options/TextOption.cs index 3c6f378..83a72df 100644 --- a/grapher/Models/Options/TextOption.cs +++ b/grapher/Models/Options/TextOption.cs @@ -14,9 +14,7 @@ namespace grapher.Models.Options public TextOption(Label label) { Label = label; - Label.AutoSize = false; - Label.Width = 150; - Label.Height = 100; + Label.AutoSize = true; } #endregion Constructors @@ -61,7 +59,7 @@ namespace grapher.Models.Options } set { - Label.Width = value; + Label.MaximumSize = new System.Drawing.Size(value, 0); } } |