Add direct process and chain occurrence editing
This commit is contained in:
@@ -38,14 +38,33 @@ mod scenario_scroll {
|
||||
content: content.into(),
|
||||
context,
|
||||
area,
|
||||
process: false,
|
||||
})
|
||||
}
|
||||
pub(super) fn observe_topology<'a>(
|
||||
context: topology::Context,
|
||||
area: scenario::ScrollArea,
|
||||
content: impl Into<Element<'a, Message>>,
|
||||
) -> Element<'a, Message> {
|
||||
Element::new(Observer {
|
||||
content: content.into(),
|
||||
context: scenario::Context {
|
||||
document: context.document,
|
||||
scenario: context.owner,
|
||||
revision: context.revision,
|
||||
epoch: context.epoch,
|
||||
},
|
||||
area,
|
||||
process: true,
|
||||
})
|
||||
}
|
||||
struct Observer<'a, R = Renderer> {
|
||||
content: Element<'a, Message, Theme, R>,
|
||||
context: scenario::Context,
|
||||
area: scenario::ScrollArea,
|
||||
process: bool,
|
||||
}
|
||||
type Report = Option<(Id, Id, Vector)>;
|
||||
type Report = Option<(bool, Id, Id, Vector)>;
|
||||
#[derive(Default)]
|
||||
struct Translation(Option<Vector>);
|
||||
impl widget::Operation for Translation {
|
||||
@@ -77,15 +96,33 @@ mod scenario_scroll {
|
||||
&mut offset,
|
||||
);
|
||||
if let Some(offset) = offset.0 {
|
||||
let next = Some((self.context.document, self.context.scenario, offset));
|
||||
let next = Some((
|
||||
self.process,
|
||||
self.context.document,
|
||||
self.context.scenario,
|
||||
offset,
|
||||
));
|
||||
let previous = tree.state.downcast_mut::<Report>();
|
||||
if *previous != next {
|
||||
*previous = next;
|
||||
shell.publish(Message::ScenarioCanvas(scenario::CanvasEvent::Scrolled(
|
||||
self.context,
|
||||
self.area,
|
||||
offset,
|
||||
)));
|
||||
shell.publish(if self.process {
|
||||
Message::TopologyCanvas(topology::CanvasEvent::Scrolled(
|
||||
topology::Context {
|
||||
document: self.context.document,
|
||||
owner: self.context.scenario,
|
||||
revision: self.context.revision,
|
||||
epoch: self.context.epoch,
|
||||
},
|
||||
self.area,
|
||||
offset,
|
||||
))
|
||||
} else {
|
||||
Message::ScenarioCanvas(scenario::CanvasEvent::Scrolled(
|
||||
self.context,
|
||||
self.area,
|
||||
offset,
|
||||
))
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -220,6 +257,7 @@ mod scenario_scroll {
|
||||
Observer {
|
||||
context,
|
||||
area: scenario::ScrollArea::Canvas,
|
||||
process: false,
|
||||
content: scrollable(iced::widget::Space::new().width(200.).height(height))
|
||||
.width(200.)
|
||||
.height(200.)
|
||||
@@ -342,7 +380,7 @@ impl Event {
|
||||
pub struct State {
|
||||
pub active_owner: Option<Id>,
|
||||
pub diagram: state_view::State,
|
||||
topology: topology::State,
|
||||
pub(crate) topology: topology::State,
|
||||
pub(crate) scenario: scenario::State,
|
||||
states: states::State,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user