dl
dl::Text类 参考

2d文本绘制对象 更多...

#include <dl_text.h>

struct  Layout
 布局属性 更多...
 

Public 成员函数

void Render ()
 绘制
 
void SetFormat (bool open)
 设置是否要格式化字符串(默认为否)
 
void SetLayoutAlign (Align::Direction dir_h)
 设置布局属性(多行内的单行)
 
void SetPositionAlign (const Position &pos={}, const Align::Direction2 &dir=Align::LT)
 设置Coor位置,来整体对齐
 
void SetCenter (const Position &pos={})
 设置Coor位置,并根据整体大小居中
 
void SetMaxW (float w)
 设置自动换行宽度,0为不自动换行
 
void SetLineSpacing (Float k)
 设置行间距,默认为1.0
 
const LayoutGetLayout ()
 
void SetOrder (float order)
 设置绘制顺序
 
void SetColor (const Color &col, TextParam type=TextParam::NORMAL)
 设置颜色
 
bool SetString (std::string_view str)
 设置内容
 
void SetFontId (std::size_t id)
 设置字体id
 
void SetFontSize (unsigned size)
 设置字体大小
 
void SetOutline (unsigned outline, const Color &color=ColorDef::BLACK)
 设置描边属性
 
void SetShadow (unsigned shadow, const Color &color=ColorDef::BLACK)
 设置阴影属性
 
void SetBackground (bool open, const Color &col=ColorDef::TEXT_BG)
 设置背景精灵
 
void SetBackground (Text *b)
 注意传入gcText会调用上面的重载
 
CoorGetCoor ()
 返回坐标系
 
float GetOrder ()
 
std::string GetString ()
 
Color GetColor (TextParam type=TextParam::NORMAL)
 
Position GetSize ()
 返回区域大小
 
unsigned GetFontSize (TextParam type=TextParam::NORMAL)
 返回字体大小
 
void SetUI (bool ui)
 设置是否是ui(影响穿透)
 
bool IsPickup ()
 是否被光标选中
 
size_t Pos2Index (const Position &pos)
 返回所在位置(本地坐标系)的字符下标
 
Position Index2Pos (size_t i)
 下标转到 字符位置(本地坐标系、左上角)
 
Position GetNodeSize (size_t i)
 获取某个字的包围盒大小
 
unsigned GetNodeFontSize (size_t i)
 获取某个字的字体大小
 
size_t Pos2IndexOutRange (const Position &pos)
 返回所在位置(本地坐标系)的字符下标
 
size_t Pos2CursorIndex (const Position &pos)
 返回所在位置(本地坐标系)的光标下标
 
void RenderDebug ()
 
 ~Text ()
 

友元

class Factory
 
class PoolList< Text >
 

详细描述

2d文本绘制对象

在文件 dl_text.h100 行定义.

构造及析构函数说明

◆ ~Text()

dl::Text::~Text ( )

成员函数说明

◆ GetColor()

Color dl::Text::GetColor ( TextParam type = TextParam::NORMAL)
inline

在文件 dl_text.h266 行定义.

◆ GetCoor()

Coor * dl::Text::GetCoor ( )
inline

返回坐标系

注解
注意,直接调整位置是以左上角对齐,请优先使用SetPositionAlign
缩放会自动控制,请勿设置

在文件 dl_text.h260 行定义.

◆ GetFontSize()

unsigned dl::Text::GetFontSize ( TextParam type = TextParam::NORMAL)
inline

返回字体大小

在文件 dl_text.h281 行定义.

◆ GetLayout()

const Layout & dl::Text::GetLayout ( )
inline

在文件 dl_text.h185 行定义.

◆ GetNodeFontSize()

unsigned dl::Text::GetNodeFontSize ( size_t i)

获取某个字的字体大小

◆ GetNodeSize()

Position dl::Text::GetNodeSize ( size_t i)

获取某个字的包围盒大小

◆ GetOrder()

float dl::Text::GetOrder ( )
inline

在文件 dl_text.h262 行定义.

◆ GetSize()

Position dl::Text::GetSize ( )

返回区域大小

注解
字体本身一定是左上角为0
高度与字体大小相关,例如"a"与"q"的高度一样

◆ GetString()

std::string dl::Text::GetString ( )

◆ Index2Pos()

Position dl::Text::Index2Pos ( size_t i)

下标转到 字符位置(本地坐标系、左上角)

◆ IsPickup()

bool dl::Text::IsPickup ( )

是否被光标选中

◆ Pos2CursorIndex()

size_t dl::Text::Pos2CursorIndex ( const Position & pos)

返回所在位置(本地坐标系)的光标下标

参数
[in]pos位置
注解
超出位置,返回行尾。选中字符右侧,返回值+1

◆ Pos2Index()

size_t dl::Text::Pos2Index ( const Position & pos)

返回所在位置(本地坐标系)的字符下标

参数
[in]pos位置

◆ Pos2IndexOutRange()

size_t dl::Text::Pos2IndexOutRange ( const Position & pos)

返回所在位置(本地坐标系)的字符下标

参数
[in]pos位置
注解
超出位置,返回行尾。

◆ Render()

void dl::Text::Render ( )

绘制

◆ RenderDebug()

void dl::Text::RenderDebug ( )

◆ SetBackground() [1/2]

void dl::Text::SetBackground ( bool open,
const Color & col = ColorDef::TEXT_BG )

设置背景精灵

注解
自动设定为文本大小,但可以设定颜色

◆ SetBackground() [2/2]

void dl::Text::SetBackground ( Text * b)
inline

注意传入gcText会调用上面的重载

在文件 dl_text.h247 行定义.

◆ SetCenter()

void dl::Text::SetCenter ( const Position & pos = {})

设置Coor位置,并根据整体大小居中

注解
字体大小变化后,需要重新设置

◆ SetColor()

void dl::Text::SetColor ( const Color & col,
TextParam type = TextParam::NORMAL )

设置颜色

◆ SetFontId()

void dl::Text::SetFontId ( std::size_t id)

设置字体id

◆ SetFontSize()

void dl::Text::SetFontSize ( unsigned size)

设置字体大小

◆ SetFormat()

void dl::Text::SetFormat ( bool open)
inline

设置是否要格式化字符串(默认为否)

在文件 dl_text.h131 行定义.

◆ SetLayoutAlign()

void dl::Text::SetLayoutAlign ( Align::Direction dir_h)
inline

设置布局属性(多行内的单行)

在文件 dl_text.h143 行定义.

◆ SetLineSpacing()

void dl::Text::SetLineSpacing ( Float k)
inline

设置行间距,默认为1.0

在文件 dl_text.h179 行定义.

◆ SetMaxW()

void dl::Text::SetMaxW ( float w)
inline

设置自动换行宽度,0为不自动换行

在文件 dl_text.h171 行定义.

◆ SetOrder()

void dl::Text::SetOrder ( float order)

设置绘制顺序

◆ SetOutline()

void dl::Text::SetOutline ( unsigned outline,
const Color & color = ColorDef::BLACK )

设置描边属性

◆ SetPositionAlign()

void dl::Text::SetPositionAlign ( const Position & pos = {},
const Align::Direction2 & dir = Align::LT )
inline

设置Coor位置,来整体对齐

注解
字体大小变化后,需要重新设置

在文件 dl_text.h155 行定义.

◆ SetShadow()

void dl::Text::SetShadow ( unsigned shadow,
const Color & color = ColorDef::BLACK )

设置阴影属性

◆ SetString()

bool dl::Text::SetString ( std::string_view str)

设置内容

参数
[in]str要设置的内容
返回值
未修改返回false
备注
格式化标签如下
[c_red] 颜色 红色,可以有3个,额外指定描边和阴影的颜色
[f_0] 字体 id为0的字体
[s_24_2_1] 字体大小 24大小,2描边大小,1阴影偏移
[spr_test_0_1] 精灵 test, [0, 1]
[v_money] 变量 money
[t_8] 对齐 tab对齐到8个字体大小,默认为2个(即4个英文字母宽度)
[l] 左中括号
[r] 右中括号
[n_2] 换行 换行2次,默认为1次
[b_white] 背景颜色 白色
特殊的 [c]、[f] 还原到字体本身颜色和字体

◆ SetUI()

void dl::Text::SetUI ( bool ui)
inline

设置是否是ui(影响穿透)

在文件 dl_text.h288 行定义.

友元及相关符号说明

◆ Factory

friend class Factory
friend

在文件 dl_text.h102 行定义.

◆ PoolList< Text >

friend class PoolList< Text >
friend

在文件 dl_text.h102 行定义.


该类的文档由以下文件生成: