openMSX
OSDImageBasedWidget.hh
Go to the documentation of this file.
1 #ifndef OSDIMAGEBASEDWIDGET_HH
2 #define OSDIMAGEBASEDWIDGET_HH
3 
4 #include "OSDWidget.hh"
5 #include <cstdint>
6 
7 namespace openmsx {
8 
9 class BaseImage;
10 class Display;
11 
13 {
14 public:
15  uint32_t getRGBA(uint32_t corner) const { return rgba[corner]; }
16  const uint32_t* getRGBA4() const { return rgba; }
17 
18  virtual uint8_t getFadedAlpha() const = 0;
19 
20  std::vector<std::string_view> getProperties() const override;
21  void setProperty(Interpreter& interp,
22  std::string_view name, const TclObject& value) override;
23  void getProperty(std::string_view name, TclObject& result) const override;
24  float getRecursiveFadeValue() const override;
25 
26 protected:
27  OSDImageBasedWidget(Display& display, const TclObject& name);
29  bool hasConstantAlpha() const;
30  void createImage(OutputSurface& output);
31  void invalidateLocal() override;
32  void paintSDL(OutputSurface& output) override;
33  void paintGL (OutputSurface& output) override;
34  virtual std::unique_ptr<BaseImage> createSDL(OutputSurface& output) = 0;
35  virtual std::unique_ptr<BaseImage> createGL (OutputSurface& output) = 0;
36 
37  void setError(std::string message);
38  bool hasError() const { return error; }
39 
40  std::unique_ptr<BaseImage> image;
41 
42 private:
43  void setRGBA(const uint32_t newRGBA[4]);
44  bool isFading() const;
45  float getCurrentFadeValue() const;
46  float getCurrentFadeValue(uint64_t now) const;
47  void updateCurrentFadeValue();
48 
49  void paint(OutputSurface& output, bool openGL);
50  gl::vec2 getTransformedPos(const OutputSurface& output) const;
51 
52  uint64_t startFadeTime;
53  float fadePeriod;
54  float fadeTarget;
55  mutable float startFadeValue;
56  uint32_t rgba[4];
57  bool error;
58 };
59 
60 } // namespace openmsx
61 
62 #endif
openmsx::OSDImageBasedWidget::OSDImageBasedWidget
OSDImageBasedWidget(Display &display, const TclObject &name)
Definition: OSDImageBasedWidget.cc:22
openmsx::OSDImageBasedWidget::getRGBA
uint32_t getRGBA(uint32_t corner) const
Definition: OSDImageBasedWidget.hh:15
openmsx::OSDImageBasedWidget::hasConstantAlpha
bool hasConstantAlpha() const
Definition: OSDImageBasedWidget.cc:151
openmsx::OSDImageBasedWidget::~OSDImageBasedWidget
~OSDImageBasedWidget() override
openmsx::OSDWidget
Definition: OSDWidget.hh:17
openmsx::OSDImageBasedWidget
Definition: OSDImageBasedWidget.hh:13
gl::vecN
Definition: gl_vec.hh:36
openmsx::OSDImageBasedWidget::createImage
void createImage(OutputSurface &output)
Definition: OSDImageBasedWidget.cc:245
openmsx::OSDImageBasedWidget::createSDL
virtual std::unique_ptr< BaseImage > createSDL(OutputSurface &output)=0
openmsx::OSDImageBasedWidget::getProperties
std::vector< std::string_view > getProperties() const override
Definition: OSDImageBasedWidget.cc:35
openmsx::OSDImageBasedWidget::setProperty
void setProperty(Interpreter &interp, std::string_view name, const TclObject &value) override
Definition: OSDImageBasedWidget.cc:62
openmsx::OSDImageBasedWidget::setError
void setError(std::string message)
Definition: OSDImageBasedWidget.cc:219
openmsx::OSDImageBasedWidget::paintGL
void paintGL(OutputSurface &output) override
Definition: OSDImageBasedWidget.cc:240
openmsx::OSDImageBasedWidget::image
std::unique_ptr< BaseImage > image
Definition: OSDImageBasedWidget.hh:40
openmsx::OSDImageBasedWidget::getRecursiveFadeValue
float getRecursiveFadeValue() const override
Definition: OSDImageBasedWidget.cc:156
OSDWidget.hh
openmsx::OSDImageBasedWidget::createGL
virtual std::unique_ptr< BaseImage > createGL(OutputSurface &output)=0
openmsx::OSDImageBasedWidget::paintSDL
void paintSDL(OutputSurface &output) override
Definition: OSDImageBasedWidget.cc:235
openmsx::Display
Represents the output window/screen of openMSX.
Definition: Display.hh:33
openmsx::OSDImageBasedWidget::getProperty
void getProperty(std::string_view name, TclObject &result) const override
Definition: OSDImageBasedWidget.cc:126
openmsx::OutputSurface
A frame buffer where pixels can be written to.
Definition: OutputSurface.hh:20
openmsx::OSDImageBasedWidget::getFadedAlpha
virtual uint8_t getFadedAlpha() const =0
openmsx::TclObject
Definition: TclObject.hh:22
openmsx::Interpreter
Definition: Interpreter.hh:17
openmsx::OSDImageBasedWidget::hasError
bool hasError() const
Definition: OSDImageBasedWidget.hh:38
openmsx
This file implemented 3 utility functions:
Definition: Autofire.cc:5
openmsx::OSDImageBasedWidget::getRGBA4
const uint32_t * getRGBA4() const
Definition: OSDImageBasedWidget.hh:16
openmsx::OSDImageBasedWidget::invalidateLocal
void invalidateLocal() override
Definition: OSDImageBasedWidget.cc:207