Don't enforce main window buttons width.

This commit is contained in:
Bartosz Taudul 2018-04-21 22:42:32 +02:00
parent 880eb7cbdd
commit 1d044b494b

View File

@ -281,6 +281,13 @@ void View::Draw()
s_instance->DrawImpl();
}
static const char* MainWindowButtons[] = {
"Resume",
"Pause"
};
enum { MainWindowButtonsCount = sizeof( MainWindowButtons ) / sizeof( *MainWindowButtons ) };
void View::DrawImpl()
{
if( !m_worker.HasData() )
@ -297,24 +304,29 @@ void View::DrawImpl()
}
const auto th = ImGui::GetTextLineHeight();
const auto bw = 6 * th;
float bw = 0;
for( int i=0; i<MainWindowButtonsCount; i++ )
{
bw = std::max( bw, ImGui::CalcTextSize( MainWindowButtons[i] ).x );
}
bw += th;
std::lock_guard<NonRecursiveBenaphore> lock( m_worker.GetDataLock() );
ImGui::Begin( m_worker.GetCaptureName().c_str(), nullptr, ImVec2( 1550, 800 ), -1, ImGuiWindowFlags_NoScrollbar );
if( !m_worker.IsDataStatic() )
{
if( ImGui::Button( m_pause ? "Resume" : "Pause", ImVec2( bw, 0 ) ) ) m_pause = !m_pause;
if( ImGui::Button( m_pause ? MainWindowButtons[0] : MainWindowButtons[1], ImVec2( bw, 0 ) ) ) m_pause = !m_pause;
ImGui::SameLine();
}
if( ImGui::Button( "Options", ImVec2( bw, 0 ) ) ) m_showOptions = true;
if( ImGui::Button( "Options" ) ) m_showOptions = true;
ImGui::SameLine();
if( ImGui::Button( "Messages", ImVec2( bw, 0 ) ) ) m_showMessages = true;
if( ImGui::Button( "Messages" ) ) m_showMessages = true;
ImGui::SameLine();
if( ImGui::Button( "Find Zone", ImVec2( bw, 0 ) ) ) m_findZone.show = true;
if( ImGui::Button( "Find Zone" ) ) m_findZone.show = true;
ImGui::SameLine();
if( ImGui::Button( "Statistics", ImVec2( bw, 0 ) ) ) m_showStatistics = true;
if( ImGui::Button( "Statistics" ) ) m_showStatistics = true;
ImGui::SameLine();
if( ImGui::Button( "Memory", ImVec2( bw, 0 ) ) ) m_memInfo.show = true;
if( ImGui::Button( "Memory" ) ) m_memInfo.show = true;
ImGui::SameLine();
ImGui::Text( "Frames: %-7" PRIu64 " Time span: %-10s View span: %-10s Zones: %-13s Queue delay: %s Timer resolution: %s", m_worker.GetFrameCount(), TimeToString( m_worker.GetLastTime() - m_worker.GetFrameBegin( 0 ) ), TimeToString( m_zvEnd - m_zvStart ), RealToString( m_worker.GetZoneCount(), true ), TimeToString( m_worker.GetDelay() ), TimeToString( m_worker.GetResolution() ) );
DrawFrames();