diff options
author | Michal Skorupinski <m.skorupinsk@samsung.com> | 2018-07-06 18:32:26 +0200 |
---|---|---|
committer | Lukasz Stanislawski <l.stanislaws@samsung.com> | 2018-07-13 15:46:07 +0000 |
commit | de8ae0f94404a5d85305707402d0a9c60f02d2d4 (patch) | |
tree | ff0d35bdc76e64bf6fad2ad0e08d8d2e3cc6942d | |
parent | 22257e1b1b0e3398a879702c2fe1f5a9006b8a69 (diff) | |
download | gear-racing-controller-de8ae0f94404a5d85305707402d0a9c60f02d2d4.tar.gz gear-racing-controller-de8ae0f94404a5d85305707402d0a9c60f02d2d4.tar.bz2 gear-racing-controller-de8ae0f94404a5d85305707402d0a9c60f02d2d4.zip |
View factory added
Change-Id: Ifc1fb24c63b5e445707e9faa470be8c1f3d0dd9a
Signed-off-by: Michal Skorupinski <m.skorupinsk@samsung.com>
-rw-r--r-- | inc/view_manager/view_factory.h | 36 | ||||
-rw-r--r-- | inc/view_manager/view_manager.h | 13 | ||||
-rw-r--r-- | src/view_manager/view_factory.c | 66 | ||||
-rw-r--r-- | src/view_manager/view_manager.c | 49 |
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); |