Subversion Repository Public Repository

Divide-Framework

This repository has no backups
This repository's network speed is throttled to 100KB/sec

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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
/*
   Copyright (c) 2018 DIVIDE-Studio
   Copyright (c) 2009 Ionut Cava

   This file is part of DIVIDE Framework.

   Permission is hereby granted, free of charge, to any person obtaining a copy
   of this software
   and associated documentation files (the "Software"), to deal in the Software
   without restriction,
   including without limitation the rights to use, copy, modify, merge, publish,
   distribute, sublicense,
   and/or sell copies of the Software, and to permit persons to whom the
   Software is furnished to do so,
   subject to the following conditions:

   The above copyright notice and this permission notice shall be included in
   all copies or substantial portions of the Software.

   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   IMPLIED,
   INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
   PARTICULAR PURPOSE AND NONINFRINGEMENT.
   IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
   DAMAGES OR OTHER LIABILITY,
   WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
   IN CONNECTION WITH THE SOFTWARE
   OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

 */

#ifndef _UTILITY_TEXT_LABEL_H_
#define _UTILITY_TEXT_LABEL_H_

#include "Core/Math/Headers/MathMatrices.h"
#include "Core/Math/Headers/Dimension.h"
#include "Core/Headers/StringHelper.h"
#include "Core/Headers/Hashable.h"

namespace Divide {

namespace Font {
    const static char* DIVIDE_DEFAULT = "DroidSerif-Regular.ttf"; /*"Test.ttf"*/
    const static char* BATANG = "Batang.ttf";
    const static char* DEJA_VU = "DejaVuSans.ttf";
    const static char* DROID_SERIF = "DroidSerif-Regular.ttf";
    const static char* DROID_SERIF_ITALIC = "DroidSerif-Italic.ttf";
    const static char* DROID_SERIF_BOLD = "DroidSerif-Bold.ttf";
};

class TextLabelStyle : public Hashable {
  protected:
    typedef hashMapImpl<size_t, TextLabelStyle> TextLabelStyleMap;
    static TextLabelStyleMap s_textLabelStyleMap;
    static SharedLock s_textLableStyleMapMutex;
    static size_t s_defaultCacheValue;

    typedef hashMapImpl<size_t, stringImpl> FontNameHashMap;
    static FontNameHashMap s_fontNameMap;

  public:
    static const TextLabelStyle& get(size_t textLabelStyleHash);
    static const TextLabelStyle& get(size_t textLabelStyleHash, bool& styleFound);
    static const stringImpl& fontName(size_t fontNameHash);

  public:
   TextLabelStyle(const char* font,
                  const UColour& colour,
                  U8 fontSize);

    size_t getHash() const override;

    inline size_t font() const { return _font; }
    inline U8 fontSize() const { return _fontSize; }
    inline U8 width() const { return _width; }
    inline F32 blurAmount() const { return _blurAmount; }
    inline F32 spacing() const { return _spacing; }
    inline U32 alignFlag() const { return _alignFlag; }
    inline const UColour& colour() const { return _colour; }
    inline bool bold() const { return _bold; }
    inline bool italic() const { return _italic; }


    inline void font(size_t font) { _font = font; _dirty = true; }
    inline void fontSize(U8 fontSize) { _fontSize = fontSize; _dirty = true; }
    inline void width(U8 width) { _width = width; _dirty = true; }
    inline void blurAmount(F32 blurAmount) { _blurAmount = blurAmount; _dirty = true; }
    inline void spacing(F32 spacing) { _spacing = spacing; _dirty = true; }
    inline void alignFlag(U32 alignFlag) { _alignFlag = alignFlag; _dirty = true; }
    inline void colour(const UColour& colour) { _colour.set(colour); _dirty = true; }
    inline void bold(bool bold) { _bold = bold; _dirty = true; }
    inline void italic(bool italic) { _italic = italic; _dirty = true; }

 protected:
    size_t _font;
    U8 _fontSize;
    U8 _width;
    F32 _blurAmount;
    F32 _spacing;
    U32 _alignFlag;  ///< Check font-stash alignment for details
    UColour _colour;
    bool _bold;
    bool _italic;

 protected:
    mutable bool _dirty = true;
};

struct TextElement {
    TextElement(const TextLabelStyle& textLabelStyle,
                const RelativePosition2D& position)
        : TextElement(textLabelStyle.getHash(), position)
    {
    }

    TextElement(size_t textLabelStyleHash,
                const RelativePosition2D& position)
        : _textLabelStyleHash(textLabelStyleHash),
          _position(position)
    {
    }

    inline void text(const stringImpl& text) {
        Util::Split(text, '\n', _text);
    }

    inline const vectorImplFast<stringImpl>& text() const {
        return _text;
    }

    size_t _textLabelStyleHash;
    RelativePosition2D _position;

  private:
    vectorImplFast<stringImpl> _text;
};

struct TextElementBatch {
    typedef vectorImplFast<TextElement> BatchType;

    TextElementBatch()
    {
    }

    TextElementBatch(const TextElement& element)
        : _data {element}
    {
    }

    const BatchType& operator()() const {
        return _data;
    }

    BatchType _data;
};

};  // namespace Divide

#endif //_UTILITY_TEXT_LABEL_H_

Commits for Divide-Framework/trunk/Source Code/Utility/Headers/TextLabel.h

Diff revisions: vs.
Revision Author Commited Message
1029 Diff Diff IonutCava picture IonutCava Tue 30 Jan, 2018 17:28:39 +0000

[Ionut]
- Update copyright notices

1004 Diff Diff IonutCava picture IonutCava Wed 20 Dec, 2017 17:16:32 +0000

[Ionut]
- More GUI cleanup (added multiple GUIButton events)
- Typedef vec4<U8> and vec4<F32> to UColour and FColour respectively for easier to read code.

979 Diff Diff IonutCava picture IonutCava Tue 21 Nov, 2017 23:24:57 +0000

[Ionut]
- W.I.P. Rework GUI element positioning and scaling
- Update ImGUI and IMGUI_ADDONS

963 Diff Diff IonutCava picture IonutCava Sun 05 Nov, 2017 18:31:51 +0000

[Ionut]
- More multi-window fixes
- Profile guided performance improvements

955 Diff Diff IonutCava picture IonutCava Sun 29 Oct, 2017 20:45:04 +0000

[Ionut]
- Modify the CEGUI opengl renderer to interact with the state in GLWrapper better
- Performance optimizations

946 Diff Diff IonutCava picture IonutCava Sun 01 Oct, 2017 21:25:10 +0000

[Ionut]
- Attempt to fix text rendering / flashing issue (improved but not fixed yet)

927 Diff Diff IonutCava picture IonutCava Thu 10 Aug, 2017 21:55:10 +0000

[Ionut]
- Cleanup Text rendering and text related structs
- Add labels to DebugViews

836 Diff Diff IonutCava picture IonutCava Fri 27 Jan, 2017 14:59:56 +0000

[IonutCava]
- Update copyright notice

830 Diff Diff IonutCava picture IonutCava Wed 25 Jan, 2017 17:29:44 +0000

[IonutCava]
- Add a new Platform element: File
— Move all predefined paths to FileManagement System
- Split MathHelper into MathHelper and StringHelper

721 IonutCava picture IonutCava Wed 08 Jun, 2016 15:47:49 +0000

[IonutCava]
- Spelling: change all references from our code of “color” to the PROPER British version of “colour” because it sounds 100x better