-
Notifications
You must be signed in to change notification settings - Fork 323
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
A drop-down that allows changing the execution mode. #6130
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use ide_view_execution_mode_selector as execution_mode_selector; | ||
|
||
|
||
|
There was a problem hiding this comment.
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()]); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
set_execution_modes (ExecutionModes), | ||
} | ||
Output { | ||
selected_ecxecution_mode (ExecutionMode), |
There was a problem hiding this comment.
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), |
There was a problem hiding this comment.
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 | ||
|
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
eval_ update_position ([model, camera] { | ||
model.update_position(&camera); | ||
}); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
let camera_changed = scene.frp.camera_changed.clone_ref(); | ||
update_position <- any(init, camera_changed); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
//! values. It should also be refactored to use `drop_down_menu` from `ensogl_components` instead | ||
//! of the old list view. |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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).
app/gui/view/graph-editor/src/lib.rs
Outdated
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); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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.
…r/Execution_Context_Dropdown_Menu # Conflicts: # CHANGELOG.md
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); |
There was a problem hiding this comment.
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)); |
There was a problem hiding this comment.
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 | ||
|
There was a problem hiding this comment.
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.
app/gui/view/graph-editor/src/lib.rs
Outdated
// 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); | ||
// }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
commented code
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; |
There was a problem hiding this comment.
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 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wdanilo @farmaazon This awaits your re-review. |
|
||
eval send_data ([](data) error!("Received data: {:?}",data)); | ||
eval deactivate ([](_) error!("Deactivated")); |
There was a problem hiding this comment.
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.
QA report 🟡In general, I didn't spot any issues on my machine. But: The play button shape was too smallOnly 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 machineThe 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: |
Thanks!
That is very concerning! I'll have a closer look at the videos in a bit. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
QA: passed
d8b6994
to
2781f0a
Compare
Bug for the WASM test failure: #6315 |
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:
Scala,
Java,
and
Rust
style guides. In case you are using a language not listed above, follow the Rust style guide.
./run ide build
.