Spinning Topp Logo BlackTopp Studios
inc
textline.cpp
1 // © Copyright 2010 - 2016 BlackTopp Studios Inc.
2 /* This file is part of The Mezzanine Engine.
3 
4  The Mezzanine Engine is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  The Mezzanine Engine is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with The Mezzanine Engine. If not, see <http://www.gnu.org/licenses/>.
16 */
17 /* The original authors have included a copy of the license specified above in the
18  'Docs' folder. See 'gpl.txt'
19 */
20 /* We welcome the use of the Mezzanine engine to anyone, including companies who wish to
21  Build professional software and charge for their product.
22 
23  However there are some practical restrictions, so if your project involves
24  any of the following you should contact us and we will try to work something
25  out:
26  - DRM or Copy Protection of any kind(except Copyrights)
27  - Software Patents You Do Not Wish to Freely License
28  - Any Kind of Linking to Non-GPL licensed Works
29  - Are Currently In Violation of Another Copyright Holder's GPL License
30  - If You want to change our code and not add a few hundred MB of stuff to
31  your distribution
32 
33  These and other limitations could cause serious legal problems if you ignore
34  them, so it is best to simply contact us or the Free Software Foundation, if
35  you have any questions.
36 
37  Joseph Toppi - toppij@gmail.com
38  John Blackwood - makoenergy02@gmail.com
39 */
40 
41 #ifndef _uitextline_cpp
42 #define _uitextline_cpp
43 
44 #include "UI/textline.h"
45 #include "UI/textlayer.h"
46 #include "UI/quadrenderable.h"
47 
48 #include <algorithm>
49 
50 namespace Mezzanine
51 {
52  namespace UI
53  {
54  ///////////////////////////////////////////////////////////////////////////////
55  // TextLine Methods
56 
57  TextLine::TextLine(TextLayer* ParentLayer) :
58  Parent(ParentLayer),
59  CurrLength(0),
60  TallestHeight(0),
61  PositionOffset(0)
62  { }
63 
65  { }
66 
67  ///////////////////////////////////////////////////////////////////////////////
68  // Utility
69 
71  {
72  if( this->Alignment != Align ) {
73  this->Alignment = Align;
74  this->RecalculateOffsets();
75  }
76  }
77 
79  {
80  return this->Alignment;
81  }
82 
84  {
85  OffsetResultPair Ret(NULL,Vector2(0,0));
86  ConstCharacterIterator CharIt = this->Characters.begin();
87  // Check if we're too far to the left side to get anything
88  if( Offset < (*CharIt)->GetLengthOffset() ) {
89  Ret.first = NULL;
90  Ret.second.X = this->GetLeftMostCursorPosition();
91  Ret.second.Y = this->PositionOffset;
92  return Ret;
93  }
94 
95  while( CharIt != this->Characters.end() && Offset > (*CharIt)->GetRightEdgeLengthOffset() )
96  {
97  ++CharIt;
98  }
99 
100  // Check if we're too far to the right side to get anything
101  if( CharIt == (--this->Characters.end()) && Offset > (*CharIt)->GetRightEdgeLengthOffset() ) {
102  Ret.first = NULL;
103  Ret.second.X = this->GetRightMostCursorPosition();
104  Ret.second.Y = this->PositionOffset;
105  return Ret;
106  }
107 
108  // Get our character dimensions for checking which side we should be on
109  Real CharXPos = (*CharIt)->GetLengthOffset();
110  Real CharXSize = (*CharIt)->GetCharacterSize().X;
111  // Fill in our values
112  Ret.first = (*CharIt);
113  Ret.second.X = ( CharXPos + (CharXSize * 0.5) < Offset ? CharXPos + CharXSize : CharXPos );
114  Ret.second.Y = this->PositionOffset;
115 
116  return Ret;
117  }
118 
120  {
121  if( !this->Characters.empty() ) {
122  ConstCharacterIterator CharIt = this->Characters.begin();
123  // Check if we're too far to the left side to get anything
124  if( Offset < (*CharIt)->GetLengthOffset() )
125  return 0;
126 
127  Integer RetIndex = 0;
128  while( CharIt != this->Characters.end() && Offset > (*CharIt)->GetRightEdgeLengthOffset() )
129  {
130  ++CharIt;
131  ++RetIndex;
132  }
133 
134  if( CharIt == this->Characters.end() )
135  return -1;
136 
137  // Get our character dimensions for checking which side we should be on
138  Real CharXPos = (*CharIt)->GetLengthOffset();
139  Real CharXSize = (*CharIt)->GetCharacterSize().X;
140  return ( Offset < CharXPos + (CharXSize * 0.5) ? RetIndex : ++RetIndex );
141  }else{
142  return -1;
143  }
144  }
145 
147  {
148  if( !this->Characters.empty() ) {
149  if( Index < 0 || static_cast<Whole>(Index) > this->Characters.size() ) {
150  ConstCharacterIterator Last = --(this->Characters.end());
151  return (*Last)->GetLengthOffset() + (*Last)->GetCharacterSize().X;
152  }else{
153  Integer IndexCount = 0;
154  ConstCharacterIterator CharIt = this->Characters.begin();
155 
156  while( CharIt != this->Characters.end() && IndexCount < Index )
157  {
158  ++IndexCount;
159  ++CharIt;
160  }
161 
162  return (*CharIt)->GetLengthOffset();
163  }
164  }else{
165  return this->GetCursorStartPosition();
166  }
167  }
168 
170  {
171  Real MaxWidth = this->Parent->GetMaxLineWidth();
172  switch( this->Alignment )
173  {
174  case UI::LA_TopLeft: return 0; break;
175  case UI::LA_BottomRight: return MaxWidth - CurrLength; break;
176  case UI::LA_Center: return (MaxWidth * 0.5) - (CurrLength * 0.5); break;
177  }
178  return 0;
179  }
180 
182  {
183  Real MaxWidth = this->Parent->GetMaxLineWidth();
184  switch( this->Alignment )
185  {
186  case UI::LA_TopLeft: return CurrLength; break;
187  case UI::LA_BottomRight: return MaxWidth; break;
188  case UI::LA_Center: return (MaxWidth * 0.5) + (CurrLength * 0.5); break;
189  }
190  return MaxWidth;
191  }
192 
194  {
195  CharacterIterator CharIt = this->Characters.begin();
196  // Check if we're too far to the left side to get anything
197  if( Position < (*CharIt)->GetLengthOffset() )
198  return this->GetLeftMostCursorPosition();
199 
200  while( CharIt != this->Characters.end() && Position < (*CharIt)->GetLengthOffset() )
201  {
202  if( (*CharIt)->IsNewLine() )
203  continue;
204 
205  ++CharIt;
206  }
207 
208  // Get some values to check/math with
209  Real CharXPos = (*CharIt)->GetLengthOffset();
210  Real CharXSize = (*CharIt)->GetCharacterSize().X;
211 
212  // Check if we're too far to the right side to get anything
213  if( CharIt == (--(this->Characters.end())) && Position > CharXPos + CharXSize )
214  return this->GetRightMostCursorPosition();
215 
216  return ( Position < CharXPos + (CharXSize * 0.5) ? CharXPos : CharXPos + CharXSize );
217  }
218 
219  ///////////////////////////////////////////////////////////////////////////////
220  // Transform Related Methods
221 
222  void TextLine::SetPositionOffset(const Real& Offset)
223  { this->PositionOffset = Offset; }
224 
226  { return this->PositionOffset; }
227 
229  { return this->CurrLength; }
230 
232  { return ( Characters.empty() ? 0 : this->TallestHeight ); }
233 
234  ///////////////////////////////////////////////////////////////////////////////
235  // Character Management
236 
238  {
239  CharacterIterator Last = this->GetLastCharacter();
240  Real CharAdvance = ToAdd->GetCharacterAdvance( Last != this->Characters.end() ? (*Last)->GetCharGlyph() : NULL );
241  Real AddedLength = this->CurrLength + CharAdvance;
242 
243  if( AddedLength <= MaxWidth ) {
244  this->CurrLength = AddedLength;
245  this->TallestHeight = std::max(this->TallestHeight,ToAdd->GetLineHeight());
246  this->AppendToBack(ToAdd);
247  this->RecalculateOffsets();
248  return true;
249  }
250 
251  return false;
252  }
253 
255  { return this->AppendCharacters(ToAdd.begin(),ToAdd.end(),MaxWidth); }
256 
258  { return this->AppendCharacters(Pair.first,Pair.second,MaxWidth); }
259 
261  { return this->AppendFittingCharacters(ToAdd.begin(),ToAdd.end(),MaxWidth); }
262 
264  { return this->AppendFittingCharacters(Pair.first,Pair.second,MaxWidth); }
265 
267  {
268  CharacterIterator CharIt = this->Characters.begin();
269  // Check to see if the index is out of bounds
270  if( Index >= this->Characters.size() )
271  return NULL;
272 
273  UInt32 Count = 0;
274  while( CharIt != this->Characters.end() && Count < Index )
275  {
276  ++CharIt;
277  }
278 
279  return (*CharIt);
280  }
281 
283  {
284  CharacterIterator CharIt = this->Characters.begin();
285  // Check if we're too far to the left side to get anything
286  if( Offset < (*CharIt)->GetLengthOffset() )
287  return NULL;
288 
289  while( CharIt != this->Characters.end() && Offset < (*CharIt)->GetLengthOffset() )
290  {
291  if( (*CharIt)->IsNewLine() )
292  continue;
293 
294  ++CharIt;
295  }
296 
297  // Check if we're too far to the right side to get anything
298  if( CharIt == (--(this->Characters.end())) && Offset > (*CharIt)->GetLengthOffset() + (*CharIt)->GetCharacterSize().X )
299  return NULL;
300 
301  return (*CharIt);
302  }
303 
305  {
306  return this->Characters.size();
307  }
308 
310  {
311  this->CurrLength = 0;
312  this->TallestHeight = 0;
313 
314  this->Characters.clear();
315  this->Parent->_MarkDirty();
316  }
317 
319  { return this->Characters.begin(); }
320 
322  { return this->Characters.end(); }
323 
325  { return this->Characters.begin(); }
326 
328  { return this->Characters.end(); }
329 
330  ///////////////////////////////////////////////////////////////////////////////
331  // LeftToRightTextLine Methods
332 
334  TextLine(ParentLayer)
335  { this->Alignment = UI::LA_TopLeft; }
336 
338  { }
339 
341  {
342  if( this->Characters.size() > 1 ) return *(++(this->Characters.rbegin()));
343  else return NULL;
344  }
345 
347  {
348  Real CursorPosition = this->GetLeftMostCursorPosition();
349  Character* Previous = NULL;
350  for( CharacterIterator CharIt = this->Characters.begin() ; CharIt != this->Characters.end() ; ++CharIt )
351  {
352  (*CharIt)->SetLengthOffset(CursorPosition);
353  CursorPosition += (*CharIt)->GetCharacterAdvance( Previous != NULL ? Previous->GetCharGlyph() : NULL );
354  Previous = (*CharIt);
355  }
356  this->Parent->_MarkDirty();
357  }
358 
360  {
361  this->Characters.push_back(ToAppend);
362  }
363 
365  {
366  this->Characters.insert(this->Characters.end(),First,Last);
367  }
368 
369  ///////////////////////////////////////////////////////////////////////////////
370  // Utility
371 
373  {
374  return this->GetLeftMostCursorPosition();
375  }
376 
377  ///////////////////////////////////////////////////////////////////////////////
378  // Character Management
379 
381  {
382  if( First == Last )
383  return false;
384 
385  // Set up data to be used
386  Real Tallest = 0, SequenceLength = 0;
387  Character* Previous = ( this->GetLastCharacter() != this->Characters.end() ? *(this->GetLastCharacter()) : NULL );
388 
389  // Collect the data we need from the provided characters
390  for( CharacterIterator CharIt = First ; CharIt != Last ; ++CharIt )
391  {
392  SequenceLength += (*CharIt)->GetCharacterAdvance( Previous != NULL ? Previous->GetCharGlyph() : NULL );
393  Tallest = std::max(Tallest,(*CharIt)->GetLineHeight());
394  Previous = (*CharIt);
395  }
396 
397  Real AddedLength = SequenceLength + this->CurrLength;
398  if( AddedLength <= MaxWidth )
399  {
400  this->CurrLength = AddedLength;
401  this->TallestHeight = std::max(TallestHeight,Tallest);
402  this->AppendToBack(First,Last);
403  this->RecalculateOffsets();
404  return true;
405  }
406 
407  return false;
408  }
409 
411  {
412  if( First == Last )
413  return First;
414 
415  // Set up data to be used
416  Character* Previous = ( this->GetLastCharacter() != this->Characters.end() ? *(this->GetLastCharacter()) : NULL );
417 
418  // Setup our iterator that will be used with our return and append operations
419  CharacterIterator CharIt = First;
420 
421  // Loop through our range
422  for( ; CharIt != Last ; ++CharIt )
423  {
424  Real CharAdvance = (*CharIt)->GetCharacterAdvance( Previous != NULL ? Previous->GetCharGlyph() : NULL );
425  Real AddedLength = CurrLength + CharAdvance;
426  if( AddedLength <= MaxWidth ) {
427  this->CurrLength = AddedLength;
428  this->TallestHeight = std::max(this->TallestHeight,(*CharIt)->GetLineHeight());
429  }else{
430  break;
431  }
432  Previous = (*CharIt);
433  }
434 
435  // Append, adjust offsets, and return
436  this->AppendToBack(First,CharIt);
437  this->RecalculateOffsets();
438  return CharIt;
439  }
440 
442  {
443  if( !this->Characters.empty() ) return this->Characters.begin();
444  else return this->Characters.end();
445  }
446 
448  {
449  if( !this->Characters.empty() ) return --(this->Characters.end());
450  else return this->Characters.end();
451  }
452 
454  {
455  if( Current != this->Characters.end() ) {
456  CharacterIterator Copy = Current;
457  return ++Copy;
458  }
459  return this->Characters.end();
460  }
461 
463  {
464  this->Characters.pop_front();
465  //Characters.erase(Characters.begin());
466  this->RecalculateOffsets();
467  }
468 
470  {
471  this->Characters.pop_back();
472  this->RecalculateOffsets();
473  }
474 
475  ///////////////////////////////////////////////////////////////////////////////
476  // RightToLeftTextLine Methods
477 
479  TextLine(ParentLayer)
480  { this->Alignment = UI::LA_BottomRight; }
481 
483  { }
484 
486  {
487  if( this->Characters.size() > 1 ) return *(++(this->Characters.begin()));
488  else return NULL;
489  }
490 
492  {
493  Real CursorPosition = this->GetRightMostCursorPosition();
494  Character* Previous = NULL;
495  for( ReverseCharacterIterator CharIt = this->Characters.rbegin() ; CharIt != this->Characters.rend() ; ++CharIt )
496  {
497  CursorPosition -= (*CharIt)->GetCharacterAdvance( Previous != NULL ? Previous->GetCharGlyph() : NULL );
498  (*CharIt)->SetLengthOffset(CursorPosition);
499  Previous = (*CharIt);
500  }
501  this->Parent->_MarkDirty();
502  }
503 
505  {
506  this->Characters.insert(this->Characters.begin(),ToAppend);
507  }
508 
510  {
511  this->Characters.insert(this->Characters.begin(),First,Last);
512  }
513 
514  ///////////////////////////////////////////////////////////////////////////////
515  // Utility
516 
518  {
519  return this->GetRightMostCursorPosition();
520  }
521 
522  ///////////////////////////////////////////////////////////////////////////////
523  // Character Management
524 
526  {
527  if( First == Last )
528  return false;
529 
530  // Set up data to be used
531  Real Tallest = 0, SequenceLength = 0;
532  Character* Previous = ( this->GetLastCharacter() != this->Characters.end() ? *(this->GetLastCharacter()) : NULL );
533 
534  // Setup our iterators for iteration (format provided is for insertion)
535  CharacterIterator FirstCopy = First;
536  CharacterIterator LastCopy = Last;
537  --FirstCopy;
538  --LastCopy;
539 
540  // Collect the data we need from the provided characters
541  for( CharacterIterator CharIt = LastCopy ; CharIt != FirstCopy ; --CharIt )
542  {
543  SequenceLength += (*CharIt)->GetCharacterAdvance( Previous != NULL ? Previous->GetCharGlyph() : NULL );
544  Tallest = std::max(Tallest,(*CharIt)->GetLineHeight());
545  Previous = (*CharIt);
546  }
547 
548  Real AddedLength = SequenceLength + this->CurrLength;
549  if( AddedLength <= MaxWidth )
550  {
551  this->CurrLength = AddedLength;
552  this->TallestHeight = std::max(TallestHeight,Tallest);
553  this->AppendToBack(First,Last);
554  this->RecalculateOffsets();
555  return true;
556  }
557 
558  return false;
559  }
560 
562  {
563  if( First == Last )
564  return First;
565 
566  // Set up data to be used
567  Character* Previous = ( this->GetLastCharacter() != this->Characters.end() ? *(this->GetLastCharacter()) : NULL );
568 
569  // Setup our iterators for iteration (format provided is for insertion)
570  CharacterIterator FirstCopy = First;
571  CharacterIterator LastCopy = Last;
572  --FirstCopy;
573  --LastCopy;
574 
575  // Setup our iterator that will be used with our return and append operations
576  CharacterIterator CharIt = LastCopy;
577 
578  // Loop through our range
579  for( ; CharIt != FirstCopy ; --CharIt )
580  {
581  Real CharAdvance = (*CharIt)->GetCharacterAdvance( Previous != NULL ? Previous->GetCharGlyph() : NULL );
582  Real AddedLength = CurrLength + CharAdvance;
583  if( AddedLength <= MaxWidth ) {
584  this->CurrLength = AddedLength;
585  this->TallestHeight = std::max(this->TallestHeight,(*CharIt)->GetLineHeight());
586  }else{
587  break;
588  }
589  Previous = (*CharIt);
590  }
591 
592  // Append, adjust offsets, and return
593  this->AppendToBack(CharIt,Last);
594  this->RecalculateOffsets();
595  return CharIt;
596  }
597 
599  {
600  if( !this->Characters.empty() ) return --(this->Characters.end());
601  else return this->Characters.end();
602  }
603 
605  {
606  if( !this->Characters.empty() ) return this->Characters.begin();
607  else return this->Characters.end();
608  }
609 
611  {
612  CharacterIterator Copy = Current;
613  if( *Current != this->Characters.front() ) return --Copy;
614  else return Copy;
615  }
616 
618  {
619  this->Characters.pop_back();
620  this->RecalculateOffsets();
621  }
622 
624  {
625  this->Characters.pop_front();
626  //Characters.erase(Characters.begin());
627  this->RecalculateOffsets();
628  }
629  }//UI
630 }//Mezzanine
631 
632 #endif
CharacterIterator GetFirstCharacter()
Gets the first character in this TextLine.
Definition: textline.cpp:441
virtual void AppendToBack(Character *ToAppend)=0
Adds a character such that it becomes the last in the sequence.
TextLayer * Parent
The parent layer this text line belongs to.
Definition: textline.h:82
CharacterIterator GetLastCharacter()
Gets the last character in this TextLine.
Definition: textline.cpp:604
Real GetPositionOffset() const
Gets the offset on the Y axis from the parent layer.
Definition: textline.cpp:225
bool Boole
Generally acts a single bit, true or false.
Definition: datatypes.h:173
virtual Real GetCursorStartPosition() const =0
Gets the offset position of the cursor based on the text order of the layer this text line belongs to...
CharacterIterator BeginCharacter()
Gets an iterator to the first Character.
Definition: textline.cpp:318
CharacterIterator AppendFittingCharacters(CharacterIterator First, CharacterIterator Last, const Real MaxWidth)
Adds as many Characters in a range as will fit to this TextLine.
Definition: textline.cpp:410
LeftToRightTextLine(TextLayer *ParentLayer)
Class constructor.
Definition: textline.cpp:333
CharacterIterator EndCharacter()
Gets an iterator to one passed the last Character.
Definition: textline.cpp:321
Character * GetCharacterAtOffset(const Real &Offset)
Gets the character in this textline at the specified offset.
Definition: textline.cpp:282
virtual ~TextLine()
Class destructor.
Definition: textline.cpp:64
UInt32 GetNumCharacters() const
Gets the number of characters in this TextLine.
Definition: textline.cpp:304
UI::LinearAlignment GetAlignment() const
Gets the current alignment for the text in this line of text.
Definition: textline.cpp:78
Real PositionOffset
The offset in pixels from the parent layer on the Y axis.
Definition: textline.h:91
CharacterIterator GetNextCharacter(CharacterIterator Current)
Gets an iterator to the next Character.
Definition: textline.cpp:453
int Integer
A datatype used to represent any integer close to.
Definition: datatypes.h:154
Real GetOffsetAtIndex(const Integer &Index) const
Gets the Offset position of the character at the specified index.
Definition: textline.cpp:146
Real GetCursorStartPosition() const
Gets the offset position of the cursor based on the text order of the layer this text line belongs to...
Definition: textline.cpp:517
virtual void _MarkDirty()
Marks this renderable as well as all parent objects as dirty.
CharacterIterator AppendFittingCharacters(CharacterIterator First, CharacterIterator Last, const Real MaxWidth)
Adds as many Characters in a range as will fit to this TextLine.
Definition: textline.cpp:561
Real CurrLength
The current length of this TextLine.
Definition: textline.h:85
This represents a single line of text to be rendered by a TextLayer.
Definition: textline.h:59
OffsetResultPair GetCharacterAndCursorPositionAtOffset(const Real &Offset) const
Gets the character at the provided offset as well as the nearest valid position the cursor can take...
Definition: textline.cpp:83
void RemoveAllCharacters()
Removes all characters from this TextLine.
Definition: textline.cpp:309
CharacterIterator AppendFittingCharacters(CharacterContainer &ToAdd, const Real MaxWidth)
Adds as many Characters in a range as will fit to this TextLine.
Definition: textline.cpp:260
Boole AppendCharacter(Character *ToAdd, const Real MaxWidth)
Adds a Character to the end of this TextLine.
Definition: textline.cpp:237
virtual ~LeftToRightTextLine()
Class destructor.
Definition: textline.cpp:337
CharacterIterator GetNextCharacter(CharacterIterator Current)
Gets an iterator to the next Character.
Definition: textline.cpp:610
CharacterIterator GetLastCharacter()
Gets the last character in this TextLine.
Definition: textline.cpp:447
float Real
A Datatype used to represent a real floating point number.
Definition: datatypes.h:141
LinearAlignment
Used by various UI classes to determine the alignment of their child objects, such as text in text li...
std::list< Character * > CharacterContainer
Basic container type for Character storage by this class.
Definition: textline.h:63
void SetAlignment(const UI::LinearAlignment Align)
Sets the current alignment for the text in this line of text.
Definition: textline.cpp:70
Real GetRightMostCursorPosition() const
Gets the offset position of the right-most part of this TextLine.
Definition: textline.cpp:181
void AppendToBack(Character *ToAppend)
Adds a character such that it becomes the last in the sequence.
Definition: textline.cpp:359
Real GetCharacterAdvance(Glyph *Prev) const
Gets the amount of pixels to advance the cursor after placing this character.
Definition: character.cpp:129
void RecalculateOffsets()
Recalculates the offset for every character in this line.
Definition: textline.cpp:346
std::pair< Character *, Vector2 > OffsetResultPair
An std::pair storing a Character and it's offset position (relative to the parent layer)...
Definition: textline.h:75
Boole AppendCharacters(CharacterIterator First, CharacterIterator Last, const Real MaxWidth)
Adds a series of Characters to the end of this TextLine.
Definition: textline.cpp:380
Integer GetIndexAtOffset(const Real &Offset) const
Gets the index of the character at the provided offset.
Definition: textline.cpp:119
This class creates and encapsultes a character that can be used in text renders.
Definition: character.h:59
uint32_t UInt32
An 32-bit unsigned integer.
Definition: datatypes.h:126
This is used to represent a point on a 2 dimentional area, such as a screen.
Definition: vector2.h:63
void RecalculateOffsets()
Recalculates the offset for every character in this line.
Definition: textline.cpp:491
Character * GetSecondFromLastCharacter() const
Gets the character before the last character.
Definition: textline.cpp:340
Real GetLineHeight() const
Gets the size of this TextLine on the Y axis.
Definition: textline.cpp:231
virtual Real GetMaxLineWidth() const
Gets the maximum width of text lines in this layer.
Definition: textlayer.cpp:373
Real TallestHeight
The size of the largest glyph on the Y axis.
Definition: textline.h:88
Real GetClosestCursorPosition(const Real &Offset)
Gets the closest valid cursor position to the offset provided.
Definition: textline.cpp:193
UI::LinearAlignment Alignment
The alignment of the text on the X axis in this line.
Definition: textline.h:94
void RemoveLastCharacter()
Removes the character at the end of this TextLine.
Definition: textline.cpp:623
std::pair< CharacterIterator, CharacterIterator > CharacterIteratorPair
An std::pair storing two CharacterIterators, usually for expressing a range.
Definition: textline.h:73
void RemoveFirstCharacter()
Removes the character at the start of this TextLine.
Definition: textline.cpp:462
Character * GetSecondFromLastCharacter() const
Gets the character before the last character.
Definition: textline.cpp:485
Real GetCurrentLength() const
Calculates the current length of this text line.
Definition: textline.cpp:228
CharacterContainer::iterator CharacterIterator
Iterator type for Character instances stored by this class.
Definition: textline.h:65
CharacterContainer::reverse_iterator ReverseCharacterIterator
Reverse Iterator type for Character instances stored by this class.
Definition: textline.h:69
Boole AppendCharacters(CharacterIterator First, CharacterIterator Last, const Real MaxWidth)
Adds a series of Characters to the end of this TextLine.
Definition: textline.cpp:525
Real GetCursorStartPosition() const
Gets the offset position of the cursor based on the text order of the layer this text line belongs to...
Definition: textline.cpp:372
Real GetLineHeight() const
Gets the height a line needs to be to support rendering this character.
Definition: character.cpp:155
void SetLengthOffset(const Real &Offset)
Sets the offset from the position of the parent TextLine.
Definition: character.cpp:312
Glyph * GetCharGlyph() const
Gets the glyph being rendered by this character.
Definition: character.cpp:375
The bulk of the engine components go in this namspace.
Definition: actor.cpp:56
Boole AppendCharacters(CharacterContainer &ToAdd, const Real MaxWidth)
Adds a series of Characters to the end of this TextLine.
Definition: textline.cpp:254
Real GetLeftMostCursorPosition() const
Gets the offset position of the left-most part of this TextLine.
Definition: textline.cpp:169
void SetPositionOffset(const Real &Offset)
Sets the offset on the Y axis from the parent layer.
Definition: textline.cpp:222
void RemoveFirstCharacter()
Removes the character at the start of this TextLine.
Definition: textline.cpp:617
Character * GetCharacterAtIndex(const UInt32 &Index)
Gets the character in this textline at the specified index.
Definition: textline.cpp:266
virtual void RecalculateOffsets()=0
Recalculates the offset for every character in this line.
virtual ~RightToLeftTextLine()
Class destructor.
Definition: textline.cpp:482
CharacterContainer::const_iterator ConstCharacterIterator
Const Iterator type for Character instances stored by this class.
Definition: textline.h:67
TextLine(TextLayer *ParentLayer)
Class constructor.
Definition: textline.cpp:57
void AppendToBack(Character *ToAppend)
Adds a character such that it becomes the last in the sequence.
Definition: textline.cpp:504
This is a base class for render layers that render text.
Definition: textlayer.h:64
RightToLeftTextLine(TextLayer *ParentLayer)
Class constructor.
Definition: textline.cpp:478
virtual CharacterIterator GetLastCharacter()=0
Gets the last character in this TextLine.
CharacterContainer Characters
Vector containing all the characters belonging to this TextLine.
Definition: textline.h:79
CharacterIterator GetFirstCharacter()
Gets the first character in this TextLine.
Definition: textline.cpp:598
void RemoveLastCharacter()
Removes the character at the end of this TextLine.
Definition: textline.cpp:469