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