voice: add voice layout 79/49079/1
authorMinkyu Kang <mk7.kang@samsung.com>
Tue, 6 Oct 2015 08:01:52 +0000 (17:01 +0900)
committerMinkyu Kang <mk7.kang@samsung.com>
Tue, 6 Oct 2015 08:01:52 +0000 (17:01 +0900)
Change-Id: Id6dcc14d97bd6d383e4bee0a699c059cc5d00d8a
Signed-off-by: Minkyu Kang <mk7.kang@samsung.com>
include/define.h
include/layout/voice.h [new file with mode: 0644]
res/layout/voice.edc [new file with mode: 0644]
res/settings.edc
src/layout/layout_voice.c
src/view/view_base.c

index 8dce284..0421dee 100644 (file)
@@ -22,6 +22,7 @@
 #include "layout/network.h"
 #include "layout/picture.h"
 #include "layout/system.h"
+#include "layout/voice.h"
 
 /* View ID */
 #define VIEW_BASE "VIEW_BASE"
diff --git a/include/layout/voice.h b/include/layout/voice.h
new file mode 100644 (file)
index 0000000..ae0dec5
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * 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_SETTINGS_LAYOUT_VOICE_H__
+#define __AIR_SETTINGS_LAYOUT_VOICE_H__
+
+/* group */
+#define GRP_LAYOUT_VOICE "grp.layout.voice"
+
+/* part */
+#define PART_VOICE "part.voice"
+
+#endif
diff --git a/res/layout/voice.edc b/res/layout/voice.edc
new file mode 100644 (file)
index 0000000..6635e15
--- /dev/null
@@ -0,0 +1,87 @@
+/*
+ * 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_LAYOUT_VOICE;
+       parts {
+               part {
+                       name, "area";
+                       type, RECT;
+                       scale, 1;
+                       description {
+                               state, "default" 0.0;
+                               visible, 0;
+                       }
+               }
+
+               part {
+                       name, "padding.top";
+                       type, SPACER;
+                       scale, 1;
+                       description {
+                               state, "default" 0.0;
+                               min, 65 134;
+                               rel1 {
+                                       to, "area";
+                                       relative, 0.0 0.0;
+                               }
+                               rel2 {
+                                       to, "area";
+                                       relative, 0.0 0.0;
+                               }
+                               align, 0.0 0.0;
+                               fixed, 1 1;
+                       }
+               }
+               part {
+                       name, "padding.bottom";
+                       type, SPACER;
+                       scale, 1;
+                       description {
+                               state, "default" 0.0;
+                               min, 65 148;
+                               rel1 {
+                                       to, "area";
+                                       relative, 1.0 1.0;
+                               }
+                               rel2 {
+                                       to, "area";
+                                       relative, 1.0 1.0;
+                               }
+                               align, 1.0 1.0;
+                               fixed, 0 1;
+                       }
+               }
+               part {
+                       name, PART_VOICE;
+                       type, SWALLOW;
+                       scale, 1;
+                       description {
+                               state, "default" 0.0;
+                               rel1 {
+                                       to, "padding.top";
+                                       relative, 1.0 1.0;
+                               }
+                               rel2 {
+                                       to, "padding.bottom";
+                                       relative, 0.0 0.0;
+                               }
+                               fixed, 1 1;
+                               align, 0.0 0.0;
+                       }
+               }
+       }
+}
index 0cfbfa9..33b66bc 100644 (file)
@@ -23,4 +23,5 @@ collections {
        #include "layout/support.edc"
        #include "layout/network.edc"
        #include "layout/system.edc"
+       #include "layout/voice.edc"
 }
index a37d80f..88d323e 100644 (file)
 
 #include <Elementary.h>
 #include <layoutmgr.h>
+#include <inputmgr.h>
+#include <app_debug.h>
 
 #include "define.h"
 #include "layout.h"
+#include "utils.h"
+#include "menumgr.h"
+
+#define PADDING_X 26
+#define PADDING_Y 26
+
+struct _priv {
+       Evas_Object *base;
+       Evas_Object *ly;
+       Evas_Object *table;
+       layoutmgr *lmgr;
+       struct menumgr *menu;
+};
+
+enum {
+       MENU_VOICE_CONTROL,
+       MENU_VOICE_LANGUAGE,
+       MENU_TTS_SPEED,
+       MENU_TTS_LANGUAGE
+};
+
+static void _selected(void *data, int id);
+static char *_get_status(void *data, int id);
+
+static struct menumgr_info menu_info[] = {
+       {
+               .id = MENU_VOICE_CONTROL,
+               .title = "Voice control",
+               .style = STYLE_STATUS_BTN,
+               .disabled = EINA_TRUE,
+               .status = _get_status,
+               .selected = _selected,
+       },
+       {
+               .id = MENU_VOICE_LANGUAGE,
+               .title = "Voice language",
+               .style = STYLE_STATUS_BTN,
+               .disabled = EINA_TRUE,
+               .status = _get_status,
+               .selected = _selected,
+       },
+       {
+               .id = MENU_TTS_SPEED,
+               .title = "TTS speed",
+               .style = STYLE_STATUS_BTN,
+               .disabled = EINA_TRUE,
+               .status = _get_status,
+               .selected = _selected,
+       },
+       {
+               .id = MENU_TTS_LANGUAGE,
+               .title = "TTS language",
+               .style = STYLE_STATUS_BTN,
+               .disabled = EINA_TRUE,
+               .status = _get_status,
+               .selected = _selected,
+       },
+};
+
+static char *_get_status(void *data, int id)
+{
+       return NULL;
+}
+
+static void _selected(void *data, int id)
+{
+}
+
+static bool _add_layout_contents(struct _priv *priv)
+{
+       Evas_Object *table;
+       struct menumgr *menu;
+
+       table = utils_add_table(priv->ly, PADDING_X, PADDING_Y);
+       if (!table) {
+               _ERR("failed to add table");
+               return false;
+       }
+
+       priv->table = table;
+
+       elm_object_part_content_set(priv->ly, PART_VOICE, table);
+
+       menu = menumgr_create(table, menu_info, ARRAY_SIZE(menu_info), priv);
+       if (!menu) {
+               _ERR("failed to create menu manager");
+               evas_object_del(table);
+               return false;
+       }
+
+       priv->menu = menu;
+
+       return true;
+}
 
 static bool _create(layoutmgr *lmgr, void *data)
 {
-       /* It will be implemented later */
+       struct _priv *priv;
+       Evas_Object *base, *ly;
+
+       if (!lmgr) {
+               _ERR("Invalid argument.");
+               return false;
+       }
+
+       base = layoutmgr_get_base(lmgr);
+       if (!base) {
+               _ERR("Get base layout failed.");
+               return false;
+       }
+
+       ly = utils_add_layout(base, GRP_LAYOUT_VOICE, EINA_FALSE);
+       if (!ly) {
+               _ERR("Add layout failed.");
+               return false;
+       }
+
+       priv = calloc(1, sizeof(*priv));
+       if (!priv) {
+               _ERR("Calloc failed.");
+               evas_object_del(ly);
+               return false;
+       }
+
+       priv->lmgr = lmgr;
+       priv->base = base;
+       priv->ly = ly;
+
+       if (!_add_layout_contents(priv)) {
+               _ERR("Add layout contents failed.");
+               evas_object_del(ly);
+               free(priv);
+               return false;
+       }
+
+       layoutmgr_set_layout_data(lmgr, LAYOUT_ID_VOICE, priv);
+
        return true;
 }
 
 static void _show(void *layout_data)
 {
-       /* It will be implemented later */
+       struct _priv *priv;
+
+       if (!layout_data) {
+               _ERR("Invalid argument.");
+               return;
+       }
+
+       priv = layout_data;
+
+       if (priv->ly) {
+               menumgr_update(priv->menu);
+
+               evas_object_show(priv->ly);
+               elm_object_part_content_set(priv->base, PART_CONTENT, priv->ly);
+       }
 }
 
 static void _hide(void *layout_data)
 {
-       /* It will be implemented later */
+       struct _priv *priv;
+
+       if (!layout_data) {
+               _ERR("Invalid argument.");
+               return;
+       }
+
+       priv = layout_data;
+
+       if (priv->ly) {
+               evas_object_hide(priv->ly);
+               elm_object_part_content_unset(priv->base, PART_CONTENT);
+       }
 }
 
 static void _destroy(void *layout_data)
 {
-       /* It will be implemented later */
+       struct _priv *priv;
+
+       if (!layout_data) {
+               _ERR("Invalid argument.");
+               return;
+       }
+
+       priv = layout_data;
+
+       menumgr_destroy(priv->menu);
+
+       evas_object_del(priv->ly);
+
+       free(priv);
 }
 
 static layout_class _lclass = {
index c3deb8a..b4c19e9 100644 (file)
@@ -88,7 +88,7 @@ static struct _menu_data _mdata[LAYOUT_MAX] = {
                .name = STR_VOICE,
                .layout_id = LAYOUT_ID_VOICE,
                .get_lclass = layout_voice_get_lclass,
-               .enable = EINA_FALSE
+               .enable = EINA_TRUE
        },
 };