control extension to center the new dialog on mouse pointer
This commit is contained in:
parent
2211a4186f
commit
28757bd8be
|
@ -79,6 +79,14 @@ namespace BizHawk.Client.EmuHawk
|
||||||
return control.PointToScreen(new Point(child.Location.X, child.Location.Y));
|
return control.PointToScreen(new Point(child.Location.X, child.Location.Y));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void FollowMousePointer(this Form form)
|
||||||
|
{
|
||||||
|
var point = Cursor.Position;
|
||||||
|
point.Offset(form.Width / -2, form.Height / -2);
|
||||||
|
form.StartPosition = FormStartPosition.Manual;
|
||||||
|
form.Location = point;
|
||||||
|
}
|
||||||
|
|
||||||
public static DialogResult ShowDialogOnScreen(this Form form)
|
public static DialogResult ShowDialogOnScreen(this Form form)
|
||||||
{
|
{
|
||||||
var topLeft = new Point(
|
var topLeft = new Point(
|
||||||
|
|
|
@ -569,12 +569,8 @@ namespace BizHawk.Client.EmuHawk
|
||||||
InitialValue = branch.UserText
|
InitialValue = branch.UserText
|
||||||
};
|
};
|
||||||
|
|
||||||
var point = Cursor.Position;
|
i.FollowMousePointer();
|
||||||
point.Offset(i.Width / -2, i.Height / -2);
|
if (i.ShowDialogOnScreen().IsOk())
|
||||||
i.StartPosition = FormStartPosition.Manual;
|
|
||||||
i.Location = point;
|
|
||||||
|
|
||||||
if (this.ShowDialogWithTempMute(i).IsOk())
|
|
||||||
{
|
{
|
||||||
branch.UserText = i.PromptText;
|
branch.UserText = i.PromptText;
|
||||||
UpdateTextColumnWidth();
|
UpdateTextColumnWidth();
|
||||||
|
|
|
@ -175,12 +175,8 @@ namespace BizHawk.Client.EmuHawk
|
||||||
""
|
""
|
||||||
};
|
};
|
||||||
|
|
||||||
var point = Cursor.Position;
|
i.FollowMousePointer();
|
||||||
point.Offset(i.Width / -2, i.Height / -2);
|
if (!i.ShowDialogOnScreen().IsOk()) return;
|
||||||
i.StartPosition = FormStartPosition.Manual;
|
|
||||||
i.Location = point;
|
|
||||||
|
|
||||||
if (!this.ShowDialogWithTempMute(i).IsOk()) return;
|
|
||||||
|
|
||||||
UpdateTextColumnWidth();
|
UpdateTextColumnWidth();
|
||||||
marker = new TasMovieMarker(frame, i.PromptText);
|
marker = new TasMovieMarker(frame, i.PromptText);
|
||||||
|
@ -210,7 +206,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void EditMarkerPopUp(TasMovieMarker marker, bool followCursor = false)
|
public void EditMarkerPopUp(TasMovieMarker marker)
|
||||||
{
|
{
|
||||||
var markerFrame = marker.Frame;
|
var markerFrame = marker.Frame;
|
||||||
var i = new InputPrompt
|
var i = new InputPrompt
|
||||||
|
@ -224,15 +220,8 @@ namespace BizHawk.Client.EmuHawk
|
||||||
: ""
|
: ""
|
||||||
};
|
};
|
||||||
|
|
||||||
if (followCursor)
|
i.FollowMousePointer();
|
||||||
{
|
if (!i.ShowDialogOnScreen().IsOk()) return;
|
||||||
var point = Cursor.Position;
|
|
||||||
point.Offset(i.Width / -2, i.Height / -2);
|
|
||||||
i.StartPosition = FormStartPosition.Manual;
|
|
||||||
i.Location = point;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!this.ShowDialogWithTempMute(i).IsOk()) return;
|
|
||||||
|
|
||||||
marker.Message = i.PromptText;
|
marker.Message = i.PromptText;
|
||||||
UpdateTextColumnWidth();
|
UpdateTextColumnWidth();
|
||||||
|
@ -252,7 +241,8 @@ namespace BizHawk.Client.EmuHawk
|
||||||
: "0",
|
: "0",
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!this.ShowDialogWithTempMute(i).IsOk()
|
i.FollowMousePointer();
|
||||||
|
if (!i.ShowDialogOnScreen().IsOk()
|
||||||
|| !int.TryParse(i.PromptText, out var promptValue)
|
|| !int.TryParse(i.PromptText, out var promptValue)
|
||||||
|| Markers.IsMarker(promptValue)) // don't move to frame with an existing marker
|
|| Markers.IsMarker(promptValue)) // don't move to frame with an existing marker
|
||||||
{
|
{
|
||||||
|
|
|
@ -903,7 +903,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
if (existingMarker != null)
|
if (existingMarker != null)
|
||||||
{
|
{
|
||||||
MarkerControl.EditMarkerPopUp(existingMarker, true);
|
MarkerControl.EditMarkerPopUp(existingMarker);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue