Introduce new visual transform property : EXTRA_SIZE
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / internal / visuals / visual-url.h
1 #ifndef DALI_TOOLKIT_INTERNAL_VISUAL_URL_H
2 #define DALI_TOOLKIT_INTERNAL_VISUAL_URL_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 <string>
21
22 namespace Dali
23 {
24
25 namespace Toolkit
26 {
27
28 namespace Internal
29 {
30
31 class VisualUrl
32 {
33 public:
34
35   /**
36    * The type of the URL based on the string contents
37    */
38   enum Type
39   {
40     REGULAR_IMAGE,
41     N_PATCH,
42     SVG,
43     GIF,
44     JSON
45   };
46
47   enum ProtocolType
48   {
49     LOCAL,   ///< file in local file system
50     TEXTURE, ///< texture uploaded to texture manager
51     REMOTE   ///< remote image
52   };
53
54   /**
55    * Default Constructor.
56    * Resulting URL is not valid
57    */
58   VisualUrl();
59
60   /**
61    * Constructor.
62    * Determines type of visual and whether the url is local or remote
63    * @param[in] url The URL to store and resolve
64    */
65   VisualUrl( const std::string& url );
66
67   /**
68    * Copy constructor
69    * @param[in] url The VisualUrl to copy
70    */
71   VisualUrl( const VisualUrl& url );
72
73   /**
74    * Assignment operator
75    * @param[in] url The VisualUrl to copy
76    */
77   VisualUrl& operator=( const VisualUrl& url );
78
79   /**
80    * Get the full URL
81    * @return The url
82    */
83   const std::string& GetUrl() const;
84
85   /**
86    * Get the visual type of the URL
87    * @return The visual type of the URL
88    */
89   Type GetType() const;
90
91   /**
92    * Is the URL is local to the device, or remote?
93    * @return the location of the resource
94    */
95   ProtocolType GetProtocolType() const;
96
97   /**
98    * Is the URL valid?
99    * @return true if the URL has length
100    */
101   bool IsValid() const;
102
103   /**
104    * @return true if the location is LOCAL, i.e. is loadable from local file system
105    */
106   bool IsLocalResource() const;
107
108   /**
109    * @return the location part of the url
110    */
111   std::string GetLocation() const;
112
113   /**
114    * Helper to create a URL of type TEXTURE
115    * @param location the location of the texture
116    * @return the Url
117    */
118   static std::string CreateTextureUrl( const std::string& location );
119
120 private:
121   std::string mUrl;
122   Type mType;
123   ProtocolType mLocation;
124 };
125
126
127 } // namespace Internal
128
129 } // namespace Toolkit
130
131 } // namespace Dali
132
133 #endif /* DALI_TOOLKIT_INTERNAL_VISUAL_URL_H */