add view_home 97/41197/1
authorSoohye Shin <soohye.shin@samsung.com>
Thu, 11 Jun 2015 12:18:44 +0000 (21:18 +0900)
committerSoohye Shin <soohye.shin@samsung.com>
Thu, 11 Jun 2015 12:19:12 +0000 (21:19 +0900)
Change-Id: Iaba40175fde2c7aec11beef1d9096fb77186531d
Signed-off-by: Soohye Shin <soohye.shin@samsung.com>
CMakeLists.txt
include/defs.h
include/view_home.h [new file with mode: 0644]
src/main.c
src/view/view_home.c [new file with mode: 0644]

index a279fcd..92a4c14 100644 (file)
@@ -40,7 +40,8 @@ ENDIF(NOT DEFINED MANIFESTDIR)
 SET(TARGET_EDJ "${PROJECT_NAME}.edj")
 SET(DEFCONFIG "${PROJECT_NAME}.json")
 SET(SRCS
-               src/main.c)
+               src/main.c
+               src/view/view_home.c)
 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
 ADD_DEFINITIONS("-DPACKAGE=\"${PACKAGE_NAME}\"")
 ADD_DEFINITIONS("-DEDJEDIR=\"${EDJEDIR}\"")
index d51708a..af6549d 100644 (file)
 #ifndef __AIR_HOME_DEFS_H__
 #define __AIR_HOME_DEFS_H__
 
+#define VIEW_HOME "VIEW_HOME"
+#define VIEW_RECENT "VIEW_RECENT"
+#define VIEW_USER "VIEW_USER"
+
 #define SRC_PROG "prog"
 
 #define GRP_HOME "group.home"
diff --git a/include/view_home.h b/include/view_home.h
new file mode 100644 (file)
index 0000000..d8b811d
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ * 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 __AIR_HOME_VIEW_HOME_H__
+#define __AIR_HOME_VIEW_HOME_H__
+
+view_class *view_home_get_vclass(void);
+
+#endif /* __AIR_HOME_VIEW_HOME_H__ */
index 4e98a9d..8dfcaa0 100644 (file)
 #include <app.h>
 #include <Elementary.h>
 #include <app_debug.h>
+#include <viewmgr.h>
 
 #include "defs.h"
+#include "view_home.h"
 
 SET_TAG(PACKAGE);
 
@@ -62,6 +64,14 @@ static bool _create(void *user_data)
                return false;
        }
 
+       if (!viewmgr_create(win)) {
+               _ERR("failed to create viewmgr");
+               evas_object_del(win);
+               return false;
+       }
+
+       viewmgr_add_view(view_home_get_vclass(), NULL);
+
        ad->win = win;
 
        return true;
@@ -76,6 +86,9 @@ static void _terminate(void *user_data)
 
        ad = user_data;
 
+       viewmgr_remove_view(VIEW_HOME);
+       viewmgr_destroy();
+
        if (ad->win)
                evas_object_del(ad->win);
 }
@@ -101,7 +114,10 @@ static void _control(app_control_h app_control, void *user_data)
 
        ad = user_data;
 
-       evas_object_show(ad->win);
+       if (ad->win)
+               elm_win_activate(ad->win);
+
+       viewmgr_push_view(VIEW_HOME);
 }
 
 int main(int argc, char **argv)
diff --git a/src/view/view_home.c b/src/view/view_home.c
new file mode 100644 (file)
index 0000000..39b1eca
--- /dev/null
@@ -0,0 +1,175 @@
+/*
+
+ * 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 <Elementary.h>
+#include <app_debug.h>
+#include <viewmgr.h>
+#include <inputmgr.h>
+
+#include "defs.h"
+#include "view_home.h"
+
+struct _priv {
+       Evas_Object *win;
+       Evas_Object *base;
+};
+
+static bool _add_navigations(Evas_Object *base)
+{
+       Evas_Object *ly;
+
+       if (!base) {
+               _ERR("Invalid argument");
+               return false;
+       }
+
+       ly = elm_layout_add(base);
+       if (!ly) {
+               _ERR("failed to add layout");
+               return false;
+       }
+       elm_layout_file_set(ly, EDJEFILE, GRP_HOME_DOWN_ARROW);
+       elm_object_focus_allow_set(ly, EINA_TRUE);
+       elm_object_part_content_set(base, PART_HOME_DOWN_ARROW, ly);
+
+       ly = elm_layout_add(base);
+       if (!ly) {
+               _ERR("failed to add layout");
+               return false;
+       }
+       elm_layout_file_set(ly, EDJEFILE, GRP_HOME_UP_ARROW);
+       elm_object_focus_allow_set(ly, EINA_TRUE);
+       elm_object_part_content_set(base, PART_HOME_UP_ARROW, ly);
+
+       return true;
+}
+
+static bool _add_home(struct _priv *priv, Evas_Object *base)
+{
+       if (!priv || !base) {
+               _ERR("Invalid argument");
+               return false;
+       }
+
+       if (!_add_navigations(base)) {
+               _ERR("failed to add navigations");
+               return false;
+       }
+
+       /* It should be implemented later */
+
+       return true;
+}
+
+static Evas_Object *_create(Evas_Object *win, void *data)
+{
+       struct _priv *priv;
+       Evas_Object *base;
+
+       if (!win) {
+               _ERR("Invalid argument");
+               return NULL;
+       }
+
+       priv = calloc(1, sizeof(*priv));
+       if (!priv) {
+               _ERR("failed to calloc priv");
+               return NULL;
+       }
+
+       base = elm_layout_add(win);
+       if (!base) {
+               _ERR("failed to create base");
+               free(priv);
+               return NULL;
+       }
+       elm_layout_file_set(base, EDJEFILE, GRP_HOME);
+       evas_object_size_hint_weight_set(base, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
+       elm_win_resize_object_add(win, base);
+
+       priv->win = win;
+       priv->base = base;
+
+       if (!_add_home(priv, base)) {
+               _ERR("failed to load home");
+               evas_object_del(base);
+               free(priv);
+               return NULL;
+       }
+
+       viewmgr_set_view_data(VIEW_HOME, priv);
+
+       return base;
+}
+
+static void _show(void *data)
+{
+       struct _priv *priv;
+
+       if (!data) {
+               _ERR("Invalid argument");
+               return;
+       }
+
+       priv = data;
+
+       evas_object_show(priv->base);
+       elm_object_signal_emit(priv->base, SIG_SHOW_NAVIGATION, SRC_PROG);
+}
+
+static void _hide(void *data)
+{
+       struct _priv *priv;
+
+       if (!data) {
+               _ERR("Invalid argument");
+               return;
+       }
+
+       priv = data;
+
+       evas_object_hide(priv->base);
+}
+
+static void _destroy(void *data)
+{
+       struct _priv *priv;
+
+       if (!data) {
+               _ERR("Invalid argument");
+               return;
+       }
+
+       priv = data;
+
+       evas_object_del(priv->base);
+       free(priv);
+}
+
+static view_class vclass = {
+       .view_id = VIEW_HOME,
+       .create = _create,
+       .show = _show,
+       .hide = _hide,
+       .destroy = _destroy
+};
+
+view_class *view_home_get_vclass(void)
+{
+       return &vclass;
+}
+