openMSX
Layer.hh
Go to the documentation of this file.
1#ifndef LAYER_HH
2#define LAYER_HH
3
4#include "stl.hh"
5
6namespace openmsx {
7
8class Display;
9class OutputSurface;
10
13class Layer
14{
15public:
19 enum class ZIndex {
23 OSDGUI,
24 IMGUI,
25 };
26 [[nodiscard]] friend auto operator<=>(ZIndex x, ZIndex y) { return to_underlying(x) <=> to_underlying(y); }
27
31 enum class Coverage {
34 FULL,
38 PARTIAL,
41 NONE
42 };
43
44 virtual ~Layer() = default;
45
48 virtual void paint(OutputSurface& output) = 0;
49
52 [[nodiscard]] ZIndex getZ() const { return z; }
53 [[nodiscard]] bool isActive() const { return getZ() == ZIndex::MSX_ACTIVE; }
54
57 [[nodiscard]] Coverage getCoverage() const { return coverage; }
58
62 void setDisplay(Display& display_) { display = &display_; }
63
64protected:
66 explicit Layer(Coverage coverage_, ZIndex z_)
67 : coverage(coverage_), z(z_)
68 {
69 }
70
73 void setCoverage(Coverage coverage_) { coverage = coverage_; }
74
77 void setZ(ZIndex z);
78
79private:
81 Display* display = nullptr;
82
84 Coverage coverage;
85
89 ZIndex z;
90
91 friend class ScopedLayerHider; // for setCoverage()
92};
93
94
96{
97public:
98 explicit ScopedLayerHider(Layer& layer);
104private:
105 Layer& layer;
106 Layer::Coverage originalCoverage;
107};
108
109} // namespace openmsx
110
111#endif
Represents the output window/screen of openMSX.
Definition Display.hh:31
Interface for display layers.
Definition Layer.hh:14
Coverage
Describes how much of the screen is currently covered by a particular layer.
Definition Layer.hh:31
@ NONE
Layer is not visible, that is completely transparent.
@ FULL
Layer fully covers the screen: any underlying layers are invisible.
@ PARTIAL
Layer partially covers the screen: it may cover only part of the screen area, or it may be (semi-)tra...
Coverage getCoverage() const
Query the coverage of this layer.
Definition Layer.hh:57
friend auto operator<=>(ZIndex x, ZIndex y)
Definition Layer.hh:26
virtual void paint(OutputSurface &output)=0
Paint this layer.
virtual ~Layer()=default
void setZ(ZIndex z)
Changes the current Z-index of this layer.
Definition Layer.cc:7
ZIndex
Determines stacking order of layers: layers with higher Z-indices are closer to the viewer.
Definition Layer.hh:19
Layer(Coverage coverage_, ZIndex z_)
Construct a layer.
Definition Layer.hh:66
void setDisplay(Display &display_)
Store pointer to Display.
Definition Layer.hh:62
ZIndex getZ() const
Query the Z-index of this layer.
Definition Layer.hh:52
void setCoverage(Coverage coverage_)
Changes the current coverage of this layer.
Definition Layer.hh:73
bool isActive() const
Definition Layer.hh:53
A frame buffer where pixels can be written to.
ScopedLayerHider & operator=(const ScopedLayerHider &)=delete
ScopedLayerHider & operator=(ScopedLayerHider &&)=delete
ScopedLayerHider(ScopedLayerHider &&)=delete
ScopedLayerHider(const ScopedLayerHider &)=delete
This file implemented 3 utility functions:
Definition Autofire.cc:11
constexpr auto to_underlying(E e) noexcept
Definition stl.hh:465