NvUIText Class Reference

A UI element that renders text strings to the view. More...

#include <NvUI.h>

Inheritance diagram for NvUIText:

NvUIElement

List of all members.

Public Member Functions

 NvUIText (const char *str, NvUIFontFamily::Enum font, float size, NvUITextAlign::Enum halign)
 Default constructor for onscreen text element.
void SetAlignment (NvUITextAlign::Enum halign)
 Set the horizontal alignment of the text.
virtual void SetAlpha (float alpha)
 Set the alpha transparency of the text.
void SetColor (const NvPackedColor &color)
 Set the overall color of the text.
void SetShadow (char offset, NvPackedColor color=NV_PC_PREDEF_BLACK)
 Set drop-shadow features on the text.
void SetTextBox (float width, float height, uint32_t lines, uint32_t dots)
 Assign a box the text will render within.
virtual void SetDimensions (float w, float h)
 Override so if a box has been set, we update the width and height with these values.
virtual void Draw (const NvUIDrawState &drawState)
 Make proper calls to the text rendering system to draw our text to the viewport.
void SetString (const char *in)
 Set the string to be drawn.
void SetFontSize (float size)
 Set the font size to use for our text.
float GetFontSize ()
 Get our font size value.
float GetStringPixelWidth ()
 Get the approximate output pixel width calculated for our text.
void SetDrawnChars (int32_t count)
 Set an explicit character count truncation for drawing our text.

Static Public Member Functions

static uint8_t GetFontID (NvUIFontFamily::Enum font)
 Static helper method to get the specific font ID for a given font family enum.
static bool StaticInit (float width=1280, float height=720)
 Static helper method for initializing underlying text system with current view size.
static void StaticCleanup ()
 Static helper method for cleaning up any static held items in the text system.

Protected Attributes

BFText * m_bftext
 The NvBitFont BFText object that does actual text rendering.
float m_size
 Local cache of the original font size.
NvPackedColor m_color
 Modulation of the text with an RGB color.
bool m_wrap
 Whether we wrap or truncate if exceed drawable width.


Detailed Description

A UI element that renders text strings to the view.

This class wrappers rendering of a string to the screen using NvBitFont.

It exposes all the matching functionality, including font, size, color, drop-shadow, alignment 'text box', and multi-line output support.

See also:
NvBitFont.h

Constructor & Destructor Documentation

NvUIText::NvUIText ( const char *  str,
NvUIFontFamily::Enum  font,
float  size,
NvUITextAlign::Enum  halign 
)

Default constructor for onscreen text element.

Parameters:
str Text string to display.
font Font family to use for this text.
size Font size to use for this text.
halign Alignment to use for this text.


Member Function Documentation

virtual void NvUIText::Draw ( const NvUIDrawState drawState  )  [virtual]

Make proper calls to the text rendering system to draw our text to the viewport.

Reimplemented from NvUIElement.

static uint8_t NvUIText::GetFontID ( NvUIFontFamily::Enum  font  )  [static]

Static helper method to get the specific font ID for a given font family enum.

float NvUIText::GetFontSize (  )  [inline]

Get our font size value.

float NvUIText::GetStringPixelWidth (  ) 

Get the approximate output pixel width calculated for our text.

void NvUIText::SetAlignment ( NvUITextAlign::Enum  halign  ) 

Set the horizontal alignment of the text.

virtual void NvUIText::SetAlpha ( float  alpha  )  [virtual]

Set the alpha transparency of the text.

Reimplemented from NvUIElement.

void NvUIText::SetColor ( const NvPackedColor color  ) 

Set the overall color of the text.

virtual void NvUIText::SetDimensions ( float  w,
float  h 
) [virtual]

Override so if a box has been set, we update the width and height with these values.

Reimplemented from NvUIElement.

void NvUIText::SetDrawnChars ( int32_t  count  ) 

Set an explicit character count truncation for drawing our text.

This is handy helper function for doing simple 'type on' animated visuals.

void NvUIText::SetFontSize ( float  size  ) 

Set the font size to use for our text.

void NvUIText::SetShadow ( char  offset,
NvPackedColor  color = NV_PC_PREDEF_BLACK 
)

Set drop-shadow features on the text.

void NvUIText::SetString ( const char *  in  ) 

Set the string to be drawn.

void NvUIText::SetTextBox ( float  width,
float  height,
uint32_t  lines,
uint32_t  dots 
)

Assign a box the text will render within.

The box will be used to align, wrap, and crop the text.

  • If lines is 1, only a single line will be drawn, cropped at the box width.
  • If lines is 0, we will wrap and never crop.
  • If lines is >1, we will wrap for that many lines, and crop on the final line.
  • If dots is a valid character, when we crop we won't simply truncate, will will back up enough to fit in three of the dots character as ellipses.
  • When a box is active, all alignment settings on the text become relative to the box rather than the view.
  • If width or height is zero, the box will be cleared/disabled.
Parameters:
width Set the width of the box
height Set the height of the box
lines Set the number of vertical lines allowed for the text
dots Set the character to use as ellipses

static void NvUIText::StaticCleanup (  )  [static]

Static helper method for cleaning up any static held items in the text system.

static bool NvUIText::StaticInit ( float  width = 1280,
float  height = 720 
) [static]

Static helper method for initializing underlying text system with current view size.


Member Data Documentation

BFText* NvUIText::m_bftext [protected]

The NvBitFont BFText object that does actual text rendering.

float NvUIText::m_size [protected]

Local cache of the original font size.

bool NvUIText::m_wrap [protected]

Whether we wrap or truncate if exceed drawable width.


The documentation for this class was generated from the following file: