Git Product home page Git Product logo

egui_memory_editor's People

Contributors

ax9d avatar hirtol avatar kryptos-fr avatar ptxmac avatar ragarnoy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

egui_memory_editor's Issues

License is not included in the repository

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 :)

Question about the performances

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 !

Add a function to modify the range after the editor has been created

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.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.