aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKazumasa Mitsunari <knimitz@witz-inc.co.jp>2018-08-22 09:05:52 +0900
committerKazumasa Mitsunari <knimitz@witz-inc.co.jp>2018-08-22 09:05:52 +0900
commit621314943d21cdb3b7e51a4c3d0faefc44658a11 (patch)
tree6e40cb50bbe8409e8431cc5ea213aa70fe006fa2
parent27e4f2d7810666d86bcb525d0e7e513e70c5f021 (diff)
Forgot adding new files
Change-Id: I9f05c8ac369890403710214522c2faa3deb129fb Signed-off-by: Kazumasa Mitsunari <knimitz@witz-inc.co.jp>
-rw-r--r--src/layout_manager.cpp62
-rw-r--r--src/layout_manager.hpp44
-rw-r--r--src/wm_layer.cpp123
-rw-r--r--src/wm_layer.hpp95
4 files changed, 324 insertions, 0 deletions
diff --git a/src/layout_manager.cpp b/src/layout_manager.cpp
new file mode 100644
index 0000000..66de5c3
--- /dev/null
+++ b/src/layout_manager.cpp
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2017 TOYOTA MOTOR CORPORATION
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <assert.h>
+#include "layers.hpp"
+#include "layout_manager.hpp"
+
+using std::string;
+
+namespace wm {
+
+LayoutManager::LayoutManager(const string& path) : wm_layers()
+{
+ WMError ret = this->load(path);
+ assert(ret == WMError::SUCCESS);
+}
+
+LayoutManager::~LayoutManager()
+{}
+
+unsigned LayoutManager::getNewLayerID(const string& role)
+{
+ unsigned ret = 0;
+ for(const auto& l: this->wm_layers)
+ {
+ ret = l->getNewLayerID(role);
+ if(ret != 0)
+ {
+ break;
+ }
+ }
+ return ret;
+}
+
+WMError LayoutManager::updateLayer(WMLayer& wm_layer)
+{
+ return WMError::SUCCESS;
+}
+
+void LayoutManager::commitChange() {}
+
+void LayoutManager::undoUpdate() {}
+
+WMError LayoutManager::load(const string &path)
+{
+ return WMError::SUCCESS;
+}
+
+} // namespace wm \ No newline at end of file
diff --git a/src/layout_manager.hpp b/src/layout_manager.hpp
new file mode 100644
index 0000000..34e8e59
--- /dev/null
+++ b/src/layout_manager.hpp
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2017 TOYOTA MOTOR CORPORATION
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <string>
+#include <memory>
+#include <vector>
+
+#include "wm_error.hpp"
+#include "wm_layer.hpp"
+
+namespace wm {
+
+class LayoutManager
+{
+ public:
+ explicit LayoutManager(const std::string& path);
+ ~LayoutManager();
+ unsigned getNewLayerID(const std::string& role);
+ // void setRenderOrder(const std::vector<unsigned> layer_render_order);
+ // std::vector<unsigned> getAllRenderOrder();
+ // std::vector<std::shared_ptr<WMLayer>>& getAllLayers();
+ // std::vector<unsigned> getRenderOrder(const std::string& layer_name);
+ WMError updateLayer(WMLayer& wm_layer);
+ void commitChange();
+ void undoUpdate();
+ private:
+ WMError load(const std::string& path);
+ std::vector<std::shared_ptr<WMLayer>> wm_layers;
+};
+
+} // namespace wm \ No newline at end of file
diff --git a/src/wm_layer.cpp b/src/wm_layer.cpp
new file mode 100644
index 0000000..87fff49
--- /dev/null
+++ b/src/wm_layer.cpp
@@ -0,0 +1,123 @@
+/*
+ * Copyright (c) 2017 TOYOTA MOTOR CORPORATION
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <regex>
+
+#include "wm_layer.hpp"
+#include "wayland_ivi_wm.hpp"
+#include "json_helper.hpp"
+#include "hmi-debug.h"
+
+using std::string;
+using std::vector;
+
+namespace wm
+{
+
+LayerState::LayerState()
+ : _ivi_layer_id_list(),
+ area2ivi_layer_id()
+{}
+
+LayerSetting::LayerSetting(const string& name, MANAGEMENT_TYPE type, unsigned begin, unsigned end)
+ : name(name), type(type),
+ role_list(), area_list(), id_list(),
+ id_begin(begin), id_end(end)
+{}
+
+void LayerSetting::appendRole(const string& role)
+{
+ this->role_list.push_back(role);
+}
+
+void LayerSetting::appendArea(const string& area)
+{
+ this->area_list.push_back(area);
+}
+
+unsigned LayerSetting::getNewLayerID(const string& role)
+{
+ unsigned ret = 0;
+ auto found = std::find(role_list.cbegin(), role_list.cend(), role);
+ if(found == role_list.cend())
+ {
+ return ret;
+ }
+ // generate new ivi layer id
+ ret = id_list.back() + 1;
+ HMI_INFO("wm", "generate ivi_layer_id : %d on the layer: %s", ret, this->name.c_str());
+
+ auto id_found = std::find(id_list.begin(), id_list.end(), ret);
+ if( (ret > this->idEnd()) || (id_found != id_list.cend()) )
+ {
+ HMI_NOTICE("wm", "id %d is not available then generate new id", ret);
+ ret = 0;
+ for(unsigned i = this->idBegin(); i < this->idEnd(); i++)
+ {
+ auto ret_found = std::find(id_list.begin(), id_list.end(), i);
+ if(ret_found == id_list.cend())
+ {
+ HMI_INFO("wm", "set new id: %d", i);
+ ret = i;
+ break;
+ }
+ }
+ }
+
+ if(ret != 0)
+ {
+ id_list.push_back(ret);
+ }
+ else
+ {
+ HMI_ERROR("wm", "failed to get New ID");
+ }
+ return ret;
+}
+
+void LayerSetting::removeLayerID(unsigned id)
+{
+ auto fwd_itr = std::remove_if(this->id_list.begin(), this->id_list.end(),
+ [id](unsigned elm) {
+ return elm == id;
+ });
+ this->id_list.erase(fwd_itr, this->id_list.end());
+}
+
+WMLayer::WMLayer()
+ : before_state(),
+ state(),
+ setting{}
+{
+ // this->setting = std::make_unique<LayerSetting>(name, type, begin, end);
+}
+
+unsigned WMLayer::getNewLayerID(const std::string& role)
+{
+ return this->setting->getNewLayerID(role);
+}
+
+WMError WMLayer::setLayerState(const LayerState& l)
+{
+ return WMError::SUCCESS;
+}
+
+bool WMLayer::checkIDBelongTo(unsigned id)
+{
+ return (id > this->setting->idBegin() && id < this->setting->idEnd());
+}
+
+} // namespace wm
diff --git a/src/wm_layer.hpp b/src/wm_layer.hpp
new file mode 100644
index 0000000..ac74530
--- /dev/null
+++ b/src/wm_layer.hpp
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2017 TOYOTA MOTOR CORPORATION
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef WM_LAYERS_H
+#define WM_LAYERS_H
+
+#include <string>
+#include <vector>
+#include <unordered_map>
+#include <memory>
+#include "wm_error.hpp"
+
+namespace wm
+{
+
+class LayerState
+{
+ public:
+ LayerState();
+ ~LayerState() = default;
+ private:
+ std::vector<unsigned> _ivi_layer_id_list;
+ std::unordered_map<std::string, unsigned> area2ivi_layer_id;
+ // std::map<std::string, unsigned> _render_order;
+};
+
+class LayerSetting
+{
+ public:
+ enum MANAGEMENT_TYPE
+ {
+ TILE,
+ STACK
+ };
+
+ explicit LayerSetting(const std::string& name, MANAGEMENT_TYPE type, unsigned begin, unsigned end);
+ ~LayerSetting() = default;
+
+ const std::string& layerName() { return this->name; }
+ MANAGEMENT_TYPE layerType() { return this->type; };
+ void appendRole(const std::string& role);
+ void appendArea(const std::string& area);
+ unsigned idBegin() { return this->id_begin; }
+ unsigned idEnd() { return this->id_end; }
+ unsigned getNewLayerID(const std::string& role);
+ void removeLayerID(unsigned id);
+
+/* unsigned getNewID(const std::string& role);
+ void remove(unsigned ivi_layer_id);
+ void clear();
+ bool attach(unsigned ivi_layer_id, const std::string& area);
+ void stack(unsigned ivi_layer_id, const std::string& area);
+ bool updateRenderOrder(const std::vector<unsigned> list); */
+
+ private:
+ std::string name = ""; // Layer name
+ MANAGEMENT_TYPE type;
+ std::vector<std::string> role_list;
+ std::vector<std::string> area_list;
+ std::vector<unsigned> id_list;
+ unsigned id_begin;
+ unsigned id_end;
+};
+
+class WMLayer
+{
+ public:
+ WMLayer();
+ ~WMLayer() = default;
+ unsigned getNewLayerID(const std::string& role);
+ LayerState getLayerState() const { return before_state; }
+ WMError setLayerState(const LayerState& l);
+ bool checkIDBelongTo(unsigned id);
+ private:
+ LayerState before_state;
+ LayerState state;
+ std::unique_ptr<LayerSetting> setting;
+};
+
+} // namespace wm
+
+#endif // WM_LAYERS_H