Simple zooming support with arrow keys
This commit is contained in:
parent
c497ce64f7
commit
985117958c
2 changed files with 55 additions and 13 deletions
|
@ -77,6 +77,8 @@ namespace Ryujinx.Profiler.UI
|
||||||
private bool _prevBackspaceDown = false;
|
private bool _prevBackspaceDown = false;
|
||||||
private double _backspaceDownTime = 0;
|
private double _backspaceDownTime = 0;
|
||||||
|
|
||||||
|
private Key _graphControlKey = Key.F35;
|
||||||
|
|
||||||
// Event management
|
// Event management
|
||||||
private double _updateTimer;
|
private double _updateTimer;
|
||||||
private double _processEventTimer;
|
private double _processEventTimer;
|
||||||
|
@ -262,6 +264,26 @@ namespace Ryujinx.Profiler.UI
|
||||||
if (_processEventTimer > 0.05)
|
if (_processEventTimer > 0.05)
|
||||||
{
|
{
|
||||||
ProcessEvents();
|
ProcessEvents();
|
||||||
|
|
||||||
|
switch (_graphControlKey)
|
||||||
|
{
|
||||||
|
case Key.Left:
|
||||||
|
_graphPosition += (float)(GraphMoveSpeed * e.Time);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Key.Right:
|
||||||
|
_graphPosition = MathF.Max(_graphPosition - (float)(GraphMoveSpeed * e.Time), 0);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Key.Up:
|
||||||
|
_graphZoom = MathF.Min(_graphZoom + (float)(GraphZoomSpeed * e.Time), 100.0f);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case Key.Down:
|
||||||
|
_graphZoom = MathF.Max(_graphZoom - (float)(GraphZoomSpeed * e.Time), 1f);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
_processEventTimer = 0;
|
_processEventTimer = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -574,20 +596,36 @@ namespace Ryujinx.Profiler.UI
|
||||||
|
|
||||||
protected override void OnKeyDown(KeyboardKeyEventArgs e)
|
protected override void OnKeyDown(KeyboardKeyEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.Key == Key.BackSpace)
|
switch (e.Key)
|
||||||
{
|
{
|
||||||
_profileUpdated = _backspaceDown = true;
|
case Key.BackSpace:
|
||||||
return;
|
_profileUpdated = _backspaceDown = true;
|
||||||
}
|
return;
|
||||||
|
|
||||||
|
case Key.Left:
|
||||||
|
case Key.Right:
|
||||||
|
case Key.Up:
|
||||||
|
case Key.Down:
|
||||||
|
_graphControlKey = e.Key;
|
||||||
|
return;
|
||||||
|
}
|
||||||
base.OnKeyUp(e);
|
base.OnKeyUp(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnKeyUp(KeyboardKeyEventArgs e)
|
protected override void OnKeyUp(KeyboardKeyEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.Key == Key.BackSpace)
|
switch (e.Key)
|
||||||
{
|
{
|
||||||
_backspaceDown = false;
|
case Key.BackSpace:
|
||||||
return;
|
_backspaceDown = false;
|
||||||
|
return;
|
||||||
|
|
||||||
|
case Key.Left:
|
||||||
|
case Key.Right:
|
||||||
|
case Key.Up:
|
||||||
|
case Key.Down:
|
||||||
|
_graphControlKey = Key.F35;
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
base.OnKeyUp(e);
|
base.OnKeyUp(e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,4 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Text;
|
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
using OpenTK.Graphics.OpenGL;
|
using OpenTK.Graphics.OpenGL;
|
||||||
|
|
||||||
|
@ -8,6 +6,12 @@ namespace Ryujinx.Profiler.UI
|
||||||
{
|
{
|
||||||
public partial class ProfileWindow
|
public partial class ProfileWindow
|
||||||
{
|
{
|
||||||
|
private const float GraphMoveSpeed = 100;
|
||||||
|
private const float GraphZoomSpeed = 5;
|
||||||
|
|
||||||
|
private float _graphZoom = 1;
|
||||||
|
private float _graphPosition = 0;
|
||||||
|
|
||||||
private void DrawGraph(float xOffset, float yOffset, float width)
|
private void DrawGraph(float xOffset, float yOffset, float width)
|
||||||
{
|
{
|
||||||
if (_sortedProfileData.Count != 0)
|
if (_sortedProfileData.Count != 0)
|
||||||
|
@ -17,7 +21,7 @@ namespace Ryujinx.Profiler.UI
|
||||||
|
|
||||||
int verticalIndex = 0;
|
int verticalIndex = 0;
|
||||||
float barHeight = (LineHeight - LinePadding);
|
float barHeight = (LineHeight - LinePadding);
|
||||||
long timeWidth = Profile.HistoryLength;
|
long timeWidth = (long)(Profile.HistoryLength / _graphZoom);
|
||||||
|
|
||||||
GL.Enable(EnableCap.ScissorTest);
|
GL.Enable(EnableCap.ScissorTest);
|
||||||
GL.Begin(PrimitiveType.Triangles);
|
GL.Begin(PrimitiveType.Triangles);
|
||||||
|
@ -26,8 +30,8 @@ namespace Ryujinx.Profiler.UI
|
||||||
GL.Color3(Color.Green);
|
GL.Color3(Color.Green);
|
||||||
foreach (Timestamp timestamp in entry.Value.GetAllTimestamps())
|
foreach (Timestamp timestamp in entry.Value.GetAllTimestamps())
|
||||||
{
|
{
|
||||||
left = (int)(xOffset + width - (((float)_captureTime - timestamp.BeginTime) / timeWidth) * width);
|
left = (int)(xOffset + width + _graphPosition - (((float)_captureTime - timestamp.BeginTime) / timeWidth) * width);
|
||||||
right = (int)(xOffset + width - (((float)_captureTime - timestamp.EndTime) / timeWidth) * width);
|
right = (int)(xOffset + width + _graphPosition - (((float)_captureTime - timestamp.EndTime) / timeWidth) * width);
|
||||||
bottom = GetLineY(yOffset, LineHeight, LinePadding, true, verticalIndex);
|
bottom = GetLineY(yOffset, LineHeight, LinePadding, true, verticalIndex);
|
||||||
top = bottom + barHeight;
|
top = bottom + barHeight;
|
||||||
|
|
||||||
|
@ -52,7 +56,7 @@ namespace Ryujinx.Profiler.UI
|
||||||
long entryBegin = entry.Value.BeginTime;
|
long entryBegin = entry.Value.BeginTime;
|
||||||
if (entryBegin != -1)
|
if (entryBegin != -1)
|
||||||
{
|
{
|
||||||
left = (int)(xOffset + width - (((float)_captureTime - entryBegin) / timeWidth) * width);
|
left = (int)(xOffset + width + _graphPosition - (((float)_captureTime - entryBegin) / timeWidth) * width);
|
||||||
bottom = GetLineY(yOffset, LineHeight, LinePadding, true, verticalIndex);
|
bottom = GetLineY(yOffset, LineHeight, LinePadding, true, verticalIndex);
|
||||||
top = bottom + barHeight;
|
top = bottom + barHeight;
|
||||||
right = (int)(xOffset + width);
|
right = (int)(xOffset + width);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue