Remove unused DocumentIsDirty
This commit is contained in:
parent
8df59be1d5
commit
d602603d46
|
|
@ -38,7 +38,6 @@ const SIDE_EFFECT_FREE_MESSAGES: &[MessageDiscriminant] = &[
|
|||
))),
|
||||
MessageDiscriminant::Portfolio(PortfolioMessageDiscriminant::Document(DocumentMessageDiscriminant::DocumentStructureChanged)),
|
||||
MessageDiscriminant::Portfolio(PortfolioMessageDiscriminant::Document(DocumentMessageDiscriminant::Overlays(OverlaysMessageDiscriminant::Draw))),
|
||||
MessageDiscriminant::Broadcast(BroadcastMessageDiscriminant::TriggerEvent(BroadcastEventDiscriminant::DocumentIsDirty)),
|
||||
MessageDiscriminant::Frontend(FrontendMessageDiscriminant::UpdateDocumentLayerStructure),
|
||||
MessageDiscriminant::Frontend(FrontendMessageDiscriminant::TriggerFontLoad),
|
||||
];
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ use serde::{Deserialize, Serialize};
|
|||
#[derive(PartialEq, Eq, Clone, Debug, Serialize, Deserialize, Hash)]
|
||||
#[impl_message(Message, BroadcastMessage, TriggerEvent)]
|
||||
pub enum BroadcastEvent {
|
||||
DocumentIsDirty,
|
||||
CanvasTransformed,
|
||||
ToolAbort,
|
||||
SelectionChanged,
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use serde::{Deserialize, Serialize};
|
|||
pub enum LayoutMessage {
|
||||
ResendActiveWidget {
|
||||
layout_target: LayoutTarget,
|
||||
dirty_id: WidgetId,
|
||||
widget_id: WidgetId,
|
||||
},
|
||||
SendLayout {
|
||||
layout: Layout,
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ pub struct LayoutMessageHandler {
|
|||
|
||||
impl LayoutMessageHandler {
|
||||
/// Get the widget path for the widget with the specified id
|
||||
fn get_widget_path(widget_layout: &WidgetLayout, id: WidgetId) -> Option<(&WidgetHolder, Vec<usize>)> {
|
||||
fn get_widget_path(widget_layout: &WidgetLayout, widget_id: WidgetId) -> Option<(&WidgetHolder, Vec<usize>)> {
|
||||
let mut stack = widget_layout.layout.iter().enumerate().map(|(index, val)| (vec![index], val)).collect::<Vec<_>>();
|
||||
while let Some((mut widget_path, group)) = stack.pop() {
|
||||
match group {
|
||||
|
|
@ -22,7 +22,7 @@ impl LayoutMessageHandler {
|
|||
LayoutGroup::Column { widgets } | LayoutGroup::Row { widgets } => {
|
||||
for (index, widget) in widgets.iter().enumerate() {
|
||||
// Return if this is the correct ID
|
||||
if widget.widget_id == id {
|
||||
if widget.widget_id == widget_id {
|
||||
widget_path.push(index);
|
||||
return Some((widget, widget_path));
|
||||
}
|
||||
|
|
@ -48,11 +48,11 @@ impl<F: Fn(&MessageDiscriminant) -> Vec<KeysGroup>> MessageHandler<LayoutMessage
|
|||
use LayoutMessage::*;
|
||||
#[remain::sorted]
|
||||
match message {
|
||||
ResendActiveWidget { layout_target, dirty_id } => {
|
||||
ResendActiveWidget { layout_target, widget_id } => {
|
||||
// Find the updated diff based on the specified layout target
|
||||
let Some(diff) = (match &self.layouts[layout_target as usize] {
|
||||
Layout::MenuLayout(_) => return,
|
||||
Layout::WidgetLayout(layout) => Self::get_widget_path(layout, dirty_id).map(|(widget, widget_path)| {
|
||||
Layout::WidgetLayout(layout) => Self::get_widget_path(layout, widget_id).map(|(widget, widget_path)| {
|
||||
// Create a widget update diff for the relevant id
|
||||
let new_value = DiffUpdate::Widget(widget.clone());
|
||||
WidgetDiff { widget_path, new_value }
|
||||
|
|
@ -208,7 +208,7 @@ impl<F: Fn(&MessageDiscriminant) -> Vec<KeysGroup>> MessageHandler<LayoutMessage
|
|||
Widget::TextLabel(_) => {}
|
||||
Widget::WorkingColorsInput(_) => {}
|
||||
};
|
||||
responses.add(ResendActiveWidget { layout_target, dirty_id: widget_id });
|
||||
responses.add(ResendActiveWidget { layout_target, widget_id: widget_id });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -344,7 +344,6 @@ impl MessageHandler<DocumentMessage, DocumentInputs<'_>> for DocumentMessageHand
|
|||
skip_rerender: false,
|
||||
});
|
||||
}
|
||||
responses.add(BroadcastEvent::DocumentIsDirty);
|
||||
}
|
||||
BackupDocument { network } => self.backup_with_document(network, responses),
|
||||
ClearLayersPanel => {
|
||||
|
|
@ -384,8 +383,6 @@ impl MessageHandler<DocumentMessage, DocumentInputs<'_>> for DocumentMessageHand
|
|||
for path in self.metadata().shallowest_unique_layers(self.selected_nodes.selected_layers(self.metadata())) {
|
||||
responses.add_front(DocumentMessage::DeleteLayer { id: path.last().unwrap().to_node() });
|
||||
}
|
||||
|
||||
responses.add(BroadcastEvent::DocumentIsDirty);
|
||||
}
|
||||
DeselectAllLayers => {
|
||||
responses.add(NodeGraphMessage::SelectedNodesSet { nodes: vec![] });
|
||||
|
|
@ -425,7 +422,6 @@ impl MessageHandler<DocumentMessage, DocumentInputs<'_>> for DocumentMessageHand
|
|||
skip_rerender: false,
|
||||
});
|
||||
}
|
||||
responses.add(BroadcastEvent::DocumentIsDirty);
|
||||
}
|
||||
}
|
||||
GraphViewOverlay { open } => {
|
||||
|
|
@ -609,7 +605,6 @@ impl MessageHandler<DocumentMessage, DocumentInputs<'_>> for DocumentMessageHand
|
|||
Redo => {
|
||||
responses.add(SelectToolMessage::Abort);
|
||||
responses.add(DocumentMessage::DocumentHistoryForward);
|
||||
responses.add(BroadcastEvent::DocumentIsDirty);
|
||||
responses.add(OverlaysMessage::Draw);
|
||||
}
|
||||
RenameDocument { new_name } => {
|
||||
|
|
@ -788,7 +783,6 @@ impl MessageHandler<DocumentMessage, DocumentInputs<'_>> for DocumentMessageHand
|
|||
self.undo_in_progress = true;
|
||||
responses.add(BroadcastEvent::ToolAbort);
|
||||
responses.add(DocumentMessage::DocumentHistoryBackward);
|
||||
responses.add(BroadcastEvent::DocumentIsDirty);
|
||||
responses.add(OverlaysMessage::Draw);
|
||||
responses.add(DocumentMessage::UndoFinished);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -90,7 +90,6 @@ impl MessageHandler<NavigationMessage, (&DocumentMetadata, Option<[DVec2; 2]>, &
|
|||
ptz.zoom = 1.;
|
||||
}
|
||||
|
||||
responses.add(BroadcastEvent::DocumentIsDirty);
|
||||
responses.add(PortfolioMessage::UpdateDocumentWidgets);
|
||||
self.create_document_transform(ipp.viewport_bounds.center(), &ptz, responses);
|
||||
}
|
||||
|
|
@ -214,13 +213,11 @@ impl MessageHandler<NavigationMessage, (&DocumentMetadata, Option<[DVec2; 2]>, &
|
|||
SetCanvasRotation { angle_radians } => {
|
||||
ptz.tilt = angle_radians;
|
||||
self.create_document_transform(ipp.viewport_bounds.center(), &ptz, responses);
|
||||
responses.add(BroadcastEvent::DocumentIsDirty);
|
||||
responses.add(PortfolioMessage::UpdateDocumentWidgets);
|
||||
}
|
||||
SetCanvasZoom { zoom_factor } => {
|
||||
ptz.zoom = zoom_factor.clamp(VIEWPORT_ZOOM_SCALE_MIN, VIEWPORT_ZOOM_SCALE_MAX);
|
||||
ptz.zoom *= Self::clamp_zoom(ptz.zoom, document_bounds, old_zoom, ipp);
|
||||
responses.add(BroadcastEvent::DocumentIsDirty);
|
||||
responses.add(PortfolioMessage::UpdateDocumentWidgets);
|
||||
self.create_document_transform(ipp.viewport_bounds.center(), &ptz, responses);
|
||||
}
|
||||
|
|
@ -246,7 +243,6 @@ impl MessageHandler<NavigationMessage, (&DocumentMetadata, Option<[DVec2; 2]>, &
|
|||
ptz.tilt = self.snapped_angle(ptz.tilt);
|
||||
ptz.zoom = self.snapped_scale(ptz.zoom);
|
||||
responses.add(BroadcastEvent::CanvasTransformed);
|
||||
responses.add(BroadcastEvent::DocumentIsDirty);
|
||||
responses.add(ToolMessage::UpdateCursor);
|
||||
responses.add(ToolMessage::UpdateHints);
|
||||
self.transform_operation = TransformOperation::None;
|
||||
|
|
@ -261,7 +257,6 @@ impl MessageHandler<NavigationMessage, (&DocumentMetadata, Option<[DVec2; 2]>, &
|
|||
|
||||
ptz.pan += transformed_delta;
|
||||
responses.add(BroadcastEvent::CanvasTransformed);
|
||||
responses.add(BroadcastEvent::DocumentIsDirty);
|
||||
self.create_document_transform(ipp.viewport_bounds.center(), &ptz, responses);
|
||||
}
|
||||
TranslateCanvasBegin => {
|
||||
|
|
@ -278,7 +273,6 @@ impl MessageHandler<NavigationMessage, (&DocumentMetadata, Option<[DVec2; 2]>, &
|
|||
let transformed_delta = metadata.document_to_viewport.inverse().transform_vector2(delta * ipp.viewport_bounds.size());
|
||||
|
||||
ptz.pan += transformed_delta;
|
||||
responses.add(BroadcastEvent::DocumentIsDirty);
|
||||
self.create_document_transform(ipp.viewport_bounds.center(), &ptz, responses);
|
||||
}
|
||||
WheelCanvasTranslate { use_y_as_x } => {
|
||||
|
|
|
|||
|
|
@ -421,7 +421,6 @@ impl<'a> Selected<'a> {
|
|||
OriginalTransforms::Path(path_transforms) => Self::transform_path(&self.document_metadata, layer, path_transforms.get(&layer), transformation, self.responses),
|
||||
}
|
||||
}
|
||||
self.responses.add(BroadcastEvent::DocumentIsDirty);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -250,7 +250,6 @@ impl MessageHandler<PortfolioMessage, (&InputPreprocessorMessageHandler, &Prefer
|
|||
|
||||
if self.active_document_mut().is_some() {
|
||||
responses.add(NodeGraphMessage::RunDocumentGraph);
|
||||
responses.add(BroadcastEvent::DocumentIsDirty);
|
||||
}
|
||||
}
|
||||
PortfolioMessage::ImaginateCheckServerStatus => {
|
||||
|
|
@ -440,7 +439,6 @@ impl MessageHandler<PortfolioMessage, (&InputPreprocessorMessageHandler, &Prefer
|
|||
responses.add(OverlaysMessage::Draw);
|
||||
responses.add(BroadcastEvent::ToolAbort);
|
||||
responses.add(BroadcastEvent::SelectionChanged);
|
||||
responses.add(BroadcastEvent::DocumentIsDirty);
|
||||
responses.add(PortfolioMessage::UpdateDocumentWidgets);
|
||||
responses.add(NavigationMessage::TranslateCanvas { delta: (0., 0.).into() });
|
||||
responses.add(NodeGraphMessage::RunDocumentGraph);
|
||||
|
|
|
|||
|
|
@ -323,7 +323,7 @@ impl SnapCandidatePoint {
|
|||
pub fn handle(document_point: DVec2) -> Self {
|
||||
Self::new_source(document_point, SnapSource::Geometry(GeometrySnapSource::Sharp))
|
||||
}
|
||||
pub fn handle_neighbours(document_point: DVec2, neighbours: impl Into<Vec<DVec2>>) -> Self {
|
||||
pub fn handle_neighbors(document_point: DVec2, neighbours: impl Into<Vec<DVec2>>) -> Self {
|
||||
let mut point = Self::new_source(document_point, SnapSource::Geometry(GeometrySnapSource::Sharp));
|
||||
point.neighbors = neighbours.into();
|
||||
point
|
||||
|
|
|
|||
|
|
@ -121,9 +121,6 @@ impl MessageHandler<ToolMessage, (&DocumentMessageHandler, DocumentId, &InputPre
|
|||
// Send the SelectionChanged message to the active tool, this will ensure the selection is updated
|
||||
responses.add(BroadcastEvent::SelectionChanged);
|
||||
|
||||
// Send the DocumentIsDirty message to the active tool's sub-tool message handler
|
||||
responses.add(BroadcastEvent::DocumentIsDirty);
|
||||
|
||||
// Update the working colors for the active tool
|
||||
responses.add(BroadcastEvent::WorkingColorChanged);
|
||||
|
||||
|
|
|
|||
|
|
@ -23,8 +23,6 @@ pub enum ArtboardToolMessage {
|
|||
#[remain::unsorted]
|
||||
Abort,
|
||||
#[remain::unsorted]
|
||||
DocumentIsDirty,
|
||||
#[remain::unsorted]
|
||||
Overlays(OverlayContext),
|
||||
|
||||
// Tool-specific messages
|
||||
|
|
@ -77,7 +75,6 @@ impl LayoutHolder for ArtboardTool {
|
|||
impl ToolTransition for ArtboardTool {
|
||||
fn event_to_message_map(&self) -> EventToMessageMap {
|
||||
EventToMessageMap {
|
||||
document_dirty: Some(ArtboardToolMessage::DocumentIsDirty.into()),
|
||||
tool_abort: Some(ArtboardToolMessage::Abort.into()),
|
||||
overlay_provider: Some(|overlay_context| ArtboardToolMessage::Overlays(overlay_context).into()),
|
||||
..Default::default()
|
||||
|
|
@ -129,7 +126,6 @@ impl ArtboardToolData {
|
|||
.click_xray(input.mouse.position)
|
||||
.filter(|&layer| is_layer_fed_by_node_of_name(layer, &document.network, "Artboard"));
|
||||
|
||||
responses.add(BroadcastEvent::DocumentIsDirty);
|
||||
if let Some(intersection) = intersections.next() {
|
||||
self.selected_artboard = Some(intersection);
|
||||
|
||||
|
|
@ -164,8 +160,6 @@ impl ArtboardToolData {
|
|||
location: position.round().as_ivec2(),
|
||||
dimensions: size.round().as_ivec2(),
|
||||
});
|
||||
|
||||
responses.add(BroadcastEvent::DocumentIsDirty);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -231,8 +225,6 @@ impl Fsm for ArtboardToolFsmState {
|
|||
dimensions: size.round().as_ivec2(),
|
||||
});
|
||||
|
||||
responses.add(BroadcastEvent::DocumentIsDirty);
|
||||
|
||||
tool_data.drag_current = mouse_position;
|
||||
}
|
||||
ArtboardToolFsmState::Dragging
|
||||
|
|
@ -283,11 +275,6 @@ impl Fsm for ArtboardToolFsmState {
|
|||
})
|
||||
}
|
||||
|
||||
// Have to put message here instead of when Artboard is created
|
||||
// This might result in a few more calls but it is not reliant on the order of messages
|
||||
|
||||
responses.add(BroadcastEvent::DocumentIsDirty);
|
||||
|
||||
ArtboardToolFsmState::Drawing
|
||||
}
|
||||
(ArtboardToolFsmState::Ready, ArtboardToolMessage::PointerMove { .. }) => {
|
||||
|
|
@ -334,8 +321,6 @@ impl Fsm for ArtboardToolFsmState {
|
|||
if let Some(artboard) = tool_data.selected_artboard.take() {
|
||||
let id = artboard.to_node();
|
||||
responses.add(GraphOperationMessage::DeleteLayer { id });
|
||||
|
||||
responses.add(BroadcastEvent::DocumentIsDirty);
|
||||
}
|
||||
ArtboardToolFsmState::Ready
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,8 +27,6 @@ pub enum GradientToolMessage {
|
|||
#[remain::unsorted]
|
||||
Abort,
|
||||
#[remain::unsorted]
|
||||
DocumentIsDirty,
|
||||
#[remain::unsorted]
|
||||
Overlays(OverlayContext),
|
||||
|
||||
// Tool-specific messages
|
||||
|
|
@ -151,35 +149,6 @@ impl SelectedGradient {
|
|||
}
|
||||
}
|
||||
|
||||
/// Update the selected gradient, checking for removal or change of gradient.
|
||||
pub fn update(gradient: &mut Option<Self>, document: &DocumentMessageHandler, responses: &mut VecDeque<Message>) {
|
||||
let Some(inner_gradient) = gradient else {
|
||||
return;
|
||||
};
|
||||
|
||||
// Clear the gradient if layer deleted
|
||||
if !inner_gradient.layer.exists(document.metadata()) {
|
||||
responses.add(ToolMessage::RefreshToolOptions);
|
||||
*gradient = None;
|
||||
return;
|
||||
};
|
||||
|
||||
// Update transform
|
||||
inner_gradient.transform = gradient_space_transform(inner_gradient.layer, document);
|
||||
|
||||
// Clear if no longer a gradient
|
||||
let Some(gradient) = get_gradient(inner_gradient.layer, &document.network) else {
|
||||
responses.add(ToolMessage::RefreshToolOptions);
|
||||
*gradient = None;
|
||||
return;
|
||||
};
|
||||
|
||||
if gradient.gradient_type != inner_gradient.gradient.gradient_type {
|
||||
responses.add(ToolMessage::RefreshToolOptions);
|
||||
}
|
||||
inner_gradient.gradient = gradient.clone();
|
||||
}
|
||||
|
||||
pub fn with_gradient_start(mut self, start: DVec2) -> Self {
|
||||
self.gradient.start = self.transform.inverse().transform_point2(start);
|
||||
self
|
||||
|
|
@ -250,9 +219,7 @@ impl GradientTool {
|
|||
impl ToolTransition for GradientTool {
|
||||
fn event_to_message_map(&self) -> EventToMessageMap {
|
||||
EventToMessageMap {
|
||||
document_dirty: Some(GradientToolMessage::DocumentIsDirty.into()),
|
||||
tool_abort: Some(GradientToolMessage::Abort.into()),
|
||||
selection_changed: Some(GradientToolMessage::DocumentIsDirty.into()),
|
||||
overlay_provider: Some(|overlay_context| GradientToolMessage::Overlays(overlay_context).into()),
|
||||
..Default::default()
|
||||
}
|
||||
|
|
@ -280,13 +247,6 @@ impl Fsm for GradientToolFsmState {
|
|||
};
|
||||
|
||||
match (self, event) {
|
||||
(_, GradientToolMessage::DocumentIsDirty) => {
|
||||
if self != GradientToolFsmState::Drawing {
|
||||
SelectedGradient::update(&mut tool_data.selected_gradient, document, responses);
|
||||
}
|
||||
|
||||
self
|
||||
}
|
||||
(_, GradientToolMessage::Overlays(mut overlay_context)) => {
|
||||
let selected = tool_data.selected_gradient.as_ref();
|
||||
|
||||
|
|
@ -395,8 +355,6 @@ impl Fsm for GradientToolFsmState {
|
|||
self
|
||||
}
|
||||
(GradientToolFsmState::Ready, GradientToolMessage::PointerDown) => {
|
||||
responses.add(BroadcastEvent::DocumentIsDirty);
|
||||
|
||||
let mouse = input.mouse.position;
|
||||
tool_data.drag_start = mouse;
|
||||
let tolerance = (MANIPULATOR_GROUP_MARKER_SIZE * 2.).powi(2);
|
||||
|
|
|
|||
|
|
@ -18,10 +18,6 @@ pub enum ImaginateToolMessage {
|
|||
// Standard messages
|
||||
#[remain::unsorted]
|
||||
Abort,
|
||||
#[remain::unsorted]
|
||||
DocumentIsDirty,
|
||||
#[remain::unsorted]
|
||||
SelectionChanged,
|
||||
|
||||
// Tool-specific messages
|
||||
DragStart,
|
||||
|
|
@ -74,9 +70,7 @@ impl ToolMetadata for ImaginateTool {
|
|||
impl ToolTransition for ImaginateTool {
|
||||
fn event_to_message_map(&self) -> EventToMessageMap {
|
||||
EventToMessageMap {
|
||||
document_dirty: Some(ImaginateToolMessage::DocumentIsDirty.into()),
|
||||
tool_abort: Some(ImaginateToolMessage::Abort.into()),
|
||||
selection_changed: Some(ImaginateToolMessage::SelectionChanged.into()),
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
|
@ -112,11 +106,6 @@ impl Fsm for ImaginateToolFsmState {
|
|||
return self;
|
||||
};
|
||||
match (self, event) {
|
||||
(_, ImaginateToolMessage::DocumentIsDirty | ImaginateToolMessage::SelectionChanged) => {
|
||||
//tool_data.path_outlines.update_selected(document.document_legacy.selected_visible_layers(), document, responses, font_cache);
|
||||
|
||||
self
|
||||
}
|
||||
(ImaginateToolFsmState::Ready, ImaginateToolMessage::DragStart) => {
|
||||
shape_data.start(document, input);
|
||||
responses.add(DocumentMessage::StartTransaction);
|
||||
|
|
|
|||
|
|
@ -38,8 +38,6 @@ impl Default for LineOptions {
|
|||
pub enum LineToolMessage {
|
||||
// Standard messages
|
||||
#[remain::unsorted]
|
||||
DocumentIsDirty,
|
||||
#[remain::unsorted]
|
||||
Overlays(OverlayContext),
|
||||
#[remain::unsorted]
|
||||
Abort,
|
||||
|
|
@ -283,8 +281,8 @@ fn generate_transform(tool_data: &mut LineToolData, snap_data: SnapData, lock_an
|
|||
let constrained = snap_angle || lock_angle;
|
||||
let snap = &mut tool_data.snap_manager;
|
||||
|
||||
let near_point = SnapCandidatePoint::handle_neighbours(document_points[1], [tool_data.drag_start]);
|
||||
let far_point = SnapCandidatePoint::handle_neighbours(2. * document_points[0] - document_points[1], [tool_data.drag_start]);
|
||||
let near_point = SnapCandidatePoint::handle_neighbors(document_points[1], [tool_data.drag_start]);
|
||||
let far_point = SnapCandidatePoint::handle_neighbors(2. * document_points[0] - document_points[1], [tool_data.drag_start]);
|
||||
|
||||
if constrained {
|
||||
let constraint = SnapConstraint::Line {
|
||||
|
|
|
|||
|
|
@ -510,8 +510,8 @@ impl PenToolData {
|
|||
origin: relative,
|
||||
direction: document_pos - relative,
|
||||
};
|
||||
let near_point = SnapCandidatePoint::handle_neighbours(document_pos, neighbours.clone());
|
||||
let far_point = SnapCandidatePoint::handle_neighbours(2. * relative - document_pos, neighbours);
|
||||
let near_point = SnapCandidatePoint::handle_neighbors(document_pos, neighbours.clone());
|
||||
let far_point = SnapCandidatePoint::handle_neighbors(2. * relative - document_pos, neighbours);
|
||||
if mirror {
|
||||
let snapped = snap.constrained_snap(&snap_data, &near_point, constraint, None);
|
||||
let snapped_far = snap.constrained_snap(&snap_data, &far_point, constraint, None);
|
||||
|
|
@ -527,8 +527,8 @@ impl PenToolData {
|
|||
snap.update_indicator(snapped);
|
||||
}
|
||||
} else if let Some(relative) = relative.map(|layer| transform.transform_point2(layer)).filter(|_| mirror) {
|
||||
let snapped = snap.free_snap(&snap_data, &SnapCandidatePoint::handle_neighbours(document_pos, neighbours.clone()), None, false);
|
||||
let snapped_far = snap.free_snap(&snap_data, &SnapCandidatePoint::handle_neighbours(2. * relative - document_pos, neighbours), None, false);
|
||||
let snapped = snap.free_snap(&snap_data, &SnapCandidatePoint::handle_neighbors(document_pos, neighbours.clone()), None, false);
|
||||
let snapped_far = snap.free_snap(&snap_data, &SnapCandidatePoint::handle_neighbors(2. * relative - document_pos, neighbours), None, false);
|
||||
document_pos = if snapped_far.other_snap_better(&snapped) {
|
||||
snapped.snapped_point_document
|
||||
} else {
|
||||
|
|
@ -536,7 +536,7 @@ impl PenToolData {
|
|||
};
|
||||
snap.update_indicator(if snapped_far.other_snap_better(&snapped) { snapped } else { snapped_far });
|
||||
} else {
|
||||
let snapped = snap.free_snap(&snap_data, &SnapCandidatePoint::handle_neighbours(document_pos, neighbours), None, false);
|
||||
let snapped = snap.free_snap(&snap_data, &SnapCandidatePoint::handle_neighbors(document_pos, neighbours), None, false);
|
||||
document_pos = snapped.snapped_point_document;
|
||||
snap.update_indicator(snapped);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,10 +59,6 @@ pub enum SelectToolMessage {
|
|||
#[remain::unsorted]
|
||||
Abort,
|
||||
#[remain::unsorted]
|
||||
DocumentIsDirty,
|
||||
#[remain::unsorted]
|
||||
SelectionChanged,
|
||||
#[remain::unsorted]
|
||||
Overlays(OverlayContext),
|
||||
|
||||
// Tool-specific messages
|
||||
|
|
@ -237,9 +233,7 @@ impl<'a> MessageHandler<ToolMessage, &mut ToolActionHandlerData<'a>> for SelectT
|
|||
impl ToolTransition for SelectTool {
|
||||
fn event_to_message_map(&self) -> EventToMessageMap {
|
||||
EventToMessageMap {
|
||||
document_dirty: Some(SelectToolMessage::DocumentIsDirty.into()),
|
||||
tool_abort: Some(SelectToolMessage::Abort.into()),
|
||||
selection_changed: Some(SelectToolMessage::SelectionChanged.into()),
|
||||
overlay_provider: Some(|overlay_context| SelectToolMessage::Overlays(overlay_context).into()),
|
||||
..Default::default()
|
||||
}
|
||||
|
|
@ -589,8 +583,6 @@ impl Fsm for SelectToolFsmState {
|
|||
}
|
||||
(SelectToolFsmState::Dragging, SelectToolMessage::PointerMove { axis_align, duplicate, .. }) => {
|
||||
tool_data.has_dragged = true;
|
||||
// TODO: This is a cheat. Break out the relevant functionality from the handler above and call it from there and here.
|
||||
responses.add_front(SelectToolMessage::DocumentIsDirty);
|
||||
|
||||
let axis_align = input.keyboard.key(axis_align);
|
||||
let mouse_position = axis_align_drag(axis_align, input.mouse.position, tool_data.drag_start);
|
||||
|
|
|
|||
|
|
@ -48,8 +48,6 @@ pub enum TextToolMessage {
|
|||
#[remain::unsorted]
|
||||
Abort,
|
||||
#[remain::unsorted]
|
||||
DocumentIsDirty,
|
||||
#[remain::unsorted]
|
||||
WorkingColorChanged,
|
||||
#[remain::unsorted]
|
||||
Overlays(OverlayContext),
|
||||
|
|
@ -193,11 +191,10 @@ impl ToolTransition for TextTool {
|
|||
fn event_to_message_map(&self) -> EventToMessageMap {
|
||||
EventToMessageMap {
|
||||
canvas_transformed: None,
|
||||
document_dirty: Some(TextToolMessage::DocumentIsDirty.into()),
|
||||
tool_abort: Some(TextToolMessage::Abort.into()),
|
||||
selection_changed: Some(TextToolMessage::DocumentIsDirty.into()),
|
||||
working_color_changed: Some(TextToolMessage::WorkingColorChanged.into()),
|
||||
overlay_provider: Some(|overlay_context| TextToolMessage::Overlays(overlay_context).into()),
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -101,7 +101,6 @@ impl<'a> MessageHandler<TransformLayerMessage, TransformData<'a>> for TransformL
|
|||
self.transform_operation = TransformOperation::None;
|
||||
|
||||
responses.add(ToolMessage::UpdateHints);
|
||||
responses.add(BroadcastEvent::DocumentIsDirty);
|
||||
responses.add(NodeGraphMessage::RunDocumentGraph);
|
||||
}
|
||||
BeginGrab => {
|
||||
|
|
@ -119,7 +118,6 @@ impl<'a> MessageHandler<TransformLayerMessage, TransformData<'a>> for TransformL
|
|||
self.transform_operation = TransformOperation::Grabbing(Default::default());
|
||||
|
||||
selected.original_transforms.clear();
|
||||
responses.add(BroadcastEvent::DocumentIsDirty);
|
||||
}
|
||||
BeginRotate => {
|
||||
if let TransformOperation::Rotating(_) = self.transform_operation {
|
||||
|
|
@ -136,7 +134,6 @@ impl<'a> MessageHandler<TransformLayerMessage, TransformData<'a>> for TransformL
|
|||
self.transform_operation = TransformOperation::Rotating(Default::default());
|
||||
|
||||
selected.original_transforms.clear();
|
||||
responses.add(BroadcastEvent::DocumentIsDirty);
|
||||
}
|
||||
BeginScale => {
|
||||
if let TransformOperation::Scaling(_) = self.transform_operation {
|
||||
|
|
@ -153,7 +150,6 @@ impl<'a> MessageHandler<TransformLayerMessage, TransformData<'a>> for TransformL
|
|||
self.transform_operation = TransformOperation::Scaling(Default::default());
|
||||
|
||||
selected.original_transforms.clear();
|
||||
responses.add(BroadcastEvent::DocumentIsDirty);
|
||||
}
|
||||
CancelTransformOperation => {
|
||||
selected.revert_operation();
|
||||
|
|
@ -164,7 +160,6 @@ impl<'a> MessageHandler<TransformLayerMessage, TransformData<'a>> for TransformL
|
|||
self.transform_operation = TransformOperation::None;
|
||||
|
||||
responses.add(ToolMessage::UpdateHints);
|
||||
responses.add(BroadcastEvent::DocumentIsDirty);
|
||||
}
|
||||
ConstrainX => self.transform_operation.constrain_axis(Axis::X, &mut selected, self.snap),
|
||||
ConstrainY => self.transform_operation.constrain_axis(Axis::Y, &mut selected, self.snap),
|
||||
|
|
|
|||
|
|
@ -168,7 +168,6 @@ impl DocumentToolData {
|
|||
#[derive(Clone, Debug, Default)]
|
||||
pub struct EventToMessageMap {
|
||||
pub canvas_transformed: Option<ToolMessage>,
|
||||
pub document_dirty: Option<ToolMessage>,
|
||||
pub selection_changed: Option<ToolMessage>,
|
||||
pub tool_abort: Option<ToolMessage>,
|
||||
pub working_color_changed: Option<ToolMessage>,
|
||||
|
|
@ -190,7 +189,6 @@ pub trait ToolTransition {
|
|||
|
||||
let event_to_tool_map = self.event_to_message_map();
|
||||
subscribe_message(event_to_tool_map.canvas_transformed, BroadcastEvent::CanvasTransformed);
|
||||
subscribe_message(event_to_tool_map.document_dirty, BroadcastEvent::DocumentIsDirty);
|
||||
subscribe_message(event_to_tool_map.tool_abort, BroadcastEvent::ToolAbort);
|
||||
subscribe_message(event_to_tool_map.selection_changed, BroadcastEvent::SelectionChanged);
|
||||
subscribe_message(event_to_tool_map.working_color_changed, BroadcastEvent::WorkingColorChanged);
|
||||
|
|
@ -211,7 +209,6 @@ pub trait ToolTransition {
|
|||
|
||||
let event_to_tool_map = self.event_to_message_map();
|
||||
unsubscribe_message(event_to_tool_map.canvas_transformed, BroadcastEvent::CanvasTransformed);
|
||||
unsubscribe_message(event_to_tool_map.document_dirty, BroadcastEvent::DocumentIsDirty);
|
||||
unsubscribe_message(event_to_tool_map.tool_abort, BroadcastEvent::ToolAbort);
|
||||
unsubscribe_message(event_to_tool_map.selection_changed, BroadcastEvent::SelectionChanged);
|
||||
unsubscribe_message(event_to_tool_map.working_color_changed, BroadcastEvent::WorkingColorChanged);
|
||||
|
|
|
|||
|
|
@ -555,7 +555,6 @@ impl NodeGraphExecutor {
|
|||
responses.extend(existing_responses);
|
||||
responses.add(NodeGraphMessage::UpdateTypes { resolved_types, node_graph_errors });
|
||||
responses.add(NodeGraphMessage::SendGraph);
|
||||
responses.add(BroadcastEvent::DocumentIsDirty);
|
||||
responses.add(OverlaysMessage::Draw);
|
||||
|
||||
let Ok(node_graph_output) = result else {
|
||||
|
|
|
|||
Loading…
Reference in New Issue