*/
#include <regex>
-
+#include <ilm/ilm_control.h>
+#include <stdlib.h>
#include "wm_client.hpp"
#include "wm_layer.hpp"
#include "json_helper.hpp"
return this->render_order;
}
-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::setRoleList(const string& role)
+WMLayer::WMLayer(json_object* j) : before_state(), state()
{
- this->role_list = role;
-}
+ this->name = jh::getStringFromJson(j, "name");
+ this->role_list = jh::getStringFromJson(j, "role");
+ const char* type = jh::getStringFromJson(j, "type");
+ this->id_begin = static_cast<unsigned>(jh::getIntFromJson(j, "id_range_begin"));
+ this->id_end = static_cast<unsigned>(jh::getIntFromJson(j, "id_range_end"));
-void LayerSetting::appendArea(const string& area)
-{
- this->area_list.push_back(area);
+ if (name.size() == 0 || type || this->id_begin == 0 || this->id_end == 0)
+ {
+ HMI_ERROR("Parse Error!!");
+ exit(1);
+ }
+ if(this->id_begin > this->id_end)
+ {
+ HMI_ERROR("INVALID");
+ exit(1);
+ }
+ string str_type = type;
+ this->type = (str_type == "tile") ? MANAGEMENT_TYPE::TILE : MANAGEMENT_TYPE::STACK;
}
-unsigned LayerSetting::getNewLayerID(const string& role)
+unsigned WMLayer::getNewLayerID(const string& role)
{
unsigned ret = 0;
auto re = std::regex(this->role_list);
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{}
+const string& WMLayer::layerName()
{
- // this->setting = std::make_unique<LayerSetting>(name, type, begin, end);
+ return this->name;
}
-WMLayer::WMLayer(json_object* j) : before_state(), state()
+WMError WMLayer::setLayerState(const LayerState& l)
{
- LayerSetting::MANAGEMENT_TYPE t;
- const char* layer_name = jh::getStringFromJson(j, "name");
- const char* roles = jh::getStringFromJson(j, "role");
- const char* type = jh::getStringFromJson(j, "type");
- int begin = jh::getIntFromJson(j, "id_range_begin");
- int end = jh::getIntFromJson(j, "id_range_end");
- string name = layer_name;
-
- if (layer_name || type || begin < 0 || end < 0)
- {
- HMI_ERROR("Parse Error!!");
- }
- if(begin > end)
- {
- HMI_ERROR("INVALID.");
- }
- string str_type = type;
- t = (str_type == "tile") ? LayerSetting::TILE : LayerSetting::STACK;
- this->setting = std::make_unique<LayerSetting>(name, t, begin, end);
- this->setting->setRoleList(roles);
+ this->before_state = l;
+ return WMError::SUCCESS;
}
-unsigned WMLayer::getNewLayerID(const std::string& role)
+void WMLayer::appendArea(const string& area)
{
- return this->setting->getNewLayerID(role);
+ this->area_list.push_back(area);
}
-WMError WMLayer::setLayerState(const LayerState& l)
+void WMLayer::removeLayerID(unsigned id)
{
- this->before_state = l;
- return WMError::SUCCESS;
+ 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());
}
bool WMLayer::checkIDBelongTo(unsigned id)
{
- return (id > this->setting->idBegin() && id < this->setting->idEnd());
+ return (id > this->idBegin() && id < this->idEnd());
}
/* WMError WMLayer::commitChange()
std::unordered_map<std::string, std::string> area2appid;
};
-class LayerSetting
+class WMLayer
{
public:
enum MANAGEMENT_TYPE
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 setRoleList(const std::string& role);
- void appendArea(const std::string& area);
+ explicit WMLayer(json_object* j);
+ ~WMLayer() = default;
+ unsigned getNewLayerID(const std::string& role);
unsigned idBegin() { return this->id_begin; }
unsigned idEnd() { return this->id_end; }
- unsigned getNewLayerID(const std::string& role);
+ const std::string& layerName();
+ MANAGEMENT_TYPE layerType() { return this->type; }
+ void appendArea(const std::string& area);
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); */
-
+ LayerState getLayerState() const { return before_state; }
+ WMError setLayerState(const LayerState& l);
+ bool checkIDBelongTo(unsigned id);
private:
+ LayerState before_state;
+ LayerState state;
std::string name = ""; // Layer name
MANAGEMENT_TYPE type;
std::string role_list;
unsigned id_end;
};
-class WMLayer
-{
- public:
- WMLayer();
- WMLayer(json_object* j);
- ~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
\r
#define LC_AREA_PATH "/etc/areas.db"\r
#define LC_LAYER_SETTING_PATH "/etc/layer_setting.json"\r
+#define LC_DEFAULT_AREA "normal.full"\r
\r
using std::string;\r
using std::vector;\r
return WMError::FAIL;\r
}\r
\r
-unsigned LayerControl::getNewLayerID(const string& role)\r
+void LayerControl::createNewLayer(unsigned id)\r
+{\r
+ HMI_INFO("create new ID :%d", id);\r
+ struct rect rct = this->area2size[LC_DEFAULT_AREA];\r
+ ilm_layerCreateWithDimension(&id, rct.w, rct.h);\r
+ ilm_layerSetSourceRectangle(id, rct.x, rct.y, rct.w, rct.h);\r
+ ilm_layerSetDestinationRectangle(id, rct.x, rct.y, rct.w, rct.h);\r
+ ilm_layerSetOpacity(id, 1.0);\r
+ ilm_layerSetVisibility(id, ILM_TRUE);\r
+ ilm_commitChanges();\r
+}\r
+\r
+unsigned LayerControl::getNewLayerID(const string& role, string* layer_name)\r
{\r
unsigned ret = 0;\r
for(const auto& l: this->wm_layers)\r
ret = l->getNewLayerID(role);\r
if(ret != 0)\r
{\r
+ *layer_name = l->layerName();\r
break;\r
}\r
}\r
void LayerControl::setupArea(double scaling)\r
{\r
struct rect rct;\r
+ this->scaling = scaling;\r
\r
rct = this->area2size["normal.full"];\r
this->area2size["normalfull"] = rct;\r
return Screen(this->screen_prop.screenWidth, this->screen_prop.screenHeight);\r
}\r
\r
+double LayerControl::scale()\r
+{\r
+ return this->scaling;\r
+}\r
+\r
WMError LayerControl::updateLayer(LayerState& layer_state)\r
{\r
return WMError::SUCCESS;\r
explicit LayerControl(const std::string& root);\r
~LayerControl() = default;\r
WMError init(const LayerControlCallbacks& cb);\r
- unsigned getNewLayerID(const std::string& role);\r
+ void createNewLayer(unsigned id);\r
+ unsigned getNewLayerID(const std::string& role, std::string* layer_name);\r
struct rect getAreaSize(const std::string& area);\r
void setupArea(double scaling);\r
Screen getScreenInfo();\r
+ double scale();\r
// void setRenderOrder(const std::vector<unsigned> layer_render_order);\r
// std::vector<unsigned> getAllRenderOrder();\r
// std::vector<std::shared_ptr<WMLayer>>& getAllLayers();\r
std::unordered_map<std::string, struct rect> area2size;\r
unsigned screenID;\r
struct ilmScreenProperties screen_prop;\r
+ double scaling;\r
LayerControlCallbacks cb;\r
};\r
\r