Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Egui editor #40

Merged
merged 64 commits into from
Jun 10, 2024
Merged

Egui editor #40

merged 64 commits into from
Jun 10, 2024

Conversation

vaneri-9
Copy link
Collaborator

@vaneri-9 vaneri-9 commented Jul 24, 2023

(Moved from #19 accidentally used wrong remote)
Related #17

Todo (not all of these are in scope for this pr):

  • Rename InputId to InputPort and the id field to port_id and all variables using it
  • Refactor/rename functions and where functionality is
  • Save, Save as, Load
  • Fix mem tests
  • Remove comments on line 57 in common.rs
  • Reverse Serialize/Deserialize on line 76 in common.rs (to revert)
  • Add a button to enter wire mode
  • Care about different signal types when connecting input (Combinatorial etc)
  • Auto-save when switching from editor in case you did something wrong
  • Select multiple components with a drag and select feature (BIG)
  • Properties maybe should be on the left side (where the library is)
  • Properties window should not include sliders for any number input, there are issues with strobing and they don't really make sense for what they're supposed to do
  • Snapping for components to the grid when moving them (maybe also placing)
  • Add more components
    • add
    • constant
    • mem
    • mux
    • probe
    • probe_edit
    • probe_out
    • probe_stim
    • probe_assert
    • register
    • sext
    • wire

Changes made:

  • Simulator now consumes the ComponentStore, this is required since we can only have ONE reference to a dyn Component to be able to edit it because of Rc limitation (it is intended to work this way)
  • Every component requires to be made with the ::new method since otherwise we don't conditionally create the EguiExtra struct that egui needs for editor functionality
  • The InputPort wraps an Input but also provides an id for a port, gui-egui requires this to bind the ends of two wires
  • gui-egui now also has a render_editor function trait that requires the dyn Component to be mutable and only runs during a specific EditorMode in the editor.
  • gui-egui render function returns Option<Vec<egui::Response>> because of the wire being multiple responses (the points)
  • gui-egui components now have tooltips (some are broken)

Bugs:

  • Program crashes when starting simulator with an incorrect ComponentStore, there is auto-save.
  • Moving wires does not connect or disconnect anything, after they've been placed they are purely visual
  • You can not start or end at a wire atm. Functionality will be added in the future (reason for it not existing now is that if a wire is connected to a port and you're trying to also connect to that port the wire should prefer connecting to the port and not the wire, this functionality does not exist atm)
  • Properties window closes when you select an item that was far down on the dropdown (outside the properties window)
  • Switching to editor, simulation, editor will crash on last switch
  • Right-clicking a multi-position wire will open the window and quickly close it because of clicked_elsewhere working on the individual part of the segments
  • When changing the id of a component also somehow change all the items connected to that component to update to the new id
  • Editor mode doesn't have background colors for Constant and Probe to be able to show where the ports are located
  • Moving your mouse outside the window while placing a component will make the cursor offset from the component when reentering
  • Placing a component while being in scaling doesn't place it in the correct position
  • Delete component with keyboard or button
  • Loading a model does not work (anymore)
  • Right clicking in input mode on the library crashes the program
  • Holding left click selecting components and then pressing right-click panics the program

How to use:

  • Toggle editor Ctrl+e or File->Editor
  • Save: Ctrl+s (currently only saves to file.json)
  • Left side is the library of components, click a component entering place mode for it where you can place it until you press Escape (or Right-click
  • w to enter wire mode so you can connect multiple components with wires, it will automatically snap to open ports on the components
  • Right-click components to manually edit them
  • Left-click-drag components to move them around

I've been testing with cargo run --no-default-features --features=gui-egui --example add -- --model mips

@vaneri-9
Copy link
Collaborator Author

vaneri-9 commented Jul 25, 2023

Finally ci passes!

The reason for not adding more components is if something seems wrong with the editor there's less to fix for all components.

@vaneri-9 vaneri-9 marked this pull request as ready for review July 25, 2023 13:02
@perlindgren
Copy link
Owner

perlindgren commented Aug 10, 2023

Bugs

  • Placing components after setting scale puts component at wrong place.

A few suggestions:

  • Grid, with settable size, and snap to grid for component placement
  • Moving of wire segments.
  • Area selection, to allow for deleting/dragging and potentially copy paste of several objects
  • Delete button for active component

@vaneri-9
Copy link
Collaborator Author

vaneri-9 commented Aug 18, 2023

Bugs

* Placing components after setting scale puts component at wrong place.

Fixed

A few suggestions:

* Grid, with settable size, and snap to grid for component placement

Added (Seems to be a bug with it not displaying properly)

* Moving of wire segments.

Was already working, but fixed properties window bug and added so you can add/remove segments in there.

* Area selection, to allow for deleting/dragging and potentially copy paste of several objects

Not done, seems like a big feature, maybe for the future

* Delete button for active component

Will do soon
Done

impl Editor {
pub fn gui(components: Components, _path: &Path) -> Self {
let dummy_input = Input::new("id", "field");
let library: Components = vec![
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should probably be passed as an argument, allowing model crates (like riscv) to provide their own component libraries

Copy link
Collaborator

@onsdagens onsdagens left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm using this now to create a better model view for the riscv, comments incoming...

@onsdagens
Copy link
Collaborator

Found a bug, the left side library view will not scroll when there are more elements than fit the screen. I've fixed it for now by just decreasing the render scale.

@onsdagens onsdagens mentioned this pull request Jun 7, 2024
@perlindgren perlindgren merged commit ebd1d09 into master Jun 10, 2024
3 checks passed
@onsdagens
Copy link
Collaborator

This is now partly merged with #78 . Since the feature is still experimental (i.e. buggy), let's keep this issue around for tracking.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants