Skip to content

Commit

Permalink
fix(engine): resolve toolbox styling issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Teresa Margarida Vargas De Matos committed Nov 10, 2023
1 parent ebee45d commit 0b65a35
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 33 deletions.
37 changes: 14 additions & 23 deletions tools/tesseratos/include/tesseratos/toolbox/plugin.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


/// @dir
/// @brief @ref toolbox-plugin plugin directory.

Expand All @@ -25,27 +23,20 @@ namespace tesseratos
class Toolbox final
{
public:
std::unordered_map<std::string, bool> toolsMap;

bool isOpen(std::string toolname)
{
if (toolsMap.contains(toolname))
{
return toolsMap[toolname];
}
toolsMap[toolname] = false;
return false;
}

void open(std::string toolname)
{
toolsMap[toolname] = true;
}

void close(std::string toolname)
{
toolsMap[toolname] = false;
}
bool isOpen(std::string toolName);

void open(std::string toolName);

void close(std::string toolName);

void doClick(std::string toolName);

auto begin();

auto end();

private:
std::unordered_map<std::string, bool> mToolsMap;
};

/// @brief Plugin entry function.
Expand Down
48 changes: 38 additions & 10 deletions tools/tesseratos/src/tesseratos/toolbox/plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,50 @@ using cubos::engine::Cubos;

using namespace tesseratos;

bool Toolbox::isOpen(std::string toolName)
{
if (mToolsMap.contains(toolName))
{
return mToolsMap[toolName];
}
mToolsMap[toolName] = false;
return false;
}

void Toolbox::open(std::string toolName)
{
mToolsMap[toolName] = true;
}

void Toolbox::close(std::string toolName)
{
mToolsMap[toolName] = false;
}

void Toolbox::doClick(std::string toolName)
{
mToolsMap[toolName] = !mToolsMap[toolName];
}

auto Toolbox::begin()
{
return mToolsMap.begin();
}

auto Toolbox::end()
{
return mToolsMap.end();
}

static void showToolbox(Write<Toolbox> toolbox)
{
ImGui::Begin("Toolbox");

for (auto& [key, val] : toolbox->toolsMap)
for (auto it = toolbox->begin(); it != toolbox->end(); ++it)
{
if (ImGui::Button(data(key)))
if (ImGui::Button(data(it->first)))
{
if (!val)
{
toolbox->open(key);
}
else
{
toolbox->close(key);
}
toolbox->doClick(it->first);
}
}

Expand Down

0 comments on commit 0b65a35

Please sign in to comment.