openMSX
OSDRectangle.hh
Go to the documentation of this file.
1#ifndef OSDRECTANGLE_HH
2#define OSDRECTANGLE_HH
3
5#include "stl.hh"
6#include <array>
7#include <cstdint>
8#include <memory>
9
10namespace openmsx {
11
12class BaseImage;
13
15{
16protected:
17 static constexpr auto rectangleProperties = [] {
18 using namespace std::literals;
19 return concatArray(
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
29public:
30 OSDRectangle(Display& display, const TclObject& name);
31
32 [[nodiscard]] std::span<const std::string_view> getProperties() const override {
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
40private:
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<BaseImage> createSDL(OutputSurface& output) override;
46 [[nodiscard]] std::unique_ptr<BaseImage> createGL (OutputSurface& output) override;
47 template<typename IMAGE> [[nodiscard]] std::unique_ptr<BaseImage> create(
48 OutputSurface& output);
49
50private:
51 std::string imageName;
52 gl::vec2 size, relSize;
53 float scale = 1.0f;
54 float borderSize = 0.0f;
55 float relBorderSize = 0.0f;
56 uint32_t borderRGBA = 0x000000ff;
57};
58
59} // namespace openmsx
60
61#endif
Represents the output window/screen of openMSX.
Definition: Display.hh:33
static constexpr auto imageBasedProperties
void getProperty(std::string_view name, TclObject &result) const override
Definition: OSDRectangle.cc:94
OSDRectangle(Display &display, const TclObject &name)
Definition: OSDRectangle.cc:21
std::span< const std::string_view > getProperties() const override
Definition: OSDRectangle.hh:32
static constexpr auto rectangleProperties
Definition: OSDRectangle.hh:17
void setProperty(Interpreter &interp, std::string_view name, const TclObject &value) override
Definition: OSDRectangle.cc:26
std::string_view getType() const override
A frame buffer where pixels can be written to.
This file implemented 3 utility functions:
Definition: Autofire.cc:9
constexpr auto concatArray(const std::array< T, X > &x, const std::array< T, Y > &y)
Definition: stl.hh:381