-
Notifications
You must be signed in to change notification settings - Fork 326
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Context menu, copy button, multi-component actions
- The 'More' menu can now be opened under the mouse, through the context menu action (right click/control-click on Mac/menu button on keyboard). - Add copy-components button to menu. - The menu can now be opened while multiple components are selected; if the clicked component was among the selected components, the selection will be preserved. Some menu actions--currently *copy* and *delete*, apply to all selected components. These actions will change their displayed labels when multiple components are selected. If a single-component action is executed, the component it was applied to will become the sole selection.
- Loading branch information
Showing
35 changed files
with
968 additions
and
410 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
app/gui/src/project-view/components/ComponentActionButton.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<script setup lang="ts"> | ||
import MenuButton from '@/components/MenuButton.vue' | ||
import SvgIcon from '@/components/SvgIcon.vue' | ||
import { type ComponentAction } from '@/util/componentActions' | ||
const { action } = defineProps<{ action: ComponentAction }>() | ||
</script> | ||
|
||
<template> | ||
<!-- eslint-disable vue/no-mutating-props -- `ComponentAction` is an internally-reactive object. --> | ||
<MenuButton | ||
:data-testid="action.testid" | ||
:disabled="action.disabled" | ||
class="ComponentActionButton" | ||
v-bind="action.state != null ? { modelValue: action.state } : {}" | ||
@update:modelValue="action.state != null && (action.state = $event)" | ||
@click="action.action" | ||
> | ||
<!-- eslint-enable vue/no-mutating-props --> | ||
<SvgIcon :name="action.icon" class="rowIcon" /> | ||
<span v-text="action.description" /> | ||
<span v-if="action.shortcut" class="shortcutHint" v-text="action.shortcut" /> | ||
</MenuButton> | ||
</template> | ||
|
||
<style scoped> | ||
.ComponentActionButton { | ||
display: flex; | ||
align-items: center; | ||
justify-content: left; | ||
padding-left: 8px; | ||
padding-right: 8px; | ||
} | ||
.rowIcon { | ||
display: inline-block; | ||
margin-right: 8px; | ||
} | ||
.shortcutHint { | ||
margin-left: auto; | ||
padding-left: 2em; | ||
opacity: 0.8; | ||
} | ||
</style> |
49 changes: 49 additions & 0 deletions
49
app/gui/src/project-view/components/ComponentContextMenu.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<script setup lang="ts"> | ||
import ComponentActionButton from '@/components/ComponentActionButton.vue' | ||
import MenuPanel from '@/components/MenuPanel.vue' | ||
import { injectSelectionActions } from '@/providers/selectionActions' | ||
import { injectComponentActions } from '@/util/componentActions' | ||
const emit = defineEmits<{ close: [] }>() | ||
const componentActions = injectComponentActions() | ||
const { actions: selectionActions } = injectSelectionActions() | ||
const componentActionButtons: (keyof typeof componentActions)[] = [ | ||
'toggleDocPanel', | ||
'toggleVisualization', | ||
'createNewNode', | ||
'editingComment', | ||
'recompute', | ||
'pickColor', | ||
'enterNode', | ||
'startEditing', | ||
] | ||
const selectionActionButtons: (keyof typeof selectionActions)[] = ['copy', 'deleteSelected'] | ||
</script> | ||
|
||
<template> | ||
<MenuPanel class="ComponentContextMenu" @contextmenu.stop.prevent="emit('close')"> | ||
<ComponentActionButton | ||
v-for="action in componentActionButtons" | ||
:key="`component:${action}`" | ||
:action="componentActions[action]" | ||
@click.stop="emit('close')" | ||
/> | ||
<ComponentActionButton | ||
v-for="action in selectionActionButtons" | ||
:key="`selection:${action}`" | ||
:action="selectionActions[action]" | ||
@click.stop="emit('close')" | ||
/> | ||
</MenuPanel> | ||
</template> | ||
|
||
<style scoped> | ||
.MenuPanel { | ||
margin-top: 2px; | ||
padding: 4px; | ||
background: var(--dropdown-opened-background, var(--color-app-bg)); | ||
backdrop-filter: var(--dropdown-opened-backdrop-filter, var(--blur-app-bg)); | ||
} | ||
</style> |
Oops, something went wrong.