Commit graph

353 commits

Author SHA1 Message Date
Emil Ernerfeldt
3819ec6fc7 Update "password" demo (storing widget state) after #836 refactor
https://github.com/emilk/egui/pull/836
2021-10-27 16:40:21 +02:00
Emil Ernerfeldt
c7638ca7f5
Add read/write of TextEdit cursor state (#848)
* Rename `CursorPair` to `CursorRange`
* Easymark editor: add keyboard shortcuts to toggle bold, italics etc
* Split up TextEdit into separate files
* Add TextEdit::show that returns a rich TextEditOutput object with response, galley and cursor
* Rename text_edit::State to TextEditState
2021-10-27 16:30:14 +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
41f77ba7d7 Clean up some of the new context menus
Follow-up to https://github.com/emilk/egui/pull/543

* Add entry to CHANGELOG.md
* Add entry to contributors in README.md
* Improve documentation
* Simplify demo
2021-10-26 20:16:46 +02:00
Linus Behrbohm
46fb9ff09b
Context menus (#543)
Main usage: `response.context_menu(…)` and `ui.menu_button`
2021-10-26 19:55:42 +02:00
Emil Ernerfeldt
c335c56de1 dancing_string demo: handle large input.time
casting time to f32 is a bad idea if the time is seconds since epoch
as it is on some integrations.
2021-10-24 18:38:44 +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
17f0ae22c9 Code example demo: remove extra ScrollArea 2021-10-23 15:36:25 +02:00
Emil Ernerfeldt
39c6c7e5c9 Small code cleanup 2021-10-23 06:03:45 +02:00
Emil Ernerfeldt
6185ee8ce4 Demo: add button to reset the demo 2021-10-23 05:50:42 +02:00
Emil Ernerfeldt
d97a369c44 End statements with semicolon (clippy::semicolon_if_nothing_returned) 2021-10-20 16:46:57 +02:00
Emil Ernerfeldt
ab3be8aca3 Use for-loop instead of Iterator::for_each 2021-10-20 16:46:57 +02:00
Emil Ernerfeldt
40445c450c use map_or and map_or_else 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
dd5d41d04e Improve backend panel in demo 2021-10-20 13:54:56 +02:00
Emil Ernerfeldt
f025513998
Code example demo (#823) 2021-10-20 12:34:27 +02:00
Emil Ernerfeldt
8178d23d19
Deduplicate code found in both egui_glium and egui_glow (#819)
* Move window building to egui-winit

* Move icon loading to egui-winit

* `use glow::HasContext;` -> `use glow::HasContext as _;`

* Move FileStorage into epi behind a feature flag

* De-duplicate screen_size_in_pixels and native_pixels_per_point

* Move creation of FileStorage to epi

* Handle epi app output (window size changes etc) in egui-winit

* Move app and memory persistence and autosave logic to egui-winit

* fix check.sh

* Make the epi backend opt-in for egui_glium and egui_glow

* Fix persistence

* Add integration name to epi::IntegrationInfo and the demo

* Clean up Cargo.toml files and fix making egui_glium optional

* fix typo

* Make egui_glium compile without the `epi` feature
2021-10-19 21:40:55 +02:00
Emil Ernerfeldt
844dd9d7a4 Remove "seconds_since_midnight" from epi/eframe. Use chrono instead
chrono works both natively and on web.

Related: https://github.com/emilk/egui/issues/212
2021-10-19 15:37:20 +02:00
Emil Ernerfeldt
cdd4dccf5f
Add egui_glow as an opt-in backend to eframe (#817)
* Make egui_glow and opt-in backend for eframe

* Add egui_glow to Cargo.toml and to CI

* Reference egui_glow where egui_glium is mentioned

* Remove path-patches from root Cargo.toml

* Add instructions on how to enable the glow backend of eframe
2021-10-19 15:32:23 +02:00
Emil Ernerfeldt
ebd2c859ac Make multi-touch demo a bit nicer looking 2021-10-18 21:00:25 +02:00
Emil Ernerfeldt
2af2e8bad5 Add ui.add_enabled and ui.add_enabled_ui, and remove Button::enabled 2021-10-17 22:17:50 +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
85941033e8 Simplify and improve http demo app
Move demo of POST to the ehttp crate instead
2021-10-13 11:47:57 +02:00
Ben Postlethwaite
5799758c2b
implement stick-to-end scroll (#765)
* implement stick-to-end scroll

* improve comment grammar

* accept emilk suggestion for demo text tweak

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>

* request repaint on each frame to show incoming scroll demo rows

* simplify pub api + doc strings

* disable scroll_stuck_to_end when wheel-scrolling or dragging

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2021-10-09 12:59:42 +02:00
Emil Ernerfeldt
1dfc399d98 code cleanup: use Trait as _; 2021-10-09 12:04:10 +02:00
Emil Ernerfeldt
45ab9a2450 demo: add syntax_highlighting module with theme editor 2021-10-09 12:04:10 +02:00
Emil Ernerfeldt
0cb1b18a6a fix shrinking scroll area in http demo 2021-10-09 12:04:10 +02:00
Emil Ernerfeldt
ce8d863249 auto-shrink ScrollArea to content size
Unless the user disables it with `ScollArea::auto_shrink([false; 2])`.
2021-10-06 23:51:03 +02:00
Emil Ernerfeldt
f59abd9684 Clean up some macro syntax 2021-10-02 21:08:00 +02:00
Emil Ernerfeldt
f0868c2f07 Code editor demo: nice syntax highlighting with customizable theme 2021-10-01 21:29:33 +02:00
Emil Ernerfeldt
96557a4fa6 Add egui::widgets::global_dark_light_mode_buttons 2021-10-01 21:28:12 +02:00
Emil Ernerfeldt
863e6cb07d expose egui::TextFormat 2021-10-01 19:25:15 +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
zu1k
f6fb4d942a
epi: drag native window (#728)
* feat: drag window

* Update epi/src/lib.rs

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>

* Update egui_demo_lib/src/backend_panel.rs

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>

* cargo fmt

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2021-09-28 17:34:58 +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
5e3c522b6c clippy fixes 2021-09-06 21:23:57 +02:00
Emil Ernerfeldt
7a9805dfb3 demo: highlight easymark editor field with different fonts and colors 2021-09-06 08:14:47 +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
71d18ba3e7 Spelling: tesselate -> tessellate 2021-09-03 21:07:25 +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
9def6ef6df All Ui:s must now have a finite max_rect
Deprecated `max_rect_finite`, `available_size_before_wrap_finite`
and `available_rect_before_wrap_finite`.
2021-08-28 16:02:16 +02:00
Emil Ernerfeldt
105b999cb6
Horizontal scrolling (#663)
* First pass (missing rendering the bar)

* Render horizontal bars, and change Window scroll API

* emath: add impl Index + IndexMut for Align2

* Scrolling: fix subtle sizing bugs

* Add horizontal scrolling to color test

* try to wrap content before showing scrollbars, + add auto-shrink option

* Add hscroll to the misc demo window

* Fix for putting wrapping labels in an infinitely wide layout

* Add a egui_asserts to protect against nans in the layout engine

* Add line about horizontal scrolling to changelog

* Add example to docs of ScrollArea

* code cleanup
2021-08-28 13:18:21 +02:00
Emil Ernerfeldt
776770cdcd
Publish 0.14.2 (#670)
* Fix window resize bug introduced in `0.14.1`.

* tweak plot demo layout to allow more narrow window

* Release 0.14.2 - Window resize fix
2021-08-28 12:19:35 +02:00
Emil Ernerfeldt
7c67066190 demo: add expandable top panel to panels-in-window demo 2021-08-27 20:08:01 +02:00
Emil Ernerfeldt
52193c2273 demo: demonstrate how to prevent auto-shrinking windows 2021-08-27 19:59:31 +02:00
Emil Ernerfeldt
7e9c3291bd Tiny demo tweaks 2021-08-26 18:54:38 +02:00
Emil Ernerfeldt
693426d9c6
Layout fixes (#651)
* Fix incorrect max_width/height of panels

* Fix set_width/set_min_width/set_height/set_min_height

Closes https://github.com/emilk/egui/issues/647

Broke in https://github.com/emilk/egui/pull/629

* Fix expand_to_include_x/expand_to_include_y

* Make minimum grid column width propagate properly

* Expand cursor when max_rect expands

* Add ui.expand_to_include_y

* Only expand cursor in advance

* demo: clean up font_book code

* Fix: Make sure `TextEdit` contents expand to fill width if applicable

* ProgressBar: minimum width and fix for having it in an infinite layout

* clippy fix
2021-08-26 18:50:30 +02:00
AsmPrgmC3
3a634ff46e
Reintroduce color fixes to WebGL1 backend, but only if sRGB textures are supported (#652)
Also removed the 300es shaders, as they'd be identical to the 100es ones.
2021-08-26 18:40:35 +02:00
AsmPrgmC3
31a1882997
Fix alpha blending in WebGL2 backend (#650)
Add a render-to-texture step with an sRGBA8 texture
2021-08-25 21:28:42 +02:00
Emil Ernerfeldt
cb566fc295 Release 0.14.0 - Ui panels and bug fixes 2021-08-24 16:47:10 +02:00
Emil Ernerfeldt
a6799b1278 Minor demo improvements 2021-08-24 16:38:03 +02:00
Emil Ernerfeldt
246b1e084b Improve panel demo 2021-08-23 22:28:42 +02:00
Emil Ernerfeldt
5d0e348777 Clean up demo slightly 2021-08-23 21:28:06 +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
Emil Ernerfeldt
a256ca115b
Drag and drop files into egui_glium and egui_web (#637)
* Implement file drag-and-drop for egui_glium

* Implement file drag-and-drop into egui_web

* Cleanup
2021-08-20 22:20:45 +02:00
gents83
68ed22ab6f
Add option to select collapsing headers (#623)
* Add collapsing header select as selectable label

* Modified Tree demo adding selectable example

* Update egui/src/containers/collapsing_header.rs

Selected is not linked to selectable

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>

* Update egui/src/containers/collapsing_header.rs

Description example

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>

* Changing example without name clashing

* Fixing merge issue (ah I miss P4 sometimes)

* Fixing doctest example

* Add possibility to show background to a single one

* Fixing clippy test

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2021-08-20 19:04:13 +02:00
Emil Ernerfeldt
3e2746a288
Make it easy to panels inside of Ui:s (#629)
* Allow using the layout cursor to restrict available area

* Avoid id clashes when putting panels inside a Ui

* Panels: Propagate height/width range to inner Ui

* Allow easy placement of panels inside of Ui:s

* demo: simplify Windows with Panels demo
2021-08-20 00:10:06 +02:00
Emil Ernerfeldt
62808b2bb9 Silence warning 2021-08-18 22:51:16 +02:00
gents83
ff8c4c0d38
Add possibility of panels inside UI (i.e. windows) (#624)
* Adding possibility to have panels inside UI

* Adding window with panels demo
2021-08-16 21:32:44 +02:00
skuzins
6a8a93e120
Generalize http fetch (#488)
* Generalize http fetch

- allow bytes as request body
- expose request and response headers in API
- update http example to show response headers and allow POST requests

* clippy fixes

* add missing comment, pub

* doc comment fix

* fix: missing argument when feature syntect not enabled

* formatting fixes

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>

* remove commented out code

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>

* formatting fixes

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>

* cargo fmt

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2021-08-15 16:56:46 +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
faf104220b Grid::num_columns: allow the last column to take up the rest of the space
This allows for resizaeable grids, where the last column will be given the remainder of the width.
To demonstrate, the widget gallery window is now resizeable.
2021-07-02 09:55:57 +02:00
Simon Persson
9603bb4f85
Grid fixes (#473)
* Fix margin for grid layout nested inside grid

* Minor fix for grid layout

At time of end_row, current state is finished updating row_height.
Might as well use that instead of previous state.

* Fix horizontal advancing for nested layouts in grid

* Add back horizontal layout

* Add test for nested layouts in grids

* make test table striped

* Improve table test case with slider for dynamic text
2021-07-02 09:25:53 +02:00
Sven Niederberger
89cea7aca7
Progress bar (#519)
* add progress bar

* update changelog

* apply suggestions

* disable animation by default and tweak colors

* allow toggling the animation by clicking

* Update egui/src/widgets/progress_bar.rs

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>

* Update egui/src/widgets/progress_bar.rs

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>

* Update egui/src/widgets/progress_bar.rs

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>

* address review comments

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2021-07-01 22:50:41 +02:00
Emil Ernerfeldt
cba840ec49
Small plot-relates fixes (#526)
* plot: take any id source as argument instead of ToString

* plot: allow user to set stroke on HLine/VLine

* Update changelog
2021-06-28 10:51:06 +02:00
Emil Ernerfeldt
4f6dac27e6 Clippy fix 2021-06-24 20:13:34 +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
Emil Ernerfeldt
182eb32b95 Tidy up plot demo 2021-06-24 15:20:31 +02:00
Sven Niederberger
147e7a47aa
More plot items (#471)
* Added plot items:

* Arrows, also called "Quiver plots" in matplotlib etc.
* Convex polygons
* Text
* Images

Other changes:

* Make HLine/VLine into PlotItems as well.
* Add a "fill" property to Line so that we can fill/shade the area between a line and a horizontal reference line.
* Add stems to Points, which are lines between the points and a horizontal reference line.
* Allow using .. when specifying ranges for values generated by explicit callback functions, as an alias for f64::NEG_INFINITY..f64::INFINITY
* Allow using ranges with exclusive end bounds for values generated by parametric callback functions to generate values where the first and last value are not the same.

* update changelog

* add legend background
2021-06-24 12:29:51 +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
ef36cac422 Improve misc docs 2021-06-12 22:12:45 +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
Sven Niederberger
02db9ee583
Plot: Legend improvements (#410)
* initial work on markers

* clippy fix

* simplify marker

* use option for color

* prepare for more demo plots

* more improvements for markers

* some small adjustments

* better highlighting

* don't draw transparent lines

* use transparent color instead of option

* don't brighten curves when highlighting

* Initial changes to lengend:
* Font options
* Position options
* Internal cleanup

* draw legend on top of curves

* update changelog

* fix legend checkboxes

* simplify legend

* remove unnecessary derives

* remove config from legend entries

* avoid allocations and use line_segment

* compare against transparent color

* create new Points primitive

* fix doctest

* some cleanup and fix hover

* common interface for lines and points

* clippy fixes

* reduce visibilities

* update legend

* clippy fix

* change instances of "curve" to "item"

* change visibility

* Update egui/src/widgets/plot/mod.rs

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>

* Update egui/src/widgets/plot/mod.rs

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>

* Update egui_demo_lib/src/apps/demo/plot_demo.rs

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>

* Update egui_demo_lib/src/apps/demo/plot_demo.rs

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>

* changes based on review

* add legend to demo

* fix test

* move highlighted items to front

* dynamic plot size

* add legend again

* remove height

* clippy fix

* update changelog

* minor changes

* Update egui/src/widgets/plot/legend.rs

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>

* Update egui/src/widgets/plot/legend.rs

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>

* Update egui/src/widgets/plot/legend.rs

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>

* changes based on review

* add functions to mutate legend config

* use horizontal_align

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2021-06-07 22:36:13 +02:00
Emil Ernerfeldt
ece25ee7f3 Add Ui::set_visible as a way to hide widgets
Closes https://github.com/emilk/egui/issues/460
2021-06-07 22:12:49 +02:00
Emil Ernerfeldt
62f58a3b05 egui_web: default to light mode unless prefers-color-scheme: dark 2021-06-07 20:56:18 +02:00
Emil Ernerfeldt
44b573f6a6 epi: merge App::load into App::setup, and provide Frame argument
This gives users more control over the order of load/setup.

It also allows users to load textures in setup.
2021-06-07 20:53:33 +02:00
Emil Ernerfeldt
6468b2b84e
Implement efficent scrolling of large content (#457) 2021-06-03 18:48:45 +02:00
Emil Ernerfeldt
4d56d0328b demo: Move egui settings/inspection windows to backend panel 2021-05-28 00:40:36 +02:00
Emil Ernerfeldt
3b807e1ad6 Add Context::set_debug_on_hover and egui::trace!(ui) 2021-05-27 19:30:08 +02:00
Sven Niederberger
8623909d82
Plotting: Add line markers (#363)
* initial work on markers

* clippy fix

* simplify marker

* use option for color

* prepare for more demo plots

* more improvements for markers

* some small adjustments

* better highlighting

* don't draw transparent lines

* use transparent color instead of option

* don't brighten curves when highlighting

* update changelog

* avoid allocations and use line_segment

* compare against transparent color

* create new Points primitive

* fix doctest

* some cleanup and fix hover

* common interface for lines and points

* clippy fixes

* reduce visibilities

* Update egui/src/widgets/plot/mod.rs

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>

* Update egui/src/widgets/plot/mod.rs

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>

* Update egui_demo_lib/src/apps/demo/plot_demo.rs

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>

* Update egui_demo_lib/src/apps/demo/plot_demo.rs

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>

* changes based on review

* fix test

* dynamic plot size

* remove height

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2021-05-27 18:40:20 +02:00
Emil Ernerfeldt
c9766f8a7b
Resizable panels + right and bottom panels (#438)
* Side panel resizing and add right panels

* Add resizable top/bottom panels

* Deprecate TopPanel

* Final tweaks and update CHANGELOG.md
2021-05-26 22:06:10 +02:00
Ivo Vollrath
67c6002578
Fix mac scroll modifier (#402)
* fix modifier key for mouse wheel zoom

* update CHANGELOG

* fix zoom modifier for web backend

* improve instructions in plot demo window

* accept emilk's proposed change

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>

* update UI instructions for Plot demo

* improve UI instructions for plot demo

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2021-05-20 19:56:33 +02:00
Emil Ernerfeldt
dd4ac43b13 Make sure egui can handle zero-sized screen rect
This would previously hit a debug assert

Fixes https://github.com/emilk/egui/issues/395
2021-05-17 22:53: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
bd5a85808a egui_demo_lib: fix persistence feature flag 2021-05-17 22:37:36 +02:00
Emil Ernerfeldt
442b953964 Tell docs.rs to use the --all-features flag when generating docs
Closes https://github.com/emilk/egui/issues/381
2021-05-12 20:02:25 +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
1423bac3aa Smooth fading of plot grid and tick labels 2021-05-10 18:13:22 +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
Emil Ernerfeldt
a8c3deaf08 Rename ui.wrap to ui.scope 2021-05-09 13:17:32 +02:00
Emil Ernerfeldt
9dc092b778 Clean up demos 2021-05-09 13:07:56 +02:00
Emil Ernerfeldt
0b52813f62 Sort demo windows (multi-touch demo was out of order) 2021-05-09 10:09:05 +02:00
Emil Ernerfeldt
04d9ce227b Tidy up multitouch code: remove double spaces after full stop
Weirdest thing I've seen in my life.
2021-05-08 22:49:40 +02:00
Emil Ernerfeldt
268ddca161 demo_app: Remove screen_reader from default features
closes https://github.com/emilk/egui/issues/338
2021-05-08 16:27:41 +02:00
Emil Ernerfeldt
7374ed9d00 epi/eframe: move options out of trait App into new NativeOptions 2021-05-08 10:14:56 +02:00
Sven Niederberger
838f3e4ff2
Add plot legends (#349)
* add plot legends

* don't show crosshairs when hovering over legend

* add a toggle for the legend

* changes based on review

* improve legend behavior when curves share names
2021-05-07 10:32:17 +02:00
Ivo Vollrath
03721dbfd8
Basic multi touch support (issue #279) (#306)
* translate touch events from glium to egui

Unfortunately, winit does not seem to create _Touch_ events for the touch pad
on my mac.  Only _TouchpadPressure_ events are sent.

Found some issues (like
[this](https://github.com/rust-windowing/winit/issues/54)), but I am not sure
what they exactly mean:  Sometimes, touch events are mixed with
touch-to-pointer translation in the discussions.

* translate touch events from web_sys to egui

The are a few open topics:
- egui_web currently translates touch events into pointer events.
  I guess this should change, such that egui itself performs this kind of
  conversion.
- `pub fn egui_web::pos_from_touch_event` is a public function, but I
  would like to change the return type to an `Option`.  Shouldn't this
  function be private, anyway?

* introduce `TouchState` and `Gesture`

InputState.touch was introduced with type `TouchState`, just as
InputState.pointer is of type `Pointer`.

The TouchState internally relies on a collection of `Gesture`s.  This commit
provides the first rudimentary implementation of a Gesture, but has no
functionality, yet.

* add method InputState::zoom()

So far, the method always returns `None`, but it should work as soon as the
`Zoom` gesture is implemented.

* manage one `TouchState` per individual device

Although quite unlikely, it is still possible to connect more than one touch
device. (I have three touch pads connected to my MacBook in total, but
unfortunately `winit` sends touch events for none of them.)

We do not want to mix-up the touches from different devices.

* implement control loop for gesture detection

The basic idea is that each gesture can focus on detection logic and does not
have to care (too much) about managing touch state in general.

* streamline `Gesture` trait, simplifying impl's

* implement first version of Zoom gesture

* fix failing doctest

a simple `TODO` should be enough

* get rid of `Gesture`s

* Provide a Zoom/Rotate window in the demo app

For now, it works for two fingers only.  The third finger interrupts the
gesture.

Bugs:
- Pinching in the demo window also moves the window -> Pointer events must be
  ignored when touch is active
- Pinching also works when doing it outside the demo window -> it would be nice
  to return the touch info in the `Response` of the painter allocation

* fix comments and non-idiomatic code

* update touch state *each frame*

* change egui_demo to use *relative* touch data

* support more than two fingers

This commit includes an improved Demo Window for egui_demo, and a complete
re-write of the gesture detection.  The PR should be ready for review, soon.

* cleanup code and comments for review

* minor code simplifications

* oops – forgot the changelog

* resolve comment fee8ed83db (r623226656)

* accept suggestion https://github.com/emilk/egui/pull/306#discussion_r623229228

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>

* fix syntax error (dough!)

* remove `dbg!` (why didnt clippy see this?)

* apply suggested diffs from review

* fix conversion of physical location to Pos2

* remove redundanct type `TouchAverages`

* remove trailing space

* avoid initial translation jump in plot demo

* extend the demo so it shows off translation

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2021-05-06 21:01:10 +02:00
Emil Ernerfeldt
0d71017ad4 clippy fixes for rust 1.52 2021-05-06 20:49:22 +02:00
Emil Ernerfeldt
1394205f52 Document and demonstrate how to expand a TextEdit to fill a Ui 2021-05-02 21:57:51 +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
Emil Ernerfeldt
c2744a1437
Implement trackpad pinch-to-zoom for plots in egui_web (#333)
This adds a new `zoom_delta` to input.
This is hooked up to ctrl-scroll on egui_web and egui_glium.

Browsers convert trackpad pinch gestures to ctrl-scroll,
so this means you can not pinch-to-zoom plots (on trackpad).

In the future we can support multitouch pinch-to-zoom via the same
`InputState::zoom_factor()` function
2021-04-25 17:04:34 +02:00
Sven Niederberger
a505d01090
Plot refactor (#331)
* drag and zoom support for plots

* update doctest

* use impl ToString

* revert back to Into<String> until #302 is solved

* Apply suggestions from code review

Co-authored-by: ilya sheprut <optitel223@gmail.com>

* use persistence feature for PlotMemory

* * split plot into multiple files
* add curve from function
* move more functionality into ScreenTransform struct

* changes from code review in base branch

* let user specify a range for generated functions

* rename file

* minor changes

* improve generator functionality

* improve callback and add parametric callback

* minor changes

* add documentation

* fix merge issues

* changes based on review

* rename folder

* make plot.rs the mod.rs file

* remove mod.rs

* rename file

* namespace changes

* fix doctest

* Update egui/src/widgets/plot/items.rs

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>

Co-authored-by: ilya sheprut <optitel223@gmail.com>
Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2021-04-24 14:26:54 +02:00
Emil Ernerfeldt
6b24dbc997 Move easy_mark from egui deo egui_demo_lib 2021-04-24 01:18:08 +02:00
Sven Niederberger
012542d066
Drag and zoom support for plots (#317)
* drag and zoom support for plots

* update doctest

* use impl ToString

* revert back to Into<String> until #302 is solved

* Apply suggestions from code review

Co-authored-by: ilya sheprut <optitel223@gmail.com>

* use persistence feature for PlotMemory

* rename shift -> translate

* remove automatic bounds

* removed unused methods

* Into<String> -> ToString

* Apply suggestions from code review

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>

* avoid potential invalid bounds bug

* use new is_valid method

* improve auto bounds behavior as suggested

* use NOTHING to initialize min_auto_bounds

Co-authored-by: ilya sheprut <optitel223@gmail.com>
Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2021-04-21 21:50:27 +02:00
Emil Ernerfeldt
fbd0e35017 Clippy fixes for benchmark 2021-04-18 23:14:35 +02:00
Emil Ernerfeldt
c07f439b28 Add benchmark of ui.label
This is to help evaluate the impact of
https://github.com/emilk/egui/pull/302
2021-04-18 10:24:31 +02:00
ilya sheprut
c69ecfe421
Memory usage example in the widget gallery (#307)
* init example

* add comments

* fix grammar in comments

* fix CI

* change example from view_edit to password

* rename file

* fix CI
2021-04-18 10:13:08 +02:00
Emil Ernerfeldt
580d27e0d3
Add anchors to windows and areas (#310)
This is so that you can put a window in e.g. the top right corner
or the center of the screen.
2021-04-18 10:01:41 +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
daf2e13238 demo: Use new id_data to store the show/hide password toggle 2021-04-12 22:37:39 +02:00
Emil Ernerfeldt
b30cb3313a
Try to allow turning off default_fonts for all libs (#266) 2021-04-07 20:14:44 +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
3803d0f3d1 Minor cleanup of the demo code 2021-04-05 14:23:42 +02:00
Emil Ernerfeldt
4b9db0cc55 Rename ui.advance_cursor to ui.add_space 2021-04-02 10:13:06 +02:00
Emil Ernerfeldt
d848b2a664 Add TextEdit::password to hide input characters 2021-04-02 09:58:55 +02:00
Emil Ernerfeldt
1c955e56fe Some code cleanup 2021-04-01 23:07:58 +02:00
Emil Ernerfeldt
44869a6718 Clean up benchmarks 2021-04-01 21:42:45 +02:00
Emil Ernerfeldt
f6770f0183 Various spelling fixes, docs improvements and code cleanup 2021-03-31 23:12:42 +02:00
Emil Ernerfeldt
f79f24c83e Clean up dependencies and features flags 2021-03-31 22:53:54 +02:00
Emil Ernerfeldt
3450168e94 egui_glium: add support for transparent windows
Also support non-decorated windows (without border)
2021-03-31 20:53:13 +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
1c60dc8d66 Pass around Arc<Galley> to avoid copying a lot of data 2021-03-29 22:49:54 +02:00
Emil Ernerfeldt
f9c4be33a7 Add a realistic end-to-end benchmark 2021-03-29 22:49:40 +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
ccc501f302 Spelling: tesselate -> tessellate 2021-03-28 22:44:03 +02:00
Emil Ernerfeldt
5011623744 Deprecate old DragValue constructors in favor of DragValue::new 2021-03-27 16:09:09 +01:00
Emil Ernerfeldt
de439b6e21 Deprecate old Slider constructors in favor of Slider::new 2021-03-27 16:07:18 +01:00
Emil Ernerfeldt
41c9de2734 Add new ComboBox builder to replace the combo_box_with_label function 2021-03-27 10:35:40 +01:00
Emil Ernerfeldt
70c6f4596a Add checkbox in demo app to turn screen reader on/off 2021-03-24 21:35:29 +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
ed0d406698 Improve misc documentation
Closes https://github.com/emilk/egui/issues/229
2021-03-21 17:13:58 +01:00
Emil Ernerfeldt
f77ab26828 [EasyMark] Add support for small and raised text 2021-03-21 15:11:12 +01:00
Emil Ernerfeldt
eaa1ed96ee Depcrecate ui.horizontal_for_text and ui.horizontal_wrapped_for_text
They just add unnecessary complexity at this point
2021-03-21 14:48:16 +01:00
Emil Ernerfeldt
953d2bb39b Add ui.set_row_height 2021-03-21 14:48:16 +01:00