swift
Loading...
Searching...
No Matches
src
xswiftbus
drawable.h
Go to the documentation of this file.
1
// SPDX-FileCopyrightText: Copyright (C) 2015 swift Project Community / Contributors
2
// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3
4
#ifndef SWIFT_SIM_XSWIFTBUS_DRAWABLE_H
5
#define SWIFT_SIM_XSWIFTBUS_DRAWABLE_H
6
8
9
#include <XPLMDisplay.h>
10
11
namespace
XSwiftBus
12
{
13
17
class
CDrawable
18
{
19
public
:
21
CDrawable
(XPLMDrawingPhase phase,
bool
before) : m_phase(phase), m_before(before) {}
22
24
virtual
~CDrawable
() {
hide
(); }
25
27
bool
isVisible
()
const
{
return
m_visible; }
28
30
void
show
()
31
{
32
if
(m_visible)
33
{
34
return
;
35
}
36
m_visible =
true
;
37
XPLMRegisterDrawCallback(callback, m_phase, m_before,
static_cast<
void
*
>
(
this
));
38
}
39
41
void
hide
()
42
{
43
if
(!m_visible)
44
{
45
return
;
46
}
47
m_visible =
false
;
48
XPLMUnregisterDrawCallback(callback, m_phase, m_before,
static_cast<
void
*
>
(
this
));
49
}
50
51
protected
:
53
virtual
void
draw
() = 0;
54
55
private
:
56
static
int
callback(XPLMDrawingPhase,
int
,
void
*refcon)
57
{
58
static_cast<
CDrawable
*
>
(refcon)->
draw
();
59
return
1;
60
}
61
62
XPLMDrawingPhase m_phase;
63
bool
m_before =
false
;
64
bool
m_visible =
false
;
65
};
66
67
}
// namespace XSwiftBus
68
69
#endif
// SWIFT_SIM_XSWIFTBUS_DRAWABLE_H
XSwiftBus::CDrawable::show
void show()
Register the draw callback.
Definition
drawable.h:30
XSwiftBus::CDrawable::~CDrawable
virtual ~CDrawable()
Destructor.
Definition
drawable.h:24
XSwiftBus::CDrawable::draw
virtual void draw()=0
Callback to draw the thing.
XSwiftBus::CDrawable::hide
void hide()
Unregister the draw callback.
Definition
drawable.h:41
XSwiftBus::CDrawable::CDrawable
CDrawable(XPLMDrawingPhase phase, bool before)
Constructor.
Definition
drawable.h:21
XSwiftBus::CDrawable::isVisible
bool isVisible() const
Is currently shown.
Definition
drawable.h:27
XSwiftBus
Plugin loaded by X-Plane which publishes a DBus service.
Definition
command.h:14
Generated on
for swift by
1.15.0