2020-02-09 09:07:34 -05:00
|
|
|
import React from "react";
|
2020-01-12 02:22:03 +04:00
|
|
|
import {
|
|
|
|
moveOneLeft,
|
|
|
|
moveOneRight,
|
|
|
|
moveAllLeft,
|
2020-01-24 12:04:54 +02:00
|
|
|
moveAllRight,
|
2020-01-12 02:22:03 +04:00
|
|
|
} from "../zindex";
|
|
|
|
import { getSelectedIndices } from "../scene";
|
2020-03-09 15:06:35 +02:00
|
|
|
import { KEYS, isDarwin } from "../keys";
|
2020-02-09 09:07:34 -05:00
|
|
|
import { t } from "../i18n";
|
2020-03-09 15:06:35 +02:00
|
|
|
import { getShortcutKey } from "../utils";
|
2020-03-07 10:20:38 -05:00
|
|
|
import { register } from "./register";
|
|
|
|
import {
|
|
|
|
sendBackward,
|
|
|
|
bringToFront,
|
|
|
|
sendToBack,
|
|
|
|
bringForward,
|
|
|
|
} from "../components/icons";
|
2020-02-09 09:07:34 -05:00
|
|
|
|
2020-03-07 10:20:38 -05:00
|
|
|
export const actionSendBackward = register({
|
2020-01-12 02:22:03 +04:00
|
|
|
name: "sendBackward",
|
|
|
|
perform: (elements, appState) => {
|
|
|
|
return {
|
2020-03-08 10:20:55 -07:00
|
|
|
elements: moveOneLeft(
|
|
|
|
[...elements],
|
|
|
|
getSelectedIndices(elements, appState),
|
|
|
|
),
|
2020-01-24 12:04:54 +02:00
|
|
|
appState,
|
2020-01-12 02:22:03 +04:00
|
|
|
};
|
|
|
|
},
|
2020-01-21 01:14:10 +02:00
|
|
|
contextItemLabel: "labels.sendBackward",
|
2020-01-12 02:22:03 +04:00
|
|
|
keyPriority: 40,
|
2020-02-05 22:47:10 +04:00
|
|
|
commitToHistory: () => true,
|
2020-03-09 15:06:35 +02:00
|
|
|
keyTest: event =>
|
|
|
|
event[KEYS.CTRL_OR_CMD] && !event.shiftKey && event.code === "BracketLeft",
|
2020-02-09 09:07:34 -05:00
|
|
|
PanelComponent: ({ updateData }) => (
|
|
|
|
<button
|
|
|
|
type="button"
|
|
|
|
className="zIndexButton"
|
2020-03-07 10:20:38 -05:00
|
|
|
onClick={() => updateData(null)}
|
2020-03-09 15:06:35 +02:00
|
|
|
title={`${t("labels.sendBackward")} ${getShortcutKey("CtrlOrCmd+[")}`}
|
2020-02-09 09:07:34 -05:00
|
|
|
>
|
2020-03-07 10:20:38 -05:00
|
|
|
{sendBackward}
|
2020-02-09 09:07:34 -05:00
|
|
|
</button>
|
|
|
|
),
|
2020-03-07 10:20:38 -05:00
|
|
|
});
|
2020-01-12 02:22:03 +04:00
|
|
|
|
2020-03-07 10:20:38 -05:00
|
|
|
export const actionBringForward = register({
|
2020-01-12 02:22:03 +04:00
|
|
|
name: "bringForward",
|
|
|
|
perform: (elements, appState) => {
|
|
|
|
return {
|
2020-03-08 10:20:55 -07:00
|
|
|
elements: moveOneRight(
|
|
|
|
[...elements],
|
|
|
|
getSelectedIndices(elements, appState),
|
|
|
|
),
|
2020-01-24 12:04:54 +02:00
|
|
|
appState,
|
2020-01-12 02:22:03 +04:00
|
|
|
};
|
|
|
|
},
|
2020-01-21 01:14:10 +02:00
|
|
|
contextItemLabel: "labels.bringForward",
|
2020-01-12 02:22:03 +04:00
|
|
|
keyPriority: 40,
|
2020-02-05 22:47:10 +04:00
|
|
|
commitToHistory: () => true,
|
2020-03-09 15:06:35 +02:00
|
|
|
keyTest: event =>
|
|
|
|
event[KEYS.CTRL_OR_CMD] && !event.shiftKey && event.code === "BracketRight",
|
2020-02-09 09:07:34 -05:00
|
|
|
PanelComponent: ({ updateData }) => (
|
|
|
|
<button
|
|
|
|
type="button"
|
|
|
|
className="zIndexButton"
|
2020-03-07 10:20:38 -05:00
|
|
|
onClick={() => updateData(null)}
|
2020-03-09 15:06:35 +02:00
|
|
|
title={`${t("labels.bringForward")} ${getShortcutKey("CtrlOrCmd+]")}`}
|
2020-02-09 09:07:34 -05:00
|
|
|
>
|
2020-03-07 10:20:38 -05:00
|
|
|
{bringForward}
|
2020-02-09 09:07:34 -05:00
|
|
|
</button>
|
|
|
|
),
|
2020-03-07 10:20:38 -05:00
|
|
|
});
|
2020-01-12 02:22:03 +04:00
|
|
|
|
2020-03-07 10:20:38 -05:00
|
|
|
export const actionSendToBack = register({
|
2020-01-12 02:22:03 +04:00
|
|
|
name: "sendToBack",
|
|
|
|
perform: (elements, appState) => {
|
|
|
|
return {
|
2020-03-08 10:20:55 -07:00
|
|
|
elements: moveAllLeft(
|
|
|
|
[...elements],
|
|
|
|
getSelectedIndices(elements, appState),
|
|
|
|
),
|
2020-01-24 12:04:54 +02:00
|
|
|
appState,
|
2020-01-12 02:22:03 +04:00
|
|
|
};
|
|
|
|
},
|
2020-01-21 01:14:10 +02:00
|
|
|
contextItemLabel: "labels.sendToBack",
|
2020-02-05 22:47:10 +04:00
|
|
|
commitToHistory: () => true,
|
2020-03-09 15:06:35 +02:00
|
|
|
keyTest: event => {
|
|
|
|
return isDarwin
|
|
|
|
? event[KEYS.CTRL_OR_CMD] && event.altKey && event.code === "BracketLeft"
|
|
|
|
: event[KEYS.CTRL_OR_CMD] &&
|
|
|
|
event.shiftKey &&
|
|
|
|
event.code === "BracketLeft";
|
|
|
|
},
|
2020-02-09 09:07:34 -05:00
|
|
|
PanelComponent: ({ updateData }) => (
|
|
|
|
<button
|
|
|
|
type="button"
|
|
|
|
className="zIndexButton"
|
2020-03-07 10:20:38 -05:00
|
|
|
onClick={() => updateData(null)}
|
2020-03-09 15:06:35 +02:00
|
|
|
title={`${t("labels.sendToBack")} ${
|
|
|
|
isDarwin
|
|
|
|
? getShortcutKey("CtrlOrCmd+Alt+[")
|
|
|
|
: getShortcutKey("CtrlOrCmd+Shift+[")
|
|
|
|
}`}
|
2020-02-09 09:07:34 -05:00
|
|
|
>
|
2020-03-07 10:20:38 -05:00
|
|
|
{sendToBack}
|
2020-02-09 09:07:34 -05:00
|
|
|
</button>
|
|
|
|
),
|
2020-03-07 10:20:38 -05:00
|
|
|
});
|
2020-01-12 02:22:03 +04:00
|
|
|
|
2020-03-07 10:20:38 -05:00
|
|
|
export const actionBringToFront = register({
|
2020-01-12 02:22:03 +04:00
|
|
|
name: "bringToFront",
|
|
|
|
perform: (elements, appState) => {
|
|
|
|
return {
|
2020-03-08 10:20:55 -07:00
|
|
|
elements: moveAllRight(
|
|
|
|
[...elements],
|
|
|
|
getSelectedIndices(elements, appState),
|
|
|
|
),
|
2020-01-24 12:04:54 +02:00
|
|
|
appState,
|
2020-01-12 02:22:03 +04:00
|
|
|
};
|
|
|
|
},
|
2020-02-05 22:47:10 +04:00
|
|
|
commitToHistory: () => true,
|
2020-01-21 01:14:10 +02:00
|
|
|
contextItemLabel: "labels.bringToFront",
|
2020-03-09 15:06:35 +02:00
|
|
|
keyTest: event => {
|
|
|
|
return isDarwin
|
|
|
|
? event[KEYS.CTRL_OR_CMD] && event.altKey && event.code === "BracketRight"
|
|
|
|
: event[KEYS.CTRL_OR_CMD] &&
|
|
|
|
event.shiftKey &&
|
|
|
|
event.code === "BracketRight";
|
|
|
|
},
|
2020-02-09 09:07:34 -05:00
|
|
|
PanelComponent: ({ updateData }) => (
|
|
|
|
<button
|
|
|
|
type="button"
|
|
|
|
className="zIndexButton"
|
2020-02-28 23:03:53 +01:00
|
|
|
onClick={event => updateData(null)}
|
2020-03-09 15:06:35 +02:00
|
|
|
title={`${t("labels.bringToFront")} ${
|
|
|
|
isDarwin
|
|
|
|
? getShortcutKey("CtrlOrCmd+Alt+]")
|
|
|
|
: getShortcutKey("CtrlOrCmd+Shift+]")
|
|
|
|
}`}
|
2020-02-09 09:07:34 -05:00
|
|
|
>
|
2020-03-07 10:20:38 -05:00
|
|
|
{bringToFront}
|
2020-02-09 09:07:34 -05:00
|
|
|
</button>
|
|
|
|
),
|
2020-03-07 10:20:38 -05:00
|
|
|
});
|