Title: [136369] trunk/Tools
Revision
136369
Author
[email protected]
Date
2012-12-02 23:58:40 -0800 (Sun, 02 Dec 2012)

Log Message

[EFL][WK2] Add support for a zoom level setting to MiniBrowser
https://bugs.webkit.org/show_bug.cgi?id=99285

Patch by KyungTae Kim <[email protected]> on 2012-12-02
Reviewed by Gyuyoung Kim.

 Add support for a zoom level setting to MiniBrowser.
 Shortcuts for setting operations are same as common browsers:
 Ctrl + '+' to zoom in, Ctrl + '-' to zoom out and Ctrl + '0' to zoom to default.

* MiniBrowser/efl/main.c:
(on_key_down):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (136368 => 136369)


--- trunk/Tools/ChangeLog	2012-12-03 07:47:33 UTC (rev 136368)
+++ trunk/Tools/ChangeLog	2012-12-03 07:58:40 UTC (rev 136369)
@@ -1,5 +1,19 @@
 2012-12-02  KyungTae Kim  <[email protected]>
 
+        [EFL][WK2] Add support for a zoom level setting to MiniBrowser
+        https://bugs.webkit.org/show_bug.cgi?id=99285
+
+        Reviewed by Gyuyoung Kim.
+
+         Add support for a zoom level setting to MiniBrowser.
+         Shortcuts for setting operations are same as common browsers:
+         Ctrl + '+' to zoom in, Ctrl + '-' to zoom out and Ctrl + '0' to zoom to default.
+
+        * MiniBrowser/efl/main.c:
+        (on_key_down):
+
+2012-12-02  KyungTae Kim  <[email protected]>
+
         [EFL][WK2] ECORE_GETOPT_VALUE_BOOL need to be used for Eina_Bool
         https://bugs.webkit.org/show_bug.cgi?id=103835
 

Modified: trunk/Tools/MiniBrowser/efl/main.c (136368 => 136369)


--- trunk/Tools/MiniBrowser/efl/main.c	2012-12-03 07:47:33 UTC (rev 136368)
+++ trunk/Tools/MiniBrowser/efl/main.c	2012-12-03 07:58:40 UTC (rev 136369)
@@ -49,6 +49,27 @@
 static double device_pixel_ratio = 0;
 static Eina_Bool legacy_behavior_enabled = EINA_FALSE;
 
+#define DEFAULT_ZOOM_LEVEL 5 // Set default zoom level to 100% (index 5 on zoomLevels).
+// The zoom values are chosen to be like in Mozilla Firefox 3.
+const static int zoomLevels[] = {30, 50, 67, 80, 90, 100, 110, 120, 133, 150, 170, 200, 240, 300};
+
+static Eina_Bool
+zoom_level_set(Evas_Object *webview, int level)
+{
+    if (level < 0  || level >= sizeof(zoomLevels) / sizeof(int))
+        return EINA_FALSE;
+
+    float factor = ((float) zoomLevels[level]) / 100.0;
+    Evas_Coord ox, oy, mx, my, cx, cy;
+    evas_pointer_canvas_xy_get(evas_object_evas_get(webview), &mx, &my); // Get current mouse position on window.
+    evas_object_geometry_get(webview, &ox, &oy, NULL, NULL); // Get webview's position on window.
+    cx = mx - ox; // current x position = mouse x position - webview x position
+    cy = my - oy; // current y position = mouse y position - webview y position
+
+    Eina_Bool result = ewk_view_scale_set(webview, factor, cx, cy);
+    return result;
+}
+
 static Ewk_View_Smart_Class *miniBrowserViewSmartClass()
 {
     static Ewk_View_Smart_Class ewkViewClass = EWK_VIEW_SMART_CLASS_INIT_NAME_VERSION("MiniBrowser_View");
@@ -61,6 +82,7 @@
     Evas_Object *url_bar;
     Evas_Object *back_button;
     Evas_Object *forward_button;
+    int current_zoom_level; 
 } Browser_Window;
 
 typedef struct _File_Selector_Data {
@@ -212,6 +234,18 @@
     } else if (!strcmp(ev->key, "Escape")) {
         if (elm_win_fullscreen_get(window->elm_window))
             ewk_view_fullscreen_exit(ewk_view);
+    } else if (ctrlPressed && (!strcmp(ev->key, "minus") || !strcmp(ev->key, "KP_Subtract"))) {
+        if (zoom_level_set(ewk_view, window->current_zoom_level - 1))
+            window->current_zoom_level--;
+        info("Zoom out (Ctrl + '-') was pressed, zoom level became %d%\n", zoomLevels[window->current_zoom_level]);
+    } else if (ctrlPressed && (!strcmp(ev->key, "equal") || !strcmp(ev->key, "KP_Add"))) {
+        if (zoom_level_set(ewk_view, window->current_zoom_level + 1))
+            window->current_zoom_level++;
+        info("Zoom in (Ctrl + '+') was pressed, zoom level became %d%\n", zoomLevels[window->current_zoom_level]);
+    } else if (ctrlPressed && !strcmp(ev->key, "0")) {
+        if (zoom_level_set(ewk_view, DEFAULT_ZOOM_LEVEL))
+            window->current_zoom_level = DEFAULT_ZOOM_LEVEL;
+        info("Zoom to default (Ctrl + '0') was pressed, zoom level became %d%\n", zoomLevels[window->current_zoom_level]);
     }
 }
 
@@ -1070,6 +1104,9 @@
     if (device_pixel_ratio)
         ewk_view_device_pixel_ratio_set(window->ewk_view, (float)device_pixel_ratio);
 
+    /* Set the zoom level to default */
+    window->current_zoom_level = DEFAULT_ZOOM_LEVEL;
+
     Ewk_Settings *settings = ewk_view_settings_get(window->ewk_view);
     ewk_settings_file_access_from_file_urls_allowed_set(settings, EINA_TRUE);
     ewk_settings_encoding_detector_enabled_set(settings, encoding_detector_enabled);
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to