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  bool isVisible() const override;
26  bool isRecursiveFading() const override;
27 
28 protected:
29  OSDImageBasedWidget(Display& display, const TclObject& name);
31  bool hasConstantAlpha() const;
32  void createImage(OutputSurface& output);
33  void invalidateLocal() override;
34  void paintSDL(OutputSurface& output) override;
35  void paintGL (OutputSurface& output) override;
36  virtual std::unique_ptr<BaseImage> createSDL(OutputSurface& output) = 0;
37  virtual std::unique_ptr<BaseImage> createGL (OutputSurface& output) = 0;
38 
39  void setError(std::string message);
40  bool hasError() const { return error; }
41 
42  std::unique_ptr<BaseImage> image;
43 
44 private:
45  void setRGBA(const uint32_t newRGBA[4]);
46  bool isFading() const;
47  float getCurrentFadeValue() const;
48  float getCurrentFadeValue(uint64_t now) const;
49  void updateCurrentFadeValue();
50 
51  void paint(OutputSurface& output, bool openGL);
52  gl::vec2 getTransformedPos(const OutputSurface& output) const;
53 
54  uint64_t startFadeTime;
55  float fadePeriod;
56  float fadeTarget;
57  mutable float startFadeValue;
58  uint32_t rgba[4];
59  bool error;
60 };
61 
62 } // namespace openmsx
63 
64 #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
openmsx::OSDImageBasedWidget::isVisible
bool isVisible() const override
Definition: OSDImageBasedWidget.cc:161
gl::vecN
Definition: gl_vec.hh:36
openmsx::OSDImageBasedWidget::createImage
void createImage(OutputSurface &output)
Definition: OSDImageBasedWidget.cc:256
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:230
openmsx::OSDImageBasedWidget::paintGL
void paintGL(OutputSurface &output) override
Definition: OSDImageBasedWidget.cc:251
openmsx::OSDImageBasedWidget::image
std::unique_ptr< BaseImage > image
Definition: OSDImageBasedWidget.hh:42
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:246
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:40
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::isRecursiveFading
bool isRecursiveFading() const override
Definition: OSDImageBasedWidget.cc:171
openmsx::OSDImageBasedWidget::invalidateLocal
void invalidateLocal() override
Definition: OSDImageBasedWidget.cc:218