@@ -39,11 +39,11 @@ namespace ax
39
39
namespace ui
40
40
{
41
41
42
- static const int NORMAL_RENDERER_Z = (-2 );
43
- static const int PRESSED_RENDERER_Z = (-2 );
44
- static const int DISABLED_RENDERER_Z = (-2 );
45
- static const int TITLE_RENDERER_Z = (-1 );
46
- static const float ZOOM_ACTION_TIME_STEP = 0 .05f ;
42
+ constexpr int NORMAL_RENDERER_Z = (-2 );
43
+ constexpr int PRESSED_RENDERER_Z = (-2 );
44
+ constexpr int DISABLED_RENDERER_Z = (-2 );
45
+ constexpr int TITLE_RENDERER_Z = (-1 );
46
+ constexpr float ZOOM_ACTION_TIME_STEP = 0 .05f ;
47
47
48
48
IMPLEMENT_CLASS_GUI_INFO (Button)
49
49
@@ -68,18 +68,17 @@ Button::Button()
68
68
, _normalTextureAdaptDirty(true )
69
69
, _pressedTextureAdaptDirty(true )
70
70
, _disabledTextureAdaptDirty(true )
71
- , _normalFileName(" " )
72
- , _clickedFileName(" " )
73
- , _disabledFileName(" " )
74
71
, _normalTexType(TextureResType::LOCAL)
75
72
, _pressedTexType(TextureResType::LOCAL)
76
73
, _disabledTexType(TextureResType::LOCAL)
77
- , _fontName(" " )
78
74
{
79
75
setTouchEnabled (true );
80
76
}
81
77
82
- Button::~Button () {}
78
+ Button::~Button ()
79
+ {
80
+ AX_SAFE_RELEASE_NULL (_titleRenderer);
81
+ }
83
82
84
83
Button* Button::create ()
85
84
{
@@ -161,7 +160,10 @@ bool Button::createTitleRendererIfNull()
161
160
162
161
void Button::createTitleRenderer ()
163
162
{
163
+ AX_SAFE_RELEASE (_titleRenderer);
164
164
_titleRenderer = Label::create ();
165
+ AX_SAFE_RETAIN (_titleRenderer);
166
+
165
167
_titleRenderer->setAnchorPoint (Vec2::ANCHOR_MIDDLE);
166
168
addProtectedChild (_titleRenderer, TITLE_RENDERER_Z, -1 );
167
169
}
@@ -722,7 +724,7 @@ void Button::setTitleAlignment(TextHAlignment hAlignment, TextVAlignment vAlignm
722
724
723
725
void Button::setTitleText (std::string_view text)
724
726
{
725
- if (text. compare ( getTitleText ()) == 0 )
727
+ if (text == getTitleText () )
726
728
{
727
729
return ;
728
730
}
0 commit comments