CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
TextLayoutManager.hpp
Go to the documentation of this file.
1//
2// CeresEngine - A game development framework
3//
4// Created by Rogiel Sulzbach.
5// Copyright (c) 2018-2022 Rogiel Sulzbach. All rights reserved.
6//
7
8#pragma once
9
11
12#include "TextLayout.hpp"
13#include "TextStorage.hpp"
14
16
20
24
25namespace CeresEngine {
26
27 struct TextContainer;
28 class TextStorage;
29
33 ShowsControlCharacters = 1u << 1u,
34 UsesFontLeading = 1u << 2u,
35 UsesDefaultHyphenation = 1u << 3u,
36
37 NeedsLayout = 1ull << 32,
38 };
39
42
75 private:
78
81
84
87
88 public:
90 [[nodiscard]] const TextStorage& getTextStorage() const { return mStorage; }
91
94
95 public: // Managing the Text Containers
98
101
103 void setTextContainer(const TextContainer& container);
104
113
124
132
143
144 public: // Configuring the Global Layout Manager Options
148
153
157
160
164
167
171
174
175 public:
180 [[nodiscard]] bool getNeedsLayout() const;
181
184
187
189 void layout();
190
193
195 [[nodiscard]] const Vector<TextLayout>& getLayout() const { return mLayouts; }
196
198 };
199
200} // namespace CeresEngine
#define CE_FLAGS_OPERATORS(Enum)
Defines global operators for a Flags<Enum, Storage> implementation.
Definition Flags.hpp:216
An object that coordinates the layout and display of text characters.
Definition TextLayoutManager.hpp:74
TextLayoutManagerStateFlags mFlags
The layout manager state flags.
Definition TextLayoutManager.hpp:86
Vector< TextLayout > mLayouts
A vector of already layout text.
Definition TextLayoutManager.hpp:83
const TextStorage & getTextStorage() const
The text storage object containing the content to be laid out.
Definition TextLayoutManager.hpp:90
SPtr< Texture > createTexture()
bool getUsesFontLeading() const
A Boolean value indicating whether the layout manager uses the leading provided in the font.
Definition TextLayoutManager.hpp:163
bool getUsesDefaultHyphenation() const
A Boolean value indicating whether the layout manager uses the default hyphenation rules to wrap line...
Definition TextLayoutManager.hpp:170
bool getShowsInvisibleCharacters() const
A Boolean value that indicates whether to substitute visible glyphs for white space and other typical...
Definition TextLayoutManager.hpp:147
bool getShowsControlCharacters() const
A Boolean value indicating whether the layout manager substitutes visible glyphs for control characte...
Definition TextLayoutManager.hpp:156
const Vector< TextLayout > & getLayout() const
Get the final text layout as it should be rendered.
Definition TextLayoutManager.hpp:195
void setShowsInvisibleCharacters(const bool showsInvisibleCharacters)
A Boolean value that indicates whether to substitute visible glyphs for white space and other typical...
Definition TextLayoutManager.hpp:150
Vector< TextContainer > mContainers
The current text containers of the layout manager.
Definition TextLayoutManager.hpp:80
void setShowsControlCharacters(const bool showsControlCharacters)
A Boolean value indicating whether the layout manager substitutes visible glyphs for control characte...
Definition TextLayoutManager.hpp:159
const TextContainer * getTextContainerForGlyph(UInt32 glyphIndex)
Returns the text container that manages the layout for the specified glyph, causing layout to happen ...
void setNeedsLayout()
A Boolean value indicating whether the text needs a layout pass before it can be drawn.
TextStorage mStorage
The text storage object containing the content to be laid out.
Definition TextLayoutManager.hpp:77
void layoutIfNeeded()
Perform text layout if needed.
void setTextContainers(const Vector< TextContainer > &containers)
The current text containers of the layout manager.
const Vector< TextContainer > & getTextContainers() const
The current text containers of the layout manager.
Definition TextLayoutManager.hpp:97
void setTextContainer(const TextContainer &container)
Defines a new single text container on the layout manager.
void setNeedsLayout(bool state)
A Boolean value indicating whether the text needs a layout pass before it can be drawn.
void insertTextContainer(const TextContainer &aTextContainer, UInt32 index)
Inserts a text container at the specified index in the list of text containers.
void addTextContainer(const TextContainer &aTextContainer)
Appends the given text container to the series of text containers where the layout manager arranges.
bool getNeedsLayout() const
A Boolean value indicating whether the text needs a layout pass before it can be drawn.
void setUsesFontLeading(const bool usesFontLeading)
A Boolean value indicating whether the layout manager uses the leading provided in the font.
Definition TextLayoutManager.hpp:166
void layout()
Perform text layout.
void setUsesDefaultHyphenation(const bool usesDefaultHyphenation)
A Boolean value indicating whether the layout manager uses the default hyphenation rules to wrap line...
Definition TextLayoutManager.hpp:173
void removeTextContainer(UInt32 index)
Removes the text container at the specified index and invalidates the layout as needed.
void setTextStorage(const TextStorage &textStorage)
The text storage object containing the content to be laid out.
Definition TextStorage.hpp:21
Definition Application.hpp:19
std::uint64_t UInt64
Definition DataTypes.hpp:26
std::shared_ptr< T > SPtr
SPtr is a smart pointer that retains shared ownership of an object through a pointer.
Definition SmartPtr.hpp:37
std::vector< T, ScopedAllocatorAdaptor< StdAllocator< T, RawAllocator > > > Vector
Vector is a sequence container that encapsulates dynamic size arrays.
Definition Vector.hpp:17
struct CeresEngine::GLState state
TextLayoutManagerState
A set of flags that represent the layout manager state.
Definition TextLayoutManager.hpp:31
std::uint32_t UInt32
Definition DataTypes.hpp:23
constexpr size_t hash(const T &v)
Generates a hash for the provided type.
Definition Hash.hpp:25
constexpr bool isSet(Enum value) const noexcept
Checks whether all of the provided bits are set.
Definition Flags.hpp:54
constexpr Flags & set(Enum value) noexcept
Activates all of the provided bits.
Definition Flags.hpp:74
A region where text is laid out.
Definition TextLayout.hpp:64