summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--inc/view_manager/view_factory.h36
-rw-r--r--inc/view_manager/view_manager.h13
-rw-r--r--src/view_manager/view_factory.c66
-rw-r--r--src/view_manager/view_manager.c49
4 files changed, 105 insertions, 59 deletions
diff --git a/inc/view_manager/view_factory.h b/inc/view_manager/view_factory.h
new file mode 100644
index 0000000..83c26bc
--- /dev/null
+++ b/inc/view_manager/view_factory.h
@@ -0,0 +1,36 @@
+/*
+* Copyright (c) 2018 Samsung Electronics Co., Ltd.
+*
+* Licensed under the Flora License, Version 1.1 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://floralicense.org/license/
+*
+* 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 VIEWMANAGER_VIEW_FACTORY_H_
+#define VIEWMANAGER_VIEW_FACTORY_H_
+
+#include "view/view_base.h"
+
+typedef enum _e_view_id {
+ VIEW_CONNECT_TO_CAR,
+ VIEW_CAR_SELECTION,
+ VIEW_CONNECTION_SUCCESSED,
+ VIEW_NAME_INPUT,
+ VIEW_HELP,
+ VIEW_RACING,
+ VIEW_EMERGENCY_STOP,
+ VIEW_RESET,
+ VIEW_NETWORK_FAILURE,
+} view_id;
+
+s_view_base *view_factory_create_view(Evas_Object *parent, view_id id);
+
+#endif /* VIEWMANAGER_VIEW_FACTORY_H_ */
diff --git a/inc/view_manager/view_manager.h b/inc/view_manager/view_manager.h
index 662bc3a..78d0dc8 100644
--- a/inc/view_manager/view_manager.h
+++ b/inc/view_manager/view_manager.h
@@ -18,20 +18,9 @@
#ifndef VIEW_MANAGER_VIEW_MANAGER_H_
#define VIEW_MANAGER_VIEW_MANAGER_H_
+#include "view_manager/view_factory.h"
#include "gear-racing-controller.h"
-typedef enum _e_view_id {
- VIEW_CONNECT_TO_CAR,
- VIEW_CAR_SELECTION,
- VIEW_CONNECTION_SUCCESSED,
- VIEW_NAME_INPUT,
- VIEW_HELP,
- VIEW_RACING,
- VIEW_EMERGENCY_STOP,
- VIEW_RESET,
- VIEW_NETWORK_FAILURE,
-} view_id;
-
void view_manager_set_view(view_id id);
void view_manager_initialize_ui(void);
Evas_Object *view_manager_get_win(void);
diff --git a/src/view_manager/view_factory.c b/src/view_manager/view_factory.c
new file mode 100644
index 0000000..dc1e8f6
--- /dev/null
+++ b/src/view_manager/view_factory.c
@@ -0,0 +1,66 @@
+/*
+* Copyright (c) 2018 Samsung Electronics Co., Ltd.
+*
+* Licensed under the Flora License, Version 1.1 (the License);
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://floralicense.org/license/
+*
+* 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 "view_manager/view_factory.h"
+#include "view/view_connect_to_car.h"
+#include "view/view_car_selection.h"
+#include "view/view_connection_successed.h"
+#include "view/view_emergency_stop.h"
+#include "view/view_help.h"
+#include "view/view_name_input.h"
+#include "view/view_network_failure.h"
+#include "view/view_racing.h"
+#include "view/view_reset.h"
+
+s_view_base *view_factory_create_view(Evas_Object *parent, view_id id)
+{
+ s_view_base *view;
+
+ switch (id) {
+ case VIEW_CONNECT_TO_CAR:
+ view = view_connect_to_car_init(parent);
+ break;
+ case VIEW_CAR_SELECTION:
+ view = view_car_selection_init(parent);
+ break;
+ case VIEW_CONNECTION_SUCCESSED:
+ view = view_connection_successed_init(parent);
+ break;
+ case VIEW_NAME_INPUT:
+ view = view_name_input_init(parent);
+ break;
+ case VIEW_HELP:
+ view = view_help_init(parent);
+ break;
+ case VIEW_RACING:
+ view = view_racing_init(parent);
+ break;
+ case VIEW_EMERGENCY_STOP:
+ view = view_emergency_stop_init(parent);
+ break;
+ case VIEW_RESET:
+ view = view_reset_init(parent);
+ break;
+ case VIEW_NETWORK_FAILURE:
+ view = view_network_failure_init(parent);
+ break;
+ default:
+ break;
+ }
+
+ return view;
+}
+
diff --git a/src/view_manager/view_manager.c b/src/view_manager/view_manager.c
index 8eff2cf..835d006 100644
--- a/src/view_manager/view_manager.c
+++ b/src/view_manager/view_manager.c
@@ -15,18 +15,7 @@
*/
#include <assert.h>
-#include <view_manager/view_manager.h>
-#include <view_manager/view_manager.h>
-#include "view/view_base.h"
-#include "view/view_connect_to_car.h"
-#include "view/view_car_selection.h"
-#include "view/view_connection_successed.h"
-#include "view/view_emergency_stop.h"
-#include "view/view_help.h"
-#include "view/view_name_input.h"
-#include "view/view_network_failure.h"
-#include "view/view_racing.h"
-#include "view/view_reset.h"
+#include "view_manager/view_manager.h"
typedef struct _s_ui {
Evas_Object *win;
@@ -77,43 +66,9 @@ void view_manager_set_view(view_id id)
{
view_base_hide(s_info.current_view);
- s_view_base *view;
-
- switch (id) {
- case VIEW_CONNECT_TO_CAR:
- view = view_connect_to_car_init(s_info.naviframe);
- break;
- case VIEW_CAR_SELECTION:
- view = view_car_selection_init(s_info.naviframe);
- break;
- case VIEW_CONNECTION_SUCCESSED:
- view = view_connection_successed_init(s_info.naviframe);
- break;
- case VIEW_NAME_INPUT:
- view = view_name_input_init(s_info.naviframe);
- break;
- case VIEW_HELP:
- view = view_help_init(s_info.naviframe);
- break;
- case VIEW_RACING:
- view = view_racing_init(s_info.naviframe);
- break;
- case VIEW_EMERGENCY_STOP:
- view = view_emergency_stop_init(s_info.naviframe);
- break;
- case VIEW_RESET:
- view = view_reset_init(s_info.naviframe);
- break;
- case VIEW_NETWORK_FAILURE:
- view = view_network_failure_init(s_info.naviframe);
- break;
- break;
- default:
- break;
- }
+ s_view_base *view = view_factory_create_view(s_info.naviframe, id);
s_info.current_view = view;
-
elm_naviframe_item_simple_push(s_info.naviframe, s_info.current_view->layout);
view_base_show(s_info.current_view);