Commit graph

183 commits

Author SHA1 Message Date
Emil Ernerfeldt
190c85a40f Rename Texture to FontImage 2021-12-28 21:19:24 +01:00
Emil Ernerfeldt
d5efa4bbca 1.56 fix: missing_crate_level_docs -> rusdoc::missing_crate_level_docs 2021-12-26 09:56:14 +01:00
Emil Ernerfeldt
c60d17b91b
Set MSRV to 1.56.0 and use rust edition 2021 (#998) 2021-12-25 19:32:25 +01:00
Jan Haller
5ec14867c8
OrderedFloat refactor (#918)
* Move egui/util/float_ord.rs -> epaint/util/ordered_float.rs

* Implement Hash on OrderedFloat

* Generic OrderedFloat<T>; impl Hash; documentation
2021-12-11 13:52:23 +01:00
Emil Ernerfeldt
5fee6b7bc5
Anti-alias path ends (#893)
Closes https://github.com/emilk/egui/issues/876
2021-11-14 17:23:51 +01:00
Emil Ernerfeldt
951ee4e142
Improve color picker cache (#886)
* colorpicker: try to maintain hue even when saturation goes to zero
* More consistent arguments to color types
* implement `Hash` for `Rgba`.
2021-11-07 21:11:42 +01:00
Emil Ernerfeldt
878eddd546
When using a custom font you can now specify a font index (#873)
When using a custom font you can now specify a font index

Closes https://github.com/emilk/egui/issues/853
2021-11-07 19:47:52 +01:00
Emil Ernerfeldt
09b8269326
Rich text for all widgets (#855)
Introduce `RichText` and `WidgetText`
2021-11-01 21:30:10 +01:00
Emil Ernerfeldt
78dfde40b2 Remove deprecated functions 2021-10-30 09:46:06 +02:00
Emil Ernerfeldt
ddd52f47c5 Add tessellation option to toggle rounding text to pixel coordinates
On by default and only there for testing
2021-10-27 08:56:06 +02:00
Emil Ernerfeldt
8e4fd942a9
Refactor memory data (#836)
This refactors the widget state storage introduced by @optozorax in https://github.com/emilk/egui/pull/257

* Unify the four buckets (`data`, `data_temp`, `id_data` and `id_data_temp`) into a single `data`.
  * Less complexity, and also less chance of error (storing in one bucket, reading from another).
* Store data by `Id` and `TypeId`.
  * Users can thus reuse the same `Id` to store many types.
  * Uses a simple xor of id and typeid, which is fast and good since both id and typeid are already high-entropy hashes.
* Use different suffixes on the functions to pick if you want the data persisted or not (`get_temp`, `insert_persisted`, etc).
  * Writing with one suffix and reading with the other works.
* To store state not bound to a specific `Id` (i.e. only based on type), use the new `Id::null` as the key.
2021-10-27 08:51:34 +02:00
Emil Ernerfeldt
08cc07bb2d Release 0.15.0 - Syntax highlighting, hscroll, egui-winit and egui_glow 2021-10-24 16:15:07 +02:00
Emil Ernerfeldt
4ace85b780 Fix: '\t' always take up the width of four spaces 2021-10-23 14:38:26 +02:00
Emil Ernerfeldt
2a9037cd90 Clean up epaint mutex code 2021-10-20 22:24:34 +02:00
Emil Ernerfeldt
dd50cba9a7 Optimize debug builds 2021-10-20 21:58:35 +02:00
Emil Ernerfeldt
d97a369c44 End statements with semicolon (clippy::semicolon_if_nothing_returned) 2021-10-20 16:46:57 +02:00
Emil Ernerfeldt
a0cd41755e Add more clippy lints 2021-10-20 16:30:39 +02:00
Emil Ernerfeldt
087c6695bb Handle having no fonts (missing "default_fonts" feature) without a crash 2021-10-20 15:40:06 +02:00
Emil Ernerfeldt
1f5cd482f6
Replace ProggyClean.ttf with Hack-Regular.ttf as default monospace font (#802)
https://github.com/source-foundry/Hack, MIT license
2021-10-17 20:49:28 +02:00
Emil Ernerfeldt
6f699b3391 Replace every ... with … like some sort of crazy person
Also fix some small typos

Closes https://github.com/emilk/egui/pull/736
2021-10-13 11:52:34 +02:00
Emil Ernerfeldt
1ab61ce9bb Implement bytemuck for epaint::Rgba
Closes https://github.com/emilk/egui/pull/784
2021-10-13 08:56:34 +02:00
Emil Ernerfeldt
e547b149ca Improve docs, especially of epaint, and add epaint/CHANGELOG.md 2021-10-10 15:35:13 +02:00
Emil Ernerfeldt
22a3a75eb5 Optimization: replace HashSet uses with AHashSet 2021-10-09 14:15:45 +02:00
Stock84
cd2227814f
Implement bytemuck behind a feature (#775) 2021-10-07 22:30:15 +02:00
Emil Ernerfeldt
a1bf5aff47 Add Memory::caches for caching things from one frame to the next 2021-10-06 17:54:45 +02:00
Emil Ernerfeldt
f59abd9684 Clean up some macro syntax 2021-10-02 21:08:00 +02:00
Emil Ernerfeldt
5539dbe620
Add separate serialize feature and better persitence control (#753)
* Rename epaint feature "persistence" to "serialize"

* Add separate "serialize" feature to egui

* egui_demo_lib: separate serialize and persistence features

* Add App::persist_native_window and App::persist_egui_memory

Controls what gets persisted
2021-09-29 08:45:13 +02:00
Emil Ernerfeldt
d9db768180 Optimize tessellator: pass options by reference 2021-09-28 18:00:01 +02:00
Emil Ernerfeldt
2e83e36146 Use ahash for Id and other things that need hashing 2021-09-28 17:56:24 +02:00
Emil Ernerfeldt
1b36863248
Split out new crate egui-winit from egui_glium (#735) 2021-09-28 17:33:28 +02:00
Emil Ernerfeldt
ba0e3780a1 Add epaint::util::hash function for hashing a value 2021-09-26 03:16:12 +02:00
Emil Ernerfeldt
976260c2bd Better error if neither single_threaded or multi_threaded features is on 2021-09-25 05:26:45 +02:00
Emil Ernerfeldt
e7cfda4941
Shape refactor (#705)
* More introspection stats about vertices/indices etc

* more serde derive

* #[inline] to Shape constructors

* Introduce RectShape

* Introduce CircleShape

* Introduce PathShape

* More serde derive

* impl Copy for RectShape and CircleShape

* Simplify some code

* More serde derive

* Add helpers for appending more input or output

* Serde derives for RawInput

* Rename Fonts::from_definitions to Fonts::new

* Add Output::take

* refactor EguiGlium slightly

* Derive PartialEq for RawInput

* Improve egui::util::History interface

* tweaks

* Improve History filter: add minimum length

* Calculate galley bounding rect

* tessellator: cull line segments and paths

* tessellator: cull meshes

* Fix bug in History bandwidth estimator
2021-09-20 21:36:56 +02:00
Emil Ernerfeldt
f37180f7dc
Bump MSRV (Minimum Supported Rust Version) to 1.54.0 (#703)
1.51.0 clippy has been giving me trouble (not reporting all problems),
and so I take the easy way out and just bump MSRV.

We will upgrade to 1.56.0 once it comes around anyway
to get access to that sweet disjoint capture in closures
(https://doc.rust-lang.org/nightly/edition-guide/rust-2021/disjoint-capture-in-closures.html)
2021-09-09 00:16:06 +02:00
Emil Ernerfeldt
acb5501fe4 Add justified and/or center- and right-aligned text
Label text will now be centered, right-aligned and/or
justified based on the layout.

Galleys are no longer always pivoted in the left top corner,
so now have a Rect rather than just a size.
2021-09-07 20:37:50 +02:00
Emil Ernerfeldt
92503ea9e1 clippy fix 2021-09-05 10:11:52 +02:00
Emil Ernerfeldt
14c989fdfa Implement rotating text
Closes https://github.com/emilk/egui/issues/428
2021-09-05 09:06:53 +02:00
Emil Ernerfeldt
5f88d89f74
Faster galley cache (#699)
* Speed up galley cache by only using the hash as key

This hashes the job but doesn't compare them with Eq,
which speeds up demo_with_tessellate__realistic by 5-6%,
winning back all the performance lost in
https://github.com/emilk/egui/pull/682

* Remove custom Eq/PartialEq code for LayoutJob and friends

* Silence clippy

* Unrelated clippy fixes
2021-09-04 10:19:58 +02:00
Emil Ernerfeldt
3b75a84d3b Point crate repository & homepage urls to their subfolders 2021-09-03 21:12:44 +02:00
Emil Ernerfeldt
9598596bdc
Replace all http code in epi/eframe/egui_glium/egui_web with ehttp (#697)
I've extracted all the http request code and turned it
into its own crate at <https://github.com/emilk/ehttp>.

There was never a reason for the HTTP request library to be part of
`eframe`. Much better to have it as its own crate!
2021-09-03 21:04:43 +02:00
Emil Ernerfeldt
de1a1ba9b2
New text layout (#682)
This PR introduces a completely rewritten text layout engine which is simpler and more powerful. It allows mixing different text styles (heading, body, etc) and formats (color, underlining, strikethrough, …) in the same layout pass, and baked into the same `Galley`.

This opens up the door to having a syntax-highlighed code editor, or a WYSIWYG markdown editor.

One major change is the color is now baked in at layout time. However, many widgets changes text color on hovered. But we need to do the text layout before we know if it is hovered. Therefor the painter has an option to override the text color of a galley.


## Performance
Text layout alone is about 20% slower, but a lot of that is because more tessellation is done upfront. Text tessellation is now a lot faster, but text layout + tessellation still lands at a net loss of 5-10% in performance. There are however a few tricks to speed it up (like using `smallvec`) which I am saving for later. Text layout is also cached, meaning that in most cases (when all text isn't changing each frame) text tessellation is actually more important (and that's more than 2x faster!).

Sadly, the actual text cache lookup is significantly slower (300ns -> 600ns). That's because the `TextLayoutJob` is a lot bigger (it has more options, like underlining, fonts etc), so it is slower to hash and compare. I have an idea how to speed this up, but I need to do some other work before I can implement that.

All in all, the performance impact on `demo_with_tesselate__realistic` is about 5-6% in the red. Not great; not terrible. The benefits are worth it, but I also think with some work I can get that down significantly, hopefully down to the old levels.
2021-09-03 18:18:00 +02:00
Emil Ernerfeldt
1fbce6b2c3 Remove everything marked deprecated 2021-08-28 11:46:30 +02:00
Emil Ernerfeldt
a9467fc5df epaint stats: correctly count the impact of Shape::Text 2021-08-26 20:44:42 +02:00
Emil Ernerfeldt
c2d1034af3 Make Options::tessellation_options public
Closes https://github.com/emilk/egui/issues/644
2021-08-25 21:39:00 +02:00
Emil Ernerfeldt
cb566fc295 Release 0.14.0 - Ui panels and bug fixes 2021-08-24 16:47:10 +02:00
Emil Ernerfeldt
91bdf9ba6e
egui_web: make text thicker and less pixelated (#640)
Closes https://github.com/emilk/egui/issues/516
2021-08-21 21:18:00 +02:00
sigaloid
12fd4906de
Update dependencies and pass all clippy's (#636)
* Cargo update

https://pastebin.com/raw/KWNuJD9u

* Cargo clippy +nightly

* Remove deprecated clippy

* Fix unbalanced backtick (now passes cargo {+nightly,} clippy)
2021-08-20 22:31:20 +02:00
zu1k
1fc2510b3b
Fix blocking when using custom large font files (#594)
* Fix blocking when using custom large font files

* Add docstring explaining laziness

* Put characters behind a epaint::RwLock

* cargo fmt font.rs

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2021-08-16 22:17:31 +02:00
Sven Niederberger
7c5a2d60c5
Plot: Line styles (#482)
* added new line styles

* update changelog

* fix #524

Add missing functions to `HLine` and `VLine`

* add functions for creating points and dashes from a line

* apply suggestions

* clippy fix

* address comments
2021-07-06 20:15:04 +02:00
Emil Ernerfeldt
d807451348 Release 0.13.0 - Better panels, plots and new visual style 2021-06-24 20:00:06 +02:00
Emil Ernerfeldt
1363ac4a24 demo: in font book, ask font what characters are supported
This replaces manual lists with a call to ab_glypgh::Font::codepoint_ids
plus names from the unicode_names2 crate.
2021-06-24 17:35:56 +02:00
Benjamin Bouvier
e22c242d17
Use ab_glyph instead of rusttype for font rendering (#490)
* Use ab_glyph instead of rusttype for font rendering

* address review feedback
2021-06-24 12:13:57 +02:00
Emil Ernerfeldt
6e7e88ba80
Use old 1.51 toolchain instead of bleeding edge (#505)
* Use old 1.51 toolchain instead of bleeding edge

1.52 and 1.53 has problems with incremental compilation,
so some people chose to stay on 1.51 for now.

So let's make sure egui supports 1.51 for a while!

* Update to cint 0.2.2 to get rust 1.51.0 compatability
2021-06-23 09:16:39 +02:00
Emil Ernerfeldt
269a4538d9 clippy fixes for rust 1.53 2021-06-22 23:38:34 +02:00
Emil Ernerfeldt
778bcc1ef7
Style tweaks (#450)
* Tweak style

More compact, less round, less noisy

* Button text is now same size as body text
* The rounder corners are now less rounded
* Collapsing headers no longer have a frame around them
* Combo-boxes looks better when opened
* Slightly more muted colors
* Remove extra line spacing after `\n` (i.e. between paragraphs)

* Thinner scrollbars

* Tweak light mode

* Tweak shadows

* Fix broken doc link

* Add style tweak to CHANGELOG
2021-06-12 15:53:56 +02:00
Emil Ernerfeldt
e6fe6a6f6a Fix occasional jittery vertical positioning of glyphs 2021-05-28 19:51:10 +02:00
Violeta Hernández
66095b69a7
Disable default features of ord-float (#440)
* Might fix #439

* `cargo update`

If the page builds, then this did fix it.
2021-05-27 20:25:30 +02:00
Emil Ernerfeldt
3b807e1ad6 Add Context::set_debug_on_hover and egui::trace!(ui) 2021-05-27 19:30:08 +02:00
St John Giddy
e320ef6c64
Detect single-threaded mutex reentry in debug mode (#433)
* fix(plot): expose VLine and HLine

* feat(mutex): detect mutex lock reetry

* chore(mutex): fix lints in tests
2021-05-26 22:13:24 +02:00
Emil Ernerfeldt
196ddff499 Rename Shape::polygon to Shape::convex_polygon
epaint only supports filling convex polygons (for now)
2021-05-20 22:14:08 +02:00
Emil Ernerfeldt
085233f907 Improve various documentation 2021-05-20 22:12:17 +02:00
Gray Olson
c0929014bf
Add support for cint (conversions to and from color types) (#393)
* implement cint for color types under feature flag

* upgrade to cint 0.2, remove from default features

* upgrade to cint 0.2.1, add a couple more from/into implementations

* changelog entry

* fix typo in changelog

* sort dependency

* fmt
2021-05-20 20:09:52 +02:00
Emil Ernerfeldt
6e5b52e3bc Add features extra_asserts and extra_debug_asserts for more asserts
This replaces all debug_asserts with these opt-in asserts

Related: https://github.com/emilk/egui/issues/395
2021-05-17 22:38:39 +02:00
Emil Ernerfeldt
9c475204da Fix uneven text kerning for non-integral dpi scales
Closes https://github.com/emilk/egui/issues/382
2021-05-12 19:41:45 +02:00
Emil Ernerfeldt
7b0f991b20 Improve docs concerning custom fonts, themes and accessibility
Closes https://github.com/emilk/egui/pull/370
Closes https://github.com/emilk/egui/issues/372
2021-05-11 14:56:27 +02:00
Emil Ernerfeldt
8f8ba16696 Release 0.12.0 - Multitouch, user memory, window pivots, and improved plots 2021-05-10 18:27:39 +02:00
Emil Ernerfeldt
b1559963bf Enable a bunch more clippy lints 2021-05-09 14:13:09 +02:00
Emil Ernerfeldt
4022b84ae7 group rustdoc lints under rustdoc:: prefix 2021-05-09 14:01:57 +02:00
Emil Ernerfeldt
fb5176c133 #![allow(clippy::float_cmp)] everywhere
it has always been an annoyance, never a help
2021-05-09 14:00:53 +02:00
Luis Wirth
87bc26fb5a
implement mint conversions (#352)
* Implement mint conversions

Implement conversions for [mint](https://docs.rs/mint) (math interoperability standard types).

- `impl {From, Into}<mint::Point2> for Pos2`
- `impl {From, Into}<mint::Vector2> for Vec2`

* Forward `mint` feature: egui -> epaint -> emath
2021-05-08 08:17:01 +02:00
Emil Ernerfeldt
66122e4c9a Decrease indentation with shift-tab 2021-05-02 20:09:11 +02:00
Emil Ernerfeldt
bf8ce774cc Don't draw bidi control characters
Closes https://github.com/emilk/egui/issues/336
2021-05-02 19:50:06 +02:00
Emil Ernerfeldt
7da9928548 Clean up new code editor code 2021-05-02 19:28:02 +02:00
Cristian Dinu
35c7b09285
Tab identation for multiline text edit (#246)
Lock focus on multiline text edit, and insert tabs on tab char

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2021-05-02 18:56:28 +02:00
David Pedersen
02a62d1986
Replace impl Into<String> with impl ToString (#302)
* Replace `impl Into<String>` with `impl ToString`

This is something I ran into today. Types that implement
`std::fmt::Display` cannot be passed to functions that take `impl
Into<String>`. You have to call `display_thing.to_string()`. Its a small
thing but would be fixed by instead taking `impl ToString`.

Afaik `impl ToString` is a superset of `impl Into<String>`, unless users
manually implement `Into<String> for T` (or `From<T> for String`) for
their own types. However I think its more common to implement `Display`
as that works with `println` and friends. The main difference is that
`Display::fmt` can return errors but thats also quite rare in my
experience.

I did some testing in a [playground] and seems to work.

[playground]: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=1111e071f6ae416ae2688d58d2e9b575

* Silence warnings
2021-04-29 19:49:49 +02:00
Emil Ernerfeldt
58ebb217dc Tesselator: ignore zero-sized clip rects
Improves https://github.com/emilk/egui/issues/328
2021-04-20 10:05:47 +02:00
Emil Ernerfeldt
0f1df90d90 Tesselator: ignore non-positive clip rectangles
Closes https://github.com/emilk/egui/issues/328
2021-04-19 23:00:30 +02:00
Emil Ernerfeldt
76d5229821
CI: run cargo doc (#309)
* Deny doc errors

* Add intentional bad intradoc link to test CI

* Add cargo doc to CI

* Fix carg doc web (add wasm32 target)

* Fix intentionally broken doc-link
2021-04-15 10:35:15 +02:00
Emil Ernerfeldt
d544c3dd8b Release 0.11.0 - Optimization, screen reader & new layout logic 2021-04-05 14:49:06 +02:00
Emil Ernerfeldt
d848b2a664 Add TextEdit::password to hide input characters 2021-04-02 09:58:55 +02:00
Emil Ernerfeldt
fe0d31204e Small optimization of tesselate_text 2021-04-01 23:07:15 +02:00
Emil Ernerfeldt
d7f9e2246c Add a bunch on inline annotations 2021-04-01 23:07:15 +02:00
Emil Ernerfeldt
0a21b01c31 Fix nightly build: remove deprecated missing_crate_level_docs lint
Closes https://github.com/emilk/egui/issues/250 and
https://github.com/emilk/egui/pull/251
2021-03-31 20:00:22 +02:00
Emil Ernerfeldt
4808da44a2 Optimize: more inlining and more use of AHashMap
No real gains, but it didn't hurt either
2021-03-31 17:06:12 +02:00
Emil Ernerfeldt
17983e1bbc Optimize tessellator by around 9% 2021-03-30 22:36:45 +02:00
Emil Ernerfeldt
8c4bb0d1d9 refactor: no need to pass Fonts structure to tessellator
This makes the tesselator take only data as argument,
which is a lot nicer.
2021-03-30 21:41:39 +02:00
Emil Ernerfeldt
0802a9d9c0 Optimize: get glyph uv rects during layouts instead of in tesselation
This allows them to be cached, saving around 20% total CPU.

It also makes the code more nicely structured
2021-03-30 21:07:19 +02:00
Emil Ernerfeldt
1c60dc8d66 Pass around Arc<Galley> to avoid copying a lot of data 2021-03-29 22:49:54 +02:00
Emil Ernerfeldt
94baf98eab Add a galley cache to Fonts to avoid doing the same layout each frame 2021-03-29 22:49:48 +02:00
Emil Ernerfeldt
d4e5133da2 refactor fonts: put TextStyle in Galley instead of in Shape::Text 2021-03-29 21:24:09 +02:00
Emil Ernerfeldt
ade41403b5 refactor fonts: do all text layout via the Fonts struct 2021-03-29 21:12:11 +02:00
Emil Ernerfeldt
46425f1e38 Optimize: add #[inline(always)] to various low-level things
saves up to 20% (text tesselation), and at least 5% overall
2021-03-28 23:16:19 +02:00
Emil Ernerfeldt
cbe6faa83b Render tab character (\t) as four spaces 2021-03-23 20:06:52 +01:00
Emil Ernerfeldt
fd3444473f Add some clippy lints 2021-03-23 19:53:31 +01:00
Emil Ernerfeldt
f5c372910c Replace emath::clamp with f32::clamp (new in rustc 1.50) 2021-03-21 17:47:03 +01:00
Emil Ernerfeldt
e20e3baa98 Bug-fixes related to recent layout rewrite 2021-03-21 14:48:12 +01:00
Emil Ernerfeldt
ec9f374d8c Fix: centered horizontal layouts should never overflow upwards 2021-03-21 10:31:18 +01:00
Emil Ernerfeldt
36d9f8a7c7 Add sanity check on pixels_per_point range 2021-03-17 08:44:00 +01:00
Emil Ernerfeldt
30885b85f9 Derive PartialEq for Vertex, Mesh, Row, Galley and Shape 2021-03-13 12:58:17 +01:00
Emil Ernerfeldt
4c45ca113e Make sure to include license files in the next release 2021-03-09 18:35:13 +01:00