Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disallow the Gradient tool from applying to raster images #2456

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions editor/src/messages/tool/tool_messages/gradient_tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::consts::{LINE_ROTATE_SNAP_ANGLE, MANIPULATOR_GROUP_MARKER_SIZE, SELEC
use crate::messages::portfolio::document::overlays::utility_types::OverlayContext;
use crate::messages::portfolio::document::utility_types::document_metadata::LayerNodeIdentifier;
use crate::messages::tool::common_functionality::auto_panning::AutoPanning;
use crate::messages::tool::common_functionality::graph_modification_utils::get_gradient;
use crate::messages::tool::common_functionality::graph_modification_utils::{NodeGraphLayer, get_gradient};
use crate::messages::tool::common_functionality::snapping::SnapManager;
use graphene_core::vector::style::{Fill, Gradient, GradientType};

Expand Down Expand Up @@ -62,9 +62,16 @@ impl<'a> MessageHandler<ToolMessage, &mut ToolActionHandlerData<'a>> for Gradien
match action {
GradientOptionsUpdate::Type(gradient_type) => {
self.options.gradient_type = gradient_type;
// Update the selected gradient if it exists
if let Some(selected_gradient) = &mut self.data.selected_gradient {
selected_gradient.gradient.gradient_type = gradient_type;
selected_gradient.render_gradient(responses);
// Check if the current layer is a raster layer
if let Some(layer) = selected_gradient.layer {
if NodeGraphLayer::is_raster_layer(layer, &mut tool_data.document.network_interface) {
return; // Don't proceed if it's a raster layer
}
selected_gradient.gradient.gradient_type = gradient_type;
selected_gradient.render_gradient(responses);
}
}
}
}
Expand Down Expand Up @@ -406,6 +413,10 @@ impl Fsm for GradientToolFsmState {

// Apply the gradient to the selected layer
if let Some(layer) = selected_layer {
// Add check for raster layer
if NodeGraphLayer::is_raster_layer(layer, &mut document.network_interface) {
return GradientToolFsmState::Ready;
}
if !document.network_interface.selected_nodes().selected_layers_contains(layer, document.metadata()) {
let nodes = vec![layer.to_node()];

Expand Down
Loading