FIND_PACKAGE(PkgConfig REQUIRED)
PKG_CHECK_MODULES(tools_pkgs REQUIRED
libxml-2.0
+ notification
capi-appfw-app-control
capi-system-runtime-info
capi-system-device
./src/external-decrypt/main.c
./src/external-decrypt/confirm.c)
+SET(WIDGET_SRC ./rework/widgets/widget.cpp
+ ./rework/widgets/window.cpp
+ ./rework/widgets/timer.cpp
+ ./rework/widgets/layout.cpp
+ ./rework/widgets/appcontrol.cpp
+ ./rework/widgets/notification.cpp
+ ./rework/widgets/button.cpp
+ ./rework/widgets/image.cpp
+ ./rework/widgets/entry.cpp
+ ./rework/widgets/naviframe.cpp
+ ./rework/widgets/textblock.cpp
+ ./rework/widgets/radio.cpp
+ ./rework/widgets/checkbox.cpp
+ ./rework/widgets/progressbar.cpp
+ ./rework/widgets/popup.cpp)
+
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIE")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pie")
-ADD_EXECUTABLE(${PKG_NAME} ${PKG_SRC})
+ADD_EXECUTABLE(${PKG_NAME} ${PKG_SRC} ${WIDGET_SRC})
INSTALL(TARGETS ${PKG_NAME} DESTINATION ${APP_INSTALL_PREFIX}/${PKG_NAME}/bin)
TARGET_LINK_LIBRARIES(${PKG_NAME} ${EFL_APP_LIBRARIES} ${tools_pkgs_LIBRARIES} ode)
<profile name="mobile"/>
<privileges>
<privilege>http://tizen.org/privilege/appmanager.launch</privilege>
+ <privilege>http://tizen.org/privilege/notification</privilege>
</privileges>
<ui-application appid="org.tizen.ode" exec="/usr/apps/org.tizen.ode/bin/org.tizen.ode" multiple="false" nodisplay="true" taskmanage="true" type="capp">
<label>ODE</label>
--- /dev/null
+/*
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 <dlog.h>
+#include "appcontrol.h"
+
+AppControl::AppControl(app_control_h handle)
+ : appControl(nullptr)
+{
+ if (handle != nullptr) {
+ ::app_control_clone(&appControl, handle);
+ }
+}
+
+AppControl::AppControl(const std::string &id)
+ : appControl(nullptr)
+{
+ ::app_control_create(&appControl);
+ setAppID(id);
+}
+
+AppControl::~AppControl()
+{
+ if (appControl != nullptr)
+ ::app_control_destroy(appControl);
+}
+
+AppControl::operator app_control_h()
+{
+ return appControl;
+}
+
+void AppControl::setAppID(const std::string &id)
+{
+ ::app_control_set_app_id(appControl, id.c_str());
+}
+
+void AppControl::setData(const std::string &key, const std::string &data)
+{
+ ::app_control_add_extra_data(appControl, key.c_str(), data.c_str());
+}
+
+std::string AppControl::getData(const std::string &key)
+{
+ std::string data("");
+ char *appData = nullptr;
+
+ ::app_control_get_extra_data(appControl, key.c_str(), &appData);
+ if (appData) {
+ data = appData;
+ ::free(appData);
+ }
+ return data;
+}
+
+void AppControl::launch(void)
+{
+ ::app_control_send_launch_request(appControl, replyEventHandlerDispatcher, reinterpret_cast<void *>(this));
+}
+
+void AppControl::replyEventHandlerDispatcher(app_control_h ug, app_control_h reply, app_control_result_e result, void *data)
+{
+ AppControl *appControl = reinterpret_cast<AppControl *>(data);
+ AppControl ugControl(ug);
+ AppControl replyControl(reply);
+
+ appControl->replyEventHandler.emit(&ugControl, &replyControl, result);
+}
--- /dev/null
+/*
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 __ODE_APPCONTROL_H__
+#define __ODE_APPCONTROL_H__
+
+#include <functional>
+#include <app_control_internal.h>
+#include "signal.h"
+
+class AppControl {
+public:
+ AppControl(app_control_h handle);
+ AppControl(const std::string &id);
+ ~AppControl();
+
+ operator app_control_h();
+
+ void setAppID(const std::string &id);
+ void setData(const std::string &key, const std::string &data);
+ std::string getData(const std::string &key);
+
+ void launch();
+ static void replyEventHandlerDispatcher(app_control_h ug, app_control_h reply, app_control_result_e result, void *data);
+public:
+ Signal<AppControl *, AppControl *, int> replyEventHandler;
+private:
+ app_control_h appControl;
+};
+
+#endif
--- /dev/null
+/*
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 "button.h"
+
+Button::Button(Widget *parent)
+ : Widget("Button", ::elm_button_add(evasObject(parent)))
+{
+ onClick = [this](void * event_info) {
+ };
+
+ addSmartHandler("clicked", [this](void * event_info) {
+ this->onClick(event_info);
+ this->onClickSignal.emit();
+ });
+}
+
+Button::~Button()
+{
+}
--- /dev/null
+/*
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 __ODE_BUTTON_H__
+#define __ODE_BUTTON_H__
+
+#include <functional>
+#include "widget.h"
+#include "signal.h"
+
+class Button : public Widget {
+public:
+ Button(Widget *parent);
+ ~Button();
+
+ Signal<> onClickSignal;
+ SmartHandler onClick;
+};
+
+#endif
--- /dev/null
+/*
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 "checkbox.h"
+
+CheckBox::CheckBox(Widget *parent)
+ : Widget ("CheckBox", ::elm_check_add(Widget::evasObject(parent)))
+{
+ onChanged = [this]() {
+ };
+ addSmartHandler("changed", [this](void *evnet_info) {
+ onChanged();
+ onChangedSignal.emit();
+ });
+}
+
+CheckBox::~CheckBox()
+{
+}
+
+void CheckBox::setState(bool state)
+{
+ ::elm_check_state_set(Widget::evasObject(this), state);
+}
+
+bool CheckBox::getState()
+{
+ return ::elm_check_state_get(Widget::evasObject(this));
+}
--- /dev/null
+/*
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 __ODE_CHECKBOX_H__
+#define __ODE_CHECKBOX_H__
+
+#include "widget.h"
+#include "signal.h"
+
+class CheckBox : public Widget {
+public:
+ CheckBox(Widget *parent);
+ ~CheckBox();
+
+ void setState(bool state);
+ bool getState();
+
+ Signal<> onChangedSignal;
+ std::function<void()> onChanged;
+};
+
+#endif
--- /dev/null
+/*
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 "entry.h"
+
+Entry::Entry(Widget *parent, int config)
+ : Widget("Entry", ::elm_entry_add(Widget::evasObject(parent)))
+{
+ ::elm_entry_input_panel_enabled_set(Widget::evasObject(this), EINA_TRUE);
+ setConfig(config);
+ setLimitFilter(14, 0); //Temp
+}
+
+Entry::~Entry()
+{
+}
+
+void Entry::setConfig(int config)
+{
+ if (config & SetSingleLine)
+ ::elm_entry_single_line_set(Widget::evasObject(this), EINA_TRUE);
+ if (config & SetPassword)
+ ::elm_entry_password_set(Widget::evasObject(this), EINA_TRUE);
+ if (config & SetReturnKeyDisabled)
+ ::elm_entry_input_panel_return_key_disabled_set(Widget::evasObject(this), EINA_TRUE);
+ if (config & SetAlignCenter)
+ ::elm_entry_text_style_user_push(Widget::evasObject(this), "DEFAULT='align=center'");
+}
+
+void Entry::setLimitFilter(int maxCharCount, int maxByteCount)
+{
+ Elm_Entry_Filter_Limit_Size limitSize = {
+ .max_char_count = maxCharCount,
+ .max_byte_count = maxByteCount
+ };
+ ::elm_entry_markup_filter_append(Widget::evasObject(this), elm_entry_filter_limit_size, &limitSize);
+}
+
+void Entry::set(const std::string &text)
+{
+ ::elm_entry_entry_set(Widget::evasObject(this), text.c_str());
+}
+
+const std::string Entry::get()
+{
+ return ::elm_entry_entry_get(Widget::evasObject(this));
+}
+
+bool Entry::isEmpty()
+{
+ return ::elm_entry_is_empty(Widget::evasObject(this));
+}
--- /dev/null
+/*
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 __ODE_ENTRY_H__
+#define __ODE_ENTRY_H__
+
+#include "widget.h"
+
+class Entry : public Widget {
+public:
+ enum Config {
+ SetSingleLine = (1 << 0),
+ SetPassword = (1 << 1),
+ SetReturnKeyDisabled = (1 << 2),
+ SetAlignCenter = (1 << 3),
+ };
+
+ Entry(Widget *parent, int config);
+ ~Entry();
+
+ void setConfig(int config);
+ void setLimitFilter(int maxCharCount, int maxByteCount);
+ void set(const std::string &text);
+ const std::string get();
+ bool isEmpty();
+};
+
+#endif
--- /dev/null
+/*
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 __ODE_GENLIST_H__
+#define __ODE_GENLIST_H__
+
+#include <dlog.h>
+#include <cstring>
+#include <memory>
+#include <vector>
+
+#include "widget.h"
+
+template<typename T>
+class Genlist;
+
+template<typename T>
+class GenlistContentProvider {
+public:
+ GenlistContentProvider() {}
+ virtual ~GenlistContentProvider() {}
+
+ virtual char *getLabel(const std::string &part, Evas_Object *obj, T *itemData) {
+ return NULL;
+ }
+ virtual Evas_Object *getObject(const std::string &part, Evas_Object *obj, T *itemData) {
+ return NULL;
+ }
+ virtual void addItems(Genlist<T> *genlist) = 0;
+};
+
+template<typename T>
+class GenlistItem {
+public:
+ virtual ~GenlistItem() {
+ }
+
+ void setSelectMode(Elm_Object_Select_Mode mode) {
+ ::elm_genlist_item_select_mode_set(item, mode);
+ }
+
+ void setDisabled(bool disable) {
+ ::elm_object_item_disabled_set(item, disable);
+ }
+
+ friend class Genlist<T>;
+
+private:
+ GenlistItem(Elm_Object_Item *object) : item(object) {
+ }
+
+private:
+ Elm_Object_Item *item;
+};
+
+template<typename T>
+class Genlist : public Widget {
+public:
+ enum Flags {
+ setCompressMode = (1 << 0),
+ setListScrollMode = (1 << 1),
+ setHomogeneous = (1 << 2),
+ };
+
+ Genlist(Widget *parent, int style);
+ virtual ~Genlist();
+
+ GenlistItem<T> append(const char *style, T *idata);
+
+ void setContentProvider(GenlistContentProvider<T> *provider);
+ GenlistContentProvider<T> *getContentProvider() const;
+
+private:
+ static char *dispatchLabel(void *data, Evas_Object *obj, const char *part);
+ static Evas_Object *dispatchContent(void *data, Evas_Object *obj, const char *part);
+ static void deleteData(void *data, Evas_Object *obj);
+ static void dispatchCallback(void *data, Evas_Object *obj, void *event);
+
+public:
+ Signal<Evas_Object *, T *> itemSelectedEvent;
+
+private:
+ GenlistContentProvider<T> *contentProvider;
+};
+
+template<typename T>
+struct GenlistItemData {
+ GenlistItemData(Genlist<T> *parent, T *idata) :
+ genlist(parent), itemData(idata) {
+ }
+
+ virtual ~GenlistItemData() {
+ ::dlog_print(DLOG_DEBUG, LOG_TAG, "Genlist Item deleted");
+ }
+
+ Genlist<T> *genlist;
+ T *itemData;
+};
+
+template<typename T>
+Genlist<T>::Genlist(Widget *parent, int style) :
+ Widget("Genlist", ::elm_genlist_add(Widget::evasObject(parent))), contentProvider(nullptr)
+{
+ if (style & setCompressMode) {
+ ::elm_genlist_mode_set(evasObject(this), ELM_LIST_COMPRESS);
+ }
+
+ if (style & setListScrollMode) {
+ ::elm_genlist_mode_set(evasObject(this), ELM_LIST_SCROLL);
+ }
+
+ if (style & setHomogeneous) {
+ ::elm_genlist_homogeneous_set(evasObject(this), EINA_TRUE);
+ }
+}
+
+template<typename T>
+Genlist<T>::~Genlist()
+{
+}
+
+template<typename T>
+GenlistItem<T> Genlist<T>::append(const char *style, T *itemData)
+{
+ Elm_Genlist_Item_Class *klass = ::elm_genlist_item_class_new();
+ klass->item_style = style;
+ klass->func.text_get = &Genlist<T>::dispatchLabel;
+ klass->func.content_get = &Genlist<T>::dispatchContent;
+ klass->func.del = &Genlist<T>::deleteData;
+
+ GenlistItemData<T> *data = new GenlistItemData<T>(this, itemData);
+
+ GenlistItem<T> item(::elm_genlist_item_append(evasObject(this),
+ klass,
+ reinterpret_cast<void *>(data),
+ NULL,
+ ELM_GENLIST_ITEM_NONE,
+ dispatchCallback,
+ reinterpret_cast<void *>(data)));
+
+ ::elm_genlist_item_class_free(klass);
+
+ return item;
+}
+
+template<typename T>
+void Genlist<T>::setContentProvider(GenlistContentProvider<T> *provider)
+{
+ // contentProvider must be set before populating items
+ contentProvider = provider;
+ contentProvider->addItems(this);
+}
+
+template<typename T>
+char *Genlist<T>::dispatchLabel(void *data, Evas_Object *obj, const char *part)
+{
+ GenlistItemData<T> *self = reinterpret_cast<GenlistItemData<T> *>(data);
+ return self->genlist->contentProvider->getLabel(part, obj, self->itemData);
+}
+
+template<typename T>
+Evas_Object *Genlist<T>::dispatchContent(void *data, Evas_Object *obj, const char *part)
+{
+ GenlistItemData<T> *self = reinterpret_cast<GenlistItemData<T> *>(data);
+ return self->genlist->contentProvider->getObject(part, obj, self->itemData);
+}
+
+template<typename T>
+void Genlist<T>::deleteData(void *data, Evas_Object *obj)
+{
+ GenlistItemData<T> *item = reinterpret_cast<GenlistItemData<T> *>(data);
+ delete item;
+}
+
+template<typename T>
+void Genlist<T>::dispatchCallback(void *data, Evas_Object *obj, void *event)
+{
+ GenlistItemData<T> *self = reinterpret_cast<GenlistItemData<T> *>(data);
+ ::elm_genlist_item_selected_set((Elm_Object_Item *)event, EINA_FALSE);
+ return self->genlist->itemSelectedEvent.emit(obj, self->itemData);
+}
+#endif
--- /dev/null
+/*
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 "image.h"
+
+Image::Image(Widget *parent)
+ : Widget("Image", ::elm_image_add(evasObject(parent)))
+{
+ evas_object_size_hint_weight_set(evasObject(this), EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+}
+
+Image::~Image()
+{
+}
+
+void Image::setFile(const std::string &path)
+{
+ ::elm_image_file_set(evasObject(this), path.c_str(), NULL);
+}
--- /dev/null
+/*
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 __ODE_IMAGE_H__
+#define __ODE_IMAGE_H__
+
+#include "widget.h"
+
+class Image : public Widget {
+public:
+ Image(Widget *parent);
+ ~Image();
+
+ void setFile(const std::string &path);
+};
+
+#endif
--- /dev/null
+/*
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 "layout.h"
+
+Layout::Layout(Widget *parent)
+ : Widget("Layout", ::elm_layout_add(Widget::evasObject(parent))), path("")
+{
+ ::elm_layout_theme_set(Widget::evasObject(this), "layout", "application", "default");
+}
+
+Layout::Layout(Widget *parent, const std::string &file, const std::string &group)
+ : Widget("Layout", ::elm_layout_add(Widget::evasObject(parent))), path("")
+{
+ setFile(file, group);
+}
+
+Layout::Layout(ConformantWindow *parent)
+ : Widget("Layout", ::elm_layout_add(Widget::evasObject(parent->getConformant()))), path("")
+{
+ ::elm_layout_theme_set(Widget::evasObject(this), "layout", "application", "default");
+}
+
+Layout::Layout(ConformantWindow *parent, const std::string &file, const std::string &group)
+ : Widget("Layout", ::elm_layout_add(Widget::evasObject(parent->getConformant()))), path("")
+{
+ setFile(file, group);
+}
+
+Layout::~Layout()
+{
+}
+
+void Layout::setTheme(const std::string &clas, const std::string &group, const std::string &style)
+{
+ ::elm_layout_theme_set(Widget::evasObject(this), clas.c_str(), group.c_str(), style.c_str());
+}
+
+void Layout::setFile(const std::string &file, const std::string &group)
+{
+ ::elm_layout_file_set(Widget::evasObject(this), file.c_str(), group.c_str());
+}
+
+Evas_Object *Layout::getEdje()
+{
+ return ::elm_layout_edje_get(Widget::evasObject(this));
+}
+
+void Layout::emitSignal(const std::string &signal, const std::string &source)
+{
+ ::edje_object_signal_emit(getEdje(), signal.c_str(), source.c_str());
+}
+
+void Layout::emitSignal(const std::string &signal, const std::string &source, const std::string &part, int col, int row)
+{
+ Evas_Object *item = nullptr;
+ item = ::edje_object_part_table_child_get(getEdje(), part.c_str(), col, row);
+ ::edje_object_signal_emit(item, signal.c_str(), source.c_str());
+}
+
+void Layout::setPartTableChildText(const std::string &part, int col, int row, const std::string &textPart, const std::string &text)
+{
+ Evas_Object *item = nullptr;
+ item = ::edje_object_part_table_child_get(getEdje(), part.c_str(), col, row);
+ ::edje_object_part_text_set(item, textPart.c_str(), text.c_str());
+}
--- /dev/null
+/*
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 __ODE_LAYOUT_H__
+#define __ODE_LAYOUT_H__
+
+#include "widget.h"
+#include "window.h"
+
+class Layout : public Widget {
+public:
+ Layout(Widget *parent);
+ Layout(Widget *parent, const std::string &file, const std::string &group);
+ Layout(ConformantWindow *parent);
+ Layout(ConformantWindow *parent, const std::string &file, const std::string &group);
+ ~Layout();
+
+ void setTheme(const std::string &clas, const std::string &group, const std::string &style);
+ void setFile(const std::string &file, const std::string &group);
+
+ Evas_Object *getEdje();
+ void emitSignal(const std::string &signal, const std::string &source);
+ void emitSignal(const std::string &signal, const std::string &source, const std::string &part, int col, int row);
+ void setPartTableChildText(const std::string &part, int col, int row, const std::string &textPart, const std::string &text);
+
+protected:
+ std::string path;
+};
+
+#endif
--- /dev/null
+/*
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 <dlog.h>
+#include "naviframe.h"
+
+static Eina_Bool naviframePopCallback(void *data, Elm_Object_Item *it)
+{
+ NaviframeItem *item = reinterpret_cast<NaviframeItem *>(data);
+ item->pagePopEvent.emit();
+ delete item;
+ return EINA_TRUE;
+}
+
+NaviframeItem::NaviframeItem(Widget *widget)
+ : parent(widget)
+{
+}
+
+NaviframeItem::~NaviframeItem()
+{
+ pagePopEvent.disconnectAll();
+}
+
+Naviframe::Naviframe(Widget *parent)
+ : Widget("Naviframe", ::elm_naviframe_add(evasObject(parent)))
+{
+ addEventHandler(EVAS_CALLBACK_KEY_DOWN, [this](void * event_info) {
+ this->keyDownEvent(event_info);
+ });
+}
+
+Naviframe::~Naviframe()
+{
+}
+
+void Naviframe::setAutoPrevButton(bool set)
+{
+ ::elm_naviframe_prev_btn_auto_pushed_set(evasObject(this), set);
+}
+
+void Naviframe::popItem()
+{
+ ::elm_naviframe_item_pop(evasObject(this));
+}
+
+void Naviframe::keyDownEvent(void *event_info)
+{
+ Evas_Event_Key_Down *ev = static_cast<Evas_Event_Key_Down *>(event_info);
+ if (!strcmp(ev->keyname, "XF86Back")) {
+ popItem();
+ }
+}
+
+NaviframeItem *Naviframe::pushPage(const std::string &title, Widget *content, Button *prevButton)
+{
+ Elm_Object_Item *nfitem = nullptr;
+ NaviframeItem *data = nullptr;
+
+ data = new NaviframeItem(this);
+ nfitem = ::elm_naviframe_item_push(evasObject(this),
+ title.c_str(),
+ evasObject(prevButton),
+ nullptr,
+ evasObject(content),
+ nullptr);
+
+ ::elm_naviframe_item_pop_cb_set(nfitem, naviframePopCallback, reinterpret_cast<void *>(data));
+ setFocus(true);
+ return data;
+}
--- /dev/null
+/*
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 __ODE_NAVIFRAME_H__
+#define __ODE_NAVIFRAME_H__
+
+#include <memory>
+#include "widget.h"
+#include "button.h"
+#include "signal.h"
+
+class NaviframeItem {
+public:
+ NaviframeItem(Widget *widget);
+ ~NaviframeItem();
+
+public:
+ Signal<> pagePopEvent;
+ Widget *parent;
+};
+
+class Naviframe : public Widget {
+public:
+ Naviframe(Widget *parent);
+ virtual ~Naviframe();
+
+ void setAutoPrevButton(bool set);
+ void keyDownEvent(void *event_info);
+ void popItem();
+ NaviframeItem *pushPage(const std::string &title, Widget *content, Button *prevButton);
+};
+
+#endif
--- /dev/null
+/*
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 "notification.h"
+
+Notification::Notification()
+{
+ notification = ::notification_create(NOTIFICATION_TYPE_NOTI);
+}
+
+Notification::~Notification()
+{
+ if (notification)
+ ::notification_free(notification);
+}
+
+void Notification::setTitle(const std::string &title)
+{
+ ::notification_set_text(notification, NOTIFICATION_TEXT_TYPE_TITLE,
+ title.c_str(), NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+}
+
+void Notification::setContent(const std::string &content)
+{
+ ::notification_set_text(notification, NOTIFICATION_TEXT_TYPE_CONTENT,
+ content.c_str(), NULL, NOTIFICATION_VARIABLE_TYPE_NONE);
+}
+
+void Notification::setImage(const std::string &path)
+{
+ ::notification_set_image(notification, NOTIFICATION_IMAGE_TYPE_THUMBNAIL, path.c_str());
+}
+
+void Notification::setAppControl(AppControl &appControl)
+{
+ ::notification_set_launch_option(notification, NOTIFICATION_LAUNCH_OPTION_APP_CONTROL, appControl);
+}
+
+void Notification::post()
+{
+ ::notification_post(notification);
+}
+
+void Notification::dispose()
+{
+ ::notification_delete(notification);
+}
--- /dev/null
+/*
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 __ODE_NOTIFICATION_H__
+#define __ODE_NOTIFICATION_H__
+
+#include <notification.h>
+#include "widget.h"
+#include "appcontrol.h"
+
+class Notification {
+public:
+ Notification();
+ ~Notification();
+
+ void setTitle(const std::string &title);
+ void setContent(const std::string &content);
+ void setImage(const std::string &path);
+ void setAppControl(AppControl &appcontrol);
+ void post();
+ void dispose();
+private:
+ notification_h notification;
+};
+
+#endif
--- /dev/null
+/*
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 "popup.h"
+
+Popup::Popup(Widget *parent)
+ : Widget("Popup", ::elm_popup_add(evasObject(parent))), leftButton(this), rightButton(this)
+{
+ onDispose = [this]() {
+ this->onDisposeSignal.emit();
+ };
+ onBackKeyEvent = [this]() {
+ };
+ addEventHandler(EVAS_CALLBACK_KEY_DOWN, [this](void *event_info) {
+ this->keyDownEvent(event_info);
+ });
+}
+
+Popup::~Popup()
+{
+}
+
+void Popup::keyDownEvent(void *info)
+{
+ Evas_Event_Key_Down *ev = static_cast<Evas_Event_Key_Down *>(info);
+ if (!strcmp(ev->keyname, "XF86Back")) {
+ this->onBackKeyEvent();
+ }
+}
+
+void Popup::setTimeOut(double time)
+{
+ ::elm_popup_timeout_set(evasObject(this), time);
+ addSmartHandler("timeout", [this](void *event_info) {
+ this->dispose();
+ });
+}
+
+void Popup::setAlign(double align)
+{
+ ::elm_popup_align_set(evasObject(this), ELM_NOTIFY_ALIGN_FILL, align);
+}
+
+void Popup::setTitleText(const std::string &text)
+{
+ setText("title,text", text.c_str());
+ ::elm_object_item_part_text_translatable_set(evasObject(this), "title,text", EINA_TRUE);
+}
+
+void Popup::setContentText(const std::string &text)
+{
+ setText(text);
+}
+
+void Popup::setButton(const std::string &text, SmartHandler &&handler)
+{
+ leftButton.setText(text);
+ leftButton.onClick = std::move(handler);
+ setContent("button1", &leftButton);
+}
+
+void Popup::setButton(const std::string &leftText, SmartHandler &&leftHandler, const std::string &rightText, SmartHandler &&rightHandler)
+{
+ leftButton.setText(leftText);
+ leftButton.onClick = std::move(leftHandler);
+ setContent("button1", &leftButton);
+
+ rightButton.setText(rightText);
+ rightButton.onClick = std::move(rightHandler);
+ setContent("button2", &rightButton);
+}
+
+MobileToastPopup::MobileToastPopup(Widget *parent)
+ : Popup(parent)
+{
+ setStyle("toast");
+ setTimeOut(3.0);
+}
+
+MobileToastPopup::~MobileToastPopup()
+{
+}
+
+WearableToastPopup::WearableToastPopup(Widget *parent)
+ : Popup(parent)
+{
+ setStyle("toast/circle");
+ setTimeOut(3.0);
+}
+
+WearableToastPopup::~WearableToastPopup()
+{
+}
+
+void WearableToastPopup::setContentText(const std::string &text)
+{
+ setText("elm.text", text);
+}
+
+MobileDefaultPopup::MobileDefaultPopup(Widget *parent)
+ : Popup(parent)
+{
+ setStyle("default");
+ setAlign(1.0);
+}
+
+MobileDefaultPopup::~MobileDefaultPopup()
+{
+}
+
+void MobileDefaultPopup::setButton(const std::string &text, SmartHandler &&handler)
+{
+ Popup::setButton(text, std::forward<SmartHandler>(handler));
+ leftButton.setStyle("popup");
+}
+
+void MobileDefaultPopup::setButton(const std::string &leftText, SmartHandler &&leftHandler, const std::string &rightText, SmartHandler &&rightHandler)
+{
+ Popup::setButton(leftText, std::forward<SmartHandler>(leftHandler), rightText, std::forward<SmartHandler>(rightHandler));
+ leftButton.setStyle("popup");
+ rightButton.setStyle("popup");
+}
+
+WearableDefaultPopup::WearableDefaultPopup(Widget *parent)
+ : Popup(parent), layout(this), leftButtonImage(&leftButton), rightButtonImage(&rightButton)
+{
+ setStyle("circle");
+ setAlign(1.0);
+ setContent(&layout);
+}
+
+WearableDefaultPopup::~WearableDefaultPopup()
+{
+}
+
+void WearableDefaultPopup::setTitleText(const std::string &text)
+{
+ layout.setText("elm.text.title", text.c_str());
+}
+
+void WearableDefaultPopup::setContentText(const std::string &text)
+{
+ layout.setText("elm.text", text.c_str());
+}
+
+void WearableDefaultPopup::setButton(const std::string &text, SmartHandler &&handler)
+{
+ layout.setTheme("layout", "popup", "content/circle/buttons1");
+
+ leftButton.setStyle("bottom");
+ leftButton.onClick = std::move(handler);
+
+ //leftButtonImage.setFile("/usr/apps/org.tizen.dpm-syspopup/res/images/tw_ic_popup_btn_delete.png");
+ leftButton.setContent(&leftButtonImage);
+}
+
+void WearableDefaultPopup::setButton(const std::string &leftText, SmartHandler &&leftHandler, const std::string &rightText, SmartHandler &&rightHandler)
+{
+ layout.setTheme("layout", "popup", "content/circle/buttons2");
+
+ leftButton.setStyle("popup/circle/left");
+ leftButton.onClick = std::move(leftHandler);
+
+ //leftButtonImage.setFile("/usr/apps/org.tizen.dpm-syspopup/res/images/tw_ic_popup_btn_delete.png");
+ leftButton.setContent(&leftButtonImage);
+
+ rightButton.setStyle("popup/circle/right");
+ rightButton.onClick = std::move(rightHandler);
+
+ //rightButtonImage.setFile("/usr/apps/org.tizen.dpm-syspopup/res/images/tw_ic_popup_btn_check.png");
+ rightButton.setContent(&rightButtonImage);
+}
--- /dev/null
+/*
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 __ODE_POPUP_H__
+#define __ODE_POPUP_H__
+
+#include <memory>
+
+#include "widget.h"
+#include "button.h"
+#include "layout.h"
+#include "image.h"
+#include "signal.h"
+
+struct PopupInfo {
+ int type;
+ std::string title;
+ std::string content;
+};
+
+class Popup : public Widget {
+public:
+ Popup(Widget *parent);
+ virtual ~Popup();
+
+ void keyDownEvent(void *info);
+ void setTimeOut(double time);
+ void setAlign(double align);
+
+ virtual void setTitleText(const std::string &text);
+ virtual void setContentText(const std::string &text);
+ virtual void setButton(const std::string &text, SmartHandler &&handler);
+ virtual void setButton(const std::string &leftText, SmartHandler &&leftHandler, const std::string &rightText, SmartHandler &&rightHandler);
+
+ std::function<void()> onBackKeyEvent;
+ Signal<> onDisposeSignal;
+
+ Button leftButton;
+ Button rightButton;
+};
+
+class MobileToastPopup : public Popup {
+public:
+ MobileToastPopup(Widget *parent);
+ ~MobileToastPopup();
+};
+
+class WearableToastPopup : public Popup {
+public:
+ WearableToastPopup(Widget *parent);
+ ~WearableToastPopup();
+
+ void setContentText(const std::string &text);
+};
+
+class MobileDefaultPopup : public Popup {
+public:
+ MobileDefaultPopup(Widget *parent);
+ ~MobileDefaultPopup();
+
+ void setButton(const std::string &text, SmartHandler &&handler);
+ void setButton(const std::string &leftText, SmartHandler &&leftHandler, const std::string &rightText, SmartHandler &&rightHandler);
+};
+
+class WearableDefaultPopup : public Popup {
+public:
+ WearableDefaultPopup(Widget *parent);
+ ~WearableDefaultPopup();
+
+ void setTitleText(const std::string &text);
+ void setContentText(const std::string &text);
+ void setButton(const std::string &text, SmartHandler &&handler);
+ void setButton(const std::string &leftText, SmartHandler &&leftHandler, const std::string &rightText, SmartHandler &&rightHandler);
+
+ Layout layout;
+
+ Image leftButtonImage;
+ Image rightButtonImage;
+};
+
+#endif /* __ODE_POPUP_H__ */
--- /dev/null
+/*
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 "progressbar.h"
+
+Progressbar::Progressbar(Widget *parent, int config)
+ : Widget("Progress", ::elm_progressbar_add(Widget::evasObject(parent)))
+{
+ setConfig(config);
+}
+
+Progressbar::~Progressbar()
+{
+}
+
+void Progressbar::setConfig(int config)
+{
+ if (config & SetPulse) {
+ ::elm_progressbar_pulse(Widget::evasObject(this), EINA_TRUE);
+ ::elm_progressbar_pulse_set(Widget::evasObject(this), EINA_TRUE);
+ }
+}
+
+void Progressbar::setValue(double value)
+{
+ ::elm_progressbar_value_set(Widget::evasObject(this), value);
+}
+
+double Progressbar::getValue()
+{
+ return ::elm_progressbar_value_get(Widget::evasObject(this));
+}
--- /dev/null
+/*
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 __ODE_PROGRESSBAR_H__
+#define __ODE_PROGRESSBAR_H__
+
+#include "widget.h"
+
+class Progressbar : public Widget {
+public:
+ enum Config {
+ SetPulse = (1 << 0),
+ };
+ Progressbar(Widget *parent, int config);
+ ~Progressbar();
+
+ void setValue(double value);
+ double getValue();
+ void setConfig(int config);
+};
+
+#endif
--- /dev/null
+/*
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 "radio.h"
+
+Radio::Radio(Widget *parent, Widget *group, int index)
+ : Widget("Radio", ::elm_radio_add(Widget::evasObject(parent)))
+{
+ setState(index);
+ addGroup(group);
+ addSmartHandler("changed", [this](void *) {
+ onChanged.emit(getState());
+ });
+}
+
+Radio::~Radio()
+{
+}
+
+void Radio::setState(int state)
+{
+ ::elm_radio_state_value_set(Widget::evasObject(this), state);
+}
+
+void Radio::setValue(int value)
+{
+ ::elm_radio_value_set(Widget::evasObject(this), value);
+}
+
+int Radio::getState(void)
+{
+ return ::elm_radio_state_value_get(Widget::evasObject(this));
+}
+
+void Radio::addGroup(Widget *group)
+{
+ if (group != nullptr) {
+ ::elm_radio_group_add(Widget::evasObject(this), Widget::evasObject(group));
+ }
+}
--- /dev/null
+/*
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 "widget.h"
+#include "signal.h"
+
+class Radio : public Widget {
+public:
+ Radio(Widget *parent, Widget *group, int index);
+ ~Radio();
+
+ void setState(int state);
+ void setValue(int value);
+ int getState(void);
+ void addGroup(Widget *group);
+
+ Signal<int> onChanged;
+};
--- /dev/null
+/*
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 __ODE_SIGNAL_H__
+#define __ODE_SIGNAL_H__
+
+#include <unordered_map>
+#include <functional>
+#include "widget.h"
+
+template <typename... Args>
+class Signal {
+public:
+ Signal() : nextId_(0) {
+ }
+
+ // copy creates new signal
+ Signal(Signal const &other) : nextId_(0) {
+ }
+
+ // connects a member function to this Signal
+ template <typename T>
+ int connect(T *instance, void (T::*function)(Args...)) {
+ return insert([ = ](Args... args) {
+ (instance->*function)(args...);
+ });
+ }
+
+ // connects a const member function to this Signal
+ template <typename T>
+ int connect(T *instance, void (T::*function)(Args...) const) {
+ return insert([ = ](Args... args) {
+ (instance->*function)(args...);
+ });
+ }
+
+ // connects a std::function to the signal. The returned
+ // value can be used to disconnect the function again
+ int insert(std::function<void(Args...)> const &slot) {
+ int id = nextId_;
+ slots_.insert(std::make_pair(++nextId_, slot));
+ return id;
+ }
+
+ // disconnects a previously connected function
+ void disconnect(int id) {
+ slots_.erase(id);
+ }
+
+ // disconnects all previously connected functions
+ void disconnectAll() {
+ slots_.clear();
+ }
+
+ // calls all connected functions
+ void emit(Args... p) {
+ for (auto it : slots_) {
+ it.second(p...);
+ }
+ }
+
+ // assignment creates new Signal
+ Signal &operator=(Signal const &other) {
+ disconnectAll();
+ }
+
+private:
+ std::unordered_map<int, std::function<void(Args...)>> slots_;
+ int nextId_;
+};
+
+#endif
--- /dev/null
+/*
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 "textblock.h"
+
+TextBlock::TextBlock(Widget *parent, const std::string &style, const std::string &text)
+ : Widget("Textblock", ::evas_object_textblock_add(evasObject(parent)))
+{
+ Evas_Textblock_Style *evasStyle = nullptr;
+ if (style.compare("")) {
+ evasStyle = ::evas_textblock_style_new();
+ ::evas_textblock_style_set(evasStyle, style.c_str());
+ ::evas_object_textblock_style_set(Widget::evasObject(this), evasStyle);
+ }
+ ::evas_object_textblock_text_markup_set(evasObject(this), text.c_str());
+ ::evas_textblock_style_free(evasStyle);
+}
+
+TextBlock::~TextBlock()
+{
+}
--- /dev/null
+/*
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 __ODE_TEXTBLOCK_H__
+#define __ODE_TEXTBLOCK_H__
+
+#include "widget.h"
+
+class TextBlock : public Widget {
+public:
+ TextBlock(Widget *parent, const std::string &style, const std::string &text);
+ ~TextBlock();
+};
+
+#endif
--- /dev/null
+/*
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 "timer.h"
+
+Timer::Timer()
+ : timer(nullptr)
+{
+ onTimer = [this]() {
+ return true;
+ };
+}
+
+Timer::~Timer()
+{
+ dispose();
+}
+
+void Timer::add(double interval)
+{
+ if (timer == nullptr)
+ timer = ::ecore_timer_add(interval, timerHandlerDispatcher, reinterpret_cast<Timer*>(this));
+}
+
+void Timer::dispose()
+{
+ if (timer != nullptr) {
+ ::ecore_timer_del(timer);
+ timer = nullptr;
+ }
+}
+
+Eina_Bool Timer::timerHandlerDispatcher(void *data)
+{
+ Timer *instance = reinterpret_cast<Timer *>(data);
+ return instance->onTimer();
+}
--- /dev/null
+/*
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 __ODE_TIMER_H__
+#define __ODE_TIMER_H__
+
+#include "widget.h"
+
+class Timer {
+public:
+ Timer();
+ virtual ~Timer();
+
+ void add(double interval);
+ void dispose();
+
+ static Eina_Bool timerHandlerDispatcher(void *data);
+public:
+ std::function<bool(void)> onTimer;
+private:
+ Ecore_Timer *timer;
+};
+
+#endif
--- /dev/null
+/*
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 "widget.h"
+
+Widget::Widget(const std::string &t, Evas_Object *obj)
+ : object(obj), tag(t), disposed(false)
+{
+ onShow = [this]() {
+ };
+ onHide = [this]() {
+ };
+ onDispose = [this]() {
+ };
+
+ addEventHandler(EVAS_CALLBACK_SHOW, [this](void * event_info) {
+ this->onShow();
+ });
+ addEventHandler(EVAS_CALLBACK_HIDE, [this](void * event_info) {
+ this->onHide();
+ });
+ addEventHandler(EVAS_CALLBACK_DEL, [this](void * event_info) {
+ this->onDispose();
+ });
+
+ ::evas_object_size_hint_weight_set(object, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+}
+
+Widget::~Widget()
+{
+ if (!disposed)
+ dispose();
+
+ eventList.clear();
+ smartList.clear();
+ ecoreList.clear();
+}
+
+void Widget::setResize(int width, int height)
+{
+ ::evas_object_resize(object, width, height);
+}
+
+void Widget::setText(const std::string &text)
+{
+ ::elm_object_text_set(object, text.c_str());
+}
+
+void Widget::setText(const std::string &part, const std::string &text)
+{
+ ::elm_object_part_text_set(object, part.c_str(), text.c_str());
+}
+
+void Widget::setStyle(const std::string &style)
+{
+ ::elm_object_style_set(object, style.c_str());
+}
+
+void Widget::setContent(Widget *content)
+{
+ ::elm_object_content_set(object, evasObject(content));
+}
+
+void Widget::setContent(const std::string &part, Widget *content)
+{
+ ::elm_object_part_content_set(object, part.c_str(), evasObject(content));
+}
+
+void Widget::setFocus(bool focused)
+{
+ ::elm_object_focus_set(object, focused);
+}
+
+void Widget::setPropagateEvent(bool set)
+{
+ ::evas_object_propagate_events_set(object, set);
+}
+
+void Widget::setRepeatEvent(bool set)
+{
+ ::evas_object_repeat_events_set(object, set);
+}
+
+void Widget::setDisabled(bool set)
+{
+ ::elm_object_disabled_set(object, set);
+}
+
+void Widget::show(void)
+{
+ ::evas_object_show(object);
+}
+
+void Widget::hide(void)
+{
+ ::evas_object_hide(object);
+}
+
+void Widget::dispose(void)
+{
+ if (disposed)
+ return;
+
+ disposed = true;
+ ::evas_object_del(object);
+}
+
+Evas_Object *Widget::evasObject(Widget *widget)
+{
+ return widget ? widget->object : nullptr;
+}
+
+void Widget::smartHandlerDispatcher(void *data, Evas_Object *obj, void *event_info)
+{
+ SmartHandler *handler = reinterpret_cast<SmartHandler *>(data);
+ (*handler)(event_info);
+}
+
+void Widget::eventHandlerDispatcher(void *data, Evas *evas, Evas_Object *obj, void *event_info)
+{
+ EventHandler *handler = reinterpret_cast<EventHandler *>(data);
+ (*handler)(event_info);
+}
+
+Eina_Bool Widget::ecoreHandlerDispatcher(void *data, int type, void *event)
+{
+ bool ret = EINA_FALSE;
+ EcoreHandler *handler = reinterpret_cast<EcoreHandler *>(data);
+ ret = (*handler)(event);
+ return ret;
+}
+
+void Widget::addEventHandler(Evas_Callback_Type type, EventHandler &&handler)
+{
+ eventList[type] = std::move(handler);
+ ::evas_object_event_callback_add(object, type, eventHandlerDispatcher, reinterpret_cast<void *>(&eventList[type]));
+}
+
+void Widget::addSmartHandler(const std::string &event, SmartHandler &&handler)
+{
+ smartList[event] = std::move(handler);
+ ::evas_object_smart_callback_add(object, event.c_str(), smartHandlerDispatcher, reinterpret_cast<void *>(&smartList[event]));
+}
+
+void Widget::addEcoreHandler(int type, EcoreHandler &&handler)
+{
+ ecoreList[type].handler = std::move(handler);
+ ecoreList[type].ecoreHandler = ::ecore_event_handler_add(type, ecoreHandlerDispatcher, reinterpret_cast<void *>(&ecoreList[type].handler));
+}
+
+void Widget::deleteEcoreHandler(int type)
+{
+ if (ecoreList.find(type) != ecoreList.end() && ecoreList[type].ecoreHandler != nullptr) {
+ ::ecore_event_handler_del(ecoreList[type].ecoreHandler);
+ }
+ ecoreList[type].ecoreHandler = nullptr;
+ ecoreList.erase(type);
+}
+
--- /dev/null
+/*
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 __ODE_WIDGET_H__
+#define __ODE_WIDGET_H__
+
+#include <memory>
+#include <functional>
+#include <unordered_map>
+
+#include <app.h>
+#include <app_common.h>
+#include <bundle.h>
+#include <system_settings.h>
+#include <Elementary.h>
+#include <efl_util.h>
+#include <klay/exception.h>
+
+class Widget {
+public:
+ typedef std::function<void(void *event)> EventHandler;
+ typedef std::function<void(void *event)> SmartHandler;
+ typedef std::function<Eina_Bool(void *event)> EcoreHandler;
+
+ virtual ~Widget();
+
+ void setResize(int width, int height);
+ void setText(const std::string &text);
+ void setText(const std::string &part, const std::string &text);
+ virtual void setStyle(const std::string &style);
+ virtual void setContent(Widget *content);
+ virtual void setContent(const std::string &part, Widget *content);
+ void setFocus(bool focused);
+ void setPropagateEvent(bool set);
+ void setRepeatEvent(bool set);
+ void setDisabled(bool set);
+
+ void show();
+ void hide();
+ void dispose();
+
+ void addEventHandler(Evas_Callback_Type type, EventHandler &&handler);
+ void addSmartHandler(const std::string &event, SmartHandler &&handler);
+ void addEcoreHandler(int type, EcoreHandler &&handler);
+ void deleteEcoreHandler(int type);
+
+ static void smartHandlerDispatcher(void *data, Evas_Object *obj, void *event_info);
+ static void eventHandlerDispatcher(void *data, Evas *evas, Evas_Object *obj, void *event_info);
+ static Eina_Bool ecoreHandlerDispatcher(void *data, int type, void *event);
+
+ std::function<void()> onShow;
+ std::function<void()> onHide;
+ std::function<void()> onDispose;
+
+protected:
+ Widget(const std::string &t, Evas_Object *obj);
+ virtual Evas_Object *evasObject(Widget *widget);
+
+protected:
+ std::unordered_map<int, EventHandler> eventList;
+ std::unordered_map<std::string, SmartHandler> smartList;
+
+ struct EcoreInfo {
+ EcoreInfo() : ecoreHandler(nullptr) {
+ }
+ EcoreHandler handler;
+ Ecore_Event_Handler *ecoreHandler;
+ };
+ std::unordered_map<int, EcoreInfo> ecoreList;
+private:
+ Evas_Object *object;
+ std::string tag;
+ bool disposed;
+};
+
+#endif /* __WIDGET_H__ */
--- /dev/null
+/*
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 "window.h"
+
+Window::Window(const std::string &packageName, Elm_Win_Type type)
+ : Widget("Window", ::elm_win_add(NULL, packageName.c_str(), type))
+{
+ setConfig(Config::SetRotate | Config::SetAutoDelete | Config::SetBorderless);
+ show();
+}
+
+Window::~Window()
+{
+}
+
+void Window::setRotate()
+{
+ int rots[] = {0, 90, 180, 270};
+
+ if (::elm_win_wm_rotation_supported_get(Widget::evasObject(this)))
+ ::elm_win_wm_rotation_available_rotations_set(Widget::evasObject(this), rots, 4);
+}
+
+void Window::setConfig(int config)
+{
+ if (config & Config::SetRotate)
+ setRotate();
+ if (config & Config::SetBorderless)
+ ::elm_win_borderless_set(Widget::evasObject(this), EINA_TRUE);
+ if (config & Config::SetAlpha)
+ ::elm_win_alpha_set(Widget::evasObject(this), EINA_TRUE);
+ if (config & Config::SetAutoDelete)
+ ::elm_win_autodel_set(Widget::evasObject(this), EINA_TRUE);
+ if (config & Config::SetConformant)
+ ::elm_win_conformant_set(Widget::evasObject(this), EINA_TRUE);
+ if (config & Config::SetIndicator)
+ ::elm_win_indicator_mode_set(Widget::evasObject(this), ELM_WIN_INDICATOR_SHOW);
+}
+
+void Window::setNotificationLevel(efl_util_notification_level_e level)
+{
+ ::efl_util_set_notification_window_level(Widget::evasObject(this), level);
+}
+
+void Window::setIndicatorOpacity(Elm_Win_Indicator_Opacity_Mode mode)
+{
+ ::elm_win_indicator_opacity_set(Widget::evasObject(this), mode);
+}
+
+void Window::resize(Widget *widget)
+{
+ ::elm_win_resize_object_add(Widget::evasObject(this), Widget::evasObject(widget));
+}
+
+Conformant::Conformant(Window *window)
+ : Widget("Conformant", ::elm_conformant_add(Widget::evasObject(window)))
+{
+ window->setConfig(Window::Config::SetConformant | Window::Config::SetIndicator);
+ window->resize(this);
+}
+
+Conformant::~Conformant()
+{
+}
+
+ConformantWindow::ConformantWindow(const std::string &packageName, Elm_Win_Type type)
+ : Window(packageName, type), conformant(new Conformant(this))
+{
+ setConfig(Config::SetConformant | Config::SetIndicator);
+ conformant->show();
+}
+
+ConformantWindow::~ConformantWindow()
+{
+ if (conformant) {
+ delete conformant;
+ }
+}
+
+void ConformantWindow::setContent(Widget *content)
+{
+ conformant->setContent(content);
+}
+
+Conformant *ConformantWindow::getConformant()
+{
+ return conformant;
+}
+
+void ConformantWindow::setIndicatorOverlap(bool set)
+{
+ if (set) {
+ ::elm_object_signal_emit(Widget::evasObject(conformant), "elm,state,indicator,overlap", "elm");
+ }
+}
--- /dev/null
+/*
+ *
+ * Copyright (c) 2017 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 __ODE_WINDOW_H__
+#define __ODE_WINDOW_H__
+
+#include "widget.h"
+
+class Window : public Widget {
+public:
+ enum Config {
+ SetRotate = (1 << 0),
+ SetBorderless = (1 << 1),
+ SetAlpha = (1 << 2),
+ SetConformant = (1 << 3),
+ SetAutoDelete = (1 << 4),
+ SetIndicator = (1 << 5),
+ };
+
+ Window(const std::string &packageName, Elm_Win_Type type);
+ virtual ~Window();
+
+ void setConfig(int config);
+ void setNotificationLevel(efl_util_notification_level_e level);
+ void setIndicatorOpacity(Elm_Win_Indicator_Opacity_Mode mode);
+ void resize(Widget *widget);
+
+protected:
+ void setRotate();
+};
+
+class Conformant : public Widget {
+public:
+ Conformant(Window *window);
+ ~Conformant();
+};
+
+class ConformantWindow : public Window {
+public:
+ ConformantWindow(const std::string &packageName, Elm_Win_Type type);
+ ~ConformantWindow();
+
+ Conformant *getConformant();
+ void setContent(Widget *content);
+ void setIndicatorOverlap(bool set);
+
+private:
+ Conformant *conformant;
+};
+
+#endif /*__ODE_WINDOW_H__*/