2 * Copyright 2012 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.tizenopensource.org/license
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #include "browser-class.h"
19 #include "browser-multi-window-view.h"
20 #include "browser-view.h"
21 #include "browser-window.h"
23 Browser_Multi_Window_View::Browser_Multi_Window_View(void)
27 ,m_zoom_effect_image(NULL)
28 ,m_flip_effect_image(NULL)
29 ,m_zoom_move_transit(NULL)
30 ,m_scroll_move_transit(NULL)
33 ,m_dummy_front_item_layout(NULL)
34 ,m_dummy_end_item_layout(NULL)
35 ,m_dummy_front_item_snapshot(NULL)
36 ,m_dummy_end_item_snapshot(NULL)
37 ,m_select_item_index(0)
38 ,m_current_position_index(0)
41 ,m_is_reordering(EINA_FALSE)
42 ,m_zoom_out_effect_idler(NULL)
43 ,m_zoom_out_duration(0.5)
44 ,m_change_view_button(NULL)
45 ,m_cancel_button(NULL)
47 ,m_new_window_button(NULL)
48 ,m_init_grid_mode(EINA_FALSE)
50 BROWSER_LOGD("[%s]", __func__);
51 memset(m_index_items, 0x00, sizeof(Elm_Object_Item *) * BROWSER_MULTI_WINDOW_MAX_COUNT);
54 Browser_Multi_Window_View::~Browser_Multi_Window_View(void)
56 BROWSER_LOGD("[%s]", __func__);
58 evas_object_del(m_main_layout);
62 evas_object_del(m_scroller);
66 evas_object_del(m_item_box);
69 if (m_dummy_front_item_layout) {
70 evas_object_del(m_dummy_front_item_layout);
71 m_dummy_front_item_layout = NULL;
73 if (m_dummy_end_item_layout) {
74 evas_object_del(m_dummy_end_item_layout);
75 m_dummy_end_item_layout = NULL;
77 if (m_dummy_front_item_snapshot) {
78 evas_object_del(m_dummy_front_item_snapshot);
79 m_dummy_front_item_snapshot = NULL;
81 if (m_dummy_end_item_snapshot) {
82 evas_object_del(m_dummy_end_item_snapshot);
83 m_dummy_end_item_snapshot = NULL;
86 evas_object_del(m_page_control);
87 m_page_control = NULL;
90 elm_transit_del(m_zoom_transit);
91 m_zoom_transit = NULL;
93 if (m_zoom_effect_image) {
94 evas_object_del(m_zoom_effect_image);
95 m_zoom_effect_image = NULL;
97 if (m_flip_effect_image) {
98 evas_object_del(m_flip_effect_image);
99 m_flip_effect_image = NULL;
101 if (m_zoom_move_transit) {
102 elm_transit_del(m_zoom_move_transit);
103 m_zoom_move_transit = NULL;
105 if (m_scroll_move_transit) {
106 elm_transit_del(m_scroll_move_transit);
107 m_scroll_move_transit = NULL;
109 if (m_zoom_out_effect_idler) {
110 ecore_idler_del(m_zoom_out_effect_idler);
111 m_zoom_out_effect_idler = NULL;
113 for (int i = 0 ; i < m_item_list.size() ; i++) {
115 evas_object_del(m_item_list[i]);
120 evas_object_del(m_gengrid);
125 Eina_Bool Browser_Multi_Window_View::init(double duration, Eina_Bool grid_mode)
127 BROWSER_LOGD("[%s]", __func__);
128 m_zoom_out_duration = duration;
129 m_init_grid_mode = grid_mode;
131 if (!_create_main_layout()) {
132 BROWSER_LOGD("_create_main_layout failed");
139 void Browser_Multi_Window_View::__zoom_out_finished_cb(void *data, Elm_Transit *transit)
141 BROWSER_LOGD("[%s]", __func__);
145 Browser_Multi_Window_View *multi_window_view = (Browser_Multi_Window_View *)data;
147 if (!multi_window_view->m_zoom_transit)
150 multi_window_view->m_zoom_transit = NULL;
151 multi_window_view->m_zoom_move_transit = NULL;
153 if (multi_window_view->m_zoom_effect_image) {
154 evas_object_del(multi_window_view->m_zoom_effect_image);
155 multi_window_view->m_zoom_effect_image = NULL;
157 if (multi_window_view->m_flip_effect_image) {
158 evas_object_del(multi_window_view->m_flip_effect_image);
159 multi_window_view->m_flip_effect_image = NULL;
162 multi_window_view->__zoom_out_finished();
165 void Browser_Multi_Window_View::__zoom_out_finished(void)
167 BROWSER_LOGD("[%s]", __func__);
168 int scroll_size = _get_scroll_page_size();
172 elm_scroller_region_get(m_scroller, NULL, &scroller_y, &scroller_w, &scroller_h);
173 elm_scroller_region_show(m_scroller, scroll_size * m_current_position_index,
174 scroller_y, scroller_w, scroller_h);
176 for (int i = 0 ; i < m_item_list.size() ; i++)
177 evas_object_show(m_item_list[i]);
179 Browser_View *browser_view = m_data_manager->get_browser_view();
180 const char *title = browser_view->get_title().c_str();
181 const char *url = browser_view->get_url().c_str();
183 BROWSER_LOGD("title=[%s]", title);
184 BROWSER_LOGD("url=[%s]", url);
185 if (!title || strlen(title) == 0) {
186 Evas_Object *entry = br_elm_editfield_entry_get(browser_view->m_option_header_url_edit_field);
187 const char *entry_text = elm_entry_entry_get(entry);
188 if (entry_text && strlen(entry_text)) {
189 BROWSER_LOGD("[%s][%s]", entry_text, entry_text);
190 char *markup = elm_entry_utf8_to_markup(entry_text);
192 edje_object_part_text_set(elm_layout_edje_get(m_main_layout), "elm.title", markup);
193 edje_object_part_text_set(elm_layout_edje_get(m_main_layout), "elm.url", markup);
197 edje_object_part_text_set(elm_layout_edje_get(m_main_layout), "elm.title", BR_STRING_EMPTY);
198 edje_object_part_text_set(elm_layout_edje_get(m_main_layout), "elm.url", "");
201 BROWSER_LOGD("[%s][%s]", title, url);
202 char *markup = elm_entry_utf8_to_markup(title);
204 edje_object_part_text_set(elm_layout_edje_get(m_main_layout), "elm.title", markup);
208 markup = elm_entry_utf8_to_markup(url);
210 edje_object_part_text_set(elm_layout_edje_get(m_main_layout), "elm.url", markup);
218 void Browser_Multi_Window_View::__zoom_in_finished_cb(void *data, Elm_Transit *transit)
220 BROWSER_LOGD("[%s]", __func__);
224 Browser_Multi_Window_View *multi_window_view = (Browser_Multi_Window_View *)data;
226 if (!multi_window_view->m_zoom_transit)
229 multi_window_view->m_zoom_transit = NULL;
230 multi_window_view->m_zoom_move_transit = NULL;
232 if (multi_window_view->m_zoom_effect_image) {
233 evas_object_del(multi_window_view->m_zoom_effect_image);
234 multi_window_view->m_zoom_effect_image = NULL;
236 if (multi_window_view->m_flip_effect_image) {
237 evas_object_del(multi_window_view->m_flip_effect_image);
238 multi_window_view->m_flip_effect_image = NULL;
241 std::vector<Browser_Window *> window_list = m_browser->get_window_list();
242 if (!window_list[multi_window_view->m_select_item_index]->m_ewk_view) {
243 Browser_Window *deleted_window = NULL;
244 deleted_window = m_browser->create_deleted_window(multi_window_view->m_select_item_index);
245 if (deleted_window) {
246 BROWSER_LOGD("************ deleted_window=%d", deleted_window);
247 for (int i = 0 ; i < window_list.size(); i++)
248 BROWSER_LOGD("************ window[%d]=%d", i, window_list[i]);
249 Browser_View *browser_view = m_data_manager->get_browser_view();
250 m_browser->set_focused_window(deleted_window);
251 BROWSER_LOGD("*** load url=[%s]", deleted_window->m_url.c_str());
252 browser_view->load_url(deleted_window->m_url.c_str());
255 m_browser->set_focused_window(window_list[multi_window_view->m_select_item_index]);
257 __close_multi_window_button_clicked_cb(multi_window_view, NULL, NULL);
260 /* zoom in effect when user selects mult window item. */
261 Eina_Bool Browser_Multi_Window_View::_show_zoom_in_effect(Evas_Object *item)
263 BROWSER_LOGD("[%s]", __func__);
264 if (m_zoom_transit) {
265 BROWSER_LOGE("transition is already running");
268 Browser_Window *focused_window = m_data_manager->get_browser_view()->m_focused_window;
270 int ewk_view_current_y = 0;
271 evas_object_geometry_get(focused_window->m_ewk_view, NULL, &ewk_view_current_y, NULL, NULL);
274 for (index = 0 ; index < m_item_list.size() ; index++) {
275 if (m_item_list[index] == item)
279 evas_object_hide(item);
281 /* Destroy speed dial little eariler because of blinking issue. */
282 Browser_View *browser_view = m_data_manager->get_browser_view();
284 std::vector<Browser_Window *> window_list = m_browser->get_window_list();
290 evas_object_geometry_get(focused_window->m_ewk_view, &webview_x, &webview_y,
291 &webview_w, &webview_h);
297 #if defined(HORIZONTAL_UI)
299 evas_object_geometry_get(window_list[index]->m_landscape_snapshot_image,
300 &snapshot_x, &snapshot_y, &snapshot_w, &snapshot_h);
303 evas_object_geometry_get(window_list[index]->m_portrait_snapshot_image,
304 &snapshot_x, &snapshot_y, &snapshot_w, &snapshot_h);
306 if (!window_list[index]->m_ewk_view || browser_view->get_url(window_list[index]).empty()) {
307 m_zoom_effect_image = evas_object_rectangle_add(evas_object_evas_get(m_navi_bar));
308 if (!m_zoom_effect_image) {
309 BROWSER_LOGE("evas_object_rectangle_add failed");
312 evas_object_resize(m_zoom_effect_image, snapshot_w, snapshot_h);
313 evas_object_color_set(m_zoom_effect_image, 255, 255, 255, 255);
315 m_flip_effect_image = evas_object_rectangle_add(evas_object_evas_get(m_navi_bar));
316 if (!m_flip_effect_image) {
317 BROWSER_LOGE("evas_object_rectangle_add failed");
320 evas_object_resize(m_flip_effect_image, webview_w, webview_h);
321 evas_object_color_set(m_flip_effect_image, 255, 255, 255, 255);
323 m_zoom_effect_image = _capture_snapshot(window_list[index],
324 BROWSER_MULTI_WINDOW_ITEM_RATIO);
325 if (!m_zoom_effect_image) {
326 BROWSER_LOGE("_capture_snapshot failed");
330 m_flip_effect_image = _capture_snapshot(window_list[index], 1.0);
331 if (!m_flip_effect_image) {
332 BROWSER_LOGE("_capture_snapshot failed");
336 evas_object_move(m_flip_effect_image, webview_x, webview_y);
338 evas_object_move(m_zoom_effect_image, snapshot_x, snapshot_y);
339 evas_object_show(m_zoom_effect_image);
341 /* m_zoom_effect_image is only for zoom out effect for the first time. */
342 m_zoom_transit = elm_transit_add();
343 if (!m_zoom_transit) {
344 BROWSER_LOGE("elm_transit_add failed");
347 /* Block event durring animation. */
348 elm_transit_event_enabled_set(m_zoom_transit, EINA_TRUE);
350 m_select_item_index = index;
352 #if defined(FEATURE_MOST_VISITED_SITES)
353 if (!(browser_view->get_url(window_list[m_select_item_index]).empty()))
354 browser_view->_show_most_visited_sites(EINA_FALSE);
357 /* Without this code, the url is empty shortly when create deleted-window in multi window. */
358 if (browser_view->get_url().empty() && !browser_view->m_focused_window->m_url.empty())
359 browser_view->_set_url_entry(window_list[m_select_item_index]->m_url.c_str(), EINA_FALSE);
361 browser_view->_set_url_entry(browser_view->get_url(window_list[m_select_item_index]).c_str(), EINA_FALSE);
363 elm_transit_object_add(m_zoom_transit, m_zoom_effect_image);
364 elm_transit_object_add(m_zoom_transit, m_flip_effect_image);
365 elm_transit_tween_mode_set(m_zoom_transit, ELM_TRANSIT_TWEEN_MODE_SINUSOIDAL);
366 elm_transit_objects_final_state_keep_set(m_zoom_transit, EINA_FALSE);
367 elm_transit_effect_resizable_flip_add(m_zoom_transit, ELM_TRANSIT_EFFECT_FLIP_AXIS_Y, EINA_TRUE);
368 elm_transit_duration_set(m_zoom_transit, 0.5);
369 elm_transit_del_cb_set(m_zoom_transit, __zoom_in_finished_cb, this);
370 elm_transit_go(m_zoom_transit);
372 #if defined(FEATURE_MOST_VISITED_SITES)
373 /* If speed dial is running, just zoom in effect is enough. */
374 if (browser_view->is_most_visited_sites_running())
378 /* If the url bar in browser scroller is being displayed,
379 * the zoom animation should be move up because of the url bar gap.
380 * So add translation effect as well. */
381 m_zoom_move_transit = elm_transit_add();
382 if (!m_zoom_move_transit) {
383 BROWSER_LOGE("elm_transit_add failed");
386 /* Block event durring animation. */
387 elm_transit_event_enabled_set(m_zoom_move_transit, EINA_TRUE);
389 int browser_scroller_y = 0;
390 int url_layout_h = 0;
391 elm_scroller_region_get(browser_view->m_scroller, NULL, &browser_scroller_y, NULL, NULL);
392 evas_object_geometry_get(browser_view->m_url_layout, NULL, NULL, NULL, &url_layout_h);
395 evas_object_geometry_get(browser_view->m_scroller, NULL, &scroller_y, NULL, NULL);
397 if (browser_scroller_y > url_layout_h)
398 browser_scroller_y = url_layout_h;
400 elm_transit_object_add(m_zoom_move_transit, m_zoom_effect_image);
401 elm_transit_object_add(m_zoom_move_transit, m_flip_effect_image);
402 elm_transit_tween_mode_set(m_zoom_move_transit, ELM_TRANSIT_TWEEN_MODE_SINUSOIDAL);
403 elm_transit_objects_final_state_keep_set(m_zoom_move_transit, EINA_FALSE);
405 elm_transit_effect_translation_add(m_zoom_move_transit, 0, 0, 0,
406 (url_layout_h - browser_scroller_y - scroller_y - (6 * elm_scale_get())));
408 elm_transit_duration_set(m_zoom_move_transit, 0.5);
409 elm_transit_go(m_zoom_move_transit);
414 /* zoom out effect for the first time when user excutes multi window. */
415 Eina_Bool Browser_Multi_Window_View::_show_zoom_out_effect(void)
417 BROWSER_LOGD("[%s]", __func__);
418 Browser_Window *focused_window = m_data_manager->get_browser_view()->m_focused_window;
420 int ewk_view_current_x = 0;
421 int ewk_view_current_y = 0;
422 int ewk_view_current_w = 0;
423 int ewk_view_current_h = 0;
424 evas_object_geometry_get(focused_window->m_ewk_view, &ewk_view_current_x, &ewk_view_current_y,
425 &ewk_view_current_w, &ewk_view_current_h);
427 Browser_View *browser_view = m_data_manager->get_browser_view();
429 if (m_zoom_out_duration == 0) {
430 Elm_Transit *tmp = m_zoom_transit = elm_transit_add();
431 __zoom_out_finished_cb(this, NULL);
432 elm_transit_del(tmp);
436 /* m_zoom_effect_image is only for zoom out effect for the first time. */
437 m_zoom_transit = elm_transit_add();
438 if (!m_zoom_transit) {
439 BROWSER_LOGE("elm_transit_add failed");
442 /* Block event durring animation. */
443 elm_transit_event_enabled_set(m_zoom_transit, EINA_TRUE);
447 evas_object_geometry_get(m_zoom_effect_image, NULL, NULL, &snapshot_w, &snapshot_h);
448 evas_object_move(m_zoom_effect_image, ewk_view_current_x, ewk_view_current_y);
450 evas_object_show(m_zoom_effect_image);
452 int current_snapshot_x = 0;
453 int current_snapshot_y = 0;
454 int current_snapshot_w = 0;
455 int current_snapshot_h = 0;
456 std::vector<Browser_Window *> window_list = m_browser->get_window_list();
457 #if defined(HORIZONTAL_UI)
459 evas_object_geometry_get(window_list[0]->m_landscape_snapshot_image,
460 ¤t_snapshot_x, ¤t_snapshot_y, ¤t_snapshot_w, ¤t_snapshot_h);
463 evas_object_geometry_get(window_list[0]->m_portrait_snapshot_image,
464 ¤t_snapshot_x, ¤t_snapshot_y, ¤t_snapshot_w, ¤t_snapshot_h);
466 evas_object_move(m_flip_effect_image, current_snapshot_x, current_snapshot_y);
468 BROWSER_LOGD("current_snapshot_x=%d, current_snapshot_y=%d", current_snapshot_x, current_snapshot_y);
469 BROWSER_LOGD("current_snapshot_w=%d, current_snapshot_h=%d", current_snapshot_w, current_snapshot_h);
471 elm_transit_object_add(m_zoom_transit, m_zoom_effect_image);
472 elm_transit_object_add(m_zoom_transit, m_flip_effect_image);
473 elm_transit_tween_mode_set(m_zoom_transit, ELM_TRANSIT_TWEEN_MODE_SINUSOIDAL);
474 elm_transit_objects_final_state_keep_set(m_zoom_transit, EINA_FALSE);
475 elm_transit_effect_resizable_flip_add(m_zoom_transit, ELM_TRANSIT_EFFECT_FLIP_AXIS_Y, EINA_TRUE);
477 elm_transit_duration_set(m_zoom_transit, m_zoom_out_duration);
478 elm_transit_del_cb_set(m_zoom_transit, __zoom_out_finished_cb, this);
479 elm_transit_go(m_zoom_transit);
481 /* If the url bar in browser scroller is being displayed,
482 * the zoom animation should be move up because of the url bar gap.
483 * So add translation effect as well. */
484 m_zoom_move_transit = elm_transit_add();
485 if (!m_zoom_move_transit) {
486 BROWSER_LOGE("elm_transit_add failed");
489 /* Block event durring animation. */
490 elm_transit_event_enabled_set(m_zoom_move_transit, EINA_TRUE);
492 elm_transit_object_add(m_zoom_move_transit, m_zoom_effect_image);
493 elm_transit_object_add(m_zoom_move_transit, m_flip_effect_image);
494 elm_transit_tween_mode_set(m_zoom_move_transit, ELM_TRANSIT_TWEEN_MODE_SINUSOIDAL);
495 elm_transit_objects_final_state_keep_set(m_zoom_move_transit, EINA_FALSE);
497 int browser_scroller_y = 0;
498 int url_layout_h = 0;
499 elm_scroller_region_get(browser_view->m_scroller, NULL, &browser_scroller_y, NULL, NULL);
500 evas_object_geometry_get(browser_view->m_url_layout, NULL, NULL, NULL, &url_layout_h);
503 evas_object_geometry_get(browser_view->m_scroller, NULL, &scroller_y, NULL, NULL);
504 if (browser_scroller_y > url_layout_h)
505 browser_scroller_y = url_layout_h;
507 /* 4 * elm_scale_get() is to make the effect layout more smoothly. */
508 elm_transit_effect_translation_add(m_zoom_move_transit, 0, 0, 0,
509 (url_layout_h - browser_scroller_y - scroller_y - (6 * elm_scale_get())) * (-1));
511 elm_transit_duration_set(m_zoom_move_transit, m_zoom_out_duration);
512 elm_transit_go(m_zoom_move_transit);
517 void Browser_Multi_Window_View::_set_multi_window_mode(Eina_Bool is_multi_window)
519 BROWSER_LOGD("[%s]", __func__);
520 Browser_View *browser_view = m_data_manager->get_browser_view();
522 if (is_multi_window) {
523 /* The dimming background is done by
524 * edje_object_signal_emit(elm_layout_edje_get(browser_view->m_main_layout),
525 "show,multi_window,signal", "");
526 * Move above code to __fill_multi_window_items_idler_cb */
528 elm_object_part_content_set(browser_view->m_main_layout,
529 "elm.swallow.multi_window", m_main_layout);
531 /* Dim the multi window background. */
532 edje_object_signal_emit(elm_layout_edje_get(m_main_layout),
533 "show,multi_window,signal", "");
535 /* Unset navigationbar title object to hide the title bar arrow. */
536 browser_view->unset_navigationbar_title_object(EINA_TRUE);
538 /* Hide dim the multi window background. */
539 edje_object_signal_emit(elm_layout_edje_get(m_main_layout),
540 "hide,multi_window,signal", "");
541 /* Unset multi window layout from browser view. */
542 elm_object_part_content_unset(browser_view->m_main_layout,
543 "elm.swallow.multi_window");
544 /* Hide the swallow of multi window in browser main layout. */
545 edje_object_signal_emit(elm_layout_edje_get(browser_view->m_main_layout),
546 "hide,multi_window,signal", "");
548 /* Set navigationbar title object to show the title bar arrow. */
549 browser_view->unset_navigationbar_title_object(EINA_FALSE);
551 /* Without this code, the url is empty shortly when create deleted-window in multi window. */
552 if (browser_view->get_url().empty() && !browser_view->m_focused_window->m_url.empty())
553 browser_view->_set_url_entry(browser_view->m_focused_window->m_url.c_str());
555 browser_view->_set_url_entry(browser_view->get_url().c_str());
556 browser_view->_set_controlbar_back_forward_status();
560 void Browser_Multi_Window_View::__snapshot_clicked_cb(void *data, Evas_Object *obj,
561 const char *emission, const char *source)
566 BROWSER_LOGD("[%s]", __func__);
567 Browser_Multi_Window_View *multi_window_view = (Browser_Multi_Window_View *)data;
569 if (multi_window_view->m_scroll_move_transit) {
570 BROWSER_LOGE("new window transit is running");
574 multi_window_view->_snapshot_clicked(obj);
577 void Browser_Multi_Window_View::_snapshot_clicked(Evas_Object *layout_edje)
580 for (index = 0 ; index < m_item_list.size() ; index++) {
581 if (elm_layout_edje_get(m_item_list[index]) == layout_edje)
584 BROWSER_LOGD("m_current_position_index = %d, selected index = %d", m_current_position_index, index);
586 if (m_current_position_index != index)
589 std::vector<Browser_Window *> window_list = m_browser->get_window_list();
590 if (!window_list[index]->m_ewk_view) {
591 /* Workaround, the grey bg is displayed shortly when create deleted window. */
592 Browser_View *browser_view = m_data_manager->get_browser_view();
593 edje_object_signal_emit(elm_layout_edje_get(browser_view->m_main_layout),
594 "hide,grey_background,signal", "");
597 if (!_show_zoom_in_effect(m_item_list[index])) {
598 BROWSER_LOGE("_show_zoom_in_effect failed");
603 void Browser_Multi_Window_View::__delete_window_icon_clicked_cb(void *data, Evas_Object *obj,
604 const char *emission, const char *source)
609 BROWSER_LOGD("[%s]", __func__);
610 Browser_Multi_Window_View *multi_window_view = (Browser_Multi_Window_View *)data;
611 multi_window_view->__delete_window_icon_clicked(obj);
614 void Browser_Multi_Window_View::__delete_window_icon_clicked(Evas_Object *layout_edje)
617 for (index = 0 ; index < m_item_list.size() ; index++) {
618 if (elm_layout_edje_get(m_item_list[index]) == layout_edje)
621 BROWSER_LOGD("selected index = %d", index);
623 if (index != m_current_position_index)
626 evas_object_hide(m_item_list[index]);
628 if (m_item_list.size() == 2) {
629 /* In case of the muti window is 2, when delete a window, hide the delete icon. */
630 for (int i = 0 ; i < m_item_list.size() ; i++)
631 edje_object_signal_emit(elm_layout_edje_get(m_item_list[i]),
632 "hide,delete_window_icon,signal", "");
635 if (!_show_delete_window_scroll_effect())
636 BROWSER_LOGE("_show_delete_window_scroll_effect failed");
639 void Browser_Multi_Window_View::__delete_window_scroll_finished_cb(void *data,
640 Elm_Transit *transit)
642 BROWSER_LOGD("[%s]", __func__);
646 Browser_Multi_Window_View *multi_window_view = (Browser_Multi_Window_View *)data;
648 if (!multi_window_view->m_scroll_move_transit)
651 multi_window_view->m_scroll_move_transit = NULL;
653 multi_window_view->_delete_window_scroll_finished();
656 void Browser_Multi_Window_View::_delete_window_scroll_finished(void)
658 BROWSER_LOGD("[%s]", __func__);
659 elm_box_unpack(m_item_box, m_item_list[m_current_position_index]);
660 evas_object_del(m_item_list[m_current_position_index]);
661 m_item_list.erase(m_item_list.begin() + m_current_position_index);
663 std::vector<Browser_Window *> window_list = m_browser->get_window_list();
665 m_browser->delete_window(window_list[m_current_position_index]);
667 BROWSER_LOGD("window_list.size() = %d", m_browser->get_window_list().size());
668 if (m_current_position_index == m_browser->get_window_list().size())
669 m_current_position_index = m_current_position_index - 1;
671 if (m_page_control) {
672 elm_object_part_content_unset(m_main_layout, "elm.swallow.page_control");
673 evas_object_del(m_page_control);
676 m_page_control = elm_index_add(m_navi_bar);
677 if (!m_page_control) {
678 BROWSER_LOGD("elm_page_control_add failed");
681 elm_object_style_set(m_page_control, "pagecontrol");
682 elm_index_horizontal_set(m_page_control, EINA_TRUE);
683 elm_index_autohide_disabled_set(m_page_control, EINA_TRUE);
685 memset(m_index_items, 0x00, sizeof(Elm_Object_Item *) * BROWSER_MULTI_WINDOW_MAX_COUNT);
687 Elm_Object_Item *index_it = NULL;
688 for (int i = 0 ; i < m_browser->get_window_list().size() ; i++) {
689 char number[5] = {0, };
690 sprintf(number, "%d", i + 1);
692 if (m_current_position_index == i) {
693 m_index_items[i] = index_it = elm_index_item_append(m_page_control, number, __index_selected_cb, this);
695 m_index_items[i] = elm_index_item_append(m_page_control, number, __index_selected_cb, this);
699 elm_index_level_go(m_page_control, m_current_position_index);
700 elm_index_item_selected_set(index_it, EINA_TRUE);
702 elm_object_part_content_set(m_main_layout, "elm.swallow.page_control", m_page_control);
703 evas_object_show(m_page_control);
705 Browser_View *browser_view = m_data_manager->get_browser_view();
707 BROWSER_LOGD("m_current_position_index = %d", m_current_position_index);
709 window_list = m_browser->get_window_list();
710 const char *title = browser_view->get_title(window_list[m_current_position_index]).c_str();
711 const char *url = browser_view->get_url(window_list[m_current_position_index]).c_str();
712 if (!title || strlen(title) == 0) {
713 Evas_Object *entry = br_elm_editfield_entry_get(browser_view->m_option_header_url_edit_field);
714 const char *entry_text = elm_entry_entry_get(entry);
715 if (entry_text && strlen(entry_text)) {
716 BROWSER_LOGD("[%s][%s]", entry_text, entry_text);
717 char *markup = elm_entry_utf8_to_markup(entry_text);
719 edje_object_part_text_set(elm_layout_edje_get(m_main_layout), "elm.title", markup);
720 edje_object_part_text_set(elm_layout_edje_get(m_main_layout), "elm.url", markup);
724 edje_object_part_text_set(elm_layout_edje_get(m_main_layout), "elm.title", BR_STRING_EMPTY);
725 edje_object_part_text_set(elm_layout_edje_get(m_main_layout), "elm.url", "");
728 BROWSER_LOGD("[%s][%s]", title, url);
729 char *markup = elm_entry_utf8_to_markup(title);
731 edje_object_part_text_set(elm_layout_edje_get(m_main_layout), "elm.title", markup);
735 markup = elm_entry_utf8_to_markup(url);
737 edje_object_part_text_set(elm_layout_edje_get(m_main_layout), "elm.url", markup);
742 if (BROWSER_MULTI_WINDOW_MAX_COUNT > window_list.size())
743 elm_object_item_disabled_set(m_new_window_button, EINA_FALSE);
748 void Browser_Multi_Window_View::_show_grey_effect(void)
750 BROWSER_LOGD("[%s]", __func__);
751 for (int i = 0 ; i < m_item_list.size() ; i++) {
752 if (i == m_current_position_index)
753 edje_object_signal_emit(elm_layout_edje_get(m_item_list[i]),
754 "non_grey,snapshot,signal", "");
756 edje_object_signal_emit(elm_layout_edje_get(m_item_list[i]),
757 "grey,snapshot,signal", "");
761 Eina_Bool Browser_Multi_Window_View::_show_delete_window_scroll_effect(void)
763 BROWSER_LOGD("[%s]", __func__);
764 int scroll_size = _get_scroll_page_size();
766 m_scroll_move_transit = elm_transit_add();
767 if (!m_scroll_move_transit) {
768 BROWSER_LOGE("elm_transit_add failed");
771 /* Block event durring animation. */
772 elm_transit_event_enabled_set(m_scroll_move_transit, EINA_TRUE);
774 if (m_current_position_index != m_item_list.size() - 1) {
775 /* If the deleted multi window item is not the last one. */
776 for (int i = m_current_position_index + 1 ; i < m_item_list.size() ; i++)
777 elm_transit_object_add(m_scroll_move_transit, m_item_list[i]);
778 elm_transit_effect_translation_add(m_scroll_move_transit, 0, 0, scroll_size * (-1), 0);
780 elm_transit_object_add(m_scroll_move_transit, m_item_box);
781 elm_transit_effect_translation_add(m_scroll_move_transit, 0, 0, scroll_size, 0);
784 elm_transit_tween_mode_set(m_scroll_move_transit, ELM_TRANSIT_TWEEN_MODE_SINUSOIDAL);
785 elm_transit_objects_final_state_keep_set(m_scroll_move_transit, EINA_TRUE);
786 elm_transit_del_cb_set(m_scroll_move_transit, __delete_window_scroll_finished_cb, this);
787 elm_transit_duration_set(m_scroll_move_transit, 0.7);
788 elm_transit_go(m_scroll_move_transit);
793 Eina_Bool Browser_Multi_Window_View::_fill_multi_window_items(void)
795 BROWSER_LOGD("[%s]", __func__);
796 int ewk_view_current_w = 0;
797 int ewk_view_current_h = 0;
798 evas_object_geometry_get(m_data_manager->get_browser_view()->m_focused_window->m_ewk_view,
799 NULL, NULL, &ewk_view_current_w, &ewk_view_current_h);
801 m_dummy_front_item_layout = elm_layout_add(m_item_box);
802 if (!m_dummy_front_item_layout) {
803 BROWSER_LOGE("elm_layout_add failed");
806 if (!elm_layout_file_set(m_dummy_front_item_layout, BROWSER_EDJE_DIR"/browser-multi-window.edj",
807 "browser/multi-window/item"))
808 BROWSER_LOGE("elm_layout_file_set failed");
809 evas_object_size_hint_weight_set(m_dummy_front_item_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
810 evas_object_size_hint_align_set(m_dummy_front_item_layout, 0.5, 0.5);
811 m_dummy_front_item_snapshot = elm_icon_add(m_dummy_front_item_layout);
812 if (!m_dummy_front_item_snapshot) {
813 BROWSER_LOGE("elm_icon_add failed");
816 int empty_item_width = 0;
817 int padding = 22 * elm_scale_get();
818 int snapshot_width = ewk_view_current_w * BROWSER_MULTI_WINDOW_ITEM_RATIO;
819 int snapshot_height = ewk_view_current_h * BROWSER_MULTI_WINDOW_ITEM_RATIO;
821 empty_item_width = (ewk_view_current_w - snapshot_width)/2 - padding;
823 int scroll_size = _get_scroll_page_size();
825 float page_relative = (float)((float)scroll_size/(float)ewk_view_current_w);
826 elm_scroller_page_relative_set(m_scroller, page_relative, page_relative);
828 evas_object_size_hint_min_set(m_dummy_front_item_snapshot, empty_item_width, snapshot_height);
829 evas_object_resize(m_dummy_front_item_snapshot, empty_item_width, snapshot_height);
830 elm_object_part_content_set(m_dummy_front_item_layout, "elm.swallow.snapshot",
831 m_dummy_front_item_snapshot);
832 elm_box_pack_end(m_item_box, m_dummy_front_item_snapshot);
834 std::vector<Browser_Window *> window_list = m_browser->get_window_list();
835 BROWSER_LOGD("window_list.size()=%d", window_list.size());
836 for (int i = 0 ; i < window_list.size() ; i++) {
837 Evas_Object *item = elm_layout_add(m_navi_bar);
839 BROWSER_LOGE("elm_layout_add failed");
842 if (!elm_layout_file_set(item, BROWSER_EDJE_DIR"/browser-multi-window.edj",
843 "browser/multi-window/item")) {
844 BROWSER_LOGE("elm_layout_file_set failed");
847 evas_object_size_hint_weight_set(item, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
848 evas_object_size_hint_align_set(item, 0.5, 0.5);
850 Evas_Object *snapshot_image = NULL;
851 #if defined(HORIZONTAL_UI)
853 snapshot_image = window_list[i]->m_landscape_snapshot_image;
856 snapshot_image = window_list[i]->m_portrait_snapshot_image;
858 elm_object_part_content_set(item, "elm.swallow.snapshot", snapshot_image);
860 edje_object_signal_callback_add(elm_layout_edje_get(item), "mouse,clicked,1",
861 "elm.swallow.snapshot", __snapshot_clicked_cb, this);
863 edje_object_signal_callback_add(elm_layout_edje_get(item), "mouse,clicked,1",
864 "elm.image.delete_window", __delete_window_icon_clicked_cb, this);
866 if (window_list.size() > 1)
867 edje_object_signal_emit(elm_layout_edje_get(item),
868 "show,delete_window_icon,signal", "");
870 elm_box_pack_end(m_item_box, item);
872 m_item_list.push_back(item);
875 m_dummy_end_item_layout = elm_layout_add(m_item_box);
876 if (!m_dummy_end_item_layout) {
877 BROWSER_LOGE("elm_layout_add failed");
880 if (!elm_layout_file_set(m_dummy_end_item_layout, BROWSER_EDJE_DIR"/browser-multi-window.edj",
881 "browser/multi-window/item"))
882 BROWSER_LOGE("elm_layout_file_set failed");
883 evas_object_size_hint_weight_set(m_dummy_end_item_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
884 evas_object_size_hint_align_set(m_dummy_end_item_layout, 0.5, 0.5);
885 m_dummy_end_item_snapshot = elm_icon_add(m_dummy_end_item_layout);
886 if (!m_dummy_end_item_snapshot) {
887 BROWSER_LOGE("elm_icon_add failed");
890 evas_object_size_hint_min_set(m_dummy_end_item_snapshot, empty_item_width, snapshot_height);
891 evas_object_resize(m_dummy_end_item_snapshot, empty_item_width, snapshot_height);
892 elm_object_part_content_set(m_dummy_end_item_layout, "elm.swallow.snapshot",
893 m_dummy_end_item_snapshot);
894 elm_box_pack_end(m_item_box, m_dummy_end_item_snapshot);
899 void Browser_Multi_Window_View::close_multi_window(void)
901 BROWSER_LOGD("[%s]", __func__);
902 __close_multi_window_button_clicked_cb(this, NULL, NULL);
905 void Browser_Multi_Window_View::__close_multi_window_button_clicked_cb(void *data,
906 Evas_Object *obj, void *event_info)
908 BROWSER_LOGD("[%s]", __func__);
912 Browser_Multi_Window_View *multi_window_view = (Browser_Multi_Window_View *)data;
914 if (multi_window_view->m_zoom_transit || multi_window_view->m_zoom_move_transit
915 || multi_window_view->m_scroll_move_transit) {
916 BROWSER_LOGE("transit animation is running");
920 std::vector<Browser_Window *> window_list = m_browser->get_window_list();
922 for (int i = 0 ; i < multi_window_view->m_item_list.size() ; i++) {
923 /* The multi window item will be deleted,
924 * So unset the snapshot image from item layout.
925 * The snapshot is kept. */
926 elm_object_part_content_unset(multi_window_view->m_item_list[i],
927 "elm.swallow.snapshot");
928 #if defined(HORIZONTAL_UI)
929 if (window_list[i]->m_landscape_snapshot_image) {
930 evas_object_hide(window_list[i]->m_landscape_snapshot_image);
933 if (window_list[i]->m_portrait_snapshot_image) {
934 evas_object_hide(window_list[i]->m_portrait_snapshot_image);
937 Browser_View *browser_view = m_data_manager->get_browser_view();
939 elm_object_part_content_set(browser_view->m_main_layout, "elm.swallow.control_bar", browser_view->m_control_bar);
940 evas_object_show(browser_view->m_control_bar);
942 if (multi_window_view->m_controlbar) {
943 evas_object_del(multi_window_view->m_controlbar);
944 multi_window_view->m_controlbar = NULL;
947 multi_window_view->_set_multi_window_mode(EINA_FALSE);
949 m_data_manager->destroy_multi_window_view();
951 browser_view->_set_multi_window_controlbar_text(window_list.size());
953 browser_view->_update_back_forward_buttons();
955 if (window_list.size() >= BROWSER_MULTI_WINDOW_MAX_COUNT)
956 elm_object_item_disabled_set(browser_view->m_new_window_button, EINA_TRUE);
958 elm_object_item_disabled_set(browser_view->m_new_window_button, EINA_FALSE);
960 /* Set the title if enter the multi window while loading. */
961 browser_view->return_to_browser_view();
963 browser_view->resume_ewk_view(browser_view->m_focused_window->m_ewk_view);
966 void Browser_Multi_Window_View::__new_window_scroll_finished_cb(void *data,
967 Elm_Transit *transit)
969 BROWSER_LOGD("[%s]", __func__);
973 Browser_Multi_Window_View *multi_window_view = (Browser_Multi_Window_View *)data;
975 if (!multi_window_view->m_scroll_move_transit)
978 multi_window_view->m_scroll_move_transit = NULL;
980 if (!multi_window_view->_show_zoom_in_new_window_effect())
981 BROWSER_LOGE("_show_zoom_in_new_window_effect failed");
984 void Browser_Multi_Window_View::__new_window_zoom_in_finished_cb(void *data,
985 Elm_Transit *transit)
987 BROWSER_LOGD("[%s]", __func__);
991 Browser_Multi_Window_View *multi_window_view = (Browser_Multi_Window_View *)data;
993 if (!multi_window_view->m_zoom_transit)
996 /* window_list[window_list.size() - 1] is new created window. */
997 std::vector<Browser_Window *> window_list = m_browser->get_window_list();
998 m_browser->set_focused_window(window_list[window_list.size() - 1]);
1000 multi_window_view->m_zoom_transit = NULL;
1002 if (multi_window_view->m_zoom_effect_image) {
1003 evas_object_del(multi_window_view->m_zoom_effect_image);
1004 multi_window_view->m_zoom_effect_image = NULL;
1006 if (multi_window_view->m_flip_effect_image) {
1007 evas_object_del(multi_window_view->m_flip_effect_image);
1008 multi_window_view->m_flip_effect_image = NULL;
1011 __close_multi_window_button_clicked_cb(multi_window_view, NULL, NULL);
1013 Browser_View *browser_view = m_data_manager->get_browser_view();
1014 #if defined(FEATURE_MOST_VISITED_SITES)
1015 browser_view->load_url(BROWSER_MOST_VISITED_SITES_URL);
1017 browser_view->load_url(BROWSER_BLANK_PAGE_URL);
1021 Eina_Bool Browser_Multi_Window_View::_show_zoom_in_new_window_effect(void)
1023 BROWSER_LOGD("[%s]", __func__);
1024 if (!m_browser->create_new_window(EINA_TRUE)) {
1025 BROWSER_LOGD("create_new_window failed");
1029 std::vector<Browser_Window *> window_list = m_browser->get_window_list();
1031 m_zoom_effect_image = evas_object_rectangle_add(evas_object_evas_get(m_navi_bar));
1032 if (!m_zoom_effect_image) {
1033 BROWSER_LOGE("evas_object_rectangle_add failed");
1037 m_flip_effect_image = evas_object_rectangle_add(evas_object_evas_get(m_navi_bar));
1038 if (!m_flip_effect_image) {
1039 BROWSER_LOGE("evas_object_rectangle_add failed");
1047 Browser_View *browser_view = m_data_manager->get_browser_view();
1048 evas_object_geometry_get(browser_view->m_focused_window->m_ewk_view, &webview_x, &webview_y,
1049 &webview_w, &webview_h);
1051 evas_object_resize(m_flip_effect_image, webview_w, webview_h);
1052 evas_object_color_set(m_flip_effect_image, 255, 255, 255, 255);
1053 evas_object_move(m_flip_effect_image, webview_x, webview_y);
1059 int scroll_size = _get_scroll_page_size();
1061 #if defined(HORIZONTAL_UI)
1063 evas_object_geometry_get(window_list[m_item_list.size() - 1]->m_landscape_snapshot_image,
1064 &snapshot_x, &snapshot_y, &snapshot_w, &snapshot_h);
1067 evas_object_geometry_get(window_list[m_item_list.size() - 1]->m_portrait_snapshot_image,
1068 &snapshot_x, &snapshot_y, &snapshot_w, &snapshot_h);
1070 evas_object_resize(m_zoom_effect_image, snapshot_w, snapshot_h);
1071 evas_object_color_set(m_zoom_effect_image, 255, 255, 255, 255);
1072 evas_object_move(m_zoom_effect_image, snapshot_x + scroll_size, snapshot_y);
1073 evas_object_show(m_zoom_effect_image);
1075 /* m_zoom_effect_image is only for zoom out effect for the first time. */
1076 m_zoom_transit = elm_transit_add();
1077 if (!m_zoom_transit) {
1078 BROWSER_LOGE("elm_transit_add failed");
1081 /* Block event durring animation. */
1082 elm_transit_event_enabled_set(m_zoom_transit, EINA_TRUE);
1084 elm_transit_object_add(m_zoom_transit, m_zoom_effect_image);
1085 elm_transit_object_add(m_zoom_transit, m_flip_effect_image);
1086 elm_transit_tween_mode_set(m_zoom_transit, ELM_TRANSIT_TWEEN_MODE_SINUSOIDAL);
1087 elm_transit_objects_final_state_keep_set(m_zoom_transit, EINA_FALSE);
1088 elm_transit_effect_resizable_flip_add(m_zoom_transit, ELM_TRANSIT_EFFECT_FLIP_AXIS_Y, EINA_TRUE);
1089 elm_transit_duration_set(m_zoom_transit, 0.5);
1090 elm_transit_del_cb_set(m_zoom_transit, __new_window_zoom_in_finished_cb, this);
1091 elm_transit_go(m_zoom_transit);
1096 Eina_Bool Browser_Multi_Window_View::_show_new_window_scroll_effect(void)
1098 BROWSER_LOGD("[%s]", __func__);
1100 int gap_to_end = m_item_list.size() - m_current_position_index;
1101 int scroll_size = _get_scroll_page_size();
1103 m_scroll_move_transit = elm_transit_add();
1104 if (!m_scroll_move_transit) {
1105 BROWSER_LOGE("elm_transit_add failed");
1108 /* Block event durring animation. */
1109 elm_transit_event_enabled_set(m_scroll_move_transit, EINA_TRUE);
1111 elm_transit_object_add(m_scroll_move_transit, m_item_box);
1112 elm_transit_tween_mode_set(m_scroll_move_transit, ELM_TRANSIT_TWEEN_MODE_SINUSOIDAL);
1113 elm_transit_objects_final_state_keep_set(m_scroll_move_transit, EINA_TRUE);
1114 elm_transit_effect_translation_add(m_scroll_move_transit, 0, 0,
1115 (scroll_size * gap_to_end) * (-1), 0);
1116 elm_transit_del_cb_set(m_scroll_move_transit, __new_window_scroll_finished_cb, this);
1118 if (_is_grid_mode())
1119 elm_transit_duration_set(m_scroll_move_transit, 0.1);
1121 elm_transit_duration_set(m_scroll_move_transit, 0.7);
1122 elm_transit_go(m_scroll_move_transit);
1127 void Browser_Multi_Window_View::__new_window_button_clicked_cb(void *data,
1128 Evas_Object *obj, void *event_info)
1130 BROWSER_LOGD("[%s]", __func__);
1134 Browser_Multi_Window_View *multi_window_view = (Browser_Multi_Window_View *)data;
1135 if (multi_window_view->m_scroll_move_transit || multi_window_view->m_zoom_transit) {
1136 BROWSER_LOGE("animation is running");
1140 multi_window_view->_show_new_window_scroll_effect();
1142 Browser_View *browser_view = m_data_manager->get_browser_view();
1144 elm_object_part_content_unset(browser_view->m_main_layout, "elm.swallow.control_bar");
1146 elm_object_part_content_set(browser_view->m_main_layout, "elm.swallow.control_bar", browser_view->m_control_bar);
1148 if (multi_window_view->m_new_window_button)
1149 elm_object_item_disabled_set(multi_window_view->m_new_window_button, EINA_TRUE);
1150 if (multi_window_view->m_change_view_button)
1151 elm_object_item_disabled_set(multi_window_view->m_change_view_button, EINA_TRUE);
1152 elm_object_disabled_set(multi_window_view->m_cancel_button, EINA_TRUE);
1154 /* clear url entry filed when click new window button. */
1155 browser_view->_set_url_entry("");
1156 edje_object_signal_emit(elm_layout_edje_get(browser_view->m_url_entry_layout), "hide,favicon,signal", "");
1157 edje_object_signal_emit(elm_layout_edje_get(browser_view->m_option_header_url_entry_layout),
1158 "hide,favicon,signal", "");
1159 browser_view->_set_navigationbar_title("");
1162 void Browser_Multi_Window_View::__scroller_animation_stop_cb(void *data,
1163 Evas_Object *obj, void *event_info)
1165 BROWSER_LOGD("[%s]", __func__);
1168 Browser_Multi_Window_View *multi_window_view = (Browser_Multi_Window_View *)data;
1169 multi_window_view->_scroller_animation_stop();
1172 int Browser_Multi_Window_View::_get_scroll_page_size(void)
1174 BROWSER_LOGD("[%s]", __func__);
1177 std::vector<Browser_Window *> window_list = m_browser->get_window_list();
1179 #if defined(HORIZONTAL_UI)
1181 evas_object_geometry_get(window_list[m_current_position_index]->m_landscape_snapshot_image,
1182 NULL, NULL, &snapshot_w, NULL);
1185 evas_object_geometry_get(window_list[m_current_position_index]->m_portrait_snapshot_image,
1186 NULL, NULL, &snapshot_w, NULL);
1188 int padding = 22 * elm_scale_get();
1190 int scroll_size = snapshot_w + (padding * 2);
1195 void Browser_Multi_Window_View::_scroller_animation_stop(void)
1198 elm_scroller_region_get(m_scroller, &scroller_x, NULL, NULL, NULL);
1200 int padding = 22 * elm_scale_get();
1201 int scroll_size = _get_scroll_page_size();
1204 * the scroll size is 337 or 338. It seems that the gap of floating operation.
1205 * So decrease the scroll_size by padding. */
1206 m_current_position_index = scroller_x / (scroll_size - padding);
1207 BROWSER_LOGD("scroller_x = %d, scroll_size = %d, m_current_position_index = %d",
1208 scroller_x, scroll_size, m_current_position_index);
1210 Browser_View *browser_view = m_data_manager->get_browser_view();
1211 std::vector<Browser_Window *> window_list = m_browser->get_window_list();
1213 if ( m_current_position_index + 1 > window_list.size())
1214 m_current_position_index = window_list.size() - 1;
1216 if (!window_list[m_current_position_index]->m_ewk_view) {
1217 std::string title_string = window_list[m_current_position_index]->m_title;
1218 std::string url_string = window_list[m_current_position_index]->m_url;
1219 if (title_string.empty()) {
1220 edje_object_part_text_set(elm_layout_edje_get(m_main_layout), "elm.title", BR_STRING_EMPTY);
1221 edje_object_part_text_set(elm_layout_edje_get(m_main_layout), "elm.url", "");
1223 BROWSER_LOGD("[%s][%s]", title_string.c_str(), url_string.c_str());
1224 char *markup = elm_entry_utf8_to_markup(title_string.c_str());
1226 edje_object_part_text_set(elm_layout_edje_get(m_main_layout), "elm.title", markup);
1230 markup = elm_entry_utf8_to_markup(url_string.c_str());
1232 edje_object_part_text_set(elm_layout_edje_get(m_main_layout), "elm.url", markup);
1236 } else if (!window_list[m_current_position_index]->m_title.empty()) {
1237 BROWSER_LOGD("[%s][%s]", window_list[m_current_position_index]->m_title.c_str(), window_list[m_current_position_index]->m_url.c_str());
1238 /* If the ewk view is deleted because of unused case(etc. low memory),
1239 * and it is re-created, then set the title. */
1240 char *markup = elm_entry_utf8_to_markup(window_list[m_current_position_index]->m_title.c_str());
1242 edje_object_part_text_set(elm_layout_edje_get(m_main_layout), "elm.title", markup);
1245 markup = elm_entry_utf8_to_markup(window_list[m_current_position_index]->m_url.c_str());
1247 edje_object_part_text_set(elm_layout_edje_get(m_main_layout), "elm.url", markup);
1251 std::string title = browser_view->get_title(window_list[m_current_position_index]);
1252 std::string url = browser_view->get_url(window_list[m_current_position_index]);
1253 if (title.empty()) {
1254 edje_object_part_text_set(elm_layout_edje_get(m_main_layout), "elm.title", BR_STRING_EMPTY);
1255 edje_object_part_text_set(elm_layout_edje_get(m_main_layout), "elm.url", "");
1257 std::string title_string = std::string(title);
1258 std::string url_string = std::string(url);
1260 char *markup = elm_entry_utf8_to_markup(title_string.c_str());
1261 BROWSER_LOGD("[%s][%s]", title_string.c_str(), url_string.c_str());
1263 edje_object_part_text_set(elm_layout_edje_get(m_main_layout), "elm.title", markup);
1267 markup = elm_entry_utf8_to_markup(url_string.c_str());
1269 edje_object_part_text_set(elm_layout_edje_get(m_main_layout), "elm.url", markup);
1275 elm_index_level_go(m_page_control, m_current_position_index);
1277 if (m_index_items[m_current_position_index])
1278 elm_index_item_selected_set(m_index_items[m_current_position_index], EINA_TRUE);
1279 BROWSER_LOGD("elm_index_level_go, m_current_position_index = %d", m_current_position_index);
1281 _show_grey_effect();
1284 Eina_Bool Browser_Multi_Window_View::_is_grid_mode(void)
1286 BROWSER_LOGD("[%s]", __func__);
1287 const char* state = edje_object_part_state_get(elm_layout_edje_get(m_main_layout),
1288 "elm.swallow.scroller", NULL);
1289 if (state && !strncmp(state, "default", strlen("default")))
1295 /* zoom in effect when user selects mult window item. */
1296 Eina_Bool Browser_Multi_Window_View::_show_grid_mode_zoom_in_effect(int index)
1298 BROWSER_LOGD("[%s]", __func__);
1299 Browser_Window *focused_window = m_data_manager->get_browser_view()->m_focused_window;
1301 std::vector<Browser_Window *> window_list = m_browser->get_window_list();
1302 Elm_Object_Item *gengrid_item = elm_gengrid_first_item_get(m_gengrid);
1303 for (int i = 1 ; i < window_list.size() ; i++) {
1306 gengrid_item = elm_gengrid_item_next_get(gengrid_item);
1309 const Evas_Object *snapshot_layout = elm_object_item_part_content_get(gengrid_item, "elm.swallow.icon");
1315 evas_object_geometry_get(snapshot_layout, &snapshot_x, &snapshot_y, &snapshot_w, &snapshot_h);
1317 evas_object_hide((Evas_Object *)snapshot_layout);
1319 int current_ewk_view_x = 0;
1320 int current_ewk_view_y = 0;
1321 int current_ewk_view_w = 0;
1322 int current_ewk_view_h = 0;
1323 Browser_View *browser_view = m_data_manager->get_browser_view();
1324 evas_object_geometry_get(browser_view->m_focused_window->m_ewk_view, ¤t_ewk_view_x, ¤t_ewk_view_y,
1325 ¤t_ewk_view_w, ¤t_ewk_view_h);
1327 int to_x = (current_ewk_view_w - snapshot_w) / 2 - snapshot_x;
1328 int to_y = (current_ewk_view_h - snapshot_h) / 2 - snapshot_y + current_ewk_view_y;
1330 BROWSER_LOGD("snapshot_x = %d, snapshot_y= %d, snapshot_w = %d, snapshot_h=%d, ", snapshot_x, snapshot_y, snapshot_w, snapshot_h);
1332 if (window_list[index]->m_ewk_view == NULL) {
1333 m_zoom_effect_image = evas_object_rectangle_add(evas_object_evas_get(m_navi_bar));
1334 if (!m_zoom_effect_image) {
1335 BROWSER_LOGE("evas_object_rectangle_add failed");
1338 evas_object_resize(m_zoom_effect_image, snapshot_w, snapshot_h);
1339 evas_object_color_set(m_zoom_effect_image, 255, 255, 255, 255);
1341 m_flip_effect_image = evas_object_rectangle_add(evas_object_evas_get(m_navi_bar));
1342 if (!m_flip_effect_image) {
1343 BROWSER_LOGE("evas_object_rectangle_add failed");
1346 evas_object_resize(m_flip_effect_image, current_ewk_view_w, current_ewk_view_h);
1347 evas_object_color_set(m_flip_effect_image, 255, 255, 255, 255);
1349 m_zoom_effect_image = _capture_snapshot(window_list[index],
1350 (float)((float)snapshot_w / (float)current_ewk_view_w));
1351 if (!m_zoom_effect_image) {
1352 BROWSER_LOGE("_capture_snapshot failed");
1353 m_zoom_effect_image = evas_object_rectangle_add(evas_object_evas_get(m_navi_bar));
1354 if (!m_zoom_effect_image) {
1355 BROWSER_LOGE("evas_object_rectangle_add failed");
1358 evas_object_resize(m_zoom_effect_image, snapshot_w, snapshot_h);
1359 evas_object_color_set(m_zoom_effect_image, 255, 255, 255, 255);
1362 m_flip_effect_image = _capture_snapshot(window_list[index], 1.0);
1363 if (!m_flip_effect_image) {
1364 BROWSER_LOGE("_capture_snapshot failed");
1365 m_flip_effect_image = evas_object_rectangle_add(evas_object_evas_get(m_navi_bar));
1366 if (!m_flip_effect_image) {
1367 BROWSER_LOGE("evas_object_rectangle_add failed");
1370 evas_object_resize(m_flip_effect_image, current_ewk_view_w, current_ewk_view_h);
1371 evas_object_color_set(m_flip_effect_image, 255, 255, 255, 255);
1374 evas_object_move(m_flip_effect_image, current_ewk_view_x, current_ewk_view_y);
1376 evas_object_move(m_zoom_effect_image, snapshot_x, snapshot_y);
1377 evas_object_show(m_zoom_effect_image);
1379 /* m_zoom_effect_image is only for zoom out effect for the first time. */
1380 m_zoom_transit = elm_transit_add();
1381 if (!m_zoom_transit) {
1382 BROWSER_LOGE("elm_transit_add failed");
1385 /* Block event durring animation. */
1386 elm_transit_event_enabled_set(m_zoom_transit, EINA_TRUE);
1388 m_select_item_index = index;
1390 #if defined(FEATURE_MOST_VISITED_SITES)
1391 /* Destroy speed dial little eariler because of blinking issue. */
1392 if (!(browser_view->get_url(window_list[m_select_item_index]).empty()))
1393 browser_view->_show_most_visited_sites(EINA_FALSE);
1396 elm_transit_object_add(m_zoom_transit, m_zoom_effect_image);
1397 elm_transit_object_add(m_zoom_transit, m_flip_effect_image);
1398 elm_transit_tween_mode_set(m_zoom_transit, ELM_TRANSIT_TWEEN_MODE_SINUSOIDAL);
1399 elm_transit_objects_final_state_keep_set(m_zoom_transit, EINA_FALSE);
1400 elm_transit_effect_resizable_flip_add(m_zoom_transit, ELM_TRANSIT_EFFECT_FLIP_AXIS_Y, EINA_TRUE);
1401 elm_transit_duration_set(m_zoom_transit, 0.5);
1402 elm_transit_del_cb_set(m_zoom_transit, __zoom_in_finished_cb, this);
1403 elm_transit_go(m_zoom_transit);
1405 /* If the url bar in browser scroller is being displayed,
1406 * the zoom animation should be move up because of the url bar gap.
1407 * So add translation effect as well. */
1408 m_zoom_move_transit = elm_transit_add();
1409 if (!m_zoom_move_transit) {
1410 BROWSER_LOGE("elm_transit_add failed");
1413 /* Block event durring animation. */
1414 elm_transit_event_enabled_set(m_zoom_move_transit, EINA_TRUE);
1416 elm_transit_object_add(m_zoom_move_transit, m_zoom_effect_image);
1417 elm_transit_object_add(m_zoom_move_transit, m_flip_effect_image);
1418 elm_transit_tween_mode_set(m_zoom_move_transit, ELM_TRANSIT_TWEEN_MODE_SINUSOIDAL);
1419 elm_transit_objects_final_state_keep_set(m_zoom_move_transit, EINA_FALSE);
1421 BROWSER_LOGD("to_x = %d, to_y = %d", to_x, to_y);
1422 elm_transit_effect_translation_add(m_zoom_move_transit, 0, 0, to_x, to_y);
1424 elm_transit_duration_set(m_zoom_move_transit, 0.5);
1425 elm_transit_go(m_zoom_move_transit);
1430 Eina_Bool Browser_Multi_Window_View::__delete_window_icon_grid_mode(int index)
1432 BROWSER_LOGD("[%s]", __func__);
1433 std::vector<Browser_Window *> window_list = m_browser->get_window_list();
1434 Elm_Object_Item *gengrid_item = elm_gengrid_first_item_get(m_gengrid);
1435 for (int i = 1 ; i < window_list.size() ; i++) {
1438 gengrid_item = elm_gengrid_item_next_get(gengrid_item);
1440 elm_object_item_del(gengrid_item);
1442 m_current_position_index = index;
1444 _delete_window_scroll_finished();
1446 if (m_item_list.size() == 1) {
1447 /* In case of the muti window is 1, hide the delete icon in normal mode. */
1448 edje_object_signal_emit(elm_layout_edje_get(m_item_list[0]),
1449 "hide,delete_window_icon,signal", "");
1452 if (!_create_gengrid()) {
1453 BROWSER_LOGE("_create_gengrid failed");
1460 void Browser_Multi_Window_View::__delete_window_icon_grid_mode_clicked_cb(void *data,
1461 Evas_Object *obj, const char *emission, const char *source)
1463 BROWSER_LOGD("[%s]", __func__);
1467 gengrid_callback_param *param = (gengrid_callback_param *)data;
1468 Browser_Multi_Window_View *multi_window_view = NULL;
1469 multi_window_view = (Browser_Multi_Window_View *)(param->multi_window_view);
1471 if (multi_window_view->m_is_reordering) {
1472 BROWSER_LOGD("reodering mode");
1473 multi_window_view->m_is_reordering = EINA_FALSE;
1477 int index = param->index;
1478 multi_window_view->__delete_window_icon_grid_mode(index);
1481 void Browser_Multi_Window_View::__snapshot_grid_mode_clicked_cb(void *data,
1482 Evas_Object *obj, const char *emission, const char *source)
1484 BROWSER_LOGD("[%s]", __func__);
1488 gengrid_callback_param *param = (gengrid_callback_param *)data;
1489 Browser_Multi_Window_View *multi_window_view = NULL;
1490 multi_window_view = (Browser_Multi_Window_View *)(param->multi_window_view);
1491 if (multi_window_view->m_is_reordering) {
1492 BROWSER_LOGD("reodering mode");
1493 multi_window_view->m_is_reordering = EINA_FALSE;
1496 if (multi_window_view->m_zoom_transit) {
1497 BROWSER_LOGD("zoom transit is running");
1501 int index = param->index;
1503 if (!multi_window_view->_show_grid_mode_zoom_in_effect(index))
1504 BROWSER_LOGE("_show_grid_mode_zoom_in_effect failed");
1507 Evas_Object *Browser_Multi_Window_View::_get_gengrid_icon_cb(void *data,
1508 Evas_Object *obj, const char *part)
1513 gengrid_callback_param *param = (gengrid_callback_param *)data;
1514 Browser_Multi_Window_View *multi_window_view = NULL;
1515 multi_window_view = (Browser_Multi_Window_View *)(param->multi_window_view);
1516 int index = param->index;
1518 if (!strncmp(part, "elm.swallow.icon", strlen("elm.swallow.icon"))) {
1519 Evas_Object *snapshot_image = evas_object_image_add(evas_object_evas_get(obj));
1520 if (!snapshot_image) {
1521 BROWSER_LOGE("evas_object_image_add failed");
1524 std::vector<Browser_Window *> window_list = m_browser->get_window_list();
1527 #if defined(HORIZONTAL_UI)
1528 if (multi_window_view->is_landscape()) {
1529 evas_object_image_source_set(snapshot_image, window_list[index]->m_landscape_snapshot_image);
1530 evas_object_geometry_get(window_list[index]->m_landscape_snapshot_image, NULL, NULL,
1531 &snapshot_w, &snapshot_h);
1532 BROWSER_LOGD("landscape, snapshot_w=%d, snapshot_h=%d", snapshot_w, snapshot_h);
1537 evas_object_image_source_set(snapshot_image, window_list[index]->m_portrait_snapshot_image);
1538 evas_object_geometry_get(window_list[index]->m_portrait_snapshot_image, NULL, NULL,
1539 &snapshot_w, &snapshot_h);
1540 BROWSER_LOGD("portrait, snapshot_w=%d, snapshot_h=%d", snapshot_w, snapshot_h);
1545 elm_gengrid_item_size_get(multi_window_view->m_gengrid, &item_w, &item_h);
1546 evas_object_image_fill_set(snapshot_image, 0, 0, item_w, item_h);
1548 Evas_Object *grid_item_layout = elm_layout_add(obj);
1549 if (!grid_item_layout) {
1550 BROWSER_LOGE("grid_item_layout failed");
1553 if (!elm_layout_file_set(grid_item_layout, BROWSER_EDJE_DIR"/browser-multi-window.edj",
1554 "browser/multi-window/grid_item"))
1555 BROWSER_LOGE("elm_layout_file_set failed");
1557 if (window_list.size() > 1)
1558 edje_object_signal_emit(elm_layout_edje_get(grid_item_layout),
1559 "show,delete_icon,signal", "");
1561 evas_object_size_hint_weight_set(grid_item_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1562 evas_object_size_hint_align_set(grid_item_layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
1563 elm_object_part_content_set(grid_item_layout, "elm.swallow.snapshot", snapshot_image);
1564 evas_object_show(snapshot_image);
1565 evas_object_show(grid_item_layout);
1567 edje_object_signal_callback_add(elm_layout_edje_get(grid_item_layout), "mouse,clicked,1",
1568 "delete_icon_click_area", __delete_window_icon_grid_mode_clicked_cb, data);
1569 edje_object_signal_callback_add(elm_layout_edje_get(grid_item_layout), "mouse,up,1",
1570 "elm.swallow.snapshot", __snapshot_grid_mode_clicked_cb, data);
1572 return grid_item_layout;
1578 void Browser_Multi_Window_View::__gengrid_item_longpress_cb(void *data, Evas_Object *obj, void *event_info)
1580 BROWSER_LOGD("[%s]", __func__);
1585 Browser_Multi_Window_View *multi_window_view = (Browser_Multi_Window_View *)data;
1586 multi_window_view->m_is_reordering = EINA_TRUE;
1589 Eina_Bool Browser_Multi_Window_View::_reorder_windows(void)
1591 BROWSER_LOGD("[%s]", __func__);
1592 std::vector<Browser_Window *> window_list = m_browser->get_window_list();
1593 std::vector<Browser_Window *> reodered_list;
1594 std::vector<Evas_Object *> reodered_item = m_item_list;
1595 reodered_list.clear();
1596 reodered_item.clear();
1598 Elm_Object_Item *it = elm_gengrid_first_item_get(m_gengrid);
1599 for (int i = 0 ; i < window_list.size() ; i++) {
1602 gengrid_callback_param *it_data = (gengrid_callback_param *)elm_object_item_data_get(it);
1603 BROWSER_LOGD("i=[%d], index=[%d]", i, it_data->index);
1605 reodered_list.push_back(window_list[it_data->index]);
1606 reodered_item.push_back(m_item_list[it_data->index]);
1610 it = elm_gengrid_item_next_get(it);
1613 /* Reoder the browser class windows. */
1614 m_browser->change_order(reodered_list);
1616 /* Reoder the multi window normal mode items. */
1617 m_item_list.clear();
1618 m_item_list = reodered_item;
1620 /* Reoder the multi window normal mode items. */
1621 elm_box_unpack_all(m_item_box);
1622 elm_box_pack_end(m_item_box, m_dummy_front_item_snapshot);
1623 for (int i = 0 ; i < m_item_list.size() ; i++)
1624 elm_box_pack_end(m_item_box, m_item_list[i]);
1625 elm_box_pack_end(m_item_box, m_dummy_end_item_snapshot);
1627 evas_object_smart_callback_call(m_scroller, "scroll,anim,stop", NULL);
1632 void Browser_Multi_Window_View::__gengrid_item_moved_cb(void *data, Evas_Object *obj, void *event_info)
1634 BROWSER_LOGD("[%s]", __func__);
1639 Browser_Multi_Window_View *multi_window_view = (Browser_Multi_Window_View *)data;
1640 if (!multi_window_view->_reorder_windows())
1641 BROWSER_LOGE("_reorder_windows failed");
1644 Eina_Bool Browser_Multi_Window_View::_create_gengrid(void)
1647 evas_object_del(m_gengrid);
1649 m_gengrid = elm_gengrid_add(m_navi_bar);
1651 BROWSER_LOGE("elm_gengrid_add failed");
1654 std::vector<Browser_Window *> window_list = m_browser->get_window_list();
1656 elm_object_part_content_set(m_main_layout, "elm.swallow.gengrid", m_gengrid);
1659 evas_object_geometry_get(m_win, NULL, NULL, &window_w, NULL);
1661 int gengrid_area_h = 0;
1662 edje_object_part_geometry_get(elm_layout_edje_get(m_main_layout), "elm.swallow.gengrid",
1663 NULL, NULL, NULL, &gengrid_area_h);
1665 elm_gengrid_item_size_set(m_gengrid, window_w / 3, gengrid_area_h / 3);
1666 elm_gengrid_horizontal_set(m_gengrid, EINA_FALSE);
1667 elm_gengrid_bounce_set(m_gengrid, EINA_FALSE, EINA_FALSE);
1668 elm_gengrid_multi_select_set(m_gengrid, EINA_FALSE);
1669 elm_gengrid_select_mode_set(m_gengrid, ELM_OBJECT_SELECT_MODE_NONE);
1670 elm_gengrid_align_set(m_gengrid, 0.0, 0.0);
1671 elm_gengrid_reorder_mode_set(m_gengrid, EINA_TRUE);
1672 evas_object_show(m_gengrid);
1674 evas_object_smart_callback_add(m_gengrid, "moved", __gengrid_item_moved_cb, this);
1675 evas_object_smart_callback_add(m_gengrid, "longpressed", __gengrid_item_longpress_cb, this);
1677 m_gengrid_item_class.item_style = "default_grid";
1678 m_gengrid_item_class.func.text_get = NULL;
1679 m_gengrid_item_class.func.content_get = _get_gengrid_icon_cb;
1680 m_gengrid_item_class.func.state_get = NULL;
1681 m_gengrid_item_class.func.del = NULL;
1683 for (int i = 0 ; i < window_list.size() ; i++ ) {
1684 m_callback_param[i].multi_window_view = this;
1685 m_callback_param[i].index = i;
1686 elm_gengrid_item_append(m_gengrid, &m_gengrid_item_class, &m_callback_param[i], NULL, NULL);
1692 void Browser_Multi_Window_View::__view_change_button_clicked_cb(void *data,
1693 Evas_Object *obj, void *event_info)
1695 BROWSER_LOGD("[%s]", __func__);
1699 Browser_Multi_Window_View *multi_window_view = (Browser_Multi_Window_View *)data;
1701 if (multi_window_view->m_zoom_transit)
1704 if (!multi_window_view->_is_grid_mode()) {
1705 if (!multi_window_view->_create_gengrid()) {
1706 BROWSER_LOGE("_create_gengrid failed");
1709 edje_object_signal_emit(elm_layout_edje_get(multi_window_view->m_main_layout),
1710 "show,grid_mode,signal", "");
1712 elm_toolbar_item_icon_set(multi_window_view->m_change_view_button,
1713 BROWSER_IMAGE_DIR"/I01_controlbar_icon_view_change.png");
1715 /* To sync grid mode, if the window is deleted or reodered at grid mode. */
1716 evas_object_smart_callback_call(multi_window_view->m_scroller, "scroll,anim,stop", NULL);
1718 edje_object_signal_emit(elm_layout_edje_get(multi_window_view->m_main_layout),
1719 "show,normal_mode,signal", "");
1720 elm_toolbar_item_icon_set(multi_window_view->m_change_view_button,
1721 BROWSER_IMAGE_DIR"/I01_controlbar_icon_view_change_3x3.png");
1725 void Browser_Multi_Window_View::__delete_gengrid_cb(void *data,
1726 Evas_Object *obj, const char *emission, const char *source)
1728 BROWSER_LOGD("[%s]", __func__);
1732 Browser_Multi_Window_View *multi_window_view = (Browser_Multi_Window_View *)data;
1733 if (multi_window_view->m_gengrid) {
1734 evas_object_del(multi_window_view->m_gengrid);
1735 multi_window_view->m_gengrid = NULL;
1739 Eina_Bool Browser_Multi_Window_View::__zoom_out_effect_idler_cb(void *data)
1741 BROWSER_LOGD("[%s]", __func__);
1743 return ECORE_CALLBACK_CANCEL;
1745 Browser_Multi_Window_View *multi_window_view = (Browser_Multi_Window_View *)data;
1746 multi_window_view->m_zoom_out_effect_idler = NULL;
1748 if (multi_window_view->m_init_grid_mode) {
1749 multi_window_view->__zoom_out_finished();
1751 __view_change_button_clicked_cb(multi_window_view, NULL, NULL);
1752 edje_object_signal_emit(elm_layout_edje_get(multi_window_view->m_main_layout),
1753 "show,bg,signal", "");
1754 multi_window_view->m_init_grid_mode = EINA_FALSE;
1755 return ECORE_CALLBACK_CANCEL;
1758 /* zoom out effect for the first time when user excutes multi window. */
1759 if (!multi_window_view->_show_zoom_out_effect()) {
1760 BROWSER_LOGD("_show_zoom_out_effect failed");
1761 return ECORE_CALLBACK_CANCEL;
1764 edje_object_signal_emit(elm_layout_edje_get(multi_window_view->m_main_layout),
1765 "show,bg,signal", "");
1767 return ECORE_CALLBACK_CANCEL;
1770 void Browser_Multi_Window_View::__index_selected_cb(void *data, Evas_Object *obj, void *event_info)
1772 BROWSER_LOGD("[%s]", __func__);
1773 Browser_Multi_Window_View *multi_window_view = (Browser_Multi_Window_View *)data;
1774 Elm_Object_Item *selected_it = (Elm_Object_Item *)event_info;
1775 int index = atoi(elm_index_item_letter_get(selected_it));
1776 BROWSER_LOGD("selected index = %d, multi_window_view->m_current_position_index = %d",
1777 index, multi_window_view->m_current_position_index);
1779 if (multi_window_view->m_current_position_index == index - 1 || index - 1 < 0)
1782 multi_window_view->m_current_position_index = index - 1;
1784 int scroll_size = multi_window_view->_get_scroll_page_size();
1788 BROWSER_LOGD("multi_window_view->m_current_position_index = %d, scroll_size=%d",
1789 multi_window_view->m_current_position_index, scroll_size);
1790 elm_scroller_region_get(multi_window_view->m_scroller, NULL, &scroller_y, &scroller_w, &scroller_h);
1791 elm_scroller_region_bring_in(multi_window_view->m_scroller, scroll_size * multi_window_view->m_current_position_index,
1792 scroller_y, scroller_w, scroller_h);
1795 Evas_Object *Browser_Multi_Window_View::_create_control_bar(void)
1797 BROWSER_LOGD("[%s]", __func__);
1798 Evas_Object *controlbar_layout;
1799 controlbar_layout = elm_layout_add(m_main_layout);
1800 if (!controlbar_layout) {
1801 BROWSER_LOGE("elm_layout_add failed");
1804 if (!elm_layout_file_set(controlbar_layout, BROWSER_EDJE_DIR"/browser-view-control-bar.edj",
1805 "browser-view-controlbar")) {
1806 BROWSER_LOGE("Can not set layout browser-view-controlbar\n");
1809 evas_object_size_hint_weight_set(controlbar_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1810 evas_object_size_hint_align_set(controlbar_layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
1811 evas_object_show(controlbar_layout);
1813 Evas_Object *control_bar;
1814 control_bar = elm_toolbar_add(controlbar_layout);
1816 elm_object_style_set(control_bar, "browser/browser-view");
1818 elm_toolbar_shrink_mode_set(control_bar, ELM_TOOLBAR_SHRINK_EXPAND);
1819 m_new_window_button = elm_toolbar_item_append(control_bar, BROWSER_IMAGE_DIR"/I01_controlbar_icon_new_window.png",
1820 NULL, __new_window_button_clicked_cb, this);
1822 Elm_Object_Item *item = elm_toolbar_item_append(control_bar, NULL, NULL, NULL, NULL);
1823 elm_object_item_disabled_set(item, EINA_TRUE);
1825 m_change_view_button = elm_toolbar_item_append(control_bar,
1826 BROWSER_IMAGE_DIR"/I01_controlbar_icon_view_change_3x3.png", NULL,
1827 __view_change_button_clicked_cb, this);
1829 item = elm_toolbar_item_append(control_bar, NULL, NULL, NULL, NULL);
1830 elm_object_item_disabled_set(item, EINA_TRUE);
1832 elm_object_part_content_set(controlbar_layout, "elm.swallow.controlbar", control_bar);
1834 m_cancel_button = elm_button_add(control_bar);
1835 if (!m_cancel_button) {
1836 BROWSER_LOGE("elm_button_add failed");
1839 elm_object_style_set(m_cancel_button, "browser/multi_window_cancel_button");
1840 elm_object_text_set(m_cancel_button, BR_STRING_CANCEL);
1842 elm_object_part_content_set(controlbar_layout, "elm.swallow.back_button", m_cancel_button);
1843 evas_object_smart_callback_add(m_cancel_button, "clicked", __close_multi_window_button_clicked_cb, this);
1844 evas_object_show(m_cancel_button);
1846 evas_object_show(control_bar);
1849 return controlbar_layout;
1852 Eina_Bool Browser_Multi_Window_View::_create_main_layout(void)
1854 BROWSER_LOGD("[%s]", __func__);
1855 Browser_View *browser_view = m_data_manager->get_browser_view();
1857 /* m_zoom_effect_image is only for zoom out effect for the first time. */
1858 Browser_Window *focused_window = m_data_manager->get_browser_view()->m_focused_window;
1859 if (browser_view->get_url(focused_window).empty()) {
1860 m_zoom_effect_image = evas_object_rectangle_add(evas_object_evas_get(m_navi_bar));
1861 if (!m_zoom_effect_image) {
1862 BROWSER_LOGE("evas_object_rectangle_add failed");
1865 int focused_ewk_view_w = 0;
1866 int focused_ewk_view_h = 0;
1867 evas_object_geometry_get(browser_view->m_focused_window->m_ewk_view, NULL, NULL,
1868 &focused_ewk_view_w, &focused_ewk_view_h);
1870 evas_object_size_hint_min_set(m_zoom_effect_image, focused_ewk_view_w, focused_ewk_view_h);
1871 evas_object_resize(m_zoom_effect_image, focused_ewk_view_w, focused_ewk_view_h);
1872 evas_object_color_set(m_zoom_effect_image, 255, 255, 255, 255);
1874 m_flip_effect_image = evas_object_rectangle_add(evas_object_evas_get(m_navi_bar));
1875 if (!m_flip_effect_image) {
1876 BROWSER_LOGE("evas_object_rectangle_add failed");
1880 evas_object_size_hint_min_set(m_flip_effect_image,
1881 (int)(focused_ewk_view_w * BROWSER_MULTI_WINDOW_ITEM_RATIO),
1882 (int)(focused_ewk_view_h * BROWSER_MULTI_WINDOW_ITEM_RATIO));
1883 evas_object_resize(m_flip_effect_image,
1884 (int)(focused_ewk_view_w * BROWSER_MULTI_WINDOW_ITEM_RATIO),
1885 (int)(focused_ewk_view_h * BROWSER_MULTI_WINDOW_ITEM_RATIO));
1887 evas_object_color_set(m_flip_effect_image, 255, 255, 255, 255);
1889 m_zoom_effect_image = _capture_snapshot(focused_window, 1.0);
1890 m_flip_effect_image = _capture_snapshot(focused_window, BROWSER_MULTI_WINDOW_ITEM_RATIO);
1893 if (!m_zoom_effect_image || !m_flip_effect_image) {
1894 BROWSER_LOGD("_capture_snapshot failed");
1898 Evas_Object *snapshot_image = NULL;
1899 if (browser_view->get_url(focused_window).empty()) {
1900 snapshot_image = evas_object_rectangle_add(evas_object_evas_get(m_navi_bar));
1901 if (!snapshot_image) {
1902 BROWSER_LOGE("evas_object_rectangle_add failed");
1905 int focused_ewk_view_w = 0;
1906 int focused_ewk_view_h = 0;
1907 evas_object_geometry_get(browser_view->m_focused_window->m_ewk_view, NULL, NULL,
1908 &focused_ewk_view_w, &focused_ewk_view_h);
1910 evas_object_size_hint_min_set(snapshot_image, (int)(focused_ewk_view_w * BROWSER_MULTI_WINDOW_ITEM_RATIO),
1911 (int)(focused_ewk_view_h * BROWSER_MULTI_WINDOW_ITEM_RATIO));
1912 evas_object_resize(snapshot_image, (int)(focused_ewk_view_w * BROWSER_MULTI_WINDOW_ITEM_RATIO),
1913 (int)(focused_ewk_view_h * BROWSER_MULTI_WINDOW_ITEM_RATIO));
1914 evas_object_color_set(snapshot_image, 255, 255, 255, 255);
1916 snapshot_image = _capture_snapshot(focused_window, BROWSER_MULTI_WINDOW_ITEM_RATIO);
1919 if (!snapshot_image) {
1920 BROWSER_LOGE("_capture_snapshot failed");
1924 m_main_layout = elm_layout_add(browser_view->m_navi_bar);
1925 if (!m_main_layout) {
1926 BROWSER_LOGE("elm_layout_add failed");
1929 if (!elm_layout_file_set(m_main_layout, BROWSER_EDJE_DIR"/browser-multi-window.edj",
1930 "browser/browser-multi-window")) {
1931 BROWSER_LOGE("elm_layout_file_set failed");
1934 evas_object_show(m_main_layout);
1936 m_scroller = elm_scroller_add(m_navi_bar);
1938 BROWSER_LOGD("elm_scroller_add failed");
1941 evas_object_size_hint_weight_set(m_scroller, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1942 evas_object_size_hint_align_set(m_scroller, EVAS_HINT_FILL, EVAS_HINT_FILL);
1943 elm_scroller_bounce_set(m_scroller, EINA_TRUE, EINA_FALSE);
1945 elm_object_part_content_set(m_main_layout, "elm.swallow.scroller", m_scroller);
1946 elm_scroller_policy_set(m_scroller, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
1947 evas_object_show(m_scroller);
1949 /* After change normal mode -> gengrid mode, delete the gengrid after view change effect in __delete_gengrid_cb. */
1950 edje_object_signal_callback_add(elm_layout_edje_get(m_main_layout), "delete,gengrid,signal",
1951 "*", __delete_gengrid_cb, this);
1953 evas_object_smart_callback_add(m_scroller, "scroll,anim,stop", __scroller_animation_stop_cb, this);
1954 evas_object_smart_callback_add(m_scroller, "edge,left", __scroller_animation_stop_cb, this);
1955 evas_object_smart_callback_add(m_scroller, "edge,right", __scroller_animation_stop_cb, this);
1957 m_item_box = elm_box_add(m_navi_bar);
1959 BROWSER_LOGD("elm_box_add failed");
1962 evas_object_size_hint_weight_set(m_item_box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1963 evas_object_size_hint_align_set(m_item_box, EVAS_HINT_FILL, EVAS_HINT_FILL);
1964 elm_box_horizontal_set(m_item_box, EINA_TRUE);
1965 elm_object_content_set(m_scroller, m_item_box);
1966 evas_object_show(m_item_box);
1968 m_controlbar = _create_control_bar();
1969 if (!m_controlbar) {
1970 BROWSER_LOGE("_create_control_bar failed");
1973 elm_object_part_content_unset(browser_view->m_main_layout, "elm.swallow.control_bar");
1974 evas_object_hide(browser_view->m_control_bar);
1976 elm_object_part_content_set(browser_view->m_main_layout, "elm.swallow.control_bar", m_controlbar);
1979 std::vector<Browser_Window *> window_list = m_browser->get_window_list();
1980 for (index = 0 ; index < window_list.size() ; index++) {
1981 if (window_list[index] == m_data_manager->get_browser_view()->m_focused_window)
1984 m_current_position_index = index;
1986 m_page_control = elm_index_add(m_navi_bar);
1987 if (!m_page_control) {
1988 BROWSER_LOGD("elm_page_control_add failed");
1991 elm_object_style_set(m_page_control, "pagecontrol");
1992 elm_index_horizontal_set(m_page_control, EINA_TRUE);
1993 elm_index_autohide_disabled_set(m_page_control, EINA_TRUE);
1995 memset(m_index_items, 0x00, sizeof(Elm_Object_Item *) * BROWSER_MULTI_WINDOW_MAX_COUNT);
1997 Elm_Object_Item *index_it = NULL;
1998 for (int i = 0 ; i < window_list.size() ; i++) {
1999 char number[5] = {0, };
2000 sprintf(number, "%d", i + 1);
2002 if (m_current_position_index == i)
2003 m_index_items[i] = index_it = elm_index_item_append(m_page_control, number, __index_selected_cb, this);
2005 m_index_items[i] = elm_index_item_append(m_page_control, number, __index_selected_cb, this);
2008 elm_index_level_go(m_page_control, m_current_position_index);
2009 elm_index_item_selected_set(index_it, EINA_TRUE);
2011 elm_object_part_content_set(m_main_layout, "elm.swallow.page_control", m_page_control);
2012 evas_object_show(m_page_control);
2014 if (BROWSER_MULTI_WINDOW_MAX_COUNT <= window_list.size())
2015 elm_object_item_disabled_set(m_new_window_button, EINA_TRUE);
2017 _set_multi_window_mode(EINA_TRUE);
2019 #if defined(HORIZONTAL_UI)
2020 if (is_landscape()) {
2021 /* Landscape mode */
2022 if (browser_view->m_focused_window->m_landscape_snapshot_image)
2023 evas_object_del(browser_view->m_focused_window->m_landscape_snapshot_image);
2024 browser_view->m_focused_window->m_landscape_snapshot_image = snapshot_image;
2026 for (int i = 0 ; i < window_list.size() ; i++) {
2027 /* Focused window is already captured above. So skip it. */
2028 if ((window_list[i] != browser_view->m_focused_window)
2029 && !(window_list[i]->m_landscape_snapshot_image)) {
2030 Evas_Object *snapshot_image = NULL;
2031 if (!window_list[i]->m_ewk_view || browser_view->get_url(window_list[i]).empty()) {
2032 snapshot_image = evas_object_rectangle_add(evas_object_evas_get(m_navi_bar));
2033 if (!snapshot_image) {
2034 BROWSER_LOGE("evas_object_rectangle_add failed");
2037 int focused_ewk_view_w = 0;
2038 int focused_ewk_view_h = 0;
2039 evas_object_geometry_get(browser_view->m_focused_window->m_ewk_view, NULL, NULL,
2040 &focused_ewk_view_w, &focused_ewk_view_h);
2042 evas_object_size_hint_min_set(snapshot_image, (int)(focused_ewk_view_w * BROWSER_MULTI_WINDOW_ITEM_RATIO),
2043 (int)(focused_ewk_view_h * BROWSER_MULTI_WINDOW_ITEM_RATIO));
2044 evas_object_resize(snapshot_image, (int)(focused_ewk_view_w * BROWSER_MULTI_WINDOW_ITEM_RATIO),
2045 (int)(focused_ewk_view_h * BROWSER_MULTI_WINDOW_ITEM_RATIO));
2046 evas_object_color_set(snapshot_image, 255, 255, 255, 255);
2048 snapshot_image = _capture_snapshot(window_list[i],
2049 BROWSER_MULTI_WINDOW_ITEM_RATIO);
2050 if (!snapshot_image) {
2051 BROWSER_LOGD("_capture_snapshot failed");
2055 window_list[i]->m_landscape_snapshot_image = snapshot_image;
2063 if (browser_view->m_focused_window->m_portrait_snapshot_image)
2064 evas_object_del(browser_view->m_focused_window->m_portrait_snapshot_image);
2065 browser_view->m_focused_window->m_portrait_snapshot_image = snapshot_image;
2067 for (int i = 0 ; i < window_list.size() ; i++) {
2068 /* Focused window is already captured above. So skip it. */
2069 if ((window_list[i] != browser_view->m_focused_window)
2070 && !(window_list[i]->m_portrait_snapshot_image)) {
2071 Evas_Object *snapshot_image = NULL;
2072 if (window_list[i]->m_ewk_view == NULL || browser_view->get_url(window_list[i]).empty()) {
2073 snapshot_image = evas_object_rectangle_add(evas_object_evas_get(m_navi_bar));
2074 if (!snapshot_image) {
2075 BROWSER_LOGE("evas_object_rectangle_add failed");
2078 int focused_ewk_view_w = 0;
2079 int focused_ewk_view_h = 0;
2080 evas_object_geometry_get(browser_view->m_focused_window->m_ewk_view, NULL, NULL,
2081 &focused_ewk_view_w, &focused_ewk_view_h);
2083 evas_object_size_hint_min_set(snapshot_image, (int)(focused_ewk_view_w * BROWSER_MULTI_WINDOW_ITEM_RATIO),
2084 (int)(focused_ewk_view_h * BROWSER_MULTI_WINDOW_ITEM_RATIO));
2085 evas_object_resize(snapshot_image, (int)(focused_ewk_view_w * BROWSER_MULTI_WINDOW_ITEM_RATIO),
2086 (int)(focused_ewk_view_h * BROWSER_MULTI_WINDOW_ITEM_RATIO));
2087 evas_object_color_set(snapshot_image, 255, 255, 255, 255);
2089 snapshot_image = _capture_snapshot(window_list[i],
2090 BROWSER_MULTI_WINDOW_ITEM_RATIO);
2091 if (!snapshot_image) {
2092 BROWSER_LOGD("_capture_snapshot failed");
2096 window_list[i]->m_portrait_snapshot_image = snapshot_image;
2101 if (!_fill_multi_window_items()) {
2102 BROWSER_LOGD("_fill_multi_window_items failed");
2106 edje_object_signal_emit(elm_layout_edje_get(browser_view->m_main_layout),
2107 "show,multi_window,signal", "");
2109 /* Give zoom out effect in idler because the effect is not smooth. */
2110 m_zoom_out_effect_idler = ecore_idler_add(__zoom_out_effect_idler_cb, this);