mirror of
https://github.com/wolfpld/tracy
synced 2025-04-30 20:53:52 +00:00
Hook up attention callback.
This commit is contained in:
parent
575f627136
commit
c89c4f46ea
@ -105,6 +105,11 @@ static void SetWindowTitleCallback( const char* title )
|
|||||||
s_customTitle = true;
|
s_customTitle = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void AttentionCallback()
|
||||||
|
{
|
||||||
|
bptr->Attention();
|
||||||
|
}
|
||||||
|
|
||||||
static void DrawContents();
|
static void DrawContents();
|
||||||
|
|
||||||
void RunOnMainThread( std::function<void()> cb, bool forceDelay = false )
|
void RunOnMainThread( std::function<void()> cb, bool forceDelay = false )
|
||||||
@ -233,12 +238,12 @@ int main( int argc, char** argv )
|
|||||||
|
|
||||||
if( initFileOpen )
|
if( initFileOpen )
|
||||||
{
|
{
|
||||||
view = std::make_unique<tracy::View>( RunOnMainThread, *initFileOpen, s_fixedWidth, s_smallFont, s_bigFont, SetWindowTitleCallback, SetupScaleCallback );
|
view = std::make_unique<tracy::View>( RunOnMainThread, *initFileOpen, s_fixedWidth, s_smallFont, s_bigFont, SetWindowTitleCallback, SetupScaleCallback, AttentionCallback );
|
||||||
initFileOpen.reset();
|
initFileOpen.reset();
|
||||||
}
|
}
|
||||||
else if( connectTo )
|
else if( connectTo )
|
||||||
{
|
{
|
||||||
view = std::make_unique<tracy::View>( RunOnMainThread, connectTo, port, s_fixedWidth, s_smallFont, s_bigFont, SetWindowTitleCallback, SetupScaleCallback );
|
view = std::make_unique<tracy::View>( RunOnMainThread, connectTo, port, s_fixedWidth, s_smallFont, s_bigFont, SetWindowTitleCallback, SetupScaleCallback, AttentionCallback );
|
||||||
}
|
}
|
||||||
|
|
||||||
tracy::Fileselector::Init();
|
tracy::Fileselector::Init();
|
||||||
@ -570,11 +575,11 @@ static void DrawContents()
|
|||||||
{
|
{
|
||||||
std::string addrPart = std::string( addr, ptr );
|
std::string addrPart = std::string( addr, ptr );
|
||||||
uint16_t portPart = (uint16_t)atoi( ptr+1 );
|
uint16_t portPart = (uint16_t)atoi( ptr+1 );
|
||||||
view = std::make_unique<tracy::View>( RunOnMainThread, addrPart.c_str(), portPart, s_fixedWidth, s_smallFont, s_bigFont, SetWindowTitleCallback, SetupScaleCallback );
|
view = std::make_unique<tracy::View>( RunOnMainThread, addrPart.c_str(), portPart, s_fixedWidth, s_smallFont, s_bigFont, SetWindowTitleCallback, SetupScaleCallback, AttentionCallback );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
view = std::make_unique<tracy::View>( RunOnMainThread, addr, port, s_fixedWidth, s_smallFont, s_bigFont, SetWindowTitleCallback, SetupScaleCallback );
|
view = std::make_unique<tracy::View>( RunOnMainThread, addr, port, s_fixedWidth, s_smallFont, s_bigFont, SetWindowTitleCallback, SetupScaleCallback, AttentionCallback );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ImGui::SameLine( 0, ImGui::GetTextLineHeight() * 2 );
|
ImGui::SameLine( 0, ImGui::GetTextLineHeight() * 2 );
|
||||||
@ -591,7 +596,7 @@ static void DrawContents()
|
|||||||
loadThread = std::thread( [f] {
|
loadThread = std::thread( [f] {
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
view = std::make_unique<tracy::View>( RunOnMainThread, *f, s_fixedWidth, s_smallFont, s_bigFont, SetWindowTitleCallback, SetupScaleCallback );
|
view = std::make_unique<tracy::View>( RunOnMainThread, *f, s_fixedWidth, s_smallFont, s_bigFont, SetWindowTitleCallback, SetupScaleCallback, AttentionCallback );
|
||||||
}
|
}
|
||||||
catch( const tracy::UnsupportedVersion& e )
|
catch( const tracy::UnsupportedVersion& e )
|
||||||
{
|
{
|
||||||
@ -716,7 +721,7 @@ static void DrawContents()
|
|||||||
}
|
}
|
||||||
if( selected && !loadThread.joinable() )
|
if( selected && !loadThread.joinable() )
|
||||||
{
|
{
|
||||||
view = std::make_unique<tracy::View>( RunOnMainThread, v.second.address.c_str(), v.second.port, s_fixedWidth, s_smallFont, s_bigFont, SetWindowTitleCallback, SetupScaleCallback );
|
view = std::make_unique<tracy::View>( RunOnMainThread, v.second.address.c_str(), v.second.port, s_fixedWidth, s_smallFont, s_bigFont, SetWindowTitleCallback, SetupScaleCallback, AttentionCallback );
|
||||||
}
|
}
|
||||||
ImGui::NextColumn();
|
ImGui::NextColumn();
|
||||||
const auto acttime = ( v.second.activeTime + ( time - v.second.time ) / 1000 ) * 1000000000ll;
|
const auto acttime = ( v.second.activeTime + ( time - v.second.time ) / 1000 ) * 1000000000ll;
|
||||||
@ -885,7 +890,7 @@ static void DrawContents()
|
|||||||
viewShutdown.store( ViewShutdown::False, std::memory_order_relaxed );
|
viewShutdown.store( ViewShutdown::False, std::memory_order_relaxed );
|
||||||
if( reconnect )
|
if( reconnect )
|
||||||
{
|
{
|
||||||
view = std::make_unique<tracy::View>( RunOnMainThread, reconnectAddr.c_str(), reconnectPort, s_fixedWidth, s_smallFont, s_bigFont, SetWindowTitleCallback, SetupScaleCallback );
|
view = std::make_unique<tracy::View>( RunOnMainThread, reconnectAddr.c_str(), reconnectPort, s_fixedWidth, s_smallFont, s_bigFont, SetWindowTitleCallback, SetupScaleCallback, AttentionCallback );
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -46,7 +46,7 @@ double s_time = 0;
|
|||||||
|
|
||||||
static View* s_instance = nullptr;
|
static View* s_instance = nullptr;
|
||||||
|
|
||||||
View::View( void(*cbMainThread)(std::function<void()>, bool), const char* addr, uint16_t port, ImFont* fixedWidth, ImFont* smallFont, ImFont* bigFont, SetTitleCallback stcb, SetScaleCallback sscb )
|
View::View( void(*cbMainThread)(std::function<void()>, bool), const char* addr, uint16_t port, ImFont* fixedWidth, ImFont* smallFont, ImFont* bigFont, SetTitleCallback stcb, SetScaleCallback sscb, AttentionCallback acb )
|
||||||
: m_worker( addr, port )
|
: m_worker( addr, port )
|
||||||
, m_staticView( false )
|
, m_staticView( false )
|
||||||
, m_viewMode( ViewMode::LastFrames )
|
, m_viewMode( ViewMode::LastFrames )
|
||||||
@ -62,6 +62,7 @@ View::View( void(*cbMainThread)(std::function<void()>, bool), const char* addr,
|
|||||||
, m_fixedFont( fixedWidth )
|
, m_fixedFont( fixedWidth )
|
||||||
, m_stcb( stcb )
|
, m_stcb( stcb )
|
||||||
, m_sscb( sscb )
|
, m_sscb( sscb )
|
||||||
|
, m_acb( acb )
|
||||||
, m_userData()
|
, m_userData()
|
||||||
, m_cbMainThread( cbMainThread )
|
, m_cbMainThread( cbMainThread )
|
||||||
{
|
{
|
||||||
@ -72,7 +73,7 @@ View::View( void(*cbMainThread)(std::function<void()>, bool), const char* addr,
|
|||||||
InitTextEditor( fixedWidth );
|
InitTextEditor( fixedWidth );
|
||||||
}
|
}
|
||||||
|
|
||||||
View::View( void(*cbMainThread)(std::function<void()>, bool), FileRead& f, ImFont* fixedWidth, ImFont* smallFont, ImFont* bigFont, SetTitleCallback stcb, SetScaleCallback sscb )
|
View::View( void(*cbMainThread)(std::function<void()>, bool), FileRead& f, ImFont* fixedWidth, ImFont* smallFont, ImFont* bigFont, SetTitleCallback stcb, SetScaleCallback sscb, AttentionCallback acb )
|
||||||
: m_worker( f )
|
: m_worker( f )
|
||||||
, m_filename( f.GetFilename() )
|
, m_filename( f.GetFilename() )
|
||||||
, m_staticView( true )
|
, m_staticView( true )
|
||||||
@ -85,6 +86,7 @@ View::View( void(*cbMainThread)(std::function<void()>, bool), FileRead& f, ImFon
|
|||||||
, m_fixedFont( fixedWidth )
|
, m_fixedFont( fixedWidth )
|
||||||
, m_stcb( stcb )
|
, m_stcb( stcb )
|
||||||
, m_sscb( sscb )
|
, m_sscb( sscb )
|
||||||
|
, m_acb( acb )
|
||||||
, m_userData( m_worker.GetCaptureProgram().c_str(), m_worker.GetCaptureTime() )
|
, m_userData( m_worker.GetCaptureProgram().c_str(), m_worker.GetCaptureTime() )
|
||||||
, m_cbMainThread( cbMainThread )
|
, m_cbMainThread( cbMainThread )
|
||||||
{
|
{
|
||||||
|
@ -89,9 +89,10 @@ public:
|
|||||||
|
|
||||||
using SetTitleCallback = void(*)( const char* );
|
using SetTitleCallback = void(*)( const char* );
|
||||||
using SetScaleCallback = void(*)( float, ImFont*&, ImFont*&, ImFont*& );
|
using SetScaleCallback = void(*)( float, ImFont*&, ImFont*&, ImFont*& );
|
||||||
|
using AttentionCallback = void(*)();
|
||||||
|
|
||||||
View( void(*cbMainThread)(std::function<void()>, bool), const char* addr, uint16_t port, ImFont* fixedWidth, ImFont* smallFont, ImFont* bigFont, SetTitleCallback stcb, SetScaleCallback sscb );
|
View( void(*cbMainThread)(std::function<void()>, bool), const char* addr, uint16_t port, ImFont* fixedWidth, ImFont* smallFont, ImFont* bigFont, SetTitleCallback stcb, SetScaleCallback sscb, AttentionCallback acb );
|
||||||
View( void(*cbMainThread)(std::function<void()>, bool), FileRead& f, ImFont* fixedWidth, ImFont* smallFont, ImFont* bigFont, SetTitleCallback stcb, SetScaleCallback sscb );
|
View( void(*cbMainThread)(std::function<void()>, bool), FileRead& f, ImFont* fixedWidth, ImFont* smallFont, ImFont* bigFont, SetTitleCallback stcb, SetScaleCallback sscb, AttentionCallback acb );
|
||||||
~View();
|
~View();
|
||||||
|
|
||||||
static bool Draw();
|
static bool Draw();
|
||||||
@ -517,6 +518,7 @@ private:
|
|||||||
SetTitleCallback m_stcb;
|
SetTitleCallback m_stcb;
|
||||||
bool m_titleSet = false;
|
bool m_titleSet = false;
|
||||||
SetScaleCallback m_sscb;
|
SetScaleCallback m_sscb;
|
||||||
|
AttentionCallback m_acb;
|
||||||
|
|
||||||
float m_notificationTime = 0;
|
float m_notificationTime = 0;
|
||||||
std::string m_notificationText;
|
std::string m_notificationText;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user