impr: Added icons to all menu items

This commit is contained in:
WerWolv
2024-01-08 21:51:48 +01:00
parent 3a068b9719
commit bfafc692db
32 changed files with 236 additions and 103 deletions

View File

@@ -639,6 +639,7 @@ namespace hex {
struct MenuItem {
std::vector<UnlocalizedString> unlocalizedNames;
const char *icon;
std::unique_ptr<Shortcut> shortcut;
View *view;
MenuCallback callback;
@@ -678,6 +679,19 @@ namespace hex {
*/
void registerMainMenuItem(const UnlocalizedString &unlocalizedName, u32 priority);
/**
* @brief Adds a new main menu entry
* @param unlocalizedMainMenuNames The unlocalized names of the main menu entries
* @param icon The icon to use for the entry
* @param priority The priority of the entry. Lower values are displayed first
* @param shortcut The shortcut to use for the entry
* @param function The function to call when the entry is clicked
* @param enabledCallback The function to call to determine if the entry is enabled
* @param view The view to use for the entry. If nullptr, the shortcut will work globally
*/
void addMenuItem(const std::vector<UnlocalizedString> &unlocalizedMainMenuNames, const char *icon, u32 priority, const Shortcut &shortcut, const impl::MenuCallback &function, const impl::EnabledCallback& enabledCallback = []{ return true; }, View *view = nullptr);
/**
* @brief Adds a new main menu entry
* @param unlocalizedMainMenuNames The unlocalized names of the main menu entries
@@ -698,6 +712,17 @@ namespace hex {
*/
void addMenuItemSubMenu(std::vector<UnlocalizedString> unlocalizedMainMenuNames, u32 priority, const impl::MenuCallback &function, const impl::EnabledCallback& enabledCallback = []{ return true; });
/**
* @brief Adds a new main menu sub-menu entry
* @param unlocalizedMainMenuNames The unlocalized names of the main menu entries
* @param icon The icon to use for the entry
* @param priority The priority of the entry. Lower values are displayed first
* @param function The function to call when the entry is clicked
* @param enabledCallback The function to call to determine if the entry is enabled
*/
void addMenuItemSubMenu(std::vector<UnlocalizedString> unlocalizedMainMenuNames, const char *icon, u32 priority, const impl::MenuCallback &function, const impl::EnabledCallback& enabledCallback = []{ return true; });
/**
* @brief Adds a new main menu separator
* @param unlocalizedMainMenuNames The unlocalized names of the main menu entries

View File

@@ -24,7 +24,7 @@
namespace hex {
class View {
explicit View(UnlocalizedString unlocalizedName);
explicit View(UnlocalizedString unlocalizedName, const char *icon);
public:
virtual ~View() = default;
@@ -82,7 +82,7 @@ namespace hex {
*/
[[nodiscard]] virtual ImGuiWindowFlags getWindowFlags() const;
[[nodiscard]] const char *getIcon() const { return m_icon; }
[[nodiscard]] bool &getWindowOpenState();
[[nodiscard]] const bool &getWindowOpenState() const;
@@ -110,6 +110,7 @@ namespace hex {
bool m_windowOpen = false, m_prevWindowOpen = false;
std::map<Shortcut, ShortcutManager::ShortcutEntry> m_shortcuts;
bool m_windowJustOpened = false;
const char *m_icon;
friend class ShortcutManager;
};
@@ -120,7 +121,7 @@ namespace hex {
*/
class View::Window : public View {
public:
explicit Window(UnlocalizedString unlocalizedName) : View(std::move(unlocalizedName)) {}
explicit Window(UnlocalizedString unlocalizedName, const char *icon) : View(std::move(unlocalizedName), icon) {}
void draw() final {
if (this->shouldDraw()) {
@@ -139,7 +140,7 @@ namespace hex {
*/
class View::Special : public View {
public:
explicit Special(UnlocalizedString unlocalizedName) : View(std::move(unlocalizedName)) {}
explicit Special(UnlocalizedString unlocalizedName) : View(std::move(unlocalizedName), "") {}
void draw() final {
if (this->shouldDraw()) {
@@ -154,7 +155,7 @@ namespace hex {
*/
class View::Floating : public View::Window {
public:
explicit Floating(UnlocalizedString unlocalizedName) : Window(std::move(unlocalizedName)) {}
explicit Floating(UnlocalizedString unlocalizedName) : Window(std::move(unlocalizedName), "") {}
[[nodiscard]] ImGuiWindowFlags getWindowFlags() const override { return ImGuiWindowFlags_NoDocking; }
};
@@ -164,7 +165,7 @@ namespace hex {
*/
class View::Modal : public View {
public:
explicit Modal(UnlocalizedString unlocalizedName) : View(std::move(unlocalizedName)) {}
explicit Modal(UnlocalizedString unlocalizedName) : View(std::move(unlocalizedName), "") {}
void draw() final {
if (this->shouldDraw()) {

View File

@@ -723,10 +723,14 @@ namespace hex {
}
void addMenuItem(const std::vector<UnlocalizedString> &unlocalizedMainMenuNames, u32 priority, const Shortcut &shortcut, const impl::MenuCallback &function, const impl::EnabledCallback& enabledCallback, View *view) {
addMenuItem(unlocalizedMainMenuNames, nullptr, priority, shortcut, function, enabledCallback, view);
}
void addMenuItem(const std::vector<UnlocalizedString> &unlocalizedMainMenuNames, const char *icon, u32 priority, const Shortcut &shortcut, const impl::MenuCallback &function, const impl::EnabledCallback& enabledCallback, View *view) {
log::debug("Added new menu item to menu {} with priority {}", unlocalizedMainMenuNames[0].get(), priority);
impl::getMenuItems().insert({
priority, impl::MenuItem { unlocalizedMainMenuNames, std::make_unique<Shortcut>(shortcut), view, function, enabledCallback }
priority, impl::MenuItem { unlocalizedMainMenuNames, icon, std::make_unique<Shortcut>(shortcut), view, function, enabledCallback }
});
if (shortcut != Shortcut::None) {
@@ -738,18 +742,22 @@ namespace hex {
}
void addMenuItemSubMenu(std::vector<UnlocalizedString> unlocalizedMainMenuNames, u32 priority, const impl::MenuCallback &function, const impl::EnabledCallback& enabledCallback) {
addMenuItemSubMenu(std::move(unlocalizedMainMenuNames), nullptr, priority, function, enabledCallback);
}
void addMenuItemSubMenu(std::vector<UnlocalizedString> unlocalizedMainMenuNames, const char *icon, u32 priority, const impl::MenuCallback &function, const impl::EnabledCallback& enabledCallback) {
log::debug("Added new menu item sub menu to menu {} with priority {}", unlocalizedMainMenuNames[0].get(), priority);
unlocalizedMainMenuNames.emplace_back(impl::SubMenuValue);
impl::getMenuItems().insert({
priority, impl::MenuItem { unlocalizedMainMenuNames, std::make_unique<Shortcut>(), nullptr, function, enabledCallback }
priority, impl::MenuItem { unlocalizedMainMenuNames, icon, std::make_unique<Shortcut>(), nullptr, function, enabledCallback }
});
}
void addMenuItemSeparator(std::vector<UnlocalizedString> unlocalizedMainMenuNames, u32 priority) {
unlocalizedMainMenuNames.emplace_back(impl::SeparatorValue);
impl::getMenuItems().insert({
priority, impl::MenuItem { unlocalizedMainMenuNames, std::make_unique<Shortcut>(), nullptr, []{}, []{ return true; } }
priority, impl::MenuItem { unlocalizedMainMenuNames, "", std::make_unique<Shortcut>(), nullptr, []{}, []{ return true; } }
});
}

View File

@@ -6,7 +6,7 @@
namespace hex {
View::View(UnlocalizedString unlocalizedName) : m_unlocalizedViewName(std::move(unlocalizedName)) { }
View::View(UnlocalizedString unlocalizedName, const char *icon) : m_unlocalizedViewName(std::move(unlocalizedName)), m_icon(icon) { }
bool View::shouldDraw() const {
return ImHexApi::Provider::isValid() && ImHexApi::Provider::get()->isAvailable();

View File

@@ -1,15 +1,13 @@
// Generated by https://github.com/juliettef/IconFontCppHeaders script GenerateIconFontCppHeaders.py for languages C and C++
// from https://raw.githubusercontent.com/microsoft/vscode-codicons/main/dist/codicon.css
// for use with https://github.com/microsoft/vscode-codicons/raw/main/dist/codicon.ttf
// for use with https://github.com/microsoft/vscode-codicons/blob/main/dist/codicon.ttf
#pragma once
#define FONT_ICON_FILE_NAME_VS "codicon.ttf"
extern const unsigned int codicons_compressed_size;
extern const unsigned int codicons_compressed_data[52184/4];
#define ICON_MIN_VS 0xea60
#define ICON_MAX_VS 0xec19
#define ICON_MAX_16_VS 0xec25
#define ICON_MAX_VS 0xec25
#define ICON_VS_ADD "\xee\xa9\xa0" // U+ea60
#define ICON_VS_PLUS "\xee\xa9\xa0" // U+ea60
#define ICON_VS_GIST_NEW "\xee\xa9\xa0" // U+ea60
@@ -25,6 +23,7 @@ extern const unsigned int codicons_compressed_data[52184/4];
#define ICON_VS_RECORD_KEYS "\xee\xa9\xa5" // U+ea65
#define ICON_VS_KEYBOARD "\xee\xa9\xa5" // U+ea65
#define ICON_VS_TAG "\xee\xa9\xa6" // U+ea66
#define ICON_VS_GIT_PULL_REQUEST_LABEL "\xee\xa9\xa6" // U+ea66
#define ICON_VS_TAG_ADD "\xee\xa9\xa6" // U+ea66
#define ICON_VS_TAG_REMOVE "\xee\xa9\xa6" // U+ea66
#define ICON_VS_PERSON "\xee\xa9\xa7" // U+ea67
@@ -60,6 +59,7 @@ extern const unsigned int codicons_compressed_data[52184/4];
#define ICON_VS_DEBUG_BREAKPOINT "\xee\xa9\xb1" // U+ea71
#define ICON_VS_DEBUG_BREAKPOINT_DISABLED "\xee\xa9\xb1" // U+ea71
#define ICON_VS_DEBUG_HINT "\xee\xa9\xb1" // U+ea71
#define ICON_VS_TERMINAL_DECORATION_SUCCESS "\xee\xa9\xb1" // U+ea71
#define ICON_VS_PRIMITIVE_SQUARE "\xee\xa9\xb2" // U+ea72
#define ICON_VS_EDIT "\xee\xa9\xb3" // U+ea73
#define ICON_VS_PENCIL "\xee\xa9\xb3" // U+ea73
@@ -179,7 +179,9 @@ extern const unsigned int codicons_compressed_data[52184/4];
#define ICON_VS_CHROME_MINIMIZE "\xee\xaa\xba" // U+eaba
#define ICON_VS_CHROME_RESTORE "\xee\xaa\xbb" // U+eabb
#define ICON_VS_CIRCLE_OUTLINE "\xee\xaa\xbc" // U+eabc
#define ICON_VS_CIRCLE "\xee\xaa\xbc" // U+eabc
#define ICON_VS_DEBUG_BREAKPOINT_UNVERIFIED "\xee\xaa\xbc" // U+eabc
#define ICON_VS_TERMINAL_DECORATION_INCOMPLETE "\xee\xaa\xbc" // U+eabc
#define ICON_VS_CIRCLE_SLASH "\xee\xaa\xbd" // U+eabd
#define ICON_VS_CIRCUIT_BOARD "\xee\xaa\xbe" // U+eabe
#define ICON_VS_CLEAR_ALL "\xee\xaa\xbf" // U+eabf
@@ -214,6 +216,7 @@ extern const unsigned int codicons_compressed_data[52184/4];
#define ICON_VS_DIFF_REMOVED "\xee\xab\x9f" // U+eadf
#define ICON_VS_DIFF_RENAMED "\xee\xab\xa0" // U+eae0
#define ICON_VS_DIFF "\xee\xab\xa1" // U+eae1
#define ICON_VS_DIFF_SIDEBYSIDE "\xee\xab\xa1" // U+eae1
#define ICON_VS_DISCARD "\xee\xab\xa2" // U+eae2
#define ICON_VS_EDITOR_LAYOUT "\xee\xab\xa3" // U+eae3
#define ICON_VS_EMPTY_WINDOW "\xee\xab\xa4" // U+eae4
@@ -277,6 +280,7 @@ extern const unsigned int codicons_compressed_data[52184/4];
#define ICON_VS_MEGAPHONE "\xee\xac\x9e" // U+eb1e
#define ICON_VS_MENTION "\xee\xac\x9f" // U+eb1f
#define ICON_VS_MILESTONE "\xee\xac\xa0" // U+eb20
#define ICON_VS_GIT_PULL_REQUEST_MILESTONE "\xee\xac\xa0" // U+eb20
#define ICON_VS_MORTAR_BOARD "\xee\xac\xa1" // U+eb21
#define ICON_VS_MOVE "\xee\xac\xa2" // U+eb22
#define ICON_VS_MULTIPLE_WINDOWS "\xee\xac\xa3" // U+eb23
@@ -386,7 +390,9 @@ extern const unsigned int codicons_compressed_data[52184/4];
#define ICON_VS_DEBUG_BREAKPOINT_FUNCTION "\xee\xae\x88" // U+eb88
#define ICON_VS_DEBUG_BREAKPOINT_FUNCTION_DISABLED "\xee\xae\x88" // U+eb88
#define ICON_VS_DEBUG_STACKFRAME_ACTIVE "\xee\xae\x89" // U+eb89
#define ICON_VS_CIRCLE_SMALL_FILLED "\xee\xae\x8a" // U+eb8a
#define ICON_VS_DEBUG_STACKFRAME_DOT "\xee\xae\x8a" // U+eb8a
#define ICON_VS_TERMINAL_DECORATION_MARK "\xee\xae\x8a" // U+eb8a
#define ICON_VS_DEBUG_STACKFRAME "\xee\xae\x8b" // U+eb8b
#define ICON_VS_DEBUG_STACKFRAME_FOCUSED "\xee\xae\x8b" // U+eb8b
#define ICON_VS_DEBUG_BREAKPOINT_UNSUPPORTED "\xee\xae\x8c" // U+eb8c
@@ -400,9 +406,11 @@ extern const unsigned int codicons_compressed_data[52184/4];
#define ICON_VS_MENU "\xee\xae\x94" // U+eb94
#define ICON_VS_EXPAND_ALL "\xee\xae\x95" // U+eb95
#define ICON_VS_FEEDBACK "\xee\xae\x96" // U+eb96
#define ICON_VS_GIT_PULL_REQUEST_REVIEWER "\xee\xae\x96" // U+eb96
#define ICON_VS_GROUP_BY_REF_TYPE "\xee\xae\x97" // U+eb97
#define ICON_VS_UNGROUP_BY_REF_TYPE "\xee\xae\x98" // U+eb98
#define ICON_VS_ACCOUNT "\xee\xae\x99" // U+eb99
#define ICON_VS_GIT_PULL_REQUEST_ASSIGNEE "\xee\xae\x99" // U+eb99
#define ICON_VS_BELL_DOT "\xee\xae\x9a" // U+eb9a
#define ICON_VS_DEBUG_CONSOLE "\xee\xae\x9b" // U+eb9b
#define ICON_VS_LIBRARY "\xee\xae\x9c" // U+eb9c
@@ -431,6 +439,7 @@ extern const unsigned int codicons_compressed_data[52184/4];
#define ICON_VS_PINNED_DIRTY "\xee\xae\xb2" // U+ebb2
#define ICON_VS_PASS_FILLED "\xee\xae\xb3" // U+ebb3
#define ICON_VS_CIRCLE_LARGE_FILLED "\xee\xae\xb4" // U+ebb4
#define ICON_VS_CIRCLE_LARGE "\xee\xae\xb5" // U+ebb5
#define ICON_VS_CIRCLE_LARGE_OUTLINE "\xee\xae\xb5" // U+ebb5
#define ICON_VS_COMBINE "\xee\xae\xb6" // U+ebb6
#define ICON_VS_GATHER "\xee\xae\xb6" // U+ebb6
@@ -473,4 +482,77 @@ extern const unsigned int codicons_compressed_data[52184/4];
#define ICON_VS_GIT_PULL_REQUEST_DRAFT "\xee\xaf\x9b" // U+ebdb
#define ICON_VS_DEBUG_ALL "\xee\xaf\x9c" // U+ebdc
#define ICON_VS_DEBUG_COVERAGE "\xee\xaf\x9d" // U+ebdd
#define ICON_VS_CHIP "\xee\xb0\x99" // U+ec19
#define ICON_VS_RUN_ERRORS "\xee\xaf\x9e" // U+ebde
#define ICON_VS_FOLDER_LIBRARY "\xee\xaf\x9f" // U+ebdf
#define ICON_VS_DEBUG_CONTINUE_SMALL "\xee\xaf\xa0" // U+ebe0
#define ICON_VS_BEAKER_STOP "\xee\xaf\xa1" // U+ebe1
#define ICON_VS_GRAPH_LINE "\xee\xaf\xa2" // U+ebe2
#define ICON_VS_GRAPH_SCATTER "\xee\xaf\xa3" // U+ebe3
#define ICON_VS_PIE_CHART "\xee\xaf\xa4" // U+ebe4
#define ICON_VS_BRACKET "\xee\xac\x8f" // U+eb0f
#define ICON_VS_BRACKET_DOT "\xee\xaf\xa5" // U+ebe5
#define ICON_VS_BRACKET_ERROR "\xee\xaf\xa6" // U+ebe6
#define ICON_VS_LOCK_SMALL "\xee\xaf\xa7" // U+ebe7
#define ICON_VS_AZURE_DEVOPS "\xee\xaf\xa8" // U+ebe8
#define ICON_VS_VERIFIED_FILLED "\xee\xaf\xa9" // U+ebe9
#define ICON_VS_NEWLINE "\xee\xaf\xaa" // U+ebea
#define ICON_VS_LAYOUT "\xee\xaf\xab" // U+ebeb
#define ICON_VS_LAYOUT_ACTIVITYBAR_LEFT "\xee\xaf\xac" // U+ebec
#define ICON_VS_LAYOUT_ACTIVITYBAR_RIGHT "\xee\xaf\xad" // U+ebed
#define ICON_VS_LAYOUT_PANEL_LEFT "\xee\xaf\xae" // U+ebee
#define ICON_VS_LAYOUT_PANEL_CENTER "\xee\xaf\xaf" // U+ebef
#define ICON_VS_LAYOUT_PANEL_JUSTIFY "\xee\xaf\xb0" // U+ebf0
#define ICON_VS_LAYOUT_PANEL_RIGHT "\xee\xaf\xb1" // U+ebf1
#define ICON_VS_LAYOUT_PANEL "\xee\xaf\xb2" // U+ebf2
#define ICON_VS_LAYOUT_SIDEBAR_LEFT "\xee\xaf\xb3" // U+ebf3
#define ICON_VS_LAYOUT_SIDEBAR_RIGHT "\xee\xaf\xb4" // U+ebf4
#define ICON_VS_LAYOUT_STATUSBAR "\xee\xaf\xb5" // U+ebf5
#define ICON_VS_LAYOUT_MENUBAR "\xee\xaf\xb6" // U+ebf6
#define ICON_VS_LAYOUT_CENTERED "\xee\xaf\xb7" // U+ebf7
#define ICON_VS_TARGET "\xee\xaf\xb8" // U+ebf8
#define ICON_VS_INDENT "\xee\xaf\xb9" // U+ebf9
#define ICON_VS_RECORD_SMALL "\xee\xaf\xba" // U+ebfa
#define ICON_VS_ERROR_SMALL "\xee\xaf\xbb" // U+ebfb
#define ICON_VS_TERMINAL_DECORATION_ERROR "\xee\xaf\xbb" // U+ebfb
#define ICON_VS_ARROW_CIRCLE_DOWN "\xee\xaf\xbc" // U+ebfc
#define ICON_VS_ARROW_CIRCLE_LEFT "\xee\xaf\xbd" // U+ebfd
#define ICON_VS_ARROW_CIRCLE_RIGHT "\xee\xaf\xbe" // U+ebfe
#define ICON_VS_ARROW_CIRCLE_UP "\xee\xaf\xbf" // U+ebff
#define ICON_VS_LAYOUT_SIDEBAR_RIGHT_OFF "\xee\xb0\x80" // U+ec00
#define ICON_VS_LAYOUT_PANEL_OFF "\xee\xb0\x81" // U+ec01
#define ICON_VS_LAYOUT_SIDEBAR_LEFT_OFF "\xee\xb0\x82" // U+ec02
#define ICON_VS_BLANK "\xee\xb0\x83" // U+ec03
#define ICON_VS_HEART_FILLED "\xee\xb0\x84" // U+ec04
#define ICON_VS_MAP "\xee\xb0\x85" // U+ec05
#define ICON_VS_MAP_FILLED "\xee\xb0\x86" // U+ec06
#define ICON_VS_CIRCLE_SMALL "\xee\xb0\x87" // U+ec07
#define ICON_VS_BELL_SLASH "\xee\xb0\x88" // U+ec08
#define ICON_VS_BELL_SLASH_DOT "\xee\xb0\x89" // U+ec09
#define ICON_VS_COMMENT_UNRESOLVED "\xee\xb0\x8a" // U+ec0a
#define ICON_VS_GIT_PULL_REQUEST_GO_TO_CHANGES "\xee\xb0\x8b" // U+ec0b
#define ICON_VS_GIT_PULL_REQUEST_NEW_CHANGES "\xee\xb0\x8c" // U+ec0c
#define ICON_VS_SEARCH_FUZZY "\xee\xb0\x8d" // U+ec0d
#define ICON_VS_COMMENT_DRAFT "\xee\xb0\x8e" // U+ec0e
#define ICON_VS_SEND "\xee\xb0\x8f" // U+ec0f
#define ICON_VS_SPARKLE "\xee\xb0\x90" // U+ec10
#define ICON_VS_INSERT "\xee\xb0\x91" // U+ec11
#define ICON_VS_MIC "\xee\xb0\x92" // U+ec12
#define ICON_VS_THUMBSDOWN_FILLED "\xee\xb0\x93" // U+ec13
#define ICON_VS_THUMBSUP_FILLED "\xee\xb0\x94" // U+ec14
#define ICON_VS_COFFEE "\xee\xb0\x95" // U+ec15
#define ICON_VS_SNAKE "\xee\xb0\x96" // U+ec16
#define ICON_VS_GAME "\xee\xb0\x97" // U+ec17
#define ICON_VS_VR "\xee\xb0\x98" // U+ec18
#define ICON_VS_CHIP "\xee\xb0\x99" // U+ec19
#define ICON_VS_PIANO "\xee\xb0\x9a" // U+ec1a
#define ICON_VS_MUSIC "\xee\xb0\x9b" // U+ec1b
#define ICON_VS_MIC_FILLED "\xee\xb0\x9c" // U+ec1c
#define ICON_VS_GIT_FETCH "\xee\xb0\x9d" // U+ec1d
#define ICON_VS_COPILOT "\xee\xb0\x9e" // U+ec1e
#define ICON_VS_LIGHTBULB_SPARKLE "\xee\xb0\x9f" // U+ec1f
#define ICON_VS_ROBOT "\xee\xb0\xa0" // U+ec20
#define ICON_VS_SPARKLE_FILLED "\xee\xb0\xa1" // U+ec21
#define ICON_VS_DIFF_SINGLE "\xee\xb0\xa2" // U+ec22
#define ICON_VS_DIFF_MULTIPLE "\xee\xb0\xa3" // U+ec23
#define ICON_VS_SURROUND_WITH "\xee\xb0\xa4" // U+ec24
#define ICON_VS_SHARE "\xee\xb0\xa5" // U+ec25