4#ifndef SWIFT_SIM_XSWIFTBUS_MESSAGES_H
5#define SWIFT_SIM_XSWIFTBUS_MESSAGES_H
24 inline auto empty_u8string()
26 using namespace std::literals;
38 using string =
decltype(Private::empty_u8string());
41 CMessage(
const string &text,
float r = 1,
float g = 1,
float b = 1) :
m_text(text),
m_rgb { { r, g, b } } {}
61 :
CDrawable(xplm_Phase_Window, true), m_boxLeft(left), m_boxRight(right), m_boxTop(top)
65 template <
typename Iterator>
69 std::copy(begin, end, std::back_inserter(m_messages));
73 void setValues(
int leftPx,
int topPx,
int rightPx,
int bottomPx,
int lines,
int durationMs);
89 virtual void draw()
override;
92 std::vector<CMessage> m_messages;
93 bool m_upArrow =
false;
94 bool m_downArrow =
false;
100 int m_durationMs = 2500;
123 void setValues(
int leftPx,
int topPx,
int rightPx,
int bottomPx,
int lines,
int durationMs)
125 m_messageBox.setValues(leftPx, topPx, rightPx, bottomPx, lines, durationMs);
163 void scrollToBottom();
164 void updateVisibleLines();
166 bool m_visible =
false;
167 std::vector<CMessage> m_messages;
168 size_t m_position = 0;
169 size_t m_maxVisibleLines = 5;
170 const size_t c_maxTotalLines = 1024;
171 CMessageBox m_messageBox;
173 CCommand m_showCommand;
174 CCommand m_hideCommand;
175 CCommand m_toggleCommand;
176 CCommand m_scrollUpCommand;
177 CCommand m_scrollDownCommand;
178 CCommand m_scrollToTopCommand;
179 CCommand m_scrollToBottomCommand;
CDrawable(XPLMDrawingPhase phase, bool before)
Constructor.
bool isVisible() const
Is message box currently visible?
void addMessage(const CMessage &message)
Add a new message to the bottom of the list.
int maxLineLength() const
Returns the maximum number of characters per line.
void setValues(int leftPx, int topPx, int rightPx, int bottomPx, int lines, int durationMs)
Set margin values.
CMessageBoxControl(int left, int right, int top)
Constructor.
void setMaxVisibleLines(size_t lines)
Set max. visible lines.
void toggle()
Toggles the visibility of the message box.
virtual void draw()
Callback to draw the thing.
void setValues(int leftPx, int topPx, int rightPx, int bottomPx, int lines, int durationMs)
Set margin values.
void setMessages(Iterator begin, Iterator end)
Set messages to draw in message box, from a pair of iterators.
int maxLineLength() const
Returns the maximum number of characters per line.
void enableArrows(bool up, bool down)
Set whether to draw a small arrow at the bottom of the box.
CMessageBox(int left, int right, int top)
Constructor.
static int lineHeight()
Line height based on font.
Class providing access to a single X-Plane dataref.
Plugin loaded by X-Plane which publishes a DBus service.
Class representing a single line of text to be drawn in a message box.
CMessage(const string &text, float r=1, float g=1, float b=1)
Constructor.
std::array< float, 3 > m_rgb
Color.
decltype(Private::empty_u8string()) string
String type.