// Copyright (c) 2019-present Dmitry Stepanov and Fyrox Engine contributors. // // Permission is hereby granted, free of charge, to any person obtaining a copy // of this software and associated documentation files (the "Software"), to deal // in the Software without restriction, including without limitation the rights // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell // copies of the Software, and to permit persons to whom the Software is // furnished to do so, subject to the following conditions: // // The above copyright notice and this permission notice shall be included in all // copies or substantial portions of the Software. // // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE // SOFTWARE. use crate::{ command::{Command, CommandContext, CommandStack, CommandTrait}, fyrox::{ asset::manager::ResourceManager, asset::Resource, core::{ futures::executor::block_on, math::curve::Curve, pool::Handle, reflect::prelude::*, some_or_return, visitor::prelude::*, }, engine::Engine, gui::{ border::BorderBuilder, button::{ButtonBuilder, ButtonMessage}, curve::{CurveEditorBuilder, CurveEditorMessage}, file_browser::FileSelectorMessage, grid::{Column, GridBuilder, Row}, menu::{MenuBuilder, MenuItemBuilder, MenuItemContent, MenuItemMessage}, message::UiMessage, messagebox::{MessageBoxBuilder, MessageBoxResult}, stack_panel::StackPanelBuilder, widget::{WidgetBuilder, WidgetMessage}, window::{WindowBuilder, WindowMessage, WindowTitle}, BuildContext, HorizontalAlignment, Orientation, Thickness, UserInterface, }, gui::{ button::Button, curve::CurveEditor, file_browser::{FileSelector, FileSelectorMode, FileType}, menu::MenuItem, messagebox::MessageBox, style::resource::StyleResourceExt, style::Style, window::{Window, WindowAlignment}, }, resource::curve::{CurveResource, CurveResourceState}, }, menu::create_menu_item, plugin::EditorPlugin, utils::create_file_selector, Editor, MessageBoxButtons, MessageBoxMessage, }; use std::{fmt::Debug, path::PathBuf}; #[derive(PartialEq, Reflect, Clone, Debug)] #[reflect(type_uuid = "f29aa9c7-e0c4-4602-8588-3e8a20ab7cdc")] pub struct CurveEditorContext {} impl CommandContext for CurveEditorContext {} #[derive(Debug)] struct ModifyCurveCommand { curve_resource: CurveResource, curve: Curve, } impl ModifyCurveCommand { fn swap(&mut self) { std::mem::swap(&mut self.curve_resource.data_ref().curve, &mut self.curve); } } impl CommandTrait for ModifyCurveCommand { fn name(&mut self, _: &dyn CommandContext) -> String { "Modify Curve".to_owned() } fn execute(&mut self, _: &mut dyn CommandContext) { self.swap(); } fn revert(&mut self, _: &mut dyn CommandContext) { self.swap(); } } struct FileMenu { new: Handle, save: Handle, load: Handle, } struct EditMenu { undo: Handle, redo: Handle, } struct Menu { file: FileMenu, edit: EditMenu, } pub struct CurveEditorWindow { window: Handle, curve_editor: Handle, ok: Handle