openMSX
Layer.hh
Go to the documentation of this file.
1 #ifndef LAYER_HH
2 #define LAYER_HH
3 
4 namespace openmsx {
5 
6 class OutputSurface;
7 class LayerListener;
8 
11 class Layer
12 {
13 public:
17  enum ZIndex {
18  Z_DUMMY = -1,
22  Z_OSDGUI = 50,
23  Z_CONSOLE = 100
24  };
25 
29  enum Coverage {
40  };
41 
42  virtual ~Layer() = default;
43 
46  virtual void paint(OutputSurface& output) = 0;
47 
50  ZIndex getZ() const { return z; }
51 
54  Coverage getCoverage() const { return coverage; }
55 
59  void setDisplay(LayerListener& display_) { display = &display_; }
60 
61 protected:
63  explicit Layer(Coverage coverage_ = COVER_NONE, ZIndex z_ = Z_DUMMY)
64  : coverage(coverage_), z(z_)
65  {
66  }
67 
70  void setCoverage(Coverage coverage_) { coverage = coverage_; }
71 
74  void setZ(ZIndex z);
75 
76 private:
78  LayerListener* display = nullptr;
79 
81  Coverage coverage;
82 
86  ZIndex z;
87 
88  friend class ScopedLayerHider; // for setCoverage()
89 };
90 
91 
93 {
94 public:
95  explicit ScopedLayerHider(Layer& layer);
97 private:
98  Layer& layer;
99  Layer::Coverage originalCoverage;
100 };
101 
102 } // namespace openmsx
103 
104 #endif
void setDisplay(LayerListener &display_)
Store pointer to Display.
Definition: Layer.hh:59
Layer is not visible, that is completely transparent.
Definition: Layer.hh:39
virtual void paint(OutputSurface &output)=0
Paint this layer.
void setCoverage(Coverage coverage_)
Changes the current coverage of this layer.
Definition: Layer.hh:70
Interface for display layers.
Definition: Layer.hh:11
Layer fully covers the screen: any underlying layers are invisible.
Definition: Layer.hh:32
A frame buffer where pixels can be written to.
void setZ(ZIndex z)
Changes the current Z-index of this layer.
Definition: Layer.cc:6
virtual ~Layer()=default
Layer partially covers the screen: it may cover only part of the screen area, or it may be (semi-)tra...
Definition: Layer.hh:36
Thanks to enen for testing this on a real cartridge:
Definition: Autofire.cc:5
ZIndex getZ() const
Query the Z-index of this layer.
Definition: Layer.hh:50
Coverage getCoverage() const
Query the coverage of this layer.
Definition: Layer.hh:54
friend class ScopedLayerHider
Definition: Layer.hh:88
Layer(Coverage coverage_=COVER_NONE, ZIndex z_=Z_DUMMY)
Construct a layer.
Definition: Layer.hh:63
ZIndex
Determines stacking order of layers: layers with higher Z-indices are closer to the viewer...
Definition: Layer.hh:17
Coverage
Describes how much of the screen is currently covered by a particular layer.
Definition: Layer.hh:29