mirror of
https://github.com/storytold/artcraft.git
synced 2026-11-16 23:03:06 +00:00
* can add text retain stroke width while transforming is now possible reorganize how the inheritance of node classes, now text can be selected, multi-selected, translate and transform, all while working with the unredo stack organize toolbarmain and dialogues, now add text brings up a dialog, meant for accepting user text input finished plumbing the data from user text input to adding text to baord clean up make the dialog less weirdly vertical clean up, and place node in the center of canvas block adding text with no text, make textbox wider transformation of old node works with new transformation setup undo redo of transformation also works for text nodes now cleanup geometry fix almost done text editor ui text formatting from text editor is sent to engine and used on text nodes * rid of useless button
107 lines
2.8 KiB
TypeScript
107 lines
2.8 KiB
TypeScript
import { useCallback } from "react";
|
|
import { Signal } from "@preact/signals-react";
|
|
import { dispatchUiEvents } from "~/signals";
|
|
import {
|
|
DialogAddImage,
|
|
DialogAddVideo,
|
|
DialogAiStylize,
|
|
DialogChromakey,
|
|
DialogEditText,
|
|
DialogError,
|
|
} from "~/components/features";
|
|
|
|
import { AppUiSignalType } from "./contextSignals/appUi";
|
|
import { dialogError } from "~/signals/uiAccess/dialogError";
|
|
import { dialogChromakey } from "~/signals/uiAccess/dialogChromakey";
|
|
|
|
export const SignaledDialogs = ({
|
|
appUiSignal,
|
|
resetAll,
|
|
}: {
|
|
appUiSignal: Signal<AppUiSignalType>;
|
|
resetAll: () => void;
|
|
}) => {
|
|
return (
|
|
<>
|
|
{/* Dialogs that are opened from within Reactland*/}
|
|
<DialogAddImage
|
|
isOpen={appUiSignal.value.isAddImageOpen ?? false}
|
|
stagedImage={appUiSignal.value.stagedImage}
|
|
closeCallback={resetAll}
|
|
onAddImage={(file) => {
|
|
dispatchUiEvents.addImageToEngine(file);
|
|
}}
|
|
/>
|
|
<DialogAddVideo
|
|
isOpen={appUiSignal.value.isAddVideoOpen ?? false}
|
|
stagedVideo={appUiSignal.value.stagedVideo}
|
|
closeCallback={resetAll}
|
|
onUploadedVideo={(response) => {
|
|
if (!response.data) {
|
|
return;
|
|
}
|
|
dispatchUiEvents.addVideoToEngine({
|
|
url: response.data.public_bucket_url,
|
|
});
|
|
}}
|
|
/>
|
|
<DialogAiStylize
|
|
isOpen={appUiSignal.value.isAiStylizeOpen ?? false}
|
|
onRequestAIStylize={(data) => {
|
|
const { selectedArtStyle: artstyle, ...rest } = data;
|
|
dispatchUiEvents.aiStylize.dispatchRequest({
|
|
artstyle,
|
|
...rest,
|
|
});
|
|
}}
|
|
closeCallback={resetAll}
|
|
/>
|
|
<DialogEditText
|
|
isOpen={appUiSignal.value.isEditTextOpen ?? false}
|
|
onDoneEditText={(data) => {
|
|
dispatchUiEvents.addTextToEngine(data);
|
|
}}
|
|
closeCallback={resetAll}
|
|
/>
|
|
{/* Dialogs that are opened from the Engine*/}
|
|
<SignaledDialogChromakey />
|
|
<SignaledDialogError />
|
|
</>
|
|
);
|
|
};
|
|
|
|
const SignaledDialogError = () => {
|
|
const props = dialogError.signal.value;
|
|
const { isShowing, title, message } = props;
|
|
const onClose = useCallback(() => {
|
|
dialogError.hide();
|
|
}, []);
|
|
return (
|
|
<DialogError
|
|
isShowing={isShowing}
|
|
title={title}
|
|
message={message}
|
|
onClose={onClose}
|
|
/>
|
|
);
|
|
};
|
|
|
|
const SignaledDialogChromakey = () => {
|
|
const props = dialogChromakey.signal.value;
|
|
const { isShowing, chromakeyProps } = props;
|
|
const onClose = useCallback(() => {
|
|
dialogChromakey.hide();
|
|
}, []);
|
|
const onConfirm = (newProps: typeof chromakeyProps) => {
|
|
dispatchUiEvents.dispatchChromakeyRequest(newProps);
|
|
};
|
|
return (
|
|
<DialogChromakey
|
|
isShowing={isShowing}
|
|
{...chromakeyProps}
|
|
onClose={onClose}
|
|
onConfirm={onConfirm}
|
|
/>
|
|
);
|
|
};
|