mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-15 22:28:10 +08:00
Remove dead code for Imaginate
This commit is contained in:
@@ -55,53 +55,3 @@ pub fn commit_info_localized(localized_commit_date: &str) -> String {
|
||||
localized_commit_date
|
||||
)
|
||||
}
|
||||
|
||||
// #[cfg(test)]
|
||||
// mod test {
|
||||
// use crate::messages::input_mapper::utility_types::input_mouse::ViewportBounds;
|
||||
// use crate::messages::prelude::*;
|
||||
|
||||
// // TODO: Fix and reenable
|
||||
// #[ignore]
|
||||
// #[test]
|
||||
// fn debug_ub() {
|
||||
// use super::Message;
|
||||
|
||||
// let mut editor = super::Editor::new();
|
||||
// let mut responses = Vec::new();
|
||||
|
||||
// let messages: Vec<Message> = vec![
|
||||
// Message::Init,
|
||||
// Message::Preferences(PreferencesMessage::Load {
|
||||
// preferences: r#"{ "imaginate_server_hostname": "http://localhost:7860/", "imaginate_refresh_frequency": 1, "zoom_with_scroll": false }"#.to_string(),
|
||||
// }),
|
||||
// PortfolioMessage::OpenDocumentFileWithId {
|
||||
// document_id: DocumentId(0),
|
||||
// document_name: "".into(),
|
||||
// document_is_auto_saved: true,
|
||||
// document_is_saved: true,
|
||||
// document_serialized_content: r#" [removed until test is reenabled] "#.into(),
|
||||
// to_front: false,
|
||||
// }
|
||||
// .into(),
|
||||
// InputPreprocessorMessage::BoundsOfViewports {
|
||||
// bounds_of_viewports: vec![ViewportBounds::from_slice(&[0., 0., 1920., 1080.])],
|
||||
// }
|
||||
// .into(),
|
||||
// ];
|
||||
|
||||
// use futures::executor::block_on;
|
||||
// for message in messages {
|
||||
// block_on(crate::node_graph_executor::run_node_graph());
|
||||
// let mut res = VecDeque::new();
|
||||
// editor.poll_node_graph_evaluation(&mut res).expect("poll_node_graph_evaluation failed");
|
||||
|
||||
// let res = editor.handle_message(message);
|
||||
// responses.push(res);
|
||||
// }
|
||||
// let responses = responses.pop().unwrap();
|
||||
// // let trigger_message = responses[responses.len() - 2].clone();
|
||||
|
||||
// println!("responses: {responses:#?}");
|
||||
// }
|
||||
// }
|
||||
|
||||
@@ -204,27 +204,6 @@ impl PreferencesDialogMessageHandler {
|
||||
.widget_holder(),
|
||||
];
|
||||
|
||||
// TODO: Reenable when Imaginate is restored
|
||||
// let imaginate_server_hostname = vec![
|
||||
// TextLabel::new("Imaginate").min_width(60).italic(true).widget_holder(),
|
||||
// TextLabel::new("Server Hostname").table_align(true).widget_holder(),
|
||||
// TextInput::new(&preferences.imaginate_server_hostname)
|
||||
// .min_width(200)
|
||||
// .on_update(|text_input: &TextInput| PreferencesMessage::ImaginateServerHostname { hostname: text_input.value.clone() }.into())
|
||||
// .widget_holder(),
|
||||
// ];
|
||||
// let imaginate_refresh_frequency = vec![
|
||||
// TextLabel::new("").min_width(60).widget_holder(),
|
||||
// TextLabel::new("Refresh Frequency").table_align(true).widget_holder(),
|
||||
// NumberInput::new(Some(preferences.imaginate_refresh_frequency))
|
||||
// .unit(" seconds")
|
||||
// .min(0.)
|
||||
// .max((1_u64 << f64::MANTISSA_DIGITS) as f64)
|
||||
// .min_width(200)
|
||||
// .on_update(|number_input: &NumberInput| PreferencesMessage::ImaginateRefreshFrequency { seconds: number_input.value.unwrap() }.into())
|
||||
// .widget_holder(),
|
||||
// ];
|
||||
|
||||
Layout::WidgetLayout(WidgetLayout::new(vec![
|
||||
LayoutGroup::Row { widgets: navigation_header },
|
||||
LayoutGroup::Row { widgets: zoom_rate_label },
|
||||
@@ -238,8 +217,6 @@ impl PreferencesDialogMessageHandler {
|
||||
LayoutGroup::Row { widgets: graph_wire_style },
|
||||
LayoutGroup::Row { widgets: use_vello },
|
||||
LayoutGroup::Row { widgets: vector_meshes },
|
||||
// LayoutGroup::Row { widgets: imaginate_server_hostname },
|
||||
// LayoutGroup::Row { widgets: imaginate_refresh_frequency },
|
||||
]))
|
||||
}
|
||||
|
||||
|
||||
@@ -206,13 +206,6 @@ pub fn input_mappings() -> Mapping {
|
||||
entry!(KeyDown(ArrowUp); action_dispatch=ShapeToolMessage::IncreaseSides),
|
||||
entry!(KeyDown(ArrowDown); action_dispatch=ShapeToolMessage::DecreaseSides),
|
||||
//
|
||||
// ImaginateToolMessage
|
||||
// entry!(KeyDown(MouseLeft); action_dispatch=ImaginateToolMessage::DragStart),
|
||||
// entry!(KeyUp(MouseLeft); action_dispatch=ImaginateToolMessage::DragStop),
|
||||
// entry!(KeyDown(MouseRight); action_dispatch=ImaginateToolMessage::Abort),
|
||||
// entry!(KeyDown(Escape); action_dispatch=ImaginateToolMessage::Abort),
|
||||
// entry!(PointerMove; refresh_keys=[Alt, Shift], action_dispatch=ImaginateToolMessage::Resize { center: Alt, lock_ratio: Shift }),
|
||||
//
|
||||
// PathToolMessage
|
||||
entry!(KeyDown(Delete); modifiers=[Accel], action_dispatch=PathToolMessage::DeleteAndBreakPath),
|
||||
entry!(KeyDown(Backspace); modifiers=[Accel], action_dispatch=PathToolMessage::DeleteAndBreakPath),
|
||||
|
||||
@@ -73,13 +73,6 @@ pub enum DocumentMessage {
|
||||
GroupSelectedLayers {
|
||||
group_folder_type: GroupFolderType,
|
||||
},
|
||||
// ImaginateGenerate {
|
||||
// imaginate_node: Vec<NodeId>,
|
||||
// },
|
||||
// ImaginateRandom {
|
||||
// imaginate_node: Vec<NodeId>,
|
||||
// then_generate: bool,
|
||||
// },
|
||||
MoveSelectedLayersTo {
|
||||
parent: LayerNodeIdentifier,
|
||||
insert_index: usize,
|
||||
|
||||
@@ -613,37 +613,6 @@ impl MessageHandler<DocumentMessage, DocumentMessageData<'_>> for DocumentMessag
|
||||
responses.add(NodeGraphMessage::SelectedNodesSet { nodes: new_folders });
|
||||
}
|
||||
}
|
||||
// DocumentMessage::ImaginateGenerate { imaginate_node } => {
|
||||
// let random_value = generate_uuid();
|
||||
// responses.add(NodeGraphMessage::SetInputValue {
|
||||
// node_id: *imaginate_node.last().unwrap(),
|
||||
// // Needs to match the index of the seed parameter in `pub const IMAGINATE_NODE: DocumentNodeDefinition` in `document_node_type.rs`
|
||||
// input_index: 17,
|
||||
// value: graph_craft::document::value::TaggedValue::U64(random_value),
|
||||
// });
|
||||
|
||||
// responses.add(PortfolioMessage::SubmitGraphRender { document_id, ignore_hash: false });
|
||||
// }
|
||||
// DocumentMessage::ImaginateRandom { imaginate_node, then_generate } => {
|
||||
// // Generate a random seed. We only want values between -2^53 and 2^53, because integer values
|
||||
// // outside of this range can get rounded in f64
|
||||
// let random_bits = generate_uuid();
|
||||
// let random_value = ((random_bits >> 11) as f64).copysign(f64::from_bits(random_bits & (1 << 63)));
|
||||
|
||||
// responses.add(DocumentMessage::AddTransaction);
|
||||
// // Set a random seed input
|
||||
// responses.add(NodeGraphMessage::SetInputValue {
|
||||
// node_id: *imaginate_node.last().unwrap(),
|
||||
// // Needs to match the index of the seed parameter in `pub const IMAGINATE_NODE: DocumentNodeDefinition` in `document_node_type.rs`
|
||||
// input_index: 3,
|
||||
// value: graph_craft::document::value::TaggedValue::F64(random_value),
|
||||
// });
|
||||
|
||||
// // Generate the image
|
||||
// if then_generate {
|
||||
// responses.add(DocumentMessage::ImaginateGenerate { imaginate_node });
|
||||
// }
|
||||
// }
|
||||
DocumentMessage::MoveSelectedLayersTo { parent, insert_index } => {
|
||||
if !self.selection_network_path.is_empty() {
|
||||
log::error!("Moving selected layers is only supported for the Document Network");
|
||||
|
||||
@@ -1466,7 +1466,6 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
|
||||
// description: Cow::Borrowed("TODO"),
|
||||
// properties: None,
|
||||
// },
|
||||
// (*IMAGINATE_NODE).clone(),
|
||||
DocumentNodeDefinition {
|
||||
identifier: "Path",
|
||||
category: "Vector",
|
||||
@@ -2119,128 +2118,6 @@ fn static_nodes() -> Vec<DocumentNodeDefinition> {
|
||||
document_node_derive::post_process_nodes(custom)
|
||||
}
|
||||
|
||||
// pub static IMAGINATE_NODE: Lazy<DocumentNodeDefinition> = Lazy::new(|| DocumentNodeDefinition {
|
||||
// identifier: "Imaginate",
|
||||
// category: "Raster",
|
||||
// node_template: NodeTemplate {
|
||||
// document_node: DocumentNode {
|
||||
// implementation: DocumentNodeImplementation::Network(NodeNetwork {
|
||||
// exports: vec![NodeInput::node(NodeId(1), 0)],
|
||||
// nodes: [
|
||||
// DocumentNode {
|
||||
// inputs: vec![NodeInput::network(concrete!(RasterDataTable<CPU>), 0)],
|
||||
// implementation: DocumentNodeImplementation::proto("graphene_core::memo::MonitorNode"),
|
||||
// manual_composition: Some(concrete!(Context)),
|
||||
// skip_deduplication: true,
|
||||
// ..Default::default()
|
||||
// },
|
||||
// DocumentNode {
|
||||
// inputs: vec![
|
||||
// NodeInput::node(NodeId(0), 0),
|
||||
// NodeInput::network(concrete!(&WasmEditorApi), 1),
|
||||
// NodeInput::network(concrete!(ImaginateController), 2),
|
||||
// NodeInput::network(concrete!(f64), 3),
|
||||
// NodeInput::network(concrete!(Option<DVec2>), 4),
|
||||
// NodeInput::network(concrete!(u32), 5),
|
||||
// NodeInput::network(concrete!(ImaginateSamplingMethod), 6),
|
||||
// NodeInput::network(concrete!(f64), 7),
|
||||
// NodeInput::network(concrete!(String), 8),
|
||||
// NodeInput::network(concrete!(String), 9),
|
||||
// NodeInput::network(concrete!(bool), 10),
|
||||
// NodeInput::network(concrete!(f64), 11),
|
||||
// NodeInput::network(concrete!(bool), 12),
|
||||
// NodeInput::network(concrete!(f64), 13),
|
||||
// NodeInput::network(concrete!(ImaginateMaskStartingFill), 14),
|
||||
// NodeInput::network(concrete!(bool), 15),
|
||||
// NodeInput::network(concrete!(bool), 16),
|
||||
// NodeInput::network(concrete!(u64), 17),
|
||||
// ],
|
||||
// implementation: DocumentNodeImplementation::proto("graphene_std::raster::ImaginateNode"),
|
||||
// ..Default::default()
|
||||
// },
|
||||
// ]
|
||||
// .into_iter()
|
||||
// .enumerate()
|
||||
// .map(|(id, node)| (NodeId(id as u64), node))
|
||||
// .collect(),
|
||||
// ..Default::default()
|
||||
// }),
|
||||
// inputs: vec![
|
||||
// NodeInput::value(TaggedValue::RasterData(RasterDataTable::default()), true),
|
||||
// NodeInput::scope("editor-api"),
|
||||
// NodeInput::value(TaggedValue::ImaginateController(Default::default()), false),
|
||||
// NodeInput::value(TaggedValue::F64(0.), false), // Remember to keep index used in `ImaginateRandom` updated with this entry's index
|
||||
// NodeInput::value(TaggedValue::OptionalDVec2(None), false),
|
||||
// NodeInput::value(TaggedValue::U32(30), false),
|
||||
// NodeInput::value(TaggedValue::ImaginateSamplingMethod(ImaginateSamplingMethod::EulerA), false),
|
||||
// NodeInput::value(TaggedValue::F64(7.5), false),
|
||||
// NodeInput::value(TaggedValue::String(String::new()), false),
|
||||
// NodeInput::value(TaggedValue::String(String::new()), false),
|
||||
// NodeInput::value(TaggedValue::Bool(false), false),
|
||||
// NodeInput::value(TaggedValue::F64(66.), false),
|
||||
// NodeInput::value(TaggedValue::Bool(true), false),
|
||||
// NodeInput::value(TaggedValue::F64(4.), false),
|
||||
// NodeInput::value(TaggedValue::ImaginateMaskStartingFill(ImaginateMaskStartingFill::Fill), false),
|
||||
// NodeInput::value(TaggedValue::Bool(false), false),
|
||||
// NodeInput::value(TaggedValue::Bool(false), false),
|
||||
// NodeInput::value(TaggedValue::U64(0), false),
|
||||
// ],
|
||||
// ..Default::default()
|
||||
// },
|
||||
// persistent_node_metadata: DocumentNodePersistentMetadata {
|
||||
// network_metadata: Some(NodeNetworkMetadata {
|
||||
// persistent_metadata: NodeNetworkPersistentMetadata {
|
||||
// node_metadata: [
|
||||
// DocumentNodeMetadata {
|
||||
// persistent_metadata: DocumentNodePersistentMetadata {
|
||||
// display_name: "Monitor".to_string(),
|
||||
// ..Default::default()
|
||||
// },
|
||||
// ..Default::default()
|
||||
// },
|
||||
// DocumentNodeMetadata {
|
||||
// persistent_metadata: DocumentNodePersistentMetadata {
|
||||
// display_name: "Imaginate".to_string(),
|
||||
// ..Default::default()
|
||||
// },
|
||||
// ..Default::default()
|
||||
// },
|
||||
// ]
|
||||
// .into_iter()
|
||||
// .enumerate()
|
||||
// .map(|(id, node)| (NodeId(id as u64), node))
|
||||
// .collect(),
|
||||
// ..Default::default()
|
||||
// },
|
||||
// ..Default::default()
|
||||
// }),
|
||||
// input_properties: vec![
|
||||
// "Input Image".into(),
|
||||
// "Editor Api".into(),
|
||||
// "Controller".into(),
|
||||
// "Seed".into(),
|
||||
// "Resolution".into(),
|
||||
// "Samples".into(),
|
||||
// "Sampling Method".into(),
|
||||
// "Prompt Guidance".into(),
|
||||
// "Prompt".into(),
|
||||
// "Negative Prompt".into(),
|
||||
// "Adapt Input Image".into(),
|
||||
// "Image Creativity".into(),
|
||||
// "Inpaint".into(),
|
||||
// "Mask Blur".into(),
|
||||
// "Mask Starting Fill".into(),
|
||||
// "Improve Faces".into(),
|
||||
// "Tiling".into(),
|
||||
// ],
|
||||
// output_names: vec!["Image".to_string()],
|
||||
// ..Default::default()
|
||||
// },
|
||||
// },
|
||||
// description: Cow::Borrowed("TODO"),
|
||||
// properties: None, // Some(&node_properties::imaginate_properties),
|
||||
// });
|
||||
|
||||
type NodeProperties = HashMap<String, Box<dyn Fn(NodeId, &mut NodePropertiesContext) -> Vec<LayoutGroup> + Send + Sync>>;
|
||||
|
||||
pub static NODE_OVERRIDES: once_cell::sync::Lazy<NodeProperties> = once_cell::sync::Lazy::new(static_node_properties);
|
||||
@@ -2975,19 +2852,3 @@ impl DocumentNodeDefinition {
|
||||
self.node_template_input_override(self.node_template.document_node.inputs.clone().into_iter().map(Some))
|
||||
}
|
||||
}
|
||||
|
||||
// Previously used by the Imaginate node, but usage was commented out since it did nothing.
|
||||
// pub fn new_image_network(output_offset: i32, output_node_id: NodeId) -> NodeNetwork {
|
||||
// let mut network = NodeNetwork { ..Default::default() };
|
||||
// network.push_node_to_document_network(
|
||||
// resolve_document_node_type("Input Frame")
|
||||
// .expect("Input Frame node does not exist")
|
||||
// .to_document_node_default_inputs([], DocumentNodeMetadata::position((8, 4))),
|
||||
// );
|
||||
// network.push_node_to_document_network(
|
||||
// resolve_document_node_type("Output")
|
||||
// .expect("Output node does not exist")
|
||||
// .to_document_node([NodeInput::node(output_node_id, 0)], DocumentNodeMetadata::position((output_offset + 8, 4))),
|
||||
// );
|
||||
// network
|
||||
// }
|
||||
|
||||
@@ -1396,12 +1396,7 @@ impl<'a> MessageHandler<NodeGraphMessage, NodeGraphHandlerData<'a>> for NodeGrap
|
||||
input,
|
||||
});
|
||||
responses.add(PropertiesPanelMessage::Refresh);
|
||||
if (network_interface
|
||||
.reference(&node_id, selection_network_path)
|
||||
.is_none_or(|reference| *reference != Some("Imaginate".to_string())) // TODO: Potentially remove the reference to Imaginate
|
||||
|| input_index == 0)
|
||||
&& network_interface.connected_to_output(&node_id, selection_network_path)
|
||||
{
|
||||
if (network_interface.reference(&node_id, selection_network_path).is_none() || input_index == 0) && network_interface.connected_to_output(&node_id, selection_network_path) {
|
||||
responses.add(NodeGraphMessage::RunDocumentGraph);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,547 +0,0 @@
|
||||
//! This has all been copied out of node_properties.rs to avoid leaving hundreds of lines of commented out code in that file. It's left here instead for future reference.
|
||||
|
||||
// pub fn imaginate_sampling_method(parameter_widgets_info: ParameterWidgetsInfo) -> LayoutGroup {
|
||||
// let ParameterWidgetsInfo { node_id, index, .. } = parameter_widgets_info;
|
||||
|
||||
// vec![
|
||||
// DropdownInput::new(
|
||||
// ImaginateSamplingMethod::list()
|
||||
// .into_iter()
|
||||
// .map(|method| {
|
||||
// vec![
|
||||
// MenuListEntry::new(format!("{:?}", method))
|
||||
// .label(method.to_string())
|
||||
// .on_update(update_value(move |_| TaggedValue::ImaginateSamplingMethod(method), node_id, index)),
|
||||
// ]
|
||||
// })
|
||||
// .collect(),
|
||||
// )
|
||||
// .widget_holder(),
|
||||
// ]
|
||||
// .into()
|
||||
// }
|
||||
|
||||
// pub fn imaginate_mask_starting_fill(parameter_widgets_info: ParameterWidgetsInfo) -> LayoutGroup {
|
||||
// let ParameterWidgetsInfo { node_id, index, .. } = parameter_widgets_info;
|
||||
|
||||
// vec![
|
||||
// DropdownInput::new(
|
||||
// ImaginateMaskStartingFill::list()
|
||||
// .into_iter()
|
||||
// .map(|fill| {
|
||||
// vec![
|
||||
// MenuListEntry::new(format!("{:?}", fill))
|
||||
// .label(fill.to_string())
|
||||
// .on_update(update_value(move |_| TaggedValue::ImaginateMaskStartingFill(fill), node_id, index)),
|
||||
// ]
|
||||
// })
|
||||
// .collect(),
|
||||
// )
|
||||
// .widget_holder(),
|
||||
// ]
|
||||
// .into()
|
||||
// }
|
||||
|
||||
// pub(crate) fn imaginate_properties(node_id: NodeId, context: &mut NodePropertiesContext) -> Vec<LayoutGroup> {
|
||||
// let imaginate_node = [context.selection_network_path, &[node_id]].concat();
|
||||
|
||||
// let resolve_input = |name: &str| {
|
||||
// IMAGINATE_NODE
|
||||
// .default_node_template()
|
||||
// .persistent_node_metadata
|
||||
// .input_properties
|
||||
// .iter()
|
||||
// .position(|row| row.input_name.as_str() == name)
|
||||
// .unwrap_or_else(|| panic!("Input {name} not found"))
|
||||
// };
|
||||
// let seed_index = resolve_input("Seed");
|
||||
// let resolution_index = resolve_input("Resolution");
|
||||
// let samples_index = resolve_input("Samples");
|
||||
// let sampling_method_index = resolve_input("Sampling Method");
|
||||
// let text_guidance_index = resolve_input("Prompt Guidance");
|
||||
// let text_index = resolve_input("Prompt");
|
||||
// let neg_index = resolve_input("Negative Prompt");
|
||||
// let base_img_index = resolve_input("Adapt Input Image");
|
||||
// let img_creativity_index = resolve_input("Image Creativity");
|
||||
// // let mask_index = resolve_input("Masking Layer");
|
||||
// // let inpaint_index = resolve_input("Inpaint");
|
||||
// // let mask_blur_index = resolve_input("Mask Blur");
|
||||
// // let mask_fill_index = resolve_input("Mask Starting Fill");
|
||||
// let faces_index = resolve_input("Improve Faces");
|
||||
// let tiling_index = resolve_input("Tiling");
|
||||
|
||||
// let document_node = match get_document_node(node_id, context) {
|
||||
// Ok(document_node) => document_node,
|
||||
// Err(err) => {
|
||||
// log::error!("Could not get document node in imaginate_properties: {err}");
|
||||
// return Vec::new();
|
||||
// }
|
||||
// };
|
||||
// let controller = &document_node.inputs[resolve_input("Controller")];
|
||||
|
||||
// let server_status = {
|
||||
// let server_status = context.persistent_data.imaginate.server_status();
|
||||
// let status_text = server_status.to_text();
|
||||
// let mut widgets = vec![
|
||||
// TextLabel::new("Server").widget_holder(),
|
||||
// Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
// IconButton::new("Settings", 24)
|
||||
// .tooltip("Preferences: Imaginate")
|
||||
// .on_update(|_| DialogMessage::RequestPreferencesDialog.into())
|
||||
// .widget_holder(),
|
||||
// Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
// TextLabel::new(status_text).bold(true).widget_holder(),
|
||||
// Separator::new(SeparatorType::Related).widget_holder(),
|
||||
// IconButton::new("Reload", 24)
|
||||
// .tooltip("Refresh connection status")
|
||||
// .on_update(|_| PortfolioMessage::ImaginateCheckServerStatus.into())
|
||||
// .widget_holder(),
|
||||
// ];
|
||||
// if let ImaginateServerStatus::Unavailable | ImaginateServerStatus::Failed(_) = server_status {
|
||||
// widgets.extend([
|
||||
// Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
// TextButton::new("Server Help")
|
||||
// .tooltip("Learn how to connect Imaginate to an image generation server")
|
||||
// .on_update(|_| {
|
||||
// FrontendMessage::TriggerVisitLink {
|
||||
// url: "https://github.com/GraphiteEditor/Graphite/discussions/1089".to_string(),
|
||||
// }
|
||||
// .into()
|
||||
// })
|
||||
// .widget_holder(),
|
||||
// ]);
|
||||
// }
|
||||
// LayoutGroup::Row { widgets }.with_tooltip("Connection status to the server that computes generated images")
|
||||
// };
|
||||
|
||||
// let Some(TaggedValue::ImaginateController(controller)) = controller.as_value() else {
|
||||
// panic!("Invalid output status input")
|
||||
// };
|
||||
// let imaginate_status = controller.get_status();
|
||||
|
||||
// let use_base_image = if let Some(&TaggedValue::Bool(use_base_image)) = &document_node.inputs[base_img_index].as_value() {
|
||||
// use_base_image
|
||||
// } else {
|
||||
// true
|
||||
// };
|
||||
|
||||
// let transform_not_connected = false;
|
||||
|
||||
// let progress = {
|
||||
// let mut widgets = vec![TextLabel::new("Progress").widget_holder(), Separator::new(SeparatorType::Unrelated).widget_holder()];
|
||||
// add_blank_assist(&mut widgets);
|
||||
// let status = imaginate_status.to_text();
|
||||
// widgets.push(TextLabel::new(status.as_ref()).bold(true).widget_holder());
|
||||
// LayoutGroup::Row { widgets }.with_tooltip(match imaginate_status {
|
||||
// ImaginateStatus::Failed(_) => status.as_ref(),
|
||||
// _ => "When generating, the percentage represents how many sampling steps have so far been processed out of the target number",
|
||||
// })
|
||||
// };
|
||||
|
||||
// let image_controls = {
|
||||
// let mut widgets = vec![TextLabel::new("Image").widget_holder(), Separator::new(SeparatorType::Unrelated).widget_holder()];
|
||||
|
||||
// match &imaginate_status {
|
||||
// ImaginateStatus::Beginning | ImaginateStatus::Uploading => {
|
||||
// add_blank_assist(&mut widgets);
|
||||
// widgets.push(TextButton::new("Beginning...").tooltip("Sending image generation request to the server").disabled(true).widget_holder());
|
||||
// }
|
||||
// ImaginateStatus::Generating(_) => {
|
||||
// add_blank_assist(&mut widgets);
|
||||
// widgets.push(
|
||||
// TextButton::new("Terminate")
|
||||
// .tooltip("Cancel the in-progress image generation and keep the latest progress")
|
||||
// .on_update({
|
||||
// let controller = controller.clone();
|
||||
// move |_| {
|
||||
// controller.request_termination();
|
||||
// Message::NoOp
|
||||
// }
|
||||
// })
|
||||
// .widget_holder(),
|
||||
// );
|
||||
// }
|
||||
// ImaginateStatus::Terminating => {
|
||||
// add_blank_assist(&mut widgets);
|
||||
// widgets.push(
|
||||
// TextButton::new("Terminating...")
|
||||
// .tooltip("Waiting on the final image generated after termination")
|
||||
// .disabled(true)
|
||||
// .widget_holder(),
|
||||
// );
|
||||
// }
|
||||
// ImaginateStatus::Ready | ImaginateStatus::ReadyDone | ImaginateStatus::Terminated | ImaginateStatus::Failed(_) => widgets.extend_from_slice(&[
|
||||
// IconButton::new("Random", 24)
|
||||
// .tooltip("Generate with a new random seed")
|
||||
// .on_update({
|
||||
// let imaginate_node = imaginate_node.clone();
|
||||
// let controller = controller.clone();
|
||||
// move |_| {
|
||||
// controller.trigger_regenerate();
|
||||
// DocumentMessage::ImaginateRandom {
|
||||
// imaginate_node: imaginate_node.clone(),
|
||||
// then_generate: true,
|
||||
// }
|
||||
// .into()
|
||||
// }
|
||||
// })
|
||||
// .widget_holder(),
|
||||
// Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
// TextButton::new("Generate")
|
||||
// .tooltip("Fill layer frame by generating a new image")
|
||||
// .on_update({
|
||||
// let controller = controller.clone();
|
||||
// let imaginate_node = imaginate_node.clone();
|
||||
// move |_| {
|
||||
// controller.trigger_regenerate();
|
||||
// DocumentMessage::ImaginateGenerate {
|
||||
// imaginate_node: imaginate_node.clone(),
|
||||
// }
|
||||
// .into()
|
||||
// }
|
||||
// })
|
||||
// .widget_holder(),
|
||||
// Separator::new(SeparatorType::Related).widget_holder(),
|
||||
// TextButton::new("Clear")
|
||||
// .tooltip("Remove generated image from the layer frame")
|
||||
// .disabled(!matches!(imaginate_status, ImaginateStatus::ReadyDone))
|
||||
// .on_update({
|
||||
// let controller = controller.clone();
|
||||
// let imaginate_node = imaginate_node.clone();
|
||||
// move |_| {
|
||||
// controller.set_status(ImaginateStatus::Ready);
|
||||
// DocumentMessage::ImaginateGenerate {
|
||||
// imaginate_node: imaginate_node.clone(),
|
||||
// }
|
||||
// .into()
|
||||
// }
|
||||
// })
|
||||
// .widget_holder(),
|
||||
// ]),
|
||||
// }
|
||||
// LayoutGroup::Row { widgets }.with_tooltip("Buttons that control the image generation process")
|
||||
// };
|
||||
|
||||
// // Requires custom layout for the regenerate button
|
||||
// let seed = {
|
||||
// let mut widgets = start_widgets(document_node, node_id, seed_index, "Seed", FrontendGraphDataType::Number, false);
|
||||
|
||||
// let Some(input) = document_node.inputs.get(seed_index) else {
|
||||
// log::warn!("A widget failed to be built because its node's input index is invalid.");
|
||||
// return vec![];
|
||||
// };
|
||||
// if let Some(&TaggedValue::F64(seed)) = &input.as_non_exposed_value() {
|
||||
// widgets.extend_from_slice(&[
|
||||
// Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
// IconButton::new("Resync", 24)
|
||||
// .tooltip("Set a new random seed")
|
||||
// .on_update({
|
||||
// let imaginate_node = imaginate_node.clone();
|
||||
// move |_| {
|
||||
// DocumentMessage::ImaginateRandom {
|
||||
// imaginate_node: imaginate_node.clone(),
|
||||
// then_generate: false,
|
||||
// }
|
||||
// .into()
|
||||
// }
|
||||
// })
|
||||
// .widget_holder(),
|
||||
// Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
// NumberInput::new(Some(seed))
|
||||
// .int()
|
||||
// .min(-((1_u64 << f64::MANTISSA_DIGITS) as f64))
|
||||
// .max((1_u64 << f64::MANTISSA_DIGITS) as f64)
|
||||
// .on_update(update_value(move |input: &NumberInput| TaggedValue::F64(input.value.unwrap()), node_id, seed_index))
|
||||
// .on_commit(commit_value)
|
||||
// .mode(NumberInputMode::Increment)
|
||||
// .widget_holder(),
|
||||
// ])
|
||||
// }
|
||||
// // Note: Limited by f64. You cannot even have all the possible u64 values :)
|
||||
// LayoutGroup::Row { widgets }.with_tooltip("Seed determines the random outcome, enabling limitless unique variations")
|
||||
// };
|
||||
|
||||
// // let transform = context
|
||||
// // .executor
|
||||
// // .introspect_node_in_network(context.network, &imaginate_node, |network| network.inputs.first().copied(), |frame: &RasterData<Color>| frame.transform)
|
||||
// // .unwrap_or_default();
|
||||
// let image_size = context
|
||||
// .executor
|
||||
// .introspect_node_in_network(
|
||||
// context.network_interface.document_network().unwrap(),
|
||||
// &imaginate_node,
|
||||
// |network| {
|
||||
// network
|
||||
// .nodes
|
||||
// .iter()
|
||||
// .find(|node| {
|
||||
// node.1
|
||||
// .inputs
|
||||
// .iter()
|
||||
// .any(|node_input| if let NodeInput::Network { import_index, .. } = node_input { *import_index == 0 } else { false })
|
||||
// })
|
||||
// .map(|(node_id, _)| node_id)
|
||||
// .copied()
|
||||
// },
|
||||
// |frame: &IORecord<(), RasterData<Color>>| (frame.output.image.width, frame.output.image.height),
|
||||
// )
|
||||
// .unwrap_or_default();
|
||||
|
||||
// let document_node = match get_document_node(node_id, context) {
|
||||
// Ok(document_node) => document_node,
|
||||
// Err(err) => {
|
||||
// log::error!("Could not get document node in imaginate_properties: {err}");
|
||||
// return Vec::new();
|
||||
// }
|
||||
// };
|
||||
|
||||
// let resolution = {
|
||||
// let mut widgets = start_widgets(document_node, node_id, resolution_index, "Resolution", FrontendGraphDataType::Number, false);
|
||||
|
||||
// let round = |size: DVec2| {
|
||||
// let (x, y) = graphene_std::imaginate::pick_safe_imaginate_resolution(size.into());
|
||||
// DVec2::new(x as f64, y as f64)
|
||||
// };
|
||||
|
||||
// let Some(input) = document_node.inputs.get(resolution_index) else {
|
||||
// log::warn!("A widget failed to be built because its node's input index is invalid.");
|
||||
// return vec![];
|
||||
// };
|
||||
// if let Some(&TaggedValue::OptionalDVec2(vec2)) = &input.as_non_exposed_value() {
|
||||
// let dimensions_is_auto = vec2.is_none();
|
||||
// let vec2 = vec2.unwrap_or_else(|| round((image_size.0 as f64, image_size.1 as f64).into()));
|
||||
|
||||
// widgets.extend_from_slice(&[
|
||||
// Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
// IconButton::new("FrameAll", 24)
|
||||
// .tooltip("Set the layer dimensions to this resolution")
|
||||
// .on_update(move |_| DialogMessage::RequestComingSoonDialog { issue: None }.into())
|
||||
// .widget_holder(),
|
||||
// Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
// CheckboxInput::new(!dimensions_is_auto || transform_not_connected)
|
||||
// .icon("Edit12px")
|
||||
// .tooltip({
|
||||
// let message = "Set a custom resolution instead of using the input's dimensions (rounded to the nearest 64)";
|
||||
// let manual_message = "Set a custom resolution instead of using the input's dimensions (rounded to the nearest 64).\n\
|
||||
// \n\
|
||||
// (Resolution must be set manually while the 'Transform' input is disconnected.)";
|
||||
|
||||
// if transform_not_connected {
|
||||
// manual_message
|
||||
// } else {
|
||||
// message
|
||||
// }
|
||||
// })
|
||||
// .disabled(transform_not_connected)
|
||||
// .on_update(update_value(
|
||||
// move |checkbox_input: &CheckboxInput| TaggedValue::OptionalDVec2(if checkbox_input.checked { Some(vec2) } else { None }),
|
||||
// node_id,
|
||||
// resolution_index,
|
||||
// ))
|
||||
// .on_commit(commit_value)
|
||||
// .for_label(checkbox_id.clone())
|
||||
// .widget_holder(),
|
||||
// Separator::new(SeparatorType::Related).widget_holder(),
|
||||
// NumberInput::new(Some(vec2.x))
|
||||
// .label("W")
|
||||
// .min(64.)
|
||||
// .step(64.)
|
||||
// .unit(" px")
|
||||
// .disabled(dimensions_is_auto && !transform_not_connected)
|
||||
// .on_update(update_value(
|
||||
// move |number_input: &NumberInput| TaggedValue::OptionalDVec2(Some(round(DVec2::new(number_input.value.unwrap(), vec2.y)))),
|
||||
// node_id,
|
||||
// resolution_index,
|
||||
// ))
|
||||
// .on_commit(commit_value)
|
||||
// .widget_holder(),
|
||||
// Separator::new(SeparatorType::Related).widget_holder(),
|
||||
// NumberInput::new(Some(vec2.y))
|
||||
// .label("H")
|
||||
// .min(64.)
|
||||
// .step(64.)
|
||||
// .unit(" px")
|
||||
// .disabled(dimensions_is_auto && !transform_not_connected)
|
||||
// .on_update(update_value(
|
||||
// move |number_input: &NumberInput| TaggedValue::OptionalDVec2(Some(round(DVec2::new(vec2.x, number_input.value.unwrap())))),
|
||||
// node_id,
|
||||
// resolution_index,
|
||||
// ))
|
||||
// .on_commit(commit_value)
|
||||
// .widget_holder(),
|
||||
// ])
|
||||
// }
|
||||
// LayoutGroup::Row { widgets }.with_tooltip(
|
||||
// "Width and height of the image that will be generated. Larger resolutions take longer to compute.\n\
|
||||
// \n\
|
||||
// 512x512 yields optimal results because the AI is trained to understand that scale best. Larger sizes may tend to integrate the prompt's subject more than once. Small sizes are often incoherent.\n\
|
||||
// \n\
|
||||
// Dimensions must be a multiple of 64, so these are set by rounding the layer dimensions. A resolution exceeding 1 megapixel is reduced below that limit because larger sizes may exceed available GPU memory on the server.")
|
||||
// };
|
||||
|
||||
// let sampling_steps = {
|
||||
// let widgets = number_widget(document_node, node_id, samples_index, "Sampling Steps", NumberInput::default().min(0.).max(150.).int(), true);
|
||||
// LayoutGroup::Row { widgets }.with_tooltip("Number of iterations to improve the image generation quality, with diminishing returns around 40 when using the Euler A sampling method")
|
||||
// };
|
||||
|
||||
// let sampling_method = {
|
||||
// let mut widgets = start_widgets(document_node, node_id, sampling_method_index, "Sampling Method", FrontendGraphDataType::General, true);
|
||||
|
||||
// let Some(input) = document_node.inputs.get(sampling_method_index) else {
|
||||
// log::warn!("A widget failed to be built because its node's input index is invalid.");
|
||||
// return vec![];
|
||||
// };
|
||||
// if let Some(&TaggedValue::ImaginateSamplingMethod(sampling_method)) = &input.as_non_exposed_value() {
|
||||
// let sampling_methods = ImaginateSamplingMethod::list();
|
||||
// let mut entries = Vec::with_capacity(sampling_methods.len());
|
||||
// for method in sampling_methods {
|
||||
// entries.push(
|
||||
// MenuListEntry::new(format!("{method:?}"))
|
||||
// .label(method.to_string())
|
||||
// .on_update(update_value(move |_| TaggedValue::ImaginateSamplingMethod(method), node_id, sampling_method_index))
|
||||
// .on_commit(commit_value),
|
||||
// );
|
||||
// }
|
||||
// let entries = vec![entries];
|
||||
|
||||
// widgets.extend_from_slice(&[
|
||||
// Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
// DropdownInput::new(entries).selected_index(Some(sampling_method as u32)).widget_holder(),
|
||||
// ]);
|
||||
// }
|
||||
// LayoutGroup::Row { widgets }.with_tooltip("Algorithm used to generate the image during each sampling step")
|
||||
// };
|
||||
|
||||
// let text_guidance = {
|
||||
// let widgets = number_widget(document_node, node_id, text_guidance_index, "Prompt Guidance", NumberInput::default().min(0.).max(30.), true);
|
||||
// LayoutGroup::Row { widgets }.with_tooltip(
|
||||
// "Amplification of the text prompt's influence over the outcome. At 0, the prompt is entirely ignored.\n\
|
||||
// \n\
|
||||
// Lower values are more creative and exploratory. Higher values are more literal and uninspired.\n\
|
||||
// \n\
|
||||
// This parameter is otherwise known as CFG (classifier-free guidance).",
|
||||
// )
|
||||
// };
|
||||
|
||||
// let text_prompt = {
|
||||
// let widgets = text_area_widget(document_node, node_id, text_index, "Prompt", true);
|
||||
// LayoutGroup::Row { widgets }.with_tooltip(
|
||||
// "Description of the desired image subject and style.\n\
|
||||
// \n\
|
||||
// Include an artist name like \"Rembrandt\" or art medium like \"watercolor\" or \"photography\" to influence the look. List multiple to meld styles.\n\
|
||||
// \n\
|
||||
// To boost (or lessen) the importance of a word or phrase, wrap it in parentheses ending with a colon and a multiplier, for example:\n\
|
||||
// \"Colorless green ideas (sleep:1.3) furiously\"",
|
||||
// )
|
||||
// };
|
||||
// let negative_prompt = {
|
||||
// let widgets = text_area_widget(document_node, node_id, neg_index, "Negative Prompt", true);
|
||||
// LayoutGroup::Row { widgets }.with_tooltip("A negative text prompt can be used to list things like objects or colors to avoid")
|
||||
// };
|
||||
// let base_image = {
|
||||
// let widgets = bool_widget(document_node, node_id, base_img_index, "Adapt Input Image", CheckboxInput::default().for_label(checkbox_id.clone()), true);
|
||||
// LayoutGroup::Row { widgets }.with_tooltip("Generate an image based upon the bitmap data plugged into this node")
|
||||
// };
|
||||
// let image_creativity = {
|
||||
// let props = NumberInput::default().percentage().disabled(!use_base_image);
|
||||
// let widgets = number_widget(document_node, node_id, img_creativity_index, "Image Creativity", props, true);
|
||||
// LayoutGroup::Row { widgets }.with_tooltip(
|
||||
// "Strength of the artistic liberties allowing changes from the input image. The image is unchanged at 0% and completely different at 100%.\n\
|
||||
// \n\
|
||||
// This parameter is otherwise known as denoising strength.",
|
||||
// )
|
||||
// };
|
||||
|
||||
// let mut layout = vec![
|
||||
// server_status,
|
||||
// progress,
|
||||
// image_controls,
|
||||
// seed,
|
||||
// resolution,
|
||||
// sampling_steps,
|
||||
// sampling_method,
|
||||
// text_guidance,
|
||||
// text_prompt,
|
||||
// negative_prompt,
|
||||
// base_image,
|
||||
// image_creativity,
|
||||
// // layer_mask,
|
||||
// ];
|
||||
|
||||
// // if use_base_image && layer_reference_input_layer_is_some {
|
||||
// // let in_paint = {
|
||||
// // let mut widgets = start_widgets(document_node, node_id, inpaint_index, "Inpaint", FrontendGraphDataType::Boolean, true);
|
||||
|
||||
// // if let Some(& TaggedValue::Bool(in_paint)
|
||||
// //)/ } = &document_node.inputs[inpaint_index].as_non_exposed_value()
|
||||
// // {
|
||||
// // widgets.extend_from_slice(&[
|
||||
// // Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
// // RadioInput::new(
|
||||
// // [(true, "Inpaint"), (false, "Outpaint")]
|
||||
// // .into_iter()
|
||||
// // .map(|(paint, name)| RadioEntryData::new(name).label(name).on_update(update_value(move |_| TaggedValue::Bool(paint), node_id, inpaint_index)))
|
||||
// // .collect(),
|
||||
// // )
|
||||
// // .selected_index(Some(1 - in_paint as u32))
|
||||
// // .widget_holder(),
|
||||
// // ]);
|
||||
// // }
|
||||
// // LayoutGroup::Row { widgets }.with_tooltip(
|
||||
// // "Constrain image generation to the interior (inpaint) or exterior (outpaint) of the mask, while referencing the other unchanged parts as context imagery.\n\
|
||||
// // \n\
|
||||
// // An unwanted part of an image can be replaced by drawing around it with a black shape and inpainting with that mask layer.\n\
|
||||
// // \n\
|
||||
// // An image can be uncropped by resizing the Imaginate layer to the target bounds and outpainting with a black rectangle mask matching the original image bounds.",
|
||||
// // )
|
||||
// // };
|
||||
|
||||
// // let blur_radius = {
|
||||
// // let number_props = NumberInput::default().unit(" px").min(0.).max(25.).int();
|
||||
// // let widgets = number_widget(document_node, node_id, mask_blur_index, "Mask Blur", number_props, true);
|
||||
// // LayoutGroup::Row { widgets }.with_tooltip("Blur radius for the mask. Useful for softening sharp edges to blend the masked area with the rest of the image.")
|
||||
// // };
|
||||
|
||||
// // let mask_starting_fill = {
|
||||
// // let mut widgets = start_widgets(document_node, node_id, mask_fill_index, "Mask Starting Fill", FrontendGraphDataType::General, true);
|
||||
|
||||
// // if let Some(& TaggedValue::ImaginateMaskStartingFill(starting_fill)
|
||||
// //)/ } = &document_node.inputs[mask_fill_index].as_non_exposed_value()
|
||||
// // {
|
||||
// // let mask_fill_content_modes = ImaginateMaskStartingFill::list();
|
||||
// // let mut entries = Vec::with_capacity(mask_fill_content_modes.len());
|
||||
// // for mode in mask_fill_content_modes {
|
||||
// // entries.push(MenuListEntry::new(format!("{mode:?}")).label(mode.to_string()).on_update(update_value(move |_| TaggedValue::ImaginateMaskStartingFill(mode), node_id, mask_fill_index)));
|
||||
// // }
|
||||
// // let entries = vec![entries];
|
||||
|
||||
// // widgets.extend_from_slice(&[
|
||||
// // Separator::new(SeparatorType::Unrelated).widget_holder(),
|
||||
// // DropdownInput::new(entries).selected_index(Some(starting_fill as u32)).widget_holder(),
|
||||
// // ]);
|
||||
// // }
|
||||
// // LayoutGroup::Row { widgets }.with_tooltip(
|
||||
// // "Begin in/outpainting the masked areas using this fill content as the starting input image.\n\
|
||||
// // \n\
|
||||
// // Each option can be visualized by generating with 'Sampling Steps' set to 0.",
|
||||
// // )
|
||||
// // };
|
||||
// // layout.extend_from_slice(&[in_paint, blur_radius, mask_starting_fill]);
|
||||
// // }
|
||||
|
||||
// let improve_faces = {
|
||||
// let widgets = bool_widget(document_node, node_id, faces_index, "Improve Faces", CheckboxInput::default().for_label(checkbox_id.clone()), true);
|
||||
// LayoutGroup::Row { widgets }.with_tooltip(
|
||||
// "Postprocess human (or human-like) faces to look subtly less distorted.\n\
|
||||
// \n\
|
||||
// This filter can be used on its own by enabling 'Adapt Input Image' and setting 'Sampling Steps' to 0.",
|
||||
// )
|
||||
// };
|
||||
// let tiling = {
|
||||
// let widgets = bool_widget(document_node, node_id, tiling_index, "Tiling", CheckboxInput::default().for_label(checkbox_id.clone()), true);
|
||||
// LayoutGroup::Row { widgets }.with_tooltip("Generate the image so its edges loop seamlessly to make repeatable patterns or textures")
|
||||
// };
|
||||
// layout.extend_from_slice(&[improve_faces, tiling]);
|
||||
|
||||
// layout
|
||||
// }
|
||||
@@ -54,9 +54,6 @@ pub enum PortfolioMessage {
|
||||
preview_url: String,
|
||||
data: Vec<u8>,
|
||||
},
|
||||
// ImaginateCheckServerStatus,
|
||||
// ImaginatePollServerStatus,
|
||||
// ImaginateServerHostname,
|
||||
Import,
|
||||
LoadDocumentResources {
|
||||
document_id: DocumentId,
|
||||
|
||||
@@ -328,35 +328,7 @@ impl MessageHandler<PortfolioMessage, PortfolioMessageData<'_>> for PortfolioMes
|
||||
responses.add(NodeGraphMessage::RunDocumentGraph);
|
||||
}
|
||||
}
|
||||
// PortfolioMessage::ImaginateCheckServerStatus => {
|
||||
// let server_status = self.persistent_data.imaginate.server_status().clone();
|
||||
// self.persistent_data.imaginate.poll_server_check();
|
||||
// #[cfg(target_arch = "wasm32")]
|
||||
// if let Some(fut) = self.persistent_data.imaginate.initiate_server_check() {
|
||||
// wasm_bindgen_futures::spawn_local(async move {
|
||||
// let () = fut.await;
|
||||
// use wasm_bindgen::prelude::*;
|
||||
|
||||
// #[wasm_bindgen(module = "/../frontend/src/editor.ts")]
|
||||
// extern "C" {
|
||||
// #[wasm_bindgen(js_name = injectImaginatePollServerStatus)]
|
||||
// fn inject();
|
||||
// }
|
||||
// inject();
|
||||
// })
|
||||
// }
|
||||
// if &server_status != self.persistent_data.imaginate.server_status() {
|
||||
// responses.add(PropertiesPanelMessage::Refresh);
|
||||
// }
|
||||
// }
|
||||
// PortfolioMessage::ImaginatePollServerStatus => {
|
||||
// self.persistent_data.imaginate.poll_server_check();
|
||||
// responses.add(PropertiesPanelMessage::Refresh);
|
||||
// }
|
||||
PortfolioMessage::EditorPreferences => self.executor.update_editor_preferences(preferences.editor_preferences()),
|
||||
// PortfolioMessage::ImaginateServerHostname => {
|
||||
// self.persistent_data.imaginate.set_host_name(&preferences.imaginate_server_hostname);
|
||||
// }
|
||||
PortfolioMessage::Import => {
|
||||
// This portfolio message wraps the frontend message so it can be listed as an action, which isn't possible for frontend messages
|
||||
responses.add(FrontendMessage::TriggerImport);
|
||||
|
||||
@@ -4,7 +4,6 @@ use graphene_std::text::FontCache;
|
||||
pub struct PersistentData {
|
||||
pub font_cache: FontCache,
|
||||
pub use_vello: bool,
|
||||
// pub imaginate: ImaginatePersistentData,
|
||||
}
|
||||
|
||||
#[derive(PartialEq, Eq, Clone, Copy, Default, Debug, serde::Serialize, serde::Deserialize)]
|
||||
|
||||
@@ -16,6 +16,4 @@ pub enum PreferencesMessage {
|
||||
ModifyLayout { zoom_with_scroll: bool },
|
||||
GraphWireStyle { style: GraphWireStyle },
|
||||
ViewportZoomWheelRate { rate: f64 },
|
||||
// ImaginateRefreshFrequency { seconds: f64 },
|
||||
// ImaginateServerHostname { hostname: String },
|
||||
}
|
||||
|
||||
@@ -7,8 +7,6 @@ use graph_craft::wasm_application_io::EditorPreferences;
|
||||
|
||||
#[derive(Debug, PartialEq, Clone, serde::Serialize, serde::Deserialize, specta::Type)]
|
||||
pub struct PreferencesMessageHandler {
|
||||
// pub imaginate_server_hostname: String,
|
||||
// pub imaginate_refresh_frequency: f64,
|
||||
pub selection_mode: SelectionMode,
|
||||
pub zoom_with_scroll: bool,
|
||||
pub use_vello: bool,
|
||||
@@ -24,7 +22,6 @@ impl PreferencesMessageHandler {
|
||||
|
||||
pub fn editor_preferences(&self) -> EditorPreferences {
|
||||
EditorPreferences {
|
||||
// imaginate_hostname: self.imaginate_server_hostname.clone(),
|
||||
use_vello: self.use_vello && self.supports_wgpu(),
|
||||
}
|
||||
}
|
||||
@@ -37,8 +34,6 @@ impl PreferencesMessageHandler {
|
||||
impl Default for PreferencesMessageHandler {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
// imaginate_server_hostname: EditorPreferences::default().imaginate_hostname,
|
||||
// imaginate_refresh_frequency: 1.,
|
||||
selection_mode: SelectionMode::Touched,
|
||||
zoom_with_scroll: matches!(MappingVariant::default(), MappingVariant::ZoomWithScroll),
|
||||
use_vello: EditorPreferences::default().use_vello,
|
||||
@@ -57,10 +52,6 @@ impl MessageHandler<PreferencesMessage, ()> for PreferencesMessageHandler {
|
||||
if let Ok(deserialized_preferences) = serde_json::from_str::<PreferencesMessageHandler>(&preferences) {
|
||||
*self = deserialized_preferences;
|
||||
|
||||
// TODO: Reenable when Imaginate is restored
|
||||
// responses.add(PortfolioMessage::ImaginateServerHostname);
|
||||
// responses.add(PortfolioMessage::ImaginateCheckServerStatus);
|
||||
|
||||
responses.add(PortfolioMessage::EditorPreferences);
|
||||
responses.add(PortfolioMessage::UpdateVelloPreference);
|
||||
responses.add(PreferencesMessage::ModifyLayout {
|
||||
@@ -101,27 +92,6 @@ impl MessageHandler<PreferencesMessage, ()> for PreferencesMessageHandler {
|
||||
self.viewport_zoom_wheel_rate = rate;
|
||||
}
|
||||
}
|
||||
// TODO: Reenable when Imaginate is restored (and move back up one line since the auto-formatter doesn't like it in that block)
|
||||
// PreferencesMessage::ImaginateRefreshFrequency { seconds } => {
|
||||
// self.imaginate_refresh_frequency = seconds;
|
||||
// responses.add(PortfolioMessage::ImaginateCheckServerStatus);
|
||||
// responses.add(PortfolioMessage::EditorPreferences);
|
||||
// }
|
||||
// PreferencesMessage::ImaginateServerHostname { hostname } => {
|
||||
// let initial = hostname.clone();
|
||||
// let has_protocol = hostname.starts_with("http://") || hostname.starts_with("https://");
|
||||
// let hostname = if has_protocol { hostname } else { "http://".to_string() + &hostname };
|
||||
// let hostname = if hostname.ends_with('/') { hostname } else { hostname + "/" };
|
||||
|
||||
// if hostname != initial {
|
||||
// refresh_dialog(responses);
|
||||
// }
|
||||
|
||||
// self.imaginate_server_hostname = hostname;
|
||||
// responses.add(PortfolioMessage::ImaginateServerHostname);
|
||||
// responses.add(PortfolioMessage::ImaginateCheckServerStatus);
|
||||
// responses.add(PortfolioMessage::EditorPreferences);
|
||||
//}
|
||||
|
||||
responses.add(FrontendMessage::TriggerSavePreferences { preferences: self.clone() });
|
||||
}
|
||||
|
||||
@@ -38,7 +38,6 @@ pub use crate::messages::tool::tool_messages::eyedropper_tool::{EyedropperToolMe
|
||||
pub use crate::messages::tool::tool_messages::fill_tool::{FillToolMessage, FillToolMessageDiscriminant};
|
||||
pub use crate::messages::tool::tool_messages::freehand_tool::{FreehandToolMessage, FreehandToolMessageDiscriminant};
|
||||
pub use crate::messages::tool::tool_messages::gradient_tool::{GradientToolMessage, GradientToolMessageDiscriminant};
|
||||
// pub use crate::messages::tool::tool_messages::imaginate_tool::{ImaginateToolMessage, ImaginateToolMessageDiscriminant};
|
||||
pub use crate::messages::tool::tool_messages::navigate_tool::{NavigateToolMessage, NavigateToolMessageDiscriminant};
|
||||
pub use crate::messages::tool::tool_messages::path_tool::{PathToolMessage, PathToolMessageDiscriminant};
|
||||
pub use crate::messages::tool::tool_messages::pen_tool::{PenToolMessage, PenToolMessageDiscriminant};
|
||||
|
||||
@@ -48,17 +48,17 @@ pub enum ToolMessage {
|
||||
// Relight(RelightToolMessage),
|
||||
// // #[child]
|
||||
// Detail(DetailToolMessage),
|
||||
// #[child]
|
||||
// Imaginate(ImaginateToolMessage),
|
||||
|
||||
// Messages
|
||||
|
||||
// General tools
|
||||
ActivateToolSelect,
|
||||
ActivateToolArtboard,
|
||||
ActivateToolNavigate,
|
||||
ActivateToolEyedropper,
|
||||
ActivateToolFill,
|
||||
ActivateToolGradient,
|
||||
|
||||
// Vector tools
|
||||
ActivateToolPath,
|
||||
ActivateToolPen,
|
||||
ActivateToolFreehand,
|
||||
@@ -68,10 +68,9 @@ pub enum ToolMessage {
|
||||
ActivateToolShapeEllipse,
|
||||
ActivateToolShape,
|
||||
ActivateToolText,
|
||||
|
||||
// Raster tools
|
||||
ActivateToolBrush,
|
||||
// ActivateToolImaginate,
|
||||
//
|
||||
|
||||
ActivateTool {
|
||||
tool_type: ToolType,
|
||||
},
|
||||
|
||||
@@ -82,7 +82,6 @@ impl MessageHandler<ToolMessage, ToolMessageData<'_>> for ToolMessageHandler {
|
||||
responses.add(ShapeToolMessage::HideShapeTypeWidget(true));
|
||||
responses.add(ShapeToolMessage::SetShape(shape));
|
||||
}
|
||||
// ToolMessage::ActivateToolImaginate => responses.add_front(ToolMessage::ActivateTool { tool_type: ToolType::Imaginate }),
|
||||
ToolMessage::ActivateTool { tool_type } => {
|
||||
let tool_data = &mut self.tool_state.tool_data;
|
||||
let old_tool = tool_data.active_tool_type.get_tool();
|
||||
@@ -340,7 +339,6 @@ impl MessageHandler<ToolMessage, ToolMessageData<'_>> for ToolMessageHandler {
|
||||
ActivateToolText,
|
||||
|
||||
ActivateToolBrush,
|
||||
// ActivateToolImaginate,
|
||||
|
||||
SelectRandomPrimaryColor,
|
||||
ResetColors,
|
||||
|
||||
@@ -1,184 +0,0 @@
|
||||
use super::tool_prelude::*;
|
||||
use crate::messages::tool::common_functionality::resize::Resize;
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct ImaginateTool {
|
||||
fsm_state: ImaginateToolFsmState,
|
||||
tool_data: ImaginateToolData,
|
||||
}
|
||||
|
||||
#[impl_message(Message, ToolMessage, Imaginate)]
|
||||
#[derive(PartialEq, Eq, Clone, Debug, Hash, serde::Serialize, serde::Deserialize, specta::Type)]
|
||||
pub enum ImaginateToolMessage {
|
||||
// Standard messages
|
||||
Abort,
|
||||
|
||||
// Tool-specific messages
|
||||
DragStart,
|
||||
DragStop,
|
||||
Resize { center: Key, lock_ratio: Key },
|
||||
}
|
||||
|
||||
impl LayoutHolder for ImaginateTool {
|
||||
fn layout(&self) -> Layout {
|
||||
Layout::WidgetLayout(WidgetLayout::default())
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> MessageHandler<ToolMessage, &mut ToolActionHandlerData<'a>> for ImaginateTool {
|
||||
fn process_message(&mut self, message: ToolMessage, responses: &mut VecDeque<Message>, tool_data: &mut ToolActionHandlerData<'a>) {
|
||||
self.fsm_state.process_event(message, &mut self.tool_data, tool_data, &(), responses, true);
|
||||
}
|
||||
|
||||
fn actions(&self) -> ActionList {
|
||||
match self.fsm_state {
|
||||
ImaginateToolFsmState::Ready => actions!(ImaginateToolMessageDiscriminant;
|
||||
DragStart,
|
||||
),
|
||||
ImaginateToolFsmState::Drawing => actions!(ImaginateToolMessageDiscriminant;
|
||||
DragStop,
|
||||
Abort,
|
||||
Resize,
|
||||
),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl ToolMetadata for ImaginateTool {
|
||||
fn icon_name(&self) -> String {
|
||||
"RasterImaginateTool".into()
|
||||
}
|
||||
fn tooltip(&self) -> String {
|
||||
"Imaginate Tool".into()
|
||||
}
|
||||
fn tool_type(&self) -> crate::messages::tool::utility_types::ToolType {
|
||||
ToolType::Imaginate
|
||||
}
|
||||
}
|
||||
|
||||
impl ToolTransition for ImaginateTool {
|
||||
fn event_to_message_map(&self) -> EventToMessageMap {
|
||||
EventToMessageMap {
|
||||
tool_abort: Some(ImaginateToolMessage::Abort.into()),
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
|
||||
enum ImaginateToolFsmState {
|
||||
#[default]
|
||||
Ready,
|
||||
Drawing,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default)]
|
||||
struct ImaginateToolData {
|
||||
data: Resize,
|
||||
}
|
||||
|
||||
impl Fsm for ImaginateToolFsmState {
|
||||
type ToolData = ImaginateToolData;
|
||||
type ToolOptions = ();
|
||||
|
||||
fn transition(
|
||||
self,
|
||||
event: ToolMessage,
|
||||
tool_data: &mut Self::ToolData,
|
||||
ToolActionHandlerData { document, input, .. }: &mut ToolActionHandlerData,
|
||||
_tool_options: &Self::ToolOptions,
|
||||
responses: &mut VecDeque<Message>,
|
||||
) -> Self {
|
||||
let shape_data = &mut tool_data.data;
|
||||
|
||||
let ToolMessage::Imaginate(event) = event else { return self };
|
||||
match (self, event) {
|
||||
(ImaginateToolFsmState::Ready, ImaginateToolMessage::DragStart) => {
|
||||
shape_data.start(document, input);
|
||||
// responses.add(DocumentMessage::AddTransaction);
|
||||
//shape_data.layer = Some(LayerNodeIdentifier::new(NodeId::new(), &document.network_interface));
|
||||
responses.add(DocumentMessage::DeselectAllLayers);
|
||||
|
||||
// // Utility function to offset the position of each consecutive node
|
||||
// let mut pos = 8;
|
||||
// let mut next_pos = || {
|
||||
// pos += 8;
|
||||
// DocumentNodeMetadata::position((pos, 4))
|
||||
// };
|
||||
|
||||
// // Get the node type for the Transform and Imaginate nodes
|
||||
// let Some(transform_node_type) = resolve_document_node_type("Transform") else {
|
||||
// warn!("Transform node should be in registry");
|
||||
// return ImaginateToolFsmState::Drawing;
|
||||
// };
|
||||
// let imaginate_node_type = &*IMAGINATE_NODE;
|
||||
|
||||
// // Give them a unique ID
|
||||
// let transform_node_id = NodeId(100);
|
||||
//let imaginate_node_id = NodeId(101);
|
||||
|
||||
// Create the network based on the Input -> Output passthrough default network
|
||||
// let mut network = new_image_network(16, imaginate_node_id);
|
||||
|
||||
// // Insert the nodes into the default network
|
||||
// network.insert_node(
|
||||
// transform_node_id,
|
||||
// transform_node_type.to_document_node_default_inputs([Some(NodeInput::node(NodeId(0), 0))], next_pos()),
|
||||
// );
|
||||
// network.insert_node(
|
||||
// imaginate_node_id,
|
||||
// imaginate_node_type.to_document_node_default_inputs([Some(NodeInput::node(transform_node_id, 0))], next_pos()),
|
||||
// );
|
||||
// responses.add(NodeGraphMessage::ShiftNode { node_id: imaginate_node_id });
|
||||
|
||||
// // Add a layer with a frame to the document
|
||||
// responses.add(Operation::AddFrame {
|
||||
// path: shape_data.layer.unwrap().to_path(),
|
||||
// insert_index: -1,
|
||||
// transform: DAffine2::ZERO.to_cols_array(),
|
||||
// network,
|
||||
// });
|
||||
|
||||
ImaginateToolFsmState::Drawing
|
||||
}
|
||||
(state, ImaginateToolMessage::Resize { center, lock_ratio }) => {
|
||||
let message = shape_data.calculate_transform(document, input, center, lock_ratio, true);
|
||||
responses.try_add(message);
|
||||
|
||||
state
|
||||
}
|
||||
(ImaginateToolFsmState::Drawing, ImaginateToolMessage::DragStop) => {
|
||||
input.mouse.finish_transaction(shape_data.viewport_drag_start(document), responses);
|
||||
shape_data.cleanup(responses);
|
||||
|
||||
ImaginateToolFsmState::Ready
|
||||
}
|
||||
(ImaginateToolFsmState::Drawing, ImaginateToolMessage::Abort) => {
|
||||
responses.add(DocumentMessage::AbortTransaction);
|
||||
|
||||
shape_data.cleanup(responses);
|
||||
|
||||
ImaginateToolFsmState::Ready
|
||||
}
|
||||
(_, ImaginateToolMessage::Abort) => ImaginateToolFsmState::Ready,
|
||||
_ => self,
|
||||
}
|
||||
}
|
||||
|
||||
fn update_hints(&self, responses: &mut VecDeque<Message>) {
|
||||
let hint_data = match self {
|
||||
ImaginateToolFsmState::Ready => HintData(vec![HintGroup(vec![
|
||||
HintInfo::mouse(MouseMotion::LmbDrag, "Draw Repaint Frame"),
|
||||
HintInfo::keys([Key::Shift], "Constrain Square").prepend_plus(),
|
||||
HintInfo::keys([Key::Alt], "From Center").prepend_plus(),
|
||||
])]),
|
||||
ImaginateToolFsmState::Drawing => HintData(vec![HintGroup(vec![HintInfo::keys([Key::Shift], "Constrain Square"), HintInfo::keys([Key::Alt], "From Center")])]),
|
||||
};
|
||||
|
||||
responses.add(FrontendMessage::UpdateInputHints { hint_data });
|
||||
}
|
||||
|
||||
fn update_cursor(&self, responses: &mut VecDeque<Message>) {
|
||||
responses.add(FrontendMessage::UpdateMouseCursor { cursor: MouseCursorIcon::Crosshair });
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,6 @@ pub mod eyedropper_tool;
|
||||
pub mod fill_tool;
|
||||
pub mod freehand_tool;
|
||||
pub mod gradient_tool;
|
||||
// pub mod imaginate_tool;
|
||||
pub mod navigate_tool;
|
||||
pub mod path_tool;
|
||||
pub mod pen_tool;
|
||||
|
||||
@@ -363,7 +363,6 @@ pub enum ToolType {
|
||||
Patch,
|
||||
Detail,
|
||||
Relight,
|
||||
Imaginate,
|
||||
Frame,
|
||||
}
|
||||
|
||||
@@ -418,9 +417,6 @@ fn list_tools_in_groups() -> Vec<Vec<ToolAvailability>> {
|
||||
ToolAvailability::ComingSoon(ToolEntry::new(ToolType::Patch, "RasterPatchTool").tooltip("Coming Soon: Patch Tool")),
|
||||
ToolAvailability::ComingSoon(ToolEntry::new(ToolType::Detail, "RasterDetailTool").tooltip("Coming Soon: Detail Tool (D)")),
|
||||
ToolAvailability::ComingSoon(ToolEntry::new(ToolType::Relight, "RasterRelightTool").tooltip("Coming Soon: Relight Tool (O)")),
|
||||
// TODO: Fix and reenable Imaginate tool
|
||||
// ToolAvailability::Available(Box::<imaginate_tool::ImaginateTool>::default()),
|
||||
ToolAvailability::ComingSoon(ToolEntry::new(ToolType::Heal, "RasterImaginateTool").tooltip("Coming Soon: Imaginate Tool")),
|
||||
],
|
||||
]
|
||||
}
|
||||
@@ -450,7 +446,6 @@ pub fn tool_message_to_tool_type(tool_message: &ToolMessage) -> ToolType {
|
||||
// ToolMessage::Patch(_) => ToolType::Patch,
|
||||
// ToolMessage::Detail(_) => ToolType::Detail,
|
||||
// ToolMessage::Relight(_) => ToolType::Relight,
|
||||
// ToolMessage::Imaginate(_) => ToolType::Imaginate,
|
||||
_ => panic!("Conversion from ToolMessage to ToolType impossible because the given ToolMessage does not have a matching ToolType. Got: {tool_message:?}"),
|
||||
}
|
||||
}
|
||||
@@ -483,7 +478,6 @@ pub fn tool_type_to_activate_tool_message(tool_type: ToolType) -> ToolMessageDis
|
||||
// ToolType::Patch => ToolMessageDiscriminant::ActivateToolPatch,
|
||||
// ToolType::Detail => ToolMessageDiscriminant::ActivateToolDetail,
|
||||
// ToolType::Relight => ToolMessageDiscriminant::ActivateToolRelight,
|
||||
// ToolType::Imaginate => ToolMessageDiscriminant::ActivateToolImaginate,
|
||||
_ => panic!("Conversion from ToolType to ToolMessage impossible because the given ToolType does not have a matching ToolMessage. Got: {tool_type:?}"),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -299,9 +299,6 @@ impl NodeGraphExecutor {
|
||||
}
|
||||
}
|
||||
}
|
||||
// NodeGraphUpdate::NodeGraphUpdateMessage(NodeGraphUpdateMessage::ImaginateStatusUpdate) => {
|
||||
// responses.add(DocumentMessage::PropertiesPanel(PropertiesPanelMessage::Refresh));
|
||||
// }
|
||||
NodeGraphUpdate::CompilationResponse(execution_response) => {
|
||||
let CompilationResponse { node_graph_errors, result } = execution_response;
|
||||
let type_delta = match result {
|
||||
|
||||
Reference in New Issue
Block a user