diff options
Diffstat (limited to 'src/home/home_scroller.c')
-rwxr-xr-x | src/home/home_scroller.c | 144 |
1 files changed, 144 insertions, 0 deletions
diff --git a/src/home/home_scroller.c b/src/home/home_scroller.c new file mode 100755 index 0000000..9418802 --- /dev/null +++ b/src/home/home_scroller.c @@ -0,0 +1,144 @@ +/* + * Copyright (c) 2013 - 2016 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 "common/log.h" +#include "common/conf.h" +#include "home/home_win.h" +#include "home/home_scroller.h" +#include "home/home_manager.h" + +#include <app.h> +#include <stdlib.h> + +static struct __home_scroller_s { + home_scroller_t *home_scroller; +} s_info = { + .home_scroller = NULL, +}; + +static home_scroller_t *__home_scroller_new(void); +static void __destroy_home_scroller(void *data); +static Evas_Object *__create_main_scroller(Evas_Object *parent); +static Evas_Object *__create_main_box(Evas_Object *parent); + +home_scroller_t *home_scroller_get(void) +{ + if (s_info.home_scroller == NULL) { + s_info.home_scroller = __home_scroller_new(); + home_add_terminate_cb(__destroy_home_scroller); + } + + return s_info.home_scroller; +} + +static home_scroller_t *__home_scroller_new(void) +{ + home_scroller_t *home_scroller = NULL; + + home_scroller = (home_scroller_t *)malloc(sizeof(home_scroller_t)); + if (home_scroller == NULL) { + _E("failed to malloc"); + return NULL; + } + + home_scroller->parent = home_win_get(); + if (home_scroller->parent == NULL) { + _E("failed to get win"); + free(home_scroller); + return NULL; + } + + home_scroller->scroller = __create_main_scroller(home_scroller->parent); + if (home_scroller->scroller == NULL) { + _E("failed to create scroller"); + free(home_scroller); + return NULL; + } + + s_info.home_scroller->box = __create_main_box(s_info.home_scroller->scroller); + if (s_info.home_scroller->box == NULL) { + _E("failed to create box"); + evas_object_del(home_scroller->scroller); + free(home_scroller); + return NULL; + } + + elm_object_content_set(s_info.home_scroller->scroller, s_info.home_scroller->box); + + s_info.home_scroller->clock_page = NULL; + s_info.home_scroller->noti_first_page = NULL; + s_info.home_scroller->widgets_first_page = NULL; + + return home_scroller; +} + +static void __destroy_home_scroller(void *data) +{ + if (s_info.home_scroller == NULL) { + return ; + } + + if (s_info.home_scroller->box) { + evas_object_del(s_info.home_scroller->box); + } + + if (s_info.home_scroller->scroller) { + evas_object_del(s_info.home_scroller->scroller); + } + + free(s_info.home_scroller); + s_info.home_scroller = NULL; +} + +static Evas_Object *__create_main_scroller(Evas_Object *parent) +{ + Evas_Object *scroller = NULL; + scroller = elm_scroller_add(parent); + + if (scroller == NULL) { + return NULL; + } + + elm_scroller_bounce_set(scroller, EINA_FALSE, EINA_FALSE); + elm_scroller_policy_set(scroller, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF); + elm_scroller_page_scroll_limit_set(scroller, 1, 0); + elm_scroller_single_direction_set(scroller, ELM_SCROLLER_SINGLE_DIRECTION_HARD); + elm_scroller_page_size_set(scroller, WINDOW_W, WINDOW_H); + elm_object_style_set(scroller, "effect"); + elm_object_scroll_lock_y_set(scroller, EINA_TRUE); + evas_object_size_hint_weight_set(scroller, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_resize(scroller, WINDOW_W, WINDOW_H); + evas_object_move(scroller, 0, 0); + evas_object_show(scroller); + + return scroller; +} + +static Evas_Object *__create_main_box(Evas_Object *parent) +{ + Evas_Object *box = NULL; + box = elm_box_add(parent); + if (box == NULL) { + return NULL; + } + + elm_box_horizontal_set(box, EINA_TRUE); + evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(box, 0, 0); + evas_object_show(box); + + return box; +} |