mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-29 08:54:34 +00:00
Cosmetics.
This commit is contained in:
parent
74789d1049
commit
c2d527e2e7
@ -146,8 +146,10 @@ private:
|
|||||||
Inactive
|
Inactive
|
||||||
};
|
};
|
||||||
|
|
||||||
struct KeyboardNavigation {
|
struct KeyboardNavigation
|
||||||
enum Direction : uint8_t {
|
{
|
||||||
|
enum Direction
|
||||||
|
{
|
||||||
// Pan left / right
|
// Pan left / right
|
||||||
Left,
|
Left,
|
||||||
Right,
|
Right,
|
||||||
@ -156,9 +158,9 @@ private:
|
|||||||
Out
|
Out
|
||||||
};
|
};
|
||||||
|
|
||||||
constexpr static auto DirectionToKeyMap = std::array<int, 4>{ImGuiKey_A, ImGuiKey_D, ImGuiKey_W, ImGuiKey_S};
|
constexpr static auto DirectionToKeyMap = std::array<int, 4> { ImGuiKey_A, ImGuiKey_D, ImGuiKey_W, ImGuiKey_S };
|
||||||
constexpr static auto StartRangeMod = std::array<int, 4>{-1, 1, 1, -1};
|
constexpr static auto StartRangeMod = std::array<int, 4> { -1, 1, 1, -1 };
|
||||||
constexpr static auto EndRangeMod = std::array<int, 4>{-1, 1, -1, 1};
|
constexpr static auto EndRangeMod = std::array<int, 4> { -1, 1, -1, 1 };
|
||||||
|
|
||||||
std::array<float, 4> m_scrollInertia;
|
std::array<float, 4> m_scrollInertia;
|
||||||
};
|
};
|
||||||
|
@ -156,7 +156,7 @@ void View::HandleTimelineMouse( int64_t timespan, const ImVec2& wpos, float w, d
|
|||||||
|
|
||||||
int64_t nextTimelineRangeStart, nextTimelineRangeEnd;
|
int64_t nextTimelineRangeStart, nextTimelineRangeEnd;
|
||||||
bool anyDeltaApplied = false;
|
bool anyDeltaApplied = false;
|
||||||
if ( m_zoomAnim.active )
|
if( m_zoomAnim.active )
|
||||||
{
|
{
|
||||||
nextTimelineRangeStart = m_zoomAnim.start1;
|
nextTimelineRangeStart = m_zoomAnim.start1;
|
||||||
nextTimelineRangeEnd = m_zoomAnim.end1;
|
nextTimelineRangeEnd = m_zoomAnim.end1;
|
||||||
@ -173,11 +173,11 @@ void View::HandleTimelineMouse( int64_t timespan, const ImVec2& wpos, float w, d
|
|||||||
const auto moveInTimelineNanos = std::max<int64_t>( span / 10, 500 );
|
const auto moveInTimelineNanos = std::max<int64_t>( span / 10, 500 );
|
||||||
const auto movement = moveInTimelineNanos * std::max( std::min( io.DeltaTime, 0.25f ), 0.016f );
|
const auto movement = moveInTimelineNanos * std::max( std::min( io.DeltaTime, 0.25f ), 0.016f );
|
||||||
|
|
||||||
for (int direction = 0; direction < 4; direction++)
|
for( int direction = 0; direction < 4; direction++ )
|
||||||
{
|
{
|
||||||
auto& inertia = m_kbNavCtrl.m_scrollInertia[direction];
|
auto& inertia = m_kbNavCtrl.m_scrollInertia[direction];
|
||||||
|
|
||||||
if ( ImGui::IsKeyDown( KeyboardNavigation::DirectionToKeyMap[direction] ) )
|
if( ImGui::IsKeyDown( KeyboardNavigation::DirectionToKeyMap[direction] ) )
|
||||||
{
|
{
|
||||||
const auto timeStartDelta = movement * KeyboardNavigation::StartRangeMod[direction];
|
const auto timeStartDelta = movement * KeyboardNavigation::StartRangeMod[direction];
|
||||||
const auto timeEndDelta = movement * KeyboardNavigation::EndRangeMod[direction];
|
const auto timeEndDelta = movement * KeyboardNavigation::EndRangeMod[direction];
|
||||||
@ -187,7 +187,7 @@ void View::HandleTimelineMouse( int64_t timespan, const ImVec2& wpos, float w, d
|
|||||||
const auto mult = 1 + std::max( 0.0, 0.7 * std::pow( x, 1.6 ) - 0.8 * std::pow( x, 1.4 ) );
|
const auto mult = 1 + std::max( 0.0, 0.7 * std::pow( x, 1.6 ) - 0.8 * std::pow( x, 1.4 ) );
|
||||||
|
|
||||||
// If we are zooming in/out
|
// If we are zooming in/out
|
||||||
if ( direction > KeyboardNavigation::Right )
|
if( direction > KeyboardNavigation::Right )
|
||||||
{
|
{
|
||||||
// Bias if equal is 0.5. Multiply by 2 to offset back to the expected movement range.
|
// Bias if equal is 0.5. Multiply by 2 to offset back to the expected movement range.
|
||||||
nextTimelineRangeStart += timeStartDelta * mult * 2 * bias;
|
nextTimelineRangeStart += timeStartDelta * mult * 2 * bias;
|
||||||
@ -208,10 +208,10 @@ void View::HandleTimelineMouse( int64_t timespan, const ImVec2& wpos, float w, d
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( anyDeltaApplied )
|
if( anyDeltaApplied )
|
||||||
{
|
{
|
||||||
if( m_viewMode == ViewMode::LastFrames ) m_viewMode = ViewMode::LastRange;
|
if( m_viewMode == ViewMode::LastFrames ) m_viewMode = ViewMode::LastRange;
|
||||||
if ( nextTimelineRangeStart > nextTimelineRangeEnd ) return;
|
if( nextTimelineRangeStart > nextTimelineRangeEnd ) return;
|
||||||
|
|
||||||
// We want to cap the zoom at the range of values that the timeline has data for
|
// We want to cap the zoom at the range of values that the timeline has data for
|
||||||
const auto lastKnownTime = m_worker.GetLastTime();
|
const auto lastKnownTime = m_worker.GetLastTime();
|
||||||
@ -221,7 +221,7 @@ void View::HandleTimelineMouse( int64_t timespan, const ImVec2& wpos, float w, d
|
|||||||
nextTimelineRangeStart = std::max<int64_t>( std::min( nextTimelineRangeStart, lastKnownTime - 50 ), 0 );
|
nextTimelineRangeStart = std::max<int64_t>( std::min( nextTimelineRangeStart, lastKnownTime - 50 ), 0 );
|
||||||
nextTimelineRangeEnd = std::max<int64_t>( std::min( nextTimelineRangeEnd, lastKnownTime ), 1 );
|
nextTimelineRangeEnd = std::max<int64_t>( std::min( nextTimelineRangeEnd, lastKnownTime ), 1 );
|
||||||
|
|
||||||
if ( nextTimelineRangeEnd - nextTimelineRangeStart <= 50 ) return;
|
if( nextTimelineRangeEnd - nextTimelineRangeStart <= 50 ) return;
|
||||||
const auto shouldPause = m_viewMode == ViewMode::Paused || !m_worker.IsConnected();
|
const auto shouldPause = m_viewMode == ViewMode::Paused || !m_worker.IsConnected();
|
||||||
ZoomToRange( nextTimelineRangeStart, nextTimelineRangeEnd, shouldPause );
|
ZoomToRange( nextTimelineRangeStart, nextTimelineRangeEnd, shouldPause );
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user