mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-30 02:31:44 +00:00
[wpigui] Add icon support
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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";
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user