badge
capi-appfw-application
capi-appfw-preference
+ capi-appfw-widget-application
capi-base-utils-i18n
capi-system-system-settings
contacts-service2
libtzplatform-config
notification
storage
+ widget_service
)
set(INCLUDES "${TIZEN_PACKAGES_INCLUDE_DIRS};inc")
--- /dev/null
+/*
+ * Copyright (c) 2015 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 APP_WIDGET_H
+#define APP_WIDGET_H
+
+#include <widget_app.h>
+#include <widget_service.h>
+
+namespace Ui
+{
+ class Window;
+}
+
+namespace App
+{
+ /**
+ * @brief Homescreen widget base class.
+ */
+ class EXPORT_API Widget
+ {
+ public:
+ Widget();
+ virtual ~Widget();
+
+ /**
+ * @brief Create widget.
+ * @param[in] context Widget context
+ * @param[in] content Widget content bundle
+ */
+ void create(widget_context_h context, bundle *content);
+
+ /**
+ * @brief Resize widget.
+ * @param[in] width Widget new width
+ * @param[in] height Widget new height
+ */
+ void resize(int width, int height);
+
+ /**
+ * @return Widget width.
+ */
+ int getWidth() const;
+
+ /**
+ * @return Widget height.
+ */
+ int getHeight() const;
+
+ /**
+ * @return Widget type.
+ * @see widget_size_type_e
+ */
+ widget_size_type_e getType() const;
+
+ /**
+ * @return Widget window.
+ */
+ Ui::Window *getWindow() const;
+
+ protected:
+ /**
+ * @brief Save widget content bundle.
+ * @param[in] content Content to save
+ */
+ void saveContent(bundle *content);
+
+ /**
+ * @brief Called when widget is created.
+ * @param[in] content Widget content bundle
+ */
+ virtual void onCreate(bundle *content) { }
+
+ /**
+ * @brief Called when widget is destroyed.
+ * @param[in] reason Reason for destruction
+ */
+ virtual void onDestroy(widget_app_destroy_type_e reason) { }
+
+ /**
+ * @brief Called when widget is paused.
+ */
+ virtual void onPause() { }
+
+ /**
+ * @brief Called when widget is resumed.
+ */
+ virtual void onResume() { }
+
+ /**
+ * @brief Called when widget is resized.
+ * @param[in] width Widget new width
+ * @param[in] height Widget new height
+ */
+ virtual void onResize(int width, int height) { }
+
+ /**
+ * @brief Called when widget is updated.
+ * @param[in] force Whether widget was forcefully updated
+ */
+ virtual void onUpdate(int force) { }
+
+ private:
+ friend class WidgetApplication;
+
+ widget_context_h m_Context;
+ int m_Width;
+ int m_Height;
+ Ui::Window *m_Window;
+ };
+}
+
+#endif /* APP_WIDGET_H */
--- /dev/null
+/*
+ * Copyright (c) 2015 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 APP_WIDGET_APPLICATION_H
+#define APP_WIDGET_APPLICATION_H
+
+#include <widget_app.h>
+
+namespace App
+{
+ class Widget;
+
+ /**
+ * @brief Widget application lifecycle controller.
+ */
+ class EXPORT_API WidgetApplication
+ {
+ public:
+ /**
+ * @brief Run application main loop.
+ * @param[in] argc argc parameter received in main()
+ * @param[in] argv argv parameter received in main()
+ */
+ int run(int argc, char **argv);
+
+ protected:
+ virtual ~WidgetApplication() { }
+
+ /**
+ * @brief Called when application is created.
+ */
+ virtual void onCreate() { }
+
+ /**
+ * @brief Called when application is terminated.
+ */
+ virtual void onTerminate() { }
+
+ /**
+ * @return Create widget instance.
+ */
+ virtual Widget *createWidget() = 0;
+
+ private:
+ widget_class_h onWidgetClassCreate();
+
+ static Widget *getWidget(widget_context_h context);
+
+ static int onWidgetCreate(widget_context_h context,
+ bundle *content, int width, int height, void *data);
+ static int onWidgetDestroy(widget_context_h context,
+ widget_app_destroy_type_e reason, bundle *content, void *data);
+
+ static int onWidgetPause(widget_context_h context, void *data);
+ static int onWidgetResume(widget_context_h context, void *data);
+
+ static int onWidgetResize(widget_context_h context,
+ int width, int height, void *data);
+ static int onWidgetUpdate(widget_context_h context,
+ bundle *content, int force, void *data);
+ };
+}
+
+#endif /* APP_WIDGET_APPLICATION_H */
--- /dev/null
+/*
+ * Copyright (c) 2015 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 APP_WIDGET_WINDOW_H
+#define APP_WIDGET_WINDOW_H
+
+#include "Ui/Window.h"
+#include <widget_app.h>
+
+namespace App
+{
+ class EXPORT_API WidgetWindow : public Ui::Window
+ {
+ public:
+ /**
+ * @brief Create WidgetWindow.
+ * @param[in] context Widget context
+ */
+ WidgetWindow(widget_context_h context);
+
+ protected:
+ /**
+ * @see Window::onWindowCreate()
+ */
+ virtual Evas_Object *onWindowCreate();
+
+ private:
+ widget_context_h m_Context;
+ };
+}
+
+#endif /* APP_WIDGET_WINDOW_H */
*/
void attachView(View *view);
- private:
+ protected:
+ /**
+ * @see Control::onCreate()
+ */
virtual Evas_Object *onCreate(Evas_Object *parent) override;
+
+ /**
+ * @brief Called to create window Evas_Object.
+ * @return Window Evas_Object.
+ */
+ virtual Evas_Object *onWindowCreate();
+
+ private:
void onBackPressed(Evas_Object *obj, void *eventInfo);
void onMenuPressed(Evas_Object *obj, void *eventInfo);
--- /dev/null
+/*
+ * Copyright (c) 2015 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 "App/Widget.h"
+#include "App/WidgetWindow.h"
+
+using namespace App;
+
+Widget::Widget()
+ : m_Context(nullptr), m_Width(0), m_Height(0), m_Window(nullptr)
+{
+}
+
+Widget::~Widget()
+{
+ delete m_Window;
+}
+
+void Widget::create(widget_context_h context, bundle *content)
+{
+ m_Context = context;
+ m_Window = new WidgetWindow(m_Context);
+ m_Window->create(nullptr);
+ onCreate(content);
+}
+
+void Widget::resize(int width, int height)
+{
+ m_Width = width;
+ m_Height = height;
+
+ evas_object_resize(m_Window->getEvasObject(), m_Width, m_Height);
+ evas_object_resize(m_Window->getBaseLayout(), m_Width, m_Height);
+
+ onResize(m_Width, m_Height);
+}
+
+int Widget::getWidth() const
+{
+ return m_Width;
+}
+
+int Widget::getHeight() const
+{
+ return m_Height;
+}
+
+widget_size_type_e Widget::getType() const
+{
+ widget_size_type_e type = WIDGET_SIZE_TYPE_UNKNOWN;
+ widget_service_get_size_type(m_Width, m_Height, &type);
+ return type;
+}
+
+Ui::Window *Widget::getWindow() const
+{
+ return m_Window;
+}
+
+void Widget::saveContent(bundle *content)
+{
+ widget_app_context_set_content_info(m_Context, content);
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 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 "App/WidgetApplication.h"
+#include "App/Widget.h"
+#include "Utils/Callback.h"
+
+using namespace App;
+
+int WidgetApplication::run(int argc, char **argv)
+{
+ widget_app_lifecycle_callback_s cbs;
+ cbs.create = makeCallback(&WidgetApplication::onWidgetClassCreate);
+ cbs.terminate = makeCallback(&WidgetApplication::onTerminate);
+
+ return widget_app_main(argc, argv, &cbs, this);
+}
+
+widget_class_h WidgetApplication::onWidgetClassCreate()
+{
+ widget_instance_lifecycle_callback_s cbs;
+ cbs.create = &WidgetApplication::onWidgetCreate;
+ cbs.destroy = &WidgetApplication::onWidgetDestroy;
+ cbs.pause = &WidgetApplication::onWidgetPause;
+ cbs.resume = &WidgetApplication::onWidgetResume;
+ cbs.resize = &WidgetApplication::onWidgetResize;
+ cbs.update = &WidgetApplication::onWidgetUpdate;
+
+ onCreate();
+ return widget_app_class_create(cbs, this);
+}
+
+Widget *App::WidgetApplication::getWidget(widget_context_h context)
+{
+ Widget *widget= nullptr;
+ widget_app_context_get_tag(context, (void **) &widget);
+ return widget;
+}
+
+int WidgetApplication::onWidgetCreate(widget_context_h context,
+ bundle *content, int width, int height, void *data)
+{
+ WidgetApplication *app = (WidgetApplication *) data;
+ Widget *widget = app->createWidget();
+ if (!widget) {
+ return WIDGET_ERROR_FAULT;
+ }
+
+ widget_app_context_set_tag(context, widget);
+ widget->create(context, content);
+ widget->resize(width, height);
+ return WIDGET_ERROR_NONE;
+}
+
+int WidgetApplication::onWidgetDestroy(widget_context_h context,
+ widget_app_destroy_type_e reason, bundle *content, void *data)
+{
+ Widget *widget = getWidget(context);
+ widget->onDestroy(reason);
+ delete widget;
+ return WIDGET_ERROR_NONE;
+}
+
+int WidgetApplication::onWidgetPause(widget_context_h context, void *data)
+{
+ getWidget(context)->onPause();
+ return WIDGET_ERROR_NONE;
+}
+
+int WidgetApplication::onWidgetResume(widget_context_h context, void *data)
+{
+ getWidget(context)->onResume();
+ return WIDGET_ERROR_NONE;
+}
+
+int WidgetApplication::onWidgetResize(widget_context_h context,
+ int width, int height, void *data)
+{
+ getWidget(context)->resize(width, height);
+ return WIDGET_ERROR_NONE;
+}
+
+int WidgetApplication::onWidgetUpdate(widget_context_h context,
+ bundle *content, int force, void *data)
+{
+ getWidget(context)->onUpdate(force);
+ return WIDGET_ERROR_NONE;
+}
--- /dev/null
+/*
+ * Copyright (c) 2015 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 "App/WidgetWindow.h"
+#include <widget_app_efl.h>
+
+using namespace App;
+
+WidgetWindow::WidgetWindow(widget_context_h context)
+ : m_Context(context)
+{
+}
+
+Evas_Object *WidgetWindow::onWindowCreate()
+{
+ Evas_Object *window = nullptr;
+ widget_app_get_elm_win(m_Context, &window);
+ evas_object_show(window);
+ return window;
+}
{
}
-Evas_Object *Window::onCreate(Evas_Object *parent)
+Evas_Object *Window::getConformant() const
{
- Evas_Object *window = elm_win_add(nullptr, nullptr, ELM_WIN_BASIC);
- elm_win_indicator_mode_set(window, ELM_WIN_INDICATOR_SHOW);
- elm_win_conformant_set(window, EINA_TRUE);
- evas_object_show(window);
+ return m_Conform;
+}
- Evas_Object *bg = elm_bg_add(window);
- evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
- elm_win_resize_object_add(window, bg);
- evas_object_show(bg);
+Evas_Object *Window::getBaseLayout() const
+{
+ return m_Layout;
+}
+
+void Window::attachView(View *view)
+{
+ m_MainView = view;
+ elm_object_part_content_set(m_Layout, "elm.swallow.content", view->create(m_Layout));
+}
+
+Evas_Object *Window::onCreate(Evas_Object *parent)
+{
+ Evas_Object *window = onWindowCreate();
m_Conform = elm_conformant_add(window);
evas_object_size_hint_weight_set(m_Conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
elm_object_content_set(m_Conform, m_Layout);
evas_object_show(m_Layout);
+ Evas_Object *bg = elm_bg_add(m_Layout);
+ evas_object_color_set(bg, 255, 255, 255, 0);
+ evas_object_show(bg);
+ elm_object_part_content_set(m_Layout, "elm.swallow.bg", bg);
+
eext_object_event_callback_add(m_Layout, EEXT_CALLBACK_BACK,
makeCallback(&Window::onBackPressed), this);
eext_object_event_callback_add(m_Layout, EEXT_CALLBACK_MORE,
return window;
}
-Evas_Object *Window::getConformant() const
+Evas_Object *Window::onWindowCreate()
{
- return m_Conform;
-}
-
-Evas_Object *Window::getBaseLayout() const
-{
- return m_Layout;
-}
-
-void Window::attachView(View *view)
-{
- m_MainView = view;
- elm_object_part_content_set(m_Layout, "elm.swallow.content", view->create(m_Layout));
+ Evas_Object *window = elm_win_add(nullptr, nullptr, ELM_WIN_BASIC);
+ elm_win_indicator_mode_set(window, ELM_WIN_INDICATOR_SHOW);
+ elm_win_conformant_set(window, EINA_TRUE);
+ evas_object_show(window);
+ return window;
}
void Window::onBackPressed(Evas_Object *obj, void *eventInfo)
BuildRequires: pkgconfig(badge)
BuildRequires: pkgconfig(capi-appfw-application)
BuildRequires: pkgconfig(capi-appfw-preference)
+BuildRequires: pkgconfig(capi-appfw-widget-application)
BuildRequires: pkgconfig(capi-base-utils-i18n)
BuildRequires: pkgconfig(capi-system-system-settings)
BuildRequires: pkgconfig(contacts-service2)
BuildRequires: pkgconfig(libtzplatform-config)
BuildRequires: pkgconfig(notification)
BuildRequires: pkgconfig(storage)
+BuildRequires: pkgconfig(widget_service)
%description
Contacts and Phone Reference Applications.