<!--
Please read the "Making a PR" section of
[`CONTRIBUTING.md`](https://github.com/emilk/egui/blob/master/CONTRIBUTING.md)
before opening a Pull Request!
* Keep your PR:s small and focused.
* The PR title is what ends up in the changelog, so make it descriptive!
* If applicable, add a screenshot or gif.
* If it is a non-trivial addition, consider adding a demo for it to
`egui_demo_lib`, or a new example.
* Do NOT open PR:s from your `master` branch, as that makes it hard for
maintainers to test and add commits to your PR.
* Remember to run `cargo fmt` and `cargo clippy`.
* Open the PR as a draft until you have self-reviewed it and run
`./scripts/check.sh`.
* When you have addressed a PR comment, mark it as resolved.
Please be patient! I will review your PR, but my time is limited!
-->
* Closes https://github.com/emilk/egui/issues/3549
* [X] I have followed the instructions in the PR template
The syntax highlighting font size was always hardcoded to 12 or 10
depending on what case it was hitting (so not consistent). This is
particularly noticeable when you increase the font size to something
larger for the rest of the ui.
With this the default monospace font size is used by default.
Since the issue is closely related to #3549 I decided to implement the
ability to use override_font_id too.
## Visualized
Default monospace is set to 15 in all the pictures
Before/After without syntect:

Before/after _with_ syntect:

Font override after without/with syntect (monospace = 20):

### Breaking changes
- `CodeTheme::dark` and `CodeTheme::light` takes in the font size
- `CodeTheme::from_memory` takes in `Style`
- `highlight` function takes in `Style`
* Closes https://github.com/emilk/egui/issues/3804
Add ability to select the text in labels with mouse-drag, double-click,
and keyboard (once clicked).
Hit Cmd+C to copy the text. If everything of a label with elided text is
selected, the copy command will copy the full non-elided text. IME and
accesskit _should_ work, but is untested.
You can control wether or not text in labels is selected globally in
`style.interaction.selectable_labels` or on a per-label basis in
`Label::selectable`. The default is ON.
This also cleans up the `TextEdit` code somewhat, fixing a couple
smaller bugs along the way.
This does _not_ implement selecting text across multiple widgets. Text
selection is only supported within a single `Label`, `TextEdit`, `Link`
or `Hyperlink`.

## TODO
* [x] Test
This introduces a special `Color32::PLACEHOLDER` which, during text
painting, will be replaced with `TextShape::fallback_color`.
The fallback color is mandatory to set in all text painting. Usually
this comes from the current visual style.
This lets users color only parts of a `WidgetText` (using e.g. a
`LayoutJob` or a `Galley`), where the uncolored parts (using
`Color32::PLACEHOLDER`) will be replaced by a default widget color (e.g.
blue for a hyperlink).
For instance, you can color the `⚠️`-emoji red in a piece of text red
and leave the rest of the text uncolored. The color of the rest of the
text will then depend on wether or not you put that text in a label, a
button, or a hyperlink.
Overall this simplifies a lot of complexity in the code but comes with a
few breaking changes:
* `TextShape::new`, `Shape::galley`, and `Painter::galley` now take a
fallback color by argument
* `Shape::galley_with_color` has been deprecated (use `Shape::galley`
instead)
* `Painter::galley_with_color` has been deprecated (use
`Painter::galley` instead)
* `WidgetTextGalley` is gone (use `Arc<Galley>` instead)
* `WidgetTextJob` is gone (use `LayoutJob` instead)
* `RichText::into_text_job` has been replaced with
`RichText::into_layout_job`
* `WidgetText::into_text_job` has been replaced with
`WidgetText::into_layout_job`
Thanks to `impl From<bool> for Vec2b` one can now shorten some builder
calls, like:
Previous:
```rust
egui::ScrollArea::vertical()
.auto_shrink([false; 2])
```
New:
```rust
egui::ScrollArea::vertical()
.auto_shrink(false)
```
* Add syntax highlighing feature to egui_extras
Enable "syntect" feature for great syntax highlighting of any language.
If not a simple fallback is used that works fine for C++, Rust, Python
* Check --no-default-features of egui_extras on CI
* spelling
* Fix building egui_extras without additional features
* add egui logo to widget gallery
* improve "no image loaders" error message
* rework static URIs to accept `Cow<'static>`
* remove `RetainedImage` from `http_app` in `egui_demo_app`
* hide `RetainedImage` from docs
* use `ui.image`/`Image` over `RawImage`
* remove last remanant of `RawImage`
* remove unused doc link
* add style option to disable image spinners
* use `Into<Image>` instead of `Into<ImageSource>` to allow configuring the underlying image
* propagate `image_options` through `ImageButton`
* calculate image size properly in `Button`
* properly calculate size in `ImageButton`
* Update crates/egui/src/widgets/image.rs
Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
* improve no image loaders error message
* add `size()` helper to `TexturePoll`
* try get size from poll in `Button`
* add `paint_at` to `Spinner`
* use `Spinner::paint_at` and hover on image button response
* `show_spinner` -> `show_loading_spinner`
* avoid `allocate_ui` in `Image` when painting spinner
* make icon smaller + remove old texture
* add `load_and_calculate_size` + expose `paint_image_at`
* update `egui_plot` to paint image in the right place
* Add helpers for painting an ImageSource directly
* Use max_size=INF as default
* Use new API in WidgetGallery
* Make egui_demo_app work by default
* Remove Option from scale
* Refactor ImageSize
* Fix docstring
* Small refactor
---------
Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
* rework loading around `Arc<Loaders>`
* use `Bytes` instead of splitting api
* remove unwraps in `texture_handle`
* make `FileLoader` optional under `file` feature
* hide http load error stack trace from UI
* implement image fit
* support more image sources
* center spinner if we know size ahead of time
* allocate final size for spinner
* improve image format guessing
* remove `ui.image`, `Image`, add `RawImage`
* deprecate `RetainedImage`
* `image2` -> `image`
* add viewer example
* update `examples/image` + remove `svg` and `download_image` exapmles
* fix lints and tests
* fix doc link
* add image controls to `images` example
* add more `From` str-like types
* add api to forget all images
* fix max size
* do not scale original size unless necessary
* fix doc link
* add more docs for `Image` and `RawImage`
* make paint_at `pub`
* update `ImageButton` to use new `Image` API
* fix double rendering
* `SizeHint::Original` -> `Scale` + remove `Option` wrapper
* Update crates/egui/src/load.rs
Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
* remove special `None` value for `forget`
* Update crates/egui/src/load.rs
Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
* add more examples to `ui.image` + add `include_image` macro
* Update crates/egui/src/ui.rs
Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
* update `menu_image_button` to use `ImageSource`
* `OrderedFloat::get` -> `into_inner`
* derive `Eq` on `SizedTexture`
* add `id` to loaders + `is_installed` check
* move `images` to demo + simplify `images` example
* log trace when installing loaders
* fix lint
* fix doc link
* add more documentation
* more `egui_extras::loaders` docs
* Update examples/images/src/main.rs
Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
* update `images` example screenshots + readme
* remove unused `rfd` from `images` example
* Update crates/egui_extras/src/loaders/ehttp_loader.rs
Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
* add `must_use` on `Image` and `RawImage`
* document `loaders::install` multiple call safety
* Update crates/egui_extras/Cargo.toml
Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
* reshuffle `is_loader_installed`
* make `include_image` produce `ImageSource` + update docs
* update `include_image` docs
* remove `None` mentions from loader `forget`
* inline `From` texture id + size for `SizedTexture`
* add warning about statically known path
* change image load error + use in image button
* add `.size()` to `Image`
* Update crates/egui_demo_app/Cargo.toml
Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
* add explanations to image viewer ui
---------
Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>