Commit graph

63 commits

Author SHA1 Message Date
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
Emil Ernerfeldt
fb2db4940e Release 0.10.0 - Plot and polish 2021-02-28 20:11:37 +01:00
Emil Ernerfeldt
a19140ec67 A simple 2D plot library 2021-02-17 22:54:10 +01:00
Emil Ernerfeldt
fc0bec44ba Remove Fonts::default() implementation 2021-02-08 23:05:48 +01:00
Emil Ernerfeldt
1c415bd8fe Add benchmark for text layout and tesselation 2021-02-08 22:53:31 +01:00
Emil Ernerfeldt
b61db038f2 Release 0.9.0 - light mode, right clicks and more 2021-02-07 17:06:51 +01:00
Emil Ernerfeldt
d9472035d7 Update ahash 0.6.3 -> 0.7.0 2021-02-07 17:04:03 +01:00
Emil Ernerfeldt
bca722ddf8 Add ui.set_enabled(false) to disable all widgets in a Ui
Closes https://github.com/emilk/egui/issues/50
2021-02-07 10:55:45 +01:00
Emil Ernerfeldt
d07a17ac6a Expose more color-related functions and types 2021-02-07 10:36:51 +01:00
Emil Ernerfeldt
8189a78284 Improve text wrapping related to first line indentation and logograms 2021-02-06 15:19:04 +01:00
Emil Ernerfeldt
91ce18d62f Widgets will now always line break at \n characters 2021-02-06 14:50:03 +01:00
Emil Ernerfeldt
2d9d06dbff [emath] Use const values for Vec2::ZERO, Rect::EVERYTHING etc 2021-02-05 10:11:39 +01:00
Emil Ernerfeldt
0942a2aa3b [epaint] Tessellator: handle sharp path corners better
Switch to bevel joints instead of miter joints for > 90° corners
2021-02-04 18:46:36 +01:00
Emil Ernerfeldt
a19fd7b780 Add light mode 2021-02-03 19:30:58 +01:00
Emil Ernerfeldt
7336df53b7 Tweak line spacing for new paragraphs 2021-01-31 16:42:54 +01:00
Emil Ernerfeldt
b647592a5a Wrap text at dashes, punctuations or anywhere if necessary
Closes https://github.com/emilk/egui/issues/55

Supersedes https://github.com/emilk/egui/pull/104
2021-01-31 15:57:19 +01:00
Emil Ernerfeldt
c50190a7e8 Add fake italics (tilt text) 2021-01-30 15:55:40 +01:00
Emil Ernerfeldt
96fb0771a2 Fix text layout bug: empty text would lack first row indentation 2021-01-27 20:17:16 +01:00
Emil Ernerfeldt
2a10747843 Mesh::split_to_u16 now returns a 16-bit indexed Mesh16 2021-01-25 22:06:06 +01:00
Emil Ernerfeldt
b493bc6efc Wrap tesselated output in struct ClippedMesh(Rect, Mesh) 2021-01-25 21:43:17 +01:00
Emil Ernerfeldt
75fa77e040 Rename Triangles to Mesh 2021-01-25 21:23:24 +01:00