add main view 04/46504/2
authorSoohye Shin <soohye.shin@samsung.com>
Fri, 21 Aug 2015 07:41:46 +0000 (16:41 +0900)
committerSoohye Shin <soohye.shin@samsung.com>
Fri, 21 Aug 2015 07:48:14 +0000 (16:48 +0900)
Change-Id: I2b6116547b194789831b82dff729f2788aac9e10
Signed-off-by: Soohye Shin <soohye.shin@samsung.com>
CMakeLists.txt
edje/etg.edc
edje/view/main.edc [new file with mode: 0644]
include/defs.h
include/utils.h [new file with mode: 0644]
include/view.h [new file with mode: 0644]
src/main.c
src/utils.c [new file with mode: 0644]
src/view/view_main.c [new file with mode: 0644]

index e9f4ccd..8756714 100644 (file)
@@ -33,7 +33,9 @@ ENDIF(NOT DEFINED MANIFESTDIR)
 
 SET(TARGET_EDJ "${PROJECT_NAME}.edj")
 SET(SRCS
-               src/main.c)
+               src/main.c
+               src/utils.c
+               src/view/view_main.c)
 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
 ADD_DEFINITIONS("-DPACKAGE=\"${PACKAGE_NAME}\"")
 ADD_DEFINITIONS("-DEDJEDIR=\"${EDJEDIR}\"")
index 2c43ca4..cb346ec 100644 (file)
@@ -17,4 +17,5 @@
 #include "../include/defs.h"
 
 collections {
+       #include "view/main.edc"
 }
diff --git a/edje/view/main.edc b/edje/view/main.edc
new file mode 100644 (file)
index 0000000..497ccc4
--- /dev/null
@@ -0,0 +1,104 @@
+/*
+ * 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.
+ */
+
+group {
+       name, GRP_MAIN;
+       parts {
+               part {
+                       name, "bg";
+                       type, RECT;
+                       scale, 1;
+                       description {
+                               state, "default" 0.0;
+                               color, 244 244 244 255;
+                       }
+               }
+               part {
+                       name, "bg.title";
+                       type, RECT;
+                       scale, 1;
+                       description {
+                               state, "default" 0.0;
+                               rel2.relative, 1.0 0.0;
+                               min, 0 184;
+                               fixed, 0 1;
+                               align, 0.5 0.0;
+                               color, 255 255 255 255;
+                       }
+               }
+               part {
+                       name, "pad.title";
+                       type, RECT;
+                       scale, 1;
+                       description {
+                               state, "default" 0.0;
+                               rel1 {
+                                       to, "bg.title";
+                                       relative, 0.5 0.0;
+                               }
+                               rel2 {
+                                       to, "bg.title";
+                                       relative, 0.5 0.0;
+                               }
+                               min, 0 44;
+                               fixed, 1 1;
+                               align, 0.5 0.0;
+                               visible, 0;
+                       }
+               }
+               part {
+                       name, "title";
+                       type, TEXT;
+                       scale, 1;
+                       description {
+                               state, "default" 0.0;
+                               rel1 {
+                                       to, "pad.title";
+                                       relative, 0.5 1.0;
+                               }
+                               rel2 {
+                                       to, "pad.title";
+                                       relative, 0.5 1.0;
+                               }
+                               align, 0.5 0.0;
+                               fixed, 1 1;
+                               min, 300 46;
+                               text {
+                                       font, "TizenSans";
+                                       size, 44;
+                                       text, "ETG";
+                               }
+                               color, 51 51 51 255;
+                       }
+               }
+               part {
+                       name, PART_MAIN_MENU;
+                       type, SWALLOW;
+                       scale, 1;
+                       description {
+                               state, "default" 0.0;
+                               rel1 {
+                                       to, "bg.title";
+                                       relative, 0.0 1.0;
+                               }
+                               rel2.to, "bg.title";
+                               align, 0.5 1.0;
+                               fixed, 0 1;
+                               min, 0 82;
+                       }
+               }
+       }
+}
index 996fa87..731f295 100644 (file)
 #ifndef __AIR_ETG_DEFS_H__
 #define __AIR_ETG_DEFS_H__
 
+#define VIEW_MAIN "VIEW_MAIN"
+
+#define GRP_MAIN "group.main"
+
+#define PART_MAIN_MENU "part.main.menu"
+
 #endif /* __AIR_ETG_DEFS_H__ */
diff --git a/include/utils.h b/include/utils.h
new file mode 100644 (file)
index 0000000..bb02ac8
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * 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_ETG_UTILS_H__
+#define __AIR_ETG_UTILS_H__
+
+#include <Evas.h>
+
+Evas_Object *utils_add_layout(Evas_Object *base, const char *group,
+               bool focus_allow, const char *part);
+
+#endif /* __AIR_ETG_UTILS_H__ */
diff --git a/include/view.h b/include/view.h
new file mode 100644 (file)
index 0000000..7cedcce
--- /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_ETG_VIEW_H__
+#define __AIR_ETG_VIEW_H__
+
+view_class *view_main_get_vclass(void);
+
+#endif /* __AIR_ETG_VIEW_H__ */
index 47b494f..c46ef65 100644 (file)
 #include <app.h>
 #include <Elementary.h>
 #include <app_debug.h>
+#include <viewmgr.h>
 
 #include "defs.h"
+#include "view.h"
 
 SET_TAG(PACKAGE);
 
@@ -45,7 +47,6 @@ static Evas_Object *_add_win(const char *name)
 static bool _create(void *user_data)
 {
        struct _appdata *ad;
-       Evas_Object *win;
 
        if (!user_data) {
                _ERR("Invalid argument");
@@ -56,13 +57,20 @@ static bool _create(void *user_data)
 
        elm_config_focus_move_policy_set(ELM_FOCUS_MOVE_POLICY_CLICK);
 
-       win = _add_win(ad->name);
-       if (!win) {
+       ad->win = _add_win(ad->name);
+       if (!ad->win) {
                _ERR("failed to create window");
                return false;
        }
 
-       ad->win = win;
+       if (!viewmgr_create(ad->win)) {
+               _ERR("failed to create viewmgr");
+               evas_object_del(ad->win);
+               ad->win = NULL;
+               return false;
+       }
+
+       viewmgr_add_view(view_main_get_vclass(), NULL);
 
        return true;
 }
@@ -76,8 +84,10 @@ static void _terminate(void *user_data)
 
        ad = user_data;
 
-       if (ad->win)
+       if (ad->win) {
+               viewmgr_destroy();
                evas_object_del(ad->win);
+       }
 }
 
 static void _pause(void *user_data)
@@ -103,7 +113,7 @@ static void _control(app_control_h app_control, void *user_data)
 
        if (ad->win) {
                elm_win_activate(ad->win);
-               evas_object_show(ad->win);
+               viewmgr_push_view(VIEW_MAIN);
        }
 }
 
diff --git a/src/utils.c b/src/utils.c
new file mode 100644 (file)
index 0000000..74a1492
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * 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 <stdbool.h>
+#include <app.h>
+
+#include "utils.h"
+#include "defs.h"
+
+Evas_Object *utils_add_layout(Evas_Object *base, const char *group,
+               bool focus_allow, const char *part)
+{
+       Evas_Object *ly;
+
+       if (!base || !group) {
+               _ERR("Invalid argument");
+               return NULL;
+       }
+
+       ly = elm_layout_add(base);
+       if (!ly) {
+               _ERR("failed to add layout");
+               return false;
+       }
+       elm_layout_file_set(ly, EDJEFILE, group);
+
+       if (focus_allow)
+               elm_object_focus_allow_set(ly, EINA_TRUE);
+       if (part)
+               elm_object_part_content_set(base, part, ly);
+
+       return ly;
+}
+
diff --git a/src/view/view_main.c b/src/view/view_main.c
new file mode 100644 (file)
index 0000000..d44c564
--- /dev/null
@@ -0,0 +1,115 @@
+/*
+ * 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 "defs.h"
+#include "view.h"
+#include "utils.h"
+
+struct _priv {
+       Evas_Object *win;
+       Evas_Object *base;
+};
+
+static Evas_Object *_create(Evas_Object *win, void *data)
+{
+       struct _priv *priv;
+       Evas_Object *base;
+
+       priv = calloc(1, sizeof(*priv));
+       if (!priv) {
+               _ERR("failed to calloc priv");
+               return NULL;
+       }
+
+       base = utils_add_layout(win, GRP_MAIN, false, NULL);
+       if (!base) {
+               _ERR("failed to create base");
+               free(priv);
+               return NULL;
+       }
+       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;
+
+       viewmgr_set_view_data(VIEW_MAIN, priv);
+
+       return base;
+}
+
+static void _show(void *data)
+{
+       struct _priv *priv;
+
+       if (!data) {
+               _ERR("Invalid argument");
+               return;
+       }
+
+       priv = data;
+
+       evas_object_show(priv->base);
+}
+
+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_MAIN,
+       .create = _create,
+       .show = _show,
+       .hide = _hide,
+       .destroy = _destroy
+};
+
+view_class *view_main_get_vclass(void)
+{
+       return &vclass;
+}
+