Skip to content

Commit 60a4b7b

Browse files
committed
feat: deduplicate stroke UI, and upgrade core rendering
1 parent 871468d commit 60a4b7b

File tree

8 files changed

+496
-382
lines changed

8 files changed

+496
-382
lines changed

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

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,7 @@ fn generate_layout(introspected_data: &Arc<dyn std::any::Any + Send + Sync + 'st
165165
Table<Raster<CPU>>,
166166
Table<Raster<GPU>>,
167167
Table<Color>,
168+
Table<Fill>,
168169
Table<GradientStops>,
169170
GradientStops,
170171
f64,
@@ -556,6 +557,58 @@ impl TableRowLayout for Color {
556557
}
557558
}
558559

560+
impl TableRowLayout for Fill {
561+
fn type_name() -> &'static str {
562+
"Fill"
563+
}
564+
fn identifier(&self) -> String {
565+
match self {
566+
Self::None => "None".to_string(),
567+
Self::Solid(color) => format!("Solid (#{})", color.to_gamma_srgb().to_rgba_hex_srgb()),
568+
Self::Gradient(gradient) => format!("{} Gradient ({} stops)", gradient.gradient_type, gradient.stops.len()),
569+
}
570+
}
571+
fn element_widget(&self, _index: usize) -> WidgetInstance {
572+
let choice = match self {
573+
Self::None => FillChoice::None,
574+
Self::Solid(color) => FillChoice::Solid(*color),
575+
Self::Gradient(gradient) => FillChoice::Gradient(gradient.stops.clone()),
576+
};
577+
ColorInput::new(choice).disabled(true).menu_direction(Some(MenuDirection::Top)).narrow(true).widget_instance()
578+
}
579+
fn element_page(&self, _data: &mut LayoutData) -> Vec<LayoutGroup> {
580+
let mut table_rows = Vec::new();
581+
table_rows.push(column_headings(&["property", "value"]));
582+
583+
match self {
584+
Self::None => table_rows.push(vec![TextLabel::new("Type").narrow(true).widget_instance(), TextLabel::new("None").narrow(true).widget_instance()]),
585+
Self::Solid(color) => {
586+
table_rows.push(vec![TextLabel::new("Type").narrow(true).widget_instance(), TextLabel::new("Solid").narrow(true).widget_instance()]);
587+
table_rows.push(vec![
588+
TextLabel::new("Color").narrow(true).widget_instance(),
589+
TextLabel::new(format!("#{} (Alpha: {}%)", color.to_rgb_hex_srgb(), color.a() * 100.)).narrow(true).widget_instance(),
590+
]);
591+
}
592+
Self::Gradient(gradient) => {
593+
table_rows.push(vec![
594+
TextLabel::new("Type").narrow(true).widget_instance(),
595+
TextLabel::new(format!("{} Gradient", gradient.gradient_type)).narrow(true).widget_instance(),
596+
]);
597+
table_rows.push(vec![
598+
TextLabel::new("Start").narrow(true).widget_instance(),
599+
TextLabel::new(format_dvec2(gradient.start)).narrow(true).widget_instance(),
600+
]);
601+
table_rows.push(vec![
602+
TextLabel::new("End").narrow(true).widget_instance(),
603+
TextLabel::new(format_dvec2(gradient.end)).narrow(true).widget_instance(),
604+
]);
605+
}
606+
}
607+
608+
vec![LayoutGroup::table(table_rows, false)]
609+
}
610+
}
611+
559612
impl TableRowLayout for GradientStops {
560613
fn type_name() -> &'static str {
561614
"Gradient"

0 commit comments

Comments
 (0)