1 /*---------------------------------------------------------------------------*
2   Project:  NintendoWare
3   File:     lyt_DrawInfo.h
4 
5   Copyright (C)2009-2011 Nintendo/HAL Laboratory, Inc.  All rights reserved.
6 
7   These coded instructions, statements, and computer programs contain proprietary
8   information of Nintendo and/or its licensed developers and are protected by
9   national and international copyright laws. They may not be disclosed to third
10   parties or copied or duplicated in any form, in whole or in part, without the
11   prior written consent of Nintendo.
12 
13   The content herein is highly confidential and should be handled accordingly.
14 
15   $Revision: 31311 $
16  *---------------------------------------------------------------------------*/
17 
18 #ifndef NW_LYT_DRAWINFO_H_
19 #define NW_LYT_DRAWINFO_H_
20 
21 #include <nw/math/math_Types.h>
22 #include <nw/font/font_WideTextWriter.h>
23 #include <nw/ut/ut_Rect.h>
24 
25 namespace nw
26 {
27 namespace lyt
28 {
29 
30 class GraphicsResource;
31 class Layout;
32 
33 //---------------------------------------------------------------------------
34 //! :category 描画
35 //!
36 //! @brief 描画情報クラスです。
37 //!
38 //! @details
39 //! 全体的な描画方法の制御や、描画中の情報の受け渡しに使用されます。
40 //!
41 //! 描画の前に SetGraphicsResource() により GraphicsResource を
42 //! 設定しておく必要があります。
43 //!
44 //! @sa Layout
45 //!
46 //! @since 2009/09/18 初版。
47 //---------------------------------------------------------------------------
48 class DrawInfo
49 {
50 public:
51     //----------------------------------------
52     //! @name コンストラクタ/デストラクタ
53     //@{
54 
55     //! @brief コンストラクタです。
56     //!
57     //! @since 2009/09/18 初版。
58     //!
59     DrawInfo();
60 
61     //! @brief デストラクタです。
62     //!
63     //! @since 2009/09/18 初版。
64     //!
65     virtual ~DrawInfo();
66 
67     //@}
68 
69     //----------------------------------------
70     //! @name 取得/設定
71     //@{
72 
73     //! @brief 現在のビュー行列を取得します。
74     //!
75     //! @return ビュー行列を返します。
76     //!
77     //! @sa SetViewMtx
78     //!
79     //! @since 2009/09/18 初版。
80     //!
GetViewMtx()81     const math::MTX34&  GetViewMtx() const
82     {
83         return m_ViewMtx;
84     }
85 
86     //! @brief ビュー行列を設定します。
87     //!
88     //! @param value ビュー行列です。
89     //!
90     //! @sa GetViewMtx
91     //!
92     //! @since 2009/09/18 初版。
93     //!
SetViewMtx(const math::MTX34 & value)94     void SetViewMtx(const math::MTX34& value)
95     {
96         m_ViewMtx = value;
97     }
98 
99     //! @brief 親のアルファ値の変化が子に影響するかどうかを判定します。
100     //!
101     //! @return 親のアルファ値の変化が子に影響する場合は true を返します。
102     //!
103     //! @sa SetInfluencedAlpha
104     //!
105     //! @since 2009/09/18 初版。
106     //!
IsInfluencedAlpha()107     bool IsInfluencedAlpha() const
108     {
109         return m_Flag.influencedAlpha;
110     }
111 
112     //! @brief 親のアルファ値の変化が子に影響するかどうかを設定します。
113     //!
114     //! @param bEnable 親のアルファ値の変化を子に影響させる場合には true を指定します。
115     //!
116     //! @sa IsInfluencedAlpha
117     //!
118     //! @since 2009/09/18 初版。
119     //!
SetInfluencedAlpha(bool bEnable)120     void SetInfluencedAlpha(bool bEnable)
121     {
122         m_Flag.influencedAlpha = bEnable;
123     }
124 
125     //! @brief 位置調整処理を行うかどうかの設定を取得します。
126     //!
127     //! @return 位置調整処理を行う場合は true を返します。
128     //!
129     //! @sa SetLocationAdjust
130     //!
131     //! @since 2009/09/18 初版。
132     //!
IsLocationAdjust()133     bool IsLocationAdjust() const
134     {
135         return m_Flag.locationAdjust;
136     }
137 
138     //! @brief 位置調整処理を行うかどうかを設定します。
139     //!
140     //! @param bEnable 位置調整処理を行う場合には true を指定します。
141     //!
142     //! @details
143     //! 位置調整処理を有効にした場合、Pane::IsLocationAdjust() が true を
144     //! を返すペインに位置調整処理のスケールが適用されます。
145     //!
146     //! 該当ペインの子孫ペインも位置調整処理のスケールの影響を受けます。
147     //!
148     //! @sa IsLocationAdjust
149     //! @sa SetLocationAdjustScale
150     //! @sa Pane::IsLocationAdjust
151     //!
152     //! @since 2009/09/18 初版。
153     //!
SetLocationAdjust(bool bEnable)154     void SetLocationAdjust(bool bEnable)
155     {
156         m_Flag.locationAdjust = bEnable;
157     }
158 
159     //! @brief 位置調整処理のスケールを取得します。
160     //!
161     //! @return 位置調整処理のスケールを返します。
162     //!
163     //! @sa SetLocationAdjustScale
164     //!
165     //! @since 2009/09/18 初版。
166     //!
GetLocationAdjustScale()167     const math::VEC2& GetLocationAdjustScale() const
168     {
169         return m_LocationAdjustScale;
170     }
171 
172     //! @brief 位置調整処理のスケールを設定します。
173     //!
174     //! @param scale スケールです。
175     //!
176     //! @sa GetLocationAdjustScale
177     //!
178     //! @since 2009/09/18 初版。
179     //!
SetLocationAdjustScale(const math::VEC2 & scale)180     void SetLocationAdjustScale(const math::VEC2& scale)
181     {
182         m_LocationAdjustScale = scale;
183     }
184 
185     //! @brief アルファ値を取得します。
186     //!
187     //! @return アルファ値を返します。
188     //!
189     //! @sa SetGlobalApha
190     //!
191     //! @since 2009/09/18 初版。
192     //!
GetGlobalAlpha()193     f32 GetGlobalAlpha() const
194     {
195         return m_GlobalAlpha;
196     }
197 
198     //! @brief アルファ値を設定します。
199     //!
200     //! @param alpha アルファ値です。
201     //!
202     //! @sa GetGlobalAlpha
203     //!
204     //! @since 2009/09/18 初版。
205     //!
SetGlobalAlpha(f32 alpha)206     void SetGlobalAlpha(f32 alpha)
207     {
208         m_GlobalAlpha = alpha;
209     }
210 
211     //! @brief 非表示のペインに対して行列計算を行うかどうかを判定します。
212     //!
213     //! @return 非表示のペインに対して行列計算を行う場合は true を返します。
214     //!
215     //! @sa SetInvisiblePaneCalculateMtx
216     //!
217     //! @since 2009/09/18 初版。
218     //!
IsInvisiblePaneCalculateMtx()219     bool IsInvisiblePaneCalculateMtx() const
220     {
221         return m_Flag.invisiblePaneCalculateMtx;
222     }
223 
224     //! @brief 非表示のペインに対して行列計算を行うかどうかを設定します。
225     //!
226     //! @param bEnable 非表示のペインに対して行列計算を行う場合には true を指定します。
227     //!
228     //! @details
229     //! bEnable に true を指定した場合、非表示のペインに対しても Pane::CalculateMtx() を
230     //! 呼び出して行列計算を行います。
231     //!
232     //! @sa IsInvisiblePaneCalculateMtx
233     //! @sa Pane::CalculateMtx
234     //! @sa Pane::IsVisible
235     //!
236     //! @since 2009/09/18 初版。
237     //!
SetInvisiblePaneCalculateMtx(bool bEnable)238     void SetInvisiblePaneCalculateMtx(bool bEnable)
239     {
240         m_Flag.invisiblePaneCalculateMtx = bEnable;
241     }
242 
243 #if ! defined(NW_RELEASE)
244     //! @brief デバッグモードか判定します。
245     //!
246     //! @details
247     //! この関数は %Final ビルドでは提供されません。
248     //!
249     //! @return デバッグモードなら true を返します。
250     //!
251     //! @sa SetDebugDrawMode
252     //!
253     //! @since 2009/09/18 初版。
254     //!
IsDebugDrawMode()255     bool IsDebugDrawMode() const
256     {
257         return m_Flag.debugDrawMode;
258     }
259 
260     //! @brief デバッグモードを設定します。
261     //!
262     //! @details
263     //! この関数は %Final ビルドでは提供されません。
264     //!
265     //! デバッグモードにすると Null, Bounding ペインの位置が表示されます。
266     //!
267     //! @param bEnable デバッグモードにする場合には true を指定します。
268     //!
269     //! @sa IsDebugDrawMode
270     //!
271     //! @since 2009/09/18 初版。
272     //!
SetDebugDrawMode(bool bEnable)273     void SetDebugDrawMode(bool bEnable)
274     {
275         m_Flag.debugDrawMode = bEnable;
276     }
277 #endif
278 
279     //! @brief %GraphicsResource オブジェクトを取得します。
280     //!
281     //! @return GraphicsResource オブジェクトへのポインタを返します。
282     //!
283     //! @sa SetGraphicsResource
284     //!
285     //! @since 2009/09/18 初版。
286     //!
GetGraphicsResource()287     GraphicsResource* GetGraphicsResource() const
288     {
289         return m_pGraphicsResource;
290     }
291 
292     //! @brief %GraphicsResource オブジェクトを設定します。
293     //!
294     //! @param pGraphicsResource GraphicsResource オブジェクトへのポインタです。
295     //!
296     //! @sa GetGraphicsResource
297     //!
298     //! @since 2009/09/18 初版。
299     //!
SetGraphicsResource(GraphicsResource * pGraphicsResource)300     void SetGraphicsResource(GraphicsResource* pGraphicsResource)
301     {
302         m_pGraphicsResource = pGraphicsResource;
303     }
304 
305     //! @brief 射影行列を設定します。
306     //!
307     //! @param mtx 射影行列です。
308     //!
309     //! @since 2009/09/18 初版。
310     //!
311     void SetProjectionMtx(const nw::math::MTX44& mtx);
312 
313     //@}
314 
315     //! :private
316     //! @brief 描画中のレイアウトを取得します。
317     //!
318     //! @details
319     //! Layout::Draw() の実行中に現在描画しているレイアウトを取得します。
320     //!
321     //! @return レイアウトへのポインタを返します。
322     //!
GetLayout()323     Layout* GetLayout() const
324     {
325         return m_pLayout;
326     }
327 
328     //! :private
329     //! @brief これから描画するレイアウトを設定します。
SetLayout(Layout * pLayout)330     void SetLayout(Layout* pLayout) const
331     {
332         m_pLayout = pLayout;
333     }
334 
335     //! :private
336     //! @brief 射影行列を取得します。
GetProjectionMtx()337     const nw::math::MTX44& GetProjectionMtx() const
338     {
339         return m_ProjMtx;
340     }
341 
342 protected:
343     //! @details :private
344     math::MTX44 m_ProjMtx;
345 
346     //! @details :private
347     math::MTX34 m_ViewMtx;
348 
349     //! @details :private
350     math::VEC2 m_LocationAdjustScale;
351 
352     //! @details :private
353     f32 m_GlobalAlpha;
354 
355     //! @details :private
356     GraphicsResource* m_pGraphicsResource;
357 
358     //! @details :private
359     mutable Layout* m_pLayout;
360 
361     //! :private
362     //! @brief フラグです。
363     struct Flag
364     {
365         u8 influencedAlpha : 1;
366         u8 locationAdjust : 1;
367         u8 invisiblePaneCalculateMtx : 1;
368 #if ! defined(NW_RELEASE)
369         u8 debugDrawMode : 1;
370 #endif
371     };
372 
373     //! @details :private
374     Flag m_Flag;
375 };
376 
377 } // namespace nw::lyt
378 } // namespace nw
379 
380 #endif // NW_LYT_DRAWINFO_H_
381 
382