Example #1
0
/**
 * @brief __br_rotate_cb 处理屏幕旋转问题
 * @param mode 旋转方向
 * @param data 传递参数
 */
static void __br_rotate_cb(app_device_orientation_e mode, void *data)
{
    BROWSER_LOGD("**********************[%s] rotation mode = %d", __func__, mode);
	struct browser_data *ad = (struct browser_data *)data;
	int rotation_value;

	switch (mode) {
	case APP_DEVICE_ORIENTATION_0:
		rotation_value = 0;
		ug_send_event(UG_EVENT_ROTATE_PORTRAIT);
		break;
	case APP_DEVICE_ORIENTATION_90:
		rotation_value = 90;
		ug_send_event(UG_EVENT_ROTATE_LANDSCAPE_UPSIDEDOWN);
		break;
	case APP_DEVICE_ORIENTATION_180:
		rotation_value = 180;
		ug_send_event(UG_EVENT_ROTATE_PORTRAIT_UPSIDEDOWN);
		break;
	case APP_DEVICE_ORIENTATION_270:
		rotation_value = 270;
		ug_send_event(UG_EVENT_ROTATE_LANDSCAPE);
		break;
	default:
		rotation_value = -1;
		break;
	}

	if (rotation_value >= 0 && ad->browser_instance) {
		if (ad->browser_instance->is_available_to_rotate()) {
			elm_win_rotation_with_resize_set(ad->main_win, rotation_value);
			ad->browser_instance->rotate(rotation_value);
		}
	}
}
static int _rotation_cb(enum appcore_rm mode, void *data)
{
    struct appdata *ad = (struct appdata *)data;
    int angle;

    switch (mode) {
        case APPCORE_RM_LANDSCAPE_NORMAL:
            angle = -90;
            break;

        case APPCORE_RM_LANDSCAPE_REVERSE:
            angle = 90;
            break;

        case APPCORE_RM_PORTRAIT_REVERSE:
            angle = 180;
            break;

        case APPCORE_RM_UNKNOWN:
        case APPCORE_RM_PORTRAIT_NORMAL:
        default:
            angle = 0;
            break;
    }

    elm_win_rotation_with_resize_set(ad->win_main, angle);
    // set_rotation_degree(angle);

    // This is need for customized rotation process.
    // rotate_for_winset(mode);

    return 0;
}
Example #3
0
/**
 * @brief __br_app_create 应用程序初始化
 * @param app_data 应用程序数据
 * @return 是否执行成功
 */
static bool __br_app_create(void *app_data)
{
    BROWSER_LOGD("********************[Browser-Launching time measure] << theme extenstion >>");
	struct browser_data *ad = (struct browser_data *)app_data;

	elm_config_preferred_engine_set("opengl_x11");


	/**
	 *加载配置文件
	 */
	if(!__init_preference())
		return false;
	/**
	*加载主题
	*/
	ad->browser_theme = elm_theme_new();
	elm_theme_ref_set(ad->browser_theme, NULL);
	elm_theme_extension_add(ad->browser_theme, BROWSER_NAVIFRAME_THEME);
	elm_theme_extension_add(ad->browser_theme, BROWSER_CONTROLBAR_THEME);
	elm_theme_extension_add(ad->browser_theme, BROWSER_BUTTON_THEME);
	elm_theme_extension_add(ad->browser_theme, BROWSER_PROGRESSBAR_THEME);
	elm_theme_extension_add(ad->browser_theme, BROWSER_URL_LAYOUT_THEME);
	elm_theme_extension_add(ad->browser_theme, BROWSER_PREDICTIVE_HISTORY_THEME);
	elm_theme_extension_add(ad->browser_theme, BROWSER_SETTINGS_THEME);
	elm_theme_extension_add(ad->browser_theme, BROWSER_BOOKMARK_THEME);
	elm_theme_extension_add(ad->browser_theme, BROWSER_FIND_WORD_LAYOUT_THEME);

	BROWSER_LOGD("[Browser-Launching time measure] << create main window >>");
	ad->main_win = __create_main_win(ad); //创建窗口
	if (!ad->main_win) {
		BROWSER_LOGE("fail to create window");
		return false;
	}

	BROWSER_LOGD("[Browser-Launching time measure] << create background >>");
    ad->bg = __create_bg(ad->main_win); //
	if (!ad->bg) {
		BROWSER_LOGE("fail to create bg");
		return false;
	}

	BROWSER_LOGD("[Browser-Launching time measure] << create layout main >>");
	ad->main_layout = __create_main_layout(ad->main_win);
	if (!ad->main_layout) {
		BROWSER_LOGE("fail to create main layout");
		return false;
	}

	ad->navi_bar = __create_navi_bar(ad);
	if (!ad->navi_bar) {
		BROWSER_LOGE("fail to create navi bar");
		return false;
	}

	/* create browser instance & init */
	ad->browser_instance = new(nothrow) Browser_Class(ad->main_win, ad->navi_bar, ad->bg);
	if (!ad->browser_instance) {
		BROWSER_LOGE("fail to Browser_Class");
		return false;
    }
    /**
      *初始化browser_view
      */
	if (ad->browser_instance->init() == EINA_FALSE) {
		BROWSER_LOGE("fail to browser init");
		return false;
	}

	/* init internationalization */
	int ret = __browser_set_i18n(BROWSER_PACKAGE_NAME, BROWSER_LOCALE_DIR);
	if (ret) {
		BROWSER_LOGE("fail to __browser_set_i18n");
		return false;
	}

#if defined(HORIZONTAL_UI)
	app_device_orientation_e rotation_value = app_get_device_orientation();

	if (rotation_value != APP_DEVICE_ORIENTATION_0) {
		elm_win_rotation_with_resize_set(ad->main_win, rotation_value);
		ad->browser_instance->rotate(rotation_value);
	}
#endif

	return true;
}