Added ImGui style selection
This commit is contained in:
parent
61bd5cfd92
commit
f66ecd936e
1 changed files with 41 additions and 8 deletions
|
|
@ -47,6 +47,8 @@ private:
|
||||||
vks::VulkanDevice *device;
|
vks::VulkanDevice *device;
|
||||||
VkPhysicalDeviceDriverProperties driverProperties = {};
|
VkPhysicalDeviceDriverProperties driverProperties = {};
|
||||||
VulkanExampleBase *example;
|
VulkanExampleBase *example;
|
||||||
|
ImGuiStyle vulkanStyle;
|
||||||
|
int selectedStyle = 0;
|
||||||
public:
|
public:
|
||||||
// UI params are set via push constants
|
// UI params are set via push constants
|
||||||
struct PushConstBlock {
|
struct PushConstBlock {
|
||||||
|
|
@ -87,12 +89,15 @@ public:
|
||||||
void init(float width, float height)
|
void init(float width, float height)
|
||||||
{
|
{
|
||||||
// Color scheme
|
// Color scheme
|
||||||
ImGuiStyle& style = ImGui::GetStyle();
|
vulkanStyle = ImGui::GetStyle();
|
||||||
style.Colors[ImGuiCol_TitleBg] = ImVec4(1.0f, 0.0f, 0.0f, 0.6f);
|
vulkanStyle.Colors[ImGuiCol_TitleBg] = ImVec4(1.0f, 0.0f, 0.0f, 0.6f);
|
||||||
style.Colors[ImGuiCol_TitleBgActive] = ImVec4(1.0f, 0.0f, 0.0f, 0.8f);
|
vulkanStyle.Colors[ImGuiCol_TitleBgActive] = ImVec4(1.0f, 0.0f, 0.0f, 0.8f);
|
||||||
style.Colors[ImGuiCol_MenuBarBg] = ImVec4(1.0f, 0.0f, 0.0f, 0.4f);
|
vulkanStyle.Colors[ImGuiCol_MenuBarBg] = ImVec4(1.0f, 0.0f, 0.0f, 0.4f);
|
||||||
style.Colors[ImGuiCol_Header] = ImVec4(1.0f, 0.0f, 0.0f, 0.4f);
|
vulkanStyle.Colors[ImGuiCol_Header] = ImVec4(1.0f, 0.0f, 0.0f, 0.4f);
|
||||||
style.Colors[ImGuiCol_CheckMark] = ImVec4(0.0f, 1.0f, 0.0f, 1.0f);
|
vulkanStyle.Colors[ImGuiCol_CheckMark] = ImVec4(0.0f, 1.0f, 0.0f, 1.0f);
|
||||||
|
|
||||||
|
setStyle(0);
|
||||||
|
|
||||||
// Dimensions
|
// Dimensions
|
||||||
ImGuiIO& io = ImGui::GetIO();
|
ImGuiIO& io = ImGui::GetIO();
|
||||||
io.DisplaySize = ImVec2(width, height);
|
io.DisplaySize = ImVec2(width, height);
|
||||||
|
|
@ -111,6 +116,28 @@ public:
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setStyle(uint32_t index)
|
||||||
|
{
|
||||||
|
switch (index)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
{
|
||||||
|
ImGuiStyle& style = ImGui::GetStyle();
|
||||||
|
style = vulkanStyle;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 1:
|
||||||
|
ImGui::StyleColorsClassic();
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
ImGui::StyleColorsDark();
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
ImGui::StyleColorsLight();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Initialize all Vulkan resources used by the ui
|
// Initialize all Vulkan resources used by the ui
|
||||||
void initResources(VkRenderPass renderPass, VkQueue copyQueue, const std::string& shadersPath)
|
void initResources(VkRenderPass renderPass, VkQueue copyQueue, const std::string& shadersPath)
|
||||||
{
|
{
|
||||||
|
|
@ -354,7 +381,7 @@ public:
|
||||||
|
|
||||||
// Init imGui windows and elements
|
// Init imGui windows and elements
|
||||||
|
|
||||||
// SRS - Set initial position of default Debug window (note: Debug window sets its own initial size, use ImGuiSetCond_Always to override)
|
// Debug window
|
||||||
ImGui::SetWindowPos(ImVec2(20 * example->UIOverlay.scale, 20 * example->UIOverlay.scale), ImGuiSetCond_FirstUseEver);
|
ImGui::SetWindowPos(ImVec2(20 * example->UIOverlay.scale, 20 * example->UIOverlay.scale), ImGuiSetCond_FirstUseEver);
|
||||||
ImGui::SetWindowSize(ImVec2(300 * example->UIOverlay.scale, 300 * example->UIOverlay.scale), ImGuiSetCond_Always);
|
ImGui::SetWindowSize(ImVec2(300 * example->UIOverlay.scale, 300 * example->UIOverlay.scale), ImGuiSetCond_Always);
|
||||||
ImGui::TextUnformatted(example->title.c_str());
|
ImGui::TextUnformatted(example->title.c_str());
|
||||||
|
|
@ -383,7 +410,7 @@ public:
|
||||||
ImGui::InputFloat3("position", &example->camera.position.x, 2);
|
ImGui::InputFloat3("position", &example->camera.position.x, 2);
|
||||||
ImGui::InputFloat3("rotation", &example->camera.rotation.x, 2);
|
ImGui::InputFloat3("rotation", &example->camera.rotation.x, 2);
|
||||||
|
|
||||||
// SRS - Set initial position and size of Example settings window
|
// Example settings window
|
||||||
ImGui::SetNextWindowPos(ImVec2(20 * example->UIOverlay.scale, 360 * example->UIOverlay.scale), ImGuiSetCond_FirstUseEver);
|
ImGui::SetNextWindowPos(ImVec2(20 * example->UIOverlay.scale, 360 * example->UIOverlay.scale), ImGuiSetCond_FirstUseEver);
|
||||||
ImGui::SetNextWindowSize(ImVec2(300 * example->UIOverlay.scale, 200 * example->UIOverlay.scale), ImGuiSetCond_FirstUseEver);
|
ImGui::SetNextWindowSize(ImVec2(300 * example->UIOverlay.scale, 200 * example->UIOverlay.scale), ImGuiSetCond_FirstUseEver);
|
||||||
ImGui::Begin("Example settings");
|
ImGui::Begin("Example settings");
|
||||||
|
|
@ -392,6 +419,12 @@ public:
|
||||||
ImGui::Checkbox("Display background", &uiSettings.displayBackground);
|
ImGui::Checkbox("Display background", &uiSettings.displayBackground);
|
||||||
ImGui::Checkbox("Animate light", &uiSettings.animateLight);
|
ImGui::Checkbox("Animate light", &uiSettings.animateLight);
|
||||||
ImGui::SliderFloat("Light speed", &uiSettings.lightSpeed, 0.1f, 1.0f);
|
ImGui::SliderFloat("Light speed", &uiSettings.lightSpeed, 0.1f, 1.0f);
|
||||||
|
//ImGui::ShowStyleSelector("UI style");
|
||||||
|
|
||||||
|
if (ImGui::Combo("UI style", &selectedStyle, "Vulkan\0Classic\0Dark\0Light\0")) {
|
||||||
|
setStyle(selectedStyle);
|
||||||
|
}
|
||||||
|
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
|
|
||||||
//SRS - ShowDemoWindow() sets its own initial position and size, cannot override here
|
//SRS - ShowDemoWindow() sets its own initial position and size, cannot override here
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue