mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-30 03:38:12 +08:00
Gradient tool improvements (#927)
* Reuse existing gradient * Double click to insert gradient stop * Add history states to the gradient tool * Do trig in viewport space so it is actually perpendicular * Sync tool options with active gradient * Deleting points with delete key * More tolerance on inserting points
This commit is contained in:
committed by
Keavon Chambers
parent
69293964c4
commit
0d703e857b
@@ -4,6 +4,7 @@ use crate::messages::portfolio::document::utility_types::misc::{AlignAggregate,
|
||||
use crate::messages::prelude::*;
|
||||
|
||||
use document_legacy::boolean_ops::BooleanOperation as BooleanOperationType;
|
||||
use document_legacy::document::Document as DocumentLegacy;
|
||||
use document_legacy::layers::blend_mode::BlendMode;
|
||||
use document_legacy::layers::style::ViewMode;
|
||||
use document_legacy::LayerId;
|
||||
@@ -46,6 +47,10 @@ pub enum DocumentMessage {
|
||||
axis: AlignAxis,
|
||||
aggregate: AlignAggregate,
|
||||
},
|
||||
BackupDocument {
|
||||
document: DocumentLegacy,
|
||||
layer_metadata: HashMap<Vec<LayerId>, LayerMetadata>,
|
||||
},
|
||||
BooleanOperation(BooleanOperationType),
|
||||
ClearLayerTree,
|
||||
CommitTransaction,
|
||||
|
||||
@@ -232,6 +232,7 @@ impl MessageHandler<DocumentMessage, (u64, &InputPreprocessorMessageHandler, &Pe
|
||||
responses.push_back(BroadcastEvent::DocumentIsDirty.into());
|
||||
}
|
||||
}
|
||||
BackupDocument { document, layer_metadata } => self.backup_with_document(document, layer_metadata, responses),
|
||||
BooleanOperation(op) => {
|
||||
// Convert Vec<&[LayerId]> to Vec<Vec<&LayerId>> because Vec<&[LayerId]> does not implement several traits (Debug, Serialize, Deserialize, ...) required by DocumentOperation enum
|
||||
responses.push_back(StartTransaction.into());
|
||||
@@ -1276,9 +1277,10 @@ impl DocumentMessageHandler {
|
||||
.unwrap_or_else(|| panic!("Layer data cannot be found because the path {:?} does not exist", path))
|
||||
}
|
||||
|
||||
pub fn backup(&mut self, responses: &mut VecDeque<Message>) {
|
||||
/// Places a document into the history system
|
||||
fn backup_with_document(&mut self, document: DocumentLegacy, layer_metadata: HashMap<Vec<LayerId>, LayerMetadata>, responses: &mut VecDeque<Message>) {
|
||||
self.document_redo_history.clear();
|
||||
self.document_undo_history.push_back((self.document_legacy.clone(), self.layer_metadata.clone()));
|
||||
self.document_undo_history.push_back((document, layer_metadata));
|
||||
if self.document_undo_history.len() > crate::consts::MAX_UNDO_HISTORY_LEN {
|
||||
self.document_undo_history.pop_front();
|
||||
}
|
||||
@@ -1287,6 +1289,22 @@ impl DocumentMessageHandler {
|
||||
responses.push_back(PortfolioMessage::UpdateOpenDocumentsList.into());
|
||||
}
|
||||
|
||||
/// Copies the entire document into the history system
|
||||
pub fn backup(&mut self, responses: &mut VecDeque<Message>) {
|
||||
self.backup_with_document(self.document_legacy.clone(), self.layer_metadata.clone(), responses);
|
||||
}
|
||||
|
||||
/// Push a message backing up the document in its current state
|
||||
pub fn backup_nonmut(&self, responses: &mut VecDeque<Message>) {
|
||||
responses.push_back(
|
||||
DocumentMessage::BackupDocument {
|
||||
document: self.document_legacy.clone(),
|
||||
layer_metadata: self.layer_metadata.clone(),
|
||||
}
|
||||
.into(),
|
||||
);
|
||||
}
|
||||
|
||||
pub fn rollback(&mut self, responses: &mut VecDeque<Message>) -> Result<(), EditorError> {
|
||||
self.backup(responses);
|
||||
self.undo(responses)
|
||||
|
||||
Reference in New Issue
Block a user