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
openmsx::ScopedLayerHider
Definition: Layer.hh:93
openmsx::LayerListener
Definition: LayerListener.hh:9
openmsx::Layer::Z_MSX_PASSIVE
@ Z_MSX_PASSIVE
Definition: Layer.hh:20
openmsx::Layer::Layer
Layer(Coverage coverage_=COVER_NONE, ZIndex z_=Z_DUMMY)
Construct a layer.
Definition: Layer.hh:63
openmsx::Layer::setDisplay
void setDisplay(LayerListener &display_)
Store pointer to Display.
Definition: Layer.hh:59
openmsx::Layer::paint
virtual void paint(OutputSurface &output)=0
Paint this layer.
openmsx::Layer::getCoverage
Coverage getCoverage() const
Query the coverage of this layer.
Definition: Layer.hh:54
openmsx::Layer::~Layer
virtual ~Layer()=default
openmsx::Layer::Z_OSDGUI
@ Z_OSDGUI
Definition: Layer.hh:22
openmsx::ScopedLayerHider::~ScopedLayerHider
~ScopedLayerHider()
Definition: Layer.cc:22
openmsx::Layer::Z_CONSOLE
@ Z_CONSOLE
Definition: Layer.hh:23
openmsx::Layer::Z_BACKGROUND
@ Z_BACKGROUND
Definition: Layer.hh:19
openmsx::Layer::setZ
void setZ(ZIndex z)
Changes the current Z-index of this layer.
Definition: Layer.cc:6
openmsx::Layer
Interface for display layers.
Definition: Layer.hh:12
openmsx::Layer::Z_DUMMY
@ Z_DUMMY
Definition: Layer.hh:18
openmsx::Layer::getZ
ZIndex getZ() const
Query the Z-index of this layer.
Definition: Layer.hh:50
openmsx::OutputSurface
A frame buffer where pixels can be written to.
Definition: OutputSurface.hh:20
openmsx::Layer::setCoverage
void setCoverage(Coverage coverage_)
Changes the current coverage of this layer.
Definition: Layer.hh:70
openmsx::Layer::COVER_FULL
@ COVER_FULL
Layer fully covers the screen: any underlying layers are invisible.
Definition: Layer.hh:32
openmsx::Layer::Z_MSX_ACTIVE
@ Z_MSX_ACTIVE
Definition: Layer.hh:21
openmsx::Layer::COVER_NONE
@ COVER_NONE
Layer is not visible, that is completely transparent.
Definition: Layer.hh:39
openmsx::ScopedLayerHider::ScopedLayerHider
ScopedLayerHider(Layer &layer)
Definition: Layer.cc:15
openmsx::Layer::COVER_PARTIAL
@ COVER_PARTIAL
Layer partially covers the screen: it may cover only part of the screen area, or it may be (semi-)tra...
Definition: Layer.hh:36
openmsx
This file implemented 3 utility functions:
Definition: Autofire.cc:5
openmsx::Layer::ZIndex
ZIndex
Determines stacking order of layers: layers with higher Z-indices are closer to the viewer.
Definition: Layer.hh:17
openmsx::Layer::Coverage
Coverage
Describes how much of the screen is currently covered by a particular layer.
Definition: Layer.hh:29