Skip to content

Commit

Permalink
Refactor memory data (#836)
Browse files Browse the repository at this point in the history
This refactors the widget state storage introduced by @optozorax in #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.
  • Loading branch information
emilk committed Oct 27, 2021
1 parent bbe0f60 commit 8e4fd94
Show file tree
Hide file tree
Showing 31 changed files with 917 additions and 1,347 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ NOTE: [`epaint`](epaint/CHANGELOG.md), [`eframe`](eframe/CHANGELOG.md), [`egui_w
### Added ⭐
* Add context menus: See `Ui::menu_button` and `Response::context_menu` ([#543](https://github.com/emilk/egui/pull/543)).

### Changed 🔧
* Unified the four `Memory` data buckts (`data`, `data_temp`, `id_data` and `id_data_temp`) into a single `Memory::data`, with a new interface ([#836](https://github.com/emilk/egui/pull/836)).


## 0.15.0 - 2021-10-24 - Syntax highlighting and hscroll

Expand Down
224 changes: 0 additions & 224 deletions egui/src/any/any_map.rs

This file was deleted.

63 changes: 0 additions & 63 deletions egui/src/any/element.rs

This file was deleted.

61 changes: 0 additions & 61 deletions egui/src/any/mod.rs

This file was deleted.

Loading

0 comments on commit 8e4fd94

Please sign in to comment.