[wpigui] Add icon support

This commit is contained in:
Peter Johnson
2020-12-23 13:05:25 -08:00
parent 6b567e0066
commit 7ac39b10f7
3 changed files with 41 additions and 0 deletions

View File

@@ -12,6 +12,11 @@
#include <imgui.h>
#if __has_include(<wpi/StringRef.h>)
#include <wpi/StringRef.h>
#define WPIGUI_HAS_STRINGREF
#endif
extern "C" struct GLFWwindow;
namespace wpi::gui {
@@ -86,6 +91,22 @@ void AddLateExecute(std::function<void()> execute);
*/
GLFWwindow* GetSystemWindow();
/**
* Adds an application icon. Multiple icons (of different sizes) may be
* set. This must be called prior to initialization to have an effect.
*
* @param data image data
* @param len image data length
* @return False if image data could not be read
*/
bool AddIcon(const unsigned char* data, int len);
#ifdef WPIGUI_HAS_STRINGREF
inline bool AddIcon(wpi::StringRef data) {
return AddIcon(data.bytes_begin(), data.size());
}
#endif
/**
* Adds a font to the GUI. The passed function is called during
* initialization as many times as necessary to create a range of sizes.

View File

@@ -57,6 +57,8 @@ struct Context : public SavedSettings {
int fontScale = 2; // updated by main loop
std::vector<Font> fonts;
std::vector<GLFWimage> icons;
std::string iniPath = "imgui.ini";
};