|
1 /* |
|
2 * Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Image specification. Specifies an area on a (segmented) texture object. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef __HUIIMAGE_H__ |
|
21 #define __HUIIMAGE_H__ |
|
22 |
|
23 |
|
24 #include <e32base.h> |
|
25 #include <uiacceltk/HuiTimedPoint.h> |
|
26 #include <uiacceltk/HuiTextureHandle.h> |
|
27 #include <uiacceltk/HuiTexture.h> |
|
28 |
|
29 |
|
30 /** |
|
31 * Image specification. Specifies an area on a texture object. |
|
32 * |
|
33 * The texture to with THuiImage refers is expected to the implement |
|
34 * the MHuiSegmentedTexture interface. |
|
35 */ |
|
36 NONSHARABLE_CLASS(THuiImage) |
|
37 { |
|
38 public: |
|
39 |
|
40 /* Constructors. */ |
|
41 |
|
42 /** @beginAPI */ |
|
43 |
|
44 /** |
|
45 * Default constructor, creates an empty THuiImage. |
|
46 * @see SetTexture() |
|
47 * @see SetTexCoords() |
|
48 */ |
|
49 IMPORT_C THuiImage(); |
|
50 |
|
51 /** |
|
52 * Constructor. Textures coordinates will be normalized to match the |
|
53 * size of the texture, so that (1,1) is always the lower right corner. |
|
54 * Note that the THuiImage instance stores a pointer to aTexture. |
|
55 * aTexture must continue to exist for the entire lifetime of the |
|
56 * THuiImage instance. For example, passing a temporary THuiTextureHandle |
|
57 * instance will result in a crash when the image's texture is accessed. |
|
58 * |
|
59 * @param aTexture Texture being drawn. |
|
60 * The texture is expected to the implement the |
|
61 * MHuiSegmentedTexture interface. |
|
62 * @param aTlX Top left X coordinate (normalized). |
|
63 * @param aTlY Top left Y coordinate (normalized). |
|
64 * @param aBrX Bottom right X coordinate (normalized). |
|
65 * @param aBrY Bottom right Y coordinate (normalized). |
|
66 */ |
|
67 IMPORT_C THuiImage(const MHuiTexture& aTexture, |
|
68 TReal32 aTlX = 0.f, TReal32 aTlY = 0.f, |
|
69 TReal32 aBrX = 1.f, TReal32 aBrY = 1.f) __SOFTFP; |
|
70 |
|
71 |
|
72 /** |
|
73 * Constructor. Textures coordinates will be normalized to match the |
|
74 * size of the texture, so that (1,1) is always the lower right corner. |
|
75 * Note that the THuiImage instance stores a pointer to aTexture. |
|
76 * aTexture must continue to exist for the entire lifetime of the |
|
77 * THuiImage instance. For example, passing a temporary THuiTextureHandle |
|
78 * instance will result in a crash when the image's texture is accessed. |
|
79 * |
|
80 * @param aTexture Texture being drawn. |
|
81 * The texture is expected to be derived from CHuiTexture. |
|
82 * @param aTlX Top left X coordinate (normalized). |
|
83 * @param aTlY Top left Y coordinate (normalized). |
|
84 * @param aBrX Bottom right X coordinate (normalized). |
|
85 * @param aBrY Bottom right Y coordinate (normalized). |
|
86 */ |
|
87 IMPORT_C THuiImage(const CHuiTexture& aTexture, |
|
88 TReal32 aTlX = 0.f, TReal32 aTlY = 0.f, |
|
89 TReal32 aBrX = 1.f, TReal32 aBrY = 1.f) __SOFTFP; |
|
90 |
|
91 |
|
92 /** |
|
93 * Returns the number of segments in this image. |
|
94 */ |
|
95 IMPORT_C TInt SegmentCount() const; |
|
96 |
|
97 /** |
|
98 * Calculate vertex coordinates for an image segment. |
|
99 * |
|
100 * @param aOutTexCoords The texture coordinates for a quad are output to |
|
101 * this array, two coordinates (x,y) per corner point. |
|
102 * Must have room for at least 8 TInt16s. |
|
103 * @param aSegment Image segment number to return the coordinates for. |
|
104 * |
|
105 * @see SegmentCount() to return the number of image segments in this image. |
|
106 */ |
|
107 IMPORT_C void GetVertexCoords(TInt16* aOutCoords, TInt aSegment = 0) const; |
|
108 |
|
109 /** |
|
110 * Calculate actual texture coordinates for image segment. |
|
111 * |
|
112 * @param aOutTexCoords The texture coordinates for a quad are output to |
|
113 * this array, two coordinates (u,v) per corner point. |
|
114 * Must have room for at least 8 TReal32s. |
|
115 * @param aSegment Image segment number to return the coordinates for. |
|
116 * |
|
117 * @see SegmentCount() to return the number of image segments in thiss image. |
|
118 */ |
|
119 IMPORT_C void GetTexCoords(TReal32* aOutTexCoords, TInt aSegment = 0) const; |
|
120 |
|
121 /** |
|
122 * Sets the texture coordinates for the whole image. |
|
123 * Raw coords flag is cleared. |
|
124 */ |
|
125 IMPORT_C void SetTexCoords(TReal32 aTlX = 0.f, TReal32 aTlY = 0.f, |
|
126 TReal32 aBrX = 1.f, TReal32 aBrY = 1.f, |
|
127 TInt aTransitionTime = 0) __SOFTFP; |
|
128 |
|
129 /** |
|
130 * Determines the current texture coordinates of the top-left corner of |
|
131 * this image. |
|
132 */ |
|
133 IMPORT_C THuiRealPoint TopLeft() const __SOFTFP; |
|
134 |
|
135 /** |
|
136 * Determines the current texture coordinates of the bottom-right corner of |
|
137 * this image. |
|
138 */ |
|
139 IMPORT_C THuiRealPoint BottomRight() const __SOFTFP; |
|
140 |
|
141 /** |
|
142 * Determines if a texture has been specified for the image. |
|
143 */ |
|
144 IMPORT_C TBool HasTexture() const; |
|
145 |
|
146 /** |
|
147 * Sets the texture of the image. |
|
148 * |
|
149 * The texture is expected to the implement the MHuiSegmentedTexture interface. |
|
150 */ |
|
151 IMPORT_C void SetTexture(const MHuiTexture& aTexture); |
|
152 |
|
153 /** |
|
154 * Sets the texture of the image. |
|
155 * |
|
156 * The texture is expected to be derived from CHuiTexture. |
|
157 */ |
|
158 IMPORT_C void SetTexture(const CHuiTexture& aTexture); |
|
159 |
|
160 /** |
|
161 * Returns the texture object associated with the image. |
|
162 */ |
|
163 IMPORT_C const MHuiSegmentedTexture& Texture() const; |
|
164 |
|
165 /** |
|
166 * Returns the interface of the texture object associated with the image. |
|
167 * |
|
168 * @return Reference to MHuiTexture. This interface can be queried for |
|
169 * the implemented texture interfaces. |
|
170 */ |
|
171 IMPORT_C const MHuiTexture& TextureIf() const; |
|
172 |
|
173 /** |
|
174 * Determines if the texture has a shadow. |
|
175 */ |
|
176 IMPORT_C TBool HasShadow() const; |
|
177 |
|
178 /** |
|
179 * Returns the shadow texture object associated with the image. |
|
180 * |
|
181 * @return NULL, if no shadow available. |
|
182 */ |
|
183 IMPORT_C THuiTextureHandle ShadowTexture() const; |
|
184 |
|
185 /** |
|
186 * Apply an offset to the texture coordinates. |
|
187 */ |
|
188 IMPORT_C void Translate(TReal32 aDx, TReal32 aDy, TInt aTransitionTime = 0) __SOFTFP; |
|
189 |
|
190 /** |
|
191 * Apply a scaling factor to the texture coordinates. |
|
192 */ |
|
193 IMPORT_C void Scale(TReal32 aScaleX, TReal32 aScaleY, TInt aTransitionTime = 0) __SOFTFP; |
|
194 |
|
195 /** |
|
196 * Returns true if the image has changed since the last change |
|
197 * notification. Changed means that the image is dirtied, and must |
|
198 * be redrawn. |
|
199 */ |
|
200 |
|
201 IMPORT_C TBool Changed() const; |
|
202 |
|
203 /** |
|
204 * Clears the changed status of the visual. |
|
205 */ |
|
206 |
|
207 IMPORT_C void ClearChanged(); |
|
208 |
|
209 /** @endAPI */ |
|
210 |
|
211 /** |
|
212 * Returns pointer to the texture object associated with the image. |
|
213 * |
|
214 * @return Pointer to MHuiTexture object. May return NULL if no texture is |
|
215 * associated with the image. |
|
216 */ |
|
217 const MHuiTexture* ImageTexture() const; |
|
218 |
|
219 /** |
|
220 * Returns pointer to the texture object associated with the image. |
|
221 * |
|
222 * @return Pointer to CHuiTexture object. May return NULL if no texture is |
|
223 * associated with the image or if the texture type is not derived from CHuiTexture. |
|
224 */ |
|
225 const CHuiTexture* ImageDefaultTexture() const; |
|
226 |
|
227 private: |
|
228 |
|
229 /** Texture containing the image data. */ |
|
230 const MHuiTexture* iTexture; |
|
231 |
|
232 /** Texture coordinates of the top left corner, for the whole image. */ |
|
233 THuiTimedPoint iTl; |
|
234 |
|
235 /** Texture coordinates of the bottom right corner, for the whole image. */ |
|
236 THuiTimedPoint iBr; |
|
237 |
|
238 /** Flags for internal use */ |
|
239 TInt iFlags; |
|
240 |
|
241 TInt iSpare2; |
|
242 }; |
|
243 |
|
244 #endif // __HUIIMAGE_H__ |