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);
135 if (m_visible) { hide(); }
157 void scrollToBottom();
158 void updateVisibleLines();
160 bool m_visible =
false;
161 std::vector<CMessage> m_messages;
162 size_t m_position = 0;
163 size_t m_maxVisibleLines = 5;
164 const size_t c_maxTotalLines = 1024;
165 CMessageBox m_messageBox;
167 CCommand m_showCommand;
168 CCommand m_hideCommand;
169 CCommand m_toggleCommand;
170 CCommand m_scrollUpCommand;
171 CCommand m_scrollDownCommand;
172 CCommand m_scrollToTopCommand;
173 CCommand m_scrollToBottomCommand;
Class-based interface to X-Plane's drawing callback API.
void show()
Register the draw callback.
void hide()
Unregister the draw callback.
Class which builds upon CMessageBox with a scrollback buffer and commands for user control.
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.
Class for drawing a gray box with text messages.
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.
Plugin loaded by X-Plane which publishes a DBus service.
T::const_iterator begin(const LockFreeReader< T > &reader)
Non-member begin() and end() for so LockFree containers can be used in ranged for loops.
T::const_iterator end(const LockFreeReader< T > &reader)
Non-member begin() and end() for so LockFree containers can be used in ranged for loops.
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.