Add imgui window size constraints helper.

This commit is contained in:
Bartosz Taudul
2026-07-18 13:04:49 +02:00
parent f08792f217
commit 3608d0c271
3 changed files with 47 additions and 0 deletions

View File

@@ -123,6 +123,7 @@ set(SERVER_FILES
TracyView_ZoneInfo.cpp
TracyView_ZoneTimeline.cpp
TracyWeb.cpp
TracyWindowConstraints.cpp
)
if(NOT EMSCRIPTEN)

View File

@@ -0,0 +1,26 @@
#include <algorithm>
#include <imgui.h>
#include "TracyWindowConstraints.hpp"
namespace tracy
{
void WindowConstraints::Reset()
{
m_minWidth = 0;
}
void WindowConstraints::Constrain() const
{
ImGui::SetNextWindowSizeConstraints( ImVec2( m_minWidth, 0 ), ImVec2( FLT_MAX, FLT_MAX ) );
}
void WindowConstraints::MarkMinWidth()
{
ImGui::SameLine();
m_minWidth = std::max( m_minWidth, ImGui::GetCursorPosX() );
ImGui::NewLine();
}
}

View File

@@ -0,0 +1,20 @@
#ifndef __TRACYWINDOWCONSTRAINTS_HPP__
#define __TRACYWINDOWCONSTRAINTS_HPP__
namespace tracy
{
class WindowConstraints
{
public:
void Reset();
void Constrain() const;
void MarkMinWidth();
private:
float m_minWidth = 0;
};
}
#endif