openMSX
VideoLayer.cc
Go to the documentation of this file.
1#include "VideoLayer.hh"
2#include "Display.hh"
3#include "Reactor.hh"
4#include "GlobalSettings.hh"
5#include "BooleanSetting.hh"
7#include "MSXMotherBoard.hh"
8#include "Event.hh"
9#include "one_of.hh"
10
11namespace openmsx {
12
14 const std::string& videoSource_)
15 : motherBoard(motherBoard_)
16 , display(motherBoard.getReactor().getDisplay())
17 , videoSourceSetting(motherBoard.getVideoSource())
18 , videoSourceActivator(videoSourceSetting, videoSource_)
19 , powerSetting(motherBoard.getReactor().getGlobalSettings().getPowerSetting())
20{
21 calcCoverage();
22 calcZ();
23 display.addLayer(*this);
24
25 videoSourceSetting.attach(*this);
26 powerSetting.attach(*this);
28}
29
31{
33 powerSetting.detach(*this);
34 videoSourceSetting.detach(*this);
35
36 display.removeLayer(*this);
37}
38
40{
41 return videoSourceActivator.getID();
42}
44{
45 return videoSourceSetting.getSource();
46}
47
48void VideoLayer::update(const Setting& setting) noexcept
49{
50 if (&setting == &videoSourceSetting) {
51 calcZ();
52 } else if (&setting == &powerSetting) {
53 calcCoverage();
54 }
55}
56
57void VideoLayer::calcZ()
58{
59 setZ((videoSourceSetting.getSource() == getVideoSource())
62}
63
64void VideoLayer::calcCoverage()
65{
66 auto cov = (!powerSetting.getBoolean() || !motherBoard.isActive())
68 : COVER_FULL;
69 setCoverage(cov);
70}
71
72void VideoLayer::signalMSXEvent(const Event& event,
73 EmuTime::param /*time*/) noexcept
74{
77 calcCoverage();
78 }
79}
80
82{
83 // Either when this layer itself is selected or when the video9000
84 // layer is selected and this layer is needed to render a
85 // (superimposed) image.
86 int current = videoSourceSetting.getSource();
87 return (current == getVideoSource()) ||
88 ((current == video9000Source) && (activeVideo9000 != INACTIVE));
89}
90
92{
93 // Either when this layer itself is selected or when the video9000
94 // layer is selected and this layer is the front layer of a
95 // (superimposed) image
96 int current = videoSourceSetting.getSource();
97 return (current == getVideoSource()) ||
98 ((current == video9000Source) && (activeVideo9000 == ACTIVE_FRONT));
99}
100
101} // namespace openmsx
BaseSetting * setting
Definition: Interpreter.cc:28
Definition: one_of.hh:7
bool getBoolean() const noexcept
void removeLayer(Layer &layer)
Definition: Display.cc:388
void addLayer(Layer &layer)
Definition: Display.cc:380
@ COVER_FULL
Layer fully covers the screen: any underlying layers are invisible.
Definition: Layer.hh:32
@ COVER_NONE
Layer is not visible, that is completely transparent.
Definition: Layer.hh:39
void setZ(ZIndex z)
Changes the current Z-index of this layer.
Definition: Layer.cc:6
@ Z_MSX_ACTIVE
Definition: Layer.hh:21
@ Z_MSX_PASSIVE
Definition: Layer.hh:20
void setCoverage(Coverage coverage_)
Changes the current coverage of this layer.
Definition: Layer.hh:71
void registerEventListener(MSXEventListener &listener)
Registers a given object to receive certain events.
void unregisterEventListener(MSXEventListener &listener)
Unregisters a previously registered event listener.
MSXEventDistributor & getMSXEventDistributor()
void detach(Observer< T > &observer)
Definition: Subject.hh:56
void attach(Observer< T > &observer)
Definition: Subject.hh:50
int getVideoSource() const
Returns the ID for this VideoLayer.
Definition: VideoLayer.cc:39
bool needRecord() const
Definition: VideoLayer.cc:91
bool needRender() const
Definition: VideoLayer.cc:81
int getVideoSourceSetting() const
Definition: VideoLayer.cc:43
void update(const Setting &setting) noexcept override
Definition: VideoLayer.cc:48
~VideoLayer() override
Definition: VideoLayer.cc:30
VideoLayer(const VideoLayer &)=delete
This file implemented 3 utility functions:
Definition: Autofire.cc:9
EventType getType(const Event &event)
Definition: Event.hh:644