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}\"")
#include "../include/defs.h"
collections {
+ #include "view/main.edc"
}
--- /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.
+ */
+
+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;
+ }
+ }
+ }
+}
#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__ */
--- /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 __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__ */
--- /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 __AIR_ETG_VIEW_H__
+#define __AIR_ETG_VIEW_H__
+
+view_class *view_main_get_vclass(void);
+
+#endif /* __AIR_ETG_VIEW_H__ */
#include <app.h>
#include <Elementary.h>
#include <app_debug.h>
+#include <viewmgr.h>
#include "defs.h"
+#include "view.h"
SET_TAG(PACKAGE);
static bool _create(void *user_data)
{
struct _appdata *ad;
- Evas_Object *win;
if (!user_data) {
_ERR("Invalid argument");
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;
}
ad = user_data;
- if (ad->win)
+ if (ad->win) {
+ viewmgr_destroy();
evas_object_del(ad->win);
+ }
}
static void _pause(void *user_data)
if (ad->win) {
elm_win_activate(ad->win);
- evas_object_show(ad->win);
+ viewmgr_push_view(VIEW_MAIN);
}
}
--- /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 <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;
+}
+
--- /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 <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;
+}
+