SpiecsEngine
 
Loading...
Searching...
No Matches

◆ DrawThis()

void Spices::CameraComponent::DrawThis ( )
overridevirtual

This interface defines how to draw this component to property panel.

Reimplemented from Spices::Component.

Definition at line 28 of file CameraComponent.cpp.

29 {
31
32 ImGui::Spacing();
33 ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2{ 0, 3.0f });
34 float columeWidth = ImGuiH::GetLineItemSize().x * 6.5f;
35
36 {
37 SPICES_PROFILE_ZONEN("CameraComponent FOV");
38
39 ImGuiH::DrawPropertyItem("FOV", columeWidth, nullptr, [&](){
40 ImGui::PushItemWidth(ImGui::GetContentRegionAvail().x - ImGuiH::GetLineItemSize().x);
41 if(ImGui::DragFloat("##", &m_Camera->GetPerspectiveParam().fov, 0.1f, 1.0f, 179.0f, "%.2f", ImGuiSliderFlags_AlwaysClamp))
42 {
44 }
45 ImGui::PopItemWidth();
46 ImGui::SameLine();
47 if (ImGuiH::DrawResetIcon(m_Camera->GetPerspectiveParam().fov != 45.0f))
48 {
49 m_Camera->GetPerspectiveParam().fov = 45.0f;
51 }
52 });
53 }
54
55 {
56 SPICES_PROFILE_ZONEN("CameraComponent Near Plane");
57
58 ImGuiH::DrawPropertyItem("Near Plane", columeWidth, nullptr, [&]() {
59 ImGui::PushItemWidth(ImGui::GetContentRegionAvail().x - ImGuiH::GetLineItemSize().x);
60 if (ImGui::DragFloat("##", &m_Camera->GetPerspectiveParam().nearPlane, 0.1f, 0.01f, 1000.0f, "%.3f", ImGuiSliderFlags_AlwaysClamp))
61 {
63 }
64 ImGui::PopItemWidth();
65 ImGui::SameLine();
66 if (ImGuiH::DrawResetIcon(m_Camera->GetPerspectiveParam().nearPlane != 0.01f))
67 {
68 m_Camera->GetPerspectiveParam().nearPlane = 0.01f;
70 }
71 });
72 }
73
74 {
75 SPICES_PROFILE_ZONEN("CameraComponent AspectRatio");
76
77 ImGuiH::DrawPropertyItem("AspectRatio", columeWidth, nullptr, [&]() {
78 ImGui::PushItemWidth(ImGui::GetContentRegionAvail().x - ImGuiH::GetLineItemSize().x);
79 float aspectRatio = m_Camera->GetPerspectiveParam().aspectRatio;
80 ImGui::DragFloat("##", &aspectRatio, 10.0f, 0.0f, 100.0f, "%.3f", ImGuiSliderFlags_AlwaysClamp);
81 ImGui::PopItemWidth();
82 ImGui::SameLine();
83 ImGuiH::DrawResetIcon(m_Camera->GetPerspectiveParam().aspectRatio != 1.777f);
84 });
85 }
86
87 ImGui::PopStyleVar();
88 ImGui::Spacing();
89 }
#define SPICES_PROFILE_ZONEN(...)
#define SPICES_PROFILE_ZONE
std::shared_ptr< Camera > m_Camera
The camera this component handled.
static FrameInfo & Get()
Get FrameInfo.
Definition FrameInfo.cpp:14
std::shared_ptr< World > m_World
The shared pointer of specific world.
Definition FrameInfo.h:94
static ImVec2 GetLineItemSize()
Get Line Width's Square Size.
static bool DrawResetIcon(const bool &isMove)
Draw Reset Icon.
static void DrawPropertyItem(const std::string &itemName, float columeWidth, std::function< void()> nameFunc, std::function< void()> valFunc)
Draw a single property.
@ FrushStableFrame
Definition World.h:48