Skip to content
Snippets Groups Projects

Dark UI Mode, compact commands

Merged Jonathan Kunstwald requested to merge feature/viewer-dark-mode into develop
7 files
+ 62
41
Compare changes
  • Side-by-side
  • Inline
Files
7
#include "command_queue.hh"
#include "command_queue.hh"
 
#include <glow/util/AsyncTextureLoader.hh>
 
#include <glow-extras/viewer/ViewerApp.hh>
#include <glow-extras/viewer/ViewerApp.hh>
#include <glow-extras/viewer/view.hh>
#include <glow-extras/viewer/view.hh>
@@ -30,6 +32,8 @@ glow::viewer::detail::shared_command_queue createQueue()
@@ -30,6 +32,8 @@ glow::viewer::detail::shared_command_queue createQueue()
void poolQueue(glow::viewer::detail::shared_command_queue&& queue) { sUnusedCommandQueuePool.push_back(std::move(queue)); }
void poolQueue(glow::viewer::detail::shared_command_queue&& queue) { sUnusedCommandQueuePool.push_back(std::move(queue)); }
 
bool sViewerImGuiDarkMode = false;
 
} // anon namespace
} // anon namespace
@@ -51,7 +55,7 @@ void glow::viewer::detail::on_last_command()
@@ -51,7 +55,7 @@ void glow::viewer::detail::on_last_command()
// Lazily init viewer globals
// Lazily init viewer globals
global_init();
global_init();
ViewerApp app(sCommandQueueStack.back());
ViewerApp app(sCommandQueueStack.back(), sViewerImGuiDarkMode);
try
try
{
{
@@ -60,11 +64,14 @@ void glow::viewer::detail::on_last_command()
@@ -60,11 +64,14 @@ void glow::viewer::detail::on_last_command()
catch (ViewerApp::TerminateException&)
catch (ViewerApp::TerminateException&)
{
{
// Special Shift + ESC termination
// Special Shift + ESC termination
 
glow::AsyncTextureLoader::shutdown();
std::exit(0);
std::exit(0);
}
}
// Clear the entire command queue stack for subsequent viewer runs
// Clear the entire command queue stack for subsequent viewer runs
sCommandQueueStack.clear();
sCommandQueueStack.clear();
 
// Reset the viewer ImGui dark mode for subsequent viewer runs
 
sViewerImGuiDarkMode = false;
}
}
else
else
{
{
@@ -84,21 +91,24 @@ bool glow::viewer::detail::is_interactive(const glow::viewer::detail::command_qu
@@ -84,21 +91,24 @@ bool glow::viewer::detail::is_interactive(const glow::viewer::detail::command_qu
void glow::viewer::detail::create_layout_tree(glow::viewer::layout::tree_node& rootNode, const glow::viewer::detail::command_queue& commands, float deltaTime, bool allowInteractiveExecute)
void glow::viewer::detail::create_layout_tree(glow::viewer::layout::tree_node& rootNode, const glow::viewer::detail::command_queue& commands, float deltaTime, bool allowInteractiveExecute)
{
{
 
using cmd_t = detail::command;
 
layout::tree_node* currentNode = nullptr;
layout::tree_node* currentNode = nullptr;
for (auto const& cmd : commands)
for (auto const& cmd : commands)
{
{
if (cmd.instr == detail::command::instruction::AddRenderjob)
if (cmd.instr == cmd_t::instruction::AddRenderjob)
{
{
TG_ASSERT(currentNode != nullptr);
TG_ASSERT(currentNode != nullptr);
cmd.renderable->runLazyInit();
auto& renderable = std::get<SharedRenderable>(cmd.data);
currentNode->scene.add(cmd.renderable);
renderable->runLazyInit();
 
currentNode->scene.add(renderable);
}
}
else if (cmd.instr == detail::command::instruction::ModifyScene)
else if (cmd.instr == cmd_t::instruction::ModifyScene)
{
{
TG_ASSERT(currentNode != nullptr);
TG_ASSERT(currentNode != nullptr);
cmd.sceneModifier(currentNode->scene);
std::get<cmd_t::scene_modifier_func_t>(cmd.data)(currentNode->scene);
}
}
else if (cmd.instr == detail::command::instruction::BeginSubview)
else if (cmd.instr == cmd_t::instruction::BeginSubview)
{
{
// Begin a subview
// Begin a subview
if (currentNode == nullptr)
if (currentNode == nullptr)
@@ -115,7 +125,7 @@ void glow::viewer::detail::create_layout_tree(glow::viewer::layout::tree_node& r
@@ -115,7 +125,7 @@ void glow::viewer::detail::create_layout_tree(glow::viewer::layout::tree_node& r
continue;
continue;
}
}
}
}
else if (cmd.instr == detail::command::instruction::EndSubview)
else if (cmd.instr == cmd_t::instruction::EndSubview)
{
{
TG_ASSERT(currentNode != nullptr);
TG_ASSERT(currentNode != nullptr);
@@ -126,12 +136,12 @@ void glow::viewer::detail::create_layout_tree(glow::viewer::layout::tree_node& r
@@ -126,12 +136,12 @@ void glow::viewer::detail::create_layout_tree(glow::viewer::layout::tree_node& r
break;
break;
}
}
}
}
else if (cmd.instr == detail::command::instruction::ModifyLayout)
else if (cmd.instr == cmd_t::instruction::ModifyLayout)
{
{
TG_ASSERT(currentNode != nullptr);
TG_ASSERT(currentNode != nullptr);
currentNode->layoutSettings = cmd.layout;
currentNode->layoutSettings = std::get<layout::settings>(cmd.data);
}
}
else if (TG_LIKELY(cmd.instr == detail::command::instruction::InteractiveSubview && allowInteractiveExecute))
else if (TG_LIKELY(cmd.instr == cmd_t::instruction::InteractiveSubview && allowInteractiveExecute))
{
{
// Interactive subviews still use Begin/End as usual
// Interactive subviews still use Begin/End as usual
TG_ASSERT(currentNode != nullptr);
TG_ASSERT(currentNode != nullptr);
@@ -142,7 +152,7 @@ void glow::viewer::detail::create_layout_tree(glow::viewer::layout::tree_node& r
@@ -142,7 +152,7 @@ void glow::viewer::detail::create_layout_tree(glow::viewer::layout::tree_node& r
// Run the interactive lambda to fill innerCommandQueue
// Run the interactive lambda to fill innerCommandQueue
{
{
sCommandQueueStack.push_back(innerCommandQueue);
sCommandQueueStack.push_back(innerCommandQueue);
cmd.interactiveLambda(deltaTime);
std::get<cmd_t::interactive_func_t>(cmd.data)(deltaTime);
sCommandQueueStack.pop_back();
sCommandQueueStack.pop_back();
}
}
@@ -153,3 +163,8 @@ void glow::viewer::detail::create_layout_tree(glow::viewer::layout::tree_node& r
@@ -153,3 +163,8 @@ void glow::viewer::detail::create_layout_tree(glow::viewer::layout::tree_node& r
}
}
}
}
}
}
 
 
void glow::viewer::detail::set_ui_darkmode(bool active)
 
{
 
sViewerImGuiDarkMode = active;
 
}
Loading