1 /** @file finalepagewidget.h  InFine animation system, FinalePageWidget.
2  *
3  * @authors Copyright © 2003-2017 Jaakko Keränen <jaakko.keranen@iki.fi>
4  * @authors Copyright © 2005-2014 Daniel Swanson <danij@dengine.net>
5  *
6  * @par License
7  * GPL: http://www.gnu.org/licenses/gpl.html
8  *
9  * <small>This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by the
11  * Free Software Foundation; either version 2 of the License, or (at your
12  * option) any later version. This program is distributed in the hope that it
13  * will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
14  * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
15  * Public License for more details. You should have received a copy of the GNU
16  * General Public License along with this program; if not, write to the Free
17  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18  * 02110-1301 USA</small>
19  */
20 
21 #ifndef DENG_UI_INFINE_FINALEPAGEWIDGET_H
22 #define DENG_UI_INFINE_FINALEPAGEWIDGET_H
23 
24 #include <QList>
25 #include <de/Error>
26 #include "finalewidget.h"
27 
28 namespace world { class Material; }
29 
30 /**
31  * Finale page widget (layer).
32  *
33  * @ingroup infine
34  */
35 class FinalePageWidget
36 {
37 public:
38     /// An invalid color index was specified. @ingroup errors
39     DENG2_ERROR(InvalidColorError);
40 
41     /// An invalid font index was specified. @ingroup errors
42     DENG2_ERROR(InvalidFontError);
43 
44     typedef QList<FinaleWidget *> Children;
45 
46 public:
47     FinalePageWidget();
48     virtual ~FinalePageWidget();
49 
50 #ifdef __CLIENT__
51     virtual void draw() const;
52 #endif
53     virtual void runTicks(timespan_t timeDelta);
54 
55     void makeVisible(bool yes = true);
56     void pause(bool yes = true);
57 
58     /**
59      * Returns @c true if @a widget is present on the page.
60      */
61     bool hasWidget(FinaleWidget *widget);
62 
63     /**
64      * Add a child widget to the page, transferring ownership. If the widget is
65      * already contained by the page then nothing happens.
66      *
67      * @param widgetToAdd  Widget to be added.
68      *
69      * @return  Same as @a widgetToAdd, for convenience.
70      */
71     FinaleWidget *addChild(FinaleWidget *widgetToAdd);
72 
73     /**
74      * Remove a child widget from the page, transferring ownership to the caller
75      * if owned by the page.
76      *
77      * @param widgetToRemove  Widget to be removed.
78      *
79      * @return  Same as @a widgetToRemove, for convenience.
80      */
81     FinaleWidget *removeChild(FinaleWidget *widgetToRemove);
82 
83     /**
84      * Provides a list of all child widgets of the page, in addition order.
85      */
86     Children const &children() const;
87 
88     FinalePageWidget &setOffset(de::Vector3f const &newOffset, int steps = 0);
89     FinalePageWidget &setOffsetX(float newOffsetX, int steps = 0);
90     FinalePageWidget &setOffsetY(float newOffsetY, int steps = 0);
91     FinalePageWidget &setOffsetZ(float newOffsetZ, int steps = 0);
92 
93     /// Current background Material.
94     world::Material *backgroundMaterial() const;
95 
96     /// Sets the background Material.
97     FinalePageWidget &setBackgroundMaterial(world::Material *newMaterial);
98 
99     /// Sets the background top color.
100     FinalePageWidget &setBackgroundTopColor(de::Vector3f const &newColor, int steps = 0);
101 
102     /// Sets the background top color and alpha.
103     FinalePageWidget &setBackgroundTopColorAndAlpha(de::Vector4f const &newColorAndAlpha, int steps = 0);
104 
105     /// Sets the background bottom color.
106     FinalePageWidget &setBackgroundBottomColor(de::Vector3f const &newColor, int steps = 0);
107 
108     /// Sets the background bottom color and alpha.
109     FinalePageWidget &setBackgroundBottomColorAndAlpha(de::Vector4f const &newColorAndAlpha, int steps = 0);
110 
111     /// Sets the filter color and alpha.
112     FinalePageWidget &setFilterColorAndAlpha(de::Vector4f const &newColorAndAlpha, int steps = 0);
113 
114     /// @return  Animator which represents the identified predefined color.
115     animatorvector3_t const *predefinedColor(uint idx);
116 
117     /// Sets a predefined color.
118     FinalePageWidget &setPredefinedColor(uint idx, de::Vector3f const &newColor, int steps = 0);
119 
120     /// @return  Unique identifier of the predefined font.
121     fontid_t predefinedFont(uint idx);
122 
123     /// Sets a predefined font.
124     FinalePageWidget &setPredefinedFont(uint idx, fontid_t font);
125 
126 private:
127     DENG2_PRIVATE(d)
128 };
129 
130 #endif // DENG_UI_INFINE_FINALEPAGEWIDGET_H
131