diff --git a/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj b/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj index 15c77d1569..c4a5782ada 100644 --- a/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj +++ b/BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj @@ -1088,7 +1088,12 @@ PatternsForm.cs - + + Form + + + ScreenshotForm.cs + TAStudio.cs Form @@ -1606,6 +1611,9 @@ PlaybackBox.cs + + ScreenshotForm.cs + TAStudio.cs diff --git a/BizHawk.Client.EmuHawk/CustomControls/InputRoll.cs b/BizHawk.Client.EmuHawk/CustomControls/InputRoll.cs index c29d1cbd68..d45bbfd577 100644 --- a/BizHawk.Client.EmuHawk/CustomControls/InputRoll.cs +++ b/BizHawk.Client.EmuHawk/CustomControls/InputRoll.cs @@ -1680,7 +1680,7 @@ namespace BizHawk.Client.EmuHawk /// /// Bool that indicates if CurrentCell is a Column Cell. /// - private bool IsHoveringOnColumnCell + public bool IsHoveringOnColumnCell { get { @@ -1761,7 +1761,7 @@ namespace BizHawk.Client.EmuHawk } } - if (!(IsPaintDown || RightButtonHeld) && newCell.RowIndex == -1) + if (!(IsPaintDown || RightButtonHeld) && newCell.RowIndex <= -1) // -2 if we're entering from the top newCell.RowIndex = null; return newCell; diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/BookmarksBranchesBox.Designer.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/BookmarksBranchesBox.Designer.cs index 83dc8144c3..b362760f88 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/BookmarksBranchesBox.Designer.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/BookmarksBranchesBox.Designer.cs @@ -36,6 +36,7 @@ this.AddWithTextBranchButton = new System.Windows.Forms.Button(); this.AddBranchButton = new System.Windows.Forms.Button(); this.LoadBranchButton = new System.Windows.Forms.Button(); + this.BranchView = new BizHawk.Client.EmuHawk.InputRoll(); this.BranchesContextMenu = new System.Windows.Forms.ContextMenuStrip(this.components); this.AddBranchContextMenu = new System.Windows.Forms.ToolStripMenuItem(); this.AddBranchWithTextContextMenuItem = new System.Windows.Forms.ToolStripMenuItem(); @@ -45,8 +46,6 @@ this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator(); this.RemoveBranchContextMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); - this.ScreenshotTooltip = new System.Windows.Forms.ToolTip(this.components); - this.BranchView = new BizHawk.Client.EmuHawk.InputRoll(); this.BookmarksBranchesGroupBox.SuspendLayout(); this.BranchesContextMenu.SuspendLayout(); this.SuspendLayout(); @@ -146,6 +145,40 @@ this.LoadBranchButton.UseVisualStyleBackColor = true; this.LoadBranchButton.Click += new System.EventHandler(this.LoadBranchToolStripMenuItem_Click); // + // BranchView + // + this.BranchView.AllowColumnReorder = false; + this.BranchView.AllowColumnResize = false; + this.BranchView.allowRightClickSelecton = true; + this.BranchView.AlwaysScroll = false; + this.BranchView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) + | System.Windows.Forms.AnchorStyles.Left) + | System.Windows.Forms.AnchorStyles.Right))); + this.BranchView.CellHeightPadding = 0; + this.BranchView.ContextMenuStrip = this.BranchesContextMenu; + this.BranchView.FullRowSelect = true; + this.BranchView.HideWasLagFrames = false; + this.BranchView.HorizontalOrientation = false; + this.BranchView.LagFramesToHide = 0; + this.BranchView.letKeysModifySelection = false; + this.BranchView.Location = new System.Drawing.Point(6, 19); + this.BranchView.MaxCharactersInHorizontal = 1; + this.BranchView.MultiSelect = false; + this.BranchView.Name = "BranchView"; + this.BranchView.RowCount = 0; + this.BranchView.ScrollSpeed = 13; + this.BranchView.SeekingCutoffInterval = 0; + this.BranchView.Size = new System.Drawing.Size(186, 224); + this.BranchView.suspendHotkeys = false; + this.BranchView.TabIndex = 0; + this.BranchView.CellHovered += new BizHawk.Client.EmuHawk.InputRoll.HoverEventHandler(this.BranchView_CellHovered); + this.BranchView.CellDropped += new BizHawk.Client.EmuHawk.InputRoll.CellDroppedEvent(this.BranchView_CellDropped); + this.BranchView.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.BranchView_MouseDoubleClick); + this.BranchView.MouseDown += new System.Windows.Forms.MouseEventHandler(this.BranchView_MouseDown); + this.BranchView.MouseLeave += new System.EventHandler(this.BranchView_MouseLeave); + this.BranchView.MouseMove += new System.Windows.Forms.MouseEventHandler(this.BranchView_MouseMove); + this.BranchView.MouseUp += new System.Windows.Forms.MouseEventHandler(this.BranchView_MouseUp); + // // BranchesContextMenu // this.BranchesContextMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { @@ -213,54 +246,6 @@ this.RemoveBranchContextMenuItem.Text = "Remove"; this.RemoveBranchContextMenuItem.Click += new System.EventHandler(this.RemoveBranchToolStripMenuItem_Click); // - // ScreenshotTooltip - // - this.ScreenshotTooltip.AutomaticDelay = 0; - this.ScreenshotTooltip.AutoPopDelay = 34952; - this.ScreenshotTooltip.BackColor = System.Drawing.SystemColors.Control; - this.ScreenshotTooltip.InitialDelay = 0; - this.ScreenshotTooltip.OwnerDraw = true; - this.ScreenshotTooltip.ReshowDelay = 0; - this.ScreenshotTooltip.ShowAlways = true; - this.ScreenshotTooltip.UseAnimation = false; - this.ScreenshotTooltip.UseFading = false; - this.ScreenshotTooltip.Draw += new System.Windows.Forms.DrawToolTipEventHandler(this.Screenshot_Draw); - this.ScreenshotTooltip.Popup += new System.Windows.Forms.PopupEventHandler(this.Screenshot_Popup); - // - // BranchView - // - this.BranchView.AllowColumnReorder = false; - this.BranchView.AllowColumnResize = false; - this.BranchView.allowRightClickSelecton = true; - this.BranchView.AlwaysScroll = false; - this.BranchView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) - | System.Windows.Forms.AnchorStyles.Left) - | System.Windows.Forms.AnchorStyles.Right))); - this.BranchView.CellHeightPadding = 0; - this.BranchView.ContextMenuStrip = this.BranchesContextMenu; - this.BranchView.FullRowSelect = true; - this.BranchView.HideWasLagFrames = false; - this.BranchView.HorizontalOrientation = false; - this.BranchView.LagFramesToHide = 0; - this.BranchView.letKeysModifySelection = false; - this.BranchView.Location = new System.Drawing.Point(6, 19); - this.BranchView.MaxCharactersInHorizontal = 1; - this.BranchView.MultiSelect = false; - this.BranchView.Name = "BranchView"; - this.BranchView.RowCount = 0; - this.BranchView.ScrollSpeed = 13; - this.BranchView.SeekingCutoffInterval = 0; - this.BranchView.Size = new System.Drawing.Size(186, 224); - this.BranchView.suspendHotkeys = false; - this.BranchView.TabIndex = 0; - this.BranchView.CellHovered += new BizHawk.Client.EmuHawk.InputRoll.HoverEventHandler(this.BranchView_CellHovered); - this.BranchView.CellDropped += new BizHawk.Client.EmuHawk.InputRoll.CellDroppedEvent(this.BranchView_CellDropped); - this.BranchView.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.BranchView_MouseDoubleClick); - this.BranchView.MouseDown += new System.Windows.Forms.MouseEventHandler(this.BranchView_MouseDown); - this.BranchView.MouseLeave += new System.EventHandler(this.BranchView_MouseLeave); - this.BranchView.MouseMove += new System.Windows.Forms.MouseEventHandler(this.BranchView_MouseMove); - this.BranchView.MouseUp += new System.Windows.Forms.MouseEventHandler(this.BranchView_MouseUp); - // // BookmarksBranchesBox // this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit; @@ -292,6 +277,5 @@ private System.Windows.Forms.Button LoadBranchButton; private System.Windows.Forms.ToolTip toolTip1; private System.Windows.Forms.ToolStripSeparator toolStripSeparator2; - private System.Windows.Forms.ToolTip ScreenshotTooltip; } } diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/BookmarksBranchesBox.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/BookmarksBranchesBox.cs index dd4e085a1b..2d1771a67f 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/BookmarksBranchesBox.cs +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/BookmarksBranchesBox.cs @@ -20,7 +20,7 @@ namespace BizHawk.Client.EmuHawk private const string FrameColumnName = "FrameColumn"; private const string UserTextColumnName = "TextColumn"; private readonly PlatformFrameRates FrameRates = new PlatformFrameRates(); - private ScreenshotPopup Screenshot = new ScreenshotPopup(); + private ScreenshotForm Screenshot = new ScreenshotForm(); private TasMovie Movie { get { return Tastudio.CurrentTasMovie; } } public TAStudio Tastudio { get; set; } @@ -452,7 +452,7 @@ namespace BizHawk.Client.EmuHawk { if (BranchView.CurrentCell == null || !BranchView.CurrentCell.RowIndex.HasValue || BranchView.CurrentCell.Column == null) { - //not sure if we need to explicitly hide the screenshot here as well + Screenshot.FadeOut(); } else if (BranchView.CurrentCell.Column.Name == BranchNumberColumnName) { @@ -462,7 +462,7 @@ namespace BizHawk.Client.EmuHawk private void BranchView_MouseLeave(object sender, EventArgs e) { - ScreenshotTooltip.Hide(this); + Screenshot.FadeOut(); } private void BranchView_CellHovered(object sender, InputRoll.CellEventArgs e) @@ -474,24 +474,25 @@ namespace BizHawk.Client.EmuHawk BranchView.CurrentCell.RowIndex < Movie.BranchCount) { TasBranch branch = GetBranch(BranchView.CurrentCell.RowIndex.Value); + Point location = Location; + location.Offset(-Screenshot.Width, 0); int width = Tastudio.VideoProvider.BufferWidth; int height = Tastudio.VideoProvider.BufferHeight; - Screenshot.UpdateValues(branch, width, height, + + Screenshot.UpdateValues(branch, PointToScreen(location), width, height, (int)Graphics.FromHwnd(this.Handle).MeasureString( branch.UserText, Screenshot.Font, width).Height); - Point location = Location; - location.Offset(-Screenshot.Width, 0); - ScreenshotTooltip.Show(" ", this, location); + Screenshot.FadeIn(); } else { - ScreenshotTooltip.Hide(this); + Screenshot.FadeOut(); } } else { - ScreenshotTooltip.Hide(this); + Screenshot.FadeOut(); } } @@ -503,16 +504,6 @@ namespace BizHawk.Client.EmuHawk } } - private void Screenshot_Popup(object sender, PopupEventArgs e) - { - Screenshot.Popup(sender, e); - } - - private void Screenshot_Draw(object sender, DrawToolTipEventArgs e) - { - Screenshot.Draw(sender, e); - } - #endregion } } diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/BookmarksBranchesBox.resx b/BizHawk.Client.EmuHawk/tools/TAStudio/BookmarksBranchesBox.resx index b03be4818d..5af3536e76 100644 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/BookmarksBranchesBox.resx +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/BookmarksBranchesBox.resx @@ -118,12 +118,9 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - 297, 18 + 185, 17 23, 17 - - 171, 17 - \ No newline at end of file diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/ScreenshotForm.Designer.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/ScreenshotForm.Designer.cs new file mode 100644 index 0000000000..7529026437 --- /dev/null +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/ScreenshotForm.Designer.cs @@ -0,0 +1,51 @@ +namespace BizHawk.Client.EmuHawk +{ + partial class ScreenshotForm + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.SuspendLayout(); + // + // ScreenshotForm + // + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; + this.ClientSize = new System.Drawing.Size(314, 234); + this.ControlBox = false; + this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "ScreenshotForm"; + this.ShowIcon = false; + this.ShowInTaskbar = false; + this.StartPosition = System.Windows.Forms.FormStartPosition.Manual; + this.ResumeLayout(false); + + } + + #endregion + } +} \ No newline at end of file diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/ScreenshotForm.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/ScreenshotForm.cs new file mode 100644 index 0000000000..fbe0d5648a --- /dev/null +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/ScreenshotForm.cs @@ -0,0 +1,128 @@ +// We pretend it's a tooltip kind of thing, so show only the actual contents +// and avoid stealing forcus, while still being topmost +// http://stackoverflow.com/a/25219399/2792852 +// This is not an actual tooltip, because they can't reliably fade in and out with trasparency + +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using BizHawk.Client.Common; + +namespace BizHawk.Client.EmuHawk +{ + public partial class ScreenshotForm : Form + { + private Timer _showTimer = new Timer(); + private Timer _hideTimer = new Timer(); + public TasBranch Branch { get; set; } + public Font Font; + public FontStyle FontStyle; + public int FontSize; + public int DrawingHeight; + public int Padding; + public string Text; + + public ScreenshotForm() + { + InitializeComponent(); + + Width = 320; + Height = 240; + FontSize = 10; + FontStyle = FontStyle.Regular; + Font = new Font(FontFamily.GenericMonospace, FontSize, FontStyle); + DrawingHeight = 0; + Padding = 0; + Opacity = 0; + + _showTimer.Interval = 1; + _showTimer.Tick += new EventHandler((sender, e) => + { + if ((Opacity += 0.05d) >= 1) + _showTimer.Stop(); + }); + + _hideTimer.Interval = 1; + _hideTimer.Tick += new EventHandler((sender, e) => + { + if ((Opacity -= 0.05d) <= 0) + { + _hideTimer.Stop(); + Hide(); + } + }); + } + + public void UpdateValues(TasBranch branch, Point location , int width, int height, int padding) + { + Branch = branch; + Width = width; + Padding = padding; + DrawingHeight = height; + Text = Branch.UserText; + Location = location; + + // Set the screenshot to "1x" resolution of the core + // cores like n64 and psx are going to still have sizes too big for the control, so cap them + if (Width > 320) + { + double ratio = 320.0 / (double)Width; + Width = 320; + DrawingHeight = (int)((double)(DrawingHeight) * ratio); + } + + if (Padding > 0) + Padding += 2; + Height = DrawingHeight + Padding; + } + + protected override void OnPaint(PaintEventArgs e) + { + Branch.OSDFrameBuffer.DiscardAlpha(); + var bitmap = Branch.OSDFrameBuffer.ToSysdrawingBitmap(); + e.Graphics.DrawImage(bitmap, new Rectangle(0, 0, Width, DrawingHeight)); + if (Padding > 0) + { + e.Graphics.DrawRectangle(new Pen(Brushes.Black), new Rectangle(new Point(0, DrawingHeight), new Size(Width - 1, Padding - 1))); + e.Graphics.DrawString(Text, Font, Brushes.Black, new Rectangle(2, DrawingHeight, Width - 2, Height)); + } + base.OnPaint(e); + } + + public void FadeIn() + { + _showTimer.Stop(); + _hideTimer.Stop(); + _showTimer.Start(); + Show(); + } + + public void FadeOut() + { + _showTimer.Stop(); + _hideTimer.Stop(); + _hideTimer.Start(); + } + + protected override bool ShowWithoutActivation + { + get { return true; } + } + + private const int WS_EX_TOPMOST = 0x00000008; + protected override CreateParams CreateParams + { + get + { + CreateParams createParams = base.CreateParams; + createParams.ExStyle |= WS_EX_TOPMOST; + return createParams; + } + } + } +} diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/ScreenshotForm.resx b/BizHawk.Client.EmuHawk/tools/TAStudio/ScreenshotForm.resx new file mode 100644 index 0000000000..1af7de150c --- /dev/null +++ b/BizHawk.Client.EmuHawk/tools/TAStudio/ScreenshotForm.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/BizHawk.Client.EmuHawk/tools/TAStudio/ScreenshotPopup.cs b/BizHawk.Client.EmuHawk/tools/TAStudio/ScreenshotPopup.cs deleted file mode 100644 index 335f1d0553..0000000000 --- a/BizHawk.Client.EmuHawk/tools/TAStudio/ScreenshotPopup.cs +++ /dev/null @@ -1,74 +0,0 @@ -using System; -using System.Drawing; -using System.Linq; -using System.Text; -using System.Windows.Forms; -using BizHawk.Client.Common; - -namespace BizHawk.Client.EmuHawk -{ - public class ScreenshotPopup - { - public TasBranch Branch { get; set; } - public Font Font; - public FontStyle FontStyle; - public int Width; - public int Height; - public int FontSize; - public int DrawingHeight; - public int Padding; - public string Text; - - public ScreenshotPopup() - { - Width = 0; - Height = 0; - FontSize = 10; - FontStyle = FontStyle.Regular; - Font = new Font(FontFamily.GenericMonospace, FontSize, FontStyle); - DrawingHeight = 0; - Padding = 0; - } - - public void UpdateValues(TasBranch branch, int width, int height, int padding) - { - Branch = branch; - Width = width; - Padding = padding; - DrawingHeight = height; - Text = Branch.UserText; - - // Set the screenshot to "1x" resolution of the core - // cores like n64 and psx are going to still have sizes too big for the control, so cap them - if (Width > 320) - { - double ratio = 320.0 / (double)Width; - Width = 320; - DrawingHeight = (int)((double)(DrawingHeight) * ratio); - } - - if (Padding > 0) - Padding += 2; - Height = DrawingHeight + Padding; - } - - public void Popup(object sender, PopupEventArgs e) - { - e.ToolTipSize = new Size(Width, Height); - } - - public void Draw(object sender, DrawToolTipEventArgs e) - { - Branch.OSDFrameBuffer.DiscardAlpha(); - var bitmap = Branch.OSDFrameBuffer.ToSysdrawingBitmap(); - - e.DrawBackground(); - e.DrawBorder(); - e.Graphics.DrawImage(bitmap, e.Bounds.Left, e.Bounds.Top, Width, DrawingHeight); - - if (Padding > 0) - e.Graphics.DrawString(Text, Font, Brushes.Black, - new Rectangle(3, DrawingHeight, Width - 3, Height)); - } - } -}