ui/api: Added sidebar

This commit is contained in:
WerWolv
2022-01-22 22:03:19 +01:00
parent d5d1577b43
commit 4e047beabb
5 changed files with 78 additions and 3 deletions

View File

@@ -232,6 +232,11 @@ namespace hex {
DrawCallback callback;
};
struct SidebarItem {
std::string icon;
DrawCallback callback;
};
}
u32 getDockSpaceId();
@@ -240,6 +245,7 @@ namespace hex {
void addWelcomeScreenEntry(const impl::DrawCallback &function);
void addFooterItem(const impl::DrawCallback &function);
void addToolbarItem(const impl::DrawCallback &function);
void addSidebarItem(const std::string &icon, const impl::DrawCallback &function);
void addLayout(const std::string &unlocalizedName, const impl::LayoutFunction &function);
@@ -247,6 +253,7 @@ namespace hex {
std::vector<impl::DrawCallback>& getWelcomeScreenEntries();
std::vector<impl::DrawCallback>& getFooterItems();
std::vector<impl::DrawCallback>& getToolbarItems();
std::vector<impl::SidebarItem>& getSidebarItems();
std::vector<impl::Layout>& getLayouts();
}

View File

@@ -81,6 +81,7 @@ namespace hex {
static std::vector<ContentRegistry::Interface::impl::DrawCallback> welcomeScreenEntries;
static std::vector<ContentRegistry::Interface::impl::DrawCallback> footerItems;
static std::vector<ContentRegistry::Interface::impl::DrawCallback> toolbarItems;
static std::vector<ContentRegistry::Interface::impl::SidebarItem> sidebarItems;
static std::vector<ContentRegistry::Interface::impl::Layout> layouts;
static std::map<Shortcut, std::function<void()>> globalShortcuts;

View File

@@ -312,6 +312,10 @@ namespace hex {
getToolbarItems().push_back(function);
}
void ContentRegistry::Interface::addSidebarItem(const std::string &icon, const impl::DrawCallback &function) {
getSidebarItems().push_back({ icon, function });
}
void ContentRegistry::Interface::addLayout(const std::string &unlocalizedName, const impl::LayoutFunction &function) {
log::info("Added new layout: {}", unlocalizedName);
@@ -332,6 +336,9 @@ namespace hex {
std::vector<ContentRegistry::Interface::impl::DrawCallback>& ContentRegistry::Interface::getToolbarItems() {
return SharedData::toolbarItems;
}
std::vector<ContentRegistry::Interface::impl::SidebarItem>& ContentRegistry::Interface::getSidebarItems() {
return SharedData::sidebarItems;
}
std::vector<ContentRegistry::Interface::impl::Layout>& ContentRegistry::Interface::getLayouts() {
return SharedData::layouts;

View File

@@ -30,6 +30,7 @@ namespace hex {
std::vector<ContentRegistry::Interface::impl::MainMenuItem> SharedData::mainMenuItems;
std::vector<ContentRegistry::Interface::impl::DrawCallback> SharedData::welcomeScreenEntries;
std::vector<ContentRegistry::Interface::impl::DrawCallback> SharedData::footerItems;
std::vector<ContentRegistry::Interface::impl::SidebarItem> SharedData::sidebarItems;
std::vector<ContentRegistry::Interface::impl::DrawCallback> SharedData::toolbarItems;
std::vector<ContentRegistry::Interface::impl::Layout> SharedData::layouts;