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

Fix component browser interactions. #8303

Conversation

MichaelMauderer
Copy link
Contributor

@MichaelMauderer MichaelMauderer commented Nov 15, 2023

Pull Request Description

Fixes: #8064

Fixes broken interactions with of the component browser.

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 added the CI: No changelog needed Do not require a changelog entry for this PR. label Nov 15, 2023
@MichaelMauderer MichaelMauderer marked this pull request as ready for review November 15, 2023 14:48
Comment on lines +321 to +322
applySuggestion()
acceptInput()
Copy link
Contributor

@farmaazon farmaazon Nov 15, 2023

Choose a reason for hiding this comment

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

Suggested change
applySuggestion()
acceptInput()
applySuggestion()

Applying accepting suggestion should also accept input, unless we want to enter module, in which case CB should not close.

Also, I would rename it as acceptSuggestion, and acceptInputRaw could be just acceptInput.

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 applySuggestion method, right now, adds the currently selected suggestion in the CB to the input. This is what happens when pressing tab.

I thought we had three interactions here:

  • tab only applies the selected suggestion but keeps the CB open
  • enter chooses the applied the selected suggestion and closes the CB
  • ctrl+enter closes the CB with the current input, without applying the selected suggestion.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry, I re-read my comment, and now I cannot say what have I had in mind. You are right, of course. Only the names:

  • tab I usually name "applying suggestion"
  • enter is "accepting suggestion"
  • ctrl+enter is "accepting input"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That sounds good, I'll apply that naming to the code, add a doc and that should make it consistent and clear.

gap: gapBetweenNodes,
}).position
} else {
return mouseDictatedPlacement(nodeSize, placementEnvironment.value).position
Copy link
Contributor

Choose a reason for hiding this comment

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

i'm testing this out during the bookclub and this doesn't work, since this value is continuously computed.
specifically, doing this makes the cb follow the mouse - which is kinda cool to see, but that makes it not very useful, as it would be no longer possible to click around in the CB entries, docs breadcrumbs, and the CB input.

Copy link
Contributor

Choose a reason for hiding this comment

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

i don't think this needs to be changed, but you'd need another ref

const realComponentBrowserPosition = ref<Vec2>()
watch(componentBrowserVisible, visible => {
  if (visible) realComponentBrowserPosition.value = componentBrowserPosition.value
  else realComponentBrowserPosition.value = undefined
})

Copy link
Contributor

Choose a reason for hiding this comment

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

I, in turn, would just make function "openComponentBrowserParams" which inter alia will just set computed position to componentBrowserPosition without using reactivity, and then set visible to true.

But if you stick to @somebody1234 solution for some reason, I prefer renaming componentBrowserPosition -> openedComponentBrowserPosition or newComponentBrowserPosition and realComponentBrowserPosition -> just componentBrowserPosition.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I went with refactoring it to a function targetComponentBrowserPosition which is used to update the componentBrowserPosition when required.

…emporary-Node-During-Node-Crteation

# Conflicts:
#	app/gui2/src/components/ComponentBrowser/__tests__/placement.test.ts
#	app/gui2/src/components/GraphEditor.vue
…emporary-Node-During-Node-Crteation

# Conflicts:
#	app/gui2/src/components/GraphEditor.vue
@MichaelMauderer
Copy link
Contributor Author

@Frizi Just missing your review now.

@Frizi Frizi added the CI: Ready to merge This PR is eligible for automatic merge label Nov 17, 2023
@mergify mergify bot merged commit 85e2c72 into develop Nov 17, 2023
35 checks passed
@mergify mergify bot deleted the wip/MichaelMauderer/gui2/Avoid-Creating-Temporary-Node-During-Node-Crteation branch November 17, 2023 15:28
const editedInfo = graphStore.editedNodeInfo
const isEditingNode = editedInfo != null
const hasNodeSelected = nodeSelection.selected.size > 0
const nodeSize = new Vec2(0, 24)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure I understand this hardcoded value. This is the expected size of a node that is about to be created by the component browser? If so, it should be loaded from a predefined constant. Let's change that soon, but in separate PR to not block anything.

const targetPos = targetNode?.position ?? Vec2.Zero
return targetPos.add(COMPONENT_BROWSER_TO_NODE_OFFSET)
} else if (hasNodeSelected) {
const gapBetweenNodes = 48.0
Copy link
Contributor

Choose a reason for hiding this comment

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

Another thing that definitely should be a constant. Also, why isn't the default gap value used instead?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
-gui CI: No changelog needed Do not require a changelog entry for this PR. CI: Ready to merge This PR is eligible for automatic merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Adding a new node with searcher
4 participants