Skip to content
Draft
Show file tree
Hide file tree
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
37 changes: 37 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ graphic-types = { path = "node-graph/libraries/graphic-types" }
brush-types = { path = "node-graph/libraries/brush-types" }
rendering = { path = "node-graph/libraries/rendering" }
brush-nodes = { path = "node-graph/nodes/brush" }
gradient-nodes = { path = "node-graph/nodes/gradient" }
blending-nodes = { path = "node-graph/nodes/blending" }
graphene-core = { path = "node-graph/nodes/gcore" }
graphic-nodes = { path = "node-graph/nodes/graphic" }
Expand All @@ -108,6 +109,7 @@ graphite-proc-macros = { path = "proc-macros" }
graphite-editor = { path = "editor" }
graphene-canvas-utils = { path = "node-graph/libraries/canvas-utils" }
ipsum = { path = "libraries/ipsum" }
graphene-cache = { path = "node-graph/libraries/graphene-cache" }

# Workspace dependencies
rustc-hash = "2.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,30 @@ impl PreferencesDialogMessageHandler {
.widget_instance(),
];

rows.extend_from_slice(&[header, node_graph_wires_label, graph_wire_style, brush_tool]);
let checkbox_id = CheckboxId::new();
let mesh_gradient_tool_description = "
Enable the Mesh Gradient tool.\n\
\n\
*Default: Off.*
"
.trim();
let mesh_gradient_tool = vec![
Separator::new(SeparatorStyle::Unrelated).widget_instance(),
Separator::new(SeparatorStyle::Unrelated).widget_instance(),
CheckboxInput::new(preferences.mesh_gradient_tool)
.tooltip_label("Mesh Gradient Tool")
.tooltip_description(mesh_gradient_tool_description)
.on_update(|checkbox_input: &CheckboxInput| PreferencesMessage::MeshGradientTool { enabled: checkbox_input.checked }.into())
.for_label(checkbox_id)
.widget_instance(),
TextLabel::new("Mesh Gradient Tool")
.tooltip_label("Mesh Gradient Tool")
.tooltip_description(mesh_gradient_tool_description)
.for_checkbox(checkbox_id)
.widget_instance(),
];

rows.extend_from_slice(&[header, node_graph_wires_label, graph_wire_style, brush_tool, mesh_gradient_tool]);
}

// =========
Expand Down
10 changes: 10 additions & 0 deletions editor/src/messages/input_mapper/input_mappings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,16 @@ pub fn input_mappings(zoom_with_scroll: bool) -> Mapping {
entry!(KeyDown(MouseRight); action_dispatch=GradientToolMessage::Abort),
entry!(KeyDown(Escape); action_dispatch=GradientToolMessage::Abort),
//
// MeshGradientToolMessage
entry!(DoubleClick(MouseButton::Left); action_dispatch=MeshGradientToolMessage::DoubleClick),
entry!(KeyDown(MouseLeft); action_dispatch=MeshGradientToolMessage::PointerDown),
entry!(PointerMove; refresh_keys=[Shift], action_dispatch=MeshGradientToolMessage::PointerMove { constrain_axis: Shift }),
entry!(KeyUp(MouseLeft); action_dispatch=MeshGradientToolMessage::PointerUp),
entry!(KeyDown(Delete); action_dispatch=MeshGradientToolMessage::DeleteEdge),
entry!(KeyDown(Backspace); action_dispatch=MeshGradientToolMessage::DeleteEdge),
entry!(KeyDown(MouseRight); action_dispatch=MeshGradientToolMessage::Abort),
entry!(KeyDown(Escape); action_dispatch=MeshGradientToolMessage::Abort),
//
// ShapeToolMessage
entry!(KeyDown(MouseLeft); action_dispatch=ShapeToolMessage::DragStart),
entry!(KeyUp(MouseLeft); action_dispatch=ShapeToolMessage::DragStop),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use graphene_std::raster::{
AdjustmentChannel, CellularDistanceFunction, CellularReturnType, DesaturateMethod, DomainWarpType, FractalType, HueSaturationRange, NoiseType, RedGreenBlue, RedGreenBlueAlpha, RelativeAbsolute,
SelectiveColorChoice, TonalRange,
};
use graphene_std::raster_types::{CPU, GPU, Raster};
use graphene_std::raster_types::{CPU, GPU, Raster, Texture};
use graphene_std::text::TextAlign;
use graphene_std::text_nodes::{StringCapitalization, TextDenomination};
use graphene_std::transfer_curve::TransferCurve;
Expand All @@ -30,7 +30,8 @@ use graphene_std::vector::misc::{
SpiralType,
};
use graphene_std::vector::style::{
DashPattern, FillChoice, GradientForm, GradientHueDirection, GradientInterpolation, GradientRamp, GradientSettings, GradientSpace, GradientSpread, StrokeAlign, StrokeCap, StrokeJoin,
DashPattern, FillChoice, GradientForm, GradientHueDirection, GradientInterpolation, GradientRamp, GradientSettings, GradientSpace, GradientSpread, MeshGradient, MeshGradientSvgMethod,
StrokeAlign, StrokeCap, StrokeJoin,
};
use graphene_std::vector::{QRCodeErrorCorrectionLevel, Vector};
use graphene_std::{Appearance, Artboard, Color, Context, Cover, Coverage, Graphic};
Expand Down Expand Up @@ -213,6 +214,7 @@ fn generate_layout(introspected_data: &Arc<dyn std::any::Any + Send + Sync + 'st
List<Raster<GPU>>,
List<Color>,
List<Gradient>,
List<MeshGradient>,
List<String>,
List<f64>,
List<i32>,
Expand Down Expand Up @@ -270,6 +272,7 @@ fn generate_layout(introspected_data: &Arc<dyn std::any::Any + Send + Sync + 'st
Item<Raster<GPU>>,
Item<Color>,
Item<Gradient>,
Item<MeshGradient>,
Item<String>,
Item<f64>,
Item<i32>,
Expand Down Expand Up @@ -634,6 +637,7 @@ impl TableItemLayout for Graphic {
Self::RasterGPU(item) => item.identifier(),
Self::Color(item) => item.identifier(),
Self::Gradient(item) => item.identifier(),
Self::MeshGradient(item) => item.identifier(),
Self::Text(item) => item.identifier(),
Self::NoneList(list) => list.identifier(),
Self::GraphicList(list) => list.identifier(),
Expand All @@ -642,6 +646,7 @@ impl TableItemLayout for Graphic {
Self::RasterGPUList(list) => list.identifier(),
Self::ColorList(list) => list.identifier(),
Self::GradientList(list) => list.identifier(),
Self::MeshGradientList(list) => list.identifier(),
Self::TextList(list) => list.identifier(),
Self::StrokeList(list) => list.identifier(),
}
Expand All @@ -659,6 +664,7 @@ impl TableItemLayout for Graphic {
Self::RasterGPU(item) => item.layout_with_breadcrumb(data),
Self::Color(item) => item.layout_with_breadcrumb(data),
Self::Gradient(item) => item.layout_with_breadcrumb(data),
Self::MeshGradient(item) => item.layout_with_breadcrumb(data),
Self::Text(item) => item.layout_with_breadcrumb(data),
Self::NoneList(list) => list.layout_with_breadcrumb(data),
Self::GraphicList(list) => list.layout_with_breadcrumb(data),
Expand All @@ -667,6 +673,7 @@ impl TableItemLayout for Graphic {
Self::RasterGPUList(list) => list.layout_with_breadcrumb(data),
Self::ColorList(list) => list.layout_with_breadcrumb(data),
Self::GradientList(list) => list.layout_with_breadcrumb(data),
Self::MeshGradientList(list) => list.layout_with_breadcrumb(data),
Self::TextList(list) => list.layout_with_breadcrumb(data),
Self::StrokeList(list) => list.layout_with_breadcrumb(data),
}
Expand Down Expand Up @@ -784,6 +791,48 @@ impl TableItemLayout for Raster<GPU> {
}
}

impl TableItemLayout for Texture {
fn type_name() -> &'static str {
"Texture"
}
fn identifier(&self) -> String {
format!("Texture ({} x {})", self.width(), self.height())
}
fn value_page(&self, _data: &mut LayoutData) -> Vec<LayoutGroup> {
let widgets = vec![TextLabel::new("This texture is stored on the GPU. It currently cannot be displayed here.").widget_instance()];
vec![LayoutGroup::row(widgets)]
}
}

impl TableItemLayout for Option<Item<Texture>> {
fn type_name() -> &'static str {
"Option<Item<Texture>>"
}
fn identifier(&self) -> String {
match self {
Some(texture) => format!("Some({})", texture.identifier()),
None => "None".to_string(),
}
}
fn value_widgets(&self, target: PathStep, _data: &LayoutData) -> Vec<WidgetInstance> {
match self {
Some(_) => vec![
TextButton::new(self.identifier())
.on_update(move |_| DataPanelMessage::PushToElementPath { step: target.clone() }.into())
.narrow(true)
.widget_instance(),
],
None => vec![TextLabel::new("None").narrow(true).widget_instance()],
}
}
fn value_page(&self, data: &mut LayoutData) -> Vec<LayoutGroup> {
match self {
Some(texture) => texture.layout_with_breadcrumb(data),
None => label("None"),
}
}
}

impl TableItemLayout for Color {
fn type_name() -> &'static str {
"Color"
Expand Down Expand Up @@ -836,6 +885,33 @@ impl TableItemLayout for Gradient {
}
}

impl TableItemLayout for MeshGradient {
fn type_name() -> &'static str {
"MeshGradient"
}
fn identifier(&self) -> String {
format!("MeshGradient ({} corners)", self.size())
}
fn value_page(&self, data: &mut LayoutData) -> Vec<LayoutGroup> {
let mut rows = vec![column_headings(&["corner", "point ID", "position", "color"])];
rows.extend(self.corners().map(|corner| {
vec![
TextLabel::new(format!("{}", corner.index)).narrow(true).widget_instance(),
TextLabel::new(format!("{}", corner.point_id.inner())).narrow(true).widget_instance(),
TextLabel::new(format!("{}", corner.position)).narrow(true).widget_instance(),
corner
.color
.value_widgets(PathStep::Element(corner.index), data)
.into_iter()
.next()
.expect("Color always provides one value widget"),
]
}));

vec![LayoutGroup::table(rows, false)]
}
}

macro_rules! impl_table_item_layout_for_number {
($($ty:ty => $type_name:literal),* $(,)?) => {
$(
Expand Down Expand Up @@ -1069,6 +1145,7 @@ impl_table_item_layout_for_choice_enum!(
GradientSpace,
GradientHueDirection,
GradientInterpolation,
MeshGradientSvgMethod,
StrokeJoin,
StrokeAlign,
StrokeCap,
Expand Down Expand Up @@ -1255,6 +1332,7 @@ macro_rules! known_item_types {
List<Raster<GPU>>,
List<Color>,
List<Gradient>,
List<MeshGradient>,
List<String>,
List<f64>,
Gradient,
Expand All @@ -1275,6 +1353,7 @@ macro_rules! known_item_types {
Vector,
Raster<CPU>,
Raster<GPU>,
Option<Item<Texture>>,
Graphic,
Artboard,
Appearance,
Expand All @@ -1289,6 +1368,7 @@ macro_rules! known_item_types {
GradientSpace,
GradientHueDirection,
GradientInterpolation,
MeshGradientSvgMethod,
StrokeJoin,
StrokeAlign,
StrokeCap,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use graph_craft::document::NodeId;
use graphene_std::Color;
use graphene_std::raster::BlendMode;
use graphene_std::text::{Font, TypesettingConfig};
use graphene_std::vector::MeshGradientSurface;
use graphene_std::vector::style::{GradientForm, GradientHueDirection, GradientInterpolation, GradientSettings, GradientSpace, GradientSpread, PaintOrder, Stroke};
use graphene_std::vector::{Gradient, VectorModificationType};
use std::sync::Arc;
Expand Down Expand Up @@ -75,6 +76,10 @@ pub enum GraphOperationMessage {
layer: LayerNodeIdentifier,
gradient_interpolation: GradientInterpolation,
},
MeshGradientSet {
layer: LayerNodeIdentifier,
mesh_gradient: MeshGradientSurface,
},
OpacitySet {
layer: LayerNodeIdentifier,
opacity: f64,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@ impl MessageHandler<GraphOperationMessage, GraphOperationMessageContext<'_>> for
modify_inputs.gradient_interpolation_set(gradient_interpolation);
}
}
GraphOperationMessage::MeshGradientSet { layer, mesh_gradient } => {
if let Some(mut modify_inputs) = ModifyInputsContext::new_with_layer(layer, network_interface, responses) {
modify_inputs.mesh_gradient_set(mesh_gradient);
}
}
GraphOperationMessage::OpacitySet { layer, opacity } => {
if let Some(mut modify_inputs) = ModifyInputsContext::new_with_layer(layer, network_interface, responses) {
modify_inputs.opacity_set(opacity);
Expand Down
Loading