obsproject / obs-browser

CEF-based OBS Studio browser plugin
GNU General Public License v2.0
769 stars 217 forks source link

Add ability to zoom browser docks with Ctrl - and + #399

Closed WizardCM closed 1 year ago

WizardCM commented 1 year ago

Description

Adds the ability for a user to control the zoom level of a browser dock using keyboard shortcuts.

Ctrl + 0 resets zoom, like a normal browser.

Attempts to use the same % values as browsers.

Also adds a Reset option to the context menu when zoom is not 100%.

Verify the zoom level using the following in the Inspect window:

Math.round(window.devicePixelRatio * 100);

Note that zoom level does not persist across restarts. However, even in this initial implementation it's more useful than not having it. Zoom level now persists thanks to https://github.com/obsproject/obs-browser/commit/4236b56fbe4706de17617b2fe69370b031294b29

https://user-images.githubusercontent.com/941350/226282748-f2b495bf-5d8e-4a1f-9d89-bec84a745b92.mp4

https://user-images.githubusercontent.com/941350/226282777-c6a7daef-d0d9-452a-bf1d-d9d9a093c0a6.mp4

Motivation and Context

How Has This Been Tested?

On Windows.

  1. Press the mentioned hotkeys while a browser dock is focused.
  2. Right click a browser dock with a non-100% zoom and select Reset Zoom.

Types of changes

Checklist:

WizardCM commented 1 year ago

Couple of updates since the original PR:

  1. Simplified a little bit of code
  2. Changed from Ctrl+* to Ctrl+0 to reset zoom (per other browsers)
  3. Added Zoom In/Out menu items to the context menu
  4. Thanks to a different commit pushed to master, zoom level now persists across sessions