Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add web support for zoom_factor #4260

Merged
merged 2 commits into from Mar 29, 2024

Conversation

justusdieckmann
Copy link
Contributor

Before, when setting the zoom_factor, the website was already enlarged, but the zoom was ignored when calculating the logical window size and mouse position, causing an offset between the actual cursor and selected elements. That is addressed here

@justusdieckmann
Copy link
Contributor Author

Thank you very much for the library! I did my first bigger project in rust and am really happy with it, especially the ease with which one can create both a native and web application. My prof had some difficulty reading the text, and I can see how one might have problems, especially with the moderate text contrast in dark mode. So I created this PR because I would like to enlarge the website a bit by default

@emilk
Copy link
Owner

emilk commented Mar 29, 2024

The intent of the current behavior is that the web browser is in charge of the zoom-factor/pixels-per-point.

If you launch a native egui app and press cmd-plus, you will zoom in, because egui catches that command and adjust the zoom factor.
If you go to egui.rs you'll notice cmd-plus also works to zoom in, but this time it's the browser that is in control. This means egui just follows the general zoom of the web page. In other words, if you embed an egui/eframe app into a web page and tells the browser to zoom in, egui will act just like any other web element.

Do you want to be able to zoom an egui app independently of the browsers setting?

@justusdieckmann
Copy link
Contributor Author

Exactly, I don't want to override the browsers zoom level, but I would like to be able to adjust the zoom level of the application programmatically

@emilk emilk added web Related to running Egui on the web eframe Relates to epi and eframe labels Mar 29, 2024
@emilk
Copy link
Owner

emilk commented Mar 29, 2024

Makes sense - thanks for the PR!

@emilk emilk merged commit 7cc98bd into emilk:master Mar 29, 2024
20 of 21 checks passed
emilk added a commit that referenced this pull request Mar 29, 2024
Before, when setting the `zoom_factor`, the website was already
enlarged, but the zoom was ignored when calculating the logical window
size and mouse position, causing an offset between the actual cursor and
selected elements. That is addressed here

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
@emilk emilk mentioned this pull request Mar 29, 2024
emilk added a commit that referenced this pull request Mar 29, 2024
## egui changelog
### 🐛 Fixed
* Fix visual glitch on the right side of highly rounded rectangles
[#4244](#4244)
* Prevent visual glitch when shadow blur width is very high
[#4245](#4245)
* Fix `InputState::any_touches` and add `InputState::has_touch_screen`
[#4247](#4247)
* Fix `Context::repaint_causes` returning no causes
[#4248](#4248)
* Fix touch-and-hold to open context menu
[#4249](#4249)
* Hide shortcut text on zoom buttons if `zoom_with_keyboard` is false
[#4262](#4262)

### 🔧 Changed
* Don't apply a clip rect to the contents of an `Area` or `Window`
[#4258](#4258)


## eframe changelog
* Web: repaint if the `#hash` in the URL changes
[#4261](#4261)
* Add web support for `zoom_factor`
[#4260](#4260) (thanks
[@justusdieckmann](https://github.com/justusdieckmann)!)

---------

Co-authored-by: Justus Dieckmann <45795270+justusdieckmann@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
eframe Relates to epi and eframe web Related to running Egui on the web
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants