hirtol / egui_memory_editor Goto Github PK
View Code? Open in Web Editor NEWMemory editor for the egui immediate mode GUI
License: Apache License 2.0
Memory editor for the egui immediate mode GUI
License: Apache License 2.0
Hi, thanks for your work on this crate! It will save me a ton of time and effort compared to a home-made solution.
I just have one question regarding the projects license. I noticed that this repository does not ship any, even though the crates.io page notes that it is licensed under either Apache 2 or MIT. I was wondering if that licensing choice was intentional?
I am not a legal expert, but I believe both of those licenses require that a copy is bundled when distributing the source code. Because of this I suggest it would be best if you could include them in the Github repository as well.
Once again thanks for this crate, I'm really looking forward to integrating it with a project of mine :)
I noticed some commits in master
branch about upgrading to egui v0.21 (194e9ad).
It seems to work on my end building from master
, though I also noticed that a piece of code was removed examples/simple/frame_history.rs#L81-L98.
Is there anything we can do to help?
You cannot just use None
when wanting to only use a read function, I don't know if there's any simpler way of doing what I did which was None as Option<fn(&mut T, Address, u8) -> ()>,
Hello!
I've looked at your very nice memory editor demo today. I was a bit "surprised" by its runtime performance on my hardware (about 4ms out of the 16.6 available). Before rolling my own stuff, I wanted to ask you: did you optimize in way or another ? If so then well, I guess the performance are not bad and it's just the best one can do.
For example, do you redraw only the "visible" parts of the view or do you let egui do the clipping for you ?
Thank you !
I find myself in a situation where I should reuse a memory editor for data that can change (and also the range).
For the moment, I have to recreate the whole editor each time, since MemoryEditor::with_address_range()
uses the builder pattern.
let mem: &mut [u8] = ...;
let mut mem_editor = MemoryEditor::new().with_address_range("All", 0..mem.len());
mem_editor.draw_editor_contents_read_only(ui, mem, |mem, address| mem[address].into());
This also forces me to clone the MemoryEditorOptions
if I want it to persist that and give it to the next instance of MemoryEditor
:
let mut mem_editor = ...;
if let Some(options) = &self.editor_options {
mem_editor = mem_editor.with_options(options.clone());
}
mem_editor.draw_editor_contents_read_only(...);
self.editor_options = Some(mem_editor.options.clone());
And because a new instance of MemoryEditor
is created each time, some functionalities (such as goto) don't work properly.
Ideally I would like to create a single instance of MemoryEditor
and keep it as a field of a struct (similarly to what is done in the examples/simple
on this repo, and still be able to modify the range whenever needed:
struct MyStruct {
Option<MemoryEditor> editor,
}
impl MyStruct {
pub fn on_frame_update(ui: &mut Ui) {
let mem_editor = self.editor.get_or_insert_with(|| {
MemoryEditor::new()
});
// ...
let mem: &mut [u8] = ...;
mem.set_address_range("All", 0..mem.len());
mem_editor.draw_editor_contents_read_only(ui, mem, |mem, address| mem[address].into());
}
}
Therefore, I would suggest to add a function such as:
impl MemoryEditor {
pub fn set_address_range(&mut self, range_name: impl Into<String>, address_range: Range<Address>) {
// ...
}
}
Likely the same could be applied to MemoryEditorOptions
:
impl MemoryEditor {
pub fn set_options(&mut self, options: MemoryEditorOptions) {
self.options = options
}
}
And to avoid code duplication, the builder functions could be rewritten as:
#[must_use]
pub fn with_address_range(mut self, range_name: impl Into<String>, address_range: Range<Address>) -> Self {
self.set_address_range(range_name, address_range);
self
}
pub fn set_address_range(&mut self, range_name: impl Into<String>, address_range: Range<Address>) {
self.address_ranges.insert(range_name.into(), address_range);
self.frame_data.memory_range_combo_box_enabled = self.address_ranges.len() > 1;
if let Some((name, _)) = self.address_ranges.iter().next() {
self.options.selected_address_range = name.clone();
}
}
#[must_use]
pub fn with_options(mut self, options: MemoryEditorOptions) -> Self {
self.set_options(options);
self
}
pub fn set_options(&mut self, options: MemoryEditorOptions) {
self.options = options;
}
If that's ok, I can create a PR with the above changes.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.