mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-23 14:08:12 +08:00
Implement dragging to reorder Properties panel node sections (#4299)
* Implement dragging to reorder Properties panel node sections * Code review
This commit is contained in:
@@ -370,14 +370,23 @@ pub struct WidgetTable {
|
||||
pub unstyled: bool,
|
||||
}
|
||||
|
||||
/// A collapsible Properties panel section for a single node: a header with its name and pin, delete, and visibility controls, above its input parameter widgets.
|
||||
#[cfg_attr(feature = "wasm", derive(tsify::Tsify), tsify(large_number_types_as_bigints))]
|
||||
#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
|
||||
pub struct WidgetSection {
|
||||
/// The node's name shown in the section header: its given alias with the implementation name in parentheses, or just the implementation name.
|
||||
pub name: String,
|
||||
/// The node definition's description, shown as the header's tooltip (empty when it has none).
|
||||
pub description: String,
|
||||
/// Whether the node is visible rather than hidden (shown as the eye icon).
|
||||
pub visible: bool,
|
||||
/// Whether the node is pinned, keeping its section shown in the Properties panel when nothing is selected (shown as the pin icon).
|
||||
pub pinned: bool,
|
||||
/// Whether this section can be dragged to reorder it within its layer's chain of nodes (true for a layer chain's nodes, but not its terminal layer node).
|
||||
pub draggable: bool,
|
||||
/// The ID of the node whose properties this section displays.
|
||||
pub id: u64,
|
||||
/// The node's properties content, rendered as the section's body when expanded.
|
||||
pub layout: Layout,
|
||||
}
|
||||
|
||||
@@ -411,6 +420,7 @@ impl LayoutGroup {
|
||||
description: description.into(),
|
||||
visible,
|
||||
pinned,
|
||||
draggable: false,
|
||||
id,
|
||||
layout,
|
||||
})
|
||||
@@ -507,6 +517,7 @@ impl Diffable for LayoutGroup {
|
||||
description: current_description,
|
||||
visible: current_visible,
|
||||
pinned: current_pinned,
|
||||
draggable: current_draggable,
|
||||
id: current_id,
|
||||
layout: current_layout,
|
||||
}),
|
||||
@@ -515,6 +526,7 @@ impl Diffable for LayoutGroup {
|
||||
description: new_description,
|
||||
visible: new_visible,
|
||||
pinned: new_pinned,
|
||||
draggable: new_draggable,
|
||||
id: new_id,
|
||||
layout: new_layout,
|
||||
}),
|
||||
@@ -526,6 +538,7 @@ impl Diffable for LayoutGroup {
|
||||
|| *current_description != new_description
|
||||
|| *current_visible != new_visible
|
||||
|| *current_pinned != new_pinned
|
||||
|| *current_draggable != new_draggable
|
||||
|| *current_id != new_id
|
||||
{
|
||||
// Update self to reflect new changes
|
||||
@@ -533,6 +546,7 @@ impl Diffable for LayoutGroup {
|
||||
current_description.clone_from(&new_description);
|
||||
*current_visible = new_visible;
|
||||
*current_pinned = new_pinned;
|
||||
*current_draggable = new_draggable;
|
||||
*current_id = new_id;
|
||||
current_layout.clone_from(&new_layout);
|
||||
|
||||
@@ -542,6 +556,7 @@ impl Diffable for LayoutGroup {
|
||||
description: new_description,
|
||||
visible: new_visible,
|
||||
pinned: new_pinned,
|
||||
draggable: new_draggable,
|
||||
id: new_id,
|
||||
layout: new_layout,
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user