Integrate allocation drag candidate with guarded input and atomic history
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
pub(crate) mod allocation_drag;
|
||||
pub(crate) mod architecture_authoring;
|
||||
#[cfg(test)]
|
||||
mod architecture_authoring_tests;
|
||||
@@ -327,6 +328,7 @@ pub struct FilePrompt {
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum Message {
|
||||
WorkDrag(allocation_drag::Event),
|
||||
BehaviorControl(behavior::canvas_workspace::Intent),
|
||||
Architecture(architecture_authoring::Event),
|
||||
Home(crate::home::Event),
|
||||
@@ -450,6 +452,7 @@ pub enum Message {
|
||||
}
|
||||
|
||||
pub struct App {
|
||||
pub allocation_drag: allocation_drag::State,
|
||||
pub home: crate::home::State,
|
||||
pub recovery: crate::recovery::State,
|
||||
recent_target: Option<PathBuf>,
|
||||
@@ -557,6 +560,7 @@ impl App {
|
||||
let explorer_index = crate::explorer::Index::new(&project, layer);
|
||||
let explorer_collapsed = project.elements.values().filter_map(|e| e.parent).collect();
|
||||
let mut app = Self {
|
||||
allocation_drag: Default::default(),
|
||||
home: Default::default(),
|
||||
recovery: Default::default(),
|
||||
recent_target: None,
|
||||
@@ -1060,11 +1064,21 @@ impl App {
|
||||
window::close_requests().map(|id| Message::Request(Pending::Close(id))),
|
||||
window::resize_events().map(|(_, size)| Message::WindowResized(size)),
|
||||
architecture_authoring::subscription(self),
|
||||
iced::event::listen_with(|event, _, _| {
|
||||
matches!(
|
||||
event,
|
||||
iced::Event::Keyboard(keyboard::Event::KeyPressed { .. })
|
||||
)
|
||||
.then_some(Message::WorkDrag(allocation_drag::Event::KeyboardBoundary))
|
||||
}),
|
||||
behavior::creation::subscription(
|
||||
self.behavior.creation.has_pending() || self.behavior.source_active(),
|
||||
)
|
||||
.map(|()| Message::Escape),
|
||||
iced::event::listen_with(|event, status, _| {
|
||||
if matches!(event, iced::Event::Window(window::Event::Unfocused)) {
|
||||
return Some(Message::WorkDrag(allocation_drag::Event::Unfocused));
|
||||
}
|
||||
let iced::Event::Keyboard(keyboard::Event::KeyPressed {
|
||||
key,
|
||||
modifiers: mods,
|
||||
@@ -1108,6 +1122,11 @@ impl App {
|
||||
])
|
||||
}
|
||||
pub fn update(&mut self, message: Message) -> Task<Message> {
|
||||
self.allocation_before(&message);
|
||||
if let Message::WorkDrag(event) = message {
|
||||
return self.allocation_event(event);
|
||||
}
|
||||
let allocation_before = self.allocation_boundary();
|
||||
if let Message::BehaviorControl(intent) = message {
|
||||
return self.behavior_control(intent);
|
||||
}
|
||||
@@ -1118,6 +1137,9 @@ impl App {
|
||||
);
|
||||
let before = self.camera_boundary();
|
||||
let task = self.update_inner(message);
|
||||
if self.allocation_boundary() != allocation_before {
|
||||
self.allocation_retire();
|
||||
}
|
||||
if !camera && self.camera_boundary() != before {
|
||||
self.camera_epoch = self.camera_epoch.wrapping_add(1);
|
||||
self.camera_boundary_epoch = self.canvas_epoch;
|
||||
@@ -1516,6 +1538,7 @@ impl App {
|
||||
}
|
||||
fn handle(&mut self, message: Message) -> Task<Message> {
|
||||
match message {
|
||||
Message::WorkDrag(event) => return self.allocation_event(event),
|
||||
Message::BehaviorControl(intent) => return self.behavior_control(intent),
|
||||
Message::Architecture(event) => return self.architecture_event(event),
|
||||
Message::Home(event) => return self.home_event(event),
|
||||
|
||||
Reference in New Issue
Block a user