libRocket
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
FontEffect.h
Go to the documentation of this file.
1 /*
2  * This source file is part of libRocket, the HTML/CSS Interface Middleware
3  *
4  * For the latest information, see http://www.librocket.com
5  *
6  * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
7  *
8  * Permission is hereby granted, free of charge, to any person obtaining a copy
9  * of this software and associated documentation files (the "Software"), to deal
10  * in the Software without restriction, including without limitation the rights
11  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12  * copies of the Software, and to permit persons to whom the Software is
13  * furnished to do so, subject to the following conditions:
14  *
15  * The above copyright notice and this permission notice shall be included in
16  * all copies or substantial portions of the Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24  * THE SOFTWARE.
25  *
26  */
27 
28 #ifndef ROCKETCOREFONTEFFECT_H
29 #define ROCKETCOREFONTEFFECT_H
30 
31 #include "FontGlyph.h"
32 
33 namespace Rocket {
34 namespace Core {
35 
36 class FontEffectInstancer;
37 
43 {
44 public:
45  FontEffect();
46  virtual ~FontEffect();
47 
50  const String& GetName() const;
51 
55  virtual bool HasUniqueTexture() const;
56 
62  virtual bool GetGlyphMetrics(Vector2i& origin, Vector2i& dimensions, const FontGlyph& glyph) const;
63 
70  virtual void GenerateGlyphTexture(byte* destination_data, const Vector2i& destination_dimensions, int destination_stride, const FontGlyph& glyph) const;
71 
74  void SetColour(const Colourb& colour);
77  const Colourb& GetColour() const;
78 
82  void SetZIndex(float z_index);
85  float GetZIndex() const;
86 
89  void SetSpecificity(int specificity);
93  int GetSpecificity() const;
94 
97  const String& GetGenerationKey() const;
98 
99 protected:
101  virtual void OnReferenceDeactivate();
102 
103 private:
104  FontEffectInstancer* instancer;
105 
106  // The name of the effect.
107  String name;
108 
109  // The colour of the effect's geometry.
110  Colourb colour;
111 
112  // The z-index of this font effect, used to resolve render order when multiple font effects are rendered.
113  float z_index;
114  // The maximum specificity of the properties used to define the font effect.
115  int specificity;
116 
117  // A string identifying the properties that affected the generation of the effect's geometry and texture data.
118  String generation_key;
119 
120  friend class Factory;
121 };
122 
123 typedef std::vector< FontEffect* > FontEffectList;
124 typedef std::map< String, FontEffect* > FontEffectMap;
125 
126 }
127 }
128 
129 #endif
const String & GetGenerationKey() const
unsigned char byte
Definition: Types.h:50
void SetColour(const Colourb &colour)
const String & GetName() const
Definition: Clipboard.h:33
void SetSpecificity(int specificity)
std::vector< FontEffect * > FontEffectList
Definition: FontEffect.h:123
const Colourb & GetColour() const
int GetSpecificity() const
virtual void GenerateGlyphTexture(byte *destination_data, const Vector2i &destination_dimensions, int destination_stride, const FontGlyph &glyph) const
Definition: ReferenceCountable.h:41
virtual void OnReferenceDeactivate()
Releases the effect through its instancer.
Definition: FontEffectInstancer.h:50
virtual bool HasUniqueTexture() const
void SetZIndex(float z_index)
std::map< String, FontEffect * > FontEffectMap
Definition: FontEffect.h:124
Definition: FontEffect.h:42
virtual bool GetGlyphMetrics(Vector2i &origin, Vector2i &dimensions, const FontGlyph &glyph) const
Definition: Factory.h:63
Definition: FontGlyph.h:42
float GetZIndex() const