Skip to content

Commit 9a38e02

Browse files
committed
Final changes for merge!
1 parent 02c31d9 commit 9a38e02

31 files changed

+419
-676
lines changed

demo-artwork/isometric-fountain.graphite

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demo-artwork/painted-dreams.graphite

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demo-artwork/procedural-string-lights.graphite

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demo-artwork/red-dress.graphite

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

demo-artwork/valley-of-spires.graphite

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

editor/src/messages/portfolio/document/document_message_handler.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -726,9 +726,6 @@ impl MessageHandler<DocumentMessage, DocumentMessageData<'_>> for DocumentMessag
726726
let center_in_viewport = DAffine2::from_translation(document_to_viewport.inverse().transform_point2(viewport_location - ipp.viewport_bounds.top_left));
727727
let center_in_viewport_layerspace = center_in_viewport;
728728

729-
// Scale the image to fit into a 512x512 box
730-
let image_size = image_size / DVec2::splat((image_size.max_element() / 512.).max(1.));
731-
732729
// Make layer the size of the image
733730
let fit_image_size = DAffine2::from_scale_angle_translation(image_size, 0., image_size / -2.);
734731

editor/src/messages/portfolio/document/node_graph/document_node_definitions.rs

Lines changed: 51 additions & 343 deletions
Large diffs are not rendered by default.

editor/src/messages/portfolio/document/node_graph/node_properties.rs

Lines changed: 25 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ pub(crate) fn property_from_type(
113113
match concrete_type.alias.as_ref().map(|x| x.as_ref()) {
114114
// Aliased types (ambiguous values)
115115
Some("Percentage") => number_widget(document_node, node_id, index, name, number_input.percentage().min(min(0.)).max(max(100.)), true).into(),
116+
Some("SignedPercentage") => number_widget(document_node, node_id, index, name, number_input.percentage().min(min(-100.)).max(max(100.)), true).into(),
116117
Some("Angle") => number_widget(document_node, node_id, index, name, number_input.mode_range().min(min(-180.)).max(max(180.)).unit("°"), true).into(),
117118
Some("PixelLength") => number_widget(document_node, node_id, index, name, number_input.min(min(0.)).unit("px"), true).into(),
118119
Some("Length") => number_widget(document_node, node_id, index, name, number_input.min(min(0.)), true).into(),
@@ -1092,45 +1093,6 @@ fn centroid_widget(document_node: &DocumentNode, node_id: NodeId, index: usize)
10921093
LayoutGroup::Row { widgets }
10931094
}
10941095

1095-
pub(crate) fn levels_properties(document_node: &DocumentNode, node_id: NodeId, _context: &mut NodePropertiesContext) -> Vec<LayoutGroup> {
1096-
let input_shadows = number_widget(document_node, node_id, 1, "Shadows", NumberInput::default().mode_range().min(0.).max(100.).unit("%"), true);
1097-
let input_midtones = number_widget(document_node, node_id, 2, "Midtones", NumberInput::default().mode_range().min(0.).max(100.).unit("%"), true);
1098-
let input_highlights = number_widget(document_node, node_id, 3, "Highlights", NumberInput::default().mode_range().min(0.).max(100.).unit("%"), true);
1099-
let output_minimums = number_widget(document_node, node_id, 4, "Output Minimums", NumberInput::default().mode_range().min(0.).max(100.).unit("%"), true);
1100-
let output_maximums = number_widget(document_node, node_id, 5, "Output Maximums", NumberInput::default().mode_range().min(0.).max(100.).unit("%"), true);
1101-
1102-
vec![
1103-
LayoutGroup::Row { widgets: input_shadows },
1104-
LayoutGroup::Row { widgets: input_midtones },
1105-
LayoutGroup::Row { widgets: input_highlights },
1106-
LayoutGroup::Row { widgets: output_minimums },
1107-
LayoutGroup::Row { widgets: output_maximums },
1108-
]
1109-
}
1110-
1111-
pub(crate) fn black_and_white_properties(document_node: &DocumentNode, node_id: NodeId, _context: &mut NodePropertiesContext) -> Vec<LayoutGroup> {
1112-
const MIN: f64 = -200.;
1113-
const MAX: f64 = 300.;
1114-
// TODO: Add tint color (blended above using the "Color" blend mode)
1115-
let tint = color_widget(document_node, node_id, 1, "Tint", ColorButton::default(), true);
1116-
let r_weight = number_widget(document_node, node_id, 2, "Reds", NumberInput::default().mode_range().min(MIN).max(MAX).unit("%"), true);
1117-
let y_weight = number_widget(document_node, node_id, 3, "Yellows", NumberInput::default().mode_range().min(MIN).max(MAX).unit("%"), true);
1118-
let g_weight = number_widget(document_node, node_id, 4, "Greens", NumberInput::default().mode_range().min(MIN).max(MAX).unit("%"), true);
1119-
let c_weight = number_widget(document_node, node_id, 5, "Cyans", NumberInput::default().mode_range().min(MIN).max(MAX).unit("%"), true);
1120-
let b_weight = number_widget(document_node, node_id, 6, "Blues", NumberInput::default().mode_range().min(MIN).max(MAX).unit("%"), true);
1121-
let m_weight = number_widget(document_node, node_id, 7, "Magentas", NumberInput::default().mode_range().min(MIN).max(MAX).unit("%"), true);
1122-
1123-
vec![
1124-
tint,
1125-
LayoutGroup::Row { widgets: r_weight },
1126-
LayoutGroup::Row { widgets: y_weight },
1127-
LayoutGroup::Row { widgets: g_weight },
1128-
LayoutGroup::Row { widgets: c_weight },
1129-
LayoutGroup::Row { widgets: b_weight },
1130-
LayoutGroup::Row { widgets: m_weight },
1131-
]
1132-
}
1133-
11341096
pub(crate) fn load_image_properties(document_node: &DocumentNode, node_id: NodeId, _context: &mut NodePropertiesContext) -> Vec<LayoutGroup> {
11351097
let url = text_widget(document_node, node_id, 1, "URL", true);
11361098

@@ -1300,14 +1262,34 @@ pub(crate) fn noise_pattern_properties(document_node: &DocumentNode, node_id: No
13001262
}
13011263

13021264
pub(crate) fn brightness_contrast_properties(document_node: &DocumentNode, node_id: NodeId, _context: &mut NodePropertiesContext) -> Vec<LayoutGroup> {
1303-
let brightness = number_widget(document_node, node_id, 1, "Brightness", NumberInput::default().min(-150.).max(150.), true);
1304-
let contrast = number_widget(document_node, node_id, 2, "Contrast", NumberInput::default().min(-100.).max(100.), true);
1305-
let use_legacy = bool_widget(document_node, node_id, 3, "Use Legacy", CheckboxInput::default(), true);
1265+
let is_use_classic = match &document_node.inputs[3].as_value() {
1266+
Some(&TaggedValue::Bool(value)) => value,
1267+
_ => false,
1268+
};
1269+
let ((b_min, b_max), (c_min, c_max)) = if is_use_classic { ((-100., 100.), (-100., 100.)) } else { ((-100., 150.), (-50., 100.)) };
1270+
1271+
let brightness = number_widget(
1272+
document_node,
1273+
node_id,
1274+
1,
1275+
"Brightness",
1276+
NumberInput::default().mode_range().range_min(Some(b_min)).range_max(Some(b_max)).unit("%").display_decimal_places(2),
1277+
true,
1278+
);
1279+
let contrast = number_widget(
1280+
document_node,
1281+
node_id,
1282+
2,
1283+
"Contrast",
1284+
NumberInput::default().mode_range().range_min(Some(c_min)).range_max(Some(c_max)).unit("%").display_decimal_places(2),
1285+
true,
1286+
);
1287+
let use_classic = bool_widget(document_node, node_id, 3, "Use Classic", CheckboxInput::default(), true);
13061288

13071289
vec![
13081290
LayoutGroup::Row { widgets: brightness },
13091291
LayoutGroup::Row { widgets: contrast },
1310-
LayoutGroup::Row { widgets: use_legacy },
1292+
LayoutGroup::Row { widgets: use_classic },
13111293
]
13121294
}
13131295

@@ -2620,11 +2602,3 @@ pub(crate) fn color_fill_properties(document_node: &DocumentNode, node_id: NodeI
26202602
let color = color_widget(document_node, node_id, 1, "Color", ColorButton::default(), true);
26212603
vec![color]
26222604
}
2623-
2624-
pub(crate) fn color_overlay_properties(document_node: &DocumentNode, node_id: NodeId, _context: &mut NodePropertiesContext) -> Vec<LayoutGroup> {
2625-
let color = color_widget(document_node, node_id, 1, "Color", ColorButton::default(), true);
2626-
let blend_mode = blend_mode(document_node, node_id, 2, "Blend Mode", true);
2627-
let opacity = number_widget(document_node, node_id, 3, "Opacity", NumberInput::default().percentage(), true);
2628-
2629-
vec![color, blend_mode, LayoutGroup::Row { widgets: opacity }]
2630-
}

editor/src/messages/portfolio/portfolio_message_handler.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,9 @@ impl MessageHandler<PortfolioMessage, PortfolioMessageData<'_>> for PortfolioMes
465465
// document.network_interface.set_implementation(node_id, &[], document_node.implementation);
466466
// }
467467
document.network_interface.replace_implementation(node_id, &[], document_node.implementation);
468+
document
469+
.network_interface
470+
.replace_implementation_metadata(node_id, &[], node_definition.default_node_template().persistent_node_metadata);
468471
}
469472
let Some(node) = document.network_interface.network(&[]).unwrap().nodes.get(node_id) else {
470473
log::error!("could not get node in deserialize_document");
@@ -528,7 +531,7 @@ impl MessageHandler<PortfolioMessage, PortfolioMessageData<'_>> for PortfolioMes
528531
}
529532
}
530533

531-
// Upgrade construct layer implementation from https://github.com/GraphiteEditor/Graphite/pull/1946
534+
// Upgrade layer implementation from https://github.com/GraphiteEditor/Graphite/pull/1946
532535
if reference == "Merge" || reference == "Artboard" {
533536
let node_definition = crate::messages::portfolio::document::node_graph::document_node_definitions::resolve_document_node_type(reference).unwrap();
534537
let new_merge_node = node_definition.default_node_template();

frontend/src/components/panels/Document.svelte

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,7 @@
461461
<LayoutCol class="table">
462462
{#if rulersVisible}
463463
<LayoutRow class="ruler-or-scrollbar top-ruler">
464+
<LayoutCol class="ruler-corner"></LayoutCol>
464465
<RulerInput origin={rulerOrigin.x} majorMarkSpacing={rulerSpacing} numberInterval={rulerInterval} direction="Horizontal" bind:this={rulerHorizontal} />
465466
</LayoutRow>
466467
{/if}
@@ -653,8 +654,23 @@
653654
flex: 0 0 auto;
654655
}
655656
657+
.ruler-corner {
658+
background: var(--color-2-mildblack);
659+
width: 16px;
660+
position: relative;
661+
662+
&::after {
663+
content: "";
664+
background: var(--color-5-dullgray);
665+
position: absolute;
666+
width: 1px;
667+
height: 1px;
668+
right: 0;
669+
bottom: 0;
670+
}
671+
}
672+
656673
.top-ruler .ruler-input {
657-
padding-left: 16px;
658674
margin-right: 16px;
659675
}
660676

frontend/src/components/widgets/inputs/RulerInput.svelte

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,16 +116,19 @@
116116
<style lang="scss" global>
117117
.ruler-input {
118118
flex: 1 1 100%;
119-
background: var(--color-4-dimgray);
119+
background: var(--color-2-mildblack);
120120
overflow: hidden;
121121
position: relative;
122+
box-sizing: border-box;
122123
123124
&.horizontal {
124125
height: 16px;
126+
border-bottom: 1px solid var(--color-5-dullgray);
125127
}
126128
127129
&.vertical {
128130
width: 16px;
131+
border-right: 1px solid var(--color-5-dullgray);
129132
130133
svg text {
131134
text-anchor: end;
@@ -137,7 +140,7 @@
137140
138141
path {
139142
stroke-width: 1px;
140-
stroke: var(--color-6-lowergray);
143+
stroke: var(--color-5-dullgray);
141144
}
142145
143146
text {

frontend/wasm/src/editor_api.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,7 @@ impl EditorHandle {
735735
for node_id in nodes_to_upgrade {
736736
document
737737
.network_interface
738-
.replace_implementation(&node_id, &[], DocumentNodeImplementation::proto("graphene_core::ConstructArtboardNode"));
738+
.replace_implementation(&node_id, &[], DocumentNodeImplementation::proto("graphene_core::ToArtboardNode"));
739739
document
740740
.network_interface
741741
.add_input(&node_id, &[], TaggedValue::IVec2(glam::IVec2::default()), false, 2, "".to_string());

node-graph/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ Instead of manually implementing the `Node` trait with complex generics, one can
102102

103103
```rs
104104
#[node_macro::node(category("Raster: Adjustments"))]
105-
fn opacity_node(_input: (), #[default(424242)] color: Color,#[min(0.1)] opacity_multiplier: f64) -> Color {
105+
fn opacity(_input: (), #[default(424242)] color: Color,#[min(0.1)] opacity_multiplier: f64) -> Color {
106106
let opacity_multiplier = opacity_multiplier as f32 / 100.;
107107
Color::from_rgbaf32_unchecked(color.r(), color.g(), color.b(), color.a() * opacity_multiplier)
108108
}

node-graph/gcore/src/graphic_element.rs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ use crate::vector::VectorData;
66
use crate::Color;
77

88
use dyn_any::DynAny;
9-
use node_macro::node;
109

1110
use core::ops::{Deref, DerefMut};
1211
use glam::{DAffine2, IVec2};
@@ -227,13 +226,13 @@ impl ArtboardGroup {
227226
Default::default()
228227
}
229228

230-
fn add_artboard(&mut self, artboard: Artboard, node_id: Option<NodeId>) {
229+
fn append_artboard(&mut self, artboard: Artboard, node_id: Option<NodeId>) {
231230
self.artboards.push((artboard, node_id));
232231
}
233232
}
234233

235-
#[node]
236-
async fn construct_layer<F: 'n + Copy + Send>(
234+
#[node_macro::node(category(""))]
235+
async fn layer<F: 'n + Copy + Send>(
237236
#[implementations((), Footprint)] footprint: F,
238237
#[implementations(((), GraphicGroup), (Footprint, GraphicGroup))] stack: impl Node<F, Output = GraphicGroup>,
239238
#[implementations(((), GraphicElement), (Footprint, GraphicElement))] graphic_element: impl Node<F, Output = GraphicElement>,
@@ -254,8 +253,8 @@ async fn construct_layer<F: 'n + Copy + Send>(
254253
stack
255254
}
256255

257-
#[node]
258-
async fn to_graphic_element<F: 'n + Send, Data: Into<GraphicElement> + 'n>(
256+
#[node_macro::node(category("Debug"))]
257+
async fn to_element<F: 'n + Send, Data: Into<GraphicElement> + 'n>(
259258
#[implementations((), (), (), (), Footprint)] footprint: F,
260259
#[implementations(
261260
((), VectorData),
@@ -272,8 +271,8 @@ async fn to_graphic_element<F: 'n + Send, Data: Into<GraphicElement> + 'n>(
272271
data.eval(footprint).await.into()
273272
}
274273

275-
#[node(name("Group"), category("General"))]
276-
async fn group<F: 'n + Send, Data: Into<GraphicGroup> + 'n>(
274+
#[node_macro::node(category("General"))]
275+
async fn to_group<F: 'n + Send, Data: Into<GraphicGroup> + 'n>(
277276
#[implementations((), (), (), (), Footprint)] footprint: F,
278277
#[implementations(
279278
((), VectorData),
@@ -290,8 +289,8 @@ async fn group<F: 'n + Send, Data: Into<GraphicGroup> + 'n>(
290289
element.eval(footprint).await.into()
291290
}
292291

293-
#[node]
294-
async fn construct_artboard<F: 'n + Copy + Send + ApplyTransform>(
292+
#[node_macro::node(category(""))]
293+
async fn to_artboard<F: 'n + Copy + Send + ApplyTransform>(
295294
#[implementations((), Footprint)] mut footprint: F,
296295
#[implementations(((), GraphicGroup), (Footprint, GraphicGroup))] contents: impl Node<F, Output = GraphicGroup>,
297296
label: String,
@@ -312,8 +311,8 @@ async fn construct_artboard<F: 'n + Copy + Send + ApplyTransform>(
312311
clip,
313312
}
314313
}
315-
#[node]
316-
async fn add_artboard<F: 'n + Copy + Send>(
314+
#[node_macro::node(category(""))]
315+
async fn append_artboard<F: 'n + Copy + Send>(
317316
#[implementations((), Footprint)] footprint: F,
318317
#[implementations(((), ArtboardGroup), (Footprint, ArtboardGroup))] artboards: impl Node<F, Output = ArtboardGroup>,
319318
#[implementations(((), Artboard), (Footprint, Artboard))] artboard: impl Node<F, Output = Artboard>,
@@ -324,7 +323,7 @@ async fn add_artboard<F: 'n + Copy + Send>(
324323

325324
// Get the penultimate element of the node path, or None if the path is too short
326325
let encapsulating_node_id = node_path.get(node_path.len().wrapping_sub(2)).copied();
327-
artboards.add_artboard(artboard, encapsulating_node_id);
326+
artboards.append_artboard(artboard, encapsulating_node_id);
328327

329328
artboards
330329
}

node-graph/gcore/src/ops.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -224,75 +224,75 @@ fn logical_not(_: (), input: bool) -> bool {
224224
}
225225

226226
// Bool Value
227-
#[node_macro::node(category("Value"), name("Bool Value"))]
227+
#[node_macro::node(category("Value"))]
228228
fn bool_value(_: (), _primary: (), #[name("Bool")] bool_value: bool) -> bool {
229229
bool_value
230230
}
231231

232232
// Number Value
233-
#[node_macro::node(category("Value"), name("Number Value"))]
233+
#[node_macro::node(category("Value"))]
234234
fn number_value(_: (), _primary: (), number: f64) -> f64 {
235235
number
236236
}
237237

238238
// Percentage Value
239-
#[node_macro::node(category("Value"), name("Percentage Value"))]
239+
#[node_macro::node(category("Value"))]
240240
fn percentage_value(_: (), _primary: (), percentage: Percentage) -> f64 {
241241
percentage
242242
}
243243

244244
// Vector2 Value
245-
#[node_macro::node(category("Value"), name("Vector2 Value"))]
245+
#[node_macro::node(category("Value"))]
246246
fn vector2_value(_: (), _primary: (), x: f64, y: f64) -> glam::DVec2 {
247247
glam::DVec2::new(x, y)
248248
}
249249

250250
// TODO: Make it possible to give Color::BLACK instead of 000000ff as the default
251251
// Color Value
252-
#[node_macro::node(category("Value"), name("Color Value"))]
252+
#[node_macro::node(category("Value"))]
253253
fn color_value(_: (), _primary: (), #[default(000000ff)] color: crate::Color) -> crate::Color {
254254
color
255255
}
256256

257257
// Gradient Value
258-
#[node_macro::node(category("Value"), name("Gradient Value"))]
258+
#[node_macro::node(category("Value"))]
259259
fn gradient_value(_: (), _primary: (), gradient: crate::vector::style::GradientStops) -> crate::vector::style::GradientStops {
260260
gradient
261261
}
262262

263263
// Color Channel Value
264-
#[node_macro::node(category("Value"), name("Color Channel Value"))]
264+
#[node_macro::node(category("Value"))]
265265
fn color_channel_value(_: (), _primary: (), color_channel: crate::raster::adjustments::RedGreenBlue) -> crate::raster::adjustments::RedGreenBlue {
266266
color_channel
267267
}
268268

269269
// Blend Mode Value
270-
#[node_macro::node(category("Value"), name("Blend Mode Value"))]
270+
#[node_macro::node(category("Value"))]
271271
fn blend_mode_value(_: (), _primary: (), blend_mode: crate::raster::BlendMode) -> crate::raster::BlendMode {
272272
blend_mode
273273
}
274274

275275
// Size Of
276276
#[cfg(feature = "std")]
277-
#[node_macro::node]
277+
#[node_macro::node(category("Debug"))]
278278
fn size_of(_: (), ty: crate::Type) -> Option<usize> {
279279
ty.size()
280280
}
281281

282282
// Some
283-
#[node_macro::node]
283+
#[node_macro::node(category("Debug"))]
284284
fn some<T>(_: (), #[implementations(f64, f32, u32, u64, String, crate::Color)] input: T) -> Option<T> {
285285
Some(input)
286286
}
287287

288288
// Unwrap
289-
#[node_macro::node]
289+
#[node_macro::node(category("Debug"))]
290290
fn unwrap<T: Default>(_: (), #[implementations(Option<f64>, Option<f32>, Option<u32>, Option<u64>, Option<String>, Option<crate::Color>)] input: Option<T>) -> T {
291291
input.unwrap_or_default()
292292
}
293293

294294
// Clone
295-
#[node_macro::node]
295+
#[node_macro::node(category("Debug"))]
296296
fn clone<'i, T: Clone + 'i>(_: (), #[implementations(&crate::raster::ImageFrame<crate::Color>)] value: &'i T) -> T {
297297
value.clone()
298298
}

0 commit comments

Comments
 (0)