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

Code editor open-close improvements #9365

Merged
merged 9 commits into from
Mar 14, 2024
Merged

Conversation

vitvakatu
Copy link
Contributor

Pull Request Description

Closes #9209

code-editor-open-close.mp4
  • Added new menu item Code editor which toggles visibility of, well, code editor
  • Changed the menu implementation:
    • Fixed platform-dependent “More” icon. It was displayed awfully on Mac.
    • Added simple opacity animation.
    • Reduced width slightly.
    • Refactored the layout, removed unused classes and CSS…
    • Added animated background when hovering “Show all” icon
  • Added close button to the upper left corner of the code editor (upper right is occupied by resize controls)

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.

@vitvakatu vitvakatu added CI: No changelog needed Do not require a changelog entry for this PR. x-new-feature Type: new feature request -gui labels Mar 11, 2024
@vitvakatu vitvakatu self-assigned this Mar 11, 2024
</script>

<template>
<div class="ExtendedMenu">
<div class="moreIcon" @pointerdown="isDropdownOpen = !isDropdownOpen"></div>
<div class="moreIcon" @pointerdown="isDropdownOpen = !isDropdownOpen"></div>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We would need an icon for that, but for now rotated ellipsis looks good IMO.

Copy link
Contributor

Choose a reason for hiding this comment

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

Again I think this should already be using an svg icon.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Replaced with SVG

@@ -347,6 +349,7 @@ const editorStyle = computed(() => {
<circle cx="14" cy="14" r="1.5" />
</svg>
</div>
<div class="closeButton button" @click="emit('close')">+</div>
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 really like drawing things with strings, lol. But we would also need an icon here in the future.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd rather see an actual placeholder svg icon already being used here (either reuse one of the existing ones, or make a placeholder one), so no styling will need to be adjusted later once an actual icon is prepared.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Replaced with SVG

@farmaazon farmaazon removed the request for review from MichaelMauderer March 12, 2024 08:07
</script>

<template>
<div class="ExtendedMenu">
<div class="moreIcon" @pointerdown="isDropdownOpen = !isDropdownOpen"></div>
<div class="moreIcon" @pointerdown="isDropdownOpen = !isDropdownOpen"></div>
Copy link
Contributor

Choose a reason for hiding this comment

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

Since it is not displayed as an ellipsis but rotated by CSS into the intended shape, I think it would be clearer to use CSS to inject the ellipsis character with :before.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Replaced with SVg

@pointerdown="emit('fitToAllClicked')"
/>
</div>
<div class="row clickableRow" @pointerdown.stop="emit('toggleCodeEditor')">
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems like we should .stop the pointerdown/pointerup/click events at the root element of the dropdown, and I think attaching these handlers to click would be more consistent with the way we're handling buttons now.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah those should be clicks. We should only use pointerdown in situations where we are dealing with drag interactions, so we need more control than what click provides.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Replaced with click handlers

@@ -347,6 +349,7 @@ const editorStyle = computed(() => {
<circle cx="14" cy="14" r="1.5" />
</svg>
</div>
<div class="closeButton button" @click="emit('close')">+</div>
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd rather see an actual placeholder svg icon already being used here (either reuse one of the existing ones, or make a placeholder one), so no styling will need to be adjusted later once an actual icon is prepared.

@pointerdown="emit('fitToAllClicked')"
/>
</div>
<div class="row clickableRow" @pointerdown.stop="emit('toggleCodeEditor')">
Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah those should be clicks. We should only use pointerdown in situations where we are dealing with drag interactions, so we need more control than what click provides.

const emit = defineEmits<{ zoomIn: []; zoomOut: []; fitToAllClicked: [] }>()
const emit = defineEmits<{ zoomIn: []; zoomOut: []; fitToAllClicked: []; toggleCodeEditor: [] }>()

const toggleCodeEditorShortcut = isMacLike ? 'Cmd + `' : 'Ctrl + `'
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of hardcoding this shortcut string, let's add a new method to the object returned from defineKeybinds, so that we can read the shortcuts by action name. Then this could be something like codeEditorBindings.displayBinding('toggle').

Copy link
Contributor

Choose a reason for hiding this comment

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

AFAIK, it's not so easy to add the function, as it parses the string and changes the representation.

@vitvakatu If refactoring defineKeybinds would take more than a day, let's make a follow-up issue and add TODO with link here.

When implemented, the function returning keybinds should be also used in area selection unit tests.

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 added the API itself, but I want it to use type information (knowing the list of shortcuts which are actually set). Added a TODO for now, to not block this PR.

</script>

<template>
<div class="ExtendedMenu">
<div class="moreIcon" @pointerdown="isDropdownOpen = !isDropdownOpen"></div>
<div class="moreIcon" @pointerdown="isDropdownOpen = !isDropdownOpen"></div>
Copy link
Contributor

Choose a reason for hiding this comment

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

Again I think this should already be using an svg icon.

@vitvakatu vitvakatu requested a review from Frizi March 14, 2024 08:31
@vitvakatu vitvakatu added the CI: Ready to merge This PR is eligible for automatic merge label Mar 14, 2024
@mergify mergify bot merged commit b33079e into develop Mar 14, 2024
39 of 41 checks passed
@mergify mergify bot deleted the wip/vitvakatu/code-editor-close branch March 14, 2024 17:05
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 x-new-feature Type: new feature request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Code Editor Open/Close enhancements
4 participants