Update wm_layer
[apps/agl-service-windowmanager.git] / src / wm_layer_control.hpp
1 /*\r
2  * Copyright (c) 2017 TOYOTA MOTOR CORPORATION\r
3  *\r
4  * Licensed under the Apache License, Version 2.0 (the "License");\r
5  * you may not use this file except in compliance with the License.\r
6  * You may obtain a copy of the License at\r
7  *\r
8  *      http://www.apache.org/licenses/LICENSE-2.0\r
9  *\r
10  * Unless required by applicable law or agreed to in writing, software\r
11  * distributed under the License is distributed on an "AS IS" BASIS,\r
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
13  * See the License for the specific language governing permissions and\r
14  * limitations under the License.\r
15  */\r
16 \r
17 #include <string>\r
18 #include <memory>\r
19 #include <vector>\r
20 #include <unordered_map>\r
21 #include <functional>\r
22 #include <ilm/ilm_control.h>\r
23 #include "wm_error.hpp"\r
24 #include "util.hpp"\r
25 \r
26 namespace wm {\r
27 \r
28 class Screen : public rectangle {\r
29 \r
30 };\r
31 \r
32 class LayerControlCallbacks {\r
33   public:\r
34     LayerControlCallbacks() {};\r
35     virtual ~LayerControlCallbacks() = default;\r
36     LayerControlCallbacks(const LayerControlCallbacks &obj) = default;\r
37 \r
38     // callback functions\r
39     virtual void test(unsigned i) { HMI_DEBUG("test %d", i); }\r
40     std::function<void(unsigned)> surfaceCreated;\r
41     /* std::function<void(unsigned)> surfaceDestroyed;\r
42     std::function<void(unsigned)> layerCreated;\r
43     std::function<void(unsigned)> layerDestroyed; */\r
44 };\r
45 \r
46 class WMLayer;\r
47 class LayerState;\r
48 class LayerControl\r
49 {\r
50   public:\r
51     explicit LayerControl(const std::string& root);\r
52     ~LayerControl() = default;\r
53     WMError init(const LayerControlCallbacks& cb);\r
54     unsigned getNewLayerID(const std::string& role);\r
55     // void setRenderOrder(const std::vector<unsigned> layer_render_order);\r
56     // std::vector<unsigned> getAllRenderOrder();\r
57     // std::vector<std::shared_ptr<WMLayer>>& getAllLayers();\r
58     // std::vector<unsigned> getRenderOrder(const std::string& layer_name);\r
59     WMError updateLayer(LayerState& layer_state);\r
60     WMError commitChange();\r
61     void undoUpdate();\r
62 \r
63     // Don't use this function.\r
64     void dispatchCreateEvent(ilmObjectType object, unsigned id, bool created);\r
65     void dispatchPropertyChangeEvent(unsigned id, struct ilmSurfaceProperties*, t_ilm_notification_mask);\r
66     void dispatchPropertyChangeEvent(unsigned id, struct ilmLayerProperties*, t_ilm_notification_mask);\r
67   private:\r
68     WMError loadLayerSetting(const std::string& path);\r
69     WMError loadAreaDb(const std::string& path);\r
70 \r
71     std::vector<std::shared_ptr<WMLayer>> wm_layers;\r
72     std::unordered_map<std::string, struct rect> area2size;\r
73     unsigned screenID;\r
74     struct ilmScreenProperties screen_prop;\r
75     LayerControlCallbacks cb;\r
76 };\r
77 \r
78 } // namespace wm