diff --git a/desktop/wrapper/src/intercept_frontend_message.rs b/desktop/wrapper/src/intercept_frontend_message.rs index 5c69df58b..4905109d1 100644 --- a/desktop/wrapper/src/intercept_frontend_message.rs +++ b/desktop/wrapper/src/intercept_frontend_message.rs @@ -120,7 +120,7 @@ pub(super) fn intercept_frontend_message(dispatcher: &mut DesktopWrapperMessageD [ WidgetDiff { widget_path, - new_value: DiffUpdate::SubLayout(layout), + new_value: DiffUpdate::WidgetLayout(layout), }, ] if widget_path.is_empty() => { let entries = crate::utils::menu::convert_menu_bar_layout_to_menu_items(layout); diff --git a/desktop/wrapper/src/utils.rs b/desktop/wrapper/src/utils.rs index 0fcf7480c..3ae13b9b9 100644 --- a/desktop/wrapper/src/utils.rs +++ b/desktop/wrapper/src/utils.rs @@ -6,11 +6,11 @@ pub(crate) mod menu { use graphite_editor::messages::input_mapper::utility_types::input_keyboard::{Key, LabeledKey, LabeledShortcut}; use graphite_editor::messages::input_mapper::utility_types::misc::ActionShortcut; use graphite_editor::messages::layout::LayoutMessage; - use graphite_editor::messages::tool::tool_messages::tool_prelude::{LayoutGroup, LayoutTarget, MenuListEntry, SubLayout, Widget, WidgetId}; + use graphite_editor::messages::tool::tool_messages::tool_prelude::{LayoutGroup, LayoutTarget, MenuListEntry, Widget, WidgetId, WidgetLayout}; use crate::messages::{EditorMessage, KeyCode, MenuItem, Modifiers, Shortcut}; - pub(crate) fn convert_menu_bar_layout_to_menu_items(layout: &SubLayout) -> Vec { + pub(crate) fn convert_menu_bar_layout_to_menu_items(layout: &WidgetLayout) -> Vec { let layout_group = match layout.as_slice() { [layout_group] => layout_group, _ => panic!("Menu bar layout is supposed to have exactly one layout group"), diff --git a/editor/src/dispatcher.rs b/editor/src/dispatcher.rs index 0e9d7403b..64d4c45cd 100644 --- a/editor/src/dispatcher.rs +++ b/editor/src/dispatcher.rs @@ -547,9 +547,9 @@ mod test { for response in responses { // Check for the existence of the file format incompatibility warning dialog after opening the test file - if let FrontendMessage::UpdateDialogColumn1 { layout_target: _, diff } = response { - if let DiffUpdate::SubLayout(sub_layout) = &diff[0].new_value { - if let LayoutGroup::Row { widgets } = &sub_layout[0] { + if let FrontendMessage::UpdateDialogColumn1 { diff } = response { + if let DiffUpdate::WidgetLayout(sub_layout) = &diff[0].new_value { + if let LayoutGroup::Row { widgets } = &sub_layout.0[0] { if let Widget::TextLabel(TextLabel { value, .. }) = &widgets[0].widget { print_problem_to_terminal_on_failure(value); } diff --git a/editor/src/messages/dialog/export_dialog/export_dialog_message_handler.rs b/editor/src/messages/dialog/export_dialog/export_dialog_message_handler.rs index 975c0785a..8562e6330 100644 --- a/editor/src/messages/dialog/export_dialog/export_dialog_message_handler.rs +++ b/editor/src/messages/dialog/export_dialog/export_dialog_message_handler.rs @@ -76,7 +76,7 @@ impl DialogLayoutHolder for ExportDialogMessageHandler { TextButton::new("Cancel").on_update(|_| FrontendMessage::DisplayDialogDismiss.into()).widget_instance(), ]; - Layout::WidgetLayout(WidgetLayout::new(vec![LayoutGroup::Row { widgets }])) + Layout::WidgetLayout(WidgetLayout(vec![LayoutGroup::Row { widgets }])) } } @@ -160,7 +160,7 @@ impl LayoutHolder for ExportDialogMessageHandler { .widget_instance(), ]; - Layout::WidgetLayout(WidgetLayout::new(vec![ + Layout::WidgetLayout(WidgetLayout(vec![ LayoutGroup::Row { widgets: export_type }, LayoutGroup::Row { widgets: resolution }, LayoutGroup::Row { widgets: export_area }, diff --git a/editor/src/messages/dialog/new_document_dialog/new_document_dialog_message_handler.rs b/editor/src/messages/dialog/new_document_dialog/new_document_dialog_message_handler.rs index 2c4fcf34d..f4c448147 100644 --- a/editor/src/messages/dialog/new_document_dialog/new_document_dialog_message_handler.rs +++ b/editor/src/messages/dialog/new_document_dialog/new_document_dialog_message_handler.rs @@ -66,7 +66,7 @@ impl DialogLayoutHolder for NewDocumentDialogMessageHandler { TextButton::new("Cancel").on_update(|_| FrontendMessage::DisplayDialogDismiss.into()).widget_instance(), ]; - Layout::WidgetLayout(WidgetLayout::new(vec![LayoutGroup::Row { widgets }])) + Layout::WidgetLayout(WidgetLayout(vec![LayoutGroup::Row { widgets }])) } } @@ -117,7 +117,7 @@ impl LayoutHolder for NewDocumentDialogMessageHandler { .widget_instance(), ]; - Layout::WidgetLayout(WidgetLayout::new(vec![ + Layout::WidgetLayout(WidgetLayout(vec![ LayoutGroup::Row { widgets: name }, LayoutGroup::Row { widgets: infinite }, LayoutGroup::Row { widgets: scale }, diff --git a/editor/src/messages/dialog/preferences_dialog/preferences_dialog_message_handler.rs b/editor/src/messages/dialog/preferences_dialog/preferences_dialog_message_handler.rs index 393c37fed..d5840a97f 100644 --- a/editor/src/messages/dialog/preferences_dialog/preferences_dialog_message_handler.rs +++ b/editor/src/messages/dialog/preferences_dialog/preferences_dialog_message_handler.rs @@ -224,7 +224,7 @@ impl PreferencesDialogMessageHandler { .widget_instance(), ]; - Layout::WidgetLayout(WidgetLayout::new(vec![ + Layout::WidgetLayout(WidgetLayout(vec![ LayoutGroup::Row { widgets: navigation_header }, LayoutGroup::Row { widgets: zoom_rate_label }, LayoutGroup::Row { widgets: zoom_rate }, @@ -272,7 +272,7 @@ impl PreferencesDialogMessageHandler { TextButton::new("Reset to Defaults").on_update(|_| PreferencesMessage::ResetToDefaults.into()).widget_instance(), ]; - Layout::WidgetLayout(WidgetLayout::new(vec![LayoutGroup::Row { widgets }])) + Layout::WidgetLayout(WidgetLayout(vec![LayoutGroup::Row { widgets }])) } fn send_layout_buttons(&self, responses: &mut VecDeque, layout_target: LayoutTarget) { diff --git a/editor/src/messages/dialog/simple_dialogs/about_graphite_dialog.rs b/editor/src/messages/dialog/simple_dialogs/about_graphite_dialog.rs index 977856455..eb45174ea 100644 --- a/editor/src/messages/dialog/simple_dialogs/about_graphite_dialog.rs +++ b/editor/src/messages/dialog/simple_dialogs/about_graphite_dialog.rs @@ -15,7 +15,7 @@ impl DialogLayoutHolder for AboutGraphiteDialog { fn layout_buttons(&self) -> Layout { let widgets = vec![TextButton::new("OK").emphasized(true).on_update(|_| FrontendMessage::DisplayDialogDismiss.into()).widget_instance()]; - Layout::WidgetLayout(WidgetLayout::new(vec![LayoutGroup::Row { widgets }])) + Layout::WidgetLayout(WidgetLayout(vec![LayoutGroup::Row { widgets }])) } fn layout_column_2(&self) -> Layout { @@ -51,13 +51,13 @@ impl DialogLayoutHolder for AboutGraphiteDialog { .widget_instance(), ); - Layout::WidgetLayout(WidgetLayout::new(vec![LayoutGroup::Column { widgets }])) + Layout::WidgetLayout(WidgetLayout(vec![LayoutGroup::Column { widgets }])) } } impl LayoutHolder for AboutGraphiteDialog { fn layout(&self) -> Layout { - Layout::WidgetLayout(WidgetLayout::new(vec![ + Layout::WidgetLayout(WidgetLayout(vec![ LayoutGroup::Row { widgets: vec![TextLabel::new("About this release").bold(true).widget_instance()], }, diff --git a/editor/src/messages/dialog/simple_dialogs/close_all_documents_dialog.rs b/editor/src/messages/dialog/simple_dialogs/close_all_documents_dialog.rs index 6d541c631..583dd48d3 100644 --- a/editor/src/messages/dialog/simple_dialogs/close_all_documents_dialog.rs +++ b/editor/src/messages/dialog/simple_dialogs/close_all_documents_dialog.rs @@ -24,7 +24,7 @@ impl DialogLayoutHolder for CloseAllDocumentsDialog { TextButton::new("Cancel").on_update(|_| FrontendMessage::DisplayDialogDismiss.into()).widget_instance(), ]; - Layout::WidgetLayout(WidgetLayout::new(vec![LayoutGroup::Row { widgets }])) + Layout::WidgetLayout(WidgetLayout(vec![LayoutGroup::Row { widgets }])) } } @@ -32,7 +32,7 @@ impl LayoutHolder for CloseAllDocumentsDialog { fn layout(&self) -> Layout { let unsaved_list = "• ".to_string() + &self.unsaved_document_names.join("\n• "); - Layout::WidgetLayout(WidgetLayout::new(vec![ + Layout::WidgetLayout(WidgetLayout(vec![ LayoutGroup::Row { widgets: vec![TextLabel::new("Save documents before closing them?").bold(true).multiline(true).widget_instance()], }, diff --git a/editor/src/messages/dialog/simple_dialogs/close_document_dialog.rs b/editor/src/messages/dialog/simple_dialogs/close_document_dialog.rs index 20b66903e..4248a9bed 100644 --- a/editor/src/messages/dialog/simple_dialogs/close_document_dialog.rs +++ b/editor/src/messages/dialog/simple_dialogs/close_document_dialog.rs @@ -35,7 +35,7 @@ impl DialogLayoutHolder for CloseDocumentDialog { TextButton::new("Cancel").on_update(|_| FrontendMessage::DisplayDialogDismiss.into()).widget_instance(), ]; - Layout::WidgetLayout(WidgetLayout::new(vec![LayoutGroup::Row { widgets }])) + Layout::WidgetLayout(WidgetLayout(vec![LayoutGroup::Row { widgets }])) } } @@ -51,7 +51,7 @@ impl LayoutHolder for CloseDocumentDialog { let break_lines = if self.document_name.len() > max_one_line_length { '\n' } else { ' ' }; - Layout::WidgetLayout(WidgetLayout::new(vec![ + Layout::WidgetLayout(WidgetLayout(vec![ LayoutGroup::Row { widgets: vec![TextLabel::new("Save document before closing it?").bold(true).widget_instance()], }, diff --git a/editor/src/messages/dialog/simple_dialogs/coming_soon_dialog.rs b/editor/src/messages/dialog/simple_dialogs/coming_soon_dialog.rs index 661a67d28..6e00c7336 100644 --- a/editor/src/messages/dialog/simple_dialogs/coming_soon_dialog.rs +++ b/editor/src/messages/dialog/simple_dialogs/coming_soon_dialog.rs @@ -13,7 +13,7 @@ impl DialogLayoutHolder for ComingSoonDialog { fn layout_buttons(&self) -> Layout { let widgets = vec![TextButton::new("OK").emphasized(true).on_update(|_| FrontendMessage::DisplayDialogDismiss.into()).widget_instance()]; - Layout::WidgetLayout(WidgetLayout::new(vec![LayoutGroup::Row { widgets }])) + Layout::WidgetLayout(WidgetLayout(vec![LayoutGroup::Row { widgets }])) } } @@ -43,6 +43,6 @@ impl LayoutHolder for ComingSoonDialog { rows.push(LayoutGroup::Row { widgets: row3 }); } - Layout::WidgetLayout(WidgetLayout::new(rows)) + Layout::WidgetLayout(WidgetLayout(rows)) } } diff --git a/editor/src/messages/dialog/simple_dialogs/demo_artwork_dialog.rs b/editor/src/messages/dialog/simple_dialogs/demo_artwork_dialog.rs index f3812c70e..fe381225d 100644 --- a/editor/src/messages/dialog/simple_dialogs/demo_artwork_dialog.rs +++ b/editor/src/messages/dialog/simple_dialogs/demo_artwork_dialog.rs @@ -22,7 +22,7 @@ impl DialogLayoutHolder for DemoArtworkDialog { fn layout_buttons(&self) -> Layout { let widgets = vec![TextButton::new("Close").emphasized(true).on_update(|_| FrontendMessage::DisplayDialogDismiss.into()).widget_instance()]; - Layout::WidgetLayout(WidgetLayout::new(vec![LayoutGroup::Row { widgets }])) + Layout::WidgetLayout(WidgetLayout(vec![LayoutGroup::Row { widgets }])) } } @@ -59,6 +59,6 @@ impl LayoutHolder for DemoArtworkDialog { .collect(); let _ = rows_of_images_with_buttons.pop(); - Layout::WidgetLayout(WidgetLayout::new(rows_of_images_with_buttons)) + Layout::WidgetLayout(WidgetLayout(rows_of_images_with_buttons)) } } diff --git a/editor/src/messages/dialog/simple_dialogs/error_dialog.rs b/editor/src/messages/dialog/simple_dialogs/error_dialog.rs index adc65efb4..94e759a22 100644 --- a/editor/src/messages/dialog/simple_dialogs/error_dialog.rs +++ b/editor/src/messages/dialog/simple_dialogs/error_dialog.rs @@ -14,13 +14,13 @@ impl DialogLayoutHolder for ErrorDialog { fn layout_buttons(&self) -> Layout { let widgets = vec![TextButton::new("OK").emphasized(true).on_update(|_| FrontendMessage::DisplayDialogDismiss.into()).widget_instance()]; - Layout::WidgetLayout(WidgetLayout::new(vec![LayoutGroup::Row { widgets }])) + Layout::WidgetLayout(WidgetLayout(vec![LayoutGroup::Row { widgets }])) } } impl LayoutHolder for ErrorDialog { fn layout(&self) -> Layout { - Layout::WidgetLayout(WidgetLayout::new(vec![ + Layout::WidgetLayout(WidgetLayout(vec![ LayoutGroup::Row { widgets: vec![TextLabel::new(&self.title).bold(true).widget_instance()], }, diff --git a/editor/src/messages/dialog/simple_dialogs/licenses_dialog.rs b/editor/src/messages/dialog/simple_dialogs/licenses_dialog.rs index 260690b90..93f56315a 100644 --- a/editor/src/messages/dialog/simple_dialogs/licenses_dialog.rs +++ b/editor/src/messages/dialog/simple_dialogs/licenses_dialog.rs @@ -12,7 +12,7 @@ impl DialogLayoutHolder for LicensesDialog { fn layout_buttons(&self) -> Layout { let widgets = vec![TextButton::new("OK").emphasized(true).on_update(|_| FrontendMessage::DisplayDialogDismiss.into()).widget_instance()]; - Layout::WidgetLayout(WidgetLayout::new(vec![LayoutGroup::Row { widgets }])) + Layout::WidgetLayout(WidgetLayout(vec![LayoutGroup::Row { widgets }])) } fn layout_column_2(&self) -> Layout { @@ -43,7 +43,7 @@ impl DialogLayoutHolder for LicensesDialog { .map(|&(icon, label, message_factory)| TextButton::new(label).icon(Some((icon).into())).flush(true).on_update(move |_| message_factory()).widget_instance()) .collect(); - Layout::WidgetLayout(WidgetLayout::new(vec![LayoutGroup::Column { widgets }])) + Layout::WidgetLayout(WidgetLayout(vec![LayoutGroup::Column { widgets }])) } } @@ -63,7 +63,7 @@ impl LayoutHolder for LicensesDialog { ); let description = description.trim(); - Layout::WidgetLayout(WidgetLayout::new(vec![ + Layout::WidgetLayout(WidgetLayout(vec![ LayoutGroup::Row { widgets: vec![TextLabel::new("Graphite is free, open source software").bold(true).widget_instance()], }, diff --git a/editor/src/messages/dialog/simple_dialogs/licenses_third_party_dialog.rs b/editor/src/messages/dialog/simple_dialogs/licenses_third_party_dialog.rs index 693a5fe3d..16f985018 100644 --- a/editor/src/messages/dialog/simple_dialogs/licenses_third_party_dialog.rs +++ b/editor/src/messages/dialog/simple_dialogs/licenses_third_party_dialog.rs @@ -12,7 +12,7 @@ impl DialogLayoutHolder for LicensesThirdPartyDialog { fn layout_buttons(&self) -> Layout { let widgets = vec![TextButton::new("OK").emphasized(true).on_update(|_| FrontendMessage::DisplayDialogDismiss.into()).widget_instance()]; - Layout::WidgetLayout(WidgetLayout::new(vec![LayoutGroup::Row { widgets }])) + Layout::WidgetLayout(WidgetLayout(vec![LayoutGroup::Row { widgets }])) } } @@ -31,7 +31,7 @@ impl LayoutHolder for LicensesThirdPartyDialog { // Two characters (one before, one after) the sequence of underscore characters, plus one additional column to provide a space between the text and the scrollbar let non_wrapping_column_width = license_text.split('\n').map(|line| line.chars().filter(|&c| c == '_').count()).max().unwrap_or(0) + 2 + 1; - Layout::WidgetLayout(WidgetLayout::new(vec![LayoutGroup::Row { + Layout::WidgetLayout(WidgetLayout(vec![LayoutGroup::Row { widgets: vec![ TextLabel::new(license_text) .monospace(true) diff --git a/editor/src/messages/frontend/frontend_message.rs b/editor/src/messages/frontend/frontend_message.rs index 8abf6c576..be74152c5 100644 --- a/editor/src/messages/frontend/frontend_message.rs +++ b/editor/src/messages/frontend/frontend_message.rs @@ -170,8 +170,6 @@ pub enum FrontendMessage { open: bool, }, UpdateDataPanelLayout { - #[serde(rename = "layoutTarget")] - layout_target: LayoutTarget, diff: Vec, }, UpdateImportReorderIndex { @@ -191,18 +189,12 @@ pub enum FrontendMessage { has_left_input_wire: HashMap, }, UpdateDialogButtons { - #[serde(rename = "layoutTarget")] - layout_target: LayoutTarget, diff: Vec, }, UpdateDialogColumn1 { - #[serde(rename = "layoutTarget")] - layout_target: LayoutTarget, diff: Vec, }, UpdateDialogColumn2 { - #[serde(rename = "layoutTarget")] - layout_target: LayoutTarget, diff: Vec, }, UpdateDocumentArtwork { @@ -212,8 +204,6 @@ pub enum FrontendMessage { image_data: Vec<(u64, Image)>, }, UpdateDocumentBarLayout { - #[serde(rename = "layoutTarget")] - layout_target: LayoutTarget, diff: Vec, }, UpdateDocumentLayerDetails { @@ -228,8 +218,6 @@ pub enum FrontendMessage { data_buffer: JsRawBuffer, }, UpdateDocumentModeLayout { - #[serde(rename = "layoutTarget")] - layout_target: LayoutTarget, diff: Vec, }, UpdateDocumentRulers { @@ -257,23 +245,15 @@ pub enum FrontendMessage { percentage: f64, }, UpdateLayersPanelControlBarLeftLayout { - #[serde(rename = "layoutTarget")] - layout_target: LayoutTarget, diff: Vec, }, UpdateLayersPanelControlBarRightLayout { - #[serde(rename = "layoutTarget")] - layout_target: LayoutTarget, diff: Vec, }, UpdateLayersPanelBottomBarLayout { - #[serde(rename = "layoutTarget")] - layout_target: LayoutTarget, diff: Vec, }, UpdateMenuBarLayout { - #[serde(rename = "layoutTarget")] - layout_target: LayoutTarget, diff: Vec, }, UpdateMouseCursor { @@ -293,8 +273,6 @@ pub enum FrontendMessage { }, ClearAllNodeGraphWires, UpdateNodeGraphControlBarLayout { - #[serde(rename = "layoutTarget")] - layout_target: LayoutTarget, diff: Vec, }, UpdateNodeGraphSelection { @@ -312,18 +290,12 @@ pub enum FrontendMessage { open_documents: Vec, }, UpdatePropertiesPanelLayout { - #[serde(rename = "layoutTarget")] - layout_target: LayoutTarget, diff: Vec, }, UpdateToolOptionsLayout { - #[serde(rename = "layoutTarget")] - layout_target: LayoutTarget, diff: Vec, }, UpdateToolShelfLayout { - #[serde(rename = "layoutTarget")] - layout_target: LayoutTarget, diff: Vec, }, UpdateWirePathInProgress { @@ -331,18 +303,12 @@ pub enum FrontendMessage { wire_path: Option, }, UpdateWelcomeScreenButtonsLayout { - #[serde(rename = "layoutTarget")] - layout_target: LayoutTarget, diff: Vec, }, UpdateStatusBarHintsLayout { - #[serde(rename = "layoutTarget")] - layout_target: LayoutTarget, diff: Vec, }, UpdateWorkingColorsLayout { - #[serde(rename = "layoutTarget")] - layout_target: LayoutTarget, diff: Vec, }, UpdatePlatform { diff --git a/editor/src/messages/layout/layout_message_handler.rs b/editor/src/messages/layout/layout_message_handler.rs index 727aae974..e6c58e2b2 100644 --- a/editor/src/messages/layout/layout_message_handler.rs +++ b/editor/src/messages/layout/layout_message_handler.rs @@ -62,7 +62,7 @@ impl MessageHandler> for LayoutMessageHa impl LayoutMessageHandler { /// Get the widget path for the widget with the specified id fn get_widget_path(widget_layout: &WidgetLayout, widget_id: WidgetId) -> Option<(&WidgetInstance, Vec)> { - let mut stack = widget_layout.layout.iter().enumerate().map(|(index, val)| (vec![index], val)).collect::>(); + let mut stack = widget_layout.0.iter().enumerate().map(|(index, val)| (vec![index], val)).collect::>(); while let Some((mut widget_path, layout_group)) = stack.pop() { match layout_group { // Check if any of the widgets in the current column or row have the correct id @@ -75,13 +75,20 @@ impl LayoutMessageHandler { } if let Widget::PopoverButton(popover) = &widget.widget { - stack.extend(popover.popover_layout.iter().enumerate().map(|(child, val)| ([widget_path.as_slice(), &[index, child]].concat(), val))); + stack.extend( + popover + .popover_layout + .0 + .iter() + .enumerate() + .map(|(child, val)| ([widget_path.as_slice(), &[index, child]].concat(), val)), + ); } } } // A section contains more LayoutGroups which we add to the stack. LayoutGroup::Section { layout, .. } => { - stack.extend(layout.iter().enumerate().map(|(index, val)| ([widget_path.as_slice(), &[index]].concat(), val))); + stack.extend(layout.0.iter().enumerate().map(|(index, val)| ([widget_path.as_slice(), &[index]].concat(), val))); } LayoutGroup::Table { rows, .. } => { for (row_index, row) in rows.iter().enumerate() { @@ -97,6 +104,7 @@ impl LayoutMessageHandler { stack.extend( popover .popover_layout + .0 .iter() .enumerate() .map(|(child, val)| ([widget_path.as_slice(), &[row_index, cell_index, child]].concat(), val)), @@ -489,7 +497,7 @@ impl LayoutMessageHandler { if layout_target == LayoutTarget::MenuBar { widget_diffs = vec![WidgetDiff { widget_path: Vec::new(), - new_value: DiffUpdate::SubLayout(current.layout.clone()), + new_value: DiffUpdate::WidgetLayout(current.layout.clone()), }]; } @@ -503,23 +511,23 @@ impl LayoutMessageHandler { diff.iter_mut().for_each(|diff| diff.new_value.apply_keyboard_shortcut(action_input_mapping)); let message = match layout_target { - LayoutTarget::DataPanel => FrontendMessage::UpdateDataPanelLayout { layout_target, diff }, - LayoutTarget::DialogButtons => FrontendMessage::UpdateDialogButtons { layout_target, diff }, - LayoutTarget::DialogColumn1 => FrontendMessage::UpdateDialogColumn1 { layout_target, diff }, - LayoutTarget::DialogColumn2 => FrontendMessage::UpdateDialogColumn2 { layout_target, diff }, - LayoutTarget::DocumentBar => FrontendMessage::UpdateDocumentBarLayout { layout_target, diff }, - LayoutTarget::DocumentMode => FrontendMessage::UpdateDocumentModeLayout { layout_target, diff }, - LayoutTarget::LayersPanelBottomBar => FrontendMessage::UpdateLayersPanelBottomBarLayout { layout_target, diff }, - LayoutTarget::LayersPanelControlLeftBar => FrontendMessage::UpdateLayersPanelControlBarLeftLayout { layout_target, diff }, - LayoutTarget::LayersPanelControlRightBar => FrontendMessage::UpdateLayersPanelControlBarRightLayout { layout_target, diff }, - LayoutTarget::MenuBar => FrontendMessage::UpdateMenuBarLayout { layout_target, diff }, - LayoutTarget::NodeGraphControlBar => FrontendMessage::UpdateNodeGraphControlBarLayout { layout_target, diff }, - LayoutTarget::PropertiesPanel => FrontendMessage::UpdatePropertiesPanelLayout { layout_target, diff }, - LayoutTarget::StatusBarHints => FrontendMessage::UpdateStatusBarHintsLayout { layout_target, diff }, - LayoutTarget::ToolOptions => FrontendMessage::UpdateToolOptionsLayout { layout_target, diff }, - LayoutTarget::ToolShelf => FrontendMessage::UpdateToolShelfLayout { layout_target, diff }, - LayoutTarget::WelcomeScreenButtons => FrontendMessage::UpdateWelcomeScreenButtonsLayout { layout_target, diff }, - LayoutTarget::WorkingColors => FrontendMessage::UpdateWorkingColorsLayout { layout_target, diff }, + LayoutTarget::DataPanel => FrontendMessage::UpdateDataPanelLayout { diff }, + LayoutTarget::DialogButtons => FrontendMessage::UpdateDialogButtons { diff }, + LayoutTarget::DialogColumn1 => FrontendMessage::UpdateDialogColumn1 { diff }, + LayoutTarget::DialogColumn2 => FrontendMessage::UpdateDialogColumn2 { diff }, + LayoutTarget::DocumentBar => FrontendMessage::UpdateDocumentBarLayout { diff }, + LayoutTarget::DocumentMode => FrontendMessage::UpdateDocumentModeLayout { diff }, + LayoutTarget::LayersPanelBottomBar => FrontendMessage::UpdateLayersPanelBottomBarLayout { diff }, + LayoutTarget::LayersPanelControlLeftBar => FrontendMessage::UpdateLayersPanelControlBarLeftLayout { diff }, + LayoutTarget::LayersPanelControlRightBar => FrontendMessage::UpdateLayersPanelControlBarRightLayout { diff }, + LayoutTarget::MenuBar => FrontendMessage::UpdateMenuBarLayout { diff }, + LayoutTarget::NodeGraphControlBar => FrontendMessage::UpdateNodeGraphControlBarLayout { diff }, + LayoutTarget::PropertiesPanel => FrontendMessage::UpdatePropertiesPanelLayout { diff }, + LayoutTarget::StatusBarHints => FrontendMessage::UpdateStatusBarHintsLayout { diff }, + LayoutTarget::ToolOptions => FrontendMessage::UpdateToolOptionsLayout { diff }, + LayoutTarget::ToolShelf => FrontendMessage::UpdateToolShelfLayout { diff }, + LayoutTarget::WelcomeScreenButtons => FrontendMessage::UpdateWelcomeScreenButtonsLayout { diff }, + LayoutTarget::WorkingColors => FrontendMessage::UpdateWorkingColorsLayout { diff }, LayoutTarget::LayoutTargetLength => panic!("`LayoutTargetLength` is not a valid Layout Target and is used for array indexing"), }; diff --git a/editor/src/messages/layout/utility_types/layout_widget.rs b/editor/src/messages/layout/utility_types/layout_widget.rs index 1cf611491..d3141c76d 100644 --- a/editor/src/messages/layout/utility_types/layout_widget.rs +++ b/editor/src/messages/layout/utility_types/layout_widget.rs @@ -118,25 +118,19 @@ impl Default for Layout { // TODO: Unwrap this struct #[derive(Debug, Default, Clone, serde::Serialize, serde::Deserialize, PartialEq, specta::Type)] -pub struct WidgetLayout { - pub layout: SubLayout, -} +pub struct WidgetLayout(pub Vec); impl WidgetLayout { - pub fn new(layout: SubLayout) -> Self { - Self { layout } - } - pub fn iter(&self) -> WidgetIter<'_> { WidgetIter { - stack: self.layout.iter().collect(), + stack: self.0.iter().collect(), ..Default::default() } } pub fn iter_mut(&mut self) -> WidgetIterMut<'_> { WidgetIterMut { - stack: self.layout.iter_mut().collect(), + stack: self.0.iter_mut().collect(), ..Default::default() } } @@ -145,12 +139,12 @@ impl WidgetLayout { pub fn diff(&mut self, new: Self, widget_path: &mut Vec, widget_diffs: &mut Vec) { // Check if the length of items is different // TODO: Diff insersion and deletion of items - if self.layout.len() != new.layout.len() { + if self.0.len() != new.0.len() { // Update the layout to the new layout - self.layout.clone_from(&new.layout); + self.0.clone_from(&new.0); // Push an update sublayout to the diff - let new = DiffUpdate::SubLayout(new.layout); + let new = DiffUpdate::WidgetLayout(new); widget_diffs.push(WidgetDiff { widget_path: widget_path.to_vec(), new_value: new, @@ -158,7 +152,7 @@ impl WidgetLayout { return; } // Diff all of the children - for (index, (current_child, new_child)) in self.layout.iter_mut().zip(new.layout).enumerate() { + for (index, (current_child, new_child)) in self.0.iter_mut().zip(new.0).enumerate() { widget_path.push(index); current_child.diff(new_child, widget_path, widget_diffs); widget_path.pop(); @@ -185,7 +179,7 @@ impl<'a> Iterator for WidgetIter<'a> { if let Some(item) = widget { if let WidgetInstance { widget: Widget::PopoverButton(p), .. } = item { - self.stack.extend(p.popover_layout.iter()); + self.stack.extend(p.popover_layout.0.iter()); return self.next(); } @@ -206,7 +200,7 @@ impl<'a> Iterator for WidgetIter<'a> { self.next() } Some(LayoutGroup::Section { layout, .. }) => { - for layout_row in layout { + for layout_row in &layout.0 { self.stack.push(layout_row); } self.next() @@ -235,7 +229,7 @@ impl<'a> Iterator for WidgetIterMut<'a> { if let Some(widget) = widget { if let WidgetInstance { widget: Widget::PopoverButton(p), .. } = widget { - self.stack.extend(p.popover_layout.iter_mut()); + self.stack.extend(p.popover_layout.0.iter_mut()); return self.next(); } @@ -256,7 +250,7 @@ impl<'a> Iterator for WidgetIterMut<'a> { self.next() } Some(LayoutGroup::Section { layout, .. }) => { - for layout_row in layout { + for layout_row in &mut layout.0 { self.stack.push(layout_row); } self.next() @@ -266,8 +260,6 @@ impl<'a> Iterator for WidgetIterMut<'a> { } } -pub type SubLayout = Vec; - #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, specta::Type)] pub enum LayoutGroup { #[serde(rename = "column")] @@ -293,7 +285,7 @@ pub enum LayoutGroup { visible: bool, pinned: bool, id: u64, - layout: SubLayout, + layout: WidgetLayout, }, } @@ -425,7 +417,7 @@ impl LayoutGroup { ) => { // Resend the entire panel if the lengths, names, visibility, or node IDs are different // TODO: Diff insersion and deletion of items - if current_layout.len() != new_layout.len() + if current_layout.0.len() != new_layout.0.len() || *current_name != new_name || *current_description != new_description || *current_visible != new_visible @@ -454,7 +446,7 @@ impl LayoutGroup { } // Diff all of the children else { - for (index, (current_child, new_child)) in current_layout.iter_mut().zip(new_layout).enumerate() { + for (index, (current_child, new_child)) in current_layout.0.iter_mut().zip(new_layout.0).enumerate() { widget_path.push(index); current_child.diff(new_child, widget_path, widget_diffs); widget_path.pop(); @@ -478,7 +470,6 @@ impl LayoutGroup { } } -// TODO: Rename to WidgetInstance #[derive(Debug, Clone, serde::Serialize, serde::Deserialize, specta::Type)] pub struct WidgetInstance { #[serde(rename = "widgetId")] @@ -514,7 +505,7 @@ impl WidgetInstance { && button1.popover_min_width == button2.popover_min_width { let mut new_widget_path = widget_path.to_vec(); - for (i, (a, b)) in button1.popover_layout.iter_mut().zip(button2.popover_layout.iter()).enumerate() { + for (i, (a, b)) in button1.popover_layout.0.iter_mut().zip(button2.popover_layout.0.iter()).enumerate() { new_widget_path.push(i); a.diff(b.clone(), &mut new_widget_path, widget_diffs); new_widget_path.pop(); @@ -598,11 +589,11 @@ pub struct WidgetDiff { /// The new value of the UI, sent as part of a diff. /// -/// An update can represent a single widget or an entire SubLayout, or just a single layout group. +/// An update can represent a single widget or an entire WidgetLayout, or just a single layout group. #[derive(PartialEq, Clone, Debug, serde::Serialize, serde::Deserialize, specta::Type)] pub enum DiffUpdate { - #[serde(rename = "subLayout")] - SubLayout(SubLayout), + #[serde(rename = "widgetLayout")] + WidgetLayout(WidgetLayout), #[serde(rename = "layoutGroup")] LayoutGroup(LayoutGroup), #[serde(rename = "widget")] @@ -684,7 +675,7 @@ impl DiffUpdate { }; match self { - Self::SubLayout(sub_layout) => sub_layout.iter_mut().flat_map(|layout_group| layout_group.iter_mut()).for_each(|widget_instance| { + Self::WidgetLayout(widget_layout) => widget_layout.0.iter_mut().flat_map(|layout_group| layout_group.iter_mut()).for_each(|widget_instance| { convert_tooltip(widget_instance); convert_menu_lists(widget_instance); }), diff --git a/editor/src/messages/layout/utility_types/widgets/button_widgets.rs b/editor/src/messages/layout/utility_types/widgets/button_widgets.rs index 6915a0922..4f3c4c896 100644 --- a/editor/src/messages/layout/utility_types/widgets/button_widgets.rs +++ b/editor/src/messages/layout/utility_types/widgets/button_widgets.rs @@ -63,7 +63,7 @@ pub struct PopoverButton { pub tooltip_shortcut: Option, #[serde(rename = "popoverLayout")] - pub popover_layout: SubLayout, + pub popover_layout: WidgetLayout, #[serde(rename = "popoverMinWidth")] pub popover_min_width: Option, diff --git a/editor/src/messages/portfolio/document/data_panel/data_panel_message_handler.rs b/editor/src/messages/portfolio/document/data_panel/data_panel_message_handler.rs index 8d492f855..a4ea7d5a8 100644 --- a/editor/src/messages/portfolio/document/data_panel/data_panel_message_handler.rs +++ b/editor/src/messages/portfolio/document/data_panel/data_panel_message_handler.rs @@ -131,7 +131,7 @@ impl DataPanelMessageHandler { } responses.add(LayoutMessage::SendLayout { - layout: Layout::WidgetLayout(WidgetLayout { layout }), + layout: Layout::WidgetLayout(WidgetLayout(layout)), layout_target: LayoutTarget::DataPanel, }); } diff --git a/editor/src/messages/portfolio/document/document_message_handler.rs b/editor/src/messages/portfolio/document/document_message_handler.rs index b43a1dfb2..34b1e290f 100644 --- a/editor/src/messages/portfolio/document/document_message_handler.rs +++ b/editor/src/messages/portfolio/document/document_message_handler.rs @@ -2175,7 +2175,7 @@ impl DocumentMessageHandler { pub fn update_document_widgets(&self, responses: &mut VecDeque, animation_is_playing: bool, time: Duration) { // Document mode (dropdown menu at the left of the bar above the viewport, before the tool options) - let document_mode_layout = WidgetLayout::new(vec![LayoutGroup::Row { + let document_mode_layout = WidgetLayout(vec![LayoutGroup::Row { widgets: vec![ // DropdownInput::new( // vec![vec![ @@ -2235,7 +2235,7 @@ impl DocumentMessageHandler { }) .widget_instance(), PopoverButton::new() - .popover_layout(vec![ + .popover_layout(WidgetLayout(vec![ LayoutGroup::Row { widgets: vec![TextLabel::new("Overlays").bold(true).widget_instance()], }, @@ -2468,7 +2468,7 @@ impl DocumentMessageHandler { ] }, }, - ]) + ])) .widget_instance(), Separator::new(SeparatorType::Related).widget_instance(), CheckboxInput::new(snapping_state.snapping_enabled) @@ -2484,7 +2484,7 @@ impl DocumentMessageHandler { }) .widget_instance(), PopoverButton::new() - .popover_layout( + .popover_layout(WidgetLayout( [ LayoutGroup::Row { widgets: vec![TextLabel::new("Snapping").bold(true).widget_instance()], @@ -2538,7 +2538,7 @@ impl DocumentMessageHandler { }, })) .collect(), - ) + )) .widget_instance(), Separator::new(SeparatorType::Related).widget_instance(), CheckboxInput::new(self.snapping_state.grid_snapping) @@ -2548,7 +2548,7 @@ impl DocumentMessageHandler { .on_update(|optional_input: &CheckboxInput| DocumentMessage::GridVisibility { visible: optional_input.checked }.into()) .widget_instance(), PopoverButton::new() - .popover_layout(overlay_options(&self.snapping_state.grid)) + .popover_layout(WidgetLayout(overlay_options(&self.snapping_state.grid))) .popover_min_width(Some(320)) .widget_instance(), Separator::new(SeparatorType::Unrelated).widget_instance(), @@ -2573,8 +2573,8 @@ impl DocumentMessageHandler { .selected_index(Some(self.render_mode as u32)) .narrow(true) .widget_instance(), - // PopoverButton::new() - // .popover_layout(vec![ + // PopoverButton::new().popover_layout( + // WidgetLayout(vec![ // LayoutGroup::Row { // widgets: vec![TextLabel::new("Render Mode").bold(true).widget_instance()], // }, @@ -2583,6 +2583,7 @@ impl DocumentMessageHandler { // }, // ]) // .widget_instance(), + // ), Separator::new(SeparatorType::Unrelated).widget_instance(), ]; @@ -2631,7 +2632,7 @@ impl DocumentMessageHandler { .widget_instance(), ]); - let document_bar_layout = WidgetLayout::new(vec![LayoutGroup::Row { widgets }]); + let document_bar_layout = WidgetLayout(vec![LayoutGroup::Row { widgets }]); responses.add(LayoutMessage::SendLayout { layout: Layout::WidgetLayout(document_bar_layout), @@ -2772,7 +2773,7 @@ impl DocumentMessageHandler { .tooltip_label("Fill") .widget_instance(), ]; - let layers_panel_control_bar_left = WidgetLayout::new(vec![LayoutGroup::Row { widgets }]); + let layers_panel_control_bar_left = WidgetLayout(vec![LayoutGroup::Row { widgets }]); let widgets = vec![ IconButton::new(if selection_all_locked { "PadlockLocked" } else { "PadlockUnlocked" }, 24) @@ -2790,7 +2791,7 @@ impl DocumentMessageHandler { .disabled(!has_selection) .widget_instance(), ]; - let layers_panel_control_bar_right = WidgetLayout::new(vec![LayoutGroup::Row { widgets }]); + let layers_panel_control_bar_right = WidgetLayout(vec![LayoutGroup::Row { widgets }]); responses.add(LayoutMessage::SendLayout { layout: Layout::WidgetLayout(layers_panel_control_bar_left), @@ -2844,7 +2845,7 @@ impl DocumentMessageHandler { } }) .widget_instance(); - vec![LayoutGroup::Row { widgets: vec![node_chooser] }] + WidgetLayout(vec![LayoutGroup::Row { widgets: vec![node_chooser] }]) }) .widget_instance(), Separator::new(SeparatorType::Unrelated).widget_instance(), @@ -2869,7 +2870,7 @@ impl DocumentMessageHandler { .disabled(!has_selection) .widget_instance(), ]; - let layers_panel_bottom_bar = WidgetLayout::new(vec![LayoutGroup::Row { widgets }]); + let layers_panel_bottom_bar = WidgetLayout(vec![LayoutGroup::Row { widgets }]); responses.add(LayoutMessage::SendLayout { layout: Layout::WidgetLayout(layers_panel_bottom_bar), diff --git a/editor/src/messages/portfolio/document/node_graph/node_graph_message_handler.rs b/editor/src/messages/portfolio/document/node_graph/node_graph_message_handler.rs index bfb3c5bf1..ddd7a348e 100644 --- a/editor/src/messages/portfolio/document/node_graph/node_graph_message_handler.rs +++ b/editor/src/messages/portfolio/document/node_graph/node_graph_message_handler.rs @@ -2069,7 +2069,7 @@ impl NodeGraphMessageHandler { /// Send the cached layout to the frontend for the control bar at the top of the node panel fn send_node_bar_layout(&self, responses: &mut VecDeque) { responses.add(LayoutMessage::SendLayout { - layout: Layout::WidgetLayout(WidgetLayout::new(self.widgets.to_vec())), + layout: Layout::WidgetLayout(WidgetLayout(self.widgets.to_vec())), layout_target: LayoutTarget::NodeGraphControlBar, }); } @@ -2145,7 +2145,7 @@ impl NodeGraphMessageHandler { } }) .widget_instance(); - vec![LayoutGroup::Row { widgets: vec![node_chooser] }] + WidgetLayout(vec![LayoutGroup::Row { widgets: vec![node_chooser] }]) }) .widget_instance(), // @@ -2443,7 +2443,7 @@ impl NodeGraphMessageHandler { .into() }) .widget_instance(); - vec![LayoutGroup::Row { widgets: vec![node_chooser] }] + WidgetLayout(vec![LayoutGroup::Row { widgets: vec![node_chooser] }]) }) .widget_instance(), Separator::new(SeparatorType::Related).widget_instance(), diff --git a/editor/src/messages/portfolio/document/node_graph/node_properties.rs b/editor/src/messages/portfolio/document/node_graph/node_properties.rs index b0a5ebeb7..cab0f0dfb 100644 --- a/editor/src/messages/portfolio/document/node_graph/node_properties.rs +++ b/editor/src/messages/portfolio/document/node_graph/node_properties.rs @@ -1699,7 +1699,7 @@ pub(crate) fn generate_node_properties(node_id: NodeId, context: &mut NodeProper visible, pinned, id: node_id.0, - layout, + layout: WidgetLayout(layout), } } diff --git a/editor/src/messages/portfolio/document/properties_panel/properties_panel_message_handler.rs b/editor/src/messages/portfolio/document/properties_panel/properties_panel_message_handler.rs index 6e7aea73a..fad48342b 100644 --- a/editor/src/messages/portfolio/document/properties_panel/properties_panel_message_handler.rs +++ b/editor/src/messages/portfolio/document/properties_panel/properties_panel_message_handler.rs @@ -35,7 +35,7 @@ impl MessageHandler> f match message { PropertiesPanelMessage::Clear => { responses.add(LayoutMessage::SendLayout { - layout: Layout::WidgetLayout(WidgetLayout::new(vec![])), + layout: Layout::WidgetLayout(WidgetLayout(vec![])), layout_target: LayoutTarget::PropertiesPanel, }); } @@ -56,7 +56,7 @@ impl MessageHandler> f let properties_sections = NodeGraphMessageHandler::collate_properties(&mut node_properties_context); node_properties_context.responses.add(LayoutMessage::SendLayout { - layout: Layout::WidgetLayout(WidgetLayout::new(properties_sections)), + layout: Layout::WidgetLayout(WidgetLayout(properties_sections)), layout_target: LayoutTarget::PropertiesPanel, }); } diff --git a/editor/src/messages/portfolio/menu_bar/menu_bar_message_handler.rs b/editor/src/messages/portfolio/menu_bar/menu_bar_message_handler.rs index d69b44edc..336155d4e 100644 --- a/editor/src/messages/portfolio/menu_bar/menu_bar_message_handler.rs +++ b/editor/src/messages/portfolio/menu_bar/menu_bar_message_handler.rs @@ -736,6 +736,6 @@ impl LayoutHolder for MenuBarMessageHandler { .widget_instance(), ]; - Layout::WidgetLayout(WidgetLayout::new(vec![LayoutGroup::Row { widgets: menu_bar_buttons }])) + Layout::WidgetLayout(WidgetLayout(vec![LayoutGroup::Row { widgets: menu_bar_buttons }])) } } diff --git a/editor/src/messages/portfolio/portfolio_message_handler.rs b/editor/src/messages/portfolio/portfolio_message_handler.rs index e57b4e845..6cb246a5c 100644 --- a/editor/src/messages/portfolio/portfolio_message_handler.rs +++ b/editor/src/messages/portfolio/portfolio_message_handler.rs @@ -924,7 +924,7 @@ impl MessageHandler> for Portfolio layout_target: LayoutTarget::WelcomeScreenButtons, }); responses.add(LayoutMessage::SendLayout { - layout: Layout::WidgetLayout(WidgetLayout::new(vec![table])), + layout: Layout::WidgetLayout(WidgetLayout(vec![table])), layout_target: LayoutTarget::WelcomeScreenButtons, }); } diff --git a/editor/src/messages/tool/tool_messages/brush_tool.rs b/editor/src/messages/tool/tool_messages/brush_tool.rs index 636b7eb4a..72de4c638 100644 --- a/editor/src/messages/tool/tool_messages/brush_tool.rs +++ b/editor/src/messages/tool/tool_messages/brush_tool.rs @@ -220,7 +220,7 @@ impl LayoutHolder for BrushTool { .widget_instance(), ); - Layout::WidgetLayout(WidgetLayout::new(vec![LayoutGroup::Row { widgets }])) + Layout::WidgetLayout(WidgetLayout(vec![LayoutGroup::Row { widgets }])) } } diff --git a/editor/src/messages/tool/tool_messages/freehand_tool.rs b/editor/src/messages/tool/tool_messages/freehand_tool.rs index 5e9cbf912..5fc79675d 100644 --- a/editor/src/messages/tool/tool_messages/freehand_tool.rs +++ b/editor/src/messages/tool/tool_messages/freehand_tool.rs @@ -151,7 +151,7 @@ impl LayoutHolder for FreehandTool { widgets.push(Separator::new(SeparatorType::Unrelated).widget_instance()); widgets.push(create_weight_widget(self.options.line_weight)); - Layout::WidgetLayout(WidgetLayout::new(vec![LayoutGroup::Row { widgets }])) + Layout::WidgetLayout(WidgetLayout(vec![LayoutGroup::Row { widgets }])) } } diff --git a/editor/src/messages/tool/tool_messages/gradient_tool.rs b/editor/src/messages/tool/tool_messages/gradient_tool.rs index 51efb5329..2a05bc79d 100644 --- a/editor/src/messages/tool/tool_messages/gradient_tool.rs +++ b/editor/src/messages/tool/tool_messages/gradient_tool.rs @@ -107,7 +107,7 @@ impl LayoutHolder for GradientTool { .selected_index(Some((self.selected_gradient().unwrap_or(self.options.gradient_type) == GradientType::Radial) as u32)) .widget_instance(); - Layout::WidgetLayout(WidgetLayout::new(vec![LayoutGroup::Row { widgets: vec![gradient_type] }])) + Layout::WidgetLayout(WidgetLayout(vec![LayoutGroup::Row { widgets: vec![gradient_type] }])) } } diff --git a/editor/src/messages/tool/tool_messages/path_tool.rs b/editor/src/messages/tool/tool_messages/path_tool.rs index 81060b342..fdde7798a 100644 --- a/editor/src/messages/tool/tool_messages/path_tool.rs +++ b/editor/src/messages/tool/tool_messages/path_tool.rs @@ -342,7 +342,7 @@ impl LayoutHolder for PathTool { let _pin_pivot = pin_pivot_widget(self.tool_data.pivot_gizmo.pin_active(), false, PivotToolSource::Path); - Layout::WidgetLayout(WidgetLayout::new(vec![LayoutGroup::Row { + Layout::WidgetLayout(WidgetLayout(vec![LayoutGroup::Row { widgets: vec![ x_location, related_seperator.clone(), diff --git a/editor/src/messages/tool/tool_messages/pen_tool.rs b/editor/src/messages/tool/tool_messages/pen_tool.rs index 7af9c5787..7a5b87a89 100644 --- a/editor/src/messages/tool/tool_messages/pen_tool.rs +++ b/editor/src/messages/tool/tool_messages/pen_tool.rs @@ -238,7 +238,7 @@ impl LayoutHolder for PenTool { .widget_instance(), ); - Layout::WidgetLayout(WidgetLayout::new(vec![LayoutGroup::Row { widgets }])) + Layout::WidgetLayout(WidgetLayout(vec![LayoutGroup::Row { widgets }])) } } diff --git a/editor/src/messages/tool/tool_messages/select_tool.rs b/editor/src/messages/tool/tool_messages/select_tool.rs index b43cfc750..e2c344cdd 100644 --- a/editor/src/messages/tool/tool_messages/select_tool.rs +++ b/editor/src/messages/tool/tool_messages/select_tool.rs @@ -252,14 +252,14 @@ impl LayoutHolder for SelectTool { widgets.extend(self.alignment_widgets(disabled)); // widgets.push( // PopoverButton::new() - // .popover_layout(vec![ + // .popover_layout(WidgetLayout(vec![ // LayoutGroup::Row { // widgets: vec![TextLabel::new("Align").bold(true).widget_instance()], // }, // LayoutGroup::Row { // widgets: vec![TextLabel::new("Coming soon").widget_instance()], // }, - // ]) + // ])) // .disabled(disabled) // .widget_instance(), // ); @@ -277,7 +277,7 @@ impl LayoutHolder for SelectTool { widgets.push(Separator::new(SeparatorType::Unrelated).widget_instance()); widgets.extend(self.boolean_widgets(self.tool_data.selected_layers_count)); - Layout::WidgetLayout(WidgetLayout::new(vec![LayoutGroup::Row { widgets }])) + Layout::WidgetLayout(WidgetLayout(vec![LayoutGroup::Row { widgets }])) } } diff --git a/editor/src/messages/tool/tool_messages/shape_tool.rs b/editor/src/messages/tool/tool_messages/shape_tool.rs index a1c485748..2abe9f383 100644 --- a/editor/src/messages/tool/tool_messages/shape_tool.rs +++ b/editor/src/messages/tool/tool_messages/shape_tool.rs @@ -335,7 +335,7 @@ impl LayoutHolder for ShapeTool { widgets.push(Separator::new(SeparatorType::Unrelated).widget_instance()); widgets.push(create_weight_widget(self.options.line_weight)); - Layout::WidgetLayout(WidgetLayout::new(vec![LayoutGroup::Row { widgets }])) + Layout::WidgetLayout(WidgetLayout(vec![LayoutGroup::Row { widgets }])) } } diff --git a/editor/src/messages/tool/tool_messages/spline_tool.rs b/editor/src/messages/tool/tool_messages/spline_tool.rs index 8bedaa2d6..ae125b30f 100644 --- a/editor/src/messages/tool/tool_messages/spline_tool.rs +++ b/editor/src/messages/tool/tool_messages/spline_tool.rs @@ -158,7 +158,7 @@ impl LayoutHolder for SplineTool { widgets.push(Separator::new(SeparatorType::Unrelated).widget_instance()); widgets.push(create_weight_widget(self.options.line_weight)); - Layout::WidgetLayout(WidgetLayout::new(vec![LayoutGroup::Row { widgets }])) + Layout::WidgetLayout(WidgetLayout(vec![LayoutGroup::Row { widgets }])) } } diff --git a/editor/src/messages/tool/tool_messages/text_tool.rs b/editor/src/messages/tool/tool_messages/text_tool.rs index 22e5862de..782a60c17 100644 --- a/editor/src/messages/tool/tool_messages/text_tool.rs +++ b/editor/src/messages/tool/tool_messages/text_tool.rs @@ -203,7 +203,7 @@ impl LayoutHolder for TextTool { }, )); - Layout::WidgetLayout(WidgetLayout::new(vec![LayoutGroup::Row { widgets }])) + Layout::WidgetLayout(WidgetLayout(vec![LayoutGroup::Row { widgets }])) } } diff --git a/editor/src/messages/tool/utility_types.rs b/editor/src/messages/tool/utility_types.rs index 2dc9753a3..8ccf82484 100644 --- a/editor/src/messages/tool/utility_types.rs +++ b/editor/src/messages/tool/utility_types.rs @@ -117,7 +117,7 @@ pub struct DocumentToolData { impl DocumentToolData { pub fn update_working_colors(&self, responses: &mut VecDeque) { - let layout = WidgetLayout::new(vec![ + let layout = WidgetLayout(vec![ LayoutGroup::Row { widgets: vec![WorkingColorsInput::new(self.primary_color.to_gamma_srgb(), self.secondary_color.to_gamma_srgb()).widget_instance()], }, @@ -290,9 +290,7 @@ impl LayoutHolder for ToolData { .skip(1) .collect(); - Layout::WidgetLayout(WidgetLayout { - layout: vec![LayoutGroup::Row { widgets: tool_groups_layout }], - }) + Layout::WidgetLayout(WidgetLayout(vec![LayoutGroup::Row { widgets: tool_groups_layout }])) } } @@ -547,7 +545,7 @@ impl HintData { } } - Layout::WidgetLayout(WidgetLayout::new(vec![LayoutGroup::Row { widgets }])) + Layout::WidgetLayout(WidgetLayout(vec![LayoutGroup::Row { widgets }])) } pub fn send_layout(&self, responses: &mut VecDeque) { @@ -559,7 +557,7 @@ impl HintData { pub fn clear_layout(responses: &mut VecDeque) { responses.add(LayoutMessage::SendLayout { - layout: Layout::WidgetLayout(WidgetLayout::new(vec![])), + layout: Layout::WidgetLayout(WidgetLayout(vec![])), layout_target: LayoutTarget::StatusBarHints, }); } diff --git a/frontend/src/components/floating-menus/Dialog.svelte b/frontend/src/components/floating-menus/Dialog.svelte index 928d86993..ce06b2262 100644 --- a/frontend/src/components/floating-menus/Dialog.svelte +++ b/frontend/src/components/floating-menus/Dialog.svelte @@ -34,8 +34,8 @@ - {#if $dialog.column1.layout.length > 0} - + {#if $dialog.column1.length > 0} + {/if} {#if $dialog.panicDetails}
@@ -57,15 +57,15 @@
{/if}
- {#if $dialog.column2.layout.length > 0} + {#if $dialog.column2.length > 0} - + {/if}
- {#if $dialog.buttons.layout.length > 0} - + {#if $dialog.buttons.length > 0} + {/if} {#if $dialog.panicDetails} navigator.clipboard.writeText($dialog.panicDetails)} /> diff --git a/frontend/src/components/panels/Data.svelte b/frontend/src/components/panels/Data.svelte index f3b111791..6d85da3f8 100644 --- a/frontend/src/components/panels/Data.svelte +++ b/frontend/src/components/panels/Data.svelte @@ -2,14 +2,14 @@ import { getContext, onMount, onDestroy } from "svelte"; import type { Editor } from "@graphite/editor"; - import { defaultWidgetLayout, patchWidgetLayout, UpdateDataPanelLayout } from "@graphite/messages"; + import { patchWidgetLayout, UpdateDataPanelLayout, type LayoutGroup } from "@graphite/messages"; import LayoutCol from "@graphite/components/layout/LayoutCol.svelte"; import WidgetLayout from "@graphite/components/widgets/WidgetLayout.svelte"; const editor = getContext("editor"); - let dataPanelLayout = defaultWidgetLayout(); + let dataPanelLayout: LayoutGroup[] = []; onMount(() => { editor.subscriptions.subscribeJsMessage(UpdateDataPanelLayout, (updateDataPanelLayout) => { @@ -25,7 +25,7 @@ - + diff --git a/frontend/src/components/panels/Document.svelte b/frontend/src/components/panels/Document.svelte index b9144496a..dd6351da8 100644 --- a/frontend/src/components/panels/Document.svelte +++ b/frontend/src/components/panels/Document.svelte @@ -126,7 +126,7 @@ totalToolRowsFor2Columns, totalToolRowsFor3Columns, }; - })($document.toolShelfLayout.layout[0]); + })($document.toolShelfLayout[0]); function dropFile(e: DragEvent) { const { dataTransfer } = e; @@ -506,12 +506,12 @@ e.preventDefault()} on:drop={dropFile}> {#if !$document.graphViewOverlayOpen} - - + + - + {:else} - + {/if} {#if !$document.graphViewOverlayOpen} - + {:else} {/if} - + diff --git a/frontend/src/components/panels/Layers.svelte b/frontend/src/components/panels/Layers.svelte index f3c25c666..04165215d 100644 --- a/frontend/src/components/panels/Layers.svelte +++ b/frontend/src/components/panels/Layers.svelte @@ -4,7 +4,6 @@ import { shortcutAltClick } from "@graphite/../wasm/pkg/graphite_wasm"; import type { Editor } from "@graphite/editor"; import { - defaultWidgetLayout, patchWidgetLayout, UpdateDocumentLayerDetails, UpdateDocumentLayerStructureJs, @@ -12,7 +11,7 @@ UpdateLayersPanelControlBarRightLayout, UpdateLayersPanelBottomBarLayout, } from "@graphite/messages"; - import type { ActionShortcut, DataBuffer, LayerPanelEntry } from "@graphite/messages"; + import type { ActionShortcut, DataBuffer, LayerPanelEntry, LayoutGroup } from "@graphite/messages"; import type { NodeGraphState } from "@graphite/state-providers/node-graph"; import { operatingSystem } from "@graphite/utility-functions/platform"; import { extractPixelData } from "@graphite/utility-functions/rasterization"; @@ -70,9 +69,9 @@ let layerToClipAltKeyPressed = false; // Layouts - let layersPanelControlBarLeftLayout = defaultWidgetLayout(); - let layersPanelControlBarRightLayout = defaultWidgetLayout(); - let layersPanelBottomBarLayout = defaultWidgetLayout(); + let layersPanelControlBarLeftLayout: LayoutGroup[] = []; + let layersPanelControlBarRightLayout: LayoutGroup[] = []; + let layersPanelBottomBarLayout: LayoutGroup[] = []; const altClickKeys: ActionShortcut = shortcutAltClick(); @@ -582,11 +581,11 @@ (dragInPanel = false)}> - - {#if layersPanelControlBarLeftLayout?.layout?.length > 0 && layersPanelControlBarRightLayout?.layout?.length > 0} + + {#if layersPanelControlBarLeftLayout?.length > 0 && layersPanelControlBarRightLayout?.length > 0} {/if} - + - + diff --git a/frontend/src/components/panels/Properties.svelte b/frontend/src/components/panels/Properties.svelte index 889ccba9b..234e081fd 100644 --- a/frontend/src/components/panels/Properties.svelte +++ b/frontend/src/components/panels/Properties.svelte @@ -2,14 +2,14 @@ import { getContext, onMount, onDestroy } from "svelte"; import type { Editor } from "@graphite/editor"; - import { defaultWidgetLayout, patchWidgetLayout, UpdatePropertiesPanelLayout } from "@graphite/messages"; + import { patchWidgetLayout, UpdatePropertiesPanelLayout, type LayoutGroup } from "@graphite/messages"; import LayoutCol from "@graphite/components/layout/LayoutCol.svelte"; import WidgetLayout from "@graphite/components/widgets/WidgetLayout.svelte"; const editor = getContext("editor"); - let propertiesPanelLayout = defaultWidgetLayout(); + let propertiesPanelLayout: LayoutGroup[] = []; onMount(() => { editor.subscriptions.subscribeJsMessage(UpdatePropertiesPanelLayout, (updatePropertiesPanelLayout) => { @@ -25,7 +25,7 @@ - + diff --git a/frontend/src/components/panels/Welcome.svelte b/frontend/src/components/panels/Welcome.svelte index 10b2e1ade..9e9ab45ba 100644 --- a/frontend/src/components/panels/Welcome.svelte +++ b/frontend/src/components/panels/Welcome.svelte @@ -2,7 +2,8 @@ import { getContext, onMount, onDestroy } from "svelte"; import type { Editor } from "@graphite/editor"; - import { defaultWidgetLayout, patchWidgetLayout, UpdateWelcomeScreenButtonsLayout } from "@graphite/messages"; + import type { LayoutGroup } from "@graphite/messages"; + import { patchWidgetLayout, UpdateWelcomeScreenButtonsLayout } from "@graphite/messages"; import { extractPixelData } from "@graphite/utility-functions/rasterization"; import LayoutCol from "@graphite/components/layout/LayoutCol.svelte"; @@ -13,7 +14,7 @@ const editor = getContext("editor"); - let welcomePanelButtonsLayout = defaultWidgetLayout(); + let welcomePanelButtonsLayout: LayoutGroup[] = []; onMount(() => { editor.subscriptions.subscribeJsMessage(UpdateWelcomeScreenButtonsLayout, (updateWelcomeScreenButtonsLayout) => { @@ -68,7 +69,7 @@ - + diff --git a/frontend/src/components/widgets/WidgetLayout.svelte b/frontend/src/components/widgets/WidgetLayout.svelte index afa849a11..15c637023 100644 --- a/frontend/src/components/widgets/WidgetLayout.svelte +++ b/frontend/src/components/widgets/WidgetLayout.svelte @@ -1,26 +1,24 @@ -{#each layout.layout as layoutGroup} +{#each layout as layoutGroup} {#if isWidgetSpanRow(layoutGroup) || isWidgetSpanColumn(layoutGroup)} - + {:else if isWidgetSection(layoutGroup)} - + {:else if isWidgetTable(layoutGroup)} - - {:else} - Error: The widget layout that belongs here has an invalid layout group type + {/if} {/each} diff --git a/frontend/src/components/widgets/WidgetSection.svelte b/frontend/src/components/widgets/WidgetSection.svelte index dd9ccc883..c9964c74a 100644 --- a/frontend/src/components/widgets/WidgetSection.svelte +++ b/frontend/src/components/widgets/WidgetSection.svelte @@ -2,7 +2,7 @@ import { getContext } from "svelte"; import type { Editor } from "@graphite/editor"; - import { isWidgetSpanRow, isWidgetSpanColumn, isWidgetSection, type WidgetSection as WidgetSectionFromJsMessages } from "@graphite/messages"; + import { isWidgetSpanRow, isWidgetSection, type WidgetSection as WidgetSectionFromJsMessages, type LayoutTarget } from "@graphite/messages"; import LayoutCol from "@graphite/components/layout/LayoutCol.svelte"; import IconButton from "@graphite/components/widgets/buttons/IconButton.svelte"; @@ -10,8 +10,7 @@ import WidgetSpan from "@graphite/components/widgets/WidgetSpan.svelte"; export let widgetData: WidgetSectionFromJsMessages; - // eslint-disable-next-line @typescript-eslint/no-explicit-any - export let layoutTarget: any; // TODO: Give type + export let layoutTarget: LayoutTarget; let className = ""; export { className as class }; @@ -64,12 +63,8 @@ {#each widgetData.layout as layoutGroup} {#if isWidgetSpanRow(layoutGroup)} - {:else if isWidgetSpanColumn(layoutGroup)} - Error: The WidgetSpan used here should be a row not a column {:else if isWidgetSection(layoutGroup)} - {:else} - Error: The widget that belongs here has an invalid layout group type {/if} {/each} diff --git a/frontend/src/components/widgets/WidgetSpan.svelte b/frontend/src/components/widgets/WidgetSpan.svelte index bb024c9b3..3b6af1a9d 100644 --- a/frontend/src/components/widgets/WidgetSpan.svelte +++ b/frontend/src/components/widgets/WidgetSpan.svelte @@ -2,7 +2,7 @@ import { getContext } from "svelte"; import type { Editor } from "@graphite/editor"; - import type { Widget, WidgetSpanColumn, WidgetSpanRow } from "@graphite/messages"; + import type { LayoutTarget, Widget, WidgetSpanColumn, WidgetSpanRow } from "@graphite/messages"; import { narrowWidgetProps, isWidgetSpanColumn, isWidgetSpanRow } from "@graphite/messages"; import { debouncer } from "@graphite/utility-functions/debounce"; @@ -34,8 +34,7 @@ const editor = getContext("editor"); export let widgetData: WidgetSpanRow | WidgetSpanColumn; - // eslint-disable-next-line @typescript-eslint/no-explicit-any - export let layoutTarget: any; + export let layoutTarget: LayoutTarget; let className = ""; export { className as class }; @@ -162,7 +161,7 @@ {@const popoverButton = narrowWidgetProps(component.props, "PopoverButton")} {#if popoverButton} - + {/if} {@const radioInput = narrowWidgetProps(component.props, "RadioInput")} diff --git a/frontend/src/components/widgets/WidgetTable.svelte b/frontend/src/components/widgets/WidgetTable.svelte index b9d5c84d0..401cf9bf5 100644 --- a/frontend/src/components/widgets/WidgetTable.svelte +++ b/frontend/src/components/widgets/WidgetTable.svelte @@ -1,11 +1,10 @@ - +