axmol/tests/cpp-tests/Classes/LabelTest/LabelTest.h

452 lines
9.4 KiB
C
Raw Normal View History

2010-09-07 11:47:54 +08:00
#ifndef _ATLAS_TEST_H_
#define _ATLAS_TEST_H_
#include "../testBasic.h"
#include "../BaseTest.h"
2010-09-07 11:47:54 +08:00
2014-03-31 17:31:04 +08:00
#if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1)))
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#elif _MSC_VER >= 1400 //vs 2005 or higher
#pragma warning (push)
#pragma warning (disable: 4996)
#endif
2013-07-12 05:41:03 +08:00
class AtlasDemo : public BaseTest
2010-09-07 11:47:54 +08:00
{
protected:
2010-09-07 11:47:54 +08:00
public:
2013-11-14 09:36:33 +08:00
CREATE_FUNC(AtlasDemo);
AtlasDemo(void);
~AtlasDemo(void);
virtual std::string title() const override;
virtual std::string subtitle() const override;
virtual void onEnter() override;
void restartCallback(Ref* sender);
void nextCallback(Ref* sender);
void backCallback(Ref* sender);
2010-09-07 11:47:54 +08:00
};
class Atlas1 : public AtlasDemo
{
TextureAtlas* _textureAtlas;
public:
2013-11-14 09:36:33 +08:00
CREATE_FUNC(Atlas1);
Atlas1();
~Atlas1();
virtual std::string title() const override;
virtual std::string subtitle() const override;
virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
2013-12-25 14:52:49 +08:00
protected:
void onDraw(const Mat4 &transform, uint32_t flags);
protected:
CustomCommand _customCommand;
2010-09-07 11:47:54 +08:00
};
class LabelAtlasTest : public AtlasDemo
{
float _time;
public:
2013-11-14 09:36:33 +08:00
CREATE_FUNC(LabelAtlasTest);
LabelAtlasTest();
2010-09-07 11:47:54 +08:00
2012-06-08 13:55:28 +08:00
virtual void step(float dt);
2010-09-07 11:47:54 +08:00
virtual std::string title() const override;
virtual std::string subtitle() const override;
2010-09-07 11:47:54 +08:00
};
class LabelAtlasColorTest : public AtlasDemo
{
float _time;
public:
2013-11-14 09:36:33 +08:00
CREATE_FUNC(LabelAtlasColorTest);
LabelAtlasColorTest();
2012-06-08 13:55:28 +08:00
virtual void step(float dt);
virtual std::string title() const override;
virtual std::string subtitle() const override;
2013-02-28 15:57:15 +08:00
void actionFinishCallback();
};
2010-09-07 11:47:54 +08:00
class LabelTTFAlignment : public AtlasDemo
{
public:
2013-11-14 09:36:33 +08:00
CREATE_FUNC(LabelTTFAlignment);
LabelTTFAlignment();
virtual std::string title() const override;
virtual std::string subtitle() const override;
};
2010-09-07 11:47:54 +08:00
class Atlas3 : public AtlasDemo
{
float _time;
public:
2013-11-14 09:36:33 +08:00
CREATE_FUNC(Atlas3);
Atlas3();
2010-09-07 11:47:54 +08:00
2012-06-08 13:55:28 +08:00
virtual void step(float dt);
2010-09-07 11:47:54 +08:00
virtual std::string title() const override;
virtual std::string subtitle() const override;
2010-09-07 11:47:54 +08:00
};
class Atlas4 : public AtlasDemo
{
float _time;
public:
2013-11-14 09:36:33 +08:00
CREATE_FUNC(Atlas4);
Atlas4();
2012-06-08 13:55:28 +08:00
virtual void step(float dt);
2010-09-07 11:47:54 +08:00
virtual std::string title() const override;
virtual std::string subtitle() const override;
2010-09-07 11:47:54 +08:00
};
class Atlas5 : public AtlasDemo
{
public:
2013-11-14 09:36:33 +08:00
CREATE_FUNC(Atlas5);
Atlas5();
virtual std::string title() const override;
virtual std::string subtitle() const override;
2010-09-07 11:47:54 +08:00
};
class Atlas6 : public AtlasDemo
{
public:
2013-11-14 09:36:33 +08:00
CREATE_FUNC(Atlas6);
Atlas6();
virtual std::string title() const override;
virtual std::string subtitle() const override;
2010-09-07 11:47:54 +08:00
};
class AtlasBitmapColor : public AtlasDemo
2010-09-07 11:47:54 +08:00
{
public:
2013-11-14 09:36:33 +08:00
CREATE_FUNC(AtlasBitmapColor);
AtlasBitmapColor();
virtual std::string title() const override;
2010-09-07 11:47:54 +08:00
virtual std::string subtitle() const override;
2010-09-07 11:47:54 +08:00
};
class AtlasFastBitmap : public AtlasDemo
{
public:
2013-11-14 09:36:33 +08:00
CREATE_FUNC(AtlasFastBitmap);
AtlasFastBitmap();
virtual std::string title() const override;
virtual std::string subtitle() const override;
2010-09-07 11:47:54 +08:00
};
2011-02-23 16:47:25 +08:00
class BitmapFontMultiLine : public AtlasDemo
{
public:
2013-11-14 09:36:33 +08:00
CREATE_FUNC(BitmapFontMultiLine);
2011-02-23 16:47:25 +08:00
BitmapFontMultiLine();
virtual std::string title() const override;
virtual std::string subtitle() const override;
2011-02-23 16:47:25 +08:00
};
class LabelsEmpty : public AtlasDemo
{
public:
2013-11-14 09:36:33 +08:00
CREATE_FUNC(LabelsEmpty);
2011-02-23 16:47:25 +08:00
LabelsEmpty();
2012-06-08 13:55:28 +08:00
void updateStrings(float dt);
virtual std::string title() const override;
virtual std::string subtitle() const override;
2011-02-23 16:47:25 +08:00
private:
bool setEmpty;
};
class LabelBMFontHD : public AtlasDemo
{
public:
2013-11-14 09:36:33 +08:00
CREATE_FUNC(LabelBMFontHD);
2011-02-23 16:47:25 +08:00
LabelBMFontHD();
virtual std::string title() const override;
virtual std::string subtitle() const override;
2011-02-23 16:47:25 +08:00
};
class LabelAtlasHD : public AtlasDemo
{
public:
2013-11-14 09:36:33 +08:00
CREATE_FUNC(LabelAtlasHD);
2011-02-23 16:47:25 +08:00
LabelAtlasHD();
virtual std::string title() const override;
virtual std::string subtitle() const override;
2011-02-23 16:47:25 +08:00
};
class LabelGlyphDesigner : public AtlasDemo
{
public:
2013-11-14 09:36:33 +08:00
CREATE_FUNC(LabelGlyphDesigner);
2011-02-23 16:47:25 +08:00
LabelGlyphDesigner();
virtual std::string title() const override;
virtual std::string subtitle() const override;
2011-02-23 16:47:25 +08:00
};
2010-09-07 11:47:54 +08:00
class AtlasTestScene : public TestScene
{
public:
2013-11-14 09:36:33 +08:00
CREATE_FUNC(AtlasTestScene);
2010-09-07 11:47:54 +08:00
virtual void runThisTest();
};
2011-07-06 14:56:05 +08:00
class LabelTTFTest : public AtlasDemo
{
public:
2013-11-14 09:36:33 +08:00
CREATE_FUNC(LabelTTFTest);
LabelTTFTest();
virtual ~LabelTTFTest();
virtual std::string title() const override;
virtual std::string subtitle() const override;
private:
void setAlignmentLeft(Ref* sender);
void setAlignmentCenter(Ref* sender);
void setAlignmentRight(Ref* sender);
void setAlignmentTop(Ref* sender);
void setAlignmentMiddle(Ref* sender);
void setAlignmentBottom(Ref* sender);
2012-11-20 18:17:47 +08:00
void updateAlignment();
const char* getCurrentAlignment();
private:
TextHAlignment _horizAlign;
2014-03-31 17:31:04 +08:00
LabelTTF* _label;
TextVAlignment _vertAlign;
2011-07-06 14:56:05 +08:00
};
class LabelTTFMultiline : public AtlasDemo
{
public:
2013-11-14 09:36:33 +08:00
CREATE_FUNC(LabelTTFMultiline);
LabelTTFMultiline();
virtual std::string title() const override;
virtual std::string subtitle() const override;
2011-07-06 14:56:05 +08:00
};
class LabelTTFChinese : public AtlasDemo
{
public:
2013-11-14 09:36:33 +08:00
CREATE_FUNC(LabelTTFChinese);
LabelTTFChinese();
virtual std::string title() const override;
};
class LabelBMFontChinese : public AtlasDemo
{
public:
2013-11-14 09:36:33 +08:00
CREATE_FUNC(LabelBMFontChinese);
LabelBMFontChinese();
virtual std::string title() const override;
};
2012-03-22 09:40:32 +08:00
class BitmapFontMultiLineAlignment : public AtlasDemo
{
public:
2013-11-14 09:36:33 +08:00
CREATE_FUNC(BitmapFontMultiLineAlignment);
BitmapFontMultiLineAlignment();
~BitmapFontMultiLineAlignment();
2012-03-22 09:40:32 +08:00
void snapArrowsToEdge();
virtual std::string title() const override;
virtual std::string subtitle() const override;
void stringChanged(Ref *sender);
void alignmentChanged(Ref *sender);
void onTouchesBegan(const std::vector<Touch*>& touches, Event *event);
void onTouchesEnded(const std::vector<Touch*>& touches, Event *event);
void onTouchesMoved(const std::vector<Touch*>& touches, Event *event);
2012-03-22 09:40:32 +08:00
public:
2014-03-31 17:31:04 +08:00
LabelBMFont *_labelShouldRetain;
Sprite *_arrowsBarShouldRetain;
Sprite *_arrowsShouldRetain;
MenuItemFont *_lastSentenceItem, *_lastAlignmentItem;
bool _drag;
2012-03-22 09:40:32 +08:00
};
2014-10-20 14:58:15 +08:00
class LabelTTFOpacityTest : public AtlasDemo
2012-03-22 11:48:37 +08:00
{
public:
2014-10-20 14:58:15 +08:00
CREATE_FUNC(LabelTTFOpacityTest);
2013-11-14 09:36:33 +08:00
2014-10-20 14:58:15 +08:00
LabelTTFOpacityTest();
2012-03-22 11:48:37 +08:00
virtual std::string title() const override;
virtual std::string subtitle() const override;
2012-03-22 11:48:37 +08:00
};
class BMFontOneAtlas : public AtlasDemo
{
public:
2013-11-14 09:36:33 +08:00
CREATE_FUNC(BMFontOneAtlas);
BMFontOneAtlas();
2012-03-22 11:48:37 +08:00
virtual std::string title() const override;
virtual std::string subtitle() const override;
2012-03-22 11:48:37 +08:00
};
class BMFontUnicode : public AtlasDemo
{
public:
2013-11-14 09:36:33 +08:00
CREATE_FUNC(BMFontUnicode);
BMFontUnicode();
2012-03-22 11:48:37 +08:00
virtual std::string title() const override;
virtual std::string subtitle() const override;
2012-03-22 11:48:37 +08:00
};
class BMFontInit : public AtlasDemo
{
public:
2013-11-14 09:36:33 +08:00
CREATE_FUNC(BMFontInit);
BMFontInit();
virtual std::string title() const override;
virtual std::string subtitle() const override;
};
class TTFFontInit : public AtlasDemo
{
public:
2013-11-14 09:36:33 +08:00
CREATE_FUNC(TTFFontInit);
TTFFontInit();
virtual std::string title() const override;
virtual std::string subtitle() const override;
};
2013-04-26 09:22:26 +08:00
class TTFFontShadowAndStroke : public AtlasDemo
{
public:
2013-11-14 09:36:33 +08:00
CREATE_FUNC(TTFFontShadowAndStroke);
2013-04-26 09:22:26 +08:00
TTFFontShadowAndStroke();
virtual std::string title() const override;
virtual std::string subtitle() const override;
2013-04-26 09:22:26 +08:00
};
class Issue1343 : public AtlasDemo
{
public:
2013-11-14 09:36:33 +08:00
CREATE_FUNC(Issue1343);
Issue1343();
virtual std::string title() const override;
virtual std::string subtitle() const override;
};
2012-11-20 18:17:47 +08:00
class LabelBMFontBounds : public AtlasDemo
{
public:
2013-11-14 09:36:33 +08:00
CREATE_FUNC(LabelBMFontBounds);
2012-11-20 18:17:47 +08:00
LabelBMFontBounds();
virtual std::string title() const override;
virtual std::string subtitle() const override;
2012-11-20 18:17:47 +08:00
};
class NewLabelTTFUnicode : public AtlasDemo
2013-07-25 08:21:51 +08:00
{
public:
2013-11-14 09:36:33 +08:00
CREATE_FUNC(NewLabelTTFUnicode);
NewLabelTTFUnicode();
virtual std::string title() const override;
virtual std::string subtitle() const override;
2013-07-25 08:21:51 +08:00
};
class NewLabelBMFontTest : public AtlasDemo
{
public:
2013-11-14 09:36:33 +08:00
CREATE_FUNC(NewLabelBMFontTest);
NewLabelBMFontTest();
virtual std::string title() const override;
virtual std::string subtitle() const override;
private:
};
class NewLabelFontDefTest : public AtlasDemo
{
public:
2013-11-14 09:36:33 +08:00
CREATE_FUNC(NewLabelFontDefTest);
NewLabelFontDefTest();
virtual std::string title() const override;
virtual std::string subtitle() const override;
private:
};
class LabelBMFontCrashTest : public AtlasDemo
{
public:
2013-11-14 09:36:33 +08:00
CREATE_FUNC(LabelBMFontCrashTest);
virtual void onEnter() override;
virtual std::string title() const override;
virtual std::string subtitle() const override;
};
2013-07-12 05:41:03 +08:00
class LabelBMFontBinaryFormat : public AtlasDemo
{
public:
CREATE_FUNC(LabelBMFontBinaryFormat);
LabelBMFontBinaryFormat();
virtual std::string title() const override;
virtual std::string subtitle() const override;
};
2014-03-31 17:31:04 +08:00
#if defined(__GNUC__) && ((__GNUC__ >= 4) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 1)))
#pragma GCC diagnostic warning "-Wdeprecated-declarations"
#elif _MSC_VER >= 1400 //vs 2005 or higher
#pragma warning (pop)
#endif
2013-07-12 05:41:03 +08:00
2011-07-06 14:56:05 +08:00
// we don't support linebreak mode
2010-09-07 11:47:54 +08:00
#endif