mirror of
https://github.com/wolfpld/tracy.git
synced 2025-03-20 07:40:02 +08:00
Set owner of file dialogs on windows.
This commit is contained in:
@@ -68,7 +68,7 @@ static SourceView::RegsX86 s_regMapX86[X86_REG_ENDING];
|
||||
enum { JumpSeparation = 6 };
|
||||
enum { JumpArrowBase = 9 };
|
||||
|
||||
SourceView::SourceView( ImFont* font )
|
||||
SourceView::SourceView( ImFont* font, GetWindowCallback gwcb )
|
||||
: m_font( font )
|
||||
, m_file( nullptr )
|
||||
, m_fileStringIdx( 0 )
|
||||
@@ -93,6 +93,7 @@ SourceView::SourceView( ImFont* font )
|
||||
, m_showJumps( true )
|
||||
, m_cpuArch( CpuArchUnknown )
|
||||
, m_showLatency( false )
|
||||
, m_gwcb( gwcb )
|
||||
{
|
||||
m_microArchOpMap.reserve( OpsNum );
|
||||
for( int i=0; i<OpsNum; i++ )
|
||||
@@ -3537,7 +3538,7 @@ void SourceView::Save( const Worker& worker, size_t start, size_t stop )
|
||||
assert( start < stop );
|
||||
|
||||
nfdchar_t* fn;
|
||||
auto res = NFD_SaveDialog( "asm", nullptr, &fn );
|
||||
auto res = NFD_SaveDialog( "asm", nullptr, &fn, m_gwcb ? m_gwcb() : nullptr );
|
||||
if( res == NFD_OKAY )
|
||||
{
|
||||
FILE* f = nullptr;
|
||||
|
||||
@@ -127,7 +127,9 @@ private:
|
||||
};
|
||||
|
||||
public:
|
||||
SourceView( ImFont* font );
|
||||
using GetWindowCallback = void*(*)();
|
||||
|
||||
SourceView( ImFont* font, GetWindowCallback gwcb );
|
||||
~SourceView();
|
||||
|
||||
void SetCpuId( uint32_t cpuid );
|
||||
@@ -242,6 +244,8 @@ private:
|
||||
|
||||
float m_srcWidth;
|
||||
float m_asmWidth;
|
||||
|
||||
GetWindowCallback m_gwcb;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ enum { MinFrameSize = 5 };
|
||||
|
||||
static View* s_instance = nullptr;
|
||||
|
||||
View::View( const char* addr, int port, ImFont* fixedWidth, ImFont* smallFont, ImFont* bigFont, SetTitleCallback stcb )
|
||||
View::View( const char* addr, int port, ImFont* fixedWidth, ImFont* smallFont, ImFont* bigFont, SetTitleCallback stcb, GetWindowCallback gwcb )
|
||||
: m_worker( addr, port )
|
||||
, m_staticView( false )
|
||||
, m_pause( false )
|
||||
@@ -139,6 +139,7 @@ View::View( const char* addr, int port, ImFont* fixedWidth, ImFont* smallFont, I
|
||||
, m_smallFont( smallFont )
|
||||
, m_bigFont( bigFont )
|
||||
, m_stcb( stcb )
|
||||
, m_gwcb( gwcb )
|
||||
, m_userData()
|
||||
{
|
||||
assert( s_instance == nullptr );
|
||||
@@ -147,7 +148,7 @@ View::View( const char* addr, int port, ImFont* fixedWidth, ImFont* smallFont, I
|
||||
InitTextEditor( fixedWidth );
|
||||
}
|
||||
|
||||
View::View( FileRead& f, ImFont* fixedWidth, ImFont* smallFont, ImFont* bigFont, SetTitleCallback stcb )
|
||||
View::View( FileRead& f, ImFont* fixedWidth, ImFont* smallFont, ImFont* bigFont, SetTitleCallback stcb, GetWindowCallback gwcb )
|
||||
: m_worker( f )
|
||||
, m_filename( f.GetFilename() )
|
||||
, m_staticView( true )
|
||||
@@ -157,6 +158,7 @@ View::View( FileRead& f, ImFont* fixedWidth, ImFont* smallFont, ImFont* bigFont,
|
||||
, m_smallFont( smallFont )
|
||||
, m_bigFont( bigFont )
|
||||
, m_stcb( stcb )
|
||||
, m_gwcb( gwcb )
|
||||
, m_userData( m_worker.GetCaptureProgram().c_str(), m_worker.GetCaptureTime() )
|
||||
{
|
||||
assert( s_instance == nullptr );
|
||||
@@ -196,7 +198,7 @@ View::~View()
|
||||
|
||||
void View::InitTextEditor( ImFont* font )
|
||||
{
|
||||
m_sourceView = std::make_unique<SourceView>( font );
|
||||
m_sourceView = std::make_unique<SourceView>( font, m_gwcb );
|
||||
m_sourceViewFile = nullptr;
|
||||
}
|
||||
|
||||
@@ -1120,7 +1122,7 @@ bool View::DrawConnection()
|
||||
{
|
||||
#ifndef TRACY_NO_FILESELECTOR
|
||||
nfdchar_t* fn;
|
||||
auto res = NFD_SaveDialog( "tracy", nullptr, &fn );
|
||||
auto res = NFD_SaveDialog( "tracy", nullptr, &fn, m_gwcb ? m_gwcb() : nullptr );
|
||||
if( res == NFD_OKAY )
|
||||
#else
|
||||
const char* fn = "trace.tracy";
|
||||
@@ -10312,7 +10314,7 @@ void View::DrawCompare()
|
||||
if( ImGui::Button( ICON_FA_FOLDER_OPEN " Open second trace" ) && !m_compare.loadThread.joinable() )
|
||||
{
|
||||
nfdchar_t* fn;
|
||||
auto res = NFD_OpenDialog( "tracy", nullptr, &fn );
|
||||
auto res = NFD_OpenDialog( "tracy", nullptr, &fn, m_gwcb ? m_gwcb() : nullptr );
|
||||
if( res == NFD_OKAY )
|
||||
{
|
||||
try
|
||||
|
||||
@@ -73,10 +73,11 @@ public:
|
||||
};
|
||||
|
||||
using SetTitleCallback = void(*)( const char* );
|
||||
using GetWindowCallback = void*(*)();
|
||||
|
||||
View( ImFont* fixedWidth = nullptr, ImFont* smallFont = nullptr, ImFont* bigFont = nullptr, SetTitleCallback stcb = nullptr ) : View( "127.0.0.1", 8086, fixedWidth, smallFont, bigFont, stcb ) {}
|
||||
View( const char* addr, int port, ImFont* fixedWidth = nullptr, ImFont* smallFont = nullptr, ImFont* bigFont = nullptr, SetTitleCallback stcb = nullptr );
|
||||
View( FileRead& f, ImFont* fixedWidth = nullptr, ImFont* smallFont = nullptr, ImFont* bigFont = nullptr, SetTitleCallback stcb = nullptr );
|
||||
View( ImFont* fixedWidth = nullptr, ImFont* smallFont = nullptr, ImFont* bigFont = nullptr, SetTitleCallback stcb = nullptr, GetWindowCallback gwcb = nullptr ) : View( "127.0.0.1", 8086, fixedWidth, smallFont, bigFont, stcb, gwcb ) {}
|
||||
View( const char* addr, int port, ImFont* fixedWidth = nullptr, ImFont* smallFont = nullptr, ImFont* bigFont = nullptr, SetTitleCallback stcb = nullptr, GetWindowCallback gwcb = nullptr );
|
||||
View( FileRead& f, ImFont* fixedWidth = nullptr, ImFont* smallFont = nullptr, ImFont* bigFont = nullptr, SetTitleCallback stcb = nullptr, GetWindowCallback gwcb = nullptr );
|
||||
~View();
|
||||
|
||||
static bool Draw();
|
||||
@@ -402,6 +403,7 @@ private:
|
||||
float m_rootWidth, m_rootHeight;
|
||||
SetTitleCallback m_stcb;
|
||||
bool m_titleSet = false;
|
||||
GetWindowCallback m_gwcb;
|
||||
|
||||
float m_notificationTime = 0;
|
||||
std::string m_notificationText;
|
||||
|
||||
Reference in New Issue
Block a user