mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-12-01 07:24:56 -10:00
Restyle Inspector panel sections and add in links between the selected layer's neighbors (#4757)
Restyle Inspector sections and link the selected layer's neighbors
This commit is contained in:
1 parent
b837b39944
commit
49711cd375
7 files changed
+349
-109
No files matched your search
@@ -423,9 +423,15 @@ pub struct NodeSection {
|
||||
/// For a section in the chain feeding another section's input, the wire drawn up to the section above, which its node's output feeds.
|
||||
#[serde(rename = "outputWire")]
|
||||
pub output_wire: Option<SectionWire>,
|
||||
/// Whether this section only refers to its node with a row like the Data panel's, in place of its header and parameters (for the layer whose stack feeds the bottom of a chain).
|
||||
/// Whether this section only refers to its node with a row like the Data panel's, in place of its header and parameters (for a layer feeding a chain, or feeding or fed by the selected layer).
|
||||
#[serde(rename = "nodeReference")]
|
||||
pub node_reference: bool,
|
||||
/// For a section referring to layers that take the wire from the section below into their content, rather than from their bottom, that wire turning in from the left past its indent.
|
||||
#[serde(rename = "contentWire")]
|
||||
pub content_wire: Option<SectionWire>,
|
||||
/// Whether the content wire also continues up past its turn, to the section above that takes it from the bottom.
|
||||
#[serde(rename = "contentWireContinues")]
|
||||
pub content_wire_continues: bool,
|
||||
/// Whether this section is expanded to show its contents, as opposed to being collapsed down to just its header.
|
||||
pub expanded: bool,
|
||||
/// The ID of the node whose Inspector section this is.
|
||||
@@ -477,6 +483,8 @@ impl LayoutGroup {
|
||||
chain_wire: None,
|
||||
output_wire: None,
|
||||
node_reference: false,
|
||||
content_wire: None,
|
||||
content_wire_continues: false,
|
||||
expanded,
|
||||
id,
|
||||
layout,
|
||||
@@ -582,6 +590,8 @@ impl Diffable for LayoutGroup {
|
||||
chain_wire: current_chain_wire,
|
||||
output_wire: current_output_wire,
|
||||
node_reference: current_node_reference,
|
||||
content_wire: current_content_wire,
|
||||
content_wire_continues: current_content_wire_continues,
|
||||
expanded: current_expanded,
|
||||
id: current_id,
|
||||
layout: current_layout,
|
||||
@@ -596,6 +606,8 @@ impl Diffable for LayoutGroup {
|
||||
chain_wire: new_chain_wire,
|
||||
output_wire: new_output_wire,
|
||||
node_reference: new_node_reference,
|
||||
content_wire: new_content_wire,
|
||||
content_wire_continues: new_content_wire_continues,
|
||||
expanded: new_expanded,
|
||||
id: new_id,
|
||||
layout: new_layout,
|
||||
@@ -613,6 +625,8 @@ impl Diffable for LayoutGroup {
|
||||
|| *current_chain_wire != new_chain_wire
|
||||
|| *current_output_wire != new_output_wire
|
||||
|| *current_node_reference != new_node_reference
|
||||
|| *current_content_wire != new_content_wire
|
||||
|| *current_content_wire_continues != new_content_wire_continues
|
||||
|| *current_expanded != new_expanded
|
||||
|| *current_id != new_id
|
||||
{
|
||||
@@ -626,6 +640,8 @@ impl Diffable for LayoutGroup {
|
||||
*current_chain_wire = new_chain_wire;
|
||||
*current_output_wire = new_output_wire;
|
||||
*current_node_reference = new_node_reference;
|
||||
*current_content_wire = new_content_wire;
|
||||
*current_content_wire_continues = new_content_wire_continues;
|
||||
*current_expanded = new_expanded;
|
||||
*current_id = new_id;
|
||||
current_layout.clone_from(&new_layout);
|
||||
@@ -641,6 +657,8 @@ impl Diffable for LayoutGroup {
|
||||
chain_wire: new_chain_wire,
|
||||
output_wire: new_output_wire,
|
||||
node_reference: new_node_reference,
|
||||
content_wire: new_content_wire,
|
||||
content_wire_continues: new_content_wire_continues,
|
||||
expanded: new_expanded,
|
||||
id: new_id,
|
||||
layout: new_layout,
|
||||
|
||||
@@ -1044,7 +1044,7 @@ pub fn node_reference_button(
|
||||
network_path: &[NodeId],
|
||||
selection_network_path: &[NodeId],
|
||||
select: impl Fn() -> Message + Send + Sync + 'static,
|
||||
) -> WidgetInstance {
|
||||
) -> TextButton {
|
||||
let is_layer = network_interface.is_layer(&node_id, network_path);
|
||||
let icon = network_interface.node_icon(&node_id, network_path);
|
||||
let name = network_interface.display_name(&node_id, network_path);
|
||||
@@ -1063,7 +1063,6 @@ pub fn node_reference_button(
|
||||
(true, false, _) => "",
|
||||
})
|
||||
.on_update(move |_| select())
|
||||
.widget_instance()
|
||||
}
|
||||
|
||||
impl TableItemLayout for NodeId {
|
||||
@@ -1097,7 +1096,7 @@ impl TableItemLayout for NodeId {
|
||||
NodeGraphMessage::SelectedNodesSet { nodes: vec![node_id] }.into(),
|
||||
]),
|
||||
};
|
||||
vec![node_reference_button(node_id, network_interface, &network_path, data.selection_network_path, select)]
|
||||
vec![node_reference_button(node_id, network_interface, &network_path, data.selection_network_path, select).widget_instance()]
|
||||
}
|
||||
fn value_page(&self, data: &mut LayoutData) -> Vec<LayoutGroup> {
|
||||
vec![LayoutGroup::row(self.value_widgets(PathStep::Element(0), data))]
|
||||
|
||||
@@ -3076,7 +3076,73 @@ impl NodeGraphMessageHandler {
|
||||
}
|
||||
}
|
||||
|
||||
vec![layer_section]
|
||||
// The layers this one's output feeds, which a stack used in several places can be many of, and the graph's output none of.
|
||||
// Followed through any nodes between, each layer takes it either from its bottom (as the sibling above in its stack) or into its content (as its parent).
|
||||
let network_path = context.selection_network_path;
|
||||
let outward_connectors = |node_id: NodeId| {
|
||||
context
|
||||
.network_interface
|
||||
.with_outward_wires(network_path, |outward_wires| outward_wires.get(&OutputConnector::primary_output(node_id)).cloned())
|
||||
.flatten()
|
||||
.unwrap_or_default()
|
||||
};
|
||||
let (mut siblings, mut parents) = (Vec::new(), Vec::new());
|
||||
let mut pending_connectors = outward_connectors(layer);
|
||||
let mut visited_nodes = HashSet::new();
|
||||
while let Some(connector) = pending_connectors.pop() {
|
||||
let Some(node_id) = connector.node_id() else { continue };
|
||||
|
||||
if context.network_interface.is_layer(&node_id, network_path) {
|
||||
let receivers = if connector.input_index() == 0 { &mut siblings } else { &mut parents };
|
||||
receivers.push(node_id);
|
||||
continue;
|
||||
}
|
||||
|
||||
// A node passes it on only when taking it as its primary input, rather than as a parameter
|
||||
if connector.input_index() == 0 && visited_nodes.insert(node_id) {
|
||||
pending_connectors.extend(outward_connectors(node_id));
|
||||
}
|
||||
}
|
||||
|
||||
// Sorted for a stable button order, since outward wires are unordered
|
||||
siblings.sort_unstable();
|
||||
siblings.dedup();
|
||||
parents.sort_unstable();
|
||||
parents.dedup();
|
||||
|
||||
// The layer feeding this one from below in its stack, unless this is the bottom
|
||||
let layer_below = node_inspector::input_chain(layer, 0, context.network_interface, network_path).and_then(|(_, stack_layer)| stack_layer);
|
||||
|
||||
// Each is only referred to by a button, wired to the layer's section. Parents sit just above, the wire turning into their content,
|
||||
// and siblings above them, the wire continuing up past that turn into their bottom.
|
||||
let mut sections = Vec::new();
|
||||
|
||||
if let Some(siblings_section) = node_inspector::layer_references_section(&siblings, "Select Sibling Layer", context) {
|
||||
sections.push(siblings_section);
|
||||
}
|
||||
if let Some(mut parents_section) = node_inspector::layer_references_section(&parents, "Select Parent Layer", context) {
|
||||
if let LayoutGroup::NodeSection(section) = &mut parents_section {
|
||||
section.content_wire = Some(node_inspector::output_section_wire(layer, context));
|
||||
section.content_wire_continues = !siblings.is_empty();
|
||||
}
|
||||
sections.push(parents_section);
|
||||
}
|
||||
if !sections.is_empty()
|
||||
&& let LayoutGroup::NodeSection(section) = &mut layer_section
|
||||
{
|
||||
section.output_wire = Some(node_inspector::output_section_wire(layer, context));
|
||||
}
|
||||
sections.push(layer_section);
|
||||
if let Some(layer_below) = layer_below
|
||||
&& let Some(mut below_section) = node_inspector::layer_references_section(&[layer_below], "Select Sibling Layer", context)
|
||||
{
|
||||
if let LayoutGroup::NodeSection(section) = &mut below_section {
|
||||
section.output_wire = Some(node_inspector::output_section_wire(layer_below, context));
|
||||
}
|
||||
sections.push(below_section);
|
||||
}
|
||||
|
||||
sections
|
||||
}
|
||||
// If multiple layers and/or nodes are selected, show nothing
|
||||
_ => Vec::new(),
|
||||
|
||||
@@ -3086,15 +3086,6 @@ pub(crate) fn rectangle_inspector(node_id: NodeId, context: &mut NodeInspectorCo
|
||||
]
|
||||
}
|
||||
|
||||
pub(crate) fn node_no_inspector_content(node_id: NodeId, context: &mut NodeInspectorContext) -> Vec<LayoutGroup> {
|
||||
let text = if context.network_interface.is_layer(&node_id, context.selection_network_path) {
|
||||
"Layer has no parameters"
|
||||
} else {
|
||||
"Node has no parameters"
|
||||
};
|
||||
string_inspector(text)
|
||||
}
|
||||
|
||||
pub(crate) fn generate_node_inspector(node_id: NodeId, context: &mut NodeInspectorContext) -> LayoutGroup {
|
||||
let mut layout = Vec::new();
|
||||
|
||||
@@ -3183,10 +3174,6 @@ pub(crate) fn generate_node_inspector(node_id: NodeId, context: &mut NodeInspect
|
||||
}
|
||||
}
|
||||
|
||||
if layout.is_empty() {
|
||||
layout = node_no_inspector_content(node_id, context);
|
||||
}
|
||||
|
||||
let display_name = context
|
||||
.network_interface
|
||||
.node_metadata(&node_id, context.selection_network_path)
|
||||
@@ -3237,16 +3224,12 @@ pub(crate) fn generate_node_inspector(node_id: NodeId, context: &mut NodeInspect
|
||||
}
|
||||
|
||||
// That layer is only referred to, as in the Data panel, rather than shown with its own parameters and chain
|
||||
if let Some(layer) = stack_layer {
|
||||
let button = node_reference_button(layer, context.network_interface, network_path, network_path, move || {
|
||||
NodeGraphMessage::SelectedNodesSet { nodes: vec![layer] }.into()
|
||||
});
|
||||
let name = context.network_interface.display_name(&layer, network_path);
|
||||
let visible = context.network_interface.is_visible(&layer, network_path);
|
||||
|
||||
let mut reference_section = LayoutGroup::section(name, None, "", visible, false, true, layer.0, Layout(vec![LayoutGroup::row(vec![button])]));
|
||||
let feeds_content = input_index == LAYER_SECONDARY_INPUT_INDEX && context.network_interface.is_layer(&node_id, network_path);
|
||||
let tooltip_label = if feeds_content { "Select Child Layer" } else { "Select Layer" };
|
||||
if let Some(layer) = stack_layer
|
||||
&& let Some(mut reference_section) = layer_references_section(&[layer], tooltip_label, context)
|
||||
{
|
||||
if let LayoutGroup::NodeSection(section) = &mut reference_section {
|
||||
section.node_reference = true;
|
||||
section.output_wire = Some(output_section_wire(layer, context));
|
||||
}
|
||||
|
||||
@@ -3261,8 +3244,35 @@ pub(crate) fn generate_node_inspector(node_id: NodeId, context: &mut NodeInspect
|
||||
section
|
||||
}
|
||||
|
||||
/// A section only referring to layers, as the Data panel does, with a row of buttons that each select one rather than showing its parameters and chain.
|
||||
/// Their tooltip label names how the layers relate to the section they're shown beside.
|
||||
pub(crate) fn layer_references_section(layers: &[NodeId], tooltip_label: &str, context: &NodeInspectorContext) -> Option<LayoutGroup> {
|
||||
let network_path = context.selection_network_path;
|
||||
let &first_layer = layers.first()?;
|
||||
|
||||
let mut buttons = Vec::with_capacity(layers.len() * 2);
|
||||
for &layer in layers {
|
||||
if !buttons.is_empty() {
|
||||
buttons.push(Separator::new(SeparatorStyle::Related).widget_instance());
|
||||
}
|
||||
let button = node_reference_button(layer, context.network_interface, network_path, network_path, move || {
|
||||
NodeGraphMessage::SelectedNodesSet { nodes: vec![layer] }.into()
|
||||
});
|
||||
buttons.push(button.tooltip_label(tooltip_label).widget_instance());
|
||||
}
|
||||
|
||||
let name = context.network_interface.display_name(&first_layer, network_path);
|
||||
let visible = context.network_interface.is_visible(&first_layer, network_path);
|
||||
|
||||
let mut section = LayoutGroup::section(name, None, "", visible, false, true, first_layer.0, Layout(vec![LayoutGroup::row(buttons)]));
|
||||
if let LayoutGroup::NodeSection(node_section) = &mut section {
|
||||
node_section.node_reference = true;
|
||||
}
|
||||
Some(section)
|
||||
}
|
||||
|
||||
/// The wire drawn up from a node's section in a chain to the section above, which its output feeds.
|
||||
fn output_section_wire(node_id: NodeId, context: &NodeInspectorContext) -> SectionWire {
|
||||
pub(crate) fn output_section_wire(node_id: NodeId, context: &NodeInspectorContext) -> SectionWire {
|
||||
let output_type = context.network_interface.output_type(&OutputConnector::node(node_id, 0), context.selection_network_path);
|
||||
|
||||
SectionWire {
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
let dragging = false;
|
||||
let fromIndex: number | undefined = undefined;
|
||||
let insertIndex: number | undefined = undefined;
|
||||
let insertMarkerTop: number | undefined = undefined;
|
||||
let insertMarker: { top: number; left: number; width: number } | undefined = undefined;
|
||||
let justFinishedDrag = false; // Used to suppress the click event that follows a drag release (which would otherwise toggle a section)
|
||||
|
||||
onMount(() => {
|
||||
@@ -91,7 +91,7 @@
|
||||
const sections = reorderableSections();
|
||||
if (!container || sections.length === 0) {
|
||||
insertIndex = undefined;
|
||||
insertMarkerTop = undefined;
|
||||
insertMarker = undefined;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -111,17 +111,38 @@
|
||||
|
||||
// Position the marker purely from the gap index so it has one fixed spot per gap, rather than snapping between adjacent
|
||||
// sections' edges as the cursor crosses their shared boundary.
|
||||
// Above the first, it's centered in the room left below what comes before, and below the last, in a gap as wide as the sections leave between each other
|
||||
const halfGap = (parseFloat(getComputedStyle(sections[0]).getPropertyValue("--section-gap")) || 0) / 2;
|
||||
let markerViewportY;
|
||||
if (index <= 0) {
|
||||
markerViewportY = sections[0].getBoundingClientRect().top - 2;
|
||||
markerViewportY = (bottomOfContentAbove(sections[0], container) + sections[0].getBoundingClientRect().top) / 2;
|
||||
} else if (index >= sections.length) {
|
||||
markerViewportY = sections[sections.length - 1].getBoundingClientRect().bottom + 2;
|
||||
markerViewportY = sections[sections.length - 1].getBoundingClientRect().bottom + halfGap;
|
||||
} else {
|
||||
markerViewportY = (sections[index - 1].getBoundingClientRect().bottom + sections[index].getBoundingClientRect().top) / 2;
|
||||
}
|
||||
|
||||
// Spanning the sections, which a layer's frame around them indents
|
||||
const firstRect = sections[0].getBoundingClientRect();
|
||||
|
||||
insertIndex = index;
|
||||
insertMarkerTop = toContentOffset(markerViewportY);
|
||||
insertMarker = { top: toContentOffset(markerViewportY), left: firstRect.left - containerRect.left, width: firstRect.width };
|
||||
}
|
||||
|
||||
// The bottom of what's shown right above a section, which is the last row or section before it (even outside the frame it's in), or else the top of the panel
|
||||
function bottomOfContentAbove(section: Element, container: HTMLElement): number {
|
||||
let current = section;
|
||||
while (current !== container && current.parentElement) {
|
||||
let previous = current.previousElementSibling;
|
||||
if (previous) {
|
||||
// Down through the frames and section bodies to the last row or section within
|
||||
while (previous.lastElementChild && previous.hasAttribute("data-section-contents")) previous = previous.lastElementChild;
|
||||
return previous.getBoundingClientRect().bottom;
|
||||
}
|
||||
|
||||
current = current.parentElement;
|
||||
}
|
||||
return container.getBoundingClientRect().top;
|
||||
}
|
||||
|
||||
function draggingPointerUp(e: PointerEvent) {
|
||||
@@ -160,15 +181,15 @@
|
||||
dragging = false;
|
||||
fromIndex = undefined;
|
||||
insertIndex = undefined;
|
||||
insertMarkerTop = undefined;
|
||||
insertMarker = undefined;
|
||||
}
|
||||
</script>
|
||||
|
||||
<LayoutCol class="inspector">
|
||||
<LayoutCol class="sections" classes={{ dragging }} scrollableY={true} bind:this={sectionsCol} on:pointerdown={sectionPointerDown}>
|
||||
<WidgetLayout layout={$inspectorLayout} layoutTarget="Inspector" />
|
||||
{#if dragging && insertMarkerTop !== undefined}
|
||||
<div class="insert-mark" style:top={`${insertMarkerTop}px`}></div>
|
||||
{#if dragging && insertMarker}
|
||||
<div class="insert-mark" style:top={`${insertMarker.top}px`} style:left={`${insertMarker.left}px`} style:width={`${insertMarker.width}px`}></div>
|
||||
{/if}
|
||||
</LayoutCol>
|
||||
</LayoutCol>
|
||||
@@ -201,8 +222,6 @@
|
||||
|
||||
.insert-mark {
|
||||
position: absolute;
|
||||
left: 4px;
|
||||
right: 4px;
|
||||
background: var(--color-e-nearwhite);
|
||||
height: 5px;
|
||||
// The marker's `top` is the center of the gap, so shift up by half its height to straddle that line
|
||||
|
||||
@@ -1329,11 +1329,15 @@
|
||||
background: rgb(from var(--color-4-dimgray) r g b / 0.5);
|
||||
}
|
||||
|
||||
// Spanning the insertion line beside the layer (past the visibility column and the indent), plus its own thickness outward so it clears the icons at both ends
|
||||
&.insert-folder::after {
|
||||
--outline-thickness: 3px;
|
||||
content: "";
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
border: 3px solid var(--color-e-nearwhite);
|
||||
left: calc(24px + var(--layer-indent-levels) * 16px - var(--outline-thickness));
|
||||
right: calc(-1 * var(--outline-thickness));
|
||||
border: var(--outline-thickness) solid var(--color-e-nearwhite);
|
||||
border-radius: 2px;
|
||||
pointer-events: none;
|
||||
}
|
||||
@@ -1412,7 +1416,7 @@
|
||||
}
|
||||
|
||||
// The name (and lock) and the chain split the rest of the row evenly, except that either gives the other whatever share it doesn't need.
|
||||
// Between them, the spacer keeps an unrelated-width gap. The right margin keeps the layer icon 4px from the row's end like the visibility icon at its start.
|
||||
// Between them, the spacer keeps an unrelated-width gap.
|
||||
.layer-name-and-chain {
|
||||
flex: 1 1 0;
|
||||
min-width: 0;
|
||||
@@ -1420,7 +1424,6 @@
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, max-content) auto minmax(4px, 1fr) minmax(0, var(--chain-width));
|
||||
align-items: center;
|
||||
margin-right: 2px;
|
||||
|
||||
// While renaming, the name takes all the room its text needs, which the chain gives up until it disappears
|
||||
&.editing {
|
||||
@@ -1692,10 +1695,10 @@
|
||||
margin: 0 8px;
|
||||
}
|
||||
|
||||
// At the row's end, past the layer icon's margin and the row's margin
|
||||
// At the row's end, past a margin like the layer icon's
|
||||
.chain-node-icon {
|
||||
margin-left: auto;
|
||||
margin-right: calc(2px + 2px);
|
||||
margin-right: 2px;
|
||||
|
||||
// Outlined like the layer icon when the active tool edits it
|
||||
&.tool-target,
|
||||
|
||||
@@ -16,8 +16,11 @@
|
||||
export { className as class };
|
||||
export let classes: Record<string, boolean> = {};
|
||||
|
||||
// A node without parameters has nothing to show, so its section stays collapsed with its arrow grayed out, like the Layers panel's
|
||||
$: expandable = widgetData.layout.length > 0;
|
||||
|
||||
// Whether the section is expanded is owned by the backend (persisted per node), so just reflect it here
|
||||
$: expanded = widgetData.expanded;
|
||||
$: expanded = widgetData.expanded && expandable;
|
||||
|
||||
// The sections of the chain feeding one of this node's inputs, which follow its own rows and are shown beneath them
|
||||
$: chainSections = widgetData.layout.flatMap((layoutGroup) => ("NodeSection" in layoutGroup && layoutGroup.NodeSection.outputWire ? [layoutGroup.NodeSection] : []));
|
||||
@@ -30,6 +33,8 @@
|
||||
|
||||
// Like the Layers panel's expand arrows, a modifier key applies the toggle recursively to the sections nested within
|
||||
function toggleExpandedWithModifiers(e: MouseEvent) {
|
||||
if (!expandable) return;
|
||||
|
||||
const accel = operatingSystem() === "Mac" ? e.metaKey : e.ctrlKey;
|
||||
editor.toggleNodeInspectorSectionExpanded(widgetData.id, e.altKey || accel);
|
||||
}
|
||||
@@ -45,42 +50,46 @@
|
||||
"output-wire": Boolean(widgetData.outputWire),
|
||||
"output-wire-list": Boolean(widgetData.outputWire?.isList),
|
||||
"node-reference": widgetData.nodeReference,
|
||||
"content-wire": Boolean(widgetData.contentWire),
|
||||
"content-wire-list": Boolean(widgetData.contentWire?.isList),
|
||||
"content-wire-continues": widgetData.contentWireContinues,
|
||||
collapsed: !expanded,
|
||||
}}
|
||||
styles={{
|
||||
"--chain-wire-color": widgetData.chainWire && `var(--color-data-${widgetData.chainWire.dataType.toLowerCase()}-dim)`,
|
||||
"--output-wire-color": widgetData.outputWire && `var(--color-data-${widgetData.outputWire.dataType.toLowerCase()}-dim)`,
|
||||
"--content-wire-color": widgetData.contentWire && `var(--color-data-${widgetData.contentWire.dataType.toLowerCase()}-dim)`,
|
||||
}}
|
||||
data-inspector-reorderable-section={reorderable ? "" : undefined}
|
||||
data-node-id={reorderable ? String(widgetData.id) : undefined}
|
||||
>
|
||||
{#if widgetData.nodeReference}
|
||||
{#if widgetData.contentWireContinues}
|
||||
<div class="content-wire-continuation"></div>
|
||||
{/if}
|
||||
{#each widgetData.layout as layoutGroup}
|
||||
{#if "Row" in layoutGroup}
|
||||
<WidgetSpan direction="row" widgets={layoutGroup.Row.rowWidgets} {layoutTarget} />
|
||||
{/if}
|
||||
{/each}
|
||||
{:else}
|
||||
<button
|
||||
class="header"
|
||||
class:expanded
|
||||
data-tooltip-label={widgetData.name}
|
||||
data-tooltip-description={widgetData.description}
|
||||
data-inspector-reorder-handle={reorderable ? "" : undefined}
|
||||
on:click|stopPropagation={toggleExpandedWithModifiers}
|
||||
>
|
||||
<button class="header" class:expanded class:expandable data-inspector-reorder-handle={reorderable ? "" : undefined} on:click|stopPropagation={toggleExpandedWithModifiers}>
|
||||
<div
|
||||
class="expand-arrow"
|
||||
data-tooltip-label={expanded ? "Collapse (All)" : "Expand (All)"}
|
||||
data-tooltip-description={expanded
|
||||
? "Hide this node's parameters. (To also collapse every node nested within, perform the shortcut shown.)"
|
||||
: "Show this node's parameters. (To also expand every node nested within, perform the shortcut shown.)"}
|
||||
data-tooltip-shortcut={$tooltip.altClickShortcut?.shortcut ? JSON.stringify($tooltip.altClickShortcut.shortcut) : undefined}
|
||||
></div>
|
||||
{#if widgetData.icon}
|
||||
<IconLabel icon={widgetData.icon} />
|
||||
{/if}
|
||||
<TextLabel bold={true}>{widgetData.name}</TextLabel>
|
||||
class="icon-slot"
|
||||
data-tooltip-label={!expandable ? undefined : expanded ? "Collapse (All)" : "Expand (All)"}
|
||||
data-tooltip-description={!expandable
|
||||
? undefined
|
||||
: expanded
|
||||
? "Hide this node's parameters. (To also collapse every node nested within, perform the shortcut shown.)"
|
||||
: "Show this node's parameters. (To also expand every node nested within, perform the shortcut shown.)"}
|
||||
data-tooltip-shortcut={expandable && $tooltip.altClickShortcut?.shortcut ? JSON.stringify($tooltip.altClickShortcut.shortcut) : undefined}
|
||||
>
|
||||
{#if widgetData.icon}
|
||||
<IconLabel icon={widgetData.icon} />
|
||||
{/if}
|
||||
<div class="expand-arrow"></div>
|
||||
</div>
|
||||
<TextLabel tooltipLabel={widgetData.name} tooltipDescription={widgetData.description}>{widgetData.name}</TextLabel>
|
||||
<IconButton
|
||||
icon="Trash"
|
||||
tooltipDescription="Delete this node from the layer chain."
|
||||
@@ -112,9 +121,12 @@
|
||||
}}
|
||||
class={widgetData.visible ? "show-only-on-hover" : ""}
|
||||
/>
|
||||
{#if reorderable}
|
||||
<div class="drag-grip" data-tooltip-description="Drag to reorder this node." on:click|stopPropagation={() => undefined} role="presentation"></div>
|
||||
{/if}
|
||||
</button>
|
||||
{#if expanded}
|
||||
<LayoutCol class="body" data-block-hover-transfer>
|
||||
<LayoutCol class="body" data-block-hover-transfer data-section-contents>
|
||||
{#each widgetData.layout as layoutGroup}
|
||||
{#if "Row" in layoutGroup}
|
||||
<WidgetSpan direction="row" widgets={layoutGroup.Row.rowWidgets} {layoutTarget} />
|
||||
@@ -124,7 +136,7 @@
|
||||
{/each}
|
||||
</LayoutCol>
|
||||
{#if chainSections.length > 0}
|
||||
<LayoutCol class="chain-sections">
|
||||
<LayoutCol class="chain-sections" data-section-contents>
|
||||
{#each chainSections as chainSection}
|
||||
<svelte:self widgetData={chainSection} {layoutTarget} />
|
||||
{/each}
|
||||
@@ -136,11 +148,32 @@
|
||||
|
||||
<style lang="scss">
|
||||
.node-section {
|
||||
--section-outline: var(--color-2-mildblack);
|
||||
// Where the icon is centered, and the wire running down through the sections: 4px inside the 1px outline, plus half the 16px icon
|
||||
--wire-center: calc(1px + 4px + 16px / 2);
|
||||
// Between neighboring sections, which the wires joining them cross
|
||||
--section-gap: 8px;
|
||||
flex: 0 0 auto;
|
||||
margin: 0 4px;
|
||||
|
||||
+ .node-section {
|
||||
margin-top: 4px;
|
||||
margin-top: var(--section-gap);
|
||||
}
|
||||
|
||||
// Hovered over its header or parameters (but not a section nested among them, which reacts instead), its outline lightens and its icon becomes the expand arrow.
|
||||
// The chain shown below doesn't count, so passing between its sections leaves this one alone.
|
||||
&:has(> .header:hover, > .body:hover):not(:has(.node-section:hover)) {
|
||||
--section-outline: var(--color-4-dimgray);
|
||||
|
||||
> .header .icon-slot {
|
||||
.icon-label {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.expand-arrow {
|
||||
display: flex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// A section showing the chain feeding one of its inputs, which it frames below its rows, with a wire rising from them through its body into that input
|
||||
@@ -148,15 +181,15 @@
|
||||
--chain-wire-corner-radius: 4px;
|
||||
--chain-wire-width: 2px;
|
||||
--chain-section-indent: 8px;
|
||||
// Within the body's border, the wire's centerline rises in line with the indented chain sections' expand arrows
|
||||
--chain-wire-x: calc(var(--chain-section-indent) + 12px - 1px);
|
||||
// Within the body's border, the wire's centerline rises in line with the indented chain sections' icons
|
||||
--chain-wire-x: calc(var(--chain-section-indent) + var(--wire-center) - 1px);
|
||||
|
||||
// Like in the graph, a list's wire is a 1px line, 2px gap, and 1px line
|
||||
&.chain-wire-list {
|
||||
--chain-wire-width: 4px;
|
||||
}
|
||||
|
||||
// The body continues down into the frame around the chain's sections
|
||||
// The body continues down into the frame around the chain's sections, the first right beneath its rows
|
||||
> .body {
|
||||
position: relative;
|
||||
border-bottom: none;
|
||||
@@ -171,9 +204,9 @@
|
||||
|
||||
// The chain's sections, indented on the left and sharing the right edge, with the wire to the body crossing the gap atop the first
|
||||
> .chain-sections {
|
||||
padding: 4px 0 calc(var(--chain-section-indent) - 1px) calc(var(--chain-section-indent) - 1px);
|
||||
padding: 0 0 calc(var(--chain-section-indent) - 1px) calc(var(--chain-section-indent) - 1px);
|
||||
background: var(--color-3-darkgray);
|
||||
border: 1px solid var(--color-2-mildblack);
|
||||
border: 1px solid var(--section-outline);
|
||||
border-top: none;
|
||||
border-radius: 0 0 4px 4px;
|
||||
|
||||
@@ -183,9 +216,9 @@
|
||||
margin-right: -1px;
|
||||
}
|
||||
|
||||
// Keeps the frame below as thick as beside
|
||||
> .node-section.collapsed:last-child > .header {
|
||||
margin-bottom: 0;
|
||||
// With no gap above the first to cross, the body's wire meets it directly
|
||||
> .node-section:first-child::before {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -230,33 +263,95 @@
|
||||
content: "";
|
||||
position: absolute;
|
||||
box-sizing: border-box;
|
||||
left: calc(12px - var(--output-wire-width) / 2);
|
||||
top: -4px;
|
||||
left: calc(var(--wire-center) - var(--output-wire-width) / 2);
|
||||
top: calc(-1 * var(--section-gap));
|
||||
width: var(--output-wire-width);
|
||||
height: 4px;
|
||||
height: var(--section-gap);
|
||||
border-left: 1px solid var(--output-wire-color);
|
||||
border-right: 1px solid var(--output-wire-color);
|
||||
pointer-events: none;
|
||||
}
|
||||
}
|
||||
|
||||
// A collapsed section keeps its header's bottom margin, which the wire from the section below crosses too
|
||||
&.collapsed + .node-section.output-wire::before {
|
||||
top: calc(-4px - 4px);
|
||||
height: calc(4px + 4px);
|
||||
}
|
||||
|
||||
// The layer whose stack feeds the bottom of a chain, only referred to by a button like the Data panel's, its 16px icon centered on the wire reaching down to it
|
||||
// A layer only referred to by a button like the Data panel's, its 16px icon centered on the wire reaching it
|
||||
&.node-reference {
|
||||
// As wide as its contents, unlike the Inspector's buttons that share their row
|
||||
// Only as tall as the button, so it's spaced from the sections around it like they are from each other
|
||||
> .widget-span.row {
|
||||
--row-height: 24px;
|
||||
}
|
||||
|
||||
// As wide as its contents, unlike the Inspector's buttons that share their row, and flush within an outline like the sections'
|
||||
.text-button {
|
||||
flex-basis: auto;
|
||||
padding-left: calc(12px - 16px / 2);
|
||||
padding-left: calc(var(--wire-center) - 16px / 2);
|
||||
--button-background-color: none;
|
||||
box-shadow: inset 0 0 0 1px var(--section-outline);
|
||||
|
||||
&:hover:not(.disabled) {
|
||||
--button-background-color: var(--color-5-dullgray);
|
||||
--section-outline: var(--color-4-dimgray);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Layers taking the wire rising from the section below into their content, indented so it turns in from the left at the middle of their buttons
|
||||
&.content-wire {
|
||||
--content-wire-width: 2px;
|
||||
--content-wire-indent: 20px;
|
||||
position: relative;
|
||||
padding-left: var(--content-wire-indent);
|
||||
|
||||
&.content-wire-list {
|
||||
--content-wire-width: 4px;
|
||||
}
|
||||
|
||||
// Outer and inner 1px lines, rising from the bottom and turning toward the buttons, like the wire into a shown chain's input
|
||||
&::before,
|
||||
&::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
box-sizing: border-box;
|
||||
right: calc(100% - var(--content-wire-indent));
|
||||
bottom: 0;
|
||||
border-left: 1px solid var(--content-wire-color);
|
||||
border-top: 1px solid var(--content-wire-color);
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
&::after {
|
||||
left: calc(var(--wire-center) - var(--content-wire-width) / 2);
|
||||
top: calc(50% - var(--content-wire-width) / 2);
|
||||
border-top-left-radius: 4px;
|
||||
}
|
||||
|
||||
// Down to the 24px button centered in its 32px row
|
||||
&::before {
|
||||
height: calc(4px + (32px - 24px) / 2);
|
||||
left: calc(var(--wire-center) + var(--content-wire-width) / 2 - 1px);
|
||||
top: calc(50% + var(--content-wire-width) / 2 - 1px);
|
||||
border-top-left-radius: max(0px, 4px - var(--content-wire-width) + 1px);
|
||||
}
|
||||
|
||||
// Also continuing straight up past the turn into the bottom of the buttons above, beneath the turn, which hides where it crosses
|
||||
&.content-wire-continues {
|
||||
.content-wire-continuation {
|
||||
position: absolute;
|
||||
box-sizing: border-box;
|
||||
left: calc(var(--wire-center) - var(--content-wire-width) / 2);
|
||||
width: var(--content-wire-width);
|
||||
top: calc(-1 * var(--section-gap));
|
||||
bottom: 0;
|
||||
border-left: 1px solid var(--content-wire-color);
|
||||
border-right: 1px solid var(--content-wire-color);
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
&::after {
|
||||
background: var(--color-3-darkgray);
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
&::before {
|
||||
z-index: 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -265,32 +360,45 @@
|
||||
align-items: center;
|
||||
display: flex;
|
||||
flex: 0 0 24px;
|
||||
padding-left: 8px;
|
||||
padding-right: 0;
|
||||
margin-bottom: 4px;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
border-radius: 4px;
|
||||
background: var(--color-2-mildblack);
|
||||
background: none;
|
||||
// The section's outline, continuing up around the header without changing its size
|
||||
box-shadow: inset 0 0 0 1px var(--section-outline);
|
||||
|
||||
&.expanded {
|
||||
border-radius: 4px 4px 0 0;
|
||||
margin-bottom: 0;
|
||||
// Open at the bottom, where the body's sides carry on
|
||||
box-shadow:
|
||||
inset 1px 0 0 var(--section-outline),
|
||||
inset -1px 0 0 var(--section-outline),
|
||||
inset 0 1px 0 var(--section-outline);
|
||||
|
||||
.expand-arrow::after {
|
||||
transform: rotate(90deg);
|
||||
}
|
||||
}
|
||||
|
||||
&:hover {
|
||||
background: var(--color-4-dimgray);
|
||||
&.expandable:hover .expand-arrow::after {
|
||||
background: var(--icon-expand-collapse-arrow-hover);
|
||||
}
|
||||
|
||||
.expand-arrow::after {
|
||||
background: var(--icon-expand-collapse-arrow-hover);
|
||||
}
|
||||
&:not(.expandable) .expand-arrow::after {
|
||||
background: var(--icon-expand-collapse-arrow-disabled);
|
||||
}
|
||||
|
||||
+ .body,
|
||||
~ .chain-sections {
|
||||
border-color: var(--color-4-dimgray);
|
||||
// Centers the icon on the wire, swapping in the expand arrow while the section is hovered
|
||||
.icon-slot {
|
||||
flex: 0 0 24px;
|
||||
height: 24px;
|
||||
margin-left: calc(var(--wire-center) - 24px / 2);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
.expand-arrow {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -301,7 +409,6 @@
|
||||
padding: 0;
|
||||
position: relative;
|
||||
flex: 0 0 auto;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
@@ -314,14 +421,26 @@
|
||||
}
|
||||
}
|
||||
|
||||
> .icon-label {
|
||||
margin-left: 8px;
|
||||
// Like a graph layer's grip
|
||||
.drag-grip {
|
||||
flex: 0 0 auto;
|
||||
width: 8px;
|
||||
height: 24px;
|
||||
// Padding rather than margin, so the gaps count toward the tooltip's hover area
|
||||
padding: 0 4px;
|
||||
background-image: var(--icon-drag-grip);
|
||||
background-position: calc(4px + 2px) 8px;
|
||||
background-repeat: no-repeat;
|
||||
|
||||
&:hover {
|
||||
background-image: var(--icon-drag-grip-hover);
|
||||
}
|
||||
}
|
||||
|
||||
// As wide as the name, with the buttons pushed to the end
|
||||
.text-label {
|
||||
height: 18px;
|
||||
margin-left: 8px;
|
||||
margin-left: 4px;
|
||||
margin-right: auto;
|
||||
flex: 0 1 auto;
|
||||
overflow: hidden;
|
||||
@@ -340,7 +459,9 @@
|
||||
padding-top: 1px;
|
||||
margin-top: -1px;
|
||||
background: var(--color-3-darkgray);
|
||||
border: 1px solid var(--color-2-mildblack);
|
||||
border: 1px solid var(--section-outline);
|
||||
// No line between it and the header, which shares its outline
|
||||
border-top-color: transparent;
|
||||
border-radius: 0 0 4px 4px;
|
||||
overflow: hidden;
|
||||
|
||||
@@ -397,10 +518,9 @@
|
||||
}
|
||||
}
|
||||
|
||||
// With no value widget after it, a chain toggle takes the rest of the row, only shrinking once that runs out
|
||||
// A chain toggle is only as wide as its text, so the rest of the row isn't clickable, only shrinking once the row runs out
|
||||
> .text-label.parameter-chain-toggle:first-of-type {
|
||||
flex-grow: 1;
|
||||
flex-shrink: 1;
|
||||
flex: 0 1 auto;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
@@ -408,6 +528,11 @@
|
||||
margin-left: 8px;
|
||||
}
|
||||
|
||||
// A label alone in its row lines up with the parameter names that follow their expose buttons
|
||||
> .text-label:only-child {
|
||||
margin-left: calc(20px + 8px + 8px);
|
||||
}
|
||||
|
||||
> .separator.horizontal.unrelated {
|
||||
flex-shrink: 1;
|
||||
min-width: 8px;
|
||||
|
||||
Reference in new issue
Block a user