Commit Graph
100 Commits
Author SHA1 Message Date
Emil Ernerfeldt 04c3efd01a Minor optimization: avoid reallocating set of visible ID:s 2022-01-26 14:44:10 +01:00
Emil Ernerfeldt 417bb3123a Fonts: only pre-render glyphs for fonts in the current egui styles 2022-01-26 14:42:44 +01:00
Emil Ernerfeldt 1e4d8ae943 Remove warm-up of demo app
Since https://github.com/emilk/egui/pull/1149 we only update the
region of the font atlas that has changes, so loading new glyphs is much
cheaper. This means warm-up is much less needed.

There is now a small delay when opening the font book,
but not when opening anything else.
2022-01-25 01:08:10 +01:00
Emil Ernerfeldt 7ed0880b8f Lower default font atlas size (#1160)
In https://github.com/emilk/egui/pull/1154 the default was set to
16k x 512, which is way excessive, as most of it will be blank.

This PR changes it to 8k x 64, which will make egui
use less RAM and VRAM, and load quicker again.

This also decreases the max size from 16k² to 8k².
That should be enough.
2022-01-25 01:04:28 +01:00
Emil Ernerfeldt fa43d16c41 Choose your own font and size (#1154)
* Refactor text layout: don't need &Fonts in all functions
* Replace indexing in Fonts with member function
* Wrap Fonts in a Mutex
* Remove mutex for Font::glyph_info_cache
* Remove RwLock around Font::characters
* Put FontsImpl and GalleyCache behind the same Mutex
* Round font sizes to whole pixels before deduplicating them
* Make TextStyle !Copy
* Implement user-named TextStyle:s
* round font size earlier
* Cache fonts based on family and size
* Move TextStyle into egui and Style
* Remove body_text_style
* Query graphics about max texture size and use that as font atlas size
* Recreate texture atlas when it is getting full
2022-01-24 14:32:36 +01:00
Emil Ernerfeldt bb407e9b00 Plot text can now contain rich text 2022-01-23 12:01:34 +01:00
Emil Ernerfeldt 462f181db3 Partial font texture update (#1149) 2022-01-22 11:23:12 +01:00
Emil Ernerfeldt e957674467 glow on web: simplify the webgl2 vs webgl1 selection 2022-01-22 09:07:41 +01:00
Emil Ernerfeldt 199bbef77b Add misc documentation 2022-01-22 09:07:41 +01:00
Emil Ernerfeldt 8138a073e7 glow: reuse the same GL texture when possible (#1142) 2022-01-21 19:51:52 +01:00
Emil Ernerfeldt a689b623a6 Make shift-scroll do horizontal scrolling on all platforms (#1136)
Closes https://github.com/emilk/egui/issues/1135
2022-01-21 10:48:44 +01:00
Emil Ernerfeldt 76ac41f9b5 WidgetGallery: hide spinner widget to save CPU in reactive mode 2022-01-17 19:57:32 +01:00
Emil Ernerfeldt 9df0c68a38 Small improvements to check.sh 2022-01-17 19:57:32 +01:00
Emil Ernerfeldt 39dd6d7644 clippy fixes 2022-01-17 19:57:32 +01:00
Emil Ernerfeldt c713fd98dd Fix horizontal scrolling direction on Linux
Closes https://github.com/emilk/egui/issues/356

Work-around until https://github.com/rust-windowing/winit/pull/2105 is merged and released
2022-01-16 09:49:22 +01:00
Emil Ernerfeldt ad5418777d Fix dead-lock in TextEdit on touch-screens (#1118)
Introduced in https://github.com/emilk/egui/pull/1035

Fixes https://github.com/emilk/egui/issues/1116
2022-01-15 22:40:53 +01:00
Emil Ernerfeldt b2c8cd0867 Simplify http demo and add new download_image eframe demo 2022-01-15 20:34:03 +01:00
Emil Ernerfeldt 66d80e2519 Texture loading in egui (#1110)
* Move texture allocation into epaint/egui proper
* Add TextureHandle
* egui_glow: cast using bytemuck instead of unsafe code
* Optimize glium painter
* Optimize WebGL
* Add example of loading an image from file
2022-01-15 13:59:52 +01:00
Emil Ernerfeldt 205e04aa18 Fix bugs in glow on web (#1092)
* Re-add check of WEBGL_debug_renderer_info to avoid OpenGL error

I removed this check in https://github.com/emilk/egui/pull/1020
because it produced a warning on Firefox. Better a warning
than an OpenGL error though.

* Bug fix: don't ask for webgl context and then later for webgl2 context

The browser will only allow the first thing we check, so this will
prevent webgl2 from working.
2022-01-10 23:19:30 +01:00
Emil ErnerfeldtandDaniel Keller d5673412dd Put everything in Context behind the same Mutex (#1050)
* Move all interior mutability from Context to CtxRef and make it a handle
* Rename `CtxRef` to `Context`
* The old `Context` is now `ContextImpl` and is non-pub
* Add benchmark Painter::rect

Co-authored-by: Daniel Keller <dklr433@gmail.com>
2022-01-10 23:13:10 +01:00
Emil Ernerfeldt 650057dd4a Improve OpenGL error detection and reporting in egui_glow
May help to diagnose https://github.com/emilk/egui/issues/1087
2022-01-09 23:04:00 +01:00
Emil Ernerfeldt 342737e2f0 Improve a couple of docstrings 2022-01-08 11:15:15 +01:00
Emil Ernerfeldt 1f93c7b0b6 Implement Clone & PartialEq on RichText WidgetTextJob WidgetTextGalley 2022-01-07 15:22:21 +01:00
Emil Ernerfeldt 7863f44111 Add demo of advanced TextEdit usage 2022-01-06 11:53:23 +01:00
Emil Ernerfeldt 79cfdaa1f9 Better docs and spelling fixes 2022-01-03 23:58:06 +01:00
Emil Ernerfeldt b1fd6a44e8 Switch to using glow as the default renderer both on native and the web (#1020)
* Switch to using glow as the default renderer both on native and the web
* Simplify code to find WebGL context for glow
* egui_web: make webgl an opt-in feature
* Stop using deprecated WEBGL_debug_renderer_info
2021-12-31 15:17:55 +01:00
Emil Ernerfeldt b5c119ef19 0.16.1 patch release: Add back CtxRef::begin_frame/end_frame (#1019)
`begin_frame`, `end_frame` is more convenient when using egui in a game engine. In particular, 0.16.0 was incompatible with https://github.com/mvlabat/bevy_egui>.
2021-12-31 11:45:57 +01:00
Emil Ernerfeldt b00edfe97f Remove keyboard focus from a widget if something else is dragged
Closes https://github.com/emilk/egui/issues/618
2021-12-30 23:24:29 +01:00
Emil Ernerfeldt 753d709d3d Hide console on windows for all examples in release builds (#1008) 2021-12-30 22:43:53 +01:00
Emil Ernerfeldt 4ef21380a2 Add Ui::add_visible and Ui::add_visible_ui
Also rename `Ui::visible` to `Ui::is_visible`.
2021-12-30 22:39:41 +01:00
Emil Ernerfeldt db110b1690 Remove deprecated functions 2021-12-30 22:37:58 +01:00
Emil Ernerfeldt 0960f38552 Add inter-linking between different forms of documentations and examples 2021-12-29 21:44:48 +01:00
Emil Ernerfeldt f779e8a346 Add an eframe example of how to install a custom font 2021-12-29 21:43:37 +01:00
Emil Ernerfeldt 0146c7e7fc Release 0.16.0 - Context menus and rich text 2021-12-29 12:07:05 +01:00
Emil Ernerfeldt 77869c21ea Publish new web demo 2021-12-29 12:06:25 +01:00
Emil Ernerfeldt 037ca5f9cd update tts 0.17 -> 0.19 2021-12-29 10:56:16 +01:00
Emil Ernerfeldt ffd28252ab cargo update 2021-12-29 10:49:40 +01:00
Emil Ernerfeldt 84399cde83 Small tweaks to documentation and demo 2021-12-29 10:49:22 +01:00
Emil Ernerfeldt d0a47bf8e8 setup_web.sh: don't force-install wasm-bindgen-cli 2021-12-28 21:30:36 +01:00
Emil Ernerfeldt 190c85a40f Rename Texture to FontImage 2021-12-28 21:19:24 +01:00
Emil Ernerfeldt d775eb3733 Fix wrong label on the feature request PR template 2021-12-28 17:34:27 +01:00
Emil Ernerfeldt 68fca09df9 Improve documentation 2021-12-28 17:34:27 +01:00
Emil Ernerfeldt 00f965de87 Add Context::animate_bool_with_time
Closes https://github.com/emilk/egui/discussions/984
2021-12-28 17:34:27 +01:00
Emil Ernerfeldt 5b9a349c26 Clean up glow painter destroy code 2021-12-28 14:24:59 +01:00
Emil Ernerfeldt beb2ea2ef6 Add favicon.ico - a single "e" for "egui", using the Ubuntu-Light font 2021-12-28 14:14:49 +01:00
Emil Ernerfeldt c412fd4a9c Add loading animation while waiting for wasm to load
Closes https://github.com/emilk/egui/issues/1009
2021-12-28 14:13:51 +01:00
Emil Ernerfeldt cda4c8ba13 Minor cleanup following https://github.com/emilk/egui/pull/999 2021-12-28 13:22:01 +01:00
Emil Ernerfeldt f919b0cc05 Clean up context menu documentation 2021-12-28 13:09:14 +01:00
Emil Ernerfeldt 369ce95bbd Add CollapsingHeader::open to control if it is open or collapsed (#1006)
Closes https://github.com/emilk/egui/issues/978
2021-12-28 10:45:32 +01:00
Emil Ernerfeldt 2684929a5d Make Memory::lock_focus public
closes https://github.com/emilk/egui/issues/993
2021-12-28 10:08:28 +01:00
Emil Ernerfeldt c63996179b README.md: add link to discussion of begin/end calls vs closures 2021-12-28 10:05:19 +01:00
Emil Ernerfeldt b88bec9ca3 Document that CtxRef is generational and shouldn't be stored
Related to https://github.com/emilk/egui/issues/1005
2021-12-28 10:05:10 +01:00
Emil Ernerfeldt b7441eeee7 Make epi::Frame cloneable so you can allocate textures in other threads (#999)
Closes https://github.com/emilk/egui/issues/673

Also adds `epi::Image`
2021-12-26 21:21:28 +01:00
Emil Ernerfeldt 647e020824 file_dialogs example: remove macos exemption
this got fixed in the latest winit upgrade
2021-12-26 18:13:29 +01:00
Emil Ernerfeldt d5efa4bbca 1.56 fix: missing_crate_level_docs -> rusdoc::missing_crate_level_docs 2021-12-26 09:56:14 +01:00
Emil Ernerfeldt c60d17b91b Set MSRV to 1.56.0 and use rust edition 2021 (#998) 2021-12-25 19:32:25 +01:00
Emil Ernerfeldt ee00214511 Add a badge and link to the official discord server
Closes https://github.com/emilk/egui/pull/990
2021-12-25 16:56:24 +01:00
Emil Ernerfeldt c85eca6eaa Update changelog 2021-11-29 18:43:52 +01:00
Emil Ernerfeldt 5fee6b7bc5 Anti-alias path ends (#893)
Closes https://github.com/emilk/egui/issues/876
2021-11-14 17:23:51 +01:00
Emil Ernerfeldt a0b635dc21 Add Button::image_and_text to changelog
following https://github.com/emilk/egui/pull/832
2021-11-13 13:19:13 +01:00
Emil Ernerfeldt 8896243146 Fix egui_web integration link in demo app 2021-11-13 13:14:39 +01:00
Emil Ernerfeldt 89700dfbbb Improve egui_glow debug prints 2021-11-13 13:14:10 +01:00
Emil Ernerfeldt 105cb57050 Clean up glsl code 2021-11-13 13:09:08 +01:00
Emil Ernerfeldt b5cb2b2c0d Some code cleanup following https://github.com/emilk/egui/pull/888 2021-11-13 12:55:48 +01:00
Emil Ernerfeldt 4d4c75c6f1 Fix vertical slider up/down keys and add a line in the changelog
Follow-up to https://github.com/emilk/egui/pull/875
2021-11-13 12:30:13 +01:00
Emil Ernerfeldt 6018c0e194 Area: automatically request a repaint when showing up for the first time (#866) 2021-11-07 21:14:13 +01:00
Emil Ernerfeldt 951ee4e142 Improve color picker cache (#886)
* colorpicker: try to maintain hue even when saturation goes to zero
* More consistent arguments to color types
* implement `Hash` for `Rgba`.
2021-11-07 21:11:42 +01:00
Emil Ernerfeldt ddd5f6f4f6 winit: don't explicitly handle Cmd-Q and Alt-F4 (#881)
Closes https://github.com/emilk/egui/issues/877

Still a problem: https://github.com/rust-windowing/winit/issues/1998
2021-11-07 20:58:02 +01:00
Emil Ernerfeldt 19d24bbebe Don't clip popups to the parent cliprect (#885)
Closes https://github.com/emilk/egui/issues/825
2021-11-07 19:48:38 +01:00
Emil Ernerfeldt 878eddd546 When using a custom font you can now specify a font index (#873)
When using a custom font you can now specify a font index

Closes https://github.com/emilk/egui/issues/853
2021-11-07 19:47:52 +01:00
Emil Ernerfeldt 83e490fb6a Remove egui::math & egui::paint, replace with egui::emath & egui::epaint 2021-11-06 09:47:23 +01:00
Emil Ernerfeldt 0ab93576da Remove references to the old begin_frame 2021-11-03 23:00:00 +01:00
Emil Ernerfeldt 6d33beabb1 Replace scroll_delta and zoom_delta in RawInput with events
Part of https://github.com/emilk/egui/issues/843
2021-11-03 22:57:13 +01:00
Emil Ernerfeldt 49e43885ff Replace Context::begin_frame/end_frame with fn run taking a closure (#872)
* Replace Context begin_frame/end_frame with `fn run` taking a closure
* Create `egui::__run_test_ui` to replace `Ui::__test`
* Add helper `egui::__run_test_ctx` for doctests
2021-11-03 20:11:25 +01:00
Emil Ernerfeldt e54106e950 Extend contributor list 2021-11-03 19:37:38 +01:00
Emil Ernerfeldt c71090473b glow-vs-web cleanup following https://github.com/emilk/egui/pull/868 2021-11-03 19:35:20 +01:00
Emil Ernerfeldt 1dbe608e73 Refactor integrations (#871)
* Unify code in egui_glium and egui_glow into egui_winit::EpiIntegration
* Simplify `EguiGlium` interface
* Simplify `EguiGlow` interface
* egui_web refactor: merge `WebBackend` into `AppRunner`
2021-11-03 13:45:51 +01:00
Emil Ernerfeldt eda1d91654 Add culling of the painting for most widgets
This is a good early-out for widgets in `ScrollAreas`, but
also prepares for speeding up the first pass of a possible two-pass
version of egui: https://github.com/emilk/egui/issues/843
2021-11-01 22:08:23 +01:00
Emil Ernerfeldt 09b8269326 Rich text for all widgets (#855)
Introduce `RichText` and `WidgetText`
2021-11-01 21:30:10 +01:00
Emil Ernerfeldt 9378cd5c6e ScrollArea: add methods to control horizontal scroll offset
Closes https://github.com/emilk/egui/issues/864
2021-11-01 19:43:27 +01:00
Emil Ernerfeldt 78dfde40b2 Remove deprecated functions 2021-10-30 09:46:06 +02:00
Emil Ernerfeldt b551dfec81 fix broken docstring link 2021-10-29 21:10:53 +02:00
Emil Ernerfeldt 081485bcaf Make it cheaper to clone Memory if there are a lot of persisted values 2021-10-27 16:49:08 +02:00
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 ddd52f47c5 Add tessellation option to toggle rounding text to pixel coordinates
On by default and only there for testing
2021-10-27 08:56:06 +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 bbe0f6089c Context-menu: fix right-click edge-case
response.hovered() checks a larger rect which includes the item spacing,
and it always matches the hover effect.
2021-10-26 20:40:17 +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
Emil Ernerfeldt b31ca7efc9 PR template: remind people to run cargo fmt and cargo clippy 2021-10-25 23:21:39 +02:00
Emil Ernerfeldt 445488755f Point contributors to the new egui Discord 2021-10-25 23:20: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 c090497727 Add 0.15.0 release code editor gif used in CHANGELOG.md 2021-10-24 17:15:23 +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 c3f61b67fe New web demo 2021-10-24 16:00:56 +02:00
Emil Ernerfeldt 316202c33a egui_web: improve text input on mobile and for IME 2021-10-24 15:57:36 +02:00
Emil Ernerfeldt 9a9b1b8746 On touch screens, prioritize drag-to-scroll over drag-to-select text
On mobile, click first, then edit the text.
Otherwise a lot of areas become difficult to scroll on mobile.
2021-10-24 15:26:40 +02:00
Emil Ernerfeldt 17f0ae22c9 Code example demo: remove extra ScrollArea 2021-10-23 15:36:25 +02:00
Emil Ernerfeldt da09a5c69c Fix compilation with "serialize" feature without "persistence" feature 2021-10-23 15:12:39 +02:00
Emil Ernerfeldt 4ace85b780 Fix: '\t' always take up the width of four spaces 2021-10-23 14:38:26 +02:00