Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/Annotator/reducers/general-reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,9 @@ export default (state, action) => {
return produce(
modifyRegion(polygon, {
points: polygon.points.slice(0, -1),
editingLabels: true,
open: false,
}),
s => {s.mode = null}
s => {s.mode = {mode: "CLOSE_POLYGON", regionId: polygon.id}}
)
} else {
state = saveToHistory(state, i18next.t("move.polypoint"))
Expand Down Expand Up @@ -319,7 +318,8 @@ export default (state, action) => {
case "MOVE_POLYGON_POINT": {
return {...state, mode: null}
}
case "MOVE_LINE_POINT": {
case "MOVE_LINE_POINT":
case "CLOSE_POLYGON": {
return produce(
modifyRegion(state.mode.regionId, { editingLabels: true }),
s => {s.mode = null}
Expand Down
4 changes: 4 additions & 0 deletions src/Localization/translation-de-DE.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ const translationDeDE = {
"menu.classifications": "Klassifizierungen",
"menu.history": "Verlauf",
"menu.regions": "Regionen",
"regions.lock.all": "Alle sperren",
"regions.unlock.all": "Alle entsperren",
"regions.hide.all": "Alle ausblenden",
"regions.show.all": "Alle einblenden",
"error.image": "Bild konnte nicht geladen werden.",
"no.history": "Kein Verlauf vorhanden",
"desc.class": "Klassen",
Expand Down
4 changes: 4 additions & 0 deletions src/Localization/translation-en-EN.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ const translationEnEN = {
"menu.classifications": "Classifications",
"menu.history": "History",
"menu.regions": "Regions",
"regions.lock.all": "Lock all",
"regions.unlock.all": "Unlock all",
"regions.hide.all": "Hide all",
"regions.show.all": "Show all",
"error.image": "Could not load image",
"no.history": "No History Yet",
"desc.class": "Class",
Expand Down
37 changes: 36 additions & 1 deletion src/RegionSelectorSidebarBox/index.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
// @flow

import {memo} from "react"
import {memo, useState} from "react"
import SidebarBoxContainer from "../SidebarBoxContainer"
import {createTheme, styled, ThemeProvider} from "@mui/material/styles"
import {grey} from "@mui/material/colors"
import RegionIcon from "@mui/icons-material/PictureInPicture"
import Grid from "@mui/material/Grid"
import Button from "@mui/material/Button"
import TrashIcon from "@mui/icons-material/Delete"
import LockIcon from "@mui/icons-material/Lock"
import UnlockIcon from "@mui/icons-material/LockOpen"
Expand All @@ -22,6 +23,7 @@ const theme = createTheme()

const ChipSpan = styled('span')(() => styles.chip)
const RowDiv = styled('div')(() => styles.row)
const ButtonRowDiv = styled('div')(() => styles.buttonRow)
const ContainerDiv = styled('div')(() => styles.container)

const Chip = ({color, text}) => {
Expand Down Expand Up @@ -161,6 +163,21 @@ export const RegionSelectorSidebarBox = ({

const {t} = useTranslation();

const [allLocked, setAllLocked] = useState(false)
const [allHidden, setAllHidden] = useState(false)

const toggleLockAll = () => {
const next = !allLocked
setAllLocked(next)
regions.forEach((r) => onChangeRegion({...r, locked: next}))
}

const toggleHideAll = () => {
const next = !allHidden
setAllHidden(next)
regions.forEach((r) => onChangeRegion({...r, visible: !next}))
}

return (
<ThemeProvider theme={theme}>
<SidebarBoxContainer
Expand All @@ -171,6 +188,24 @@ export const RegionSelectorSidebarBox = ({
noScroll={true}
>
<ContainerDiv>
<ButtonRowDiv>
<Button
className="batchButton"
size="small"
onClick={toggleLockAll}
startIcon={allLocked ? <UnlockIcon /> : <LockIcon />}
>
{allLocked ? t("regions.unlock.all") : t("regions.lock.all")}
</Button>
<Button
className="batchButton"
size="small"
onClick={toggleHideAll}
startIcon={allHidden ? <VisibleIcon /> : <VisibleOffIcon />}
>
{allHidden ? t("regions.show.all") : t("regions.hide.all")}
</Button>
</ButtonRowDiv>
{regions.map((r, i) => (
<MemoRow
key={r.id}
Expand Down
19 changes: 19 additions & 0 deletions src/RegionSelectorSidebarBox/styles.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,25 @@ export default {
},
},
},
buttonRow: {
display: "flex",
flexDirection: "row",
gap: 4,
padding: 4,
borderBottom: `1px solid ${grey[200]}`,
"& .batchButton": {
flex: 1,
fontSize: 11,
fontWeight: "bold",
color: grey[700],
textTransform: "none",
minWidth: 0,
"& .MuiButton-startIcon > svg": {
width: 16,
height: 16,
},
},
},
row: {
padding: 4,
cursor: "pointer",
Expand Down