From 418645e59cb9a4037fd293b1ef261f0afa208194 Mon Sep 17 00:00:00 2001 From: YoshiRulz Date: Fri, 29 Nov 2024 00:03:51 +1000 Subject: [PATCH] When double-clicking TAStudio frame# cell, open dialog beside cell --- .../CustomControls/InputRoll/InputRoll.cs | 8 ++++++++ .../tools/TAStudio/MarkerControl.cs | 13 +++++++++++-- .../tools/TAStudio/TAStudio.ListView.cs | 4 +++- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/src/BizHawk.Client.EmuHawk/CustomControls/InputRoll/InputRoll.cs b/src/BizHawk.Client.EmuHawk/CustomControls/InputRoll/InputRoll.cs index e524c151e8..68c91d623f 100644 --- a/src/BizHawk.Client.EmuHawk/CustomControls/InputRoll/InputRoll.cs +++ b/src/BizHawk.Client.EmuHawk/CustomControls/InputRoll/InputRoll.cs @@ -1882,6 +1882,14 @@ private Cell CalculatePointedCell(int x, int y) ? _columns.VisibleColumns.Last().Right : 0; + /// in both orientations, the bottom-left corner of , relative to this control + 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); + } + /// /// Returns the RollColumn object at the specified visible pixel coordinate. /// diff --git a/src/BizHawk.Client.EmuHawk/tools/TAStudio/MarkerControl.cs b/src/BizHawk.Client.EmuHawk/tools/TAStudio/MarkerControl.cs index 3bfbf6c7b4..3238441a28 100644 --- a/src/BizHawk.Client.EmuHawk/tools/TAStudio/MarkerControl.cs +++ b/src/BizHawk.Client.EmuHawk/tools/TAStudio/MarkerControl.cs @@ -205,7 +205,8 @@ public void UpdateTextColumnWidth() } } - public void EditMarkerPopUp(TasMovieMarker marker) + /// bottom-left corner, in screen-space, or to center on this control + public void EditMarkerPopUp(TasMovieMarker marker, Point? location = null) { var markerFrame = marker.Frame; var i = new InputPrompt @@ -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; diff --git a/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs b/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs index 65832afc01..e21c57ea49 100644 --- a/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs +++ b/src/BizHawk.Client.EmuHawk/tools/TAStudio/TAStudio.ListView.cs @@ -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 {