Commit graph

1931 commits

Author SHA1 Message Date
Wayne Warren
51a98d586b egui_extras: fix row indexing 2022-04-03 20:03:11 -06:00
Wayne Warren
91d78fa2e9 egui_extras: clean up virtual scroll table demo settings a little 2022-04-03 20:02:50 -06:00
Wayne Warren
1c5f93322d egui_extras: restore TableBody::row example 2022-04-03 12:16:23 -06:00
Wayne Warren
7706a91974 egui_extras: add heterogeneous_rows example 2022-04-03 12:11:12 -06:00
Wayne Warren
2f22f41185 egui_extras: cleanup TableBody.heterogeneous_rows a little
* use f64 when accumulating virtual height above and below visible
  region
* break the big loop iterating over heights into three loops, one for
  each non-visible region, and one for the visible region
* retain each row's stripe color using an enumeration over the given
  heights iterator
* use a VIRTUAL_EXTENSION constant to extend the "visible" region of the
  table above and below the actual visible region to provide the
  illusion of rows sliding into and out of sight
2022-04-03 12:00:27 -06:00
Wayne Warren
c2df572dd1 egui_extras: add comments to new TableBody methods 2022-04-03 11:25:38 -06:00
Wayne Warren
44bd8c1cc4 egui_extras: follow closure-based conventions for TableBody.heterogeneous_rows 2022-04-03 11:18:18 -06:00
Wayne Warren
ab4930fde7 egui_extras: make number of rows in table demo configurable 2022-04-03 10:59:10 -06:00
Wayne Warren
e81a92d32d egui_extras: enable virtual scroll for heterogenous rows
Introduce `TableBody.heterogenous_rows` and `TableRowBuilder`, the former of which takes as an argument the latter. `TableRowBuilder` provides two methods that enable virtual scrolling for rows with non-uniform heights. Those methods are:

* `TableRowBuilder.row_heights` which returns an iterator over `f32` to allow incremental virtual scroll buffer calculation.
* `TableRowBuilder.populate_row` which `TableBody.heterogenous_rows` uses to allow `TableRowBuilder` implementations to, you guessed it, populate rows that are visible.

One thought that occurs to me while writing this description is that
`TableBody.heterogenous_rows` could look more like the following:

```
    pub fn heterogenous_rows(
        mut self,
        row_heights: impl Iterator<Item = f32> + '_,
        mut row: impl FnMut(usize, TableRow<'_, '_>),
    )
```

This could potentially be easier to use, considering all the trouble I had coming up with and implementing the trait. Happy to make this change if the maintainers prefer.
2022-04-03 00:18:17 -06:00
Emil Ernerfeldt
5dff1e42c6
More table improvements (#1440)
* Clip by default
* Fix some spacing bugs
* datepicker: look nicer in light mode
* datepicker: show month names
* Table: don't allow resize of last column if it is Size::Remainder
2022-04-01 15:27:42 +02:00
Emil Ernerfeldt
c029f25c13 Table: don't allow resize of last column if it is Size::Remainder 2022-04-01 14:44:25 +02:00
Emil Ernerfeldt
51cc9c9a9a Table: fix bug with item spacing 2022-04-01 14:43:43 +02:00
Emil Ernerfeldt
21c32a18d8
Table resize (#1438)
* Let 1D strips fill up parent width/height
* Add Strip + Table + DatePicker to egui_extras changelog
* Expose some dragging- and pointer related context/memory methods
* Make tables resizable
2022-04-01 12:01:00 +02:00
Collin Kemper
a52bbade45
Place dark-light behind a feature gate in eframe and egui_glow (#1437) 2022-04-01 11:10:47 +02:00
René Rössler
1d32670cf3
Dynamic sized strips, tables, and date picker (#963) 2022-03-31 21:13:25 +02:00
follower
95ff7ec000
Typo fixes in egui_web README (#1433) 2022-03-30 10:19:42 +02:00
Luis Wirth
c3ac340e25
egui-winit: re-export egui (#1429) 2022-03-28 13:23:07 +02:00
Emil Ernerfeldt
8f178fa4e0
Add glow::Context to epi::Frame (#1425)
This can be used, for instance, to:

* Render things to offscreen buffers.
* Read the pixel buffer from the previous frame (glow::Context::read_pixels).
* Render things behind the egui windows.
2022-03-27 15:20:45 +02:00
Emil Ernerfeldt
b7ebe16cfb
Storage and frame refactor (#1418)
The purpose of this is to expose `frame.storage()` and `frame.storage_mut()` so users can save/load app state from the `App::update` function, without having to add another parameter to that function.

Changes:
* Added `Frame::storage()` and `Frame::storage_mut()`
* `App::update` now takes a `&mut Frame` rather than just `&Frame`
* `Frame` is no longer `Clone` or `Sync` (doesn't have to be since https://github.com/emilk/egui/pull/1366)
2022-03-25 21:19:31 +01:00
Anna Clemens
bc0fdefceb
Expose ui.cursor and ui.next_widget_position (#1342) 2022-03-25 19:34:03 +01:00
4JX
dd9699099f
Add ComboBox::icon() (#1405) 2022-03-23 21:56:46 +01:00
Emil Ernerfeldt
8272b08742
Improve text contrast in bright mode (#1412)
* Rename AlphaImage to FontImage to discourage any other use for it
* Encode FontImage as f32 and postpone the alpha correction
* Interpret alpha coverage in a new, making dark text darker, improving contrast in bright mode
2022-03-23 16:49:49 +01:00
Zachary Kohnen
d3c002a4e5
Remove FAQs for resolved issues (#1413)
It was noted that the problems with Firefox on Linux/MacOS have been resolved in #1377 and the limitation on the canvas size was lifted in commit 465c96122c
2022-03-23 15:37:50 +01:00
Emil Ernerfeldt
bcddafb505 Add a some fine lines to the color test to test anti-aliasing 2022-03-23 13:31:38 +01:00
Emil Ernerfeldt
3e41da7187 Revert accidentally setting srgb option on glutin window based on vsync
Introduced in a9fd03709e
2022-03-23 13:04:12 +01:00
Emil Ernerfeldt
1387d6e9d6
Refactor TessellationOptions to expose slider for feathering size (#1408)
The epaint tessellator uses "feathering" to accomplish anti-aliasing. This PS allows you to control the feathering size, i.e. how blurry the edges of epaint shapes are.

This changes the interface of Tessellator slightly, and renames some options in TessellationOptions.
2022-03-23 11:41:38 +01:00
Emil Ernerfeldt
a9fd03709e Add new NativeOptions: vsync multisampling depth_buffer stencil_buffer
These are useful when embedding 3D into eframe.
2022-03-23 11:13:57 +01:00
Emil Ernerfeldt
c63bdeab67
Add an example of showing 3D using three-d (#1407) 2022-03-23 11:06:33 +01:00
Emil Ernerfeldt
85e3ec5027 Log supported OpenGL extensions if VAO is in doubt. 2022-03-23 10:10:12 +01:00
Emil Ernerfeldt
ea9393aa9b
glow painter improvements (#1406)
* Add viewport info to PaintCallback
* glow: be more explicit with more state
* glow: Refactor VAO
2022-03-22 23:11:27 +01:00
Emil Ernerfeldt
6f10e2e725
Improve glow error reporting (#1403)
* Improve glow error reporting
* Add more check_for_gl_error calls
* Remove clippy lint list from egui_glow lib.rs
  - Forgotten in https://github.com/emilk/egui/pull/1394
* egui_glow: move vao code to own file
* Cleanup: `use glow::HasContext as _;`

Co-authored-by: Zachary Kohnen <me@dusterthefirst.com>
2022-03-22 16:04:06 +01:00
Emil Ernerfeldt
41b178b6ec
Use atomic_refcell instead of parking_lot for wasm32 targets (#1404)
Closes https://github.com/emilk/egui/issues/1401
2022-03-22 15:34:21 +01:00
Edgeworth
e5aeb1618f
Export the PlotBounds type. (#1392) 2022-03-22 08:59:13 +01:00
Hunter522
0a400a5bcc
Add Image::rotate and Mesh::rotate (#1371)
Co-authored-by: Hunter Morgan <hmorgan@bellflight.com>
2022-03-22 08:44:23 +01:00
Emil Ernerfeldt
805539b50d
Add example of custom window frame for native window using eframe (#1396) 2022-03-21 22:20:58 +01:00
Emil Ernerfeldt
15254f8235
Remove the single_threaded/multi_threaded feature flags (#1390)
Always use parking_lot for mutexes, i.e. always be multi-threaded.

Closes #1379
2022-03-21 22:20:37 +01:00
Emil Ernerfeldt
5c68edbb15 Clippy fixes 2022-03-21 22:14:25 +01:00
Emil Ernerfeldt
339b28b470 Add Frame::outer_margin, and rename Frame::margin to Frame::inner_margin 2022-03-21 21:44:52 +01:00
Emil Ernerfeldt
fda8189cba
Move lints list to .carg/config.toml (#1394)
That way they apply to all crates equally.

See https://github.com/EmbarkStudios/rust-ecosystem/issues/22 for why.
2022-03-21 16:54:29 +01:00
Emil Ernerfeldt
ccbddcfe95 Add example of how to move text cursor in a TextEdit 2022-03-20 23:08:19 +01:00
Emil Ernerfeldt
fde9c232b3 Improve the introspection paint stats 2022-03-20 23:05:16 +01:00
Emil Ernerfeldt
e369626d3d glow: move where FRAMEBUFFER_SRGB is enabled 2022-03-20 23:04:44 +01:00
Emil Ernerfeldt
d20be45c4c Add egui_assert to ensure texture size is <= max_texture_side 2022-03-20 22:49:44 +01:00
Emil Ernerfeldt
861e129ace Add Shape::image convenience method 2022-03-20 20:39:48 +01:00
jean-airoldie
734d4c57ad
Expose more epaint tessellator methods (#1384)
* Expose more tessellator method

* Make public the Tessellator methods to tessellate a circle, a
    mesh, a rectangle, a line, a path, a quadratic and cubic
    bezier curve.
* Add doc to tessellate_text.
* Add Mesh::append_ref method.

* Make tessellate_text take a reference

* Fix breaking change in benchmark
2022-03-20 20:38:48 +01:00
Zachary Kohnen
8bb381d50b
Fix code that could lead to a possible deadlock. (#1380)
* Fix code that could lead to a possible deadlock.

Drop implementations are not called until the end of a statement. The statement changed in this commit therefore took 4 read locks on a RwLock which can lead to problems if a write lock is requested between any of these read locks. The code looks like it would only hold one lock at a time but it does not drop any of the locks until after the arithmatic operations complete, which leads to this situation. See https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=996079046184329f3a9df1cd19c87da8 to see this in action. The fix is to just take one lock and share it between the three calls to num_presses, letting it drop at the end of the scope.

* Fix code that may cause a deadlock in `MenuRoot::stationary_interaction`

The issue here is related to that in 9673b8f2a08302c10ffcfd063f2dbdec4301d3e2 in that the lock is not dropped when it is expected.  Since the `RwLockReadGuard` produced by `ctx.input()` has a reference taken from it (one into `pointer`), the lock cannot be dropped until that reference is no longre valid, which is the end of the scope (in this case this function).  The following `ctx.input()` then attempts to aquire a second lock on the `RwLock`, creating the same situation that was found in the referenced commit.

This has been resolved by holding one lock on the input for the whole function.

* Reference this PR from comments in the code for future maintainers

* Add the change to the changelog

* Use full link to PR

* Use full link to PR

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2022-03-20 20:30:38 +01:00
Emil Ernerfeldt
465c96122c
egui_web: by default, use full web browser size (#1378)
* egui_web: by default, use full web browser size

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

* Remove max_size_points from demo app
2022-03-19 13:47:30 +01:00
Emil Ernerfeldt
6ce8594351 README.md: add links to license files
Closes https://github.com/emilk/egui/issues/1367
2022-03-19 13:34:08 +01:00
Emil Ernerfeldt
12c31e980b
Add Ui::push_id (#1374) 2022-03-19 13:30:43 +01:00
Emil Ernerfeldt
f6af7bda27 Better error message when trying to upload too large texture
Closes https://github.com/emilk/egui/issues/1370
2022-03-19 13:30:29 +01:00