Allow greater range in set position and possible fix linux issue #7530

This commit is contained in:
niksedk 2023-10-21 07:11:57 +02:00
parent 9600a761fc
commit 75d4ab98f0
2 changed files with 118 additions and 21 deletions

View File

@ -56,6 +56,7 @@ namespace Nikse.SubtitleEdit.Forms.Assa
this.numericUpDownDistortY = new Nikse.SubtitleEdit.Controls.NikseUpDown();
this.groupBoxApplyTo.SuspendLayout();
this.groupBoxPreview.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxPreview)).BeginInit();
this.panelAdvanced.SuspendLayout();
this.SuspendLayout();
//
@ -115,7 +116,6 @@ namespace Nikse.SubtitleEdit.Forms.Assa
this.pictureBoxPreview.TabIndex = 0;
this.pictureBoxPreview.TabStop = false;
this.pictureBoxPreview.Click += new System.EventHandler(this.pictureBoxPreview_Click);
this.pictureBoxPreview.MouseMove += new System.Windows.Forms.MouseEventHandler(this.pictureBoxPreview_MouseMove);
//
// buttonOK
//
@ -144,6 +144,7 @@ namespace Nikse.SubtitleEdit.Forms.Assa
//
// timer1
//
this.timer1.Interval = 25;
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
//
// labelInfo
@ -194,7 +195,19 @@ namespace Nikse.SubtitleEdit.Forms.Assa
//
// numericUpDownRotateX
//
this.numericUpDownRotateX.BackColor = System.Drawing.SystemColors.Window;
this.numericUpDownRotateX.BackColorDisabled = System.Drawing.Color.FromArgb(((int)(((byte)(240)))), ((int)(((byte)(240)))), ((int)(((byte)(240)))));
this.numericUpDownRotateX.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(171)))), ((int)(((byte)(173)))), ((int)(((byte)(179)))));
this.numericUpDownRotateX.BorderColorDisabled = System.Drawing.Color.FromArgb(((int)(((byte)(120)))), ((int)(((byte)(120)))), ((int)(((byte)(120)))));
this.numericUpDownRotateX.ButtonForeColor = System.Drawing.SystemColors.ControlText;
this.numericUpDownRotateX.ButtonForeColorDown = System.Drawing.Color.Orange;
this.numericUpDownRotateX.ButtonForeColorOver = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(120)))), ((int)(((byte)(215)))));
this.numericUpDownRotateX.DecimalPlaces = 1;
this.numericUpDownRotateX.Increment = new decimal(new int[] {
1,
0,
0,
0});
this.numericUpDownRotateX.Location = new System.Drawing.Point(91, 9);
this.numericUpDownRotateX.Maximum = new decimal(new int[] {
360,
@ -209,6 +222,13 @@ namespace Nikse.SubtitleEdit.Forms.Assa
this.numericUpDownRotateX.Name = "numericUpDownRotateX";
this.numericUpDownRotateX.Size = new System.Drawing.Size(52, 20);
this.numericUpDownRotateX.TabIndex = 18;
this.numericUpDownRotateX.TabStop = false;
this.numericUpDownRotateX.ThousandsSeparator = false;
this.numericUpDownRotateX.Value = new decimal(new int[] {
0,
0,
0,
0});
this.numericUpDownRotateX.ValueChanged += new System.EventHandler(this.numericUpDownRotateX_ValueChanged);
//
// labelRotateX
@ -222,7 +242,19 @@ namespace Nikse.SubtitleEdit.Forms.Assa
//
// numericUpDownRotateY
//
this.numericUpDownRotateY.BackColor = System.Drawing.SystemColors.Window;
this.numericUpDownRotateY.BackColorDisabled = System.Drawing.Color.FromArgb(((int)(((byte)(240)))), ((int)(((byte)(240)))), ((int)(((byte)(240)))));
this.numericUpDownRotateY.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(171)))), ((int)(((byte)(173)))), ((int)(((byte)(179)))));
this.numericUpDownRotateY.BorderColorDisabled = System.Drawing.Color.FromArgb(((int)(((byte)(120)))), ((int)(((byte)(120)))), ((int)(((byte)(120)))));
this.numericUpDownRotateY.ButtonForeColor = System.Drawing.SystemColors.ControlText;
this.numericUpDownRotateY.ButtonForeColorDown = System.Drawing.Color.Orange;
this.numericUpDownRotateY.ButtonForeColorOver = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(120)))), ((int)(((byte)(215)))));
this.numericUpDownRotateY.DecimalPlaces = 1;
this.numericUpDownRotateY.Increment = new decimal(new int[] {
1,
0,
0,
0});
this.numericUpDownRotateY.Location = new System.Drawing.Point(91, 34);
this.numericUpDownRotateY.Maximum = new decimal(new int[] {
360,
@ -237,6 +269,13 @@ namespace Nikse.SubtitleEdit.Forms.Assa
this.numericUpDownRotateY.Name = "numericUpDownRotateY";
this.numericUpDownRotateY.Size = new System.Drawing.Size(52, 20);
this.numericUpDownRotateY.TabIndex = 20;
this.numericUpDownRotateY.TabStop = false;
this.numericUpDownRotateY.ThousandsSeparator = false;
this.numericUpDownRotateY.Value = new decimal(new int[] {
0,
0,
0,
0});
this.numericUpDownRotateY.ValueChanged += new System.EventHandler(this.numericUpDownRotateX_ValueChanged);
//
// labelRotateY
@ -250,7 +289,19 @@ namespace Nikse.SubtitleEdit.Forms.Assa
//
// numericUpDownRotateZ
//
this.numericUpDownRotateZ.BackColor = System.Drawing.SystemColors.Window;
this.numericUpDownRotateZ.BackColorDisabled = System.Drawing.Color.FromArgb(((int)(((byte)(240)))), ((int)(((byte)(240)))), ((int)(((byte)(240)))));
this.numericUpDownRotateZ.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(171)))), ((int)(((byte)(173)))), ((int)(((byte)(179)))));
this.numericUpDownRotateZ.BorderColorDisabled = System.Drawing.Color.FromArgb(((int)(((byte)(120)))), ((int)(((byte)(120)))), ((int)(((byte)(120)))));
this.numericUpDownRotateZ.ButtonForeColor = System.Drawing.SystemColors.ControlText;
this.numericUpDownRotateZ.ButtonForeColorDown = System.Drawing.Color.Orange;
this.numericUpDownRotateZ.ButtonForeColorOver = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(120)))), ((int)(((byte)(215)))));
this.numericUpDownRotateZ.DecimalPlaces = 1;
this.numericUpDownRotateZ.Increment = new decimal(new int[] {
1,
0,
0,
0});
this.numericUpDownRotateZ.Location = new System.Drawing.Point(91, 60);
this.numericUpDownRotateZ.Maximum = new decimal(new int[] {
360,
@ -265,6 +316,13 @@ namespace Nikse.SubtitleEdit.Forms.Assa
this.numericUpDownRotateZ.Name = "numericUpDownRotateZ";
this.numericUpDownRotateZ.Size = new System.Drawing.Size(52, 20);
this.numericUpDownRotateZ.TabIndex = 22;
this.numericUpDownRotateZ.TabStop = false;
this.numericUpDownRotateZ.ThousandsSeparator = false;
this.numericUpDownRotateZ.Value = new decimal(new int[] {
0,
0,
0,
0});
this.numericUpDownRotateZ.ValueChanged += new System.EventHandler(this.numericUpDownRotateX_ValueChanged);
//
// labelRotateZ
@ -305,6 +363,13 @@ namespace Nikse.SubtitleEdit.Forms.Assa
//
// numericUpDownDistortX
//
this.numericUpDownDistortX.BackColor = System.Drawing.SystemColors.Window;
this.numericUpDownDistortX.BackColorDisabled = System.Drawing.Color.FromArgb(((int)(((byte)(240)))), ((int)(((byte)(240)))), ((int)(((byte)(240)))));
this.numericUpDownDistortX.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(171)))), ((int)(((byte)(173)))), ((int)(((byte)(179)))));
this.numericUpDownDistortX.BorderColorDisabled = System.Drawing.Color.FromArgb(((int)(((byte)(120)))), ((int)(((byte)(120)))), ((int)(((byte)(120)))));
this.numericUpDownDistortX.ButtonForeColor = System.Drawing.SystemColors.ControlText;
this.numericUpDownDistortX.ButtonForeColorDown = System.Drawing.Color.Orange;
this.numericUpDownDistortX.ButtonForeColorOver = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(120)))), ((int)(((byte)(215)))));
this.numericUpDownDistortX.DecimalPlaces = 2;
this.numericUpDownDistortX.Increment = new decimal(new int[] {
5,
@ -325,6 +390,13 @@ namespace Nikse.SubtitleEdit.Forms.Assa
this.numericUpDownDistortX.Name = "numericUpDownDistortX";
this.numericUpDownDistortX.Size = new System.Drawing.Size(52, 20);
this.numericUpDownDistortX.TabIndex = 24;
this.numericUpDownDistortX.TabStop = false;
this.numericUpDownDistortX.ThousandsSeparator = false;
this.numericUpDownDistortX.Value = new decimal(new int[] {
0,
0,
0,
0});
this.numericUpDownDistortX.ValueChanged += new System.EventHandler(this.numericUpDownRotateX_ValueChanged);
//
// labelDistortY
@ -338,6 +410,13 @@ namespace Nikse.SubtitleEdit.Forms.Assa
//
// numericUpDownDistortY
//
this.numericUpDownDistortY.BackColor = System.Drawing.SystemColors.Window;
this.numericUpDownDistortY.BackColorDisabled = System.Drawing.Color.FromArgb(((int)(((byte)(240)))), ((int)(((byte)(240)))), ((int)(((byte)(240)))));
this.numericUpDownDistortY.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(171)))), ((int)(((byte)(173)))), ((int)(((byte)(179)))));
this.numericUpDownDistortY.BorderColorDisabled = System.Drawing.Color.FromArgb(((int)(((byte)(120)))), ((int)(((byte)(120)))), ((int)(((byte)(120)))));
this.numericUpDownDistortY.ButtonForeColor = System.Drawing.SystemColors.ControlText;
this.numericUpDownDistortY.ButtonForeColorDown = System.Drawing.Color.Orange;
this.numericUpDownDistortY.ButtonForeColorOver = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(120)))), ((int)(((byte)(215)))));
this.numericUpDownDistortY.DecimalPlaces = 2;
this.numericUpDownDistortY.Increment = new decimal(new int[] {
1,
@ -358,6 +437,13 @@ namespace Nikse.SubtitleEdit.Forms.Assa
this.numericUpDownDistortY.Name = "numericUpDownDistortY";
this.numericUpDownDistortY.Size = new System.Drawing.Size(52, 20);
this.numericUpDownDistortY.TabIndex = 26;
this.numericUpDownDistortY.TabStop = false;
this.numericUpDownDistortY.ThousandsSeparator = false;
this.numericUpDownDistortY.Value = new decimal(new int[] {
0,
0,
0,
0});
this.numericUpDownDistortY.ValueChanged += new System.EventHandler(this.numericUpDownRotateX_ValueChanged);
//
// SetPosition

View File

@ -475,6 +475,8 @@ namespace Nikse.SubtitleEdit.Forms.Assa
return;
}
CheckImageMouseMove();
if (_updatePos && (_x != _tempX || _y != _tempY))
{
_x = _tempX;
@ -485,6 +487,35 @@ namespace Nikse.SubtitleEdit.Forms.Assa
}
}
private void CheckImageMouseMove()
{
var pos = pictureBoxPreview.PointToClient(Cursor.Position);
var x = pos.X;
var y = pos.Y;
if (x < -100 || y < -100 || x > pictureBoxPreview.Width + 100 || y > pictureBoxPreview.Height + 100)
{
return;
}
var xAspectRatio = (double)_videoInfo.Width / pictureBoxPreview.Width;
_tempX = (int)Math.Round(x * xAspectRatio);
var yAspectRatio = (double)_videoInfo.Height / pictureBoxPreview.Height;
_tempY = (int)Math.Round(y * yAspectRatio);
if (_playResScaleOn)
{
_tempXScaled = AssaResampler.Resample(_videoInfo.Width, _originalPlayResX, _tempX);
_tempYScaled = AssaResampler.Resample(_videoInfo.Height, _originalPlayResY, _tempY);
labelCurrentPosition.Text = string.Format(LanguageSettings.Current.AssaSetPosition.CurrentMousePositionX, $"{_tempX},{_tempY} ({_tempXScaled},{_tempYScaled})");
}
else
{
labelCurrentPosition.Text = string.Format(LanguageSettings.Current.AssaSetPosition.CurrentMousePositionX, $"{_tempX},{_tempY}");
}
}
private void SetPosition_Shown(object sender, EventArgs e)
{
ShowStyleAlignment();
@ -693,26 +724,6 @@ namespace Nikse.SubtitleEdit.Forms.Assa
_positionChanged = true;
}
private void pictureBoxPreview_MouseMove(object sender, MouseEventArgs e)
{
var xAspectRatio = (double)_videoInfo.Width / pictureBoxPreview.Width;
_tempX = (int)Math.Round(e.Location.X * xAspectRatio);
var yAspectRatio = (double)_videoInfo.Height / pictureBoxPreview.Height;
_tempY = (int)Math.Round(e.Location.Y * yAspectRatio);
if (_playResScaleOn)
{
_tempXScaled = AssaResampler.Resample(_videoInfo.Width, _originalPlayResX, _tempX);
_tempYScaled = AssaResampler.Resample(_videoInfo.Height, _originalPlayResY, _tempY);
labelCurrentPosition.Text = string.Format(LanguageSettings.Current.AssaSetPosition.CurrentMousePositionX, $"{_tempX},{_tempY} ({_tempXScaled},{_tempYScaled})");
}
else
{
labelCurrentPosition.Text = string.Format(LanguageSettings.Current.AssaSetPosition.CurrentMousePositionX, $"{_tempX},{_tempY}");
}
}
private void SetPosition_ResizeEnd(object sender, EventArgs e)
{
var aspectRatio = (double)_videoInfo.Width / _videoInfo.Height;