This commit is contained in:
DD 2018-01-25 11:33:43 -05:00
parent 1ff5fdff38
commit 3ab1067c65
2 changed files with 9 additions and 5 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,13 @@ class ModeTools extends React.Component {
} }
} }
_handleFlip (horizontalScale, verticalScale) { _handleFlip (horizontalScale, verticalScale) {
const selectedItems = getSelectedRootItems(); let selectedItems = getSelectedRootItems();
let center;
if (selectedItems.length === 0) {
// If nothing is selected, flip everything over the rotation point
selectedItems = getAllRootItems();
center = paper.view.center;
}
// 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;
@ -146,7 +152,7 @@ class ModeTools extends React.Component {
// Group items so that they flip as a unit // Group items so that they flip as a unit
const itemGroup = new paper.Group(selectedItems); const itemGroup = new paper.Group(selectedItems);
// Flip // Flip
itemGroup.scale(horizontalScale, verticalScale); itemGroup.scale(horizontalScale, verticalScale, center);
ensureClockwise(itemGroup); ensureClockwise(itemGroup);
// Remove flipped item from group and insert at old index. Must insert from bottom index up. // Remove flipped item from group and insert at old index. Must insert from bottom index up.