1 TIZEN Native App April, 2016 Dept. of software Dankook University http://embedded.dankook.ac.kr/~baeksj
목차 2 Tizen EFL
Tizen EFL 3 Tizen EFL Enlightment Foundation Libraries 타이젠핵심코어툴킷
Tizen EFL 4 Tizen EFL Eina 자료구조라이브러리 C++ 의 STL 과같이배열, 리스트, 해시, 트리등제공 Eet 데이터인코딩및디코딩 임의의자료구조, 데이터등을압축하여파일저장또는네트워크전송 Zip 과유사한압축기법, 파일로부터임의의위치데이터빠른접근가능 Evas EFL 의핵심라이브러리, Canvas or Rendering Engine 사용자는 Evas 를통해윈도우내이미지, 사각형, 선, 폴리곤, 텍스트등을표현하며, 출력물은모두객체화 Evas_Object 타입으로객체화하여제공하며, 모든그래픽객체들은 Evas_Object 인터페이스로접근
Tizen EFL 5 Tizen EFL Ecore 사용자편의를위해제공되는시스템라이브러리 Main loop, Timer, Event, Connection IPC, Thread 등 복잡한설정및사용단계들을내부적으로처리하여보다쉽게단순화 Edje 복잡한 GUI 구성을위한기능들을제공 EDC Script 언어제공, 사용자는 EDC Script를통해 GUI부분분리작성 Emotion 비디오 / 오디오플레이백 Elementary 위젯툴킷라이브러리 ( 버튼, 리스트, 레이블, 슬라이더 ) GUI확장성지원-> 다양한스크린해상도지원, 테마지원
6 Native app development 설치 Tizen Update Manager > 2.4 Mobile > Native app.development
7 프로젝트생성 Tizen IDE 2.4 > File > New > Other
8 프로젝트생성 Tizen Native Project
9 프로젝트생성 Mobile 2.4 > Basic UI > Finish
10 Privileges 설정 /tizen-manifest.xml > Privileges 설정
11 Privileges 설정 Add > http://tizen.org/privilege/display > OK Display 접근권한획득
12 /inc/simplenativeapp.h 수정 헤더파일추가 #ifndef simplenativeapp_h #define simplenativeapp_h #include <app.h> #include <Elementary.h> #include <system_settings.h> #include <efl_extension.h> #include <dlog.h> #include <device/battery.h> #include <stdlib.h> #include <string.h> #include <system_info.h> #include <device/display.h>
13 /src/simplenativeapp.c 파일수정 appdata_s 구성 기본객체정보 typedef struct appdata { Evas_Object *win; // 기본윈도우창 Evas_Object *conform; // gui 구현시사용 Evas_Object *label; // text 출력시사용 Evas_Object *btn1; // 버튼 1-5 Evas_Object *btn2; Evas_Object *btn3; Evas_Object *btn4; Evas_Object *btn5; Evas_Object *grid; // 화면구성 int brightness; } appdata_s;
14 Main 함수수정 객체자료구조및변수초기화 LifeCycle callback 함수등록 Int main(int argc, char *argv[]) { appdata_s ad = {0,}; ad.brightness = 100; // 기본자료구조초기화 // 객체밝기정보초기화 int ret = 0; // lifecycle callback함수등록 ui_app_lifecycle_callback_s event_callback = {0,}; app_event_handler_h handlers[5] = {NULL, }; event_callback.create = app_create; k.terminate = app_terminate; event_callback.pause = app_pause; event_callback.resume = app_resume; event_callback.app_control = app_control; event_callbac
15 Main 함수수정 System callback 함수등록 ui_app_add_event_handler(&handlers[app_event_low_battery], APP_EVENT_LOW_BATTERY, ui_app_low_battery, &ad); ui_app_add_event_handler(&handlers[app_event_low_memory], APP_EVENT_LOW_MEMORY, ui_app_low_memory, &ad); ui_app_add_event_handler(&handlers[app_event_device_orientation_chang ED], APP_EVENT_DEVICE_ORIENTATION_CHANGED, ui_app_orient_changed, &ad); ui_app_add_event_handler(&handlers[app_event_language_changed], APP_EVENT_LANGUAGE_CHANGED, ui_app_lang_changed, &ad); ui_app_add_event_handler(&handlers[app_event_region_format_changed], APP_EVENT_REGION_FORMAT_CHANGED, ui_app_region_changed, &ad); } ret = ui_app_main(argc, argv, &event_callback, &ad); if (ret!= APP_ERROR_NONE) { dlog_print(dlog_error, LOG_TAG, "app_main() is failed. err = %d", ret); } //Event registration return ret;
16 GUI 설정 app_create : App 에필요데이터와 UI 설정 static bool app_create(void *data) { appdata_s *ad = data; create_base_gui(ad); } return true;
17 GUI 설정 create_base_gui : 메인화면초기화 elm_win_util_standard_add() : 윈도우생성및타이틀전달 static void create_base_gui(appdata_s *ad) { ad->win = elm_win_util_standard_add(package, PACKAGE); elm_win_autodel_set(ad->win, EINA_TRUE); if (elm_win_wm_rotation_supported_get(ad->win)) { int rots[4] = { 0, 90, 180, 270 }; elm_win_wm_rotation_available_rotations_set(ad->win, (const int *)(&rots), 4); } evas_object_smart_callback_add(ad->win, "delete,request", win_delete_request_cb, NULL); eext_object_event_callback_add(ad->win, EEXT_CALLBACK_BACK, win_back_cb, ad);
18 GUI 설정 Conformant 생성및부모객체전달 ad->conform = elm_conformant_add(ad->win); elm_win_indicator_mode_set(ad->win, ELM_WIN_INDICATOR_SHOW); elm_win_indicator_opacity_set(ad->win, ELM_WIN_INDICATOR_OPAQUE); evas_object_size_hint_weight_set(ad->conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); elm_win_resize_object_add(ad->win, ad->conform);
19 GUI 설정 Container 객체 grid 생성 ad->grid = elm_grid_add(ad->conform); evas_object_show(ad->grid);
20 GUI 설정 버튼 1 ~ 5 생성및 content 설정 ad->btn1 = elm_button_add(ad->grid); elm_object_text_set(ad->btn1,"<font font_size=70>model N ame</font>"); elm_object_content_set(ad->grid, ad->btn1); evas_object_show(ad->btn1); ad->btn2 = elm_button_add(ad->grid); elm_object_text_set(ad->btn2,"<font font_size=70>battery State</font>"); elm_object_content_set(ad->grid, ad->btn2); evas_object_show(ad->btn2);
21 GUI 설정 버튼 1 ~ 5 생성및 content 설정 ad->btn3 = elm_button_add(ad->grid); elm_object_text_set(ad->btn3,"<font font_size=70>brightness ++</font>"); elm_object_content_set(ad->grid, ad->btn3); evas_object_show(ad->btn3); ad->btn4 = elm_button_add(ad->grid); elm_object_text_set(ad->btn4,"<font font_size=70>brightness --</font>"); elm_object_content_set(ad->grid, ad->btn4); evas_object_show(ad->btn4); ad->btn5 = elm_button_add(ad->grid); elm_object_text_set(ad->btn5,"<font font_size=70>finish</font>"); elm_object_content_set(ad->grid, ad->btn5); evas_object_show(ad->btn5);
22 GUI 설정 Label 생성및 grid 등록 ad->label = elm_label_add(ad->grid); elm_object_content_set(ad->grid, ad->label); evas_object_show(ad->label); elm_grid_pack(ad->grid,ad->btn1, 10,5,80,12); elm_grid_pack(ad->grid,ad->btn2, 10,22,80,12); elm_grid_pack(ad->grid,ad->btn3, 10,39,80,12); elm_grid_pack(ad->grid,ad->btn4, 10,56,80,12); elm_grid_pack(ad->grid,ad->btn5, 10,73,80,12); elm_grid_pack(ad->grid,ad->label, 10,88,80,20); elm_object_content_set(ad->conform, ad->grid);
23 GUI 설정 버튼 Event 등록 } evas_object_smart_callback_add(ad- >btn1,"clicked", clicked_btn1,ad); evas_object_smart_callback_add(ad->btn2,"clicked", clicked_btn2,ad); evas_object_smart_callback_add(ad->btn3,"clicked", clicked_btn3,ad); evas_object_smart_callback_add(ad->btn4,"clicked", clicked_btn4,ad); evas_object_smart_callback_add(ad->btn5,"clicked", clicked_btn5,ad); evas_object_show(ad->conform); evas_object_show(ad->win);
24 Clicked_btn1 함수등록 디바이스이름출력함수 static void clicked_btn1(void *user_data, Evas_Object *obj, void* event_info) { int ret; appdata_s *ad = user_data; char *buf1; char buf2[1024]; ret = system_info_get_platform_string( "http://tizen.org/system/model_name",&buf1); sprintf(buf2, "<align=center><font font_size=50> Model : %s</font></align>",buf1); elm_object_text_set(ad->label,buf2); } free(buf1);
25 Clicked_btn2 함수등록 디아비스베터리잔량출력함수 static void clicked_btn2(void *user_data, Evas_Object *obj, void* event_info) { int error, pct; char buf[1024]; appdata_s *ad = user_data; error = device_battery_get_percent(&pct); sprintf(buf, "<align=center><font font_size=50> CurrentBattery : %d</font></align>",pct); elm_object_text_set(ad->label,buf); }
26 Clicked_btn3 함수등록 디아비스 Display 밝기증가함수 static void clicked_btn3(void *user_data, Evas_Object *obj, void* event_info) { int error; appdata_s *ad = user_data; } ad->brightness += 10; if(ad->brightness >= 100) ad->brightness = 100; error = device_display_set_brightness(0, ad->brightness);
27 Clicked_btn4 함수등록 디아비스 Display 밝기감소함수 static void clicked_btn4(void *user_data, Evas_Object *obj, void* event_info) { int error; appdata_s *ad = user_data; } ad->brightness -= 10; if(ad->brightness <= 0) ad->brightness = 0; error = device_display_set_brightness(0, ad->brightness);
28 Clicked_btn5 함수등록 애플리케이션종료함수 static void clicked_btn5(void *user_data, Evas_Object *obj, void* event_info) { ui_app_exit(); }
29 실행화면
30 실행화면
Q/A 31