Update src/components/mode-tools/mode-tools.jsx
Browse files- src/components/mode-tools/mode-tools.jsx +976 -976
src/components/mode-tools/mode-tools.jsx
CHANGED
@@ -1,976 +1,976 @@
|
|
1 |
-
/* eslint-disable no-case-declarations */
|
2 |
-
import classNames from 'classnames';
|
3 |
-
import { connect } from 'react-redux';
|
4 |
-
import PropTypes from 'prop-types';
|
5 |
-
import React from 'react';
|
6 |
-
|
7 |
-
import Dropdown from '../dropdown/dropdown.jsx';
|
8 |
-
import MediaQuery from 'react-responsive';
|
9 |
-
import layout from '../../lib/layout-constants';
|
10 |
-
|
11 |
-
import { changeBrushSize, changeSimplifySize, setBrushType } from '../../reducers/brush-mode';
|
12 |
-
import { changeBrushSize as changeEraserSize, changeSimplifySize as changeEraserSimplifySize } from '../../reducers/eraser-mode';
|
13 |
-
import { changeSimplifySize as changePenSimplifySize } from '../../reducers/pen-mode';
|
14 |
-
import { changeRoundedRectCornerSize } from '../../reducers/rounded-rect-mode';
|
15 |
-
import { changeRoundedCornerSize } from '../../reducers/rect-mode';
|
16 |
-
import { changeTrianglePolyCount, changeTrianglePointCount } from '../../reducers/triangle-mode';
|
17 |
-
import { changeCurrentlySelectedShape } from '../../reducers/sussy-mode';
|
18 |
-
import { changeBitBrushSize } from '../../reducers/bit-brush-size';
|
19 |
-
import { changeBitEraserSize } from '../../reducers/bit-eraser-size';
|
20 |
-
import { setShapesFilled } from '../../reducers/fill-bitmap-shapes';
|
21 |
-
import { setTextAlignment } from '../../reducers/text-alignment';
|
22 |
-
|
23 |
-
import FontDropdown from '../../containers/font-dropdown.jsx';
|
24 |
-
import LiveInputHOC from '../forms/live-input-hoc.jsx';
|
25 |
-
import Label from '../forms/label.jsx';
|
26 |
-
import { defineMessages, injectIntl, intlShape } from 'react-intl';
|
27 |
-
import Input from '../forms/input.jsx';
|
28 |
-
import InputGroup from '../input-group/input-group.jsx';
|
29 |
-
import ButtonGroup from '../button-group/button-group.jsx';
|
30 |
-
import Button from '../button/button.jsx';
|
31 |
-
import LabeledIconButton from '../labeled-icon-button/labeled-icon-button.jsx';
|
32 |
-
import Modes from '../../lib/modes';
|
33 |
-
import Formats, { isBitmap, isVector } from '../../lib/format';
|
34 |
-
import { hideLabel } from '../../lib/hide-label';
|
35 |
-
import styles from './mode-tools.css';
|
36 |
-
import { MAX_STROKE_WIDTH } from '../../reducers/stroke-width';
|
37 |
-
import {
|
38 |
-
selectableShapes as sussyToolShapes,
|
39 |
-
categories as sussyToolCategories,
|
40 |
-
generateShapeSVG as generateSussyShapeSVG,
|
41 |
-
categorizeShapes as categorizeSussyShapes,
|
42 |
-
} from '../../helper/selectable-shapes.js';
|
43 |
-
|
44 |
-
import copyIcon from './icons/copy.svg';
|
45 |
-
import cutIcon from './icons/cut.svg';
|
46 |
-
import pasteIcon from './icons/paste.svg';
|
47 |
-
import deleteIcon from './icons/delete.svg';
|
48 |
-
import roundLine from './icons/round-line.svg';
|
49 |
-
import squareLine from './icons/square-line.svg';
|
50 |
-
import miterLineJoin from './icons/miter-line-join.svg';
|
51 |
-
import roundLineJoin from './icons/round-line-join.svg';
|
52 |
-
import bevelLineJoin from './icons/bevel-line-join.svg';
|
53 |
-
import shapeMergeIcon from './icons/merge.svg';
|
54 |
-
import shapeMaskIcon from './icons/mask.svg';
|
55 |
-
import shapeSubtractIcon from './icons/subtract.svg';
|
56 |
-
import shapeFilterIcon from './icons/filter.svg';
|
57 |
-
import alignLeftIcon from './icons/alignLeft.svg';
|
58 |
-
import alignRightIcon from './icons/alignRight.svg';
|
59 |
-
import alignCenterIcon from './icons/alignCenter.svg';
|
60 |
-
import bitBrushIcon from '../bit-brush-mode/brush.svg';
|
61 |
-
import bitEraserIcon from '../bit-eraser-mode/eraser.svg';
|
62 |
-
import bitLineIcon from '../bit-line-mode/line.svg';
|
63 |
-
import brushIcon from '../brush-mode/brush.svg';
|
64 |
-
import curvedPointIcon from './icons/curved-point.svg';
|
65 |
-
import eraserIcon from '../eraser-mode/eraser.svg';
|
66 |
-
import roundedRectIcon from '../rounded-rect-mode/rounded-rectangle.svg';
|
67 |
-
import triangleIcon from '../triangle-mode/triangle.svg';
|
68 |
-
import triangleSpikeRatioIcon from './icons/triangle-spike-ratio.svg';
|
69 |
-
import flipHorizontalIcon from './icons/flip-horizontal.svg';
|
70 |
-
import flipVerticalIcon from './icons/flip-vertical.svg';
|
71 |
-
import centerSelectionIcon from './icons/centerSelection.svg';
|
72 |
-
import straightPointIcon from './icons/straight-point.svg';
|
73 |
-
import bitOvalIcon from '../bit-oval-mode/oval.svg';
|
74 |
-
import bitRectIcon from '../bit-rect-mode/rectangle.svg';
|
75 |
-
import bitOvalOutlinedIcon from '../bit-oval-mode/oval-outlined.svg';
|
76 |
-
import bitRectOutlinedIcon from '../bit-rect-mode/rectangle-outlined.svg';
|
77 |
-
|
78 |
-
const LiveInput = LiveInputHOC(Input);
|
79 |
-
const ModeToolsComponent = props => {
|
80 |
-
const messages = defineMessages({
|
81 |
-
brushSize: {
|
82 |
-
defaultMessage: 'Size',
|
83 |
-
description: 'Label for the brush size input',
|
84 |
-
id: 'paint.modeTools.brushSize'
|
85 |
-
},
|
86 |
-
brushSimplify: {
|
87 |
-
defaultMessage: 'Smoothing',
|
88 |
-
description: 'Label for the brush smoothing input, higher numbers control how much the drawn line will be corrected',
|
89 |
-
id: 'paint.modeTools.brushSimplify'
|
90 |
-
},
|
91 |
-
eraserSize: {
|
92 |
-
defaultMessage: 'Eraser size',
|
93 |
-
description: 'Label for the eraser size input',
|
94 |
-
id: 'paint.modeTools.eraserSize'
|
95 |
-
},
|
96 |
-
eraserSimplify: {
|
97 |
-
defaultMessage: 'Smoothing',
|
98 |
-
description: 'Label for the eraser smoothing input, higher numbers control how much the drawn line will be corrected',
|
99 |
-
id: 'paint.modeTools.eraserSimplify'
|
100 |
-
},
|
101 |
-
brushCircle: {
|
102 |
-
defaultMessage: 'Circle Brush',
|
103 |
-
description: 'Label for the circle brush shape',
|
104 |
-
id: 'paint.modeTools.circleSquare'
|
105 |
-
},
|
106 |
-
brushSquare: {
|
107 |
-
defaultMessage: 'Square Brush',
|
108 |
-
description: 'Label for the square brush shape',
|
109 |
-
id: 'paint.modeTools.brushSquare'
|
110 |
-
},
|
111 |
-
roundedCornerSize: {
|
112 |
-
defaultMessage: 'Rounded corner size',
|
113 |
-
description: 'Label for the Rounded corner size input',
|
114 |
-
id: 'paint.modeTools.roundedCornerSize'
|
115 |
-
},
|
116 |
-
currentSideCount: {
|
117 |
-
defaultMessage: 'Polygon side count',
|
118 |
-
description: 'Label for the Polygon side count input',
|
119 |
-
id: 'paint.modeTools.currentSideCount'
|
120 |
-
},
|
121 |
-
spokeRatio: {
|
122 |
-
defaultMessage: 'Star spoke ratio',
|
123 |
-
description: 'Label for the Star spoke ratio input, controls the size of the spokes on a star',
|
124 |
-
id: 'paint.modeTools.spikeRatio'
|
125 |
-
},
|
126 |
-
penSimplify: {
|
127 |
-
defaultMessage: 'Smoothing',
|
128 |
-
description: 'Label for the pen smoothing input, higher numbers control how much the drawn line will be corrected',
|
129 |
-
id: 'paint.modeTools.penSimplify'
|
130 |
-
},
|
131 |
-
copy: {
|
132 |
-
defaultMessage: 'Copy',
|
133 |
-
description: 'Label for the copy button',
|
134 |
-
id: 'paint.modeTools.copy'
|
135 |
-
},
|
136 |
-
cut: {
|
137 |
-
defaultMessage: 'Cut',
|
138 |
-
description: 'Label for the cut button',
|
139 |
-
id: 'paint.modeTools.cut'
|
140 |
-
},
|
141 |
-
paste: {
|
142 |
-
defaultMessage: 'Paste',
|
143 |
-
description: 'Label for the paste button',
|
144 |
-
id: 'paint.modeTools.paste'
|
145 |
-
},
|
146 |
-
delete: {
|
147 |
-
defaultMessage: 'Delete',
|
148 |
-
description: 'Label for the delete button',
|
149 |
-
id: 'paint.modeTools.delete'
|
150 |
-
},
|
151 |
-
curved: {
|
152 |
-
defaultMessage: 'Curved',
|
153 |
-
description: 'Label for the button that converts selected points to curves',
|
154 |
-
id: 'paint.modeTools.curved'
|
155 |
-
},
|
156 |
-
pointed: {
|
157 |
-
defaultMessage: 'Pointed',
|
158 |
-
description: 'Label for the button that converts selected points to sharp points',
|
159 |
-
id: 'paint.modeTools.pointed'
|
160 |
-
},
|
161 |
-
thickness: {
|
162 |
-
defaultMessage: 'Thickness',
|
163 |
-
description: 'Label for the number input to choose the line thickness',
|
164 |
-
id: 'paint.modeTools.thickness'
|
165 |
-
},
|
166 |
-
flipHorizontal: {
|
167 |
-
defaultMessage: 'Flip Horizontal',
|
168 |
-
description: 'Label for the button to flip the image horizontally',
|
169 |
-
id: 'paint.modeTools.flipHorizontal'
|
170 |
-
},
|
171 |
-
flipVertical: {
|
172 |
-
defaultMessage: 'Flip Vertical',
|
173 |
-
description: 'Label for the button to flip the image vertically',
|
174 |
-
id: 'paint.modeTools.flipVertical'
|
175 |
-
},
|
176 |
-
filled: {
|
177 |
-
defaultMessage: 'Filled',
|
178 |
-
description: 'Label for the button that sets the bitmap rectangle/oval mode to draw outlines',
|
179 |
-
id: 'paint.modeTools.filled'
|
180 |
-
},
|
181 |
-
outlined: {
|
182 |
-
defaultMessage: 'Outlined',
|
183 |
-
description: 'Label for the button that sets the bitmap rectangle/oval mode to draw filled-in shapes',
|
184 |
-
id: 'paint.modeTools.outlined'
|
185 |
-
},
|
186 |
-
movementCenter: {
|
187 |
-
defaultMessage: 'Center',
|
188 |
-
description: 'Label for the button that moves the selected objects to the center of the canvas',
|
189 |
-
id: 'paint.modeTools.movementCenter'
|
190 |
-
}
|
191 |
-
});
|
192 |
-
|
193 |
-
switch (props.mode) {
|
194 |
-
case Modes.BRUSH:
|
195 |
-
/* falls through */
|
196 |
-
case Modes.BIT_BRUSH:
|
197 |
-
/* falls through */
|
198 |
-
case Modes.BIT_LINE:
|
199 |
-
{
|
200 |
-
const currentIcon = isVector(props.format) ? brushIcon :
|
201 |
-
props.mode === Modes.BIT_LINE ? bitLineIcon : bitBrushIcon;
|
202 |
-
const currentBrushValue = isBitmap(props.format) ? props.bitBrushSize : props.brushValue;
|
203 |
-
const currentSimplifyValue = props.simplifyValue;
|
204 |
-
const changeFunction = isBitmap(props.format) ? props.onBitBrushSliderChange : props.onBrushSliderChange;
|
205 |
-
const changeFunctionSimplify = props.onSimplifySliderChange;
|
206 |
-
const currentMessage = props.mode === Modes.BIT_LINE ? messages.thickness : messages.brushSize;
|
207 |
-
const hasSimplifyOption = props.mode === Modes.BRUSH;
|
208 |
-
return (
|
209 |
-
<div className={classNames(props.className, styles.modeTools)}>
|
210 |
-
<div>
|
211 |
-
<img
|
212 |
-
alt={props.intl.formatMessage(currentMessage)}
|
213 |
-
title={props.intl.formatMessage(currentMessage)}
|
214 |
-
className={styles.modeToolsIcon}
|
215 |
-
draggable={false}
|
216 |
-
src={currentIcon}
|
217 |
-
/>
|
218 |
-
</div>
|
219 |
-
<LiveInput
|
220 |
-
range
|
221 |
-
small
|
222 |
-
max={MAX_STROKE_WIDTH}
|
223 |
-
min="1"
|
224 |
-
type="number"
|
225 |
-
value={currentBrushValue}
|
226 |
-
onSubmit={changeFunction}
|
227 |
-
/>
|
228 |
-
|
229 |
-
{hasSimplifyOption && (
|
230 |
-
<Label text={props.intl.formatMessage(messages.brushSimplify)} style={{ marginLeft: 'calc(2 * .25rem)' }}>
|
231 |
-
<LiveInput
|
232 |
-
range
|
233 |
-
small
|
234 |
-
max={1000}
|
235 |
-
min="0"
|
236 |
-
type="number"
|
237 |
-
value={currentSimplifyValue}
|
238 |
-
onSubmit={changeFunctionSimplify}
|
239 |
-
/>
|
240 |
-
</Label>
|
241 |
-
)}
|
242 |
-
|
243 |
-
{/* TODO replace this with a dropdown when we add more brush shapes */}
|
244 |
-
{hasSimplifyOption && (
|
245 |
-
<InputGroup>
|
246 |
-
<ButtonGroup>
|
247 |
-
<Button
|
248 |
-
className={
|
249 |
-
classNames(styles.buttonGroupButton)
|
250 |
-
}
|
251 |
-
onClick={() => props.onBrushChange("CIRCLE")}
|
252 |
-
>
|
253 |
-
<img
|
254 |
-
alt={props.intl.formatMessage(messages.brushCircle)}
|
255 |
-
className={styles.buttonGroupButtonIcon}
|
256 |
-
draggable={false}
|
257 |
-
src={"data:image/svg+xml;base64,
|
258 |
-
/>
|
259 |
-
</Button>
|
260 |
-
<Button
|
261 |
-
className={
|
262 |
-
classNames(styles.buttonGroupButton)
|
263 |
-
}
|
264 |
-
onClick={() => props.onBrushChange("SQUARE")}
|
265 |
-
>
|
266 |
-
<img
|
267 |
-
alt={props.intl.formatMessage(messages.brushSquare)}
|
268 |
-
className={styles.buttonGroupButtonIcon}
|
269 |
-
draggable={false}
|
270 |
-
src={"data:image/svg+xml;base64,
|
271 |
-
/>
|
272 |
-
</Button>
|
273 |
-
</ButtonGroup>
|
274 |
-
</InputGroup>
|
275 |
-
)}
|
276 |
-
</div>
|
277 |
-
);
|
278 |
-
}
|
279 |
-
case Modes.BIT_ERASER:
|
280 |
-
/* falls through */
|
281 |
-
case Modes.ERASER:
|
282 |
-
{
|
283 |
-
const currentIcon = isVector(props.format) ? eraserIcon : bitEraserIcon;
|
284 |
-
const currentEraserValue = isBitmap(props.format) ? props.bitEraserSize : props.eraserValue;
|
285 |
-
const currentEraserSimplifyValue = props.eraserSimplifyValue;
|
286 |
-
const changeFunction = isBitmap(props.format) ? props.onBitEraserSliderChange : props.onEraserSliderChange;
|
287 |
-
const changeFunctionSimplify = props.onEraserSimplifySliderChange;
|
288 |
-
const hasSimplifyOption = props.mode === Modes.ERASER;
|
289 |
-
return (
|
290 |
-
<div className={classNames(props.className, styles.modeTools)}>
|
291 |
-
<div>
|
292 |
-
<img
|
293 |
-
alt={props.intl.formatMessage(messages.eraserSize)}
|
294 |
-
title={props.intl.formatMessage(messages.eraserSize)}
|
295 |
-
className={styles.modeToolsIcon}
|
296 |
-
draggable={false}
|
297 |
-
src={currentIcon}
|
298 |
-
/>
|
299 |
-
</div>
|
300 |
-
<LiveInput
|
301 |
-
range
|
302 |
-
small
|
303 |
-
max={MAX_STROKE_WIDTH}
|
304 |
-
min="1"
|
305 |
-
type="number"
|
306 |
-
value={currentEraserValue}
|
307 |
-
onSubmit={changeFunction}
|
308 |
-
/>
|
309 |
-
|
310 |
-
{hasSimplifyOption && (
|
311 |
-
<Label text={props.intl.formatMessage(messages.eraserSimplify)} style={{ marginLeft: 'calc(2 * .25rem)' }}>
|
312 |
-
<LiveInput
|
313 |
-
range
|
314 |
-
small
|
315 |
-
max={1000}
|
316 |
-
min="0"
|
317 |
-
type="number"
|
318 |
-
value={currentEraserSimplifyValue}
|
319 |
-
onSubmit={changeFunctionSimplify}
|
320 |
-
/>
|
321 |
-
</Label>
|
322 |
-
)}
|
323 |
-
|
324 |
-
{/* TODO replace this with a dropdown when we add more brush shapes */}
|
325 |
-
{hasSimplifyOption && (
|
326 |
-
<InputGroup>
|
327 |
-
<ButtonGroup>
|
328 |
-
<Button
|
329 |
-
className={
|
330 |
-
classNames(styles.buttonGroupButton)
|
331 |
-
}
|
332 |
-
onClick={() => props.onBrushChange("CIRCLE")}
|
333 |
-
>
|
334 |
-
<img
|
335 |
-
alt={props.intl.formatMessage(messages.brushCircle)}
|
336 |
-
className={styles.buttonGroupButtonIcon}
|
337 |
-
draggable={false}
|
338 |
-
src={"data:image/svg+xml;base64,
|
339 |
-
/>
|
340 |
-
</Button>
|
341 |
-
<Button
|
342 |
-
className={
|
343 |
-
classNames(styles.buttonGroupButton)
|
344 |
-
}
|
345 |
-
onClick={() => props.onBrushChange("SQUARE")}
|
346 |
-
>
|
347 |
-
<img
|
348 |
-
alt={props.intl.formatMessage(messages.brushSquare)}
|
349 |
-
className={styles.buttonGroupButtonIcon}
|
350 |
-
draggable={false}
|
351 |
-
src={"data:image/svg+xml;base64,
|
352 |
-
/>
|
353 |
-
</Button>
|
354 |
-
</ButtonGroup>
|
355 |
-
</InputGroup>
|
356 |
-
)}
|
357 |
-
</div>
|
358 |
-
)
|
359 |
-
}
|
360 |
-
case Modes.ROUNDED_RECT:
|
361 |
-
/* falls through */
|
362 |
-
case Modes.RECT:
|
363 |
-
{
|
364 |
-
// NOTE: BIT_RECT doesnt use Path, so this can't be added there the same way as RECT has it.
|
365 |
-
const currentCornerValue = props.mode === Modes.ROUNDED_RECT ? props.roundedRectCornerValue : props.roundedCornerValue;
|
366 |
-
const changeFunction = props.mode === Modes.ROUNDED_RECT ? props.onRoundedRectCornerSliderChange : props.onRoundedCornerSliderChange;
|
367 |
-
return (
|
368 |
-
<div className={classNames(props.className, styles.modeTools)}>
|
369 |
-
<div>
|
370 |
-
<img
|
371 |
-
alt={props.intl.formatMessage(messages.roundedCornerSize)}
|
372 |
-
title={props.intl.formatMessage(messages.roundedCornerSize)}
|
373 |
-
className={styles.modeToolsIcon}
|
374 |
-
draggable={false}
|
375 |
-
src={roundedRectIcon}
|
376 |
-
/>
|
377 |
-
</div>
|
378 |
-
<LiveInput
|
379 |
-
range
|
380 |
-
small
|
381 |
-
min={0}
|
382 |
-
max={1000}
|
383 |
-
type="number"
|
384 |
-
value={currentCornerValue}
|
385 |
-
onSubmit={changeFunction}
|
386 |
-
/>
|
387 |
-
</div>
|
388 |
-
);
|
389 |
-
}
|
390 |
-
case Modes.TRIANGLE:
|
391 |
-
{
|
392 |
-
const currentSideValue = props.trianglePolyValue;
|
393 |
-
const currentPointValue = props.trianglePointValue;
|
394 |
-
const changeFunction = props.onPolyCountSliderChange;
|
395 |
-
const changeFunctionPoint = props.onPointCountSliderChange;
|
396 |
-
return (
|
397 |
-
<div className={classNames(props.className, styles.modeTools)}>
|
398 |
-
<div>
|
399 |
-
<img
|
400 |
-
alt={props.intl.formatMessage(messages.currentSideCount)}
|
401 |
-
title={props.intl.formatMessage(messages.currentSideCount)}
|
402 |
-
className={styles.modeToolsIcon}
|
403 |
-
draggable={false}
|
404 |
-
src={triangleIcon}
|
405 |
-
/>
|
406 |
-
</div>
|
407 |
-
<LiveInput
|
408 |
-
range
|
409 |
-
small
|
410 |
-
max={1000}
|
411 |
-
min="3"
|
412 |
-
type="number"
|
413 |
-
value={currentSideValue}
|
414 |
-
onSubmit={changeFunction}
|
415 |
-
/>
|
416 |
-
<div>
|
417 |
-
<img
|
418 |
-
alt={props.intl.formatMessage(messages.spokeRatio)}
|
419 |
-
title={props.intl.formatMessage(messages.spokeRatio)}
|
420 |
-
className={styles.modeToolsIcon}
|
421 |
-
draggable={false}
|
422 |
-
src={triangleSpikeRatioIcon}
|
423 |
-
/>
|
424 |
-
</div>
|
425 |
-
<LiveInput
|
426 |
-
range
|
427 |
-
small
|
428 |
-
max={1000}
|
429 |
-
min="0" // Spike ratio is limited to 0.01, but setting that here makes the number input arrows work really ugly
|
430 |
-
step="0.1"
|
431 |
-
type="number"
|
432 |
-
value={currentPointValue}
|
433 |
-
onSubmit={changeFunctionPoint}
|
434 |
-
/>
|
435 |
-
</div>
|
436 |
-
);
|
437 |
-
}
|
438 |
-
case Modes.SUSSY:
|
439 |
-
{
|
440 |
-
const currentlySelectedShape = props.currentlySelectedShape;
|
441 |
-
const changeFunction = props.onCurrentlySelectedShapeChange;
|
442 |
-
const selectedShapeObject = sussyToolShapes
|
443 |
-
.filter(shape => shape.id === currentlySelectedShape)[0];
|
444 |
-
const categorizedShapes = categorizeSussyShapes(sussyToolShapes);
|
445 |
-
const selectableShapesList = (
|
446 |
-
<InputGroup
|
447 |
-
className={classNames(
|
448 |
-
styles.modDashedBorder,
|
449 |
-
styles.dropItemShapeToolMenu,
|
450 |
-
styles.dropdownMaxItemList
|
451 |
-
)}
|
452 |
-
>
|
453 |
-
{Object.keys(categorizedShapes).map(categoryId => categorizedShapes[categoryId].length === 0 ?
|
454 |
-
(<React.Fragment key={categoryId} />) : (<React.Fragment key={categoryId}>
|
455 |
-
<p className={classNames(styles.dropItemShapeToolLabel)}>
|
456 |
-
{sussyToolCategories[categoryId]}
|
457 |
-
</p>
|
458 |
-
{categorizedShapes[categoryId].map(shape => (
|
459 |
-
<LabeledIconButton
|
460 |
-
key={shape.id}
|
461 |
-
className={classNames(styles.dropItemShapeTool)}
|
462 |
-
hideLabel={hideLabel(props.intl.locale)}
|
463 |
-
imgSrc={`data:image/svg+xml,${encodeURIComponent(generateSussyShapeSVG(shape))}`}
|
464 |
-
title={shape.name}
|
465 |
-
onClick={() => changeFunction(shape.id)}
|
466 |
-
/>
|
467 |
-
))}
|
468 |
-
</React.Fragment>))}
|
469 |
-
</InputGroup>
|
470 |
-
);
|
471 |
-
return (
|
472 |
-
<div className={classNames(props.className, styles.modeTools)}>
|
473 |
-
<Dropdown
|
474 |
-
className={styles.modUnselect}
|
475 |
-
enterExitTransitionDurationMs={20}
|
476 |
-
popoverContent={
|
477 |
-
<InputGroup
|
478 |
-
className={styles.modContextMenu}
|
479 |
-
rtl={props.rtl}
|
480 |
-
>
|
481 |
-
{selectableShapesList}
|
482 |
-
</InputGroup>
|
483 |
-
}
|
484 |
-
tipSize={.01}
|
485 |
-
>
|
486 |
-
<img
|
487 |
-
src={`data:image/svg+xml,${encodeURIComponent(generateSussyShapeSVG(selectedShapeObject))}`}
|
488 |
-
alt={selectedShapeObject.name}
|
489 |
-
title={selectedShapeObject.name}
|
490 |
-
height={16}
|
491 |
-
/>
|
492 |
-
</Dropdown>
|
493 |
-
</div>
|
494 |
-
);
|
495 |
-
}
|
496 |
-
case Modes.PEN:
|
497 |
-
{
|
498 |
-
const currentPenSimplifyValue = props.penSimplifyValue;
|
499 |
-
const changeFunctionSimplify = props.onPenSimplifySliderChange;
|
500 |
-
return (
|
501 |
-
<div className={classNames(props.className, styles.modeTools)}>
|
502 |
-
<Label text={props.intl.formatMessage(messages.eraserSimplify)} style={{ marginLeft: 'calc(2 * .25rem)' }}>
|
503 |
-
<LiveInput
|
504 |
-
range
|
505 |
-
small
|
506 |
-
max={1000}
|
507 |
-
min="0"
|
508 |
-
type="number"
|
509 |
-
value={currentPenSimplifyValue}
|
510 |
-
onSubmit={changeFunctionSimplify}
|
511 |
-
/>
|
512 |
-
</Label>
|
513 |
-
</div>
|
514 |
-
);
|
515 |
-
}
|
516 |
-
case Modes.RESHAPE:
|
517 |
-
const lineJoinReshape = (
|
518 |
-
<InputGroup className={classNames(styles.modDashedBorder, styles.modLabeledIconHeight)}>
|
519 |
-
<LabeledIconButton
|
520 |
-
disabled={props.hasSelectedMiterLineJoin}
|
521 |
-
hideLabel={hideLabel(props.intl.locale)}
|
522 |
-
imgSrc={miterLineJoin}
|
523 |
-
title={'Spiked'}
|
524 |
-
onClick={props.onMiterLineJoin}
|
525 |
-
/>
|
526 |
-
<LabeledIconButton
|
527 |
-
disabled={props.hasSelectedRoundLineJoin}
|
528 |
-
hideLabel={hideLabel(props.intl.locale)}
|
529 |
-
imgSrc={roundLineJoin}
|
530 |
-
title={'Rounded'}
|
531 |
-
onClick={props.onRoundLineJoin}
|
532 |
-
/>
|
533 |
-
<LabeledIconButton
|
534 |
-
disabled={props.hasSelectedBevelLineJoin}
|
535 |
-
hideLabel={hideLabel(props.intl.locale)}
|
536 |
-
imgSrc={bevelLineJoin}
|
537 |
-
title={'Beveled'}
|
538 |
-
onClick={props.onBevelLineJoin}
|
539 |
-
/>
|
540 |
-
</InputGroup>
|
541 |
-
);
|
542 |
-
const deleteSelectedNodes = (
|
543 |
-
<InputGroup className={classNames(styles.modLabeledIconHeight)}>
|
544 |
-
<LabeledIconButton
|
545 |
-
hideLabel={hideLabel(props.intl.locale)}
|
546 |
-
imgSrc={deleteIcon}
|
547 |
-
title={props.intl.formatMessage(messages.delete)}
|
548 |
-
onClick={props.onDelete}
|
549 |
-
/>
|
550 |
-
</InputGroup>
|
551 |
-
);
|
552 |
-
return (
|
553 |
-
<div className={classNames(props.className, styles.modeTools)}>
|
554 |
-
<InputGroup className={classNames(styles.modDashedBorder, styles.modLabeledIconHeight)}>
|
555 |
-
<LabeledIconButton
|
556 |
-
disabled={!props.hasSelectedUncurvedPoints}
|
557 |
-
hideLabel={hideLabel(props.intl.locale)}
|
558 |
-
imgSrc={curvedPointIcon}
|
559 |
-
title={props.intl.formatMessage(messages.curved)}
|
560 |
-
onClick={props.onCurvePoints}
|
561 |
-
/>
|
562 |
-
<LabeledIconButton
|
563 |
-
disabled={!props.hasSelectedUnpointedPoints}
|
564 |
-
hideLabel={hideLabel(props.intl.locale)}
|
565 |
-
imgSrc={straightPointIcon}
|
566 |
-
title={props.intl.formatMessage(messages.pointed)}
|
567 |
-
onClick={props.onPointPoints}
|
568 |
-
/>
|
569 |
-
</InputGroup>
|
570 |
-
<InputGroup className={classNames(styles.modDashedBorder, styles.modLabeledIconHeight)}>
|
571 |
-
<LabeledIconButton
|
572 |
-
disabled={props.hasSelectedRoundEnds}
|
573 |
-
hideLabel={hideLabel(props.intl.locale)}
|
574 |
-
imgSrc={roundLine}
|
575 |
-
title={'Rounded'}
|
576 |
-
onClick={props.onRoundEnds}
|
577 |
-
/>
|
578 |
-
<LabeledIconButton
|
579 |
-
disabled={props.hasSelectedSquareEnds}
|
580 |
-
hideLabel={hideLabel(props.intl.locale)}
|
581 |
-
imgSrc={squareLine}
|
582 |
-
title={'Squared'}
|
583 |
-
onClick={props.onSquareEnds}
|
584 |
-
/>
|
585 |
-
</InputGroup>
|
586 |
-
<MediaQuery minWidth={layout.fullSizeEditorMinWidthExtraToolsCollapsed}>
|
587 |
-
{lineJoinReshape}
|
588 |
-
{deleteSelectedNodes}
|
589 |
-
</MediaQuery>
|
590 |
-
<MediaQuery maxWidth={layout.fullSizeEditorMinWidthExtraToolsCollapsed - 1}>
|
591 |
-
<InputGroup className={classNames(styles.modDashedBorder, styles.modLabeledIconHeight)}>
|
592 |
-
<Dropdown
|
593 |
-
className={styles.modUnselect}
|
594 |
-
enterExitTransitionDurationMs={20}
|
595 |
-
popoverContent={
|
596 |
-
<InputGroup
|
597 |
-
className={styles.modContextMenu}
|
598 |
-
rtl={props.rtl}
|
599 |
-
>
|
600 |
-
{lineJoinReshape}
|
601 |
-
{deleteSelectedNodes}
|
602 |
-
</InputGroup>
|
603 |
-
}
|
604 |
-
tipSize={.01}
|
605 |
-
>
|
606 |
-
More
|
607 |
-
</Dropdown>
|
608 |
-
</InputGroup>
|
609 |
-
</MediaQuery>
|
610 |
-
</div>
|
611 |
-
);
|
612 |
-
case Modes.BIT_SELECT:
|
613 |
-
/* falls through */
|
614 |
-
case Modes.SELECT:
|
615 |
-
const reshapingMethods = props.format.startsWith("BITMAP") ? null : (
|
616 |
-
<InputGroup className={classNames(styles.modDashedBorder, styles.modLabeledIconHeight)}>
|
617 |
-
<LabeledIconButton
|
618 |
-
hideLabel={hideLabel(props.intl.locale)}
|
619 |
-
imgSrc={shapeMergeIcon}
|
620 |
-
title={'Merge'}
|
621 |
-
onClick={props.onMergeShape}
|
622 |
-
/>
|
623 |
-
<LabeledIconButton
|
624 |
-
hideLabel={hideLabel(props.intl.locale)}
|
625 |
-
imgSrc={shapeMaskIcon}
|
626 |
-
title={'Mask'}
|
627 |
-
onClick={props.onMaskShape}
|
628 |
-
/>
|
629 |
-
<LabeledIconButton
|
630 |
-
hideLabel={hideLabel(props.intl.locale)}
|
631 |
-
imgSrc={shapeSubtractIcon}
|
632 |
-
title={'Subtract'}
|
633 |
-
onClick={props.onSubtractShape}
|
634 |
-
/>
|
635 |
-
<LabeledIconButton
|
636 |
-
hideLabel={hideLabel(props.intl.locale)}
|
637 |
-
imgSrc={shapeFilterIcon}
|
638 |
-
title={'Filter'}
|
639 |
-
onClick={props.onExcludeShape}
|
640 |
-
/>
|
641 |
-
</InputGroup>
|
642 |
-
);
|
643 |
-
const flipOptions = (
|
644 |
-
<InputGroup className={classNames(styles.modDashedBorder, styles.modLabeledIconHeight)}>
|
645 |
-
<LabeledIconButton
|
646 |
-
hideLabel={props.intl.locale !== 'en'}
|
647 |
-
imgSrc={flipHorizontalIcon}
|
648 |
-
title={props.intl.formatMessage(messages.flipHorizontal)}
|
649 |
-
onClick={props.onFlipHorizontal}
|
650 |
-
/>
|
651 |
-
<LabeledIconButton
|
652 |
-
hideLabel={props.intl.locale !== 'en'}
|
653 |
-
imgSrc={flipVerticalIcon}
|
654 |
-
title={props.intl.formatMessage(messages.flipVertical)}
|
655 |
-
onClick={props.onFlipVertical}
|
656 |
-
/>
|
657 |
-
</InputGroup>
|
658 |
-
);
|
659 |
-
const movementOptions = (
|
660 |
-
<InputGroup className={classNames(styles.modDashedBorder, styles.modLabeledIconHeight)}>
|
661 |
-
<LabeledIconButton
|
662 |
-
hideLabel={props.intl.locale !== 'en'}
|
663 |
-
imgSrc={centerSelectionIcon}
|
664 |
-
title={props.intl.formatMessage(messages.movementCenter)}
|
665 |
-
onClick={props.onCenterSelection}
|
666 |
-
/>
|
667 |
-
</InputGroup>
|
668 |
-
);
|
669 |
-
return (
|
670 |
-
<div className={classNames(props.className, styles.modeTools)}>
|
671 |
-
<InputGroup className={classNames(styles.modDashedBorder, styles.modLabeledIconHeight)}>
|
672 |
-
<LabeledIconButton
|
673 |
-
hideLabel={hideLabel(props.intl.locale)}
|
674 |
-
imgSrc={copyIcon}
|
675 |
-
title={props.intl.formatMessage(messages.copy)}
|
676 |
-
onClick={props.onCopyToClipboard}
|
677 |
-
/>
|
678 |
-
<LabeledIconButton
|
679 |
-
disabled={!(props.clipboardItems.length > 0)}
|
680 |
-
hideLabel={hideLabel(props.intl.locale)}
|
681 |
-
imgSrc={pasteIcon}
|
682 |
-
title={props.intl.formatMessage(messages.paste)}
|
683 |
-
onClick={props.onPasteFromClipboard}
|
684 |
-
/>
|
685 |
-
<LabeledIconButton
|
686 |
-
hideLabel={hideLabel(props.intl.locale)}
|
687 |
-
imgSrc={cutIcon}
|
688 |
-
title={props.intl.formatMessage(messages.cut)}
|
689 |
-
onClick={props.onCutToClipboard}
|
690 |
-
/>
|
691 |
-
</InputGroup>
|
692 |
-
<InputGroup className={classNames(styles.modDashedBorder, styles.modLabeledIconHeight)}>
|
693 |
-
<LabeledIconButton
|
694 |
-
hideLabel={hideLabel(props.intl.locale)}
|
695 |
-
imgSrc={deleteIcon}
|
696 |
-
title={props.intl.formatMessage(messages.delete)}
|
697 |
-
onClick={props.onDelete}
|
698 |
-
/>
|
699 |
-
</InputGroup>
|
700 |
-
<MediaQuery minWidth={layout.fullSizeEditorMinWidthExtraToolsCollapsed}>
|
701 |
-
{/* Flip Options */}
|
702 |
-
{flipOptions}
|
703 |
-
{/* Movement Options */}
|
704 |
-
{movementOptions}
|
705 |
-
{/* Reshaping Methods */}
|
706 |
-
{(props.mode === Modes.SELECT) ? (
|
707 |
-
<MediaQuery minWidth={layout.fullSizeEditorMinWidthExtraTools}>
|
708 |
-
{reshapingMethods}
|
709 |
-
</MediaQuery>
|
710 |
-
) : null}
|
711 |
-
{(props.mode === Modes.SELECT) ? (
|
712 |
-
<MediaQuery maxWidth={layout.fullSizeEditorMinWidthExtraTools - 1}>
|
713 |
-
<InputGroup className={classNames(styles.modDashedBorder, styles.modLabeledIconHeight)}>
|
714 |
-
<Dropdown
|
715 |
-
className={styles.modUnselect}
|
716 |
-
enterExitTransitionDurationMs={20}
|
717 |
-
popoverContent={
|
718 |
-
<InputGroup
|
719 |
-
className={styles.modContextMenu}
|
720 |
-
rtl={props.rtl}
|
721 |
-
>
|
722 |
-
{reshapingMethods}
|
723 |
-
</InputGroup>
|
724 |
-
}
|
725 |
-
tipSize={.01}
|
726 |
-
>
|
727 |
-
More
|
728 |
-
</Dropdown>
|
729 |
-
</InputGroup>
|
730 |
-
</MediaQuery>
|
731 |
-
) : null}
|
732 |
-
</MediaQuery>
|
733 |
-
<MediaQuery maxWidth={layout.fullSizeEditorMinWidthExtraToolsCollapsed - 1}>
|
734 |
-
<InputGroup className={classNames(styles.modDashedBorder, styles.modLabeledIconHeight)}>
|
735 |
-
<Dropdown
|
736 |
-
className={styles.modUnselect}
|
737 |
-
enterExitTransitionDurationMs={20}
|
738 |
-
popoverContent={
|
739 |
-
<InputGroup
|
740 |
-
className={styles.modContextMenu}
|
741 |
-
rtl={props.rtl}
|
742 |
-
>
|
743 |
-
{flipOptions}
|
744 |
-
{movementOptions}
|
745 |
-
{reshapingMethods}
|
746 |
-
</InputGroup>
|
747 |
-
}
|
748 |
-
tipSize={.01}
|
749 |
-
>
|
750 |
-
More
|
751 |
-
</Dropdown>
|
752 |
-
</InputGroup>
|
753 |
-
</MediaQuery>
|
754 |
-
</div>
|
755 |
-
);
|
756 |
-
case Modes.BIT_TEXT:
|
757 |
-
/* falls through */
|
758 |
-
case Modes.TEXT:
|
759 |
-
return (
|
760 |
-
<div className={classNames(props.className, styles.modeTools)}>
|
761 |
-
<InputGroup className={classNames(styles.modDashedBorder)}>
|
762 |
-
<FontDropdown
|
763 |
-
onUpdateImage={props.onUpdateImage}
|
764 |
-
onManageFonts={props.onManageFonts}
|
765 |
-
/>
|
766 |
-
</InputGroup>
|
767 |
-
<InputGroup className={classNames(styles.modDashedBorder, styles.modLabeledIconHeight)}>
|
768 |
-
<LabeledIconButton
|
769 |
-
hideLabel
|
770 |
-
imgSrc={alignLeftIcon}
|
771 |
-
title={'Left Align'}
|
772 |
-
onClick={props.onTextAlignLeft}
|
773 |
-
/>
|
774 |
-
<LabeledIconButton
|
775 |
-
hideLabel
|
776 |
-
imgSrc={alignCenterIcon}
|
777 |
-
title={'Center Align'}
|
778 |
-
onClick={props.onTextAlignCenter}
|
779 |
-
/>
|
780 |
-
<LabeledIconButton
|
781 |
-
hideLabel
|
782 |
-
imgSrc={alignRightIcon}
|
783 |
-
title={'Right Align'}
|
784 |
-
onClick={props.onTextAlignRight}
|
785 |
-
/>
|
786 |
-
</InputGroup>
|
787 |
-
</div>
|
788 |
-
);
|
789 |
-
case Modes.BIT_RECT:
|
790 |
-
/* falls through */
|
791 |
-
case Modes.BIT_OVAL:
|
792 |
-
{
|
793 |
-
const fillIcon = props.mode === Modes.BIT_RECT ? bitRectIcon : bitOvalIcon;
|
794 |
-
const outlineIcon = props.mode === Modes.BIT_RECT ? bitRectOutlinedIcon : bitOvalOutlinedIcon;
|
795 |
-
return (
|
796 |
-
<div className={classNames(props.className, styles.modeTools)}>
|
797 |
-
<InputGroup>
|
798 |
-
<LabeledIconButton
|
799 |
-
highlighted={props.fillBitmapShapes}
|
800 |
-
imgSrc={fillIcon}
|
801 |
-
title={props.intl.formatMessage(messages.filled)}
|
802 |
-
onClick={props.onFillShapes}
|
803 |
-
/>
|
804 |
-
</InputGroup>
|
805 |
-
<InputGroup>
|
806 |
-
<LabeledIconButton
|
807 |
-
highlighted={!props.fillBitmapShapes}
|
808 |
-
imgSrc={outlineIcon}
|
809 |
-
title={props.intl.formatMessage(messages.outlined)}
|
810 |
-
onClick={props.onOutlineShapes}
|
811 |
-
/>
|
812 |
-
</InputGroup>
|
813 |
-
{props.fillBitmapShapes ? null : (
|
814 |
-
<InputGroup>
|
815 |
-
<Label text={props.intl.formatMessage(messages.thickness)}>
|
816 |
-
<LiveInput
|
817 |
-
range
|
818 |
-
small
|
819 |
-
max={MAX_STROKE_WIDTH}
|
820 |
-
min="1"
|
821 |
-
type="number"
|
822 |
-
value={props.bitBrushSize}
|
823 |
-
onSubmit={props.onBitBrushSliderChange}
|
824 |
-
/>
|
825 |
-
</Label>
|
826 |
-
</InputGroup>)
|
827 |
-
}
|
828 |
-
</div>
|
829 |
-
);
|
830 |
-
}
|
831 |
-
case Modes.ARROW:
|
832 |
-
{
|
833 |
-
return (
|
834 |
-
<div className={classNames(props.className, styles.modeTools)}>
|
835 |
-
<span>{`Hold Alt + Shift to resize arrow tip`}</span>
|
836 |
-
</div>
|
837 |
-
);
|
838 |
-
}
|
839 |
-
default:
|
840 |
-
// Leave empty for now, if mode not supported
|
841 |
-
return (
|
842 |
-
<div className={classNames(props.className, styles.modeTools)} />
|
843 |
-
);
|
844 |
-
}
|
845 |
-
};
|
846 |
-
|
847 |
-
ModeToolsComponent.propTypes = {
|
848 |
-
bitBrushSize: PropTypes.number,
|
849 |
-
bitEraserSize: PropTypes.number,
|
850 |
-
brushValue: PropTypes.number,
|
851 |
-
simplifyValue: PropTypes.number,
|
852 |
-
className: PropTypes.string,
|
853 |
-
clipboardItems: PropTypes.arrayOf(PropTypes.array),
|
854 |
-
eraserValue: PropTypes.number,
|
855 |
-
eraserSimplifyValue: PropTypes.number,
|
856 |
-
brushType: PropTypes.string,
|
857 |
-
penSimplifyValue: PropTypes.number,
|
858 |
-
roundedCornerValue: PropTypes.number,
|
859 |
-
roundedRectCornerValue: PropTypes.number,
|
860 |
-
trianglePolyValue: PropTypes.number,
|
861 |
-
trianglePointValue: PropTypes.number,
|
862 |
-
currentlySelectedShape: PropTypes.string,
|
863 |
-
fillBitmapShapes: PropTypes.bool,
|
864 |
-
format: PropTypes.oneOf(Object.keys(Formats)),
|
865 |
-
hasSelectedUncurvedPoints: PropTypes.bool,
|
866 |
-
hasSelectedUnpointedPoints: PropTypes.bool,
|
867 |
-
intl: intlShape.isRequired,
|
868 |
-
mode: PropTypes.string.isRequired,
|
869 |
-
onBitBrushSliderChange: PropTypes.func.isRequired,
|
870 |
-
onBitEraserSliderChange: PropTypes.func.isRequired,
|
871 |
-
onBrushSliderChange: PropTypes.func.isRequired,
|
872 |
-
onSimplifySliderChange: PropTypes.func.isRequired,
|
873 |
-
onCopyToClipboard: PropTypes.func.isRequired,
|
874 |
-
onCutToClipboard: PropTypes.func.isRequired,
|
875 |
-
onCurvePoints: PropTypes.func.isRequired,
|
876 |
-
onDelete: PropTypes.func.isRequired,
|
877 |
-
onEraserSliderChange: PropTypes.func,
|
878 |
-
onBrushChange: PropTypes.func,
|
879 |
-
onEraserSimplifySliderChange: PropTypes.func,
|
880 |
-
onPenSimplifySliderChange: PropTypes.func,
|
881 |
-
onFillShapes: PropTypes.func.isRequired,
|
882 |
-
onFlipHorizontal: PropTypes.func.isRequired,
|
883 |
-
onFlipVertical: PropTypes.func.isRequired,
|
884 |
-
onCenterSelection: PropTypes.func.isRequired,
|
885 |
-
onManageFonts: PropTypes.func,
|
886 |
-
onOutlineShapes: PropTypes.func.isRequired,
|
887 |
-
onPasteFromClipboard: PropTypes.func.isRequired,
|
888 |
-
onPointPoints: PropTypes.func.isRequired,
|
889 |
-
onUpdateImage: PropTypes.func.isRequired,
|
890 |
-
|
891 |
-
onMergeShape: PropTypes.func.isRequired,
|
892 |
-
onMaskShape: PropTypes.func.isRequired,
|
893 |
-
onSubtractShape: PropTypes.func.isRequired,
|
894 |
-
onExcludeShape: PropTypes.func.isRequired
|
895 |
-
};
|
896 |
-
|
897 |
-
const mapStateToProps = state => ({
|
898 |
-
mode: state.scratchPaint.mode,
|
899 |
-
format: state.scratchPaint.format,
|
900 |
-
fillBitmapShapes: state.scratchPaint.fillBitmapShapes,
|
901 |
-
bitBrushSize: state.scratchPaint.bitBrushSize,
|
902 |
-
bitEraserSize: state.scratchPaint.bitEraserSize,
|
903 |
-
brushValue: state.scratchPaint.brushMode.brushSize,
|
904 |
-
simplifyValue: state.scratchPaint.brushMode.simplifySize,
|
905 |
-
clipboardItems: state.scratchPaint.clipboard.items,
|
906 |
-
eraserValue: state.scratchPaint.eraserMode.brushSize,
|
907 |
-
eraserSimplifyValue: state.scratchPaint.eraserMode.simplifySize,
|
908 |
-
brushType: state.scratchPaint.brushType,
|
909 |
-
penSimplifyValue: state.scratchPaint.penMode.simplifySize,
|
910 |
-
roundedRectCornerValue: state.scratchPaint.roundedRectMode.roundedCornerSize,
|
911 |
-
roundedCornerValue: state.scratchPaint.rectMode.roundedCornerSize,
|
912 |
-
trianglePolyValue: state.scratchPaint.triangleMode.trianglePolyCount,
|
913 |
-
trianglePointValue: state.scratchPaint.triangleMode.trianglePointCount,
|
914 |
-
currentlySelectedShape: state.scratchPaint.sussyMode.shape
|
915 |
-
});
|
916 |
-
const mapDispatchToProps = dispatch => ({
|
917 |
-
onBrushSliderChange: brushSize => {
|
918 |
-
dispatch(changeBrushSize(brushSize));
|
919 |
-
},
|
920 |
-
onSimplifySliderChange: brushSize => {
|
921 |
-
dispatch(changeSimplifySize(brushSize));
|
922 |
-
},
|
923 |
-
onRoundedRectCornerSliderChange: roundedCornerSize => {
|
924 |
-
dispatch(changeRoundedRectCornerSize(roundedCornerSize));
|
925 |
-
},
|
926 |
-
onRoundedCornerSliderChange: roundedCornerSize => {
|
927 |
-
dispatch(changeRoundedCornerSize(roundedCornerSize));
|
928 |
-
},
|
929 |
-
onPolyCountSliderChange: polyCount => {
|
930 |
-
dispatch(changeTrianglePolyCount(polyCount));
|
931 |
-
},
|
932 |
-
onPointCountSliderChange: polyCount => {
|
933 |
-
dispatch(changeTrianglePointCount(polyCount));
|
934 |
-
},
|
935 |
-
onCurrentlySelectedShapeChange: shape => {
|
936 |
-
dispatch(changeCurrentlySelectedShape(shape));
|
937 |
-
},
|
938 |
-
onBitBrushSliderChange: bitBrushSize => {
|
939 |
-
dispatch(changeBitBrushSize(bitBrushSize));
|
940 |
-
},
|
941 |
-
onBitEraserSliderChange: eraserSize => {
|
942 |
-
dispatch(changeBitEraserSize(eraserSize));
|
943 |
-
},
|
944 |
-
onEraserSliderChange: eraserSize => {
|
945 |
-
dispatch(changeEraserSize(eraserSize));
|
946 |
-
},
|
947 |
-
onEraserSimplifySliderChange: eraserSize => {
|
948 |
-
dispatch(changeEraserSimplifySize(eraserSize));
|
949 |
-
},
|
950 |
-
onBrushChange: type => {
|
951 |
-
dispatch(setBrushType(type));
|
952 |
-
},
|
953 |
-
onPenSimplifySliderChange: eraserSize => {
|
954 |
-
dispatch(changePenSimplifySize(eraserSize));
|
955 |
-
},
|
956 |
-
onFillShapes: () => {
|
957 |
-
dispatch(setShapesFilled(true));
|
958 |
-
},
|
959 |
-
onOutlineShapes: () => {
|
960 |
-
dispatch(setShapesFilled(false));
|
961 |
-
},
|
962 |
-
onTextAlignLeft: () => {
|
963 |
-
dispatch(setTextAlignment("left"));
|
964 |
-
},
|
965 |
-
onTextAlignRight: () => {
|
966 |
-
dispatch(setTextAlignment("right"));
|
967 |
-
},
|
968 |
-
onTextAlignCenter: () => {
|
969 |
-
dispatch(setTextAlignment("center"));
|
970 |
-
},
|
971 |
-
});
|
972 |
-
|
973 |
-
export default connect(
|
974 |
-
mapStateToProps,
|
975 |
-
mapDispatchToProps
|
976 |
-
)(injectIntl(ModeToolsComponent));
|
|
|
1 |
+
/* eslint-disable no-case-declarations */
|
2 |
+
import classNames from 'classnames';
|
3 |
+
import { connect } from 'react-redux';
|
4 |
+
import PropTypes from 'prop-types';
|
5 |
+
import React from 'react';
|
6 |
+
|
7 |
+
import Dropdown from '../dropdown/dropdown.jsx';
|
8 |
+
import MediaQuery from 'react-responsive';
|
9 |
+
import layout from '../../lib/layout-constants';
|
10 |
+
|
11 |
+
import { changeBrushSize, changeSimplifySize, setBrushType } from '../../reducers/brush-mode';
|
12 |
+
import { changeBrushSize as changeEraserSize, changeSimplifySize as changeEraserSimplifySize } from '../../reducers/eraser-mode';
|
13 |
+
import { changeSimplifySize as changePenSimplifySize } from '../../reducers/pen-mode';
|
14 |
+
import { changeRoundedRectCornerSize } from '../../reducers/rounded-rect-mode';
|
15 |
+
import { changeRoundedCornerSize } from '../../reducers/rect-mode';
|
16 |
+
import { changeTrianglePolyCount, changeTrianglePointCount } from '../../reducers/triangle-mode';
|
17 |
+
import { changeCurrentlySelectedShape } from '../../reducers/sussy-mode';
|
18 |
+
import { changeBitBrushSize } from '../../reducers/bit-brush-size';
|
19 |
+
import { changeBitEraserSize } from '../../reducers/bit-eraser-size';
|
20 |
+
import { setShapesFilled } from '../../reducers/fill-bitmap-shapes';
|
21 |
+
import { setTextAlignment } from '../../reducers/text-alignment';
|
22 |
+
|
23 |
+
import FontDropdown from '../../containers/font-dropdown.jsx';
|
24 |
+
import LiveInputHOC from '../forms/live-input-hoc.jsx';
|
25 |
+
import Label from '../forms/label.jsx';
|
26 |
+
import { defineMessages, injectIntl, intlShape } from 'react-intl';
|
27 |
+
import Input from '../forms/input.jsx';
|
28 |
+
import InputGroup from '../input-group/input-group.jsx';
|
29 |
+
import ButtonGroup from '../button-group/button-group.jsx';
|
30 |
+
import Button from '../button/button.jsx';
|
31 |
+
import LabeledIconButton from '../labeled-icon-button/labeled-icon-button.jsx';
|
32 |
+
import Modes from '../../lib/modes';
|
33 |
+
import Formats, { isBitmap, isVector } from '../../lib/format';
|
34 |
+
import { hideLabel } from '../../lib/hide-label';
|
35 |
+
import styles from './mode-tools.css';
|
36 |
+
import { MAX_STROKE_WIDTH } from '../../reducers/stroke-width';
|
37 |
+
import {
|
38 |
+
selectableShapes as sussyToolShapes,
|
39 |
+
categories as sussyToolCategories,
|
40 |
+
generateShapeSVG as generateSussyShapeSVG,
|
41 |
+
categorizeShapes as categorizeSussyShapes,
|
42 |
+
} from '../../helper/selectable-shapes.js';
|
43 |
+
|
44 |
+
import copyIcon from './icons/copy.svg';
|
45 |
+
import cutIcon from './icons/cut.svg';
|
46 |
+
import pasteIcon from './icons/paste.svg';
|
47 |
+
import deleteIcon from './icons/delete.svg';
|
48 |
+
import roundLine from './icons/round-line.svg';
|
49 |
+
import squareLine from './icons/square-line.svg';
|
50 |
+
import miterLineJoin from './icons/miter-line-join.svg';
|
51 |
+
import roundLineJoin from './icons/round-line-join.svg';
|
52 |
+
import bevelLineJoin from './icons/bevel-line-join.svg';
|
53 |
+
import shapeMergeIcon from './icons/merge.svg';
|
54 |
+
import shapeMaskIcon from './icons/mask.svg';
|
55 |
+
import shapeSubtractIcon from './icons/subtract.svg';
|
56 |
+
import shapeFilterIcon from './icons/filter.svg';
|
57 |
+
import alignLeftIcon from './icons/alignLeft.svg';
|
58 |
+
import alignRightIcon from './icons/alignRight.svg';
|
59 |
+
import alignCenterIcon from './icons/alignCenter.svg';
|
60 |
+
import bitBrushIcon from '../bit-brush-mode/brush.svg';
|
61 |
+
import bitEraserIcon from '../bit-eraser-mode/eraser.svg';
|
62 |
+
import bitLineIcon from '../bit-line-mode/line.svg';
|
63 |
+
import brushIcon from '../brush-mode/brush.svg';
|
64 |
+
import curvedPointIcon from './icons/curved-point.svg';
|
65 |
+
import eraserIcon from '../eraser-mode/eraser.svg';
|
66 |
+
import roundedRectIcon from '../rounded-rect-mode/rounded-rectangle.svg';
|
67 |
+
import triangleIcon from '../triangle-mode/triangle.svg';
|
68 |
+
import triangleSpikeRatioIcon from './icons/triangle-spike-ratio.svg';
|
69 |
+
import flipHorizontalIcon from './icons/flip-horizontal.svg';
|
70 |
+
import flipVerticalIcon from './icons/flip-vertical.svg';
|
71 |
+
import centerSelectionIcon from './icons/centerSelection.svg';
|
72 |
+
import straightPointIcon from './icons/straight-point.svg';
|
73 |
+
import bitOvalIcon from '../bit-oval-mode/oval.svg';
|
74 |
+
import bitRectIcon from '../bit-rect-mode/rectangle.svg';
|
75 |
+
import bitOvalOutlinedIcon from '../bit-oval-mode/oval-outlined.svg';
|
76 |
+
import bitRectOutlinedIcon from '../bit-rect-mode/rectangle-outlined.svg';
|
77 |
+
|
78 |
+
const LiveInput = LiveInputHOC(Input);
|
79 |
+
const ModeToolsComponent = props => {
|
80 |
+
const messages = defineMessages({
|
81 |
+
brushSize: {
|
82 |
+
defaultMessage: 'Size',
|
83 |
+
description: 'Label for the brush size input',
|
84 |
+
id: 'paint.modeTools.brushSize'
|
85 |
+
},
|
86 |
+
brushSimplify: {
|
87 |
+
defaultMessage: 'Smoothing',
|
88 |
+
description: 'Label for the brush smoothing input, higher numbers control how much the drawn line will be corrected',
|
89 |
+
id: 'paint.modeTools.brushSimplify'
|
90 |
+
},
|
91 |
+
eraserSize: {
|
92 |
+
defaultMessage: 'Eraser size',
|
93 |
+
description: 'Label for the eraser size input',
|
94 |
+
id: 'paint.modeTools.eraserSize'
|
95 |
+
},
|
96 |
+
eraserSimplify: {
|
97 |
+
defaultMessage: 'Smoothing',
|
98 |
+
description: 'Label for the eraser smoothing input, higher numbers control how much the drawn line will be corrected',
|
99 |
+
id: 'paint.modeTools.eraserSimplify'
|
100 |
+
},
|
101 |
+
brushCircle: {
|
102 |
+
defaultMessage: 'Circle Brush',
|
103 |
+
description: 'Label for the circle brush shape',
|
104 |
+
id: 'paint.modeTools.circleSquare'
|
105 |
+
},
|
106 |
+
brushSquare: {
|
107 |
+
defaultMessage: 'Square Brush',
|
108 |
+
description: 'Label for the square brush shape',
|
109 |
+
id: 'paint.modeTools.brushSquare'
|
110 |
+
},
|
111 |
+
roundedCornerSize: {
|
112 |
+
defaultMessage: 'Rounded corner size',
|
113 |
+
description: 'Label for the Rounded corner size input',
|
114 |
+
id: 'paint.modeTools.roundedCornerSize'
|
115 |
+
},
|
116 |
+
currentSideCount: {
|
117 |
+
defaultMessage: 'Polygon side count',
|
118 |
+
description: 'Label for the Polygon side count input',
|
119 |
+
id: 'paint.modeTools.currentSideCount'
|
120 |
+
},
|
121 |
+
spokeRatio: {
|
122 |
+
defaultMessage: 'Star spoke ratio',
|
123 |
+
description: 'Label for the Star spoke ratio input, controls the size of the spokes on a star',
|
124 |
+
id: 'paint.modeTools.spikeRatio'
|
125 |
+
},
|
126 |
+
penSimplify: {
|
127 |
+
defaultMessage: 'Smoothing',
|
128 |
+
description: 'Label for the pen smoothing input, higher numbers control how much the drawn line will be corrected',
|
129 |
+
id: 'paint.modeTools.penSimplify'
|
130 |
+
},
|
131 |
+
copy: {
|
132 |
+
defaultMessage: 'Copy',
|
133 |
+
description: 'Label for the copy button',
|
134 |
+
id: 'paint.modeTools.copy'
|
135 |
+
},
|
136 |
+
cut: {
|
137 |
+
defaultMessage: 'Cut',
|
138 |
+
description: 'Label for the cut button',
|
139 |
+
id: 'paint.modeTools.cut'
|
140 |
+
},
|
141 |
+
paste: {
|
142 |
+
defaultMessage: 'Paste',
|
143 |
+
description: 'Label for the paste button',
|
144 |
+
id: 'paint.modeTools.paste'
|
145 |
+
},
|
146 |
+
delete: {
|
147 |
+
defaultMessage: 'Delete',
|
148 |
+
description: 'Label for the delete button',
|
149 |
+
id: 'paint.modeTools.delete'
|
150 |
+
},
|
151 |
+
curved: {
|
152 |
+
defaultMessage: 'Curved',
|
153 |
+
description: 'Label for the button that converts selected points to curves',
|
154 |
+
id: 'paint.modeTools.curved'
|
155 |
+
},
|
156 |
+
pointed: {
|
157 |
+
defaultMessage: 'Pointed',
|
158 |
+
description: 'Label for the button that converts selected points to sharp points',
|
159 |
+
id: 'paint.modeTools.pointed'
|
160 |
+
},
|
161 |
+
thickness: {
|
162 |
+
defaultMessage: 'Thickness',
|
163 |
+
description: 'Label for the number input to choose the line thickness',
|
164 |
+
id: 'paint.modeTools.thickness'
|
165 |
+
},
|
166 |
+
flipHorizontal: {
|
167 |
+
defaultMessage: 'Flip Horizontal',
|
168 |
+
description: 'Label for the button to flip the image horizontally',
|
169 |
+
id: 'paint.modeTools.flipHorizontal'
|
170 |
+
},
|
171 |
+
flipVertical: {
|
172 |
+
defaultMessage: 'Flip Vertical',
|
173 |
+
description: 'Label for the button to flip the image vertically',
|
174 |
+
id: 'paint.modeTools.flipVertical'
|
175 |
+
},
|
176 |
+
filled: {
|
177 |
+
defaultMessage: 'Filled',
|
178 |
+
description: 'Label for the button that sets the bitmap rectangle/oval mode to draw outlines',
|
179 |
+
id: 'paint.modeTools.filled'
|
180 |
+
},
|
181 |
+
outlined: {
|
182 |
+
defaultMessage: 'Outlined',
|
183 |
+
description: 'Label for the button that sets the bitmap rectangle/oval mode to draw filled-in shapes',
|
184 |
+
id: 'paint.modeTools.outlined'
|
185 |
+
},
|
186 |
+
movementCenter: {
|
187 |
+
defaultMessage: 'Center',
|
188 |
+
description: 'Label for the button that moves the selected objects to the center of the canvas',
|
189 |
+
id: 'paint.modeTools.movementCenter'
|
190 |
+
}
|
191 |
+
});
|
192 |
+
|
193 |
+
switch (props.mode) {
|
194 |
+
case Modes.BRUSH:
|
195 |
+
/* falls through */
|
196 |
+
case Modes.BIT_BRUSH:
|
197 |
+
/* falls through */
|
198 |
+
case Modes.BIT_LINE:
|
199 |
+
{
|
200 |
+
const currentIcon = isVector(props.format) ? brushIcon :
|
201 |
+
props.mode === Modes.BIT_LINE ? bitLineIcon : bitBrushIcon;
|
202 |
+
const currentBrushValue = isBitmap(props.format) ? props.bitBrushSize : props.brushValue;
|
203 |
+
const currentSimplifyValue = props.simplifyValue;
|
204 |
+
const changeFunction = isBitmap(props.format) ? props.onBitBrushSliderChange : props.onBrushSliderChange;
|
205 |
+
const changeFunctionSimplify = props.onSimplifySliderChange;
|
206 |
+
const currentMessage = props.mode === Modes.BIT_LINE ? messages.thickness : messages.brushSize;
|
207 |
+
const hasSimplifyOption = props.mode === Modes.BRUSH;
|
208 |
+
return (
|
209 |
+
<div className={classNames(props.className, styles.modeTools)}>
|
210 |
+
<div>
|
211 |
+
<img
|
212 |
+
alt={props.intl.formatMessage(currentMessage)}
|
213 |
+
title={props.intl.formatMessage(currentMessage)}
|
214 |
+
className={styles.modeToolsIcon}
|
215 |
+
draggable={false}
|
216 |
+
src={currentIcon}
|
217 |
+
/>
|
218 |
+
</div>
|
219 |
+
<LiveInput
|
220 |
+
range
|
221 |
+
small
|
222 |
+
max={MAX_STROKE_WIDTH}
|
223 |
+
min="1"
|
224 |
+
type="number"
|
225 |
+
value={currentBrushValue}
|
226 |
+
onSubmit={changeFunction}
|
227 |
+
/>
|
228 |
+
|
229 |
+
{hasSimplifyOption && (
|
230 |
+
<Label text={props.intl.formatMessage(messages.brushSimplify)} style={{ marginLeft: 'calc(2 * .25rem)' }}>
|
231 |
+
<LiveInput
|
232 |
+
range
|
233 |
+
small
|
234 |
+
max={1000}
|
235 |
+
min="0"
|
236 |
+
type="number"
|
237 |
+
value={currentSimplifyValue}
|
238 |
+
onSubmit={changeFunctionSimplify}
|
239 |
+
/>
|
240 |
+
</Label>
|
241 |
+
)}
|
242 |
+
|
243 |
+
{/* TODO replace this with a dropdown when we add more brush shapes */}
|
244 |
+
{hasSimplifyOption && (
|
245 |
+
<InputGroup>
|
246 |
+
<ButtonGroup>
|
247 |
+
<Button
|
248 |
+
className={
|
249 |
+
classNames(styles.buttonGroupButton)
|
250 |
+
}
|
251 |
+
onClick={() => props.onBrushChange("CIRCLE")}
|
252 |
+
>
|
253 |
+
<img
|
254 |
+
alt={props.intl.formatMessage(messages.brushCircle)}
|
255 |
+
className={styles.buttonGroupButtonIcon}
|
256 |
+
draggable={false}
|
257 |
+
src={"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjAiIGhlaWdodD0iMjAiIHZpZXdCb3g9IjAgMCAyMCAyMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cmVjdCBmaWxsPSIjNjI1ZWRiIiB3aWR0aD0iMTUiIGhlaWdodD0iMTUiIHJ4PSIxMDAiIHRyYW5zZm9ybT0idHJhbnNsYXRlKDIuNSAyLjUpIi8+PC9zdmc+"}
|
258 |
+
/>
|
259 |
+
</Button>
|
260 |
+
<Button
|
261 |
+
className={
|
262 |
+
classNames(styles.buttonGroupButton)
|
263 |
+
}
|
264 |
+
onClick={() => props.onBrushChange("SQUARE")}
|
265 |
+
>
|
266 |
+
<img
|
267 |
+
alt={props.intl.formatMessage(messages.brushSquare)}
|
268 |
+
className={styles.buttonGroupButtonIcon}
|
269 |
+
draggable={false}
|
270 |
+
src={"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjAiIGhlaWdodD0iMjAiIHZpZXdCb3g9IjAgMCAyMCAyMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cmVjdCBmaWxsPSIjNjI1ZWRiIiB3aWR0aD0iMTUiIGhlaWdodD0iMTUiIHJ4PSIyIiB0cmFuc2Zvcm09InRyYW5zbGF0ZSgyLjUgMi41KSIvPjwvc3ZnPg=="}
|
271 |
+
/>
|
272 |
+
</Button>
|
273 |
+
</ButtonGroup>
|
274 |
+
</InputGroup>
|
275 |
+
)}
|
276 |
+
</div>
|
277 |
+
);
|
278 |
+
}
|
279 |
+
case Modes.BIT_ERASER:
|
280 |
+
/* falls through */
|
281 |
+
case Modes.ERASER:
|
282 |
+
{
|
283 |
+
const currentIcon = isVector(props.format) ? eraserIcon : bitEraserIcon;
|
284 |
+
const currentEraserValue = isBitmap(props.format) ? props.bitEraserSize : props.eraserValue;
|
285 |
+
const currentEraserSimplifyValue = props.eraserSimplifyValue;
|
286 |
+
const changeFunction = isBitmap(props.format) ? props.onBitEraserSliderChange : props.onEraserSliderChange;
|
287 |
+
const changeFunctionSimplify = props.onEraserSimplifySliderChange;
|
288 |
+
const hasSimplifyOption = props.mode === Modes.ERASER;
|
289 |
+
return (
|
290 |
+
<div className={classNames(props.className, styles.modeTools)}>
|
291 |
+
<div>
|
292 |
+
<img
|
293 |
+
alt={props.intl.formatMessage(messages.eraserSize)}
|
294 |
+
title={props.intl.formatMessage(messages.eraserSize)}
|
295 |
+
className={styles.modeToolsIcon}
|
296 |
+
draggable={false}
|
297 |
+
src={currentIcon}
|
298 |
+
/>
|
299 |
+
</div>
|
300 |
+
<LiveInput
|
301 |
+
range
|
302 |
+
small
|
303 |
+
max={MAX_STROKE_WIDTH}
|
304 |
+
min="1"
|
305 |
+
type="number"
|
306 |
+
value={currentEraserValue}
|
307 |
+
onSubmit={changeFunction}
|
308 |
+
/>
|
309 |
+
|
310 |
+
{hasSimplifyOption && (
|
311 |
+
<Label text={props.intl.formatMessage(messages.eraserSimplify)} style={{ marginLeft: 'calc(2 * .25rem)' }}>
|
312 |
+
<LiveInput
|
313 |
+
range
|
314 |
+
small
|
315 |
+
max={1000}
|
316 |
+
min="0"
|
317 |
+
type="number"
|
318 |
+
value={currentEraserSimplifyValue}
|
319 |
+
onSubmit={changeFunctionSimplify}
|
320 |
+
/>
|
321 |
+
</Label>
|
322 |
+
)}
|
323 |
+
|
324 |
+
{/* TODO replace this with a dropdown when we add more brush shapes */}
|
325 |
+
{hasSimplifyOption && (
|
326 |
+
<InputGroup>
|
327 |
+
<ButtonGroup>
|
328 |
+
<Button
|
329 |
+
className={
|
330 |
+
classNames(styles.buttonGroupButton)
|
331 |
+
}
|
332 |
+
onClick={() => props.onBrushChange("CIRCLE")}
|
333 |
+
>
|
334 |
+
<img
|
335 |
+
alt={props.intl.formatMessage(messages.brushCircle)}
|
336 |
+
className={styles.buttonGroupButtonIcon}
|
337 |
+
draggable={false}
|
338 |
+
src={"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjAiIGhlaWdodD0iMjAiIHZpZXdCb3g9IjAgMCAyMCAyMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cmVjdCBmaWxsPSIjNjI1ZWRiIiB3aWR0aD0iMTUiIGhlaWdodD0iMTUiIHJ4PSIxMDAiIHRyYW5zZm9ybT0idHJhbnNsYXRlKDIuNSAyLjUpIi8+PC9zdmc+"}
|
339 |
+
/>
|
340 |
+
</Button>
|
341 |
+
<Button
|
342 |
+
className={
|
343 |
+
classNames(styles.buttonGroupButton)
|
344 |
+
}
|
345 |
+
onClick={() => props.onBrushChange("SQUARE")}
|
346 |
+
>
|
347 |
+
<img
|
348 |
+
alt={props.intl.formatMessage(messages.brushSquare)}
|
349 |
+
className={styles.buttonGroupButtonIcon}
|
350 |
+
draggable={false}
|
351 |
+
src={"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjAiIGhlaWdodD0iMjAiIHZpZXdCb3g9IjAgMCAyMCAyMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cmVjdCBmaWxsPSIjNjI1ZWRiIiB3aWR0aD0iMTUiIGhlaWdodD0iMTUiIHJ4PSIyIiB0cmFuc2Zvcm09InRyYW5zbGF0ZSgyLjUgMi41KSIvPjwvc3ZnPg=="}
|
352 |
+
/>
|
353 |
+
</Button>
|
354 |
+
</ButtonGroup>
|
355 |
+
</InputGroup>
|
356 |
+
)}
|
357 |
+
</div>
|
358 |
+
)
|
359 |
+
}
|
360 |
+
case Modes.ROUNDED_RECT:
|
361 |
+
/* falls through */
|
362 |
+
case Modes.RECT:
|
363 |
+
{
|
364 |
+
// NOTE: BIT_RECT doesnt use Path, so this can't be added there the same way as RECT has it.
|
365 |
+
const currentCornerValue = props.mode === Modes.ROUNDED_RECT ? props.roundedRectCornerValue : props.roundedCornerValue;
|
366 |
+
const changeFunction = props.mode === Modes.ROUNDED_RECT ? props.onRoundedRectCornerSliderChange : props.onRoundedCornerSliderChange;
|
367 |
+
return (
|
368 |
+
<div className={classNames(props.className, styles.modeTools)}>
|
369 |
+
<div>
|
370 |
+
<img
|
371 |
+
alt={props.intl.formatMessage(messages.roundedCornerSize)}
|
372 |
+
title={props.intl.formatMessage(messages.roundedCornerSize)}
|
373 |
+
className={styles.modeToolsIcon}
|
374 |
+
draggable={false}
|
375 |
+
src={roundedRectIcon}
|
376 |
+
/>
|
377 |
+
</div>
|
378 |
+
<LiveInput
|
379 |
+
range
|
380 |
+
small
|
381 |
+
min={0}
|
382 |
+
max={1000}
|
383 |
+
type="number"
|
384 |
+
value={currentCornerValue}
|
385 |
+
onSubmit={changeFunction}
|
386 |
+
/>
|
387 |
+
</div>
|
388 |
+
);
|
389 |
+
}
|
390 |
+
case Modes.TRIANGLE:
|
391 |
+
{
|
392 |
+
const currentSideValue = props.trianglePolyValue;
|
393 |
+
const currentPointValue = props.trianglePointValue;
|
394 |
+
const changeFunction = props.onPolyCountSliderChange;
|
395 |
+
const changeFunctionPoint = props.onPointCountSliderChange;
|
396 |
+
return (
|
397 |
+
<div className={classNames(props.className, styles.modeTools)}>
|
398 |
+
<div>
|
399 |
+
<img
|
400 |
+
alt={props.intl.formatMessage(messages.currentSideCount)}
|
401 |
+
title={props.intl.formatMessage(messages.currentSideCount)}
|
402 |
+
className={styles.modeToolsIcon}
|
403 |
+
draggable={false}
|
404 |
+
src={triangleIcon}
|
405 |
+
/>
|
406 |
+
</div>
|
407 |
+
<LiveInput
|
408 |
+
range
|
409 |
+
small
|
410 |
+
max={1000}
|
411 |
+
min="3"
|
412 |
+
type="number"
|
413 |
+
value={currentSideValue}
|
414 |
+
onSubmit={changeFunction}
|
415 |
+
/>
|
416 |
+
<div>
|
417 |
+
<img
|
418 |
+
alt={props.intl.formatMessage(messages.spokeRatio)}
|
419 |
+
title={props.intl.formatMessage(messages.spokeRatio)}
|
420 |
+
className={styles.modeToolsIcon}
|
421 |
+
draggable={false}
|
422 |
+
src={triangleSpikeRatioIcon}
|
423 |
+
/>
|
424 |
+
</div>
|
425 |
+
<LiveInput
|
426 |
+
range
|
427 |
+
small
|
428 |
+
max={1000}
|
429 |
+
min="0" // Spike ratio is limited to 0.01, but setting that here makes the number input arrows work really ugly
|
430 |
+
step="0.1"
|
431 |
+
type="number"
|
432 |
+
value={currentPointValue}
|
433 |
+
onSubmit={changeFunctionPoint}
|
434 |
+
/>
|
435 |
+
</div>
|
436 |
+
);
|
437 |
+
}
|
438 |
+
case Modes.SUSSY:
|
439 |
+
{
|
440 |
+
const currentlySelectedShape = props.currentlySelectedShape;
|
441 |
+
const changeFunction = props.onCurrentlySelectedShapeChange;
|
442 |
+
const selectedShapeObject = sussyToolShapes
|
443 |
+
.filter(shape => shape.id === currentlySelectedShape)[0];
|
444 |
+
const categorizedShapes = categorizeSussyShapes(sussyToolShapes);
|
445 |
+
const selectableShapesList = (
|
446 |
+
<InputGroup
|
447 |
+
className={classNames(
|
448 |
+
styles.modDashedBorder,
|
449 |
+
styles.dropItemShapeToolMenu,
|
450 |
+
styles.dropdownMaxItemList
|
451 |
+
)}
|
452 |
+
>
|
453 |
+
{Object.keys(categorizedShapes).map(categoryId => categorizedShapes[categoryId].length === 0 ?
|
454 |
+
(<React.Fragment key={categoryId} />) : (<React.Fragment key={categoryId}>
|
455 |
+
<p className={classNames(styles.dropItemShapeToolLabel)}>
|
456 |
+
{sussyToolCategories[categoryId]}
|
457 |
+
</p>
|
458 |
+
{categorizedShapes[categoryId].map(shape => (
|
459 |
+
<LabeledIconButton
|
460 |
+
key={shape.id}
|
461 |
+
className={classNames(styles.dropItemShapeTool)}
|
462 |
+
hideLabel={hideLabel(props.intl.locale)}
|
463 |
+
imgSrc={`data:image/svg+xml,${encodeURIComponent(generateSussyShapeSVG(shape))}`}
|
464 |
+
title={shape.name}
|
465 |
+
onClick={() => changeFunction(shape.id)}
|
466 |
+
/>
|
467 |
+
))}
|
468 |
+
</React.Fragment>))}
|
469 |
+
</InputGroup>
|
470 |
+
);
|
471 |
+
return (
|
472 |
+
<div className={classNames(props.className, styles.modeTools)}>
|
473 |
+
<Dropdown
|
474 |
+
className={styles.modUnselect}
|
475 |
+
enterExitTransitionDurationMs={20}
|
476 |
+
popoverContent={
|
477 |
+
<InputGroup
|
478 |
+
className={styles.modContextMenu}
|
479 |
+
rtl={props.rtl}
|
480 |
+
>
|
481 |
+
{selectableShapesList}
|
482 |
+
</InputGroup>
|
483 |
+
}
|
484 |
+
tipSize={.01}
|
485 |
+
>
|
486 |
+
<img
|
487 |
+
src={`data:image/svg+xml,${encodeURIComponent(generateSussyShapeSVG(selectedShapeObject))}`}
|
488 |
+
alt={selectedShapeObject.name}
|
489 |
+
title={selectedShapeObject.name}
|
490 |
+
height={16}
|
491 |
+
/>
|
492 |
+
</Dropdown>
|
493 |
+
</div>
|
494 |
+
);
|
495 |
+
}
|
496 |
+
case Modes.PEN:
|
497 |
+
{
|
498 |
+
const currentPenSimplifyValue = props.penSimplifyValue;
|
499 |
+
const changeFunctionSimplify = props.onPenSimplifySliderChange;
|
500 |
+
return (
|
501 |
+
<div className={classNames(props.className, styles.modeTools)}>
|
502 |
+
<Label text={props.intl.formatMessage(messages.eraserSimplify)} style={{ marginLeft: 'calc(2 * .25rem)' }}>
|
503 |
+
<LiveInput
|
504 |
+
range
|
505 |
+
small
|
506 |
+
max={1000}
|
507 |
+
min="0"
|
508 |
+
type="number"
|
509 |
+
value={currentPenSimplifyValue}
|
510 |
+
onSubmit={changeFunctionSimplify}
|
511 |
+
/>
|
512 |
+
</Label>
|
513 |
+
</div>
|
514 |
+
);
|
515 |
+
}
|
516 |
+
case Modes.RESHAPE:
|
517 |
+
const lineJoinReshape = (
|
518 |
+
<InputGroup className={classNames(styles.modDashedBorder, styles.modLabeledIconHeight)}>
|
519 |
+
<LabeledIconButton
|
520 |
+
disabled={props.hasSelectedMiterLineJoin}
|
521 |
+
hideLabel={hideLabel(props.intl.locale)}
|
522 |
+
imgSrc={miterLineJoin}
|
523 |
+
title={'Spiked'}
|
524 |
+
onClick={props.onMiterLineJoin}
|
525 |
+
/>
|
526 |
+
<LabeledIconButton
|
527 |
+
disabled={props.hasSelectedRoundLineJoin}
|
528 |
+
hideLabel={hideLabel(props.intl.locale)}
|
529 |
+
imgSrc={roundLineJoin}
|
530 |
+
title={'Rounded'}
|
531 |
+
onClick={props.onRoundLineJoin}
|
532 |
+
/>
|
533 |
+
<LabeledIconButton
|
534 |
+
disabled={props.hasSelectedBevelLineJoin}
|
535 |
+
hideLabel={hideLabel(props.intl.locale)}
|
536 |
+
imgSrc={bevelLineJoin}
|
537 |
+
title={'Beveled'}
|
538 |
+
onClick={props.onBevelLineJoin}
|
539 |
+
/>
|
540 |
+
</InputGroup>
|
541 |
+
);
|
542 |
+
const deleteSelectedNodes = (
|
543 |
+
<InputGroup className={classNames(styles.modLabeledIconHeight)}>
|
544 |
+
<LabeledIconButton
|
545 |
+
hideLabel={hideLabel(props.intl.locale)}
|
546 |
+
imgSrc={deleteIcon}
|
547 |
+
title={props.intl.formatMessage(messages.delete)}
|
548 |
+
onClick={props.onDelete}
|
549 |
+
/>
|
550 |
+
</InputGroup>
|
551 |
+
);
|
552 |
+
return (
|
553 |
+
<div className={classNames(props.className, styles.modeTools)}>
|
554 |
+
<InputGroup className={classNames(styles.modDashedBorder, styles.modLabeledIconHeight)}>
|
555 |
+
<LabeledIconButton
|
556 |
+
disabled={!props.hasSelectedUncurvedPoints}
|
557 |
+
hideLabel={hideLabel(props.intl.locale)}
|
558 |
+
imgSrc={curvedPointIcon}
|
559 |
+
title={props.intl.formatMessage(messages.curved)}
|
560 |
+
onClick={props.onCurvePoints}
|
561 |
+
/>
|
562 |
+
<LabeledIconButton
|
563 |
+
disabled={!props.hasSelectedUnpointedPoints}
|
564 |
+
hideLabel={hideLabel(props.intl.locale)}
|
565 |
+
imgSrc={straightPointIcon}
|
566 |
+
title={props.intl.formatMessage(messages.pointed)}
|
567 |
+
onClick={props.onPointPoints}
|
568 |
+
/>
|
569 |
+
</InputGroup>
|
570 |
+
<InputGroup className={classNames(styles.modDashedBorder, styles.modLabeledIconHeight)}>
|
571 |
+
<LabeledIconButton
|
572 |
+
disabled={props.hasSelectedRoundEnds}
|
573 |
+
hideLabel={hideLabel(props.intl.locale)}
|
574 |
+
imgSrc={roundLine}
|
575 |
+
title={'Rounded'}
|
576 |
+
onClick={props.onRoundEnds}
|
577 |
+
/>
|
578 |
+
<LabeledIconButton
|
579 |
+
disabled={props.hasSelectedSquareEnds}
|
580 |
+
hideLabel={hideLabel(props.intl.locale)}
|
581 |
+
imgSrc={squareLine}
|
582 |
+
title={'Squared'}
|
583 |
+
onClick={props.onSquareEnds}
|
584 |
+
/>
|
585 |
+
</InputGroup>
|
586 |
+
<MediaQuery minWidth={layout.fullSizeEditorMinWidthExtraToolsCollapsed}>
|
587 |
+
{lineJoinReshape}
|
588 |
+
{deleteSelectedNodes}
|
589 |
+
</MediaQuery>
|
590 |
+
<MediaQuery maxWidth={layout.fullSizeEditorMinWidthExtraToolsCollapsed - 1}>
|
591 |
+
<InputGroup className={classNames(styles.modDashedBorder, styles.modLabeledIconHeight)}>
|
592 |
+
<Dropdown
|
593 |
+
className={styles.modUnselect}
|
594 |
+
enterExitTransitionDurationMs={20}
|
595 |
+
popoverContent={
|
596 |
+
<InputGroup
|
597 |
+
className={styles.modContextMenu}
|
598 |
+
rtl={props.rtl}
|
599 |
+
>
|
600 |
+
{lineJoinReshape}
|
601 |
+
{deleteSelectedNodes}
|
602 |
+
</InputGroup>
|
603 |
+
}
|
604 |
+
tipSize={.01}
|
605 |
+
>
|
606 |
+
More
|
607 |
+
</Dropdown>
|
608 |
+
</InputGroup>
|
609 |
+
</MediaQuery>
|
610 |
+
</div>
|
611 |
+
);
|
612 |
+
case Modes.BIT_SELECT:
|
613 |
+
/* falls through */
|
614 |
+
case Modes.SELECT:
|
615 |
+
const reshapingMethods = props.format.startsWith("BITMAP") ? null : (
|
616 |
+
<InputGroup className={classNames(styles.modDashedBorder, styles.modLabeledIconHeight)}>
|
617 |
+
<LabeledIconButton
|
618 |
+
hideLabel={hideLabel(props.intl.locale)}
|
619 |
+
imgSrc={shapeMergeIcon}
|
620 |
+
title={'Merge'}
|
621 |
+
onClick={props.onMergeShape}
|
622 |
+
/>
|
623 |
+
<LabeledIconButton
|
624 |
+
hideLabel={hideLabel(props.intl.locale)}
|
625 |
+
imgSrc={shapeMaskIcon}
|
626 |
+
title={'Mask'}
|
627 |
+
onClick={props.onMaskShape}
|
628 |
+
/>
|
629 |
+
<LabeledIconButton
|
630 |
+
hideLabel={hideLabel(props.intl.locale)}
|
631 |
+
imgSrc={shapeSubtractIcon}
|
632 |
+
title={'Subtract'}
|
633 |
+
onClick={props.onSubtractShape}
|
634 |
+
/>
|
635 |
+
<LabeledIconButton
|
636 |
+
hideLabel={hideLabel(props.intl.locale)}
|
637 |
+
imgSrc={shapeFilterIcon}
|
638 |
+
title={'Filter'}
|
639 |
+
onClick={props.onExcludeShape}
|
640 |
+
/>
|
641 |
+
</InputGroup>
|
642 |
+
);
|
643 |
+
const flipOptions = (
|
644 |
+
<InputGroup className={classNames(styles.modDashedBorder, styles.modLabeledIconHeight)}>
|
645 |
+
<LabeledIconButton
|
646 |
+
hideLabel={props.intl.locale !== 'en'}
|
647 |
+
imgSrc={flipHorizontalIcon}
|
648 |
+
title={props.intl.formatMessage(messages.flipHorizontal)}
|
649 |
+
onClick={props.onFlipHorizontal}
|
650 |
+
/>
|
651 |
+
<LabeledIconButton
|
652 |
+
hideLabel={props.intl.locale !== 'en'}
|
653 |
+
imgSrc={flipVerticalIcon}
|
654 |
+
title={props.intl.formatMessage(messages.flipVertical)}
|
655 |
+
onClick={props.onFlipVertical}
|
656 |
+
/>
|
657 |
+
</InputGroup>
|
658 |
+
);
|
659 |
+
const movementOptions = (
|
660 |
+
<InputGroup className={classNames(styles.modDashedBorder, styles.modLabeledIconHeight)}>
|
661 |
+
<LabeledIconButton
|
662 |
+
hideLabel={props.intl.locale !== 'en'}
|
663 |
+
imgSrc={centerSelectionIcon}
|
664 |
+
title={props.intl.formatMessage(messages.movementCenter)}
|
665 |
+
onClick={props.onCenterSelection}
|
666 |
+
/>
|
667 |
+
</InputGroup>
|
668 |
+
);
|
669 |
+
return (
|
670 |
+
<div className={classNames(props.className, styles.modeTools)}>
|
671 |
+
<InputGroup className={classNames(styles.modDashedBorder, styles.modLabeledIconHeight)}>
|
672 |
+
<LabeledIconButton
|
673 |
+
hideLabel={hideLabel(props.intl.locale)}
|
674 |
+
imgSrc={copyIcon}
|
675 |
+
title={props.intl.formatMessage(messages.copy)}
|
676 |
+
onClick={props.onCopyToClipboard}
|
677 |
+
/>
|
678 |
+
<LabeledIconButton
|
679 |
+
disabled={!(props.clipboardItems.length > 0)}
|
680 |
+
hideLabel={hideLabel(props.intl.locale)}
|
681 |
+
imgSrc={pasteIcon}
|
682 |
+
title={props.intl.formatMessage(messages.paste)}
|
683 |
+
onClick={props.onPasteFromClipboard}
|
684 |
+
/>
|
685 |
+
<LabeledIconButton
|
686 |
+
hideLabel={hideLabel(props.intl.locale)}
|
687 |
+
imgSrc={cutIcon}
|
688 |
+
title={props.intl.formatMessage(messages.cut)}
|
689 |
+
onClick={props.onCutToClipboard}
|
690 |
+
/>
|
691 |
+
</InputGroup>
|
692 |
+
<InputGroup className={classNames(styles.modDashedBorder, styles.modLabeledIconHeight)}>
|
693 |
+
<LabeledIconButton
|
694 |
+
hideLabel={hideLabel(props.intl.locale)}
|
695 |
+
imgSrc={deleteIcon}
|
696 |
+
title={props.intl.formatMessage(messages.delete)}
|
697 |
+
onClick={props.onDelete}
|
698 |
+
/>
|
699 |
+
</InputGroup>
|
700 |
+
<MediaQuery minWidth={layout.fullSizeEditorMinWidthExtraToolsCollapsed}>
|
701 |
+
{/* Flip Options */}
|
702 |
+
{flipOptions}
|
703 |
+
{/* Movement Options */}
|
704 |
+
{movementOptions}
|
705 |
+
{/* Reshaping Methods */}
|
706 |
+
{(props.mode === Modes.SELECT) ? (
|
707 |
+
<MediaQuery minWidth={layout.fullSizeEditorMinWidthExtraTools}>
|
708 |
+
{reshapingMethods}
|
709 |
+
</MediaQuery>
|
710 |
+
) : null}
|
711 |
+
{(props.mode === Modes.SELECT) ? (
|
712 |
+
<MediaQuery maxWidth={layout.fullSizeEditorMinWidthExtraTools - 1}>
|
713 |
+
<InputGroup className={classNames(styles.modDashedBorder, styles.modLabeledIconHeight)}>
|
714 |
+
<Dropdown
|
715 |
+
className={styles.modUnselect}
|
716 |
+
enterExitTransitionDurationMs={20}
|
717 |
+
popoverContent={
|
718 |
+
<InputGroup
|
719 |
+
className={styles.modContextMenu}
|
720 |
+
rtl={props.rtl}
|
721 |
+
>
|
722 |
+
{reshapingMethods}
|
723 |
+
</InputGroup>
|
724 |
+
}
|
725 |
+
tipSize={.01}
|
726 |
+
>
|
727 |
+
More
|
728 |
+
</Dropdown>
|
729 |
+
</InputGroup>
|
730 |
+
</MediaQuery>
|
731 |
+
) : null}
|
732 |
+
</MediaQuery>
|
733 |
+
<MediaQuery maxWidth={layout.fullSizeEditorMinWidthExtraToolsCollapsed - 1}>
|
734 |
+
<InputGroup className={classNames(styles.modDashedBorder, styles.modLabeledIconHeight)}>
|
735 |
+
<Dropdown
|
736 |
+
className={styles.modUnselect}
|
737 |
+
enterExitTransitionDurationMs={20}
|
738 |
+
popoverContent={
|
739 |
+
<InputGroup
|
740 |
+
className={styles.modContextMenu}
|
741 |
+
rtl={props.rtl}
|
742 |
+
>
|
743 |
+
{flipOptions}
|
744 |
+
{movementOptions}
|
745 |
+
{reshapingMethods}
|
746 |
+
</InputGroup>
|
747 |
+
}
|
748 |
+
tipSize={.01}
|
749 |
+
>
|
750 |
+
More
|
751 |
+
</Dropdown>
|
752 |
+
</InputGroup>
|
753 |
+
</MediaQuery>
|
754 |
+
</div>
|
755 |
+
);
|
756 |
+
case Modes.BIT_TEXT:
|
757 |
+
/* falls through */
|
758 |
+
case Modes.TEXT:
|
759 |
+
return (
|
760 |
+
<div className={classNames(props.className, styles.modeTools)}>
|
761 |
+
<InputGroup className={classNames(styles.modDashedBorder)}>
|
762 |
+
<FontDropdown
|
763 |
+
onUpdateImage={props.onUpdateImage}
|
764 |
+
onManageFonts={props.onManageFonts}
|
765 |
+
/>
|
766 |
+
</InputGroup>
|
767 |
+
<InputGroup className={classNames(styles.modDashedBorder, styles.modLabeledIconHeight)}>
|
768 |
+
<LabeledIconButton
|
769 |
+
hideLabel
|
770 |
+
imgSrc={alignLeftIcon}
|
771 |
+
title={'Left Align'}
|
772 |
+
onClick={props.onTextAlignLeft}
|
773 |
+
/>
|
774 |
+
<LabeledIconButton
|
775 |
+
hideLabel
|
776 |
+
imgSrc={alignCenterIcon}
|
777 |
+
title={'Center Align'}
|
778 |
+
onClick={props.onTextAlignCenter}
|
779 |
+
/>
|
780 |
+
<LabeledIconButton
|
781 |
+
hideLabel
|
782 |
+
imgSrc={alignRightIcon}
|
783 |
+
title={'Right Align'}
|
784 |
+
onClick={props.onTextAlignRight}
|
785 |
+
/>
|
786 |
+
</InputGroup>
|
787 |
+
</div>
|
788 |
+
);
|
789 |
+
case Modes.BIT_RECT:
|
790 |
+
/* falls through */
|
791 |
+
case Modes.BIT_OVAL:
|
792 |
+
{
|
793 |
+
const fillIcon = props.mode === Modes.BIT_RECT ? bitRectIcon : bitOvalIcon;
|
794 |
+
const outlineIcon = props.mode === Modes.BIT_RECT ? bitRectOutlinedIcon : bitOvalOutlinedIcon;
|
795 |
+
return (
|
796 |
+
<div className={classNames(props.className, styles.modeTools)}>
|
797 |
+
<InputGroup>
|
798 |
+
<LabeledIconButton
|
799 |
+
highlighted={props.fillBitmapShapes}
|
800 |
+
imgSrc={fillIcon}
|
801 |
+
title={props.intl.formatMessage(messages.filled)}
|
802 |
+
onClick={props.onFillShapes}
|
803 |
+
/>
|
804 |
+
</InputGroup>
|
805 |
+
<InputGroup>
|
806 |
+
<LabeledIconButton
|
807 |
+
highlighted={!props.fillBitmapShapes}
|
808 |
+
imgSrc={outlineIcon}
|
809 |
+
title={props.intl.formatMessage(messages.outlined)}
|
810 |
+
onClick={props.onOutlineShapes}
|
811 |
+
/>
|
812 |
+
</InputGroup>
|
813 |
+
{props.fillBitmapShapes ? null : (
|
814 |
+
<InputGroup>
|
815 |
+
<Label text={props.intl.formatMessage(messages.thickness)}>
|
816 |
+
<LiveInput
|
817 |
+
range
|
818 |
+
small
|
819 |
+
max={MAX_STROKE_WIDTH}
|
820 |
+
min="1"
|
821 |
+
type="number"
|
822 |
+
value={props.bitBrushSize}
|
823 |
+
onSubmit={props.onBitBrushSliderChange}
|
824 |
+
/>
|
825 |
+
</Label>
|
826 |
+
</InputGroup>)
|
827 |
+
}
|
828 |
+
</div>
|
829 |
+
);
|
830 |
+
}
|
831 |
+
case Modes.ARROW:
|
832 |
+
{
|
833 |
+
return (
|
834 |
+
<div className={classNames(props.className, styles.modeTools)}>
|
835 |
+
<span>{`Hold Alt + Shift to resize arrow tip`}</span>
|
836 |
+
</div>
|
837 |
+
);
|
838 |
+
}
|
839 |
+
default:
|
840 |
+
// Leave empty for now, if mode not supported
|
841 |
+
return (
|
842 |
+
<div className={classNames(props.className, styles.modeTools)} />
|
843 |
+
);
|
844 |
+
}
|
845 |
+
};
|
846 |
+
|
847 |
+
ModeToolsComponent.propTypes = {
|
848 |
+
bitBrushSize: PropTypes.number,
|
849 |
+
bitEraserSize: PropTypes.number,
|
850 |
+
brushValue: PropTypes.number,
|
851 |
+
simplifyValue: PropTypes.number,
|
852 |
+
className: PropTypes.string,
|
853 |
+
clipboardItems: PropTypes.arrayOf(PropTypes.array),
|
854 |
+
eraserValue: PropTypes.number,
|
855 |
+
eraserSimplifyValue: PropTypes.number,
|
856 |
+
brushType: PropTypes.string,
|
857 |
+
penSimplifyValue: PropTypes.number,
|
858 |
+
roundedCornerValue: PropTypes.number,
|
859 |
+
roundedRectCornerValue: PropTypes.number,
|
860 |
+
trianglePolyValue: PropTypes.number,
|
861 |
+
trianglePointValue: PropTypes.number,
|
862 |
+
currentlySelectedShape: PropTypes.string,
|
863 |
+
fillBitmapShapes: PropTypes.bool,
|
864 |
+
format: PropTypes.oneOf(Object.keys(Formats)),
|
865 |
+
hasSelectedUncurvedPoints: PropTypes.bool,
|
866 |
+
hasSelectedUnpointedPoints: PropTypes.bool,
|
867 |
+
intl: intlShape.isRequired,
|
868 |
+
mode: PropTypes.string.isRequired,
|
869 |
+
onBitBrushSliderChange: PropTypes.func.isRequired,
|
870 |
+
onBitEraserSliderChange: PropTypes.func.isRequired,
|
871 |
+
onBrushSliderChange: PropTypes.func.isRequired,
|
872 |
+
onSimplifySliderChange: PropTypes.func.isRequired,
|
873 |
+
onCopyToClipboard: PropTypes.func.isRequired,
|
874 |
+
onCutToClipboard: PropTypes.func.isRequired,
|
875 |
+
onCurvePoints: PropTypes.func.isRequired,
|
876 |
+
onDelete: PropTypes.func.isRequired,
|
877 |
+
onEraserSliderChange: PropTypes.func,
|
878 |
+
onBrushChange: PropTypes.func,
|
879 |
+
onEraserSimplifySliderChange: PropTypes.func,
|
880 |
+
onPenSimplifySliderChange: PropTypes.func,
|
881 |
+
onFillShapes: PropTypes.func.isRequired,
|
882 |
+
onFlipHorizontal: PropTypes.func.isRequired,
|
883 |
+
onFlipVertical: PropTypes.func.isRequired,
|
884 |
+
onCenterSelection: PropTypes.func.isRequired,
|
885 |
+
onManageFonts: PropTypes.func,
|
886 |
+
onOutlineShapes: PropTypes.func.isRequired,
|
887 |
+
onPasteFromClipboard: PropTypes.func.isRequired,
|
888 |
+
onPointPoints: PropTypes.func.isRequired,
|
889 |
+
onUpdateImage: PropTypes.func.isRequired,
|
890 |
+
|
891 |
+
onMergeShape: PropTypes.func.isRequired,
|
892 |
+
onMaskShape: PropTypes.func.isRequired,
|
893 |
+
onSubtractShape: PropTypes.func.isRequired,
|
894 |
+
onExcludeShape: PropTypes.func.isRequired
|
895 |
+
};
|
896 |
+
|
897 |
+
const mapStateToProps = state => ({
|
898 |
+
mode: state.scratchPaint.mode,
|
899 |
+
format: state.scratchPaint.format,
|
900 |
+
fillBitmapShapes: state.scratchPaint.fillBitmapShapes,
|
901 |
+
bitBrushSize: state.scratchPaint.bitBrushSize,
|
902 |
+
bitEraserSize: state.scratchPaint.bitEraserSize,
|
903 |
+
brushValue: state.scratchPaint.brushMode.brushSize,
|
904 |
+
simplifyValue: state.scratchPaint.brushMode.simplifySize,
|
905 |
+
clipboardItems: state.scratchPaint.clipboard.items,
|
906 |
+
eraserValue: state.scratchPaint.eraserMode.brushSize,
|
907 |
+
eraserSimplifyValue: state.scratchPaint.eraserMode.simplifySize,
|
908 |
+
brushType: state.scratchPaint.brushType,
|
909 |
+
penSimplifyValue: state.scratchPaint.penMode.simplifySize,
|
910 |
+
roundedRectCornerValue: state.scratchPaint.roundedRectMode.roundedCornerSize,
|
911 |
+
roundedCornerValue: state.scratchPaint.rectMode.roundedCornerSize,
|
912 |
+
trianglePolyValue: state.scratchPaint.triangleMode.trianglePolyCount,
|
913 |
+
trianglePointValue: state.scratchPaint.triangleMode.trianglePointCount,
|
914 |
+
currentlySelectedShape: state.scratchPaint.sussyMode.shape
|
915 |
+
});
|
916 |
+
const mapDispatchToProps = dispatch => ({
|
917 |
+
onBrushSliderChange: brushSize => {
|
918 |
+
dispatch(changeBrushSize(brushSize));
|
919 |
+
},
|
920 |
+
onSimplifySliderChange: brushSize => {
|
921 |
+
dispatch(changeSimplifySize(brushSize));
|
922 |
+
},
|
923 |
+
onRoundedRectCornerSliderChange: roundedCornerSize => {
|
924 |
+
dispatch(changeRoundedRectCornerSize(roundedCornerSize));
|
925 |
+
},
|
926 |
+
onRoundedCornerSliderChange: roundedCornerSize => {
|
927 |
+
dispatch(changeRoundedCornerSize(roundedCornerSize));
|
928 |
+
},
|
929 |
+
onPolyCountSliderChange: polyCount => {
|
930 |
+
dispatch(changeTrianglePolyCount(polyCount));
|
931 |
+
},
|
932 |
+
onPointCountSliderChange: polyCount => {
|
933 |
+
dispatch(changeTrianglePointCount(polyCount));
|
934 |
+
},
|
935 |
+
onCurrentlySelectedShapeChange: shape => {
|
936 |
+
dispatch(changeCurrentlySelectedShape(shape));
|
937 |
+
},
|
938 |
+
onBitBrushSliderChange: bitBrushSize => {
|
939 |
+
dispatch(changeBitBrushSize(bitBrushSize));
|
940 |
+
},
|
941 |
+
onBitEraserSliderChange: eraserSize => {
|
942 |
+
dispatch(changeBitEraserSize(eraserSize));
|
943 |
+
},
|
944 |
+
onEraserSliderChange: eraserSize => {
|
945 |
+
dispatch(changeEraserSize(eraserSize));
|
946 |
+
},
|
947 |
+
onEraserSimplifySliderChange: eraserSize => {
|
948 |
+
dispatch(changeEraserSimplifySize(eraserSize));
|
949 |
+
},
|
950 |
+
onBrushChange: type => {
|
951 |
+
dispatch(setBrushType(type));
|
952 |
+
},
|
953 |
+
onPenSimplifySliderChange: eraserSize => {
|
954 |
+
dispatch(changePenSimplifySize(eraserSize));
|
955 |
+
},
|
956 |
+
onFillShapes: () => {
|
957 |
+
dispatch(setShapesFilled(true));
|
958 |
+
},
|
959 |
+
onOutlineShapes: () => {
|
960 |
+
dispatch(setShapesFilled(false));
|
961 |
+
},
|
962 |
+
onTextAlignLeft: () => {
|
963 |
+
dispatch(setTextAlignment("left"));
|
964 |
+
},
|
965 |
+
onTextAlignRight: () => {
|
966 |
+
dispatch(setTextAlignment("right"));
|
967 |
+
},
|
968 |
+
onTextAlignCenter: () => {
|
969 |
+
dispatch(setTextAlignment("center"));
|
970 |
+
},
|
971 |
+
});
|
972 |
+
|
973 |
+
export default connect(
|
974 |
+
mapStateToProps,
|
975 |
+
mapDispatchToProps
|
976 |
+
)(injectIntl(ModeToolsComponent));
|