Draw plot points in a separate function.

This commit is contained in:
Bartosz Taudul 2017-10-13 15:09:01 +02:00
parent d05827135d
commit f32114cb35
2 changed files with 9 additions and 2 deletions

View File

@ -2121,7 +2121,7 @@ int View::DrawPlots( int offset, double pxns, const ImVec2& wpos )
{ {
const auto x = ( it->time - m_zvStart ) * pxns; const auto x = ( it->time - m_zvStart ) * pxns;
const auto y = PlotHeight - ( it->val - min ) * revrange * PlotHeight; const auto y = PlotHeight - ( it->val - min ) * revrange * PlotHeight;
draw->AddRect( wpos + ImVec2( x - 1.5f, offset + y - 1.5f ), wpos + ImVec2( x + 2.5f, offset + y + 2.5f ), 0xFF44DDDD ); DrawPlotPoint( wpos, x, y, offset, 0xFF44DDDD );
} }
auto prev = it; auto prev = it;
@ -2134,7 +2134,7 @@ int View::DrawPlots( int offset, double pxns, const ImVec2& wpos )
const auto y1 = PlotHeight - ( it->val - min ) * revrange * PlotHeight; const auto y1 = PlotHeight - ( it->val - min ) * revrange * PlotHeight;
draw->AddLine( wpos + ImVec2( x0, offset + y0 ), wpos + ImVec2( x1, offset + y1 ), 0xFF44DDDD ); draw->AddLine( wpos + ImVec2( x0, offset + y0 ), wpos + ImVec2( x1, offset + y1 ), 0xFF44DDDD );
draw->AddRect( wpos + ImVec2( x1 - 1.5f, offset + y1 - 1.5f ), wpos + ImVec2( x1 + 2.5f, offset + y1 + 2.5f ), 0xFF44DDDD ); DrawPlotPoint( wpos, x1, y1, offset, 0xFF44DDDD );
prev = it; prev = it;
++it; ++it;
@ -2153,6 +2153,12 @@ int View::DrawPlots( int offset, double pxns, const ImVec2& wpos )
return offset; return offset;
} }
void View::DrawPlotPoint( const ImVec2& wpos, float x, float y, int offset, uint32_t color )
{
auto draw = ImGui::GetWindowDrawList();
draw->AddRect( wpos + ImVec2( x - 1.5f, offset + y - 1.5f ), wpos + ImVec2( x + 2.5f, offset + y + 2.5f ), color );
}
void View::DrawZoneInfoWindow() void View::DrawZoneInfoWindow()
{ {
if( !m_zoneInfoWindow ) return; if( !m_zoneInfoWindow ) return;

View File

@ -134,6 +134,7 @@ private:
int DrawLocks( uint64_t tid, bool hover, double pxns, const ImVec2& wpos, int offset, LockHighlight& highlight ); int DrawLocks( uint64_t tid, bool hover, double pxns, const ImVec2& wpos, int offset, LockHighlight& highlight );
void DrawZoneInfoWindow(); void DrawZoneInfoWindow();
int DrawPlots( int offset, double pxns, const ImVec2& wpos ); int DrawPlots( int offset, double pxns, const ImVec2& wpos );
void DrawPlotPoint( const ImVec2& wpos, float x, float y, int offset, uint32_t color );
void DrawOptions(); void DrawOptions();
void HandleZoneViewMouse( int64_t timespan, const ImVec2& wpos, float w, double& pxns ); void HandleZoneViewMouse( int64_t timespan, const ImVec2& wpos, float w, double& pxns );