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

All ways of creating node (+ button, dragging out edges) #8341

Conversation

MichaelMauderer
Copy link
Contributor

@MichaelMauderer MichaelMauderer commented Nov 20, 2023

Pull Request Description

Closes #8054

Peek.2023-11-20.13-50.webm

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 Nov 20, 2023
@MichaelMauderer MichaelMauderer added -gui CI: No changelog needed Do not require a changelog entry for this PR. labels Nov 20, 2023
@MichaelMauderer MichaelMauderer force-pushed the wip/MichaelMauderer/gui2/All-ways-of-creating-node-(+-button,-dragging-out-edges) branch from 705c06b to 9da34fc Compare November 20, 2023 15:05
@MichaelMauderer MichaelMauderer marked this pull request as ready for review November 20, 2023 15:08
app/gui2/src/components/GraphEditor.vue Show resolved Hide resolved
app/gui2/src/components/GraphEditor.vue Outdated Show resolved Hide resolved
app/gui2/src/components/GraphEditor.vue Outdated Show resolved Hide resolved
app/gui2/src/components/GraphEditor/GraphEdges.vue Outdated Show resolved Hide resolved
app/gui2/src/components/GraphEditor.vue Outdated Show resolved Hide resolved
app/gui2/src/components/GraphEditor/GraphEdges.vue Outdated Show resolved Hide resolved
app/gui2/src/components/GraphEditor/GraphNode.vue Outdated Show resolved Hide resolved
app/gui2/src/providers/interactionHandler.ts Outdated Show resolved Hide resolved
app/gui2/src/stores/graph/index.ts Outdated Show resolved Hide resolved
</template>

<script>
export default {
Copy link
Contributor

Choose a reason for hiding this comment

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

This is an atypical component definition. Use <script setup lang="ts">.

@@ -0,0 +1,55 @@
<template>
<div class="parent">
Copy link
Contributor

Choose a reason for hiding this comment

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

looks like this is an unused class, and doesn't match component name. Use PlusButton class here, as it makes tests and debugging easier if we keep that convention everywhere.

Comment on lines 10 to 17
singleClickTimer = setTimeout(() => {
clickCount = 0
// If within proper time range, consider it as fast click
if (Date.now() - lastClickTime >= timeBetweenClicks) {
onClick()
}
lastClickTime = Date.now()
}, timeBetweenClicks)
Copy link
Contributor

Choose a reason for hiding this comment

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

This logic seems wrong to me, as lastClickTime is set within the timer callback only. Isn't it true that if the timer callback was allowed to execute in the first place, then the event wasn't a double-click?

Also, delaying a click handler just to allow for doubleclick action is a really bad UX. The doubleclick can only really be used in cases where the first click handler can be executed immediately anyway, e.g. allowing the node to be selected, only then to start editing it after second click. In your case, I believe it would mean first click starts edge drag, but then subsequent doubleclick simply "overrides" that action with edge creation and predefined position.

Also for handling that, you can use builtin events instead of relying on your own timer. For example, a click provides a detail field, which tells you about which click in a sequence it is (1 for first, 2 for doubleclick etc.). There is also a dedicated dblclick event, though I'd rather use the detail field instead of two handlers (because click will fire again together with dblclick).

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've removed the delay for now as for my use case it is not relevant either way.

It seems detail does not work for pointerdown events, as it is always zero. So I left this to support usage in those events.

…ting-node-(+-button,-dragging-out-edges)

# Conflicts:
#	app/gui2/src/components/GraphEditor.vue
#	app/gui2/src/components/GraphEditor/GraphEdges.vue
#	app/gui2/src/stores/graph/index.ts
@MichaelMauderer MichaelMauderer force-pushed the wip/MichaelMauderer/gui2/All-ways-of-creating-node-(+-button,-dragging-out-edges) branch from 87c1013 to d6cc6af Compare November 23, 2023 16:37
@MichaelMauderer MichaelMauderer added the CI: Ready to merge This PR is eligible for automatic merge label Nov 23, 2023
@mergify mergify bot merged commit 76fb9f5 into develop Nov 23, 2023
30 of 33 checks passed
@mergify mergify bot deleted the wip/MichaelMauderer/gui2/All-ways-of-creating-node-(+-button,-dragging-out-edges) branch November 23, 2023 17:47
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.

All ways of creating node (+ button, dragging out edges)
3 participants