ui: Added toolbar

This commit is contained in:
WerWolv
2021-08-21 00:52:11 +02:00
parent 0f45bef980
commit 37d2d58d2f
13 changed files with 133 additions and 79 deletions

View File

@@ -12,7 +12,7 @@ add_library(${PROJECT_NAME} SHARED
source/content/settings_entries.cpp
source/content/tools_entries.cpp
source/content/data_processor_nodes.cpp
source/content/footer_items.cpp
source/content/ui_items.cpp
source/math_evaluator.cpp

View File

@@ -1,5 +1,9 @@
#include <hex/plugin.hpp>
#include <codicons_font.h>
#include <imgui.h>
#include <imgui_internal.h>
namespace hex::plugin::builtin {
void addFooterItems() {
@@ -15,4 +19,32 @@ namespace hex::plugin::builtin {
}
void addToolbarItems() {
ContentRegistry::Interface::addToolbarItem([] {
const static auto buttonSize = ImVec2(ImGui::GetCurrentWindow()->MenuBarHeight(), ImGui::GetCurrentWindow()->MenuBarHeight());
ImGui::ToolBarButton(ICON_VS_DISCARD, ImGui::GetCustomColorVec4(ImGuiCustomCol_ToolbarBlue), buttonSize);
ImGui::ToolBarButton(ICON_VS_REDO, ImGui::GetCustomColorVec4(ImGuiCustomCol_ToolbarBlue), buttonSize);
ImGui::SeparatorEx(ImGuiSeparatorFlags_Vertical);
ImGui::ToolBarButton(ICON_VS_FILE, ImGui::GetCustomColorVec4(ImGuiCustomCol_ToolbarGray), buttonSize);
ImGui::ToolBarButton(ICON_VS_FOLDER_OPENED, ImGui::GetCustomColorVec4(ImGuiCustomCol_ToolbarBrown), buttonSize);
ImGui::SeparatorEx(ImGuiSeparatorFlags_Vertical);
ImGui::ToolBarButton(ICON_VS_SAVE, ImGui::GetCustomColorVec4(ImGuiCustomCol_ToolbarBlue), buttonSize);
ImGui::ToolBarButton(ICON_VS_SAVE_AS, ImGui::GetCustomColorVec4(ImGuiCustomCol_ToolbarBlue), buttonSize);
ImGui::SeparatorEx(ImGuiSeparatorFlags_Vertical);
ImGui::ToolBarButton(ICON_VS_COPY, ImGui::GetCustomColorVec4(ImGuiCustomCol_ToolbarGray), buttonSize);
ImGui::ToolBarButton(ICON_VS_OUTPUT, ImGui::GetCustomColorVec4(ImGuiCustomCol_ToolbarGray), buttonSize);
ImGui::SeparatorEx(ImGuiSeparatorFlags_Vertical);
ImGui::ToolBarButton(ICON_VS_BOOKMARK, ImGui::GetCustomColorVec4(ImGuiCustomCol_ToolbarGreen), buttonSize);
});
}
}

View File

@@ -10,6 +10,7 @@ namespace hex::plugin::builtin {
void registerDataProcessorNodes();
void addFooterItems();
void addToolbarItems();
void registerLanguageEnUS();
void registerLanguageDeDE();
@@ -29,6 +30,7 @@ IMHEX_PLUGIN_SETUP("Built-in", "WerWolv", "Default ImHex functionality") {
registerDataProcessorNodes();
addFooterItems();
addToolbarItems();
registerLanguageEnUS();
registerLanguageDeDE();

View File

@@ -191,9 +191,11 @@ namespace hex {
static void addWelcomeScreenEntry(const DrawCallback &function);
static void addFooterItem(const DrawCallback &function);
static void addToolbarItem(const DrawCallback &function);
static std::vector<DrawCallback>& getWelcomeScreenEntries();
static std::vector<DrawCallback>& getFooterItems();
static std::vector<DrawCallback>& getToolbarItems();
};
};

View File

@@ -72,6 +72,7 @@ namespace hex {
static std::vector<ContentRegistry::Interface::DrawCallback> welcomeScreenEntries;
static std::vector<ContentRegistry::Interface::DrawCallback> footerItems;
static std::vector<ContentRegistry::Interface::DrawCallback> toolbarItems;
static std::vector<ContentRegistry::DataProcessorNode::Entry> dataProcessorNodes;
static u32 dataProcessorNodeIdCounter;

View File

@@ -2,6 +2,7 @@
#include <glad/glad.h>
#include <imgui.h>
#include <imgui_internal.h>
#include <hex.hpp>
#include <hex/api/imhex_api.hpp>
@@ -20,5 +21,6 @@
[[gnu::visibility("default")]] const char* getPluginName() { return name; } \
[[gnu::visibility("default")]] const char* getPluginAuthor() { return author; } \
[[gnu::visibility("default")]] const char* getPluginDescription() { return description; } \
[[gnu::visibility("default")]] void setImGuiContext(ImGuiContext *ctx) { ImGui::SetCurrentContext(ctx); GImGui = ctx; } \
} \
void hex::plugin::namespaceName::internal::initializePlugin()

View File

@@ -233,6 +233,10 @@ namespace hex {
getFooterItems().push_back(function);
}
void ContentRegistry::Interface::addToolbarItem(const ContentRegistry::Interface::DrawCallback &function){
getToolbarItems().push_back(function);
}
std::vector<ContentRegistry::Interface::DrawCallback>& ContentRegistry::Interface::getWelcomeScreenEntries() {
return SharedData::welcomeScreenEntries;
@@ -240,4 +244,7 @@ namespace hex {
std::vector<ContentRegistry::Interface::DrawCallback>& ContentRegistry::Interface::getFooterItems() {
return SharedData::footerItems;
}
std::vector<ContentRegistry::Interface::DrawCallback>& ContentRegistry::Interface::getToolbarItems() {
return SharedData::toolbarItems;
}
}

View File

@@ -22,6 +22,7 @@ namespace hex {
std::vector<ContentRegistry::Interface::DrawCallback> SharedData::welcomeScreenEntries;
std::vector<ContentRegistry::Interface::DrawCallback> SharedData::footerItems;
std::vector<ContentRegistry::Interface::DrawCallback> SharedData::toolbarItems;
std::vector<ContentRegistry::DataProcessorNode::Entry> SharedData::dataProcessorNodes;
u32 SharedData::dataProcessorNodeIdCounter = 1;