Skip to content

Commit

Permalink
When double-clicking TAStudio frame# cell, open dialog beside cell
Browse files Browse the repository at this point in the history
  • Loading branch information
YoshiRulz committed Nov 28, 2024
1 parent c9df57b commit 418645e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1882,6 +1882,14 @@ private Cell CalculatePointedCell(int x, int y)
? _columns.VisibleColumns.Last().Right
: 0;

/// <returns>in both orientations, the bottom-left corner of <paramref name="c"/>, relative to this control</returns>
public Point CellToPixels(Cell c)
{
var x = c.Column!.Right;
var y = RowsToPixels(c.RowIndex!.Value - FirstVisibleRow + 3); // magic 3? I expected 1
return _horizontalOrientation ? new(y, x) : new(x, y);
}

/// <summary>
/// Returns the RollColumn object at the specified visible pixel coordinate.
/// </summary>
Expand Down
13 changes: 11 additions & 2 deletions src/BizHawk.Client.EmuHawk/tools/TAStudio/MarkerControl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,8 @@ public void UpdateTextColumnWidth()
}
}

public void EditMarkerPopUp(TasMovieMarker marker)
/// <param name="location">bottom-left corner, in screen-space, or <see langword="null"/> to center on this control</param>
public void EditMarkerPopUp(TasMovieMarker marker, Point? location = null)
{
var markerFrame = marker.Frame;
var i = new InputPrompt
Expand All @@ -218,7 +219,15 @@ public void EditMarkerPopUp(TasMovieMarker marker)
? Markers.PreviousOrCurrent(markerFrame).Message
: ""
};

if (location is null)
{
i.CenterOn(this);
}
else
{
i.StartPosition = FormStartPosition.Manual;
i.Location = location.Value - new Size(0, i.Height);
}
if (!this.ShowDialogWithTempMute(i).IsOk()) return;

marker.Message = i.PromptText;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,9 @@ private void TasView_MouseDoubleClick(object sender, MouseEventArgs e)

if (existingMarker != null)
{
MarkerControl.EditMarkerPopUp(existingMarker);
var dialogLocation = this.ChildPointToScreen(TasView);
dialogLocation.Offset(TasView.CellToPixels(TasView.CurrentCell));
MarkerControl.EditMarkerPopUp(existingMarker, dialogLocation);
}
else
{
Expand Down

0 comments on commit 418645e

Please sign in to comment.