Skip to content

Commit 9a85877

Browse files
Merge branch 'master' into improve-save-document
2 parents 69778c1 + 2995113 commit 9a85877

File tree

41 files changed

+749
-1218
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+749
-1218
lines changed

.nix/flake.nix

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@
4040
};
4141

4242
libcef = pkgs.libcef.overrideAttrs (finalAttrs: previousAttrs: {
43-
version = "138.0.26";
44-
gitRevision = "84f2d27";
45-
chromiumVersion = "138.0.7204.158";
46-
srcHash = "sha256-d9jQJX7rgdoHfROD3zmOdMSesRdKE3slB5ZV+U2wlbQ=";
43+
version = "139.0.17";
44+
gitRevision = "6c347eb";
45+
chromiumVersion = "139.0.7258.31";
46+
srcHash = "sha256-kRMO8DP4El1qytDsAZBdHvR9AAHXce90nPdyfJailBg=";
4747

4848
__intentionallyOverridingVersion = true;
4949

Cargo.lock

Lines changed: 15 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,12 +159,13 @@ iai-callgrind = { version = "0.12.3" }
159159
ndarray = "0.16.1"
160160
strum = { version = "0.26.3", features = ["derive"] }
161161
dirs = "6.0"
162-
cef = "138.5.0"
162+
cef = "139.0.1"
163163
include_dir = "0.7.4"
164164
tracing-subscriber = { version = "0.3.19", features = ["env-filter"] }
165165
tracing = "0.1.41"
166166
rfd = "0.15.4"
167167
open = "5.3.2"
168+
poly-cool = "0.2.0"
168169

169170
[profile.dev]
170171
opt-level = 1

editor/src/messages/message.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ mod test {
6969

7070
fn print_tree_node(tree: &DebugMessageTree, prefix: &str, is_last: bool, file: &mut std::fs::File) {
7171
// Print the current node
72-
let (branch, child_prefix) = if tree.has_message_handler_data_fields() || tree.has_message_handler_fields() {
72+
let (branch, child_prefix) = if tree.message_handler_data_fields().is_some() || tree.message_handler_fields().is_some() {
7373
("├── ", format!("{}│ ", prefix))
7474
} else {
7575
if is_last {
@@ -97,7 +97,7 @@ mod test {
9797
// Print handler field if any
9898
if let Some(data) = tree.message_handler_fields() {
9999
let len = data.fields().len();
100-
let (branch, child_prefix) = if tree.has_message_handler_data_fields() {
100+
let (branch, child_prefix) = if tree.message_handler_data_fields().is_some() {
101101
("├── ", format!("{}│ ", prefix))
102102
} else {
103103
("└── ", format!("{} ", prefix))

editor/src/messages/portfolio/document/data_panel/data_panel_message_handler.rs

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use crate::messages::tool::tool_messages::tool_prelude::*;
77
use graph_craft::document::NodeId;
88
use graphene_std::Color;
99
use graphene_std::Context;
10+
use graphene_std::gradient::GradientStops;
1011
use graphene_std::memo::IORecord;
1112
use graphene_std::raster_types::{CPU, GPU, Raster};
1213
use graphene_std::table::Table;
@@ -153,7 +154,6 @@ macro_rules! generate_layout_downcast {
153154
else { None }
154155
}
155156
}
156-
157157
// TODO: We simply try all these types sequentially. Find a better strategy.
158158
fn generate_layout(introspected_data: &Arc<dyn std::any::Any + Send + Sync + 'static>, data: &mut LayoutData) -> Option<Vec<LayoutGroup>> {
159159
generate_layout_downcast!(introspected_data, data, [
@@ -163,6 +163,7 @@ fn generate_layout(introspected_data: &Arc<dyn std::any::Any + Send + Sync + 'st
163163
Table<Raster<CPU>>,
164164
Table<Raster<GPU>>,
165165
Table<Color>,
166+
Table<GradientStops>,
166167
f64,
167168
u32,
168169
u64,
@@ -263,6 +264,7 @@ impl TableRowLayout for Graphic {
263264
Self::RasterCPU(table) => table.identifier(),
264265
Self::RasterGPU(table) => table.identifier(),
265266
Self::Color(table) => table.identifier(),
267+
Self::Gradient(table) => table.identifier(),
266268
}
267269
}
268270
// Don't put a breadcrumb for Graphic
@@ -276,6 +278,7 @@ impl TableRowLayout for Graphic {
276278
Self::RasterCPU(table) => table.layout_with_breadcrumb(data),
277279
Self::RasterGPU(table) => table.layout_with_breadcrumb(data),
278280
Self::Color(table) => table.layout_with_breadcrumb(data),
281+
Self::Gradient(table) => table.layout_with_breadcrumb(data),
279282
}
280283
}
281284
}
@@ -335,10 +338,6 @@ impl TableRowLayout for Vector {
335338
TextLabel::new(format_dvec2(gradient.start)).widget_holder(),
336339
]);
337340
table_rows.push(vec![TextLabel::new("Fill Gradient End").widget_holder(), TextLabel::new(format_dvec2(gradient.end)).widget_holder()]);
338-
table_rows.push(vec![
339-
TextLabel::new("Fill Gradient Transform").widget_holder(),
340-
TextLabel::new(format_transform_matrix(&gradient.transform)).widget_holder(),
341-
]);
342341
}
343342
}
344343

@@ -485,6 +484,25 @@ impl TableRowLayout for Color {
485484
}
486485
}
487486

487+
impl TableRowLayout for GradientStops {
488+
fn type_name() -> &'static str {
489+
"Gradient"
490+
}
491+
fn identifier(&self) -> String {
492+
format!("Gradient ({} stops)", self.0.len())
493+
}
494+
fn element_widget(&self, _index: usize) -> WidgetHolder {
495+
ColorInput::new(FillChoice::Gradient(self.clone()))
496+
.disabled(true)
497+
.menu_direction(Some(MenuDirection::Top))
498+
.widget_holder()
499+
}
500+
fn element_page(&self, _data: &mut LayoutData) -> Vec<LayoutGroup> {
501+
let widgets = vec![self.element_widget(0)];
502+
vec![LayoutGroup::Row { widgets }]
503+
}
504+
}
505+
488506
impl TableRowLayout for f64 {
489507
fn type_name() -> &'static str {
490508
"Number (f64)"
@@ -545,7 +563,7 @@ impl TableRowLayout for String {
545563
"String".to_string()
546564
}
547565
fn element_page(&self, _data: &mut LayoutData) -> Vec<LayoutGroup> {
548-
let widgets = vec![TextLabel::new(self.to_string()).widget_holder()];
566+
let widgets = vec![TextAreaInput::new(self.to_string()).disabled(true).widget_holder()];
549567
vec![LayoutGroup::Row { widgets }]
550568
}
551569
}

editor/src/messages/portfolio/document/graph_operation/graph_operation_message_handler.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,6 @@ fn apply_usvg_fill(fill: &usvg::Fill, modify_inputs: &mut ModifyInputsContext, t
426426
Fill::Gradient(Gradient {
427427
start,
428428
end,
429-
transform: DAffine2::IDENTITY,
430429
gradient_type: GradientType::Linear,
431430
stops,
432431
})
@@ -453,7 +452,6 @@ fn apply_usvg_fill(fill: &usvg::Fill, modify_inputs: &mut ModifyInputsContext, t
453452
Fill::Gradient(Gradient {
454453
start,
455454
end,
456-
transform: DAffine2::IDENTITY,
457455
gradient_type: GradientType::Radial,
458456
stops,
459457
})

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ pub(crate) fn property_from_type(
182182
// STRUCT TYPES
183183
// ============
184184
Some(x) if x == TypeId::of::<Table<Color>>() => color_widget(default_info, ColorInput::default().allow_none(true)),
185+
Some(x) if x == TypeId::of::<Table<GradientStops>>() => color_widget(default_info, ColorInput::default().allow_none(false)),
185186
Some(x) if x == TypeId::of::<GradientStops>() => color_widget(default_info, ColorInput::default().allow_none(false)),
186187
Some(x) if x == TypeId::of::<Font>() => font_widget(default_info),
187188
Some(x) if x == TypeId::of::<Curve>() => curve_widget(default_info),
@@ -922,6 +923,20 @@ pub fn color_widget(parameter_widgets_info: ParameterWidgetsInfo, color_button:
922923
.on_commit(commit_value)
923924
.widget_holder(),
924925
),
926+
TaggedValue::GradientTable(gradient_table) => widgets.push(
927+
color_button
928+
.value(match gradient_table.iter().next() {
929+
Some(row) => FillChoice::Gradient(row.element.clone()),
930+
None => FillChoice::None,
931+
})
932+
.on_update(update_value(
933+
|input: &ColorInput| TaggedValue::GradientTable(input.value.as_gradient().iter().map(|&gradient| TableRow::new_from_element(gradient.clone())).collect()),
934+
node_id,
935+
index,
936+
))
937+
.on_commit(commit_value)
938+
.widget_holder(),
939+
),
925940
TaggedValue::GradientStops(gradient_stops) => widgets.push(
926941
color_button
927942
.value(FillChoice::Gradient(gradient_stops.clone()))

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ pub enum FrontendGraphDataType {
1414
Raster,
1515
Vector,
1616
Color,
17+
Gradient,
18+
Typography,
1719
}
1820

1921
impl FrontendGraphDataType {
@@ -32,6 +34,8 @@ impl FrontendGraphDataType {
3234
TaggedValue::Raster(_) => Self::Raster,
3335
TaggedValue::Vector(_) => Self::Vector,
3436
TaggedValue::Color(_) => Self::Color,
37+
TaggedValue::Gradient(_) | TaggedValue::GradientStops(_) | TaggedValue::GradientTable(_) => Self::Gradient,
38+
TaggedValue::String(_) => Self::Typography,
3539
_ => Self::General,
3640
}
3741
}

editor/src/messages/tool/tool_messages/gradient_tool.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,6 @@ impl SelectedGradient {
204204

205205
/// Update the layer fill to the current gradient
206206
pub fn render_gradient(&mut self, responses: &mut VecDeque<Message>) {
207-
self.gradient.transform = self.transform;
208207
if let Some(layer) = self.layer {
209208
responses.add(GraphOperationMessage::FillSet {
210209
layer,
@@ -436,14 +435,7 @@ impl Fsm for GradientToolFsmState {
436435
gradient.clone()
437436
} else {
438437
// Generate a new gradient
439-
Gradient::new(
440-
DVec2::ZERO,
441-
global_tool_data.secondary_color,
442-
DVec2::ONE,
443-
global_tool_data.primary_color,
444-
DAffine2::IDENTITY,
445-
tool_options.gradient_type,
446-
)
438+
Gradient::new(DVec2::ZERO, global_tool_data.secondary_color, DVec2::ONE, global_tool_data.primary_color, tool_options.gradient_type)
447439
};
448440
let selected_gradient = SelectedGradient::new(gradient, layer, document).with_gradient_start(input.mouse.position);
449441

0 commit comments

Comments
 (0)