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

Implementation of elements adding to List Editor and a lot of internal API #6390

Merged
merged 14 commits into from
Apr 25, 2023

Conversation

wdanilo
Copy link
Member

@wdanilo wdanilo commented Apr 24, 2023

Pull Request Description

This PR makes it possible to add elements to List Editor and extends internal API to notify about the operations performed:

Screen.Recording.2023-04-24.at.13.36.51.mov

Important Notes

This PR also changes the implementation of slider. The old implementation had a few bugs and did not use modern EnsoGL stuff, such as display-object-based sizing. The implementation is not finished, but will be in the next day or two. As we want to merge it fast, it is here in a not-finished state. But as no one uses the slider yet, we might accept it.

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.

Comment on lines +420 to +431
f!([model] (gap, gaps, pos, size, is_dragging, enable_all, enable_last) {
let is_close_x = pos.x > -gap && pos.x < size.x + gap;
let is_close_y = pos.y > -gap && pos.y < size.y + gap;
let is_close = is_close_x && is_close_y;
let opt_gap = gaps.find(pos.x);
opt_gap.and_then(|gap| {
let last_gap = *gap == gaps.len() - 1;
let enabled = is_close && !is_dragging;
let enabled = enabled && (*enable_all || (*enable_last && last_gap));
enabled.and_option_from(|| model.item_or_placeholder_index_to_index(gap))
})
})
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we make it a method? Also, the FRP node name is unclear: of what element is the index?

Comment on lines +459 to +463
eval frp.remove([model, on_item_removed] (index) {
if let Some(item) = model.borrow_mut().trash_item_at(*index) {
on_item_removed.emit(Response::api((*index, Rc::new(item).downgrade())));
}
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Is it impossible to express this node as on_item_removed <+ frp.remove.filter_map(...)? It would keep the FRP traces.

Comment on lines +503 to +507
eval target_on_start([model, on_item_removed] (t) {
if let Some((index, item)) = model.borrow_mut().start_item_drag(t) {
on_item_removed.emit(Response::gui((index, Rc::new(item).downgrade())));
}
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here.

}
(is_dragging, drag_diff)
(status, drag_diff)
}

/// Implementation of item trashing logic. See docs of this crate to learn more.
Copy link
Contributor

Choose a reason for hiding this comment

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

This docs should explain return values. Also, the terms in docs should be consistent - here we say about "trashing", but the crates docs (where the user is sent) says about "removing".

To make life easier you may make a link like See [docs of this crate](crate) ...

}

impl<T: display::Object + 'static> Model<T> {
impl<T: display::Object + CloneRef + 'static> Model<T> {
// FIXME: refactor and generalize
Copy link
Contributor

Choose a reason for hiding this comment

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

When it would be fixed? Is there a task when we plan to do this?

self.init_precision_popup();
self.init_information_tooltip();
self.init_component_layout();
self.init_component_colors();
// self.init_component_colors();
Copy link
Contributor

Choose a reason for hiding this comment

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

commented code.

@@ -264,33 +263,30 @@ impl Model {
}

/// Set whether the lower overfow marker is visible.
pub fn set_value_indicator(&self, indicator: &ValueIndicator) {
pub fn kind(&self, indicator: &Kind) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Update docs, and perhaps var name too.

Comment on lines +45 to +48
// slider.frp.set_background_color(color::Lcha(0.8, 0.0, 0.0, 1.0));
// slider.frp.set_max_value(5.0);
// slider.frp.set_default_value(1.0);
// slider.frp.set_value(1.0);
Copy link
Contributor

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 +634 to +638
// comp_size <- all2(&input.set_width, &input.set_height).map(|(w, h)| Vector2(*w,*h));
eval obj.on_resized((size) model.update_size(*size));
eval input.kind((i) model.kind(i));
// output.width <+ input.set_width;
// output.height <+ input.set_height;
Copy link
Contributor

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 +666 to +687
// overflow_marker_position <- all3(
// &input.set_width,
// &input.set_height,
// &input.orientation,
// );
// eval overflow_marker_position((p) model.set_overflow_marker_position(p));
// overflow_marker_shape <- all2(&model.value_text_left.height, &input.orientation);
// eval overflow_marker_shape((s) model.set_overflow_marker_shape(s));
//
// eval input.set_label_hidden((v) model.set_label_hidden(*v));
// model.label.set_content <+ input.set_label;
// label_position <- all6(
// &input.set_width,
// &input.set_height,
// &model.label.width,
// &model.label.height,
// &input.set_label_position,
// &input.orientation,
// );
// eval label_position((p) model.set_label_position(p));

// output.orientation <+ input.orientation;
Copy link
Contributor

Choose a reason for hiding this comment

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

Commented code.

@wdanilo wdanilo added the CI: No changelog needed Do not require a changelog entry for this PR. label Apr 25, 2023
@wdanilo
Copy link
Member Author

wdanilo commented Apr 25, 2023

All the comments from Adam will be addressed in the next PR (I will open it tonight) as we need this merged fast.

@wdanilo wdanilo merged commit 115e9b4 into develop Apr 25, 2023
@wdanilo wdanilo deleted the wip/wd/vector-editor4 branch April 25, 2023 16:06
Procrat added a commit that referenced this pull request Apr 27, 2023
* develop:
  Passing events to sub-widgets in List Editor and refactoring of the slider component. (#6433)
  Revert "Cloud/desktop mode switcher (#6308)" (#6444)
  Widgets integrated with graph nodes (#6347)
  Table Visualization and display text changes. (#6382)
  Skip redundant compilations (#6436)
  Add parse extensions to Text type. #6330 (#6404)
  Cloud/desktop mode switcher (#6308)
  Replace Table should_equal with should_equal_verbose (#6405)
  Rollback event handling changes for the mouse (#6396)
  Dashboard directory interactivity (#6279)
  Ability to change the execution environment between design and live. (#6341)
  Implementation of elements adding to List Editor and a lot of internal API (#6390)
  Drop method exported from WASM + removing leaks. (#6365)
  Turn null into UnexpectedExpression when Union type is incomplete (#6415)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI: No changelog needed Do not require a changelog entry for this PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants