From 621314943d21cdb3b7e51a4c3d0faefc44658a11 Mon Sep 17 00:00:00 2001 From: Kazumasa Mitsunari Date: Wed, 22 Aug 2018 09:05:52 +0900 Subject: [PATCH] Forgot adding new files Change-Id: I9f05c8ac369890403710214522c2faa3deb129fb Signed-off-by: Kazumasa Mitsunari --- src/layout_manager.cpp | 62 +++++++++++++++++++++++++ src/layout_manager.hpp | 44 ++++++++++++++++++ src/wm_layer.cpp | 123 +++++++++++++++++++++++++++++++++++++++++++++++++ src/wm_layer.hpp | 95 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 324 insertions(+) create mode 100644 src/layout_manager.cpp create mode 100644 src/layout_manager.hpp create mode 100644 src/wm_layer.cpp create mode 100644 src/wm_layer.hpp 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 +#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 +#include +#include + +#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 layer_render_order); + // std::vector getAllRenderOrder(); + // std::vector>& getAllLayers(); + // std::vector getRenderOrder(const std::string& layer_name); + WMError updateLayer(WMLayer& wm_layer); + void commitChange(); + void undoUpdate(); + private: + WMError load(const std::string& path); + std::vector> 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 + +#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(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 +#include +#include +#include +#include "wm_error.hpp" + +namespace wm +{ + +class LayerState +{ + public: + LayerState(); + ~LayerState() = default; + private: + std::vector _ivi_layer_id_list; + std::unordered_map area2ivi_layer_id; + // std::map _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 list); */ + + private: + std::string name = ""; // Layer name + MANAGEMENT_TYPE type; + std::vector role_list; + std::vector area_list; + std::vector 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 setting; +}; + +} // namespace wm + +#endif // WM_LAYERS_H -- 2.16.6