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 : Layer(Layer::Coverage::NONE, Layer::ZIndex::BACKGROUND)
16 , motherBoard(motherBoard_)
17 , display(motherBoard.getReactor().getDisplay())
18 , videoSourceSetting(motherBoard.getVideoSource())
19 , videoSourceActivator(videoSourceSetting, videoSource_)
20 , powerSetting(motherBoard.getReactor().getGlobalSettings().getPowerSetting())
21{
22 calcCoverage();
23 calcZ();
24 display.addLayer(*this);
25
26 videoSourceSetting.attach(*this);
27 powerSetting.attach(*this);
29}
30
32{
34 powerSetting.detach(*this);
35 videoSourceSetting.detach(*this);
36
37 display.removeLayer(*this);
38}
39
41{
42 return videoSourceActivator.getID();
43}
45{
46 return videoSourceSetting.getSource();
47}
48
49void VideoLayer::update(const Setting& setting) noexcept
50{
51 if (&setting == &videoSourceSetting) {
52 calcZ();
53 } else if (&setting == &powerSetting) {
54 calcCoverage();
55 }
56}
57
58void VideoLayer::calcZ()
59{
60 setZ((videoSourceSetting.getSource() == getVideoSource())
63}
64
65void VideoLayer::calcCoverage()
66{
67 auto cov = (!powerSetting.getBoolean() || !motherBoard.isActive())
69 : Coverage::FULL;
70 setCoverage(cov);
71}
72
73void VideoLayer::signalMSXEvent(const Event& event,
74 EmuTime::param /*time*/) noexcept
75{
78 calcCoverage();
79 }
80}
81
83{
84 // Either when this layer itself is selected or when the video9000
85 // layer is selected and this layer is needed to render a
86 // (superimposed) image.
87 int current = videoSourceSetting.getSource();
88 return (current == getVideoSource()) ||
89 ((current == video9000Source) && (activeVideo9000 != Video9000Active::NO));
90}
91
93{
94 // Either when this layer itself is selected or when the video9000
95 // layer is selected and this layer is the front layer of a
96 // (superimposed) image
97 int current = videoSourceSetting.getSource();
98 return (current == getVideoSource()) ||
99 ((current == video9000Source) && (activeVideo9000 == Video9000Active::FRONT));
100}
101
102} // namespace openmsx
BaseSetting * setting
bool getBoolean() const noexcept
void removeLayer(Layer &layer)
Definition Display.cc:397
void addLayer(Layer &layer)
Definition Display.cc:389
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.
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
void setCoverage(Coverage coverage_)
Changes the current coverage of this layer.
Definition Layer.hh:73
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:60
void attach(Observer< T > &observer)
Definition Subject.hh:54
int getVideoSource() const
Returns the ID for this VideoLayer.
Definition VideoLayer.cc:40
bool needRecord() const
Definition VideoLayer.cc:92
bool needRender() const
Definition VideoLayer.cc:82
int getVideoSourceSetting() const
Definition VideoLayer.cc:44
void update(const Setting &setting) noexcept override
Definition VideoLayer.cc:49
~VideoLayer() override
Definition VideoLayer.cc:31
VideoLayer(const VideoLayer &)=delete
This file implemented 3 utility functions:
Definition Autofire.cc:11
EventType getType(const Event &event)
Definition Event.hh:517
std::variant< KeyUpEvent, KeyDownEvent, MouseMotionEvent, MouseButtonUpEvent, MouseButtonDownEvent, MouseWheelEvent, JoystickAxisMotionEvent, JoystickHatEvent, JoystickButtonUpEvent, JoystickButtonDownEvent, OsdControlReleaseEvent, OsdControlPressEvent, WindowEvent, TextEvent, FileDropEvent, QuitEvent, FinishFrameEvent, CliCommandEvent, GroupEvent, BootEvent, FrameDrawnEvent, BreakEvent, SwitchRendererEvent, TakeReverseSnapshotEvent, AfterTimedEvent, MachineLoadedEvent, MachineActivatedEvent, MachineDeactivatedEvent, MidiInReaderEvent, MidiInWindowsEvent, MidiInCoreMidiEvent, MidiInCoreMidiVirtualEvent, MidiInALSAEvent, Rs232TesterEvent, Rs232NetEvent, ImGuiDelayedActionEvent, ImGuiActiveEvent > Event
Definition Event.hh:445