mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-22 14:44:34 +00:00
Start extracting timeline height control logic.
This commit is contained in:
parent
b0ac78dde1
commit
c01ad38d46
@ -136,6 +136,7 @@
|
||||
<ClCompile Include="..\..\..\server\TracyTexture.cpp" />
|
||||
<ClCompile Include="..\..\..\server\TracyTextureCompression.cpp" />
|
||||
<ClCompile Include="..\..\..\server\TracyThreadCompress.cpp" />
|
||||
<ClCompile Include="..\..\..\server\TracyTimelineController.cpp" />
|
||||
<ClCompile Include="..\..\..\server\TracyUserData.cpp" />
|
||||
<ClCompile Include="..\..\..\server\TracyView.cpp" />
|
||||
<ClCompile Include="..\..\..\server\TracyView_Annotations.cpp" />
|
||||
@ -269,6 +270,7 @@
|
||||
<ClInclude Include="..\..\..\server\TracyTexture.hpp" />
|
||||
<ClInclude Include="..\..\..\server\TracyTextureCompression.hpp" />
|
||||
<ClInclude Include="..\..\..\server\TracyThreadCompress.hpp" />
|
||||
<ClInclude Include="..\..\..\server\TracyTimelineController.hpp" />
|
||||
<ClInclude Include="..\..\..\server\TracyUserData.hpp" />
|
||||
<ClInclude Include="..\..\..\server\TracyVarArray.hpp" />
|
||||
<ClInclude Include="..\..\..\server\TracyVector.hpp" />
|
||||
|
@ -351,6 +351,9 @@
|
||||
<ClCompile Include="..\..\src\ImGuiContext.cpp">
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\..\..\server\TracyTimelineController.cpp">
|
||||
<Filter>server</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="..\..\..\server\TracyEvent.hpp">
|
||||
@ -713,6 +716,9 @@
|
||||
<ClInclude Include="..\..\src\ImGuiContext.hpp">
|
||||
<Filter>src</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\..\..\server\TracyTimelineController.hpp">
|
||||
<Filter>server</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Natvis Include="DebugVis.natvis" />
|
||||
|
29
server/TracyTimelineController.cpp
Normal file
29
server/TracyTimelineController.cpp
Normal file
@ -0,0 +1,29 @@
|
||||
#include "imgui.h"
|
||||
|
||||
#include "TracyTimelineController.hpp"
|
||||
|
||||
namespace tracy
|
||||
{
|
||||
|
||||
TimelineController::TimelineController()
|
||||
: m_height( 0 )
|
||||
, m_offset( 0 )
|
||||
, m_scroll( 0 )
|
||||
{
|
||||
}
|
||||
|
||||
void TimelineController::End( float offset )
|
||||
{
|
||||
const auto scrollPos = ImGui::GetScrollY();
|
||||
if( scrollPos == 0 && m_scroll != 0 )
|
||||
{
|
||||
m_height = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( offset > m_height ) m_height = offset;
|
||||
}
|
||||
m_scroll = scrollPos;
|
||||
}
|
||||
|
||||
}
|
24
server/TracyTimelineController.hpp
Normal file
24
server/TracyTimelineController.hpp
Normal file
@ -0,0 +1,24 @@
|
||||
#ifndef __TRACYTIMELINECONTROLLER_HPP__
|
||||
#define __TRACYTIMELINECONTROLLER_HPP__
|
||||
|
||||
namespace tracy
|
||||
{
|
||||
|
||||
class TimelineController
|
||||
{
|
||||
public:
|
||||
TimelineController();
|
||||
|
||||
void End( float offset );
|
||||
|
||||
float GetHeight() const { return m_height; }
|
||||
|
||||
private:
|
||||
float m_height;
|
||||
float m_offset;
|
||||
float m_scroll;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@ -81,8 +81,10 @@ void UserData::LoadState( ViewData& data )
|
||||
{
|
||||
fread( &data.zvStart, 1, sizeof( data.zvStart ), f );
|
||||
fread( &data.zvEnd, 1, sizeof( data.zvEnd ), f );
|
||||
fread( &data.zvHeight, 1, sizeof( data.zvHeight ), f );
|
||||
fread( &data.zvScroll, 1, sizeof( data.zvScroll ), f );
|
||||
//fread( &data.zvHeight, 1, sizeof( data.zvHeight ), f );
|
||||
fseek( f, sizeof( float ), SEEK_CUR );
|
||||
//fread( &data.zvScroll, 1, sizeof( data.zvScroll ), f );
|
||||
fseek( f, sizeof( float ), SEEK_CUR );
|
||||
fread( &data.frameScale, 1, sizeof( data.frameScale ), f );
|
||||
fread( &data.frameStart, 1, sizeof( data.frameStart ), f );
|
||||
}
|
||||
@ -128,8 +130,11 @@ void UserData::SaveState( const ViewData& data )
|
||||
fwrite( &ver, 1, sizeof( ver ), f );
|
||||
fwrite( &data.zvStart, 1, sizeof( data.zvStart ), f );
|
||||
fwrite( &data.zvEnd, 1, sizeof( data.zvEnd ), f );
|
||||
fwrite( &data.zvHeight, 1, sizeof( data.zvHeight ), f );
|
||||
fwrite( &data.zvScroll, 1, sizeof( data.zvScroll ), f );
|
||||
//fwrite( &data.zvHeight, 1, sizeof( data.zvHeight ), f );
|
||||
float zero = 0;
|
||||
fwrite( &zero, 1, sizeof( zero ), f );
|
||||
//fwrite( &data.zvScroll, 1, sizeof( data.zvScroll ), f );
|
||||
fwrite( &zero, 1, sizeof( zero ), f );
|
||||
fwrite( &data.frameScale, 1, sizeof( data.frameScale ), f );
|
||||
fwrite( &data.frameStart, 1, sizeof( data.frameStart ), f );
|
||||
fclose( f );
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "TracyFileWrite.hpp"
|
||||
#include "TracyShortPtr.hpp"
|
||||
#include "TracySourceContents.hpp"
|
||||
#include "TracyTimelineController.hpp"
|
||||
#include "TracyUserData.hpp"
|
||||
#include "TracyVector.hpp"
|
||||
#include "TracyViewData.hpp"
|
||||
@ -402,6 +403,7 @@ private:
|
||||
uint64_t m_totalMemory;
|
||||
|
||||
ViewData m_vd;
|
||||
TimelineController m_tc;
|
||||
|
||||
const ZoneEvent* m_zoneInfoWindow = nullptr;
|
||||
const ZoneEvent* m_zoneHighlight;
|
||||
|
@ -35,8 +35,6 @@ struct ViewData
|
||||
{
|
||||
int64_t zvStart = 0;
|
||||
int64_t zvEnd = 0;
|
||||
int32_t zvHeight = 0;
|
||||
int32_t zvScroll = 0;
|
||||
int32_t frameScale = 0;
|
||||
int32_t frameStart = 0;
|
||||
|
||||
|
@ -285,7 +285,7 @@ void View::DrawTimeline()
|
||||
|
||||
const auto wpos = ImGui::GetCursorScreenPos();
|
||||
const auto dpos = wpos + ImVec2( 0.5f, 0.5f );
|
||||
const auto h = std::max<float>( m_vd.zvHeight, ImGui::GetContentRegionAvail().y - 4 ); // magic border value
|
||||
const auto h = std::max<float>( m_tc.GetHeight(), ImGui::GetContentRegionAvail().y - 4 ); // magic border value
|
||||
|
||||
ImGui::ItemSize( ImVec2( w, h ) );
|
||||
bool hover = ImGui::IsWindowHovered() && ImGui::IsMouseHoveringRect( wpos, wpos + ImVec2( w, h ) );
|
||||
@ -976,17 +976,7 @@ void View::DrawTimeline()
|
||||
offset = DrawPlots( offset, pxns, wpos, hover, yMin, yMax );
|
||||
}
|
||||
|
||||
const auto scrollPos = ImGui::GetScrollY();
|
||||
if( scrollPos == 0 && m_vd.zvScroll != 0 )
|
||||
{
|
||||
m_vd.zvHeight = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( offset > m_vd.zvHeight ) m_vd.zvHeight = offset;
|
||||
}
|
||||
m_vd.zvScroll = scrollPos;
|
||||
|
||||
m_tc.End( offset );
|
||||
ImGui::EndChild();
|
||||
|
||||
for( auto& ann : m_annotations )
|
||||
|
Loading…
Reference in New Issue
Block a user