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-01-19 13:21:33 -08:00
|
|
|
import { KEYS } from "../keys";
|
2020-02-09 09:07:34 -05:00
|
|
|
import { t } from "../i18n";
|
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-02-01 17:37:22 +01:00
|
|
|
keyTest: event => event[KEYS.META] && event.altKey && event.key === "B",
|
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-02-09 09:07:34 -05:00
|
|
|
title={t("labels.sendBackward")}
|
|
|
|
>
|
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-02-01 17:37:22 +01:00
|
|
|
keyTest: event => event[KEYS.META] && event.altKey && event.key === "F",
|
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-02-09 09:07:34 -05:00
|
|
|
title={t("labels.bringForward")}
|
|
|
|
>
|
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-02-01 17:37:22 +01:00
|
|
|
keyTest: event => event[KEYS.META] && event.shiftKey && event.key === "B",
|
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-02-09 09:07:34 -05:00
|
|
|
title={t("labels.sendToBack")}
|
|
|
|
>
|
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-02-01 17:37:22 +01:00
|
|
|
keyTest: event => event[KEYS.META] && event.shiftKey && event.key === "F",
|
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-02-09 09:07:34 -05:00
|
|
|
title={t("labels.bringToFront")}
|
|
|
|
>
|
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
|
|
|
});
|