diff --git a/profiler/CMakeLists.txt b/profiler/CMakeLists.txt index 885dbe73..daee5b64 100644 --- a/profiler/CMakeLists.txt +++ b/profiler/CMakeLists.txt @@ -123,6 +123,7 @@ set(SERVER_FILES TracyView_ZoneInfo.cpp TracyView_ZoneTimeline.cpp TracyWeb.cpp + TracyWindowConstraints.cpp ) if(NOT EMSCRIPTEN) diff --git a/profiler/src/profiler/TracyWindowConstraints.cpp b/profiler/src/profiler/TracyWindowConstraints.cpp new file mode 100644 index 00000000..ecf08f1a --- /dev/null +++ b/profiler/src/profiler/TracyWindowConstraints.cpp @@ -0,0 +1,26 @@ +#include +#include + +#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(); +} + +} diff --git a/profiler/src/profiler/TracyWindowConstraints.hpp b/profiler/src/profiler/TracyWindowConstraints.hpp new file mode 100644 index 00000000..f5f42c60 --- /dev/null +++ b/profiler/src/profiler/TracyWindowConstraints.hpp @@ -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