1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104 | /********************************************************************
*
* File: fsCNativeTextSprite.h
*
* Purpose: Cocos2d-x retained text sprite - needs to be added
* to a scene
*
*********************************************************************/
#ifndef fsCNativeTextSpriteehdr
#define fsCNativeTextSpriteehdr
#include <fsCore/fsBaseTypes.h>
#include <fsCore/fsStr.h>
#include <fsCore/fsSColour.h>
#include <fsCore/fsRect.h>
#include "fsINative.h"
#include <2d/Label.h>
#ifdef AXMOL_V3
#include <ui/RichText.h>
#else
#include <ui/UIRichText.h>
#endif
class fsIFont;
class fsRect;
class fsSColour;
class fsAffineMtx2d;
class fsStr;
class fsCNativeTextSprite : public fsINative
{
friend class fsCNativeTextSpriteRenderData;
public:
void outlineSet(const fsSColour4B& pOutline, fsF32 pSize) const;
void shadowSet(const fsSColour4B& pShadow, fsVec2d pOffset, fsF32 pBlurRadius) const;
void glowSet(const fsSColour4B& pGlow) const;
void alignmentSet(fsS32 pAlignH, fsS32 pAlignV);
void initialise(const fsStr& pText, fsIFont* pFont);
fsS32 stringWidthInPixelsGet() const;
void formattingRectSizeSet(const fsRect& pFormattingRect);
fsStr textGet() const;
void textSet(const fsStr& pText);
virtual ~fsCNativeTextSprite();<--- Destructor in derived class
protected:
void renderDo() override;
void matrixApplyDo(const fsAffineMtx2d& pRenderMatrix) override;
void colourSetDo(const fsSColour4B& pColour) override;
fsCNativeTextSprite();
private:
ax::Node* implGet() const override;
ax::Label* labelImplGet();
void textApply(const fsStr& pText, fsBool pForceRebuild);
void richTextRebuild();
void richTextFormattingRectApply();
ax::Label* mImpl;
ax::ui::RichText* mRichImpl;
fsBool mUseRichText;
ax::TTFConfig* mConfig;
ax::FontAtlas* mFontAtlas;
fsStr mLastText;
fsSColour4B mDefaultColour;
fsRect mFormattingRect;
fsBool mHasFormattingRect;
fsS32 mAlignH;
fsS32 mAlignV;
// outlineSet()/shadowSet()/glowSet() are const (no mImpl to apply to yet is a legitimate
// call before the Label exists - e.g. a label whose initial text is empty), so these need
// to be mutable to cache the values for labelImplGet() to replay once mImpl is created.
mutable fsBool mHasOutline;
mutable fsSColour4B mOutlineColour;
mutable fsF32 mOutlineSize;
mutable fsBool mHasShadow;
mutable fsSColour4B mShadowColour;
mutable fsVec2d mShadowOffset;
mutable fsF32 mShadowBlurRadius;
mutable fsBool mHasGlow;
mutable fsSColour4B mGlowColour;
ax::Mat4 mRenderMatrix;
};
#endif
|