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

A drop-down that allows changing the execution mode. #6130

Merged
merged 21 commits into from
Apr 18, 2023

Conversation

MichaelMauderer
Copy link
Contributor

@MichaelMauderer MichaelMauderer commented Mar 29, 2023

Pull Request Description

Implements #5931.

Peek.2023-03-29.13-15.mp4

Important Notes

Not functional yet, as it needs integration with the engine.

Checklist

Please ensure that the following checklist has been satisfied before submitting the PR:

  • The documentation has been updated, if necessary.
  • Screenshots/screencasts have been attached, if there are any visual changes. For interactive or animated visual changes, a screencast is preferred.
  • All code follows the
    Scala,
    Java,
    and
    Rust
    style guides. In case you are using a language not listed above, follow the Rust style guide.
  • All code has been tested:
    • Unit tests have been written where possible.
    • If GUI codebase was changed, the GUI was tested when built using ./run ide build.

@MichaelMauderer MichaelMauderer self-assigned this Mar 29, 2023
@MichaelMauderer MichaelMauderer added d-intermediate Difficulty: some prior knowledge required p-high Should be completed in the next sprint -gui labels Mar 29, 2023
@MichaelMauderer MichaelMauderer marked this pull request as ready for review March 29, 2023 12:48
Copy link
Contributor

@farmaazon farmaazon left a comment

Choose a reason for hiding this comment

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

In the video you posted, the entry labels in drop-down are not centered vertically in selection:

image

Please change (or remove) the offset I suspect we're adding there.

app/gui/view/examples/icons/src/lib.rs Outdated Show resolved Hide resolved
app/gui/view/execution-mode-selector/Cargo.toml Outdated Show resolved Hide resolved
app/gui/view/execution-mode-selector/src/lib.rs Outdated Show resolved Hide resolved
@wdanilo
Copy link
Member

wdanilo commented Mar 31, 2023

In the video you posted, the entry labels in drop-down are not centered vertically in selection:

image

Please change (or remove) the offset I suspect we're adding there.

I just did the same screenshot :D

use ide_view_execution_mode_selector as execution_mode_selector;



Copy link
Member

Choose a reason for hiding this comment

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

no section

@@ -254,6 +254,13 @@ fn init(app: &Application) {
graph_editor.set_node_profiling_status(node3_id, node3_status);


// === Execution Modes ===

graph_editor.set_execution_modes(vec!["development".to_string(), "production".to_string()]);
Copy link
Member

Choose a reason for hiding this comment

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

These strings ar defiend in another file as well

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These are dummy strings anyway. The ones in the demo scene will only be used there, while the other ones will be removed during integration.

app/gui/view/execution-mode-selector/src/lib.rs Outdated Show resolved Hide resolved
set_execution_modes (ExecutionModes),
}
Output {
selected_ecxecution_mode (ExecutionMode),
Copy link
Member

Choose a reason for hiding this comment

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

typo


ensogl::define_endpoints_2! {
Input {
set_execution_modes (ExecutionModes),
Copy link
Member

Choose a reason for hiding this comment

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

This sounds like selecting execution modes. Maybe it should be named set_available_execution_modes instead?

});

// Inputs

Copy link
Member

Choose a reason for hiding this comment

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

why this nl? Code above and below does not use nl after such comments.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added the space in the above place for consistency.

Copy link
Member

Choose a reason for hiding this comment

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

But literally 7 lines below you have the exact same problem now. I think this is a good place to use sub-sections, as their layout rules are unified across files and they are very close to what you have here.

Copy link
Member

Choose a reason for hiding this comment

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

I do not know what to write here. I mean, this discussion should already be resolved, but .... it is still inconsistent ...

image

image

Doing review of the same code so many times is super time consuming :(

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

Comment on lines 228 to 230
eval_ update_position ([model, camera] {
model.update_position(&camera);
});
Copy link
Member

Choose a reason for hiding this comment

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

you don't need curly braces here and this can be one-line expressions.

Copy link
Contributor

Choose a reason for hiding this comment

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

Technically, there is a difference, because here we discard potential return value from update_position.

But more important is, that rustfmt formats too long lambdas this way, and we are meant to apply same formatting rules to macros.

Copy link
Member

@wdanilo wdanilo Mar 31, 2023

Choose a reason for hiding this comment

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

Regarding rustfmt, without curly braces I believe rustfmt would format that one-line.

Oh, you are right - it adds braces only when extended 100 characters limit.

Comment on lines 226 to 227
let camera_changed = scene.frp.camera_changed.clone_ref();
update_position <- any(init, camera_changed);
Copy link
Member

Choose a reason for hiding this comment

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

Why are we making position update on camera change? Instead, this should be added to al ayer with camera that does not move with navigator.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This update is not about camera movement, but the viewport size change. As we want this to be aligned with the top of the window. This seems to be what all the components placed this way are using at the moment.

The alternative would be a new layer with a fixed origin at the top left window corner, but that would also not work for things placed at the bottom. We could fix the coordinates of that layer to be 0..1, but then finding the correct position for an object would be an issue as it would depend on the scaling. Or am I missing something?

Copy link
Member

Choose a reason for hiding this comment

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

Hmm, we shouldd probably have a layer aligned to top left corner and place such items there. Items aligned to bottom left one would use another layer then. I mean, it should not be the responsibility of elements to place themselves. Nevertheless, this is a broader discussion and im ok with not fixing it here.

Comment on lines +7 to +8
//! values. It should also be refactored to use `drop_down_menu` from `ensogl_components` instead
//! of the old list view.
Copy link
Member

Choose a reason for hiding this comment

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

Why are we not using the new drop-down in the first place here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The "new drop-down" only implements the part that opens and closes, while this component has the "clickable selected item". Ideally, they should be refactored to be merged, but for this use cases, the "old one" is more appropriate (and the additional refactoring not required at this time).

Comment on lines 1810 to 1815
let traffic_light_width = traffic_lights_gap_width();

self.add_child(&self.execution_mode_selector);
self.execution_mode_selector
.set_x(traffic_light_width + execution_mode_selector::OVERALL_WIDTH / 2.0);
self.execution_mode_selector.set_y(y_offset + execution_mode_selector::HEIGHT / 2.0);
Copy link
Member

Choose a reason for hiding this comment

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

The position of the execution mode selector should be reactive. It should probably be computed with FRP based on the width of traffic light. Even better, you can use our auto-layout to place execution mode next to traffic light. The description of how to use auto-layout is in display::object module.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It actually is reactive based on the FRP updates below. This is just the default initialization. The reason I did not go with the layout is, that the traffic lights are: (a) not currently part of the Graph Editor and (b) as far as I am aware, are not always present, as on macOS there are the native controls placed there and this offset is applied without a corresponding EnsoGL component.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

(also some changes happening due to use of the theme here soon to be visible)

Copy link
Member

Choose a reason for hiding this comment

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

Regarding auto-layouts - they work great when some items are not always present. Just FYI - you can create auto grid layout and when item is missing, other items will be layout correctly.

@MichaelMauderer
Copy link
Contributor Author

MichaelMauderer commented Apr 3, 2023

Updated video.

Peek.2023-04-03.14-04.mp4


impl Model {
fn update_dropdown_style(&self, overall_width: f32, divider_offset: f32) {
self.dropdown.set_menu_offset_y(20.0);
Copy link
Member

Choose a reason for hiding this comment

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

hardcoded literal - could you please extract it to a well named const? :)

}

fn update_play_icon_style(&self, max_width: f32, play_button_offset: f32) {
self.play_icon.set_size(Vector2::new(10.0, 11.0));
Copy link
Member

Choose a reason for hiding this comment

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

Hardcoded literals, also, the size of 10x11 looks strange - could you provide some explanation next to the definition of that it is, please?

});

// Inputs

Copy link
Member

Choose a reason for hiding this comment

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

But literally 7 lines below you have the exact same problem now. I think this is a good place to use sub-sections, as their layout rules are unified across files and they are very close to what you have here.

Comment on lines 3874 to 3882
// breadcrumb_gap_update <- all(inputs.space_for_window_buttons,size_update);
// eval breadcrumb_gap_update([model]((gap_size, execution_mode_selector_size)) {
// let traffic_light_width = traffic_lights_gap_width();
// let breadcrumb_gap_width = traffic_light_width + execution_mode_selector_size.x + TOP_BAR_ITEM_MARGIN;
//
// let execution_mode_selector_x = traffic_light_width + execution_mode_selector_size.x / 2.0;
// model.execution_mode_selector.set_x(gap_size.x + execution_mode_selector_x);
// model.breadcrumbs.gap_width(gap_size.x + breadcrumb_gap_width);
// });
Copy link
Member

Choose a reason for hiding this comment

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

commented code

Comment on lines 658 to 667
background = Rgb::from_base_255(100.0, 181.0, 38.0) , Rgb::from_base_255(100.0, 181.0, 38.0);
divider = Rgba::black_with_alpha(0.12) , Rgba::black_with_alpha(0.12);
triangle = Rgba::white_with_alpha(0.75) , Rgba::white_with_alpha(0.75);
play_button_size = 10.0 , 10.0;
play_button_offset = 15.0 , 15.0;
play_button_padding = 10.0 , 10.0;
divider_offset = 32.5 , 32.5;
divider_padding = 10.0 , 10.0;
dropdown_width = 95.0 , 95.0;
height = 24.0 , 24.0;
Copy link
Member

Choose a reason for hiding this comment

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

very big indentation in the code

});

// Inputs

Copy link
Member

Choose a reason for hiding this comment

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

I do not know what to write here. I mean, this discussion should already be resolved, but .... it is still inconsistent ...

image

image

Doing review of the same code so many times is super time consuming :(

@MichaelMauderer MichaelMauderer requested a review from wdanilo April 4, 2023 13:00
@MichaelMauderer
Copy link
Contributor Author

@wdanilo @farmaazon This awaits your re-review.

Comment on lines 168 to 170

eval send_data ([](data) error!("Received data: {:?}",data));
eval deactivate ([](_) error!("Deactivated"));
Copy link
Contributor

Choose a reason for hiding this comment

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

I think there are leftover debug logs here.

@vitvakatu
Copy link
Contributor

QA report 🟡

In general, I didn't spot any issues on my machine. But:

The play button shape was too small

Only the triangle could capture mouse events, so it was quite hard to press it. I changed the code slightly to fix that and pushed the commit f39f74d

🔴 @Procrat reported that dropdown does not work on his machine

The list does not react on clicking. I didn't spot any obvious issues with layers, and it is not reproducible on my machine.

The video by @Procrat:

videos.zip

@MichaelMauderer
Copy link
Contributor Author

Only the triangle could capture mouse events, so it was quite hard to press it. I changed the code slightly to fix that and pushed the commit f39f74d

Thanks!

red_circle @Procrat reported that dropdown does not work on his machine

The list does not react on clicking. I didn't spot any obvious issues with layers, and it is not reproducible on my machine.

The video by @Procrat:

videos.zip

That is very concerning! I'll have a closer look at the videos in a bit.
@Procrat are you able to select visualizations from the visualization dropdown menu on this branch and on develop? (That menu uses the same component).

Copy link
Contributor

@vitvakatu vitvakatu left a comment

Choose a reason for hiding this comment

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

QA: passed

@farmaazon farmaazon added the CI: Ready to merge This PR is eligible for automatic merge label Apr 14, 2023
@MichaelMauderer MichaelMauderer added the CI: Clean build required CI runners will be cleaned before and after this PR is built. label Apr 16, 2023
@kazcw
Copy link
Contributor

kazcw commented Apr 17, 2023

Bug for the WASM test failure: #6315

@MichaelMauderer MichaelMauderer added the CI: Keep up to date Automatically update this PR to the latest develop. label Apr 18, 2023
@mergify mergify bot merged commit 6404332 into develop Apr 18, 2023
@mergify mergify bot deleted the wip/MichaelMauderer/Execution_Context_Dropdown_Menu branch April 18, 2023 10:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI: Clean build required CI runners will be cleaned before and after this PR is built. CI: Keep up to date Automatically update this PR to the latest develop. CI: Ready to merge This PR is eligible for automatic merge d-intermediate Difficulty: some prior knowledge required p-high Should be completed in the next sprint
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants