Refactored Font and Text classes.

--HG--
branch : dev
This commit is contained in:
Martí­n Lucas Golini
2017-03-24 04:49:14 -03:00
parent 97558261ae
commit bb0a6cacda
8 changed files with 263 additions and 326 deletions

View File

@@ -41,30 +41,6 @@ class EE_API Font {
/** @return The font id */
const Uint32& getId();
/** Shrink the String to a max width
* @param Str The string to shrink
* @param MaxWidth The Max Width posible
*/
void shrinkText( String& Str, const Uint32& characterSize, bool bold, Float outlineThickness, const Uint32& MaxWidth );
/** Shrink the string to a max width
* @param Str The string to shrink
* @param MaxWidth The Max Width posible
*/
void shrinkText( std::string& Str, const Uint32& characterSize, bool bold, Float outlineThickness, const Uint32& MaxWidth );
/** Cache the with of the current text */
void cacheWidth( const String& TextCache, const Uint32& characterSize, bool bold, Float outlineThickness, std::vector<Float>& LinesWidth, Float& CachedWidth, int& NumLines, int& LargestLineCharCount );
/** Finds the closest cursor position to the point position */
Int32 findClosestCursorPosFromPoint( const String& TextCache, const Uint32& characterSize, bool bold, Float outlineThickness, const Vector2i& pos );
/** Simulates a selection request and return the initial and end cursor position when the selection worked. Otherwise both parameters will be -1. */
void selectSubStringFromCursor(const String& TextCache, const Int32& CurPos, Int32& InitCur, Int32& EndCur );
/** @return The cursor position inside the string */
Vector2i getCursorPos( const String& TextCache, const Uint32& characterSize, bool bold, Float outlineThickness, const Uint32& Pos );
virtual const Info& getInfo() const = 0;
virtual const Glyph& getGlyph(Uint32 codePoint, unsigned int characterSize, bool bold, Float outlineThickness = 0) const = 0;

View File

@@ -102,6 +102,20 @@ class EE_API Text {
const int& getNumLines();
void setStyleConfig( const FontStyleConfig& styleConfig );
/** Finds the closest cursor position to the point position */
Int32 findCharacterFromPos( const Vector2i& pos );
/** Simulates a selection request and return the initial and end cursor position when the selection worked. Otherwise both parameters will be -1. */
void findWordFromCharacterIndex( const Int32& characterIndex, Int32& InitCur, Int32& EndCur );
/** Cache the with of the current text */
void getWidthInfo( std::vector<Float>& LinesWidth, Float& CachedWidth, int& NumLines, int& LargestLineCharCount );
/** Shrink the String to a max width
* @param MaxWidth The Max Width posible
*/
void shrinkText( const Uint32& MaxWidth );
protected:
struct VertexCoords {
Vector2f texCoords;

View File

@@ -93,13 +93,13 @@ class EE_API UITextView : public UIWidget {
Recti mRealPadding;
struct SelPosCache
{
SelPosCache( Vector2i ip, Vector2i ep ) :
SelPosCache( Vector2f ip, Vector2f ep ) :
initPos( ip ),
endPos( ep )
{}
Vector2i initPos;
Vector2i endPos;
Vector2f initPos;
Vector2f endPos;
};
std::vector<SelPosCache> mSelPosCache;
Int32 mLastSelCurInit;