2022-08-15 11:29:45 +00:00
|
|
|
#ifndef __TRACYTIMELINECONTROLLER_HPP__
|
|
|
|
#define __TRACYTIMELINECONTROLLER_HPP__
|
|
|
|
|
2022-09-03 14:47:41 +00:00
|
|
|
#include <assert.h>
|
2023-01-27 19:00:05 +00:00
|
|
|
#include <optional>
|
2022-09-03 14:41:17 +00:00
|
|
|
#include <vector>
|
|
|
|
|
2023-03-18 16:03:23 +00:00
|
|
|
#include "TracyImGui.hpp"
|
2023-03-19 17:54:32 +00:00
|
|
|
#include "TracyTaskDispatch.hpp"
|
2022-08-20 15:02:29 +00:00
|
|
|
#include "../public/common/TracyForceInline.hpp"
|
|
|
|
#include "tracy_robin_hood.h"
|
|
|
|
|
2022-08-15 11:29:45 +00:00
|
|
|
namespace tracy
|
|
|
|
{
|
|
|
|
|
2023-03-18 16:03:23 +00:00
|
|
|
class TimelineItem;
|
|
|
|
class View;
|
|
|
|
class Worker;
|
|
|
|
|
2022-08-15 11:29:45 +00:00
|
|
|
class TimelineController
|
|
|
|
{
|
|
|
|
public:
|
2022-09-03 16:34:11 +00:00
|
|
|
TimelineController( View& view, Worker& worker );
|
2023-03-18 16:03:23 +00:00
|
|
|
~TimelineController();
|
2022-08-15 11:29:45 +00:00
|
|
|
|
2022-08-20 15:02:29 +00:00
|
|
|
void FirstFrameExpired();
|
2022-09-03 14:45:53 +00:00
|
|
|
void Begin();
|
2023-01-27 19:00:05 +00:00
|
|
|
void End( double pxns, const ImVec2& wpos, bool hover, bool vcenter, float yMin, float yMax );
|
2022-08-15 11:29:45 +00:00
|
|
|
|
2022-09-03 14:41:17 +00:00
|
|
|
template<class T, class U>
|
|
|
|
void AddItem( U* data )
|
|
|
|
{
|
|
|
|
auto it = m_itemMap.find( data );
|
|
|
|
if( it == m_itemMap.end() ) it = m_itemMap.emplace( data, std::make_unique<T>( m_view, m_worker, data ) ).first;
|
|
|
|
m_items.emplace_back( it->second.get() );
|
|
|
|
}
|
|
|
|
|
2022-08-15 11:29:45 +00:00
|
|
|
float GetHeight() const { return m_height; }
|
2022-09-03 21:43:17 +00:00
|
|
|
const unordered_flat_map<const void*, std::unique_ptr<TimelineItem>>& GetItemMap() const { return m_itemMap; }
|
2022-08-20 15:02:29 +00:00
|
|
|
|
2022-09-03 14:47:41 +00:00
|
|
|
tracy_force_inline TimelineItem& GetItem( const void* data )
|
|
|
|
{
|
|
|
|
auto it = m_itemMap.find( data );
|
|
|
|
assert( it != m_itemMap.end() );
|
|
|
|
return *it->second;
|
|
|
|
}
|
|
|
|
|
2022-08-15 11:29:45 +00:00
|
|
|
private:
|
2023-01-27 19:00:05 +00:00
|
|
|
void UpdateCenterItem();
|
|
|
|
std::optional<int> CalculateScrollPosition() const;
|
|
|
|
|
2022-09-03 14:41:17 +00:00
|
|
|
std::vector<TimelineItem*> m_items;
|
|
|
|
unordered_flat_map<const void*, std::unique_ptr<TimelineItem>> m_itemMap;
|
|
|
|
|
2022-08-15 11:29:45 +00:00
|
|
|
float m_height;
|
|
|
|
float m_scroll;
|
2022-08-20 15:02:29 +00:00
|
|
|
|
2023-01-27 19:00:05 +00:00
|
|
|
const void* m_centerItemkey;
|
|
|
|
int m_centerItemOffsetY;
|
|
|
|
|
2022-08-20 15:02:29 +00:00
|
|
|
bool m_firstFrame;
|
2022-09-03 14:38:39 +00:00
|
|
|
|
|
|
|
View& m_view;
|
2022-09-03 16:34:11 +00:00
|
|
|
Worker& m_worker;
|
2023-03-19 17:54:32 +00:00
|
|
|
|
|
|
|
TaskDispatch m_td;
|
2022-08-15 11:29:45 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|