Бранимир Караџић 7 years ago
parent
commit
0df9a005fa
2 changed files with 29 additions and 56 deletions
  1. 29 35
      examples/18-ibl/ibl.cpp
  2. 0 21
      examples/common/imgui/imgui.h

+ 29 - 35
examples/18-ibl/ibl.cpp

@@ -528,19 +528,21 @@ public:
 			ImGui::Checkbox("IBL Diffuse",  &m_settings.m_doDiffuseIbl);
 			ImGui::Checkbox("IBL Specular", &m_settings.m_doSpecularIbl);
 
+			if (ImGui::BeginTabBar("Cubemap", ImGuiTabBarFlags_None) )
 			{
-				float tabWidth = ImGui::GetContentRegionAvailWidth() / 2.0f;
-				if (ImGui::TabButton("Bolonga", tabWidth, m_currentLightProbe == LightProbe::Bolonga) )
+				if (ImGui::BeginTabItem("Bolonga") )
 				{
 					m_currentLightProbe = LightProbe::Bolonga;
+					ImGui::EndTabItem();
 				}
 
-				ImGui::SameLine(0.0f,0.0f);
-
-				if (ImGui::TabButton("Kyoto", tabWidth, m_currentLightProbe == LightProbe::Kyoto) )
+				if (ImGui::BeginTabItem("Kyoto") )
 				{
 					m_currentLightProbe = LightProbe::Kyoto;
+					ImGui::EndTabItem();
 				}
+
+				ImGui::EndTabBar();
 			}
 
 			ImGui::SliderFloat("Texture LOD", &m_settings.m_lod, 0.0f, 10.1f);
@@ -579,41 +581,33 @@ public:
 					selection = UINT8_C(1);
 				}
 
-				float tabWidth = ImGui::GetContentRegionAvailWidth() / 3.0f;
-				if (ImGui::TabButton("Skybox", tabWidth, selection == 0) )
+				if (ImGui::BeginTabBar("CubemapSelection", ImGuiTabBarFlags_None) )
 				{
-					selection = 0;
-				}
+					if (ImGui::BeginTabItem("Radiance") )
+					{
+						selection = 1;
+						m_settings.m_bgType = 7.0f;
 
-				ImGui::SameLine(0.0f,0.0f);
-				if (ImGui::TabButton("Radiance", tabWidth, selection == 1) )
-				{
-					selection = 1;
-				}
+						ImGui::SliderFloat("Mip level", &m_settings.m_radianceSlider, 1.0f, 6.0f);
 
-				ImGui::SameLine(0.0f,0.0f);
-				if (ImGui::TabButton("Irradiance", tabWidth, selection == 2) )
-				{
-					selection = 2;
-				}
+						ImGui::EndTabItem();
+					}
 
-				if (0 == selection)
-				{
-					m_settings.m_bgType = 0.0f;
-				}
-				else if (2 == selection)
-				{
-					m_settings.m_bgType = 7.0f;
-				}
-				else
-				{
-					m_settings.m_bgType = m_settings.m_radianceSlider;
-				}
+					if (ImGui::BeginTabItem("Irradiance") )
+					{
+						selection = 2;
+						m_settings.m_bgType = m_settings.m_radianceSlider;
+						ImGui::EndTabItem();
+					}
 
-				const bool isRadiance = (selection == 1);
-				if (isRadiance)
-				{
-					ImGui::SliderFloat("Mip level", &m_settings.m_radianceSlider, 1.0f, 6.0f);
+					if (ImGui::BeginTabItem("Skybox") )
+					{
+						selection = 0;
+						m_settings.m_bgType = 0.0f;
+						ImGui::EndTabItem();
+					}
+
+					ImGui::EndTabBar();
 				}
 			}
 			ImGui::Unindent();

+ 0 - 21
examples/common/imgui/imgui.h

@@ -108,27 +108,6 @@ namespace ImGui
 		SetCursorPosY(GetCursorPosY() + GetTextLineHeightWithSpacing() );
 	}
 
-	inline bool TabButton(const char* _text, float _width, bool _active)
-	{
-		int32_t count = 1;
-
-		if (_active)
-		{
-			ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(1.0f, 0.75f, 0.0f, 0.78f) );
-			ImGui::PushStyleColor(ImGuiCol_Text,   ImVec4(0.0f, 0.0f,  0.0f, 1.0f ) );
-			count = 2;
-		}
-		else
-		{
-			ImGui::PushStyleColor(ImGuiCol_Button, ImVec4(0.5f, 0.5f, 0.5f, 0.7f) );
-		}
-
-		bool retval = ImGui::Button(_text, ImVec2(_width, 20.0f) );
-		ImGui::PopStyleColor(count);
-
-		return retval;
-	}
-
 	inline bool MouseOverArea()
 	{
 		return false