Skip to content

Commit 1b351ac

Browse files
authored
Replace the Color type with Table<Color> everywhere (#3048)
1 parent 437fc70 commit 1b351ac

Some content is hidden

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

46 files changed

+310
-390
lines changed

demo-artwork/changing-seasons.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/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/marbled-mandelbrot.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/parametric-dunescape.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/data_panel/data_panel_message_handler.rs

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,6 @@ 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-
Color,
167-
Option<Color>,
168166
f64,
169167
u32,
170168
u64,
@@ -487,28 +485,6 @@ impl TableRowLayout for Color {
487485
}
488486
}
489487

490-
impl TableRowLayout for Option<Color> {
491-
fn type_name() -> &'static str {
492-
"Option<Color>"
493-
}
494-
fn identifier(&self) -> String {
495-
format!(
496-
"Option<Color> (#{})",
497-
if let Some(color) = self { color.to_linear_srgb().to_rgba_hex_srgb() } else { "None".to_string() }
498-
)
499-
}
500-
fn element_widget(&self, _index: usize) -> WidgetHolder {
501-
ColorInput::new(if let Some(color) = self { FillChoice::Solid(*color) } else { FillChoice::None })
502-
.disabled(true)
503-
.menu_direction(Some(MenuDirection::Top))
504-
.widget_holder()
505-
}
506-
fn element_page(&self, _data: &mut LayoutData) -> Vec<LayoutGroup> {
507-
let widgets = vec![self.element_widget(0)];
508-
vec![LayoutGroup::Row { widgets }]
509-
}
510-
}
511-
512488
impl TableRowLayout for f64 {
513489
fn type_name() -> &'static str {
514490
"Number (f64)"

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ impl<'a> ModifyInputsContext<'a> {
135135
Some(NodeInput::value(TaggedValue::Graphic(Default::default()), true)),
136136
Some(NodeInput::value(TaggedValue::DVec2(artboard.location.into()), false)),
137137
Some(NodeInput::value(TaggedValue::DVec2(artboard.dimensions.into()), false)),
138-
Some(NodeInput::value(TaggedValue::Color(artboard.background), false)),
138+
Some(NodeInput::value(TaggedValue::Color(Table::new_from_element(artboard.background)), false)),
139139
Some(NodeInput::value(TaggedValue::Bool(artboard.clip), false)),
140140
]);
141141
self.network_interface.insert_node(new_id, artboard_node_template, &[]);
@@ -329,11 +329,11 @@ impl<'a> ModifyInputsContext<'a> {
329329
match &fill {
330330
Fill::None => {
331331
let input_connector = InputConnector::node(fill_node_id, backup_color_index);
332-
self.set_input_with_refresh(input_connector, NodeInput::value(TaggedValue::OptionalColor(None), false), true);
332+
self.set_input_with_refresh(input_connector, NodeInput::value(TaggedValue::Color(Table::new()), false), true);
333333
}
334334
Fill::Solid(color) => {
335335
let input_connector = InputConnector::node(fill_node_id, backup_color_index);
336-
self.set_input_with_refresh(input_connector, NodeInput::value(TaggedValue::OptionalColor(Some(*color)), false), true);
336+
self.set_input_with_refresh(input_connector, NodeInput::value(TaggedValue::Color(Table::new_from_element(*color)), false), true);
337337
}
338338
Fill::Gradient(gradient) => {
339339
let input_connector = InputConnector::node(fill_node_id, backup_gradient_index);
@@ -372,8 +372,10 @@ impl<'a> ModifyInputsContext<'a> {
372372
pub fn stroke_set(&mut self, stroke: Stroke) {
373373
let Some(stroke_node_id) = self.existing_node_id("Stroke", true) else { return };
374374

375-
let input_connector = InputConnector::node(stroke_node_id, graphene_std::vector::stroke::ColorInput::<Option<graphene_std::Color>>::INDEX);
376-
self.set_input_with_refresh(input_connector, NodeInput::value(TaggedValue::OptionalColor(stroke.color), false), true);
375+
let stroke_color = if let Some(color) = stroke.color { Table::new_from_element(color) } else { Table::new() };
376+
377+
let input_connector = InputConnector::node(stroke_node_id, graphene_std::vector::stroke::ColorInput::INDEX);
378+
self.set_input_with_refresh(input_connector, NodeInput::value(TaggedValue::Color(stroke_color), false), true);
377379
let input_connector = InputConnector::node(stroke_node_id, graphene_std::vector::stroke::WeightInput::INDEX);
378380
self.set_input_with_refresh(input_connector, NodeInput::value(TaggedValue::F64(stroke.weight), false), true);
379381
let input_connector = InputConnector::node(stroke_node_id, graphene_std::vector::stroke::AlignInput::INDEX);

0 commit comments

Comments
 (0)