| 1 |
#ifndef OSDRECTANGLE_HH |
| 2 |
#define OSDRECTANGLE_HH |
| 3 |
|
| 4 |
#include "OSDImageBasedWidget.hh" |
| 5 |
#include "stl.hh" |
| 6 |
#include <array> |
| 7 |
#include <cstdint> |
| 8 |
#include <memory> |
| 9 |
|
| 10 |
namespace openmsx { |
| 11 |
|
| 12 |
class GLImage; |
| 13 |
|
| 14 |
class OSDRectangle final : public OSDImageBasedWidget |
| 15 |
{ |
| 16 |
private: |
| 17 |
static constexpr auto rectangleProperties = [] { |
| 18 |
using namespace std::literals; |
| 19 |
return concatArray( |
| 20 |
imageBasedProperties, |
| 21 |
std::array{ |
| 22 |
"-w"sv, "-h"sv, "-relw"sv, "-relh"sv, |
| 23 |
"-scale"sv, "-image"sv, |
| 24 |
"-bordersize"sv, "-relbordersize"sv, |
| 25 |
"-borderrgba"sv, |
| 26 |
}); |
| 27 |
}(); |
| 28 |
|
| 29 |
public: |
| 30 |
OSDRectangle(Display& display, const TclObject& name); |
| 31 |
|
| 32 |
[[nodiscard]] std::span<const std::string_view> getProperties() const override { |
| 33 |
return rectangleProperties; |
| 34 |
} |
| 35 |
void setProperty(Interpreter& interp, |
| 36 |
std::string_view name, const TclObject& value) override; |
| 37 |
void getProperty(std::string_view name, TclObject& result) const override; |
| 38 |
[[nodiscard]] std::string_view getType() const override; |
| 39 |
|
| 40 |
private: |
| 41 |
[[nodiscard]] bool takeImageDimensions() const; |
| 42 |
|
| 43 |
[[nodiscard]] gl::vec2 getSize(const OutputSurface& output) const override; |
| 44 |
[[nodiscard]] uint8_t getFadedAlpha() const override; |
| 45 |
[[nodiscard]] std::unique_ptr<GLImage> create(OutputSurface& output) override; |
| 46 |
|
| 47 |
private: |
| 48 |
std::string imageName; |
| 49 |
gl::vec2 size, relSize; |
| 50 |
float scale = 1.0f; |
| 51 |
float borderSize = 0.0f; |
| 52 |
float relBorderSize = 0.0f; |
| 53 |
uint32_t borderRGBA = 0x000000ff; |
| 54 |
}; |
| 55 |
|
| 56 |
} |
| 57 |
|
| 58 |
#endif |