Add default image provider
This commit is contained in:
parent
852a170c97
commit
c1699fe882
3 changed files with 31 additions and 1 deletions
30
libs/ui/include/psemek/ui/default_image_provider.hpp
Normal file
30
libs/ui/include/psemek/ui/default_image_provider.hpp
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <psemek/ui/image_provider.hpp>
|
||||||
|
#include <psemek/util/hstring.hpp>
|
||||||
|
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
|
namespace psemek::ui
|
||||||
|
{
|
||||||
|
|
||||||
|
struct default_image_provider
|
||||||
|
: image_provider
|
||||||
|
{
|
||||||
|
void put(std::string id, gfx::texture_view_2d view)
|
||||||
|
{
|
||||||
|
images_[std::move(id)] = view;
|
||||||
|
}
|
||||||
|
|
||||||
|
gfx::texture_view_2d get(std::string_view const & id) const override
|
||||||
|
{
|
||||||
|
if (auto it = images_.find(id); it != images_.end())
|
||||||
|
return it->second;
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::unordered_map<util::hstring, gfx::texture_view_2d> images_;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -9,7 +9,7 @@ namespace psemek::ui
|
||||||
|
|
||||||
struct image_provider
|
struct image_provider
|
||||||
{
|
{
|
||||||
virtual gfx::texture_view_2d get(std::string_view const & id) = 0;
|
virtual gfx::texture_view_2d get(std::string_view const & id) const = 0;
|
||||||
|
|
||||||
virtual ~ image_provider() {}
|
virtual ~ image_provider() {}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
0
libs/ui/source/default_image_provider.cpp
Normal file
0
libs/ui/source/default_image_provider.cpp
Normal file
Loading…
Add table
Reference in a new issue