25#ifndef TGUI_CHAT_BOX_HPP
26#define TGUI_CHAT_BOX_HPP
28#include <TGUI/Widgets/Scrollbar.hpp>
29#include <TGUI/Renderers/ChatBoxRenderer.hpp>
30#include <TGUI/Text.hpp>
32#if !TGUI_EXPERIMENTAL_USE_STD_MODULE
38TGUI_MODULE_EXPORT
namespace tgui
46 using Ptr = std::shared_ptr<ChatBox>;
47 using ConstPtr = std::shared_ptr<const ChatBox>;
49 static constexpr const char StaticWidgetType[] =
"ChatBox";
64 ChatBox(
const char* typeName = StaticWidgetType,
bool initRenderer =
true);
87 TGUI_NODISCARD
const ChatBoxRenderer* getSharedRenderer()
const override;
104 using Widget::setSize;
279 TGUI_DEPRECATED(
"Use getScrollbar()->setValue(value) instead") void setScrollbarValue(
unsigned int value);
286 TGUI_DEPRECATED("Use getScrollbar()->getValue() instead") TGUI_NODISCARD
unsigned int getScrollbarValue() const;
295 TGUI_DEPRECATED("Use getScrollbar()->getMaxValue() instead") TGUI_NODISCARD
unsigned int getScrollbarMaxValue() const;
302 TGUI_NODISCARD
bool isMouseOnWidget(
Vector2f pos) const override;
312 void leftMouseReleased(
Vector2f pos) override;
317 void mouseMoved(
Vector2f pos) override;
322 bool scrolled(
float delta,
Vector2f pos,
bool touch) override;
327 void mouseNoLongerOnWidget() override;
332 void leftMouseButtonNoLongerDown() override;
340 void recalculateLineText(
Line& line);
345 void recalculateAllLines();
350 void recalculateFullTextHeight();
355 void updateDisplayedText();
360 void updateRendering();
378 void rendererChanged(const
String& property) override;
383 TGUI_NODISCARD std::unique_ptr<DataIO::Node> save(SavingRenderersMap& renderers) const override;
388 void load(const std::unique_ptr<DataIO::Node>& node, const LoadingRenderersMap& renderers) override;
393 void updateTextSize() override;
398 TGUI_NODISCARD
Vector2f getInnerSize() const;
411 std::
size_t m_maxLines = 0;
413 float m_fullTextHeight = 0;
415 bool m_linesStartFromTop = false;
416 bool m_newLinesBelowOthers = true;
418 std::deque<
Line> m_lines;
420 Sprite m_spriteBackground;
425 Color m_backgroundColorCached;
426 Color m_borderColorCached;
Base class for render targets.
Definition BackendRenderTarget.hpp:46
Definition ChatBoxRenderer.hpp:35
Definition ChatBox.hpp:43
std::shared_ptr< const ChatBox > ConstPtr
Shared constant widget pointer.
Definition ChatBox.hpp:47
std::shared_ptr< ChatBox > Ptr
Shared widget pointer.
Definition ChatBox.hpp:46
void removeAllLines()
Removes all lines from the chat box.
bool getLinesStartFromTop() const
Returns whether the first lines start from the top or from the bottom of the chat box.
ChatBoxRenderer * getSharedRenderer() override
Returns the renderer, which gives access to functions that determine how the widget is displayed.
static ChatBox::Ptr create()
Creates a new chat box widget.
void setLinesStartFromTop(bool startFromTop=true)
Lets the first lines start from the top or from the bottom of the chat box.
void addLine(const String &text, Color color)
Adds a new line of text to the chat box.
void addLine(const String &text, Color color, TextStyles style)
Adds a new line of text to the chat box.
const Color & getTextColor() const
Returns the default color of the text.
std::size_t getLineLimit() const
Returns the maximum amount of lines in the chat box.
void addLine(const String &text)
Adds a new line of text to the chat box.
bool getNewLinesBelowOthers() const
Returns whether new lines are added below the other lines or above them.
static ChatBox::Ptr copy(const ChatBox::ConstPtr &chatBox)
Makes a copy of another chat box.
Color getLineColor(std::size_t lineIndex) const
Returns the color of the requested line.
void setSize(const Layout2d &size) override
Changes the size of the chat box.
void setNewLinesBelowOthers(bool newLinesBelowOthers=true)
Sets whether new lines are added below the other lines or above them.
TextStyles getTextStyle() const
Returns the default text style.
TextStyles getLineTextStyle(std::size_t lineIndex) const
Returns the text style of the requested line.
ChatBoxRenderer * getRenderer() override
Returns the renderer, which gives access to functions that determine how the widget is displayed.
std::size_t getLineAmount() const
Returns the amount of lines in the chat box.
void setTextColor(Color color)
Changes the default color of the text.
void setTextStyle(TextStyles style)
Changes the default text style.
String getLine(std::size_t lineIndex) const
Returns the contents of the requested line.
void setLineLimit(std::size_t maxLines)
Sets a maximum amount of lines in the chat box.
bool removeLine(std::size_t lineIndex)
Removes the requested line.
Wrapper for colors.
Definition Color.hpp:73
Class to store the position or size of a widget.
Definition Layout.hpp:323
Definition Outline.hpp:38
Wrapper class to store strings.
Definition String.hpp:96
Wrapper for text styles.
Definition TextStyle.hpp:55
Backend-independent wrapper around the backend-specific text class.
Definition Text.hpp:48
Namespace that contains all TGUI functions and classes.
Definition AbsoluteOrRelativeValue.hpp:38
Definition ChatBox.hpp:52
States used for drawing.
Definition RenderStates.hpp:38