Commit Graph

66 Commits

Author SHA1 Message Date
Emil Ernerfeldt ded8dbd45b
Fix some clippy warning from Rust 1.78.0 (#4444) 2024-05-02 17:04:25 +02:00
Emil Ernerfeldt 2f508d6a61
Replace cargo-cranky with workspace lints (#4413)
Replace `cargo-cranky` (which has served us well) with workspace lints
2024-04-25 17:24:50 +02:00
Emil Ernerfeldt 87b294534e
Add `emath::OrderedFloat` (moved from `epaint::util::OrderedFloat`) (#4389)
It makes much more sense in `emath`
2024-04-21 20:36:32 +02:00
Narcha 26c97a19a4
Expose `ClosestElem` and `PlotConfig` (#4380)
These two items are needed to implement the `PlotItem` trait (which is
already public) when using `PlotGeometry::Rects`.
Specifically, they are used in the return type of
`PlotItem::find_closest` and as arguments to `PlotItem::on_hover`, which
need to be implemented when using `PlotGeometry::Rects`.
2024-04-21 11:05:53 +02:00
Emil Ernerfeldt 15b0ef3259 Release 0.27.2 - Fix blurry web rendering 2024-04-02 18:18:43 +02:00
Emil Ernerfeldt 36ebce163a
egui_plots: Fix the same plot tick label being painted multiple times (#4307)
Usually this isn't visible (the same label being painted on top of
itself), but it will be visible if the user has a custom formatter (e.g.
`y_axis_formatter`) that choses a different format based on
`GridMark:step_size` (e.g. using fewer decimals for thicker ticks).
2024-04-02 15:37:44 +02:00
Emil Ernerfeldt aa2f87e0ff
Allow zoom/pan a plot as long as it contains the mouse cursor (#4292)
This is a fix meant mostly for Rerun, where we sometiems paint a
vertical time-line over the plot (which is interactive). Before this PR
you couldn't zoom or pan the plot while hovering that line, which was
really annoying.
2024-03-31 20:20:46 +02:00
Emil Ernerfeldt dfbe118ea4
Release 0.27.1 (#4264)
## egui changelog
### 🐛 Fixed
* Fix visual glitch on the right side of highly rounded rectangles
[#4244](https://github.com/emilk/egui/pull/4244)
* Prevent visual glitch when shadow blur width is very high
[#4245](https://github.com/emilk/egui/pull/4245)
* Fix `InputState::any_touches` and add `InputState::has_touch_screen`
[#4247](https://github.com/emilk/egui/pull/4247)
* Fix `Context::repaint_causes` returning no causes
[#4248](https://github.com/emilk/egui/pull/4248)
* Fix touch-and-hold to open context menu
[#4249](https://github.com/emilk/egui/pull/4249)
* Hide shortcut text on zoom buttons if `zoom_with_keyboard` is false
[#4262](https://github.com/emilk/egui/pull/4262)

### 🔧 Changed
* Don't apply a clip rect to the contents of an `Area` or `Window`
[#4258](https://github.com/emilk/egui/pull/4258)


## eframe changelog
* Web: repaint if the `#hash` in the URL changes
[#4261](https://github.com/emilk/egui/pull/4261)
* Add web support for `zoom_factor`
[#4260](https://github.com/emilk/egui/pull/4260) (thanks
[@justusdieckmann](https://github.com/justusdieckmann)!)

---------

Co-authored-by: Justus Dieckmann <45795270+justusdieckmann@users.noreply.github.com>
2024-03-29 13:12:26 +01:00
YgorSouza c4f16af721
Prevent plot from resetting one axis while zooming/dragging the other (#4252)
* Closes <https://github.com/emilk/egui/issues/4251>
2024-03-28 10:43:28 +01:00
Nicolas PASCAL 9fa8aa7e30
`Plot::Items:allow_hover` give possibility to masked the interaction on hovered item (#2558)
This is particularly interesting if you want to authorize a single hover
tooltip on an item in the event of an interaction.

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2024-03-27 16:35:36 +01:00
Emil Ernerfeldt 4d4cb3d20d Release 0.27.0 - Nicer menus and new hit test logic 2024-03-26 17:13:57 +01:00
Emil Ernerfeldt f8d7d0ebaa
Enforce writing username in TODO comments (#4235) 2024-03-26 11:48:24 +01:00
dwuertz 0299663cdd
Expose `PlotGeometry` in public API (#4193)
Expose `egui_plot::items::values::PlotGeometry` in public API so that
`PlotItem`, which is already public, can actually be implemented by
applications. Fixes #3464.

---------

Co-authored-by: Dominique Würtz <dom@blaukraut.info>
2024-03-21 12:27:18 +01:00
Antoine Beyeler 74891cac2f
egui_plot: fix panic when the base step size is set to 0 (#4078)
This can happen e.g. when the user forces some axis range to (0.0, 0.0)
like in rerun-io/rerun#5239
2024-02-20 16:26:47 +01:00
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
YgorSouza 34e8af87d4
Plot widget - allow disabling scroll for x and y separately (#4051)
To be consistent with the zoom and drag options that were added earlier.
2024-02-16 09:23:08 +01:00
Dunfan Lu 62e80c7729
`egui_plot`: Add `sense` option to `Plot` (#4052)
This PR adds a `sense` option to `Plot`.
2024-02-16 09:19:03 +01:00
Emil Ernerfeldt 3672b150ed Release 0.26.2 - Response.interact/context_menu fix 2024-02-14 10:49:57 +01:00
Emil Ernerfeldt d22ee81ab0 Release 0.26.1 - Bug Fixes 2024-02-11 09:03:09 +01:00
Emil Ernerfeldt 56bf8b79f3 Release 0.26.0 - Text selection in labels 2024-02-05 17:28:10 +01:00
Emil Ernerfeldt d02491425c
Put all egui crates as workspace crates (#3976)
Second attempty
2024-02-05 12:59:49 +01:00
Emil Ernerfeldt bcebfecb84
Use more workspace dependencies (#3975) 2024-02-05 12:43:58 +01:00
YgorSouza 1636b6af08
Fix clip rect for plot items (#3955)
Closes <https://github.com/emilk/egui/issues/3865>.
2024-02-05 08:24:49 +01:00
Emil Ernerfeldt 60e272f192
Make `egui_plot::PlotItem` a public trait (#3943) 2024-02-02 14:38:35 +01:00
Emil Ernerfeldt 8f2c8664e7
Emilk/revert workspace deps (#3942)
* Closes https://github.com/emilk/egui/issues/3941

Workspace dependencies can be annoying.

If you don't set them to `default-features=false`, then you cannot opt
out of their default features anywhere else, and get warnings if you
try.

So you set `default-features=false`, and then you need to manually opt
in to the default features everywhere else.
Or, as in my case, don't.

I don't have the energy to do this tonight, so I'll just revert.
2024-02-01 21:29:48 +01:00
Emil Ernerfeldt 00cd671ad8 Use workspace dependencies for the egui crates 2024-02-01 20:25:31 +01:00
Emil Ernerfeldt dda9f79838 Remove `version` field for path-dependencies 2024-02-01 20:11:40 +01:00
Emil Ernerfeldt 67b796faee
Misc cleanup (#3935)
* Improve docstring
* Nicer welcome gif in README
* Misc cleanup
2024-02-01 17:09:35 +01:00
Andreas Reich ca513ce241
Plot items now have optional id which is returned in the plot's response when hovered (#3920)
This allows users to check which item the user interacts with in the
plot.



https://github.com/emilk/egui/assets/1220815/1a174b38-8414-49be-a802-d187cd93d154

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2024-01-30 15:55:56 +01:00
Emil Ernerfeldt 527f4bfdf6
Expand plot axes thickness to fit their labels (#3921)
Expand the plot axis thickness as the contained plot axis labels get
wider.

This fixes a problem where the plot labels would otherwise get clipped.


![plot-axis-expansion](https://github.com/emilk/egui/assets/1148717/4500a26e-4a11-401d-9e8e-2d98d02ef3b7)
2024-01-30 12:45:27 +01:00
Emil Ernerfeldt 8562150e33
Change default plot line thickness from 1.0 to 1.5 (#3918) 2024-01-29 19:23:27 +01:00
Emil Ernerfeldt 5d0bc2bf7d
egui_plot: customizable spacing of grid and axis label spacing (#3896)
This lets users specify the spacing of the grid lines and the axis
labels, as well as when these start to fade out.

New:
* `AxisHints::new_x/new_y` (replaces `::default()`)
* `AxisHints::label_spacing`
* `Plot::grid_spacing`
2024-01-26 13:36:49 +01:00
Emil Ernerfeldt 5388e65623
Smooth scrolling (#3884)
This adds smooth scrolling in egui. This makes scrolling in a
`ScrollArea` using a notched mouse wheel a lot nicer.

`InputState::scroll_delta` has been replaced by
`InputState::raw_scroll_delta` and `InputState::smooth_scroll_delta`.
2024-01-24 16:40:20 +01:00
Emil Ernerfeldt 2f9a4ca6e8
Make `egui_plot::PlotMemory` public (#3871)
This allows users to e.g. read/write the plot bounds/transform before
and after showing a `Plot`.
2024-01-23 09:47:47 +01:00
Emil Ernerfeldt 31cc31a67b
Add `Align2::anchor_size` (#3863) 2024-01-22 16:47:50 +01:00
Emil Ernerfeldt 401de05630
Use `Self` everywhere (#3787)
This turns on the clippy lint
[`clippy::use_self`](https://rust-lang.github.io/rust-clippy/v0.0.212/index.html#use_self)
and fixes it everywhere.
2024-01-08 17:41:21 +01:00
Emil Ernerfeldt 12ad9e7b36 Release 0.25.0 - Better keyboard input 2024-01-08 12:25:43 +01:00
Emil Ernerfeldt 8c30e8c5f7
Highlight submenu buttons when hovered and open (#3780)
Submenu buttons in menues now properly highlight when hovered and when
opened.

…plus a bunch of other cleanup
2024-01-07 22:08:32 +01:00
jayzhudev e13cc69d76
Add a public API for overriding plot legend traces' visibilities (#3534)
Added a public API in `egui_plot -> legend` to allow `hidden_items` to
be overridden in the plot legend widget. This allows convenient control
of traces' visibilities the selection of traces from the application
code.

### Example
```rust
    let legend_config = if plot_selection_changed {
        let hidden_items = match plot_selection {
            PlotSelection::SelectAll => Vec::new(),
            PlotSelection::DeselectAll => all_trace_names,
        };

        Legend::default()
            .position(Corner::RightTop)
            .hidden_items(hidden_items) // Overrides `hidden_items`
    } else {
        Legend::default().position(Corner::RightTop)
    };

    Plot::new(id)
        .legend(legend_config)
        .show(ui, draw_plot);
```

Closes <https://github.com/emilk/egui/issues/3533>.

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2024-01-06 22:35:54 +01:00
YgorSouza 5ed2c0aa90
Plot custom zoom (#2714)
<!--
Please read the "Making a PR" section of
[`CONTRIBUTING.md`](https://github.com/emilk/egui/blob/master/CONTRIBUTING.md)
before opening a Pull Request!

* Keep your PR:s small and focused.
* If applicable, add a screenshot or gif.
* Unless this is a trivial change, add a line to the relevant
`CHANGELOG.md` under "Unreleased".
* If it is a non-trivial addition, consider adding a demo for it to
`egui_demo_lib`.
* Remember to run `cargo fmt` and `cargo clippy`.
* Open the PR as a draft until you have self-reviewed it and run
`./sh/check.sh`.
* When you have addressed a PR comment, mark it as resolved.

Please be patient! I will review you PR, but my time is limited!
-->

- Added methods to zoom the plot programmatically, to match the
previously added `translate_bounds()`.
- Added an example of how this method can be used to customize the plot
navigation.

Closes #1164.
2024-01-06 22:34:42 +01:00
Emil Ernerfeldt 34c341444f
Release `egui_plot` 0.24.2 (#3763)
## Changelog
* Fix plot auto-bounds default
[#3722](https://github.com/emilk/egui/pull/3722) (thanks
[@abey79](https://github.com/abey79)!)

---------

Co-authored-by: Antoine Beyeler <49431240+abey79@users.noreply.github.com>
2024-01-03 09:42:56 +01:00
Emil Ernerfeldt 0561fcaba9
Replace a special `Color32::PLACEHOLDER` with widget fallback color (#3727)
This introduces a special `Color32::PLACEHOLDER` which, during text
painting, will be replaced with `TextShape::fallback_color`.

The fallback color is mandatory to set in all text painting. Usually
this comes from the current visual style.

This lets users color only parts of a `WidgetText` (using e.g. a
`LayoutJob` or a `Galley`), where the uncolored parts (using
`Color32::PLACEHOLDER`) will be replaced by a default widget color (e.g.
blue for a hyperlink).

For instance, you can color the `⚠️`-emoji red in a piece of text red
and leave the rest of the text uncolored. The color of the rest of the
text will then depend on wether or not you put that text in a label, a
button, or a hyperlink.

Overall this simplifies a lot of complexity in the code but comes with a
few breaking changes:

* `TextShape::new`, `Shape::galley`, and `Painter::galley` now take a
fallback color by argument
* `Shape::galley_with_color` has been deprecated (use `Shape::galley`
instead)
* `Painter::galley_with_color` has been deprecated (use
`Painter::galley` instead)
* `WidgetTextGalley` is gone (use `Arc<Galley>` instead)
* `WidgetTextJob` is gone (use `LayoutJob` instead)
* `RichText::into_text_job` has been replaced with
`RichText::into_layout_job`
* `WidgetText::into_text_job` has been replaced with
`WidgetText::into_layout_job`
2023-12-22 15:09:10 +01:00
Emil Ernerfeldt e36b981118
Add @Bromeon and @EmbersArc as CODEOWNERS for egui_plot (#3711)
Please take a look @Bromeon and @EmbersArc!

You have both contributed substantially to `egui_plot` (more than I
have).
This is me inviting you to co-maintain the `egui_plot` crate.
If you accept, you'll get a notification when someone opens a PR
touching `egui_plot`, and you can review and merge it as you see fit.
You can also merge your own egui_plot PRs without waiting on me to
review them.
2023-12-21 09:08:16 +01:00
Antoine Beyeler add1695624
Fix plot auto-bounds unset by default (#3722)
These PR recently cleaned up the code around auto-bounds, but introduced
an involuntary change whereby auto-bounds would not be enabled by
default. All plots would default to being not properly centred as a
result.

- #3587
- #3586

This PR changes the default back to enabled. It also deprecates
`auto_bounds_x()` and `auto_bounds_y()`, which could only enable
auto-bounds (which is not very useful as auto-bounds were, and now are
again, enabled by default). A new `auto_bounds()` API can now be sued to
disable auto-bounds if needed.

Fixes #3712 
Fixes https://github.com/rerun-io/rerun/issues/4503
2023-12-19 17:58:59 +01:00
Emil Ernerfeldt 8d4de866d4
Remove deprecated functions (#3692) 2023-12-08 11:02:57 +01:00
Emil Ernerfeldt d17613c242 Release 0.24.1 - Bug fixes 2023-11-30 17:46:25 +01:00
Emil Ernerfeldt bd087ffb8d Release 0.24.0 - Multi-viewport 2023-11-23 15:56:46 +01:00
Emil Ernerfeldt e7604c0230 Update changelogs 2023-11-23 15:46:04 +01:00
Emil Ernerfeldt 96bc34a66d Use workspace definitions of edition,license,rust-version,version 2023-11-23 15:45:11 +01:00
Emil Ernerfeldt bfadb90d42
Update MSRV to Rust 1.72 (#3595)
Required to update to puffin 0.18
2023-11-21 17:26:35 +01:00