Tastudio - ability to move markers by shift+click dragging them

This commit is contained in:
adelikat 2015-07-28 20:03:03 -04:00
parent 75ccd1966b
commit 6bcbf82b7c
4 changed files with 102 additions and 11 deletions

View File

@ -359,6 +359,10 @@ namespace BizHawk.Client.EmuHawk
[Description("Occurs when the scroll value of the columns (in vertical orientation this is the horizontal scroll bar change, and in horizontal it is the vertical scroll bar)")]
public event ColumnScrollEvent ColumnScroll;
[Category("Action")]
[Description("Occurs when a cell is dragged and then dropped into a new cell, old cell is the cell that was being dragged, new cell is its new destination")]
public event CellDroppedEvent CellDropped;
/// <summary>
/// Retrieve the text for a cell
/// </summary>
@ -394,6 +398,8 @@ namespace BizHawk.Client.EmuHawk
public delegate void ColumnScrollEvent(object sender, EventArgs e);
public delegate void CellDroppedEvent(object sender, CellEventArgs e);
public class CellEventArgs
{
public CellEventArgs(Cell oldCell, Cell newCell)
@ -780,6 +786,30 @@ namespace BizHawk.Client.EmuHawk
}
}
private Cell DraggingCell = null;
public void DragCurrentCell()
{
DraggingCell = CurrentCell;
}
public void ReleaseCurrentCell()
{
if (DraggingCell != null)
{
var draggedCell = DraggingCell;
DraggingCell = null;
if (CurrentCell != draggedCell)
{
if (CellDropped != null)
{
CellDropped(this, new CellEventArgs(draggedCell, CurrentCell));
}
}
}
}
/// <summary>
/// Scrolls to the given index, according to the scroll settings.
/// </summary>
@ -916,6 +946,7 @@ namespace BizHawk.Client.EmuHawk
DrawData(e);
DrawColumnDrag(e);
DrawCellDrag(e);
Gdi.CopyToScreen();
Gdi.EndOffScreenBitmap();
@ -943,6 +974,42 @@ namespace BizHawk.Client.EmuHawk
}
}
private void DrawCellDrag(PaintEventArgs e)
{
if (DraggingCell != null)
{
try
{
var text = "";
if (QueryItemText != null)
{
QueryItemText(DraggingCell.RowIndex.Value, DraggingCell.Column, out text);
}
Color bgColor = this.BackColor;
if (QueryItemBkColor != null)
{
QueryItemBkColor(DraggingCell.RowIndex.Value, DraggingCell.Column, ref bgColor);
}
int x1 = _currentX.Value - (DraggingCell.Column.Width.Value / 2);
int y1 = _currentY.Value - (CellHeight / 2);
int x2 = x1 + DraggingCell.Column.Width.Value;
int y2 = y1 + CellHeight;
Gdi.SetBrush(bgColor);
Gdi.FillRectangle(x1, y1, x2 - x1, y2 - y1);
Gdi.PrepDrawString(this.NormalFont, this.ForeColor);
Gdi.DrawString(text, new Point(x1 + CellWidthPadding, y1 + CellHeightPadding));
}
catch (Exception ex)
{
int zzz = 0;
}
}
}
private void DrawColumnText(PaintEventArgs e)
{
var columns = _columns.VisibleColumns.ToList();

View File

@ -172,11 +172,11 @@ namespace BizHawk.Client.EmuHawk
this.BranchContextMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.StartFromNowSeparator = new System.Windows.Forms.ToolStripSeparator();
this.StartNewProjectFromNowMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.StartANewProjectFromSaveRamMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.groupBox1 = new System.Windows.Forms.GroupBox();
this.BookMarkControl = new BizHawk.Client.EmuHawk.BookmarksBranchesBox();
this.BranchesMarkersSplit = new System.Windows.Forms.SplitContainer();
this.MainVertialSplit = new System.Windows.Forms.SplitContainer();
this.StartANewProjectFromSaveRamMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.TASMenu.SuspendLayout();
this.TasStatusStrip.SuspendLayout();
this.MarkerContextMenu.SuspendLayout();
@ -1057,6 +1057,7 @@ namespace BizHawk.Client.EmuHawk
this.TasView.SelectedIndexChanged += new System.EventHandler(this.TasView_SelectedIndexChanged);
this.TasView.RightMouseScrolled += new BizHawk.Client.EmuHawk.InputRoll.RightMouseScrollEventHandler(this.TasView_MouseWheel);
this.TasView.ColumnReordered += new BizHawk.Client.EmuHawk.InputRoll.ColumnReorderedEventHandler(this.TasView_ColumnReordered);
this.TasView.CellDropped += new BizHawk.Client.EmuHawk.InputRoll.CellDroppedEvent(this.TasView_CellDropped);
this.TasView.KeyDown += new System.Windows.Forms.KeyEventHandler(this.TasView_KeyDown);
this.TasView.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.TasView_MouseDoubleClick);
this.TasView.MouseDown += new System.Windows.Forms.MouseEventHandler(this.TasView_MouseDown);
@ -1194,7 +1195,7 @@ namespace BizHawk.Client.EmuHawk
this.StartNewProjectFromNowMenuItem,
this.StartANewProjectFromSaveRamMenuItem});
this.RightClickMenu.Name = "RightClickMenu";
this.RightClickMenu.Size = new System.Drawing.Size(273, 480);
this.RightClickMenu.Size = new System.Drawing.Size(273, 458);
this.RightClickMenu.Opened += new System.EventHandler(this.RightClickMenu_Opened);
//
// SetMarkersContextMenuItem
@ -1365,6 +1366,13 @@ namespace BizHawk.Client.EmuHawk
this.StartNewProjectFromNowMenuItem.Text = "Start a new project from Here";
this.StartNewProjectFromNowMenuItem.Click += new System.EventHandler(this.StartNewProjectFromNowMenuItem_Click);
//
// StartANewProjectFromSaveRamMenuItem
//
this.StartANewProjectFromSaveRamMenuItem.Name = "StartANewProjectFromSaveRamMenuItem";
this.StartANewProjectFromSaveRamMenuItem.Size = new System.Drawing.Size(272, 22);
this.StartANewProjectFromSaveRamMenuItem.Text = "Start a new project from SaveRam";
this.StartANewProjectFromSaveRamMenuItem.Click += new System.EventHandler(this.StartANewProjectFromSaveRamMenuItem_Click);
//
// groupBox1
//
this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
@ -1432,13 +1440,6 @@ namespace BizHawk.Client.EmuHawk
this.MainVertialSplit.TabIndex = 10;
this.MainVertialSplit.SplitterMoved += new System.Windows.Forms.SplitterEventHandler(this.MainVertialSplit_SplitterMoved);
//
// StartANewProjectFromSaveRamMenuItem
//
this.StartANewProjectFromSaveRamMenuItem.Name = "StartANewProjectFromSaveRamMenuItem";
this.StartANewProjectFromSaveRamMenuItem.Size = new System.Drawing.Size(272, 22);
this.StartANewProjectFromSaveRamMenuItem.Text = "Start a new project from SaveRam";
this.StartANewProjectFromSaveRamMenuItem.Click += new System.EventHandler(this.StartANewProjectFromSaveRamMenuItem_Click);
//
// TAStudio
//
this.AllowDrop = true;

View File

@ -354,8 +354,16 @@ namespace BizHawk.Client.EmuHawk
}
else if (TasView.CurrentCell.Column.Name == FrameColumnName)
{
_startFrameDrag = true;
_frameDragState = TasView.SelectedRows.Contains(frame);
if (Control.ModifierKeys == Keys.Shift && CurrentTasMovie.Markers.IsMarker(frame))
{
// TODO
TasView.DragCurrentCell();
}
else
{
_startFrameDrag = true;
_frameDragState = TasView.SelectedRows.Contains(frame);
}
}
else // User changed input
{
@ -477,6 +485,7 @@ namespace BizHawk.Client.EmuHawk
_startFrameDrag = false;
_startBoolDrawColumn = string.Empty;
_startFloatDrawColumn = string.Empty;
TasView.ReleaseCurrentCell();
// Exit float editing if value was changed with cursor
if (_floatEditRow != -1 && _floatPaintState != CurrentTasMovie.GetFloatState(_floatEditRow, _floatEditColumn))
{

View File

@ -902,5 +902,19 @@ namespace BizHawk.Client.EmuHawk
}
}
}
private void TasView_CellDropped(object sender, InputRoll.CellEventArgs e)
{
if (e.NewCell != null && e.NewCell.RowIndex.HasValue &&
!CurrentTasMovie.Markers.IsMarker(e.NewCell.RowIndex.Value))
{
var currentMarker = CurrentTasMovie.Markers.Single(m => m.Frame == e.OldCell.RowIndex.Value);
int newFrame = e.NewCell.RowIndex.Value;
var newMarker = new TasMovieMarker(newFrame, currentMarker.Message);
CurrentTasMovie.Markers.Remove(currentMarker);
CurrentTasMovie.Markers.Add(newMarker);
RefreshDialog();
}
}
}
}