Zoom in/out in zone view.

This commit is contained in:
Bartosz Taudul 2017-09-21 01:39:07 +02:00
parent a353a7601d
commit 2f645c589d

View File

@ -645,8 +645,8 @@ void View::DrawZones()
ImGui::InvisibleButton( "##zones", ImVec2( w, h ) ); ImGui::InvisibleButton( "##zones", ImVec2( w, h ) );
bool hover = ImGui::IsItemHovered(); bool hover = ImGui::IsItemHovered();
const auto timespan = m_zvEnd - m_zvStart; auto timespan = m_zvEnd - m_zvStart;
const auto pxns = w / double( timespan ); auto pxns = w / double( timespan );
if( hover ) if( hover )
{ {
@ -659,6 +659,28 @@ void View::DrawZones()
m_zvEnd -= delta * nspx; m_zvEnd -= delta * nspx;
io.MouseClickedPos[1].x = io.MousePos.x; io.MouseClickedPos[1].x = io.MousePos.x;
} }
const auto wheel = io.MouseWheel;
if( wheel != 0 )
{
m_pause = true;
const double mouse = io.MousePos.x - wpos.x;
const auto p = mouse / w;
const auto p1 = timespan * p;
const auto p2 = timespan - p1;
if( wheel > 0 )
{
m_zvStart += int64_t( p1 * 0.1f );
m_zvEnd -= int64_t( p2 * 0.1f );
}
else if( timespan < 1000ull * 1000 * 1000 * 60 )
{
m_zvStart -= std::max( 1ll, int64_t( p1 * 0.1f ) );
m_zvEnd += std::max( 1ll, int64_t( p2 * 0.1f ) );
}
timespan = m_zvEnd - m_zvStart;
pxns = w / double( timespan );
}
} }
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 );