Files
MuditaOS/module-apps/WindowsStack.hpp
Adam Dobrowolski 7b4a706cd6 EGD-4036 Application windows - added register mechanism
* Moved ApplicationLauncher to separate files - declutering
* WindowsStore renamed to WindowsFactory - Store needs to be splitted toavoid antipattern
* Options window build dynamically onBeforeShow
* Dialog windows dynamically built
2020-10-13 17:46:10 +02:00

53 lines
1.2 KiB
C++

#pragma once
#include <memory>
#include <map>
#include <vector>
#include <string>
#include <AppWindow.hpp>
namespace app
{
class Application;
class WindowsStack
{
Application *parent;
public:
WindowsStack(Application *parent) : parent(parent)
{}
std::vector<std::string> stack;
std::map<std::string, std::unique_ptr<gui::AppWindow>> windows;
std::map<std::string, std::unique_ptr<gui::AppWindow>>::const_iterator begin() const
{
return std::begin(windows);
}
std::map<std::string, std::unique_ptr<gui::AppWindow>>::const_iterator end() const
{
return std::end(windows);
}
[[nodiscard]] auto getParent() const
{
return parent;
}
auto push(const std::string &name, std::unique_ptr<gui::AppWindow> window)
{
windows[name] = std::move(window);
stack.push_back(name);
}
gui::AppWindow *get(const std::string &name)
{
auto ret = windows.find(name);
return ret == std::end(windows) ? nullptr : ret->second.get();
}
};
} // namespace app