2fb4e8367a33f25098d0ed4766b8ad692c6df9fc
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / builder / style.h
1 #ifndef DALI_TOOLKIT_INTERNAL_BUILDER_STYLE_H
2 #define DALI_TOOLKIT_INTERNAL_BUILDER_STYLE_H
3
4 /*
5  * Copyright (c) 2017 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19
20 #include <dali/public-api/object/ref-object.h>
21 #include <dali-toolkit/devel-api/visual-factory/transition-data.h>
22 #include <dali-toolkit/internal/builder/dictionary.h>
23
24 namespace Dali
25 {
26 namespace Toolkit
27 {
28 namespace Internal
29 {
30
31 class Style;
32 typedef IntrusivePtr<Style> StylePtr;
33
34 /**
35  * This class encapsulates the style information for a given styled
36  * control.  It is generated only when a control instance looks up
37  * it's style information for the first time, and then stored by
38  * Builder.
39  *
40  * It contains the visual, property and transition definitions for the
41  * main control and for each state and sub-state within the control.
42  *
43  * It has methods to enable the base control to apply visuals and
44  * properties per state.
45  */
46 class Style : public RefObject
47 {
48 public:
49   static StylePtr New();
50
51 public:
52   /**
53    * Apply the visuals and properties for the current state/substate
54    * of the handle to the control pointed at by handle. Recurses
55    * through sub-states.
56    *
57    * @param[in] handle The handle to apply the visuals to
58    */
59   void ApplyVisualsAndPropertiesRecursively( Handle handle ) const;
60
61
62 private:
63   /**
64    * Apply the visuals of the style to the control pointed at by
65    * handle.
66    *
67    * @param[in] handle The handle to apply the visuals to
68    */
69   void ApplyVisuals( Handle handle ) const;
70
71   /**
72    * Apply the properties of the style to the control pointed at by
73    * handle.
74    *
75    * @param[in] handle The handle to apply the properties to
76    */
77   void ApplyProperties( Handle handle ) const;
78
79 protected:
80   /**
81    * @brief Default constructor.
82    */
83   Style();
84
85   /**
86    * @brief virtual destructor.
87    */
88   virtual ~Style();
89
90 private:
91   // Not implemented
92   DALI_INTERNAL Style( const Style& rhs );
93
94   // Not implemented
95   DALI_INTERNAL Style& operator=(const Style& rhs);
96
97 public:
98   // Everything must be shallow-copiable.
99   Dictionary<StylePtr> subStates; // Each named style maps to a state.
100   Dictionary<Property::Map> visuals;
101   Property::Map properties;
102   Property::Array transitions;
103   Toolkit::TransitionData entryTransition;
104   Toolkit::TransitionData exitTransition;
105 };
106
107 } // Internal
108 } // Toolkit
109 } // Dali
110
111
112 #endif //DALI_TOOLKIT_INTERNAL_BUILDER_STYLE_H