Added Control::SetSubState handling
[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    * Apply the visuals of the style to the control pointed at by
63    * handle.
64    *
65    * @param[in] handle The handle to apply the visuals to
66    */
67   void ApplyVisuals( Handle handle ) const;
68
69   /**
70    * Apply the properties of the style to the control pointed at by
71    * handle.
72    *
73    * @param[in] handle The handle to apply the properties to
74    */
75   void ApplyProperties( Handle handle ) const;
76
77 protected:
78   /**
79    * @brief Default constructor.
80    */
81   Style();
82
83   /**
84    * @brief virtual destructor.
85    */
86   virtual ~Style();
87
88 private:
89   // Not implemented
90   DALI_INTERNAL Style( const Style& rhs );
91
92   // Not implemented
93   DALI_INTERNAL Style& operator=(const Style& rhs);
94
95 public:
96   // Everything must be shallow-copiable.
97   Dictionary<StylePtr> subStates; // Each named style maps to a state.
98   Dictionary<Property::Map> visuals;
99   Property::Map properties;
100   Property::Array transitions;
101   Toolkit::TransitionData entryTransition;
102   Toolkit::TransitionData exitTransition;
103 };
104
105 } // Internal
106 } // Toolkit
107 } // Dali
108
109
110 #endif //DALI_TOOLKIT_INTERNAL_BUILDER_STYLE_H