Add "Mouse selection threshold" option (#141 by Mistranger)

* Mouse selection threshold

* Cleanup

* Fix selection bug
This commit is contained in:
Mistranger 2017-08-24 18:24:03 +05:00 committed by jewalky
parent c9162c6f26
commit 7168ad2095
9 changed files with 86 additions and 34 deletions

View file

@ -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

View file

@ -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

View file

@ -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();

View file

@ -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();

View file

@ -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();

View file

@ -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();

View file

@ -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

View file

@ -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;
}
}

View file

@ -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
}
}