mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-16 06:38:03 +08:00
Gradient Tool (#546)
* Refactor to support fill enum & svg defs * Init tool * Fix advertise * Gradient tool click and drag * Overlays * Drag overlays * Cleanup * Fix transform on elongated shapes * Snap rotate * Snapping * Add hints * Rename to solid * Code review changes Co-authored-by: Keavon Chambers <keavon@keavon.com>
This commit is contained in:
committed by
Keavon Chambers
parent
8bf1289429
commit
93dffb8741
@@ -30,7 +30,7 @@ impl MessageHandler<ArtboardMessage, ()> for ArtboardMessageHandler {
|
||||
match message {
|
||||
// Sub-messages
|
||||
#[remain::unsorted]
|
||||
DispatchOperation(operation) => match self.artboards_graphene_document.handle_operation(&operation) {
|
||||
DispatchOperation(operation) => match self.artboards_graphene_document.handle_operation(*operation) {
|
||||
Ok(_) => (),
|
||||
Err(e) => log::error!("Artboard Error: {:?}", e),
|
||||
},
|
||||
@@ -46,7 +46,7 @@ impl MessageHandler<ArtboardMessage, ()> for ArtboardMessageHandler {
|
||||
path: vec![artboard_id],
|
||||
insert_index: -1,
|
||||
transform: DAffine2::from_scale_angle_translation(size.into(), 0., position.into()).to_cols_array(),
|
||||
style: style::PathStyle::new(None, Some(Fill::new(Color::WHITE))),
|
||||
style: style::PathStyle::new(None, Fill::solid(Color::WHITE)),
|
||||
}
|
||||
.into(),
|
||||
)
|
||||
|
||||
@@ -628,7 +628,7 @@ impl MessageHandler<DocumentMessage, &InputPreprocessorMessageHandler> for Docum
|
||||
match message {
|
||||
// Sub-messages
|
||||
#[remain::unsorted]
|
||||
DispatchOperation(op) => match self.graphene_document.handle_operation(&op) {
|
||||
DispatchOperation(op) => match self.graphene_document.handle_operation(*op) {
|
||||
Ok(Some(document_responses)) => {
|
||||
for response in document_responses {
|
||||
match &response {
|
||||
|
||||
@@ -26,15 +26,17 @@ pub fn layer_panel_entry(layer_metadata: &LayerMetadata, transform: DAffine2, la
|
||||
let arr = arr.iter().map(|x| (*x).into()).collect::<Vec<(f64, f64)>>();
|
||||
|
||||
let mut thumbnail = String::new();
|
||||
layer.data.clone().render(&mut thumbnail, &mut vec![transform], ViewMode::Normal);
|
||||
let mut svg_defs = String::new();
|
||||
layer.data.clone().render(&mut thumbnail, &mut svg_defs, &mut vec![transform], ViewMode::Normal);
|
||||
let transform = transform.to_cols_array().iter().map(ToString::to_string).collect::<Vec<_>>().join(",");
|
||||
let thumbnail = if let [(x_min, y_min), (x_max, y_max)] = arr.as_slice() {
|
||||
format!(
|
||||
r#"<svg xmlns="http://www.w3.org/2000/svg" viewBox="{} {} {} {}"><g transform="matrix({})">{}</g></svg>"#,
|
||||
r#"<svg xmlns="http://www.w3.org/2000/svg" viewBox="{} {} {} {}"><defs>{}</defs><g transform="matrix({})">{}</g></svg>"#,
|
||||
x_min,
|
||||
y_min,
|
||||
x_max - x_min,
|
||||
y_max - y_min,
|
||||
svg_defs,
|
||||
transform,
|
||||
thumbnail,
|
||||
)
|
||||
|
||||
@@ -17,7 +17,7 @@ impl MessageHandler<OverlaysMessage, bool> for OverlaysMessageHandler {
|
||||
match message {
|
||||
// Sub-messages
|
||||
#[remain::unsorted]
|
||||
DispatchOperation(operation) => match self.overlays_graphene_document.handle_operation(&operation) {
|
||||
DispatchOperation(operation) => match self.overlays_graphene_document.handle_operation(*operation) {
|
||||
Ok(_) => responses.push_back(OverlaysMessage::Rerender.into()),
|
||||
Err(e) => log::error!("OverlaysError: {:?}", e),
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user