jnschulze / flutter-webview-windows

A WebView2-powered Flutter WebView implementation for the Windows platform.
BSD 3-Clause "New" or "Revised" License
203 stars 120 forks source link

Add zoom factor method #196

Closed filipenanclarez closed 1 year ago

filipenanclarez commented 1 year ago

Can you implement a way to change the zoom factor?

Reading the docs seams SetBoundsAndZoomFactor method make this possible.

This help dev who need change the zoom of content without javascript. Actually make this with javascript in many old devices is so hard.

Eerey commented 1 year ago

webview.cc line 74, 75, 76

  webview_controller_->put_BoundsMode(COREWEBVIEW2_BOUNDS_MODE_USE_RAW_PIXELS);
  webview_controller_->put_ShouldDetectMonitorScaleChanges(FALSE);
  webview_controller_->put_RasterizationScale(1.0);

This might be the place where you can set those values. But I'm all new to cc programming and do not know how to implement it dynamically. I can't help you there (because I'm working on other projects), but this is a hint for anyone who knows to programm in cc <-> dart with ffi.

Eerey commented 1 year ago

Also, I found something in the Microsoft.Web.Webview2 directory. Maybe this could be used to resize it dynamically? WebView2.idl line 2904

  /// Add an event handler for the RasterizationScaleChanged event.
  /// The event is raised when the WebView detects that the monitor DPI scale
  /// has changed, ShouldDetectMonitorScaleChanges is true, and the WebView has
  /// changed the RasterizationScale property.
  ///
  /// \snippet ViewComponent.cpp RasterizationScaleChanged
  HRESULT add_RasterizationScaleChanged(
    [in] ICoreWebView2RasterizationScaleChangedEventHandler* eventHandler,
    [out] EventRegistrationToken* token);
  /// Remove an event handler previously added with
  /// add_RasterizationScaleChanged.
  HRESULT remove_RasterizationScaleChanged(
    [in] EventRegistrationToken token);
    ...