guillaume 2026.6.1
A C++ UI framework designed for modern desktop and extended reality (XR) applications.
Loading...
Searching...
No Matches
image.hpp
1/*
2 Copyright (c) 2026 ETIB Corporation
3
4 Permission is hereby granted, free of charge, to any person obtaining a copy of
5 this software and associated documentation files (the "Software"), to deal in
6 the Software without restriction, including without limitation the rights to
7 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
8 of the Software, and to permit persons to whom the Software is furnished to do
9 so, subject to the following conditions:
10
11 The above copyright notice and this permission notice shall be included in all
12 copies or substantial portions of the Software.
13
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 SOFTWARE.
21 */
22
23#pragma once
24
25#include <string>
26
27#include "guillaume/ecs/component.hpp"
28
30{
55 class Image: public ecs::Component
56 {
57 public:
67
68 private:
69 std::string _texturePath {};
70 std::string _fallbackPath {};
71 LoadState _loadState { LoadState::Pending };
72 bool _usingFallback { false };
73
74 public:
78 Image(void) = default;
79
83 ~Image(void) = default;
84
96 Image &setTexturePath(const std::string &path);
97
102 const std::string &getTexturePath(void) const;
103
114 Image &setFallbackPath(const std::string &path);
115
120 const std::string &getFallbackPath(void) const;
121
127 LoadState getLoadState(void) const;
128
142 Image &setLoadState(LoadState state, bool usingFallback = false);
143
149 bool isUsingFallback(void) const;
150 };
151} // namespace guillaume::components
Image(void)=default
Default constructor for the Image component.
Image & setTexturePath(const std::string &path)
Choose the texture to draw.
Definition image.cpp:27
LoadState
Whether the texture could be loaded, as recorded by systems::ImageRender.
Definition image.hpp:62
@ Pending
Not attempted since the path was set.
Definition image.hpp:63
@ Loaded
The texture (or the fallback) is drawn.
Definition image.hpp:64
@ Failed
Neither loaded; nothing is drawn.
Definition image.hpp:65
~Image(void)=default
Default destructor for the Image component.
Image & setLoadState(LoadState state, bool usingFallback=false)
Record the outcome of a load attempt. Called by systems::ImageRender.
Definition image.cpp:62
Image & setFallbackPath(const std::string &path)
Set the texture drawn when the main texture fails to load.
Definition image.cpp:39
LoadState getLoadState(void) const
Get the outcome of the last load attempt.
Definition image.cpp:57
const std::string & getTexturePath(void) const
Get the path of the texture to draw.
Definition image.cpp:76
bool isUsingFallback(void) const
Check whether the fallback texture is drawn.
Definition image.cpp:71
const std::string & getFallbackPath(void) const
Get the path of the fallback texture.
Definition image.cpp:52
Base class of every component: a piece of state attached to an entity, plus a "changed" flag.
Definition component.hpp:72
State. Every class here is plain data attached to an entity.