Merge pull request #268 from fsih/flipAll

Flip all
This commit is contained in:
DD Liu 2018-01-30 15:57:30 -05:00 committed by GitHub
commit 0a308e8e44
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 4 deletions

View file

@ -151,13 +151,11 @@ const ModeToolsComponent = props => {
</InputGroup> </InputGroup>
<InputGroup className={classNames(styles.modLabeledIconHeight)}> <InputGroup className={classNames(styles.modLabeledIconHeight)}>
<LabeledIconButton <LabeledIconButton
disabled={!props.selectedItems.length}
imgSrc={flipHorizontalIcon} imgSrc={flipHorizontalIcon}
title={props.intl.formatMessage(messages.flipHorizontal)} title={props.intl.formatMessage(messages.flipHorizontal)}
onClick={props.onFlipHorizontal} onClick={props.onFlipHorizontal}
/> />
<LabeledIconButton <LabeledIconButton
disabled={!props.selectedItems.length}
imgSrc={flipVerticalIcon} imgSrc={flipVerticalIcon}
title={props.intl.formatMessage(messages.flipVertical)} title={props.intl.formatMessage(messages.flipVertical)}
onClick={props.onFlipVertical} onClick={props.onFlipVertical}

View file

@ -7,7 +7,7 @@ import bindAll from 'lodash.bindall';
import ModeToolsComponent from '../components/mode-tools/mode-tools.jsx'; import ModeToolsComponent from '../components/mode-tools/mode-tools.jsx';
import {clearSelectedItems, setSelectedItems} from '../reducers/selected-items'; import {clearSelectedItems, setSelectedItems} from '../reducers/selected-items';
import {incrementPasteOffset, setClipboardItems} from '../reducers/clipboard'; import {incrementPasteOffset, setClipboardItems} from '../reducers/clipboard';
import {clearSelection, getSelectedLeafItems, getSelectedRootItems} from '../helper/selection'; import {clearSelection, getSelectedLeafItems, getSelectedRootItems, getAllRootItems} from '../helper/selection';
import {HANDLE_RATIO, ensureClockwise} from '../helper/math'; import {HANDLE_RATIO, ensureClockwise} from '../helper/math';
class ModeTools extends React.Component { class ModeTools extends React.Component {
@ -137,7 +137,11 @@ class ModeTools extends React.Component {
} }
} }
_handleFlip (horizontalScale, verticalScale) { _handleFlip (horizontalScale, verticalScale) {
const selectedItems = getSelectedRootItems(); let selectedItems = getSelectedRootItems();
if (selectedItems.length === 0) {
// If nothing is selected, select everything
selectedItems = getAllRootItems();
}
// Record old indices // Record old indices
for (const item of selectedItems) { for (const item of selectedItems) {
item.data.index = item.index; item.data.index = item.index;