-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[3981] Add the last used tool entry in the palette
Bug: #3981 Signed-off-by: Florian Barbin <[email protected]>
- Loading branch information
1 parent
32f8298
commit 955a924
Showing
12 changed files
with
161 additions
and
86 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
69 changes: 69 additions & 0 deletions
69
.../frontend/sirius-components-diagrams/src/renderer/palette/tool-list-item/ToolListItem.tsx
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,69 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2024 Obeo. | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Obeo - initial API and implementation | ||
*******************************************************************************/ | ||
|
||
import { IconOverlay } from '@eclipse-sirius/sirius-components-core'; | ||
import ListItemButton from '@mui/material/ListItemButton'; | ||
import ListItemIcon from '@mui/material/ListItemIcon'; | ||
import ListItemText from '@mui/material/ListItemText'; | ||
import Tooltip from '@mui/material/Tooltip'; | ||
import { makeStyles } from 'tss-react/mui'; | ||
import { GQLTool } from '../Palette.types'; | ||
import { usePaletteEntryTooltip } from '../usePaletteEntryTooltip'; | ||
import { ToolListItemProps } from './ToolListItem.types'; | ||
const useStyle = makeStyles()((theme) => ({ | ||
toolListContainer: { | ||
display: 'grid', | ||
overflowY: 'auto', | ||
overflowX: 'hidden', | ||
gridTemplateColumns: '100%', | ||
}, | ||
toolList: { | ||
gridRowStart: 1, | ||
gridColumnStart: 1, | ||
width: '100%', | ||
padding: 0, | ||
}, | ||
listItemText: { | ||
'& .MuiListItemText-primary': { | ||
whiteSpace: 'nowrap', | ||
overflow: 'hidden', | ||
textOverflow: 'ellipsis', | ||
}, | ||
}, | ||
listItemButton: { | ||
paddingTop: 0, | ||
paddingBottom: 0, | ||
}, | ||
listItemIcon: { | ||
minWidth: 0, | ||
marginRight: theme.spacing(2), | ||
}, | ||
})); | ||
export const ToolListItem = ({ tool, onToolClick }: ToolListItemProps) => { | ||
const { classes } = useStyle(); | ||
const { tooltipEnterDelay, tooltipPlacement } = usePaletteEntryTooltip(); | ||
const handleToolClick = (event: React.MouseEvent<HTMLDivElement, MouseEvent>, tool: GQLTool) => { | ||
event.stopPropagation(); | ||
onToolClick(tool); | ||
}; | ||
return ( | ||
<Tooltip enterDelay={tooltipEnterDelay} placement={tooltipPlacement} title={tool.label} key={'tooltip_' + tool.id}> | ||
<ListItemButton className={classes.listItemButton} onClick={(event) => handleToolClick(event, tool)}> | ||
<ListItemIcon className={classes.listItemIcon}> | ||
<IconOverlay iconURL={tool.iconURL} alt={tool.label} customIconHeight={16} customIconWidth={16} /> | ||
</ListItemIcon> | ||
<ListItemText primary={tool.label} className={classes.listItemText} /> | ||
</ListItemButton> | ||
</Tooltip> | ||
); | ||
}; |
18 changes: 18 additions & 0 deletions
18
...tend/sirius-components-diagrams/src/renderer/palette/tool-list-item/ToolListItem.types.ts
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,18 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2024 Obeo. | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Obeo - initial API and implementation | ||
*******************************************************************************/ | ||
|
||
import { GQLTool } from '../Palette.types'; | ||
export interface ToolListItemProps { | ||
tool: GQLTool; | ||
onToolClick: (tool: GQLTool) => void; | ||
} |
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
File renamed without changes.
File renamed without changes.