Commit Graph

1005 Commits

Author SHA1 Message Date
Emil Ernerfeldt 6a3e7d17ac Use parking_lot for wrapping TextureManager 2022-03-21 16:37:07 +01:00
Emil Ernerfeldt 079490b30d Make Context::load_texture thread safe 2022-03-21 16:37:07 +01:00
Emil Ernerfeldt 72d264ed6c Make Context::request_repaint safe to call from any thread.
Closes https://github.com/emilk/egui/issues/1379
2022-03-21 16:37:07 +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 d20be45c4c Add egui_assert to ensure texture size is <= max_texture_side 2022-03-20 22:49:44 +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 9673b8f2a0 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 12c31e980b Add Ui::push_id (#1374) 2022-03-19 13:30:43 +01:00
zam-5 cecb48af03 Added plot_ui::plot_clicked() (#1372) 2022-03-19 13:00:18 +01:00
Emil Ernerfeldt c8f6cae362 eframe app creation refactor (#1363)
* Change how eframe apps are created
* eframe: re-export epi::* so users don't need to care about what epi is
2022-03-16 15:39:48 +01:00
Emil Ernerfeldt c768d1d48e Context::request_repaint will wake up the UI thread (#1366)
This adds a callback (set by `Context::set_request_repaint_callback`)
which integration can use to wake up the UI thread.

eframe (egui_web and egui_glow) will use this, replacing
`epi::Frame::request_repaint`.

Existing code calling `epi::Frame::request_repaint` should be changed
to instead call `egui::Context::request_repaint`.

This is the first callback added to the egui API, which otherwise is
completely driven by data.

The purpose of this is to remove the confusion between the two
`request_repaint` methods (by removing one). Furthermore, it makes
`epi::Frame` a lot simpler, allowing future simplifications to it
(perhaps no longer having it be `Send+Sync+Clone`).
2022-03-15 17:21:52 +01:00
Emil Ernerfeldt 6aee4997d4 Add Shape::Callback to do custom rendering inside of an egui UI (#1351)
* Add Shape::Callback to do custom rendering inside of an egui UI
* Use Rc<glow::Context> everywhere
* Remove trait WebPainter
* Add glow::Context to epi::App::setup
2022-03-14 13:25:11 +01:00
Emil Ernerfeldt 002158050b Add Frame::canvas - bright in bright mode, dark in dark mode (#1362)
and use it in the demo app
2022-03-14 12:33:17 +01:00
Emil Ernerfeldt 510cef02ca Run a formatter on all toml files 2022-03-10 14:25:33 +01:00
Simon Gardling c19a7ff34f remove unnecessary to_string in docs (#1345) 2022-03-10 08:23:00 +01:00
Zachary Kohnen 5d950e1c15 [egui_web] Prevent event handlers from running if code has panicked (#1306)
Closes: #1290

Fix panic reported by @Titaniumtown
See https://github.com/emilk/egui/pull/1306#issuecomment-1060775376
2022-03-10 08:13:32 +01:00
Simon Gardling 0e7a4fdbfd Add method to set a Plot's margin (#1308) 2022-03-08 15:50:53 +01:00
Juan Campa e3d1fa22d1 Fix combo box misalignment on rtl layout (#1304) 2022-03-07 10:48:12 +01:00
Emil Ernerfeldt a05520b9d3 Release 0.17.0 - Improved font selection and image handling 2022-02-22 19:32:30 +01:00
Emil Ernerfeldt 31d324932c Introduce egui::FullOutput, returned from Context::run (#1292)
* Introduce `egui::FullOutput`, returned from `Context::run`
* Rename `Output` to `PlatformOutput`
2022-02-22 17:13:53 +01:00
Emil Ernerfeldt 745f209c61 Make RawInput.max_texture_side an Option 2022-02-22 13:21:28 +01:00
Emil Ernerfeldt fd3fb726c1 Fix bugs in consume_key and improve Modifiers API
Improvements and fixes following https://github.com/emilk/egui/pull/1212
2022-02-21 16:53:41 +01:00
Emil Ernerfeldt c3fc8997d6 Introduce egui_extras with RetainedImage for loading svg,png,jpeg,… (#1282) 2022-02-21 15:26:26 +01:00
Emil Ernerfeldt 89d19860b8 Misc code cleanup, docs fixes, etc 2022-02-19 20:58:28 +01:00
Emil Ernerfeldt b8fbbf7d62 Fix anti-aliasing of filled paths with counter-clockwise winding order
Part of https://github.com/emilk/egui/issues/1226
2022-02-19 20:46:44 +01:00
Emil Ernerfeldt aa53522179 Slider event fixes (#1270)
* Slider: return drag_started,dragged,drag_released if value was dragged

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

* Fix: DragValue correctly reports gained_focus

* Make `Slider` report gained_focus,has_focus,lost_focus from DragValue

Closes https://github.com/emilk/egui/issues/1268
2022-02-19 19:56:12 +01:00
Emil Ernerfeldt 3ed68274b0 Make Slider report gained_focus,has_focus,lost_focus from DragValue
Closes https://github.com/emilk/egui/issues/1268
2022-02-19 11:12:09 +01:00
Emil Ernerfeldt 0d21405855 Fix: DragValue correctly reports gained_focus 2022-02-19 11:05:02 +01:00
Emil Ernerfeldt 989a6d202f Slider: return drag_started,dragged,drag_released if value was dragged
Closes https://github.com/emilk/egui/issues/1269
2022-02-19 10:58:07 +01:00
Benedikt Terhechte 8e62b382fd Add some macOS emacs keybindings (#1243)
Move cursor left: ^B
    Move cursor right: ^F
    Beginning of line: ^A
    End of line: ^E
    Line up: ^P
    Line down: ^N
2022-02-19 10:42:43 +01:00
Emil Ernerfeldt 3d754e3a16 Prevent ScrollArea:s from becoming tiny (#1255)
Closes https://github.com/emilk/egui/issues/1097
2022-02-17 17:08:05 +01:00
Emil Ernerfeldt 4e316d32e5 Fix scroll_to with align
Broke in https://github.com/emilk/egui/pull/1252
2022-02-17 16:45:42 +01:00
Emil Ernerfeldt 4af3cae26d Scroll so that text cursor remains visible (#1252)
Closes https://github.com/emilk/egui/issues/165
2022-02-16 21:34:47 +01:00
cat-state c1569ed0d7 Add Ui.input_mut & InputState.ignore_key (#1212) 2022-02-15 17:14:24 +01:00
Friz64 c8c871fcd1 Add move_to_top and top_most_layer (#1242) 2022-02-15 17:13:08 +01:00
Sven Niederberger 8f8eb5d4a9 Customize Plot label and cursor texts (#1235)
Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2022-02-15 17:12:29 +01:00
BctfN0HUK7Yg cfad28936d Color picker now always pops up next to the button (#1237) 2022-02-15 16:55:43 +01:00
Juan Campa 635c65773d Allow scroll into view without specifying an alignment (#1247)
* Allow scroll into view without specifying an alignment
* Handle case of UI being too big to fit in the scroll view
2022-02-15 16:52:29 +01:00
Alexander 62504fface Slider: Add step parameter (#1225)
Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
2022-02-13 21:55:51 +01:00
Juan Campa c4528beb72 Make non interactable layers not interact (#1240)
* Make non interactable layers not interact
* Make menus interactable
* Fix area interactable not being updated each frame
2022-02-13 21:09:25 +01:00
4JX 14e985a894 Expose FontTweak through egui::FontTweak (#1244) 2022-02-13 10:10:39 +01:00
Emil Ernerfeldt 3f8ba3a542 Improve the contrast of the default light mode style (#1238)
Makes backgrounds brighter and foregrounds darker.
2022-02-11 13:58:50 +01:00
4JX 2f042ababd Make Margin pub and move to style.rs (#1236) 2022-02-10 15:26:57 +01:00
Emil Ernerfeldt 4cede42748 Add ui.weak(text) 2022-02-09 15:08:01 +01:00
Emil Ernerfeldt defc400c21 Add an example of how to display an SVG image in egui (#1228) 2022-02-09 08:12:12 +01:00
Erlend Walstad 2802e03526 Per-side margins with new struct Margin (#1219) 2022-02-07 11:29:16 +01:00
4JX c9098288f5 Fix a typo: tolerence -> tolerance (#1214) 2022-02-06 16:30:34 +01:00
Emil Ernerfeldt 5459ab29b7 Fix: allow calling set_pixels_per_point before first frame
Closes https://github.com/emilk/egui/issues/1153
2022-02-06 00:16:59 +01:00
Manuel Innerhofer 7d41551913 Fixed typos: wether -> whether (#1210)
Co-authored-by: mir <mir@wisdomtag.com>
2022-02-05 18:14:16 +01:00
Emil Ernerfeldt 9ed96155e9 Rename corner_radius to rounding
Also update changelogs and clean up other aspects of
https://github.com/emilk/egui/pull/1206
2022-02-05 18:13:46 +01:00