mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-10-01 13:38:11 +08:00
Refactor the WidgetLayout struct to remove SubLayout and avoid sending LayoutTarget to frontend
This commit is contained in:
@@ -131,7 +131,7 @@ impl DataPanelMessageHandler {
|
||||
}
|
||||
|
||||
responses.add(LayoutMessage::SendLayout {
|
||||
layout: Layout::WidgetLayout(WidgetLayout { layout }),
|
||||
layout: Layout::WidgetLayout(WidgetLayout(layout)),
|
||||
layout_target: LayoutTarget::DataPanel,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -2175,7 +2175,7 @@ impl DocumentMessageHandler {
|
||||
pub fn update_document_widgets(&self, responses: &mut VecDeque<Message>, 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),
|
||||
|
||||
@@ -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<Message>) {
|
||||
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(),
|
||||
|
||||
@@ -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),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -35,7 +35,7 @@ impl MessageHandler<PropertiesPanelMessage, PropertiesPanelMessageContext<'_>> 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<PropertiesPanelMessage, PropertiesPanelMessageContext<'_>> 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,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -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 }]))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -924,7 +924,7 @@ impl MessageHandler<PortfolioMessage, PortfolioMessageContext<'_>> 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,
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user