If DISPATCH_KEY_EVENTS property is false, the KeyEvent is not received.
[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) 2021 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 namespace Toolkit
25 {
26 namespace Internal
27 {
28 class VisualUrl
29 {
30 public:
31   /**
32    * The type of the URL based on the string contents
33    */
34   enum Type
35   {
36     REGULAR_IMAGE,
37     N_PATCH,
38     SVG,
39     GIF,
40     WEBP,
41     JSON
42   };
43
44   enum ProtocolType
45   {
46     LOCAL,   ///< file in local file system
47     TEXTURE, ///< texture uploaded to texture manager
48     REMOTE,  ///< remote image
49     BUFFER   ///< encoded image buffer
50   };
51
52   /**
53    * Default Constructor.
54    * Resulting URL is not valid
55    */
56   VisualUrl();
57
58   /**
59    * Default Destructor.
60    * Delete an external texture if if protocolType is TEXTURE.
61    */
62   ~VisualUrl();
63
64   /**
65    * Constructor.
66    * Determines type of visual and whether the url is local or remote
67    * Notify that it is using an external texture if if protocolType is TEXTURE.
68    *
69    * @param[in] url The URL to store and resolve
70    */
71   VisualUrl(const std::string& url);
72
73   /**
74    * Copy constructor
75    * @param[in] url The VisualUrl to copy
76    */
77   VisualUrl(const VisualUrl& url);
78
79   /**
80    * Assignment operator
81    * @param[in] url The VisualUrl to copy
82    */
83   VisualUrl& operator=(const VisualUrl& url);
84
85   /**
86    * Get the full URL
87    * @return The url
88    */
89   const std::string& GetUrl() const;
90
91   /**
92    * Get the visual type of the URL
93    * @return The visual type of the URL
94    */
95   Type GetType() const;
96
97   /**
98    * Is the URL is local to the device, or remote?
99    * @return the location of the resource
100    */
101   ProtocolType GetProtocolType() const;
102
103   /**
104    * Is the URL valid?
105    * @return true if the URL has length
106    */
107   bool IsValid() const;
108
109   /**
110    * @return true if the location is LOCAL, i.e. is loadable from local file system
111    */
112   bool IsLocalResource() const;
113
114   /**
115    * @return true if the location is BUFFER, i.e. may contain EncodedImageBuffer
116    */
117   bool IsBufferResource() const;
118
119   /**
120    * @return the location part of the url
121    */
122   std::string GetLocation() const;
123
124   /**
125    * Helper to create a URL of type TEXTURE
126    * @param location the location of the texture
127    * @return the Url
128    */
129   static std::string CreateTextureUrl(const std::string& location);
130
131   /**
132    * Helper to create a URL of type BUFFER
133    * @param location the location of the texture
134    * @return the Url
135    */
136   static std::string CreateBufferUrl(const std::string& location);
137
138   /**
139    * Helper to get a ProtocolType from url
140    * @param url the url of the texture
141    * @return the protocol type
142    */
143   static VisualUrl::ProtocolType GetProtocolType(const std::string& url);
144
145   /**
146    * Helper to get a location from url
147    * @param url the location of the texture
148    * @return the location
149    */
150   static std::string GetLocation(const std::string& url);
151
152 private:
153   std::string  mUrl;
154   Type         mType;
155   ProtocolType mLocation;
156 };
157
158 } // namespace Internal
159
160 } // namespace Toolkit
161
162 } // namespace Dali
163
164 #endif /* DALI_TOOLKIT_INTERNAL_VISUAL_URL_H */