LMMS
Loading...
Searching...
No Matches
juce_GlyphArrangement.h
Go to the documentation of this file.
1/*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
10 By using JUCE, you agree to the terms of both the JUCE 7 End-User License
11 Agreement and JUCE Privacy Policy.
12
13 End User License Agreement: www.juce.com/juce-7-licence
14 Privacy Policy: www.juce.com/juce-privacy-policy
15
16 Or: You may also use this code under the terms of the GPL v3 (see
17 www.gnu.org/licenses).
18
19 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
20 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
21 DISCLAIMED.
22
23 ==============================================================================
24*/
25
26namespace juce
27{
28
29//==============================================================================
42{
43public:
44 //==============================================================================
45 PositionedGlyph() noexcept;
46
47 PositionedGlyph (const Font& font, juce_wchar character, int glyphNumber,
48 float anchorX, float baselineY, float width, bool isWhitespace);
49
54
56 float getLeft() const noexcept { return x; }
58 float getRight() const noexcept { return x + w; }
60 float getBaselineY() const noexcept { return y; }
62 float getTop() const { return y - font.getAscent(); }
64 float getBottom() const { return y + font.getDescent(); }
66 Rectangle<float> getBounds() const { return { x, getTop(), w, font.getHeight() }; }
67
68 //==============================================================================
70 void moveBy (float deltaX, float deltaY);
71
72 //==============================================================================
76 void draw (Graphics& g) const;
77
81 void draw (Graphics& g, AffineTransform transform) const;
82
86 void createPath (Path& path) const;
87
89 bool hitTest (float x, float y) const;
90
91private:
92 //==============================================================================
93 friend class GlyphArrangement;
96 int glyph;
97 float x, y, w;
99
101};
102
103
104//==============================================================================
117{
118public:
119 //==============================================================================
122
124 GlyphArrangement& operator= (const GlyphArrangement&) = default;
126 GlyphArrangement& operator= (GlyphArrangement&&) = default;
127
129 ~GlyphArrangement() = default;
130
131 //==============================================================================
133 int getNumGlyphs() const noexcept { return glyphs.size(); }
134
141 PositionedGlyph& getGlyph (int index) noexcept;
142
143 const PositionedGlyph* begin() const { return glyphs.begin(); }
144 const PositionedGlyph* end() const { return glyphs.end(); }
145
146 //==============================================================================
148 void clear();
149
158 void addLineOfText (const Font& font,
159 const String& text,
160 float x, float y);
161
168 void addCurtailedLineOfText (const Font& font,
169 const String& text,
170 float x, float y,
171 float maxWidthPixels,
172 bool useEllipsis);
173
187 void addJustifiedText (const Font& font,
188 const String& text,
189 float x, float y,
190 float maxLineWidth,
191 Justification horizontalLayout,
192 float leading = 0.0f);
193
213 void addFittedText (const Font& font,
214 const String& text,
215 float x, float y, float width, float height,
216 Justification layout,
217 int maximumLinesToUse,
218 float minimumHorizontalScale = 0.0f);
219
221 void addGlyphArrangement (const GlyphArrangement&);
222
224 void addGlyph (const PositionedGlyph&);
225
226 //==============================================================================
232 void draw (const Graphics&) const;
233
239 void draw (const Graphics&, AffineTransform) const;
240
244 void createPath (Path& path) const;
245
249 int findGlyphIndexAt (float x, float y) const;
250
251 //==============================================================================
261 Rectangle<float> getBoundingBox (int startIndex, int numGlyphs, bool includeWhitespace) const;
262
271 void moveRangeOfGlyphs (int startIndex, int numGlyphs,
272 float deltaX, float deltaY);
273
280 void removeRangeOfGlyphs (int startIndex, int numGlyphs);
281
289 void stretchRangeOfGlyphs (int startIndex, int numGlyphs,
290 float horizontalScaleFactor);
291
300 void justifyGlyphs (int startIndex, int numGlyphs,
301 float x, float y, float width, float height,
302 Justification justification);
303
304
305private:
306 //==============================================================================
308
309 int insertEllipsis (const Font&, float maxXPos, int startIndex, int endIndex);
310 int fitLineIntoSpace (int start, int numGlyphs, float x, float y, float w, float h, const Font&,
311 Justification, float minimumHorizontalScale);
312 void spreadOutLine (int start, int numGlyphs, float targetWidth);
313 void splitLines (const String&, Font, int start, float x, float y, float w, float h, int maxLines,
314 float lineWidth, Justification, float minimumHorizontalScale);
315 void addLinesWithLineBreaks (const String&, const Font&, float x, float y, float width, float height, Justification);
316 void drawGlyphUnderline (const Graphics&, const PositionedGlyph&, int, AffineTransform) const;
317
319};
320
321} // namespace juce
#define noexcept
Definition DistrhoDefines.h:72
#define final
Definition DistrhoDefines.h:74
Definition juce_AffineTransform.h:43
Definition juce_Array.h:56
Definition juce_Font.h:42
Definition juce_GlyphArrangement.h:117
void splitLines(const String &, Font, int start, float x, float y, float w, float h, int maxLines, float lineWidth, Justification, float minimumHorizontalScale)
Definition juce_GlyphArrangement.cpp:557
void addLinesWithLineBreaks(const String &, const Font &, float x, float y, float width, float height, Justification)
Definition juce_GlyphArrangement.cpp:376
GlyphArrangement(const GlyphArrangement &)=default
GlyphArrangement(GlyphArrangement &&)=default
int getNumGlyphs() const noexcept
Definition juce_GlyphArrangement.h:133
int insertEllipsis(const Font &, float maxXPos, int startIndex, int endIndex)
Definition juce_GlyphArrangement.cpp:187
Array< PositionedGlyph > glyphs
Definition juce_GlyphArrangement.h:307
GlyphArrangement()
Definition juce_GlyphArrangement.cpp:111
const PositionedGlyph * end() const
Definition juce_GlyphArrangement.h:144
void drawGlyphUnderline(const Graphics &, const PositionedGlyph &, int, AffineTransform) const
Definition juce_GlyphArrangement.cpp:692
const PositionedGlyph * begin() const
Definition juce_GlyphArrangement.h:143
int fitLineIntoSpace(int start, int numGlyphs, float x, float y, float w, float h, const Font &, Justification, float minimumHorizontalScale)
Definition juce_GlyphArrangement.cpp:393
void spreadOutLine(int start, int numGlyphs, float targetWidth)
Definition juce_GlyphArrangement.cpp:509
Definition juce_GraphicsContext.h:45
Definition juce_Justification.h:41
Definition juce_Path.h:65
Definition juce_GlyphArrangement.h:42
float getBaselineY() const noexcept
Definition juce_GlyphArrangement.h:60
PositionedGlyph() noexcept
Definition juce_GlyphArrangement.cpp:37
float w
Definition juce_GlyphArrangement.h:97
float y
Definition juce_GlyphArrangement.h:97
juce_wchar getCharacter() const noexcept
Definition juce_GlyphArrangement.h:51
friend class GlyphArrangement
Definition juce_GlyphArrangement.h:93
bool isWhitespace() const noexcept
Definition juce_GlyphArrangement.h:53
float x
Definition juce_GlyphArrangement.h:97
float getRight() const noexcept
Definition juce_GlyphArrangement.h:58
float getBottom() const
Definition juce_GlyphArrangement.h:64
int glyph
Definition juce_GlyphArrangement.h:96
float getTop() const
Definition juce_GlyphArrangement.h:62
bool whitespace
Definition juce_GlyphArrangement.h:98
Font font
Definition juce_GlyphArrangement.h:94
float getLeft() const noexcept
Definition juce_GlyphArrangement.h:56
Rectangle< float > getBounds() const
Definition juce_GlyphArrangement.h:66
juce_wchar character
Definition juce_GlyphArrangement.h:95
Definition juce_Rectangle.h:67
Definition juce_String.h:53
UINT_D64 w
Definition inflate.c:942
int y
Definition inflate.c:1588
int g
Definition inflate.c:1573
unsigned x[BMAX+1]
Definition inflate.c:1586
static int int height
Definition pugl.h:1594
static int width
Definition pugl.h:1593
virtual ASIOError start()=0
#define JUCE_LEAK_DETECTOR(OwnerClass)
Definition juce_LeakedObjectDetector.h:138
#define JUCE_API
Definition juce_StandardHeader.h:152
Definition carla_juce.cpp:31
wchar_t juce_wchar
Definition juce_CharacterFunctions.h:42
const char * text
Definition swell-functions.h:167
uch h[RAND_HEAD_LEN]
Definition crypt.c:459
#define const
Definition zconf.h:137