dl
dl::UI::Button类 参考abstract

按钮(Button、Switch、Radio) 更多...

#include <dl_ui_button_base.h>

dl::UI::ButtonNormal, dl::UI::ButtonScale, dl::UI::ButtonSprite, dl::UI::ButtonSprite9, dl::UI::ButtonSpriteColor , 以及 dl::UI::ButtonTextColor 继承.

struct  TextData
 

Public 类型

enum class  State {
  NORMAL , OVER , DOWN , DISABLE ,
  DOWN_OVER , DOWN_DISABLE , MAX_NUM
}
 
enum class  Mode { BUTTON , SWITCH , RADIO }
 
using CbCustomRender = std::function<void(Button*)>
 
using CbEventClick = std::function<void(Button*)>
 

Public 成员函数

 Button ()
 
 Button (const Button &b)
 
void Update ()
 
void Render ()
 
bool IsClick ()
 控件被点击
 
bool IsDown ()
 控件按下状态
 
bool IsOverOnce ()
 经过按钮,直到离开控件再次进入才会返回真
 
bool IsRadio ()
 
bool IsSelect ()
 控件是选中状态
 
void SetSelect (bool open)
 
void SetMode (Mode mode)
 
void SetDisable (bool disable)
 
void ClearState ()
 清理状态为普通
 
void SetSound (std::string_view click, std::string_view over)
 设置按钮音效
 
State GetState ()
 
CoorGetCoor ()
 添加到Panel后会自动设置Coor数据,要设置位置等 请调用SetElementData
 
virtual ButtonClone ()=0
 必须实现的函数
 
virtual bool IsPickup ()=0
 
virtual void SetOrder (float order)=0
 
virtual float GetOrder ()=0
 
virtual Position GetSize ()=0
 
virtual Position GetAnchor ()=0
 
float GetOrder (int offset)
 
void SetElementData (const Align::Direction2 &hv, const Position &pos={})
 
void SetElementDataRunAble (bool able)
 
void SetElementDataAutoSize (bool parent_w, bool parent_h)
 
std::string GetString ()
 
void AddText (gcText txt, const std::vector< Color > &mul_col, const std::vector< Position > &mul_offset)
 添加文本属性
 
void AddTextDefault ()
 
void AddText (gcText txt)
 
void AddText (gcText txt, const std::vector< Color > &mul_col)
 
void SetString (std::string_view str)
 
void SetTextAlign (const Align::Direction2 &hv)
 
void SetSizeWithText (bool with, const Position &extra_size)
 设置精灵大小跟随文本
 
void SetName (std::string_view name)
 
void SetCustomRender (CbCustomRender cb)
 
void SetEevntClick (CbEventClick cb)
 
ComponentsGetCpt ()
 
Mode GetMode ()
 
virtual ~Button ()
 

静态 Public 成员函数

static ButtonGetClickControl ()
 

Protected 成员函数

std::size_t GetIndex (State state)
 返回索引
 
void _refresh_element_data ()
 
constexpr bool _use_over ()
 
virtual void UpdateChild (State state_pre, State state)
 重载此函数,制定控件行为
 
virtual void RenderChild (State state_pre, State state)
 
virtual void RenderDebug ()
 
void UpdateTextOrder (float order)
 order变化时需要调用
 
virtual void OnTextSizeChange (const Position &size)
 
TextDataGetTextData ()
 

Protected 属性

Coor_coor
 

详细描述

按钮(Button、Switch、Radio)

在文件 dl_ui_button_base.h29 行定义.

成员类型定义说明

◆ CbCustomRender

using dl::UI::Button::CbCustomRender = std::function<void(Button*)>

在文件 dl_ui_button_base.h32 行定义.

◆ CbEventClick

using dl::UI::Button::CbEventClick = std::function<void(Button*)>

在文件 dl_ui_button_base.h33 行定义.

成员枚举类型说明

◆ Mode

enum class dl::UI::Button::Mode
strong
枚举值
BUTTON 

按钮

SWITCH 

开关,按下后不会自动弹起,再次点击后弹起

RADIO 

收音机按钮,按下后就不能弹起,只能通过代码弹起

在文件 dl_ui_button_base.h45 行定义.

◆ State

enum class dl::UI::Button::State
strong
枚举值
NORMAL 

普通

OVER 

经过(仅有光标时使用)

DOWN 

按下

DISABLE 

禁用

DOWN_OVER 

按下经过(Switch使用)

DOWN_DISABLE 

按下禁用(Switch、Radio使用)

MAX_NUM 

在文件 dl_ui_button_base.h34 行定义.

构造及析构函数说明

◆ Button() [1/2]

dl::UI::Button::Button ( )
inline

在文件 dl_ui_button_base.h73 行定义.

◆ Button() [2/2]

dl::UI::Button::Button ( const Button & b)

◆ ~Button()

virtual dl::UI::Button::~Button ( )
inlinevirtual

在文件 dl_ui_button_base.h237 行定义.

成员函数说明

◆ _refresh_element_data()

void dl::UI::Button::_refresh_element_data ( )
inlineprotected

在文件 dl_ui_button_base.h277 行定义.

◆ _use_over()

bool dl::UI::Button::_use_over ( )
inlineconstexprprotected

在文件 dl_ui_button_base.h283 行定义.

◆ AddText() [1/3]

void dl::UI::Button::AddText ( gcText txt)

◆ AddText() [2/3]

void dl::UI::Button::AddText ( gcText txt,
const std::vector< Color > & mul_col )

◆ AddText() [3/3]

void dl::UI::Button::AddText ( gcText txt,
const std::vector< Color > & mul_col,
const std::vector< Position > & mul_offset )

添加文本属性

参数
[in]txt文本
[in]mul_col5种状态颜色
[in]mul_offset5种状态的文本偏移

◆ AddTextDefault()

void dl::UI::Button::AddTextDefault ( )

◆ ClearState()

void dl::UI::Button::ClearState ( )

清理状态为普通

◆ Clone()

virtual Button * dl::UI::Button::Clone ( )
pure virtual

◆ GetAnchor()

◆ GetClickControl()

static Button * dl::UI::Button::GetClickControl ( )
inlinestatic

在文件 dl_ui_button_base.h232 行定义.

◆ GetCoor()

Coor * dl::UI::Button::GetCoor ( )
inline

添加到Panel后会自动设置Coor数据,要设置位置等 请调用SetElementData

在文件 dl_ui_button_base.h147 行定义.

◆ GetCpt()

Components * dl::UI::Button::GetCpt ( )
inline

在文件 dl_ui_button_base.h226 行定义.

◆ GetIndex()

std::size_t dl::UI::Button::GetIndex ( State state)
inlineprotected

返回索引

在文件 dl_ui_button_base.h261 行定义.

◆ GetMode()

Mode dl::UI::Button::GetMode ( )
inline

在文件 dl_ui_button_base.h228 行定义.

◆ GetOrder() [1/2]

virtual float dl::UI::Button::GetOrder ( )
pure virtual

◆ GetOrder() [2/2]

float dl::UI::Button::GetOrder ( int offset)
inline

在文件 dl_ui_button_base.h159 行定义.

◆ GetSize()

◆ GetState()

State dl::UI::Button::GetState ( )
inline

在文件 dl_ui_button_base.h141 行定义.

◆ GetString()

std::string dl::UI::Button::GetString ( )
inline

在文件 dl_ui_button_base.h180 行定义.

◆ GetTextData()

TextData * dl::UI::Button::GetTextData ( )
inlineprotected

在文件 dl_ui_button_base.h309 行定义.

◆ IsClick()

bool dl::UI::Button::IsClick ( )

控件被点击

注解
对于 button来说,单击并释放才会触发
对于 switch来说,单击并释放才会触发
对于 radio来说,单击才会触发

◆ IsDown()

bool dl::UI::Button::IsDown ( )
inline

控件按下状态

注解
状态为DOWN

在文件 dl_ui_button_base.h105 行定义.

◆ IsOverOnce()

bool dl::UI::Button::IsOverOnce ( )

经过按钮,直到离开控件再次进入才会返回真

◆ IsPickup()

virtual bool dl::UI::Button::IsPickup ( )
pure virtual

◆ IsRadio()

bool dl::UI::Button::IsRadio ( )
inline

在文件 dl_ui_button_base.h113 行定义.

◆ IsSelect()

bool dl::UI::Button::IsSelect ( )
inline

控件是选中状态

注解
仅 switch、radio有效

在文件 dl_ui_button_base.h118 行定义.

◆ OnTextSizeChange()

virtual void dl::UI::Button::OnTextSizeChange ( const Position & size)
inlineprotectedvirtual

在文件 dl_ui_button_base.h308 行定义.

◆ Render()

void dl::UI::Button::Render ( )

◆ RenderChild()

virtual void dl::UI::Button::RenderChild ( State state_pre,
State state )
protectedvirtual

◆ RenderDebug()

virtual void dl::UI::Button::RenderDebug ( )
protectedvirtual

◆ SetCustomRender()

void dl::UI::Button::SetCustomRender ( CbCustomRender cb)
inline

在文件 dl_ui_button_base.h217 行定义.

◆ SetDisable()

void dl::UI::Button::SetDisable ( bool disable)
inline

在文件 dl_ui_button_base.h124 行定义.

◆ SetEevntClick()

void dl::UI::Button::SetEevntClick ( CbEventClick cb)
inline

在文件 dl_ui_button_base.h221 行定义.

◆ SetElementData()

void dl::UI::Button::SetElementData ( const Align::Direction2 & hv,
const Position & pos = {} )
inline

在文件 dl_ui_button_base.h164 行定义.

◆ SetElementDataAutoSize()

void dl::UI::Button::SetElementDataAutoSize ( bool parent_w,
bool parent_h )
inline

在文件 dl_ui_button_base.h174 行定义.

◆ SetElementDataRunAble()

void dl::UI::Button::SetElementDataRunAble ( bool able)
inline

在文件 dl_ui_button_base.h170 行定义.

◆ SetMode()

void dl::UI::Button::SetMode ( Mode mode)

◆ SetName()

void dl::UI::Button::SetName ( std::string_view name)
inline

在文件 dl_ui_button_base.h212 行定义.

◆ SetOrder()

virtual void dl::UI::Button::SetOrder ( float order)
pure virtual

◆ SetSelect()

void dl::UI::Button::SetSelect ( bool open)

◆ SetSizeWithText()

void dl::UI::Button::SetSizeWithText ( bool with,
const Position & extra_size )

设置精灵大小跟随文本

◆ SetSound()

void dl::UI::Button::SetSound ( std::string_view click,
std::string_view over )
inline

设置按钮音效

参数
[in]click点击音效
[in]over经过音效
注解
默认为空字符串,为没有音效

在文件 dl_ui_button_base.h135 行定义.

◆ SetString()

void dl::UI::Button::SetString ( std::string_view str)

◆ SetTextAlign()

void dl::UI::Button::SetTextAlign ( const Align::Direction2 & hv)
inline

在文件 dl_ui_button_base.h203 行定义.

◆ Update()

void dl::UI::Button::Update ( )

◆ UpdateChild()

virtual void dl::UI::Button::UpdateChild ( State state_pre,
State state )
protectedvirtual

重载此函数,制定控件行为

注解
一般需要重载并调用

◆ UpdateTextOrder()

void dl::UI::Button::UpdateTextOrder ( float order)
inlineprotected

order变化时需要调用

在文件 dl_ui_button_base.h303 行定义.

类成员变量说明

◆ _coor

Coor* dl::UI::Button::_coor
protected

在文件 dl_ui_button_base.h258 行定义.


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