add tooltip drawing
This commit is contained in:
parent
42926a0c9b
commit
6d7ffe0873
|
|
@ -37,6 +37,7 @@ namespace Nz
|
||||||
{
|
{
|
||||||
obj = Color(values[0], values[1], values[2], values[3]);
|
obj = Color(values[0], values[1], values[2], values[3]);
|
||||||
}
|
}
|
||||||
|
Tooltip(tooltip);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,20 +9,22 @@ namespace Nz
|
||||||
{
|
{
|
||||||
namespace EditorImgui
|
namespace EditorImgui
|
||||||
{
|
{
|
||||||
inline bool Begin(bool& obj, const std::string& name, const std::string& /*tooltip*/)
|
inline bool Begin(bool& obj, const std::string& name, const std::string& tooltip)
|
||||||
{
|
{
|
||||||
ImGui::Checkbox(name.c_str(), &obj);
|
ImGui::Checkbox(name.c_str(), &obj);
|
||||||
|
Tooltip(tooltip);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void End(bool&) {}
|
inline void End(bool&) {}
|
||||||
|
|
||||||
#define IMGUI_BASIC_INTEGER(Type) \
|
#define IMGUI_BASIC_INTEGER(Type) \
|
||||||
inline bool Begin(Type& obj, const std::string& name, const std::string& /*tooltip*/) \
|
inline bool Begin(Type& obj, const std::string& name, const std::string& tooltip) \
|
||||||
{ \
|
{ \
|
||||||
int value = static_cast<int>(obj); \
|
int value = static_cast<int>(obj); \
|
||||||
if (ImGui::DragInt(name.c_str(), &value, 1.f, std::numeric_limits<Type>::min(), std::numeric_limits<Type>::max())) \
|
if (ImGui::DragInt(name.c_str(), &value, 1.f, std::numeric_limits<Type>::min(), std::numeric_limits<Type>::max())) \
|
||||||
obj = static_cast<Type>(value); \
|
obj = static_cast<Type>(value); \
|
||||||
|
Tooltip(tooltip); \
|
||||||
return false; \
|
return false; \
|
||||||
} \
|
} \
|
||||||
inline void End(Type&) {}
|
inline void End(Type&) {}
|
||||||
|
|
@ -37,12 +39,13 @@ namespace Nz
|
||||||
IMGUI_BASIC_INTEGER(Nz::UInt64);
|
IMGUI_BASIC_INTEGER(Nz::UInt64);
|
||||||
|
|
||||||
#define IMGUI_BASIC_FLOAT(Type) \
|
#define IMGUI_BASIC_FLOAT(Type) \
|
||||||
inline bool Begin(Type& obj, const std::string& name, const std::string& /*tooltip*/) \
|
inline bool Begin(Type& obj, const std::string& name, const std::string& tooltip) \
|
||||||
{ \
|
{ \
|
||||||
float value = (float)obj; \
|
float value = (float)obj; \
|
||||||
if (ImGui::DragFloat(name.c_str(), &value, 1.f, std::numeric_limits<Type>::min(), std::numeric_limits<Type>::max())) \
|
if (ImGui::DragFloat(name.c_str(), &value, 1.f, std::numeric_limits<Type>::min(), std::numeric_limits<Type>::max())) \
|
||||||
obj = (Type)value; \
|
obj = (Type)value; \
|
||||||
return false; \
|
Tooltip(tooltip); \
|
||||||
|
return false; \
|
||||||
} \
|
} \
|
||||||
inline void End(Type&) {}
|
inline void End(Type&) {}
|
||||||
|
|
||||||
|
|
@ -50,18 +53,19 @@ namespace Nz
|
||||||
IMGUI_BASIC_FLOAT(double);
|
IMGUI_BASIC_FLOAT(double);
|
||||||
|
|
||||||
|
|
||||||
inline bool Begin(Nz::Vector3f& obj, const std::string& name, const std::string& /*tooltip*/)
|
inline bool Begin(Nz::Vector3f& obj, const std::string& name, const std::string& tooltip)
|
||||||
{
|
{
|
||||||
float value[] = { obj.x, obj.y, obj.z };
|
float value[] = { obj.x, obj.y, obj.z };
|
||||||
if (ImGui::DragFloat3(name.c_str(), value, 1.f, std::numeric_limits<float>::min(), std::numeric_limits<float>::max()))
|
if (ImGui::DragFloat3(name.c_str(), value, 1.f, std::numeric_limits<float>::min(), std::numeric_limits<float>::max()))
|
||||||
obj = Nz::Vector3f(value[0], value[1], value[2]);
|
obj = Nz::Vector3f(value[0], value[1], value[2]);
|
||||||
|
Tooltip(tooltip);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void End(Nz::Vector3f&) {}
|
inline void End(Nz::Vector3f&) {}
|
||||||
|
|
||||||
|
|
||||||
inline bool Begin(Nz::Quaternionf& obj, const std::string& name, const std::string& /*tooltip*/)
|
inline bool Begin(Nz::Quaternionf& obj, const std::string& name, const std::string& tooltip)
|
||||||
{
|
{
|
||||||
auto euler = obj.ToEulerAngles();
|
auto euler = obj.ToEulerAngles();
|
||||||
float value[] = { euler.pitch.ToDegrees(), euler.yaw.ToDegrees(), euler.roll.ToDegrees() };
|
float value[] = { euler.pitch.ToDegrees(), euler.yaw.ToDegrees(), euler.roll.ToDegrees() };
|
||||||
|
|
@ -69,6 +73,7 @@ namespace Nz
|
||||||
{
|
{
|
||||||
obj = EulerAnglesf(value[0], value[1], value[2]).ToQuaternion();
|
obj = EulerAnglesf(value[0], value[1], value[2]).ToQuaternion();
|
||||||
}
|
}
|
||||||
|
Tooltip(tooltip);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <imgui.h>
|
||||||
|
|
||||||
namespace Nz
|
namespace Nz
|
||||||
{
|
{
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
|
@ -9,4 +11,17 @@ namespace Nz
|
||||||
template <typename TEnumerator>
|
template <typename TEnumerator>
|
||||||
static void Reflect(TEnumerator&, T&) { } // default specialization
|
static void Reflect(TEnumerator&, T&) { } // default specialization
|
||||||
};
|
};
|
||||||
|
|
||||||
|
namespace EditorImgui
|
||||||
|
{
|
||||||
|
inline void Tooltip(const std::string& tooltip)
|
||||||
|
{
|
||||||
|
if (ImGui::IsItemHovered())
|
||||||
|
{
|
||||||
|
ImGui::BeginTooltip();
|
||||||
|
ImGui::Text(tooltip.c_str());
|
||||||
|
ImGui::EndTooltip();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue