mirror of
https://github.com/scratchfoundation/scratch-paint.git
synced 2025-01-09 14:12:13 -05:00
Don't enable if there is nothing in the editor
This commit is contained in:
parent
3ab1067c65
commit
e4ca0482b8
3 changed files with 11 additions and 1 deletions
|
@ -151,11 +151,13 @@ const ModeToolsComponent = props => {
|
||||||
</InputGroup>
|
</InputGroup>
|
||||||
<InputGroup className={classNames(styles.modLabeledIconHeight)}>
|
<InputGroup className={classNames(styles.modLabeledIconHeight)}>
|
||||||
<LabeledIconButton
|
<LabeledIconButton
|
||||||
|
disabled={!props.hasItems}
|
||||||
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.hasItems}
|
||||||
imgSrc={flipVerticalIcon}
|
imgSrc={flipVerticalIcon}
|
||||||
title={props.intl.formatMessage(messages.flipVertical)}
|
title={props.intl.formatMessage(messages.flipVertical)}
|
||||||
onClick={props.onFlipVertical}
|
onClick={props.onFlipVertical}
|
||||||
|
@ -176,6 +178,7 @@ ModeToolsComponent.propTypes = {
|
||||||
className: PropTypes.string,
|
className: PropTypes.string,
|
||||||
clipboardItems: PropTypes.arrayOf(PropTypes.array),
|
clipboardItems: PropTypes.arrayOf(PropTypes.array),
|
||||||
eraserValue: PropTypes.number,
|
eraserValue: PropTypes.number,
|
||||||
|
hasItems: PropTypes.bool,
|
||||||
hasSelectedUncurvedPoints: PropTypes.bool,
|
hasSelectedUncurvedPoints: PropTypes.bool,
|
||||||
hasSelectedUnpointedPoints: PropTypes.bool,
|
hasSelectedUnpointedPoints: PropTypes.bool,
|
||||||
intl: intlShape.isRequired,
|
intl: intlShape.isRequired,
|
||||||
|
|
|
@ -7,7 +7,8 @@ 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, getAllRootItems} from '../helper/selection';
|
import {clearSelection, getSelectedLeafItems, getSelectedRootItems} from '../helper/selection';
|
||||||
|
import {getAllRootItems, getAllSelectableRootItems} 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 {
|
||||||
|
@ -16,6 +17,7 @@ class ModeTools extends React.Component {
|
||||||
bindAll(this, [
|
bindAll(this, [
|
||||||
'_getSelectedUncurvedPoints',
|
'_getSelectedUncurvedPoints',
|
||||||
'_getSelectedUnpointedPoints',
|
'_getSelectedUnpointedPoints',
|
||||||
|
'hasItems',
|
||||||
'hasSelectedUncurvedPoints',
|
'hasSelectedUncurvedPoints',
|
||||||
'hasSelectedUnpointedPoints',
|
'hasSelectedUnpointedPoints',
|
||||||
'handleCopyToClipboard',
|
'handleCopyToClipboard',
|
||||||
|
@ -68,6 +70,9 @@ class ModeTools extends React.Component {
|
||||||
const points = this._getSelectedUnpointedPoints();
|
const points = this._getSelectedUnpointedPoints();
|
||||||
return points.length > 0;
|
return points.length > 0;
|
||||||
}
|
}
|
||||||
|
hasItems () {
|
||||||
|
return getAllSelectableRootItems().length > 0;
|
||||||
|
}
|
||||||
handleCurvePoints () {
|
handleCurvePoints () {
|
||||||
let changed;
|
let changed;
|
||||||
const points = this._getSelectedUncurvedPoints();
|
const points = this._getSelectedUncurvedPoints();
|
||||||
|
@ -203,6 +208,7 @@ class ModeTools extends React.Component {
|
||||||
render () {
|
render () {
|
||||||
return (
|
return (
|
||||||
<ModeToolsComponent
|
<ModeToolsComponent
|
||||||
|
hasItems={this.hasItems()}
|
||||||
hasSelectedUncurvedPoints={this.hasSelectedUncurvedPoints()}
|
hasSelectedUncurvedPoints={this.hasSelectedUncurvedPoints()}
|
||||||
hasSelectedUnpointedPoints={this.hasSelectedUnpointedPoints()}
|
hasSelectedUnpointedPoints={this.hasSelectedUnpointedPoints()}
|
||||||
onCopyToClipboard={this.handleCopyToClipboard}
|
onCopyToClipboard={this.handleCopyToClipboard}
|
||||||
|
|
|
@ -400,6 +400,7 @@ const shouldShowSelectAll = function () {
|
||||||
export {
|
export {
|
||||||
getItems,
|
getItems,
|
||||||
getAllRootItems,
|
getAllRootItems,
|
||||||
|
getAllSelectableRootItems,
|
||||||
selectAllItems,
|
selectAllItems,
|
||||||
selectAllSegments,
|
selectAllSegments,
|
||||||
clearSelection,
|
clearSelection,
|
||||||
|
|
Loading…
Reference in a new issue