mirror of
https://github.com/wolfpld/tracy.git
synced 2026-10-23 09:10:51 +00:00
Add imgui window size constraints helper.
This commit is contained in:
@@ -123,6 +123,7 @@ set(SERVER_FILES
|
||||
TracyView_ZoneInfo.cpp
|
||||
TracyView_ZoneTimeline.cpp
|
||||
TracyWeb.cpp
|
||||
TracyWindowConstraints.cpp
|
||||
)
|
||||
|
||||
if(NOT EMSCRIPTEN)
|
||||
|
||||
26
profiler/src/profiler/TracyWindowConstraints.cpp
Normal file
26
profiler/src/profiler/TracyWindowConstraints.cpp
Normal 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();
|
||||
}
|
||||
|
||||
}
|
||||
20
profiler/src/profiler/TracyWindowConstraints.hpp
Normal file
20
profiler/src/profiler/TracyWindowConstraints.hpp
Normal 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
|
||||
Reference in New Issue
Block a user