12#include <Common/assertion.h>
13#include <Common/Container/TStdUnorderedStringMap.h>
14#include <Utility/utility.h>
15#include <Math/TVector2.h>
16#include <Math/TVector4.h>
17#include <DataIO/FileSystem/Path.h>
32class RenderThreadCaller;
62 const math::Vector2F& sizePx,
63 const math::Vector4F& tintColorRGBA = math::Vector4F(1, 1, 1, 1),
64 const math::Vector4F& borderColorRGBA = math::Vector4F(0, 0, 0, 0))
const;
67 std::string_view imageName,
68 const math::Vector2F& sizePx,
69 const math::Vector4F& tintColorRGBA = math::Vector4F(1, 1, 1, 1),
70 const math::Vector4F& borderColorRGBA = math::Vector4F(0, 0, 0, 0))
const;
75 const math::Vector2F& sizePx,
76 const math::Vector4F& backgroundColorRGBA = math::Vector4F(0, 0, 0, 0),
77 const math::Vector4F& tintColorRGBA = math::Vector4F(1, 1, 1, 1));
81 std::string_view imageName,
82 const math::Vector2F& sizePx,
83 const math::Vector4F& backgroundColorRGBA = math::Vector4F(0, 0, 0, 0),
84 const math::Vector4F& tintColorRGBA = math::Vector4F(1, 1, 1, 1));
86 ImTextureID
get(std::string_view imageName)
const;
93 bool has(std::string_view imageName)
const;
98 math::Vector2UI
getSizePx(std::string_view imageName)
const;
114 std::string_view imageName,
115 const Path& filePath,
116 math::Vector2UI sizePx = {0, 0},
120 std::string_view imageName,
121 math::Vector2UI sizePx,
141 ImTextureID textureID =
nullptr;
142 math::Vector2UI sizePx = {0, 0};
148 std::string entryName;
151 math::Vector2UI sizePx = {0, 0};
155 struct NativeHandleRetriever
157 std::string entryName;
161 bool isFinished =
false;
164 auto getEntry(std::string_view name)
const ->
const Entry*;
169 std::vector<Loader> m_loaders;
170 std::vector<NativeHandleRetriever> m_retrievers;
171 std::vector<render::TextureHandle> m_unloadingTextures;
172 TStdUnorderedStringMap<Entry> m_namedEntries;
173 std::array<Entry, enum_size<EImguiImage>()> m_builtinEntries;
178 const Entry* entry = getEntry(name);
179 return entry ? entry->sizePx : math::Vector2UI{0, 0};
184 const Entry* entry = getEntry(name);
190 const Entry* entry = getEntry(name);
196 const Entry* entry = getEntry(name);
208 auto iter = m_namedEntries.find(imageName);
209 return iter != m_namedEntries.end() ? iter->second.textureID :
nullptr;
214 PH_ASSERT_LT(
static_cast<std::size_t
>(targetImage), m_builtinEntries.size());
215 return m_builtinEntries[
static_cast<std::size_t
>(targetImage)].textureID;
220 return getEntry(imageName) !=
nullptr;
223inline auto ImguiImageLibrary::getEntry(std::string_view imageName)
const
226 auto iter = m_namedEntries.find(imageName);
227 return iter != m_namedEntries.end() ? &(iter->second) : nullptr;
Definition ImguiImageLibrary.h:52
void initialize(Editor *editor)
Definition ImguiImageLibrary.cpp:33
void unloadImage(std::string_view imageName)
Definition ImguiImageLibrary.cpp:153
bool imguiImageButton(const char *strId, EImguiImage targetImage, const math::Vector2F &sizePx, const math::Vector4F &backgroundColorRGBA=math::Vector4F(0, 0, 0, 0), const math::Vector4F &tintColorRGBA=math::Vector4F(1, 1, 1, 1))
Definition ImguiImageLibrary.cpp:62
void terminate()
Definition ImguiImageLibrary.cpp:39
void createRenderCommands(RenderThreadCaller &caller, render::Scene &scene)
Definition ImguiImageLibrary.cpp:190
void cleanupTextures(RenderThreadCaller &caller, render::Scene &scene)
Unload all named and builtin images.
Definition ImguiImageLibrary.cpp:357
render::TextureHandle getHandle(std::string_view imageName) const
Definition ImguiImageLibrary.h:188
ImguiImageLibrary()
Definition ImguiImageLibrary.cpp:22
void loadImage(EImguiImage targetImage, const Path &filePath)
Definition ImguiImageLibrary.cpp:84
void imguiImage(EImguiImage targetImage, const math::Vector2F &sizePx, const math::Vector4F &tintColorRGBA=math::Vector4F(1, 1, 1, 1), const math::Vector4F &borderColorRGBA=math::Vector4F(0, 0, 0, 0)) const
Definition ImguiImageLibrary.cpp:42
ghi::ESizedPixelFormat getFormat(std::string_view imageName) const
Definition ImguiImageLibrary.h:182
math::Vector2UI getSizePx(std::string_view imageName) const
Get information of a named image.
Definition ImguiImageLibrary.h:176
Editor & getEditor()
Definition ImguiImageLibrary.h:200
ImTextureID get(std::string_view imageName) const
Definition ImguiImageLibrary.h:206
ghi::TextureHandle getGraphicsHandle(std::string_view imageName) const
Definition ImguiImageLibrary.h:194
bool has(std::string_view imageName) const
Whether the library has the image. If true is returned, does not mean get(imageName) will necessary r...
Definition ImguiImageLibrary.h:218
Thin wrapper for render thread interactions from another thread. Mainly to hide unrelated render thre...
Definition RenderThreadCaller.h:16
A scene for the editor renderer only.
Definition Scene.h:34
ESizedPixelFormat
Combined pixel layout and component type information. Unless stated explicitly, the characters RGB do...
Definition ghi_enums.h:19
std::variant< std::monostate, uint64 > TextureNativeHandle
Definition ghi_fwd.h:52
TQuery< GraphicsContext, Performer > TQueryOf
Definition query_basics.h:15
Definition DesignerObject.h:19
TQuery< System, Performer > TQueryOf
Definition query_basics.h:15
Definition ph_editor.h:10
@ File
Definition ImguiEditorPanel.h:13
EImguiImage
Built-in images.
Definition ImguiImageLibrary.h:37