SpiecsEngine
 
Loading...
Searching...
No Matches

◆ DrawThis()

void Spices::PointLightComponent::DrawThis ( )
overridevirtual

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

Reimplemented from Spices::Component.

Definition at line 25 of file PointLightComponent.cpp.

26 {
28
29 ImGui::Spacing();
30 ImGui::PushStyleVar(ImGuiStyleVar_ItemSpacing, ImVec2{ 0, 3.0f });
31 float columeWidth = ImGuiH::GetLineItemSize().x * 6.5f;
32
33 {
34 SPICES_PROFILE_ZONEN("PointLightComponent Color");
35
36 ImGuiH::DrawPropertyItem("Color", columeWidth, nullptr, [&]() {
37
38 float itemWidth = (ImGui::GetContentRegionAvail().x - 8.0f * ImGuiH::GetLineItemSize().x) / 3.0f;
39
40 {
41 SPICES_PROFILE_ZONEN("PointLightComponent Color R");
42 ImGui::PushID("PointLightComponent Color R");
43
44 ImGui::PushStyleColor(ImGuiCol_Button, ImVec4{ 0.8f, 0.1f, 0.15f, 1.0f });
45 ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4{ 0.9f, 0.2f, 0.2f, 1.0f });
46 ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4{ 0.8f, 0.1f, 0.15f, 1.0f });
47 if (ImGui::Button("R", ImGuiH::GetLineItemSize())) m_PointLight.color.x = 1.0f;
48 ImGui::PopStyleColor(3);
49 ImGui::SameLine();
50 ImGui::PushItemWidth(itemWidth);
51 if(ImGui::SliderFloat("##R", &m_PointLight.color.x, 0.0f, 1.0f, "%.2f", ImGuiSliderFlags_AlwaysClamp))
52 {
54 }
55 ImGui::PopItemWidth();
56 ImGui::SameLine();
57 if (ImGuiH::DrawResetIcon(m_PointLight.color.x != 1.0f))
58 {
59 m_PointLight.color.x = 1.0f;
61 }
62 ImGui::SameLine();
63 ImGui::PopID();
64 }
65
66 {
67 SPICES_PROFILE_ZONEN("PointLightComponent Color G");
68 ImGui::PushID("PointLightComponent Color G");
69
70 ImGui::PushStyleColor(ImGuiCol_Button, ImVec4{ 0.2f, 0.7f, 0.2f, 1.0f });
71 ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4{ 0.3f, 0.8f, 0.3f, 1.0f });
72 ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4{ 0.2f, 0.7f, 0.2f, 1.0f });
73 if (ImGui::Button("G", ImGuiH::GetLineItemSize())) m_PointLight.color.y = 1.0f;
74 ImGui::PopStyleColor(3);
75 ImGui::SameLine();
76 ImGui::PushItemWidth(itemWidth);
77 if(ImGui::SliderFloat("##G", &m_PointLight.color.y, 0.0f, 1.0f, "%.2f", ImGuiSliderFlags_AlwaysClamp))
78 {
80 }
81 ImGui::PopItemWidth();
82 ImGui::SameLine();
83 if (ImGuiH::DrawResetIcon(m_PointLight.color.y != 1.0f))
84 {
85 m_PointLight.color.y = 1.0f;
87 }
88 ImGui::SameLine();
89 ImGui::PopID();
90 }
91
92 {
93 SPICES_PROFILE_ZONEN("PointLightComponent Color B");
94 ImGui::PushID("PointLightComponent Color B");
95
96 ImGui::PushStyleColor(ImGuiCol_Button, ImVec4{ 0.1f, 0.25f, 0.8f, 1.0f });
97 ImGui::PushStyleColor(ImGuiCol_ButtonHovered, ImVec4{ 0.2f, 0.35f, 0.9f, 1.0f });
98 ImGui::PushStyleColor(ImGuiCol_ButtonActive, ImVec4{ 0.1f, 0.25f, 0.8f, 1.0f });
99 if (ImGui::Button("B", ImGuiH::GetLineItemSize())) m_PointLight.color.z = 1.0f;
100 ImGui::PopStyleColor(3);
101 ImGui::SameLine();
102 ImGui::PushItemWidth(itemWidth);
103 if(ImGui::SliderFloat("##B", &m_PointLight.color.z, 0.0f, 1.0f, "%.2f", ImGuiSliderFlags_AlwaysClamp))
104 {
106 }
107 ImGui::PopItemWidth();
108 ImGui::SameLine();
109 if (ImGuiH::DrawResetIcon(m_PointLight.color.z != 1.0f))
110 {
111 m_PointLight.color.z = 1.0f;
113 }
114 ImGui::SameLine();
115 ImGui::PopID();
116 }
117
118 {
119 SPICES_PROFILE_ZONEN("PointLightComponent Color Picker");
120 ImGui::PushID("PointLightComponent Color Picker");
121
122 ImGui::PushStyleColor(ImGuiCol_FrameBg, ImGui::GetStyle().Colors[ImGuiCol_WindowBg]);
123 if(ImGui::ColorEdit3("##", glm::value_ptr(m_PointLight.color), ImGuiColorEditFlags_NoInputs | ImGuiColorEditFlags_PickerHueBar))
124 {
126 }
127 ImGui::SameLine();
128 if (ImGuiH::DrawResetIcon(m_PointLight.color != glm::vec3(1.0f, 1.0f, 1.0f)))
129 {
130 m_PointLight.color = glm::vec3(1.0f, 1.0f, 1.0f);
132 }
133 ImGui::PopStyleColor();
134 ImGui::PopID();
135 }
136 });
137 }
138
139 {
140 SPICES_PROFILE_ZONEN("PointLightComponent Intensity");
141
142 ImGuiH::DrawPropertyItem("Intensity", columeWidth, nullptr, [&]() {
143 ImGui::PushItemWidth(ImGui::GetContentRegionAvail().x - ImGuiH::GetLineItemSize().x);
144 if(ImGui::DragFloat("##", &m_PointLight.intensity, 0.1f, 0.0f, 10000.0f, "%.2f", ImGuiSliderFlags_AlwaysClamp))
145 {
147 }
148 ImGui::PopItemWidth();
149 ImGui::SameLine();
150 if (ImGuiH::DrawResetIcon(m_PointLight.intensity != 1.0f))
151 {
152 m_PointLight.intensity = 1.0f;
154 }
155 });
156 }
157
158 {
159 SPICES_PROFILE_ZONEN("PointLightComponent Constantf");
160
161 ImGuiH::DrawPropertyItem("Constantf", columeWidth, nullptr, [&]() {
162 ImGui::PushItemWidth(ImGui::GetContentRegionAvail().x - ImGuiH::GetLineItemSize().x);
163 if(ImGui::DragFloat("##", &m_PointLight.constantf, 0.1f, 0.0f, 10000.0f, "%.2f", ImGuiSliderFlags_AlwaysClamp))
164 {
166 }
167 ImGui::PopItemWidth();
168 ImGui::SameLine();
169 if (ImGuiH::DrawResetIcon(m_PointLight.constantf != 1.0f))
170 {
171 m_PointLight.constantf = 1.0f;
173 }
174 });
175 }
176
177 {
178 SPICES_PROFILE_ZONEN("PointLightComponent Linear");
179
180 ImGuiH::DrawPropertyItem("Linear", columeWidth, nullptr, [&]() {
181 ImGui::PushItemWidth(ImGui::GetContentRegionAvail().x - ImGuiH::GetLineItemSize().x);
182 if(ImGui::DragFloat("##", &m_PointLight.linear, 0.1f, 0.0f, 10000.0f, "%.2f", ImGuiSliderFlags_AlwaysClamp))
183 {
185 }
186 ImGui::PopItemWidth();
187 ImGui::SameLine();
188 if (ImGuiH::DrawResetIcon(m_PointLight.linear != 0.35f))
189 {
190 m_PointLight.linear = 0.35f;
192 }
193 });
194 }
195
196 {
197 SPICES_PROFILE_ZONEN("PointLightComponent Quadratic");
198
199 ImGuiH::DrawPropertyItem("Quadratic", columeWidth, nullptr, [&]() {
200 ImGui::PushItemWidth(ImGui::GetContentRegionAvail().x - ImGuiH::GetLineItemSize().x);
201 if(ImGui::DragFloat("##", &m_PointLight.quadratic, 0.1f, 0.0f, 10000.0f, "%.2f", ImGuiSliderFlags_AlwaysClamp))
202 {
204 }
205 ImGui::PopItemWidth();
206 ImGui::SameLine();
207 if (ImGuiH::DrawResetIcon(m_PointLight.quadratic != 0.44f))
208 {
209 m_PointLight.quadratic = 0.44f;
211 }
212 });
213 }
214
215 ImGui::PopStyleVar();
216 ImGui::Spacing();
217 }
#define SPICES_PROFILE_ZONEN(...)
#define SPICES_PROFILE_ZONE
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.
SpicesShader::PointLight m_PointLight
This PointLight data this component handled.
@ FrushStableFrame
Definition World.h:48