From 7168ad209515e759292a9764d0e075a782429578 Mon Sep 17 00:00:00 2001 From: Mistranger Date: Thu, 24 Aug 2017 18:24:03 +0500 Subject: [PATCH] Add "Mouse selection threshold" option (#141 by Mistranger) * Mouse selection threshold * Cleanup * Fix selection bug --- Source/Core/Editing/ClassicMode.cs | 2 +- .../ClassicModes/BaseClassicMode.cs | 6 -- .../BuilderModes/ClassicModes/LinedefsMode.cs | 4 +- .../BuilderModes/ClassicModes/SectorsMode.cs | 4 +- .../BuilderModes/ClassicModes/ThingsMode.cs | 4 +- .../BuilderModes/ClassicModes/VerticesMode.cs | 4 +- .../BuilderModes/General/BuilderPlug.cs | 3 + .../Interface/PreferencesForm.Designer.cs | 90 +++++++++++++++---- .../BuilderModes/Interface/PreferencesForm.cs | 3 + 9 files changed, 86 insertions(+), 34 deletions(-) diff --git a/Source/Core/Editing/ClassicMode.cs b/Source/Core/Editing/ClassicMode.cs index 433dff3e..7d84b141 100755 --- a/Source/Core/Editing/ClassicMode.cs +++ b/Source/Core/Editing/ClassicMode.cs @@ -826,7 +826,7 @@ namespace CodeImp.DoomBuilder.Editing protected virtual void StartMultiSelection() { selecting = true; - selectstart = mousemappos; + selectstart = mousedownmappos; selectionrect = new RectangleF(selectstart.x, selectstart.y, 0, 0); //mxd diff --git a/Source/Plugins/BuilderModes/ClassicModes/BaseClassicMode.cs b/Source/Plugins/BuilderModes/ClassicModes/BaseClassicMode.cs index 6d43e4e9..cd384933 100755 --- a/Source/Plugins/BuilderModes/ClassicModes/BaseClassicMode.cs +++ b/Source/Plugins/BuilderModes/ClassicModes/BaseClassicMode.cs @@ -32,12 +32,6 @@ namespace CodeImp.DoomBuilder.BuilderModes { public abstract class BaseClassicMode : ClassicMode { - #region ================== Constants - - protected const int MULTISELECT_START_MOVE_PIXELS = 2; //mxd - - #endregion - #region ================== Variables protected bool paintselectpressed; //mxd diff --git a/Source/Plugins/BuilderModes/ClassicModes/LinedefsMode.cs b/Source/Plugins/BuilderModes/ClassicModes/LinedefsMode.cs index bdffca31..ed73ad8b 100755 --- a/Source/Plugins/BuilderModes/ClassicModes/LinedefsMode.cs +++ b/Source/Plugins/BuilderModes/ClassicModes/LinedefsMode.cs @@ -878,8 +878,8 @@ namespace CodeImp.DoomBuilder.BuilderModes { // Check if moved enough pixels for multiselect Vector2D delta = mousedownpos - mousepos; - if((Math.Abs(delta.x) > MULTISELECT_START_MOVE_PIXELS) || - (Math.Abs(delta.y) > MULTISELECT_START_MOVE_PIXELS)) + if((Math.Abs(delta.x) > BuilderPlug.Me.MouseSelectionThreshold) || + (Math.Abs(delta.y) > BuilderPlug.Me.MouseSelectionThreshold)) { // Start multiselecting StartMultiSelection(); diff --git a/Source/Plugins/BuilderModes/ClassicModes/SectorsMode.cs b/Source/Plugins/BuilderModes/ClassicModes/SectorsMode.cs index 6a8d6c7e..4cb3b7a6 100755 --- a/Source/Plugins/BuilderModes/ClassicModes/SectorsMode.cs +++ b/Source/Plugins/BuilderModes/ClassicModes/SectorsMode.cs @@ -1036,8 +1036,8 @@ namespace CodeImp.DoomBuilder.BuilderModes { // Check if moved enough pixels for multiselect Vector2D delta = mousedownpos - mousepos; - if((Math.Abs(delta.x) > MULTISELECT_START_MOVE_PIXELS) || - (Math.Abs(delta.y) > MULTISELECT_START_MOVE_PIXELS)) + if((Math.Abs(delta.x) > BuilderPlug.Me.MouseSelectionThreshold) || + (Math.Abs(delta.y) > BuilderPlug.Me.MouseSelectionThreshold)) { // Start multiselecting StartMultiSelection(); diff --git a/Source/Plugins/BuilderModes/ClassicModes/ThingsMode.cs b/Source/Plugins/BuilderModes/ClassicModes/ThingsMode.cs index 7f6dfbda..3094be88 100755 --- a/Source/Plugins/BuilderModes/ClassicModes/ThingsMode.cs +++ b/Source/Plugins/BuilderModes/ClassicModes/ThingsMode.cs @@ -653,8 +653,8 @@ namespace CodeImp.DoomBuilder.BuilderModes { // Check if moved enough pixels for multiselect Vector2D delta = mousedownpos - mousepos; - if((Math.Abs(delta.x) > MULTISELECT_START_MOVE_PIXELS) || - (Math.Abs(delta.y) > MULTISELECT_START_MOVE_PIXELS)) + if((Math.Abs(delta.x) > BuilderPlug.Me.MouseSelectionThreshold) || + (Math.Abs(delta.y) > BuilderPlug.Me.MouseSelectionThreshold)) { // Start multiselecting StartMultiSelection(); diff --git a/Source/Plugins/BuilderModes/ClassicModes/VerticesMode.cs b/Source/Plugins/BuilderModes/ClassicModes/VerticesMode.cs index 57002767..2db52bf4 100755 --- a/Source/Plugins/BuilderModes/ClassicModes/VerticesMode.cs +++ b/Source/Plugins/BuilderModes/ClassicModes/VerticesMode.cs @@ -422,8 +422,8 @@ namespace CodeImp.DoomBuilder.BuilderModes { // Check if moved enough pixels for multiselect Vector2D delta = mousedownpos - mousepos; - if((Math.Abs(delta.x) > MULTISELECT_START_MOVE_PIXELS) || - (Math.Abs(delta.y) > MULTISELECT_START_MOVE_PIXELS)) + if((Math.Abs(delta.x) > BuilderPlug.Me.MouseSelectionThreshold) || + (Math.Abs(delta.y) > BuilderPlug.Me.MouseSelectionThreshold)) { // Start multiselecting StartMultiSelection(); diff --git a/Source/Plugins/BuilderModes/General/BuilderPlug.cs b/Source/Plugins/BuilderModes/General/BuilderPlug.cs index 29db8a75..ff12ca66 100755 --- a/Source/Plugins/BuilderModes/General/BuilderPlug.cs +++ b/Source/Plugins/BuilderModes/General/BuilderPlug.cs @@ -122,6 +122,7 @@ namespace CodeImp.DoomBuilder.BuilderModes private float highlightrange; private float highlightthingsrange; private float splitlinedefsrange; + private float mouseselectionthreshold; private bool autodragonpaste; private bool autoAlignTextureOffsetsOnCreate;//mxd private bool dontMoveGeometryOutsideMapBoundary;//mxd @@ -173,6 +174,7 @@ namespace CodeImp.DoomBuilder.BuilderModes public float HighlightRange { get { return highlightrange; } } public float HighlightThingsRange { get { return highlightthingsrange; } } public float SplitLinedefsRange { get { return splitlinedefsrange; } } + public float MouseSelectionThreshold { get { return mouseselectionthreshold; } } public bool AutoDragOnPaste { get { return autodragonpaste; } set { autodragonpaste = value; } } public bool AutoDrawOnEdit { get { return autoDrawOnEdit; } set { autoDrawOnEdit = value; } } //mxd public bool AutoAlignTextureOffsetsOnCreate { get { return autoAlignTextureOffsetsOnCreate; } set { autoAlignTextureOffsetsOnCreate = value; } } //mxd @@ -279,6 +281,7 @@ namespace CodeImp.DoomBuilder.BuilderModes highlightrange = General.Settings.ReadPluginSetting("highlightrange", 20); highlightthingsrange = General.Settings.ReadPluginSetting("highlightthingsrange", 10); splitlinedefsrange = General.Settings.ReadPluginSetting("splitlinedefsrange", 10); + mouseselectionthreshold = General.Settings.ReadPluginSetting("mouseselectionthreshold", 2); autodragonpaste = General.Settings.ReadPluginSetting("autodragonpaste", false); autoDrawOnEdit = General.Settings.ReadPluginSetting("autodrawonedit", true); //mxd autoAlignTextureOffsetsOnCreate = General.Settings.ReadPluginSetting("autoaligntextureoffsetsoncreate", false); //mxd diff --git a/Source/Plugins/BuilderModes/Interface/PreferencesForm.Designer.cs b/Source/Plugins/BuilderModes/Interface/PreferencesForm.Designer.cs index 5d7ef9e9..c4377e48 100755 --- a/Source/Plugins/BuilderModes/Interface/PreferencesForm.Designer.cs +++ b/Source/Plugins/BuilderModes/Interface/PreferencesForm.Designer.cs @@ -40,6 +40,7 @@ namespace CodeImp.DoomBuilder.BuilderModes this.defaultbrightness = new CodeImp.DoomBuilder.Controls.ButtonsNumericTextbox(); this.label11 = new System.Windows.Forms.Label(); this.groupBox3 = new System.Windows.Forms.GroupBox(); + this.switchviewmodes = new System.Windows.Forms.CheckBox(); this.autodrawonedit = new System.Windows.Forms.CheckBox(); this.syncSelection = new System.Windows.Forms.CheckBox(); this.dontMoveGeometryOutsideBounds = new System.Windows.Forms.CheckBox(); @@ -51,6 +52,9 @@ namespace CodeImp.DoomBuilder.BuilderModes this.editnewsector = new System.Windows.Forms.CheckBox(); this.additiveselect = new System.Windows.Forms.CheckBox(); this.groupBox2 = new System.Windows.Forms.GroupBox(); + this.mouseselectionthreshold = new CodeImp.DoomBuilder.Controls.ButtonsNumericTextbox(); + this.label16 = new System.Windows.Forms.Label(); + this.label17 = new System.Windows.Forms.Label(); this.splitlinedefsrange = new CodeImp.DoomBuilder.Controls.ButtonsNumericTextbox(); this.stitchrange = new CodeImp.DoomBuilder.Controls.ButtonsNumericTextbox(); this.highlightthingsrange = new CodeImp.DoomBuilder.Controls.ButtonsNumericTextbox(); @@ -68,7 +72,6 @@ namespace CodeImp.DoomBuilder.BuilderModes this.label10 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label(); this.heightbysidedef = new System.Windows.Forms.ComboBox(); - this.switchviewmodes = new System.Windows.Forms.CheckBox(); this.tabs.SuspendLayout(); this.taboptions.SuspendLayout(); this.groupBox4.SuspendLayout(); @@ -79,9 +82,9 @@ namespace CodeImp.DoomBuilder.BuilderModes // // tabs // - this.tabs.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); + this.tabs.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); this.tabs.Controls.Add(this.taboptions); this.tabs.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(204))); this.tabs.Location = new System.Drawing.Point(12, 12); @@ -116,9 +119,9 @@ namespace CodeImp.DoomBuilder.BuilderModes this.groupBox4.Controls.Add(this.label12); this.groupBox4.Controls.Add(this.defaultbrightness); this.groupBox4.Controls.Add(this.label11); - this.groupBox4.Location = new System.Drawing.Point(6, 261); + this.groupBox4.Location = new System.Drawing.Point(6, 300); this.groupBox4.Name = "groupBox4"; - this.groupBox4.Size = new System.Drawing.Size(272, 160); + this.groupBox4.Size = new System.Drawing.Size(272, 122); this.groupBox4.TabIndex = 2; this.groupBox4.TabStop = false; this.groupBox4.Text = " Default sector settings"; @@ -144,6 +147,7 @@ namespace CodeImp.DoomBuilder.BuilderModes // defaultfloorheight // this.defaultfloorheight.AllowDecimal = false; + this.defaultfloorheight.AllowExpressions = false; this.defaultfloorheight.AllowNegative = true; this.defaultfloorheight.AllowRelative = false; this.defaultfloorheight.ButtonStep = 5; @@ -170,6 +174,7 @@ namespace CodeImp.DoomBuilder.BuilderModes // defaultceilheight // this.defaultceilheight.AllowDecimal = false; + this.defaultceilheight.AllowExpressions = false; this.defaultceilheight.AllowNegative = true; this.defaultceilheight.AllowRelative = false; this.defaultceilheight.ButtonStep = 5; @@ -196,6 +201,7 @@ namespace CodeImp.DoomBuilder.BuilderModes // defaultbrightness // this.defaultbrightness.AllowDecimal = false; + this.defaultbrightness.AllowExpressions = false; this.defaultbrightness.AllowNegative = false; this.defaultbrightness.AllowRelative = false; this.defaultbrightness.ButtonStep = 5; @@ -239,6 +245,16 @@ namespace CodeImp.DoomBuilder.BuilderModes this.groupBox3.TabStop = false; this.groupBox3.Text = " Options "; // + // switchviewmodes + // + this.switchviewmodes.AutoSize = true; + this.switchviewmodes.Location = new System.Drawing.Point(13, 287); + this.switchviewmodes.Name = "switchviewmodes"; + this.switchviewmodes.Size = new System.Drawing.Size(317, 17); + this.switchviewmodes.TabIndex = 10; + this.switchviewmodes.Text = "Switch view modes when switching to the same Classic Mode"; + this.switchviewmodes.UseVisualStyleBackColor = true; + // // autodrawonedit // this.autodrawonedit.AutoSize = true; @@ -247,7 +263,7 @@ namespace CodeImp.DoomBuilder.BuilderModes this.autodrawonedit.Size = new System.Drawing.Size(353, 30); this.autodrawonedit.TabIndex = 0; this.autodrawonedit.Text = "Start drawing when Edit pressed over empty space in Classic modes\r\nInsert new thi" + - "ng when Edit pressed over empty space in Things mode"; + "ng when Edit pressed over empty space in Things mode"; this.autodrawonedit.UseVisualStyleBackColor = true; // // syncSelection @@ -342,6 +358,9 @@ namespace CodeImp.DoomBuilder.BuilderModes // // groupBox2 // + this.groupBox2.Controls.Add(this.mouseselectionthreshold); + this.groupBox2.Controls.Add(this.label16); + this.groupBox2.Controls.Add(this.label17); this.groupBox2.Controls.Add(this.splitlinedefsrange); this.groupBox2.Controls.Add(this.stitchrange); this.groupBox2.Controls.Add(this.highlightthingsrange); @@ -356,14 +375,52 @@ namespace CodeImp.DoomBuilder.BuilderModes this.groupBox2.Controls.Add(this.label7); this.groupBox2.Location = new System.Drawing.Point(6, 104); this.groupBox2.Name = "groupBox2"; - this.groupBox2.Size = new System.Drawing.Size(272, 151); + this.groupBox2.Size = new System.Drawing.Size(272, 190); this.groupBox2.TabIndex = 1; this.groupBox2.TabStop = false; this.groupBox2.Text = " Ranges "; // + // mouseselectionthreshold + // + this.mouseselectionthreshold.AllowDecimal = false; + this.mouseselectionthreshold.AllowExpressions = false; + this.mouseselectionthreshold.AllowNegative = false; + this.mouseselectionthreshold.AllowRelative = false; + this.mouseselectionthreshold.ButtonStep = 5; + this.mouseselectionthreshold.ButtonStepBig = 10F; + this.mouseselectionthreshold.ButtonStepFloat = 1F; + this.mouseselectionthreshold.ButtonStepSmall = 0.1F; + this.mouseselectionthreshold.ButtonStepsUseModifierKeys = false; + this.mouseselectionthreshold.ButtonStepsWrapAround = false; + this.mouseselectionthreshold.Location = new System.Drawing.Point(156, 141); + this.mouseselectionthreshold.Name = "mouseselectionthreshold"; + this.mouseselectionthreshold.Size = new System.Drawing.Size(59, 24); + this.mouseselectionthreshold.StepValues = null; + this.mouseselectionthreshold.TabIndex = 16; + // + // label16 + // + this.label16.AutoSize = true; + this.label16.Location = new System.Drawing.Point(221, 146); + this.label16.Name = "label16"; + this.label16.Size = new System.Drawing.Size(33, 13); + this.label16.TabIndex = 18; + this.label16.Text = "pixels"; + // + // label17 + // + this.label17.AutoSize = true; + this.label17.Location = new System.Drawing.Point(13, 146); + this.label17.Name = "label17"; + this.label17.Size = new System.Drawing.Size(133, 13); + this.label17.TabIndex = 17; + this.label17.Text = "Mouse selection threshold:"; + this.label17.TextAlign = System.Drawing.ContentAlignment.TopRight; + // // splitlinedefsrange // this.splitlinedefsrange.AllowDecimal = false; + this.splitlinedefsrange.AllowExpressions = false; this.splitlinedefsrange.AllowNegative = false; this.splitlinedefsrange.AllowRelative = false; this.splitlinedefsrange.ButtonStep = 5; @@ -381,6 +438,7 @@ namespace CodeImp.DoomBuilder.BuilderModes // stitchrange // this.stitchrange.AllowDecimal = false; + this.stitchrange.AllowExpressions = false; this.stitchrange.AllowNegative = false; this.stitchrange.AllowRelative = false; this.stitchrange.ButtonStep = 5; @@ -398,6 +456,7 @@ namespace CodeImp.DoomBuilder.BuilderModes // highlightthingsrange // this.highlightthingsrange.AllowDecimal = false; + this.highlightthingsrange.AllowExpressions = false; this.highlightthingsrange.AllowNegative = false; this.highlightthingsrange.AllowRelative = false; this.highlightthingsrange.ButtonStep = 5; @@ -415,6 +474,7 @@ namespace CodeImp.DoomBuilder.BuilderModes // highlightrange // this.highlightrange.AllowDecimal = false; + this.highlightrange.AllowExpressions = false; this.highlightrange.AllowNegative = false; this.highlightrange.AllowRelative = false; this.highlightrange.ButtonStep = 5; @@ -566,16 +626,6 @@ namespace CodeImp.DoomBuilder.BuilderModes this.heightbysidedef.Size = new System.Drawing.Size(309, 21); this.heightbysidedef.TabIndex = 0; // - // switchviewmodes - // - this.switchviewmodes.AutoSize = true; - this.switchviewmodes.Location = new System.Drawing.Point(13, 287); - this.switchviewmodes.Name = "switchviewmodes"; - this.switchviewmodes.Size = new System.Drawing.Size(317, 17); - this.switchviewmodes.TabIndex = 10; - this.switchviewmodes.Text = "Switch view modes when switching to the same Classic Mode"; - this.switchviewmodes.UseVisualStyleBackColor = true; - // // PreferencesForm // this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F); @@ -585,7 +635,6 @@ namespace CodeImp.DoomBuilder.BuilderModes this.MaximizeBox = false; this.MinimizeBox = false; this.Name = "PreferencesForm"; - this.Opacity = 1; this.ShowIcon = false; this.Text = "PreferencesForm"; this.tabs.ResumeLayout(false); @@ -645,5 +694,8 @@ namespace CodeImp.DoomBuilder.BuilderModes private System.Windows.Forms.Label label14; private System.Windows.Forms.CheckBox autodrawonedit; private System.Windows.Forms.CheckBox switchviewmodes; + private Controls.ButtonsNumericTextbox mouseselectionthreshold; + private System.Windows.Forms.Label label16; + private System.Windows.Forms.Label label17; } } \ No newline at end of file diff --git a/Source/Plugins/BuilderModes/Interface/PreferencesForm.cs b/Source/Plugins/BuilderModes/Interface/PreferencesForm.cs index 08719e2e..e08fa8a3 100755 --- a/Source/Plugins/BuilderModes/Interface/PreferencesForm.cs +++ b/Source/Plugins/BuilderModes/Interface/PreferencesForm.cs @@ -50,6 +50,7 @@ namespace CodeImp.DoomBuilder.BuilderModes highlightrange.Text = General.Settings.ReadPluginSetting("highlightrange", 20).ToString(); highlightthingsrange.Text = General.Settings.ReadPluginSetting("highlightthingsrange", 10).ToString(); splitlinedefsrange.Text = General.Settings.ReadPluginSetting("splitlinedefsrange", 10).ToString(); + mouseselectionthreshold.Text = General.Settings.ReadPluginSetting("mouseselectionthreshold", 2).ToString(); splitbehavior.SelectedIndex = (int)General.Settings.SplitLineBehavior; //mxd autoclearselection.Checked = BuilderPlug.Me.AutoClearSelection; visualmodeclearselection.Checked = BuilderPlug.Me.VisualModeClearSelection; @@ -80,6 +81,7 @@ namespace CodeImp.DoomBuilder.BuilderModes General.Settings.WritePluginSetting("highlightrange", highlightrange.GetResult(0)); General.Settings.WritePluginSetting("highlightthingsrange", highlightthingsrange.GetResult(0)); General.Settings.WritePluginSetting("splitlinedefsrange", splitlinedefsrange.GetResult(0)); + General.Settings.WritePluginSetting("mouseselectionthreshold", mouseselectionthreshold.GetResult(0)); General.Settings.WritePluginSetting("autoclearselection", autoclearselection.Checked); General.Settings.WritePluginSetting("visualmodeclearselection", visualmodeclearselection.Checked); General.Settings.WritePluginSetting("autodragonpaste", autodragonpaste.Checked); @@ -125,5 +127,6 @@ namespace CodeImp.DoomBuilder.BuilderModes } #endregion + } } \ No newline at end of file