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