mirror of
https://github.com/SourMesen/Mesen.git
synced 2025-04-02 10:52:48 -04:00
UI: Hide mouse cursor after 3 seconds if user doesn't move mouse
This commit is contained in:
parent
8d57d13c64
commit
2715d87179
3 changed files with 38 additions and 0 deletions
10
GUI.NET/Controls/ctrlRenderer.Designer.cs
generated
10
GUI.NET/Controls/ctrlRenderer.Designer.cs
generated
|
@ -27,14 +27,22 @@
|
|||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.tmrMouse = new System.Windows.Forms.Timer(this.components);
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// tmrMouse
|
||||
//
|
||||
this.tmrMouse.Interval = 3000;
|
||||
this.tmrMouse.Tick += new System.EventHandler(this.tmrMouse_Tick);
|
||||
//
|
||||
// ctrlRenderer
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Name = "ctrlRenderer";
|
||||
this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.ctrlRenderer_MouseDown);
|
||||
this.MouseLeave += new System.EventHandler(this.ctrlRenderer_MouseLeave);
|
||||
this.MouseMove += new System.Windows.Forms.MouseEventHandler(this.ctrlRenderer_MouseMove);
|
||||
this.MouseUp += new System.Windows.Forms.MouseEventHandler(this.ctrlRenderer_MouseUp);
|
||||
this.ResumeLayout(false);
|
||||
|
@ -42,5 +50,7 @@
|
|||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Timer tmrMouse;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ namespace Mesen.GUI.Controls
|
|||
public partial class ctrlRenderer : UserControl
|
||||
{
|
||||
private bool _rightButtonDown = false;
|
||||
private bool _cursorHidden = false;
|
||||
|
||||
public ctrlRenderer()
|
||||
{
|
||||
|
@ -32,10 +33,19 @@ namespace Mesen.GUI.Controls
|
|||
|
||||
private void ctrlRenderer_MouseMove(object sender, MouseEventArgs e)
|
||||
{
|
||||
if(_cursorHidden) {
|
||||
Cursor.Show();
|
||||
_cursorHidden = false;
|
||||
}
|
||||
tmrMouse.Stop();
|
||||
|
||||
if(InteropEmu.HasZapper()) {
|
||||
this.Cursor = Cursors.Cross;
|
||||
} else {
|
||||
this.Cursor = Cursors.Default;
|
||||
|
||||
//Only hide mouse if no zapper (otherwise this could be pretty annoying)
|
||||
tmrMouse.Start();
|
||||
}
|
||||
|
||||
if(_rightButtonDown) {
|
||||
|
@ -58,5 +68,20 @@ namespace Mesen.GUI.Controls
|
|||
_rightButtonDown = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void tmrMouse_Tick(object sender, EventArgs e)
|
||||
{
|
||||
_cursorHidden = true;
|
||||
Cursor.Hide();
|
||||
}
|
||||
|
||||
private void ctrlRenderer_MouseLeave(object sender, EventArgs e)
|
||||
{
|
||||
tmrMouse.Stop();
|
||||
if(_cursorHidden) {
|
||||
_cursorHidden = false;
|
||||
Cursor.Show();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -117,4 +117,7 @@
|
|||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="tmrMouse.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
</root>
|
Loading…
Add table
Reference in a new issue