temporary change
[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 {\r
29   public:\r
30     Screen(unsigned w, unsigned h);\r
31     ~Screen();\r
32     unsigned width() { return _width; }\r
33     unsigned height() { return _height; }\r
34   private:\r
35     unsigned _width;\r
36     unsigned _height;\r
37     unsigned _pysical_width = 0;\r
38     unsigned _pysical_height = 0;\r
39 };\r
40 \r
41 class LayerControlCallbacks {\r
42   public:\r
43     LayerControlCallbacks() {};\r
44     virtual ~LayerControlCallbacks() = default;\r
45     LayerControlCallbacks(const LayerControlCallbacks &obj) = default;\r
46 \r
47     // callback functions\r
48     virtual void test(unsigned i) { HMI_DEBUG("test %d", i); }\r
49     std::function<void(unsigned)> surfaceCreated;\r
50     /* std::function<void(unsigned)> surfaceDestroyed;\r
51     std::function<void(unsigned)> layerCreated;\r
52     std::function<void(unsigned)> layerDestroyed; */\r
53 };\r
54 \r
55 class WMLayer;\r
56 class LayerState;\r
57 class WMAction;\r
58 class WMClient;\r
59 \r
60 class LayerControl\r
61 {\r
62   public:\r
63     explicit LayerControl(const std::string& root);\r
64     ~LayerControl() = default;\r
65     WMError init(const LayerControlCallbacks& cb);\r
66     void createNewLayer(unsigned id);\r
67     unsigned getNewLayerID(const std::string& role, std::string* layer_name);\r
68     struct rect getAreaSize(const std::string& area);\r
69     void setupArea(double scaling);\r
70     Screen getScreenInfo();\r
71     double scale();\r
72     // void setRenderOrder(const std::vector<unsigned> layer_render_order);\r
73     // std::vector<unsigned> getAllRenderOrder();\r
74     // std::vector<std::shared_ptr<WMLayer>>& getAllLayers();\r
75     // std::vector<unsigned> getRenderOrder(const std::string& layer_name);\r
76     WMError updateLayer(LayerState& layer_state);\r
77     WMError commitChange();\r
78     void undoUpdate();\r
79     WMError layoutChange(const WMAction& action);\r
80     WMError visibilityChange(const WMAction &action);\r
81 \r
82     // Don't use this function.\r
83     void dispatchCreateEvent(ilmObjectType object, unsigned id, bool created);\r
84     void dispatchPropertyChangeEvent(unsigned id, struct ilmSurfaceProperties*, t_ilm_notification_mask);\r
85     void dispatchPropertyChangeEvent(unsigned id, struct ilmLayerProperties*, t_ilm_notification_mask);\r
86   private:\r
87     WMError makeVisible(const WMClient* client);\r
88     WMError makeInvisible(const WMClient* client);\r
89     WMError loadLayerSetting(const std::string& path);\r
90     WMError loadAreaDb(const std::string& path);\r
91 \r
92     std::vector<std::shared_ptr<WMLayer>> wm_layers;\r
93     std::unordered_map<std::string, struct rect> area2size;\r
94     unsigned screenID;\r
95     struct ilmScreenProperties screen_prop;\r
96     double scaling;\r
97     LayerControlCallbacks cb;\r
98 };\r
99 \r
100 } // namespace wm