Update the parameter expose button in the Properties panel and fix undo history when it's clicked
This commit is contained in:
parent
7cb16a8bec
commit
41fe46591a
|
|
@ -159,6 +159,7 @@ pub enum DocumentMessage {
|
|||
SetViewMode {
|
||||
view_mode: ViewMode,
|
||||
},
|
||||
AddTransaction,
|
||||
StartTransaction,
|
||||
EndTransaction,
|
||||
CommitTransaction,
|
||||
|
|
@ -166,7 +167,6 @@ pub enum DocumentMessage {
|
|||
RepeatedAbortTransaction {
|
||||
undo_count: usize,
|
||||
},
|
||||
AddTransaction,
|
||||
ToggleLayerExpansion {
|
||||
id: NodeId,
|
||||
recursive: bool,
|
||||
|
|
|
|||
|
|
@ -1155,6 +1155,11 @@ impl MessageHandler<DocumentMessage, DocumentMessageData<'_>> for DocumentMessag
|
|||
self.view_mode = view_mode;
|
||||
responses.add_front(NodeGraphMessage::RunDocumentGraph);
|
||||
}
|
||||
DocumentMessage::AddTransaction => {
|
||||
// Reverse order since they are added to the front
|
||||
responses.add_front(DocumentMessage::CommitTransaction);
|
||||
responses.add_front(DocumentMessage::StartTransaction);
|
||||
}
|
||||
// Note: A transaction should never be started in a scope that mutates the network interface, since it will only be run after that scope ends.
|
||||
DocumentMessage::StartTransaction => {
|
||||
self.network_interface.start_transaction();
|
||||
|
|
@ -1198,11 +1203,6 @@ impl MessageHandler<DocumentMessage, DocumentMessageData<'_>> for DocumentMessag
|
|||
self.network_interface.finish_transaction();
|
||||
responses.add(OverlaysMessage::Draw);
|
||||
}
|
||||
DocumentMessage::AddTransaction => {
|
||||
// Reverse order since they are added to the front
|
||||
responses.add_front(DocumentMessage::CommitTransaction);
|
||||
responses.add_front(DocumentMessage::StartTransaction);
|
||||
}
|
||||
DocumentMessage::ToggleLayerExpansion { id, recursive } => {
|
||||
let layer = LayerNodeIdentifier::new(id, &self.network_interface, &[]);
|
||||
let metadata = self.metadata();
|
||||
|
|
|
|||
|
|
@ -58,7 +58,8 @@ pub enum NodeGraphMessage {
|
|||
DuplicateSelectedNodes,
|
||||
ExposeInput {
|
||||
input_connector: InputConnector,
|
||||
new_exposed: bool,
|
||||
set_to_exposed: bool,
|
||||
start_transaction: bool,
|
||||
},
|
||||
InsertNode {
|
||||
node_id: NodeId,
|
||||
|
|
|
|||
|
|
@ -315,7 +315,11 @@ impl<'a> MessageHandler<NodeGraphMessage, NodeGraphHandlerData<'a>> for NodeGrap
|
|||
responses.add(DocumentMessage::EnterNestedNetwork { node_id });
|
||||
}
|
||||
}
|
||||
NodeGraphMessage::ExposeInput { input_connector, new_exposed } => {
|
||||
NodeGraphMessage::ExposeInput {
|
||||
input_connector,
|
||||
set_to_exposed,
|
||||
start_transaction,
|
||||
} => {
|
||||
let InputConnector::Node { node_id, input_index } = input_connector else {
|
||||
log::error!("Cannot expose/hide export");
|
||||
return;
|
||||
|
|
@ -324,26 +328,43 @@ impl<'a> MessageHandler<NodeGraphMessage, NodeGraphHandlerData<'a>> for NodeGrap
|
|||
log::error!("Could not find node {node_id} in NodeGraphMessage::ExposeInput");
|
||||
return;
|
||||
};
|
||||
let Some(mut input) = node.inputs.get(input_index).cloned() else {
|
||||
let Some(mut node_input) = node.inputs.get(input_index).cloned() else {
|
||||
log::error!("Could not find input {input_index} in NodeGraphMessage::ExposeInput");
|
||||
return;
|
||||
};
|
||||
if let NodeInput::Value { exposed, .. } = &mut input {
|
||||
*exposed = new_exposed;
|
||||
} else if !new_exposed {
|
||||
// If hiding an input that is not a value, then disconnect it. This will convert it to a value input.
|
||||
responses.add(NodeGraphMessage::DisconnectInput { input_connector });
|
||||
responses.add(NodeGraphMessage::ExposeInput { input_connector, new_exposed });
|
||||
|
||||
// If we're un-exposing an input that is not a value, then disconnect it. This will convert it to a value input,
|
||||
// so we can come back to handle this message again to set the exposed value in the second run-through.
|
||||
if !set_to_exposed && node_input.as_value().is_none() {
|
||||
// Reversed order because we are pushing front
|
||||
responses.add_front(NodeGraphMessage::ExposeInput {
|
||||
input_connector,
|
||||
set_to_exposed,
|
||||
start_transaction: false,
|
||||
});
|
||||
responses.add_front(NodeGraphMessage::DisconnectInput { input_connector });
|
||||
responses.add_front(DocumentMessage::StartTransaction);
|
||||
return;
|
||||
}
|
||||
|
||||
responses.add(DocumentMessage::AddTransaction);
|
||||
// Add a history step, but only do so if we didn't already start a transaction in the first run-through of this message in the above code
|
||||
if start_transaction {
|
||||
responses.add_front(DocumentMessage::StartTransaction);
|
||||
}
|
||||
|
||||
// If this node's input is a value type, we set its chosen exposed state
|
||||
if let NodeInput::Value { exposed, .. } = &mut node_input {
|
||||
*exposed = set_to_exposed;
|
||||
}
|
||||
responses.add(NodeGraphMessage::SetInput {
|
||||
input_connector: InputConnector::node(node_id, input_index),
|
||||
input,
|
||||
input: node_input,
|
||||
});
|
||||
|
||||
// Finish the history step
|
||||
responses.add(DocumentMessage::CommitTransaction);
|
||||
|
||||
// Update the graph UI and re-render
|
||||
responses.add(PropertiesPanelMessage::Refresh);
|
||||
responses.add(NodeGraphMessage::SendGraph);
|
||||
responses.add(NodeGraphMessage::RunDocumentGraph);
|
||||
|
|
|
|||
|
|
@ -52,11 +52,12 @@ pub fn expose_widget(node_id: NodeId, index: usize, data_type: FrontendGraphData
|
|||
ParameterExposeButton::new()
|
||||
.exposed(exposed)
|
||||
.data_type(data_type)
|
||||
.tooltip("Expose this parameter input in node graph")
|
||||
.tooltip("Expose this parameter as a node input in the graph")
|
||||
.on_update(move |_parameter| {
|
||||
NodeGraphMessage::ExposeInput {
|
||||
input_connector: InputConnector::node(node_id, index),
|
||||
new_exposed: !exposed,
|
||||
set_to_exposed: !exposed,
|
||||
start_transaction: true,
|
||||
}
|
||||
.into()
|
||||
})
|
||||
|
|
|
|||
|
|
@ -19,20 +19,23 @@
|
|||
title={tooltip}
|
||||
tabindex="-1"
|
||||
>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 10 10">
|
||||
<path class="interior" d="M0,7.882c0,1.832,1.325,2.63,2.945,1.772L8.785,6.56c1.62-.858,1.62-2.262,0-3.12L2.945.345C1.325-.512,0,.285,0,2.118Z" />
|
||||
<path
|
||||
class="outline"
|
||||
d="M 1.705180287361145 9.999852180480957 L 1.705180287361145 8.999852180480957 C 1.9275803565979 8.999852180480957 2.194530248641968 8.920772552490234 2.476730346679688
|
||||
8.771392822265625 L 8.31682014465332 5.67636251449585 C 8.788760185241699 5.426312446594238 9 5.156492233276367 9 5.000002384185791 C 9 4.843512535095215 8.788760185241699
|
||||
4.573692321777344 8.316730499267578 4.323602199554443 L 2.477190256118774 1.228852391242981 C 2.194520235061646 1.079232335090637 1.927510380744934 1.000152349472046 1.70503032207489
|
||||
1.000152349472046 C 1.091590285301208 1.000152349472046 1.000000357627869 1.700212359428406 1.000000357627869 2.117512464523315 L 1.000000357627869 7.882492542266846 C
|
||||
1.000000357627869 8.299762725830078 1.091610312461853 8.999792098999023 1.705130338668823 8.999852180480957 L 1.705180287361145 9.999852180480957 M 1.705027341842651 9.999849319458008
|
||||
C 0.7003514766693115 9.999751091003418 0 9.214582443237305 0 7.882492542266846 L 0 2.117512464523315 C 0 0.2850223779678345 1.325000405311584 -0.512467622756958 2.945000410079956
|
||||
0.3450223803520203 L 8.785000801086426 3.440012454986572 C 10.40500068664551 4.298342227935791 10.40500068664551 5.701662540435791 8.785000801086426 6.55999231338501 L
|
||||
2.945000410079956 9.654982566833496 C 2.502624750137329 9.889138221740723 2.082434415817261 9.999885559082031 1.705027341842651 9.999849319458008 Z"
|
||||
/>
|
||||
</svg>
|
||||
{#if !exposed}
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 8 8">
|
||||
<circle class="interior" r="3" cx="4" cy="4" />
|
||||
<path
|
||||
class="outline"
|
||||
d="M4,1C5.656,1 7,2.344 7,4C7,5.656 5.656,7 4,7C2.344,7 1,5.656 1,4C1,2.344 2.344,1 4,1ZM4,2C2.896,2 2,2.896 2,4C2,5.104 2.896,6 4,6C5.104,6 6,5.104 6,4C6,2.896 5.104,2 4,2z"
|
||||
/>
|
||||
</svg>
|
||||
{:else}
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 8 8">
|
||||
<path class="interior" d="M0,6.306L0,1.694C0,0.228 1.06,-0.41 2.356,0.276L7.028,2.752C8.324,3.438 8.324,4.562 7.028,5.248L2.356,7.723C1.06,8.41 0,7.771 0,6.306z" />
|
||||
<path
|
||||
class="outline"
|
||||
d="M1.364,8C0.56,8 0,7.372 0,6.306L0,1.694C0,0.228 1.06,-0.41 2.356,0.276L7.028,2.752C8.324,3.439 8.324,4.561 7.028,5.248L2.356,7.724C2.002,7.911 1.666,8 1.364,8ZM1.364,7.2C1.542,7.2 1.756,7.137 1.981,7.017L6.653,4.541C7.031,4.341 7.2,4.125 7.2,4C7.2,3.875 7.031,3.659 6.653,3.459L1.982,0.983C1.756,0.863 1.542,0.8 1.364,0.8C0.873,0.8 0.8,1.36 0.8,1.694L0.8,6.306C0.8,6.64 0.873,7.2 1.364,7.2z"
|
||||
/>
|
||||
</svg>
|
||||
{/if}
|
||||
</button>
|
||||
</LayoutRow>
|
||||
|
||||
|
|
@ -54,42 +57,21 @@
|
|||
fill: none;
|
||||
stroke: none;
|
||||
|
||||
svg {
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
margin-top: -1px;
|
||||
margin-left: -1px;
|
||||
.outline {
|
||||
fill: none;
|
||||
}
|
||||
|
||||
&:not(.exposed) {
|
||||
&:not(:hover) {
|
||||
.outline {
|
||||
fill: var(--data-type-color-dim);
|
||||
}
|
||||
}
|
||||
|
||||
&:hover {
|
||||
.outline {
|
||||
fill: var(--data-type-color);
|
||||
}
|
||||
}
|
||||
.interior {
|
||||
fill: var(--data-type-color);
|
||||
}
|
||||
|
||||
&.exposed {
|
||||
&:not(:hover) {
|
||||
.interior {
|
||||
fill: var(--data-type-color);
|
||||
}
|
||||
&:hover {
|
||||
.outline {
|
||||
fill: var(--data-type-color);
|
||||
}
|
||||
|
||||
&:hover {
|
||||
.outline {
|
||||
fill: var(--data-type-color);
|
||||
}
|
||||
|
||||
.interior {
|
||||
fill: var(--data-type-color-dim);
|
||||
}
|
||||
.interior {
|
||||
fill: var(--data-type-color-dim);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue