egui/examples
Emil Ernerfeldt ca8c8792c2
New widget interaction logic (#4026)
* Closes https://github.com/emilk/egui/issues/3936
* Closes https://github.com/emilk/egui/issues/3923
* Closes https://github.com/emilk/egui/pull/4058

The interaction code is now done at the start of the frame, using stored
`WidgetRect`s from the previous frame.

The intention is that the new interaction code should be more accurate,
making it easier to hit widgets, and better respecting the rules of
overlapping widgets.

There is a new `style::Interaction::interact_radius` controlling how far
away from a widget the cursor can be and still hit it. This helps big
fat fingers hit small widgets on touch screens.

This PR adds a new `Context::read_response` which lets you read the
`Response` of a `Widget` _before_ you create the widget. This can be
used for styling, or for reading the result of an interaction early (to
prevent frame-delay) for a widget you add late (so it is on top of other
widgets).

# ⚠️ BREAKING CHANGES
`Memory::dragged_id`, `Memory::set_dragged_id` etc have been moved to
`Context`.
The semantics for `Context::dragged_id` is slightly different: a widget
is not considered dragged until egui it is sure this is not a
click-in-progress. For a widget that is only sensitive to drags, that is
right away, but for widgets sensitive to both clicks and drags it is not
until the mouse has moved a certain distance.

# TODO
* [x] Fix panel resizing
* [x] Fix scroll hover weirdness
* [x] Fix Resize widget
* [x] Fix drag-and-drop
* [x] Test all of egui_demo_app
* [x] Change `is_dragging` API
* [x] Consistent naming of start/stop or begin/end drag
* [x] Test `egui_tiles`
* [x] Test Rerun
* [x] Document
* [x] Document breaking changes in PR description
* [x] Test one final time

# Saving for a later PR
* [ ] Fix https://github.com/emilk/egui/issues/4047
* [ ] Specify what the response order for e.g. `ui.horizontal` is

I think both these can be fixed if each `Ui` registers themselves as a
`WidgetRect`, with the possibility to interact with it later, as if the
interaction was under all widgets on top of it.
2024-02-17 15:48:23 +01:00
..
confirm_exit Put all egui crates as workspace crates (#3976) 2024-02-05 12:59:49 +01:00
custom_3d_glow Put all egui crates as workspace crates (#3976) 2024-02-05 12:59:49 +01:00
custom_font Put all egui crates as workspace crates (#3976) 2024-02-05 12:59:49 +01:00
custom_font_style Put all egui crates as workspace crates (#3976) 2024-02-05 12:59:49 +01:00
custom_plot_manipulation Update example screenshots 2024-02-05 13:01:10 +01:00
custom_window_frame Update example screenshots 2024-02-05 13:01:10 +01:00
file_dialog Update `ehttp` to 0.5 (#4055) 2024-02-16 10:57:54 +01:00
hello_world Revert test code in hello_world example 2024-02-10 18:09:41 +01:00
hello_world_par Put all egui crates as workspace crates (#3976) 2024-02-05 12:59:49 +01:00
hello_world_simple Update example screenshots 2024-02-05 13:01:10 +01:00
images Update example screenshots 2024-02-05 13:01:10 +01:00
keyboard_events Put all egui crates as workspace crates (#3976) 2024-02-05 12:59:49 +01:00
multiple_viewports Put all egui crates as workspace crates (#3976) 2024-02-05 12:59:49 +01:00
puffin_profiler Update example screenshots 2024-02-05 13:01:10 +01:00
save_plot Update `ehttp` to 0.5 (#4055) 2024-02-16 10:57:54 +01:00
screenshot Put all egui crates as workspace crates (#3976) 2024-02-05 12:59:49 +01:00
serial_windows Put all egui crates as workspace crates (#3976) 2024-02-05 12:59:49 +01:00
test_inline_glow_paint Update example screenshots 2024-02-05 13:01:10 +01:00
test_viewports New widget interaction logic (#4026) 2024-02-17 15:48:23 +01:00
user_attention Put all egui crates as workspace crates (#3976) 2024-02-05 12:59:49 +01:00
README.md examples/README.md: explain that the examples are for master 2023-02-08 20:34:43 +01:00
run_all.sh Fix up some examples (#3614) 2023-11-23 12:58:44 +01:00

README.md

egui and eframe examples

All the examples in this folder uses eframe to set up a window for egui. Some examples are specific to eframe, but many are applicable to any egui integration.

There are a lot more examples at https://www.egui.rs, and it has links to the source code of each example.

Also check out the official docs at https://docs.rs/egui and https://docs.rs/eframe.

Note that all the examples on master are for the latest master version of egui.

If you want to look for examples for a specific version of egui, go to that tag, e.g. https://github.com/emilk/egui/tree/latest/examples.