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

Add slider for free rotate #50

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
3 changes: 1 addition & 2 deletions __tests__/MiradorImageTools.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ describe('MiradorImageTools', () => {
it('renders ImageRotation', () => {
createWrapper();

expect(screen.getByRole('button', { name: 'rotateLeft' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: 'rotateRight' })).toBeInTheDocument();
expect(screen.getByRole('button', { name: 'rotation' })).toBeInTheDocument();
});
it('renders ImageFlip', () => {
createWrapper();
Expand Down
24 changes: 0 additions & 24 deletions src/plugins/ImageRotation.js

This file was deleted.

34 changes: 14 additions & 20 deletions src/plugins/MiradorImageTools.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import InvertColorsIcon from '@mui/icons-material/InvertColors';
import TuneSharpIcon from '@mui/icons-material/TuneSharp';
import CloseSharpIcon from '@mui/icons-material/CloseSharp';
import ReplaySharpIcon from '@mui/icons-material/ReplaySharp';
import LinearScaleIcon from '@mui/icons-material/LinearScale';
import { styled, alpha } from '@mui/material/styles';
import MiradorMenuButton from 'mirador/dist/es/src/containers/MiradorMenuButton';
import ImageTool from './ImageTool';
import ImageRotation from './ImageRotation';
import ImageFlip from './ImageFlip';

const SizeContainer = styled('div')(() => ({
Expand Down Expand Up @@ -78,7 +78,6 @@ class MiradorImageTools extends Component {
constructor(props) {
super(props);
this.toggleState = this.toggleState.bind(this);
this.toggleRotate = this.toggleRotate.bind(this);
this.toggleFlip = this.toggleFlip.bind(this);
this.handleChange = this.handleChange.bind(this);
this.handleReset = this.handleReset.bind(this);
Expand Down Expand Up @@ -148,14 +147,6 @@ class MiradorImageTools extends Component {
updateWindow(windowId, { imageToolsOpen: !open });
}

toggleRotate(value) {
const { updateViewport, viewConfig: { flip = false, rotation = 0 }, windowId } = this.props;

const offset = flip ? -1 * value : value;

updateViewport(windowId, { rotation: (rotation + offset) % 360 });
}

toggleFlip() {
const { updateViewport, viewConfig: { flip = false }, windowId } = this.props;

Expand All @@ -166,6 +157,7 @@ class MiradorImageTools extends Component {
const {
enabled, open, viewer, windowId,
viewConfig: {
rotation = 0,
flip = false,
brightness = 100,
contrast = 100,
Expand Down Expand Up @@ -201,16 +193,18 @@ class MiradorImageTools extends Component {
&& (
<React.Fragment>
<ToolContainer>
<ImageRotation
label={t('rotateRight')}
onClick={() => this.toggleRotate(90)}
variant="right"
/>
<ImageRotation
label={t('rotateLeft')}
onClick={() => this.toggleRotate(-90)}
variant="left"
/>
<ImageTool
type="rotation"
label={t('rotation')}
min={-180}
max={180}
windowId={windowId}
value={rotation}
onChange={this.handleChange('rotation')}
small={isSmallDisplay}
>
<LinearScaleIcon />
</ImageTool>
<ImageFlip
label={t('flip')}
onClick={this.toggleFlip}
Expand Down
24 changes: 8 additions & 16 deletions src/translations.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ const translations = {
hide: 'Bildbearbeitung verbergen',
invert: 'Umkehrung der Farben',
revert: 'Einstellungen zurücksetzen',
rotateLeft: 'Rotation links',
rotateRight: 'Rotation rechts',
rotation: 'Rotation',
saturation: 'Sättigung',
show: 'Bildbearbeitung anzeigen',
},
Expand All @@ -24,8 +23,7 @@ const translations = {
hide: 'Hide image tools',
invert: 'Invert colors',
revert: 'Revert image',
rotateLeft: 'Rotate left',
rotateRight: 'Rotate right',
rotation: 'Rotate',
saturation: 'Saturation',
show: 'Show image tools',
},
Expand All @@ -39,8 +37,7 @@ const translations = {
hide: 'Nascondi gli strumenti dell\'immagine',
invert: 'Inverti colori',
revert: 'Ripristinare l\'immagine',
rotateLeft: 'Ruota a sinistra',
rotateRight: 'Ruota a destra',
rotation: 'Ruota',
saturation: 'Saturazione',
show: 'Mostra gli strumenti dell\'immagine',
},
Expand All @@ -54,8 +51,7 @@ const translations = {
hide: 'Masquer les outils d\'image',
invert: 'Inverser les couleurs',
revert: 'Réinitialiser les réglages',
rotateLeft: 'Rotation vers la gauche',
rotateRight: 'Rotation vers la droite',
rotation: 'Rotation',
saturation: 'Saturation',
show: 'Afficher les outils d\'image',
},
Expand All @@ -69,8 +65,7 @@ const translations = {
hide: '画像ツールを隠す',
invert: '色を反転',
revert: '元に戻す',
rotateLeft: '左回転',
rotateRight: '右回転',
rotation: '旋回',
saturation: '彩度',
show: '画像ツールを表示',
},
Expand All @@ -84,8 +79,7 @@ const translations = {
hide: 'Сакријте алат',
invert: 'Инверзија боја',
revert: 'Поништи подешавања',
rotateLeft: 'Ротирај лево',
rotateRight: 'Ротирај десно',
rotation: 'Ротирај',
saturation: 'Сатурација',
show: 'Прикажите алат',
},
Expand All @@ -99,8 +93,7 @@ const translations = {
hide: '隐藏图像工具',
invert: '反转颜色',
revert: '还原图像',
rotateLeft: '向左旋转',
rotateRight: '向右旋转',
rotation: '向左旋转',
saturation: '饱和度',
show: '显示图像工具',
},
Expand All @@ -114,8 +107,7 @@ const translations = {
hide: '隱藏圖像工具',
invert: '反轉顏色',
revert: '還原圖像',
rotateLeft: '向左旋轉',
rotateRight: '向右旋轉',
rotation: '向左旋轉',
saturation: '飽和度',
show: '顯示圖像工具',
},
Expand Down