Scrolling zone view.

This commit is contained in:
Bartosz Taudul 2017-09-21 01:13:23 +02:00
parent c3df475de7
commit b725be87c7
2 changed files with 23 additions and 6 deletions

View File

@ -604,7 +604,8 @@ void View::DrawFrames()
const auto zitbegin = std::lower_bound( m_frames.begin(), m_frames.end(), m_zvStart ); const auto zitbegin = std::lower_bound( m_frames.begin(), m_frames.end(), m_zvStart );
const auto zitend = std::lower_bound( m_frames.begin(), m_frames.end(), m_zvEnd ); const auto zitend = std::lower_bound( m_frames.begin(), m_frames.end(), m_zvEnd );
const auto zbegin = (int)std::distance( m_frames.begin(), zitbegin ); auto zbegin = (int)std::distance( m_frames.begin(), zitbegin );
if( zbegin > 0 && *zitbegin != m_zvStart ) zbegin--;
const auto zend = (int)std::distance( m_frames.begin(), zitend ); const auto zend = (int)std::distance( m_frames.begin(), zitend );
if( zend > m_frameStart && zbegin < m_frameStart + onScreen * group ) if( zend > m_frameStart && zbegin < m_frameStart + onScreen * group )
@ -632,6 +633,8 @@ void View::DrawZones()
ImGuiWindow* window = ImGui::GetCurrentWindow(); ImGuiWindow* window = ImGui::GetCurrentWindow();
if( window->SkipItems ) return; if( window->SkipItems ) return;
auto& io = ImGui::GetIO();
const auto wpos = ImGui::GetCursorScreenPos(); const auto wpos = ImGui::GetCursorScreenPos();
const auto w = ImGui::GetWindowContentRegionWidth(); const auto w = ImGui::GetWindowContentRegionWidth();
const auto h = ImGui::GetContentRegionAvail().y; const auto h = ImGui::GetContentRegionAvail().y;
@ -645,17 +648,31 @@ void View::DrawZones()
const auto timespan = m_zvEnd - m_zvStart; const auto timespan = m_zvEnd - m_zvStart;
const auto pxns = w / double( timespan ); const auto pxns = w / double( timespan );
if( hover )
{
if( ImGui::IsMouseDragging( 1, 0 ) )
{
m_pause = true;
const auto delta = ImGui::GetMouseDragDelta( 1, 0 ).x;
const auto nspx = double( timespan ) / w;
m_zvStart -= delta * nspx;
m_zvEnd -= delta * nspx;
io.MouseClickedPos[1].x = io.MousePos.x;
}
}
const auto zitbegin = std::lower_bound( m_frames.begin(), m_frames.end(), m_zvStart ); const auto zitbegin = std::lower_bound( m_frames.begin(), m_frames.end(), m_zvStart );
const auto zitend = std::lower_bound( m_frames.begin(), m_frames.end(), m_zvEnd ); const auto zitend = std::lower_bound( m_frames.begin(), m_frames.end(), m_zvEnd );
const auto zbegin = (int)std::distance( m_frames.begin(), zitbegin ); auto zbegin = (int)std::distance( m_frames.begin(), zitbegin );
if( zbegin > 0 && *zitbegin != m_zvStart ) zbegin--;
const auto zend = (int)std::distance( m_frames.begin(), zitend ); const auto zend = (int)std::distance( m_frames.begin(), zitend );
for( int i=zbegin; i<zend; i++ ) for( int i=zbegin; i<zend; i++ )
{ {
const auto ftime = GetFrameTime( i ); const auto ftime = GetFrameTime( i );
const auto fbegin = GetFrameBegin( i ); const auto fbegin = (int64_t)GetFrameBegin( i );
const auto fend = GetFrameEnd( i ); const auto fend = (int64_t)GetFrameEnd( i );
char buf[128]; char buf[128];
sprintf( buf, "Frame %i (%s)", i, TimeToString( ftime ) ); sprintf( buf, "Frame %i (%s)", i, TimeToString( ftime ) );

View File

@ -90,8 +90,8 @@ private:
bool m_pause; bool m_pause;
int m_frameStart; int m_frameStart;
uint64_t m_zvStart; int64_t m_zvStart;
uint64_t m_zvEnd; int64_t m_zvEnd;
}; };
} }