feat: add production UI gallery and inspector system
CI / Format, lint, test, build (push) Waiting to run
CI / Format, lint, test, build (push) Waiting to run
This commit is contained in:
1 parent
cf6eaba534
commit
53dc1e44d8
95 files changed
+11003
-1652
No files matched your search
@@ -31,6 +31,7 @@ bevy_egui.workspace = true
|
||||
bevy-inspector-egui.workspace = true
|
||||
egui_dock.workspace = true
|
||||
egui_phosphor_icons.workspace = true
|
||||
editor_ui.workspace = true
|
||||
bevy_ufbx.workspace = true
|
||||
content_pipeline.workspace = true
|
||||
ufbx = "0.9"
|
||||
|
||||
@@ -62,33 +62,53 @@ fn color_control_impl(
|
||||
) -> ColorPickerResponse {
|
||||
let palette = super::palette(ui);
|
||||
let id = ui.make_persistent_id(("penpot_color_picker", salt));
|
||||
let (rect, response) = ui.allocate_exact_size(egui::vec2(130.0, 22.0), egui::Sense::click());
|
||||
let swatch_rect = egui::Rect::from_min_size(rect.min, egui::vec2(24.0, 22.0));
|
||||
let hex_rect =
|
||||
egui::Rect::from_min_size(rect.min + egui::vec2(30.0, 0.0), egui::vec2(100.0, 22.0));
|
||||
let width = ui.available_width().max(1.0);
|
||||
let (rect, response) = ui.allocate_exact_size(egui::vec2(width, 22.0), egui::Sense::click());
|
||||
let swatch_width = 44.0_f32.min(width);
|
||||
let swatch_rect = egui::Rect::from_min_size(rect.min, egui::vec2(swatch_width, 22.0));
|
||||
let gap = if width > swatch_width + 6.0 { 6.0 } else { 0.0 };
|
||||
let hex_rect = egui::Rect::from_min_size(
|
||||
rect.min + egui::vec2(swatch_width + gap, 0.0),
|
||||
egui::vec2((width - swatch_width - gap).max(0.0), 22.0),
|
||||
);
|
||||
popup::checker(ui.painter(), swatch_rect, palette.control, palette.elevated);
|
||||
ui.painter()
|
||||
.rect_filled(swatch_rect.shrink(1.0), 4.0, color32(*rgba));
|
||||
let inner_swatch = swatch_rect.shrink(1.0);
|
||||
let rgb_rect = egui::Rect::from_min_max(
|
||||
inner_swatch.min,
|
||||
egui::pos2(inner_swatch.center().x, inner_swatch.max.y),
|
||||
);
|
||||
let alpha_rect = egui::Rect::from_min_max(
|
||||
egui::pos2(inner_swatch.center().x, inner_swatch.min.y),
|
||||
inner_swatch.max,
|
||||
);
|
||||
ui.painter().rect_filled(
|
||||
rgb_rect,
|
||||
3.0,
|
||||
egui::Color32::from_rgb(byte(rgba[0]), byte(rgba[1]), byte(rgba[2])),
|
||||
);
|
||||
ui.painter().rect_filled(alpha_rect, 3.0, color32(*rgba));
|
||||
ui.painter().rect_stroke(
|
||||
swatch_rect,
|
||||
4.0,
|
||||
egui::Stroke::new(1.0_f32, palette.border_strong),
|
||||
egui::StrokeKind::Inside,
|
||||
);
|
||||
ui.painter().rect(
|
||||
hex_rect,
|
||||
4.0,
|
||||
palette.control,
|
||||
egui::Stroke::new(1.0_f32, palette.border),
|
||||
egui::StrokeKind::Inside,
|
||||
);
|
||||
ui.painter().text(
|
||||
hex_rect.left_center() + egui::vec2(9.0, 0.0),
|
||||
egui::Align2::LEFT_CENTER,
|
||||
hex(*rgba),
|
||||
TypeRole::Body.font(),
|
||||
palette.text_primary,
|
||||
);
|
||||
if hex_rect.width() > 0.0 {
|
||||
ui.painter().rect(
|
||||
hex_rect,
|
||||
4.0,
|
||||
palette.control,
|
||||
egui::Stroke::new(1.0_f32, palette.border),
|
||||
egui::StrokeKind::Inside,
|
||||
);
|
||||
ui.painter().text(
|
||||
hex_rect.left_center() + egui::vec2(9.0, 0.0),
|
||||
egui::Align2::LEFT_CENTER,
|
||||
hex(*rgba),
|
||||
TypeRole::Body.font(),
|
||||
palette.text_primary,
|
||||
);
|
||||
}
|
||||
|
||||
if response.clicked() {
|
||||
let opened_at = ui.input(|input| input.time);
|
||||
|
||||
@@ -7,12 +7,10 @@ use std::ops::RangeInclusive;
|
||||
use super::palette;
|
||||
use super::typography::TypeRole;
|
||||
|
||||
const SCALAR_CONTROL_WIDTH: f32 = 132.0;
|
||||
const SCALAR_TRACK_X: f32 = 0.0;
|
||||
const SCALAR_TRACK_WIDTH: f32 = 78.0;
|
||||
const SCALAR_TRACK_X: f32 = 6.0;
|
||||
const SCALAR_NUMBER_GAP: f32 = 6.0;
|
||||
const SCALAR_TRACK_INTERACTION_HEIGHT: f32 = 10.0;
|
||||
const SCALAR_NUMBER_X: f32 = 84.0;
|
||||
const SCALAR_NUMBER_WIDTH: f32 = 48.0;
|
||||
const SCALAR_NUMBER_WIDTH: f32 = 33.0;
|
||||
const SCALAR_THUMB_RADIUS: f32 = 4.0;
|
||||
|
||||
pub(crate) fn section_frame(ui: &egui::Ui) -> egui::Frame {
|
||||
@@ -50,7 +48,7 @@ pub(crate) fn section_header_with_summary(
|
||||
} else {
|
||||
icons::CARET_RIGHT.as_str()
|
||||
},
|
||||
egui::FontId::new(10.0, egui::FontFamily::Name("phosphor-regular".into())),
|
||||
egui::FontId::new(10.0, egui::FontFamily::Name("phosphor-bold".into())),
|
||||
palette.text_secondary,
|
||||
);
|
||||
ui.painter().text(
|
||||
@@ -90,10 +88,7 @@ pub(crate) fn icon_label(
|
||||
icon.as_str(),
|
||||
0.0,
|
||||
egui::TextFormat {
|
||||
font_id: egui::FontId::new(
|
||||
icon_size,
|
||||
egui::FontFamily::Name("phosphor-regular".into()),
|
||||
),
|
||||
font_id: egui::FontId::new(icon_size, egui::FontFamily::Name("phosphor-bold".into())),
|
||||
color,
|
||||
..Default::default()
|
||||
},
|
||||
@@ -123,7 +118,7 @@ pub(crate) fn icon_button(
|
||||
enabled,
|
||||
egui::Button::new(egui::RichText::new(icon.as_str()).font(egui::FontId::new(
|
||||
14.0,
|
||||
egui::FontFamily::Name("phosphor-regular".into()),
|
||||
egui::FontFamily::Name("phosphor-bold".into()),
|
||||
)))
|
||||
.min_size(egui::vec2(24.0, 24.0))
|
||||
.fill(palette.control)
|
||||
@@ -133,12 +128,35 @@ pub(crate) fn icon_button(
|
||||
response.on_hover_text(tooltip)
|
||||
}
|
||||
|
||||
pub(crate) fn status(ui: &mut egui::Ui, color: egui::Color32, label: &str, tooltip: &str) {
|
||||
pub(crate) fn status(
|
||||
ui: &mut egui::Ui,
|
||||
icon: Icon,
|
||||
color: egui::Color32,
|
||||
label: &str,
|
||||
tooltip: &str,
|
||||
) {
|
||||
let palette = palette(ui);
|
||||
let (dot, response) = ui.allocate_exact_size(egui::vec2(8.0, 14.0), egui::Sense::hover());
|
||||
ui.painter().circle_filled(dot.center(), 4.0, color);
|
||||
let mut job = egui::text::LayoutJob::default();
|
||||
job.append(
|
||||
icon.as_str(),
|
||||
0.0,
|
||||
egui::TextFormat {
|
||||
font_id: egui::FontId::new(12.0, egui::FontFamily::Name("phosphor-bold".into())),
|
||||
color,
|
||||
..Default::default()
|
||||
},
|
||||
);
|
||||
job.append(
|
||||
label,
|
||||
5.0,
|
||||
egui::TextFormat {
|
||||
font_id: TypeRole::Body.font(),
|
||||
color: palette.text_secondary,
|
||||
..Default::default()
|
||||
},
|
||||
);
|
||||
let response = ui.add(egui::Label::new(job).sense(egui::Sense::hover()));
|
||||
response.on_hover_text(tooltip);
|
||||
ui.label(TypeRole::Body.text(label).color(palette.text_secondary));
|
||||
}
|
||||
|
||||
pub(crate) fn switch(ui: &mut egui::Ui, value: &mut bool) -> egui::Response {
|
||||
@@ -260,12 +278,15 @@ pub(crate) fn scalar_control(
|
||||
) -> egui::Response {
|
||||
let palette = palette(ui);
|
||||
let before = *value;
|
||||
let width = SCALAR_CONTROL_WIDTH.min(ui.available_width().max(1.0));
|
||||
// The final Penpot component deliberately stretches only the track at the compact
|
||||
// breakpoint: 93.8 px at the 569 px reference and 160.3 px at the 369 px reference.
|
||||
// The numeric field remains a stable 33 px in both modes.
|
||||
let width = ui.available_width().max(1.0);
|
||||
let (rect, base_response) =
|
||||
ui.allocate_exact_size(egui::vec2(width, 22.0), egui::Sense::hover());
|
||||
let number_width = SCALAR_NUMBER_WIDTH.min(width);
|
||||
let number_x = SCALAR_NUMBER_X.min((width - number_width).max(0.0));
|
||||
let track_width = SCALAR_TRACK_WIDTH.min((number_x - 6.0).max(1.0));
|
||||
let number_x = (width - number_width).max(0.0);
|
||||
let track_width = (number_x - SCALAR_TRACK_X - SCALAR_NUMBER_GAP).max(1.0);
|
||||
let slider_rect = egui::Rect::from_min_size(
|
||||
rect.min + egui::vec2(SCALAR_TRACK_X, 6.0),
|
||||
egui::vec2(track_width, SCALAR_TRACK_INTERACTION_HEIGHT),
|
||||
@@ -337,8 +358,15 @@ mod scalar_tests {
|
||||
|
||||
#[test]
|
||||
fn penpot_scalar_geometry_matches_the_current_export() {
|
||||
assert!((SCALAR_NUMBER_X - (SCALAR_TRACK_X + SCALAR_TRACK_WIDTH) - 6.0).abs() < 0.001);
|
||||
assert_eq!(SCALAR_CONTROL_WIDTH, SCALAR_NUMBER_X + SCALAR_NUMBER_WIDTH);
|
||||
let wide_width = 132.8;
|
||||
let wide_number_x = wide_width - SCALAR_NUMBER_WIDTH;
|
||||
let wide_track = wide_number_x - SCALAR_TRACK_X - SCALAR_NUMBER_GAP;
|
||||
assert!((wide_track - 93.8).abs() < 0.001);
|
||||
|
||||
let compact_width = 199.3;
|
||||
let compact_number_x = compact_width - SCALAR_NUMBER_WIDTH;
|
||||
let compact_track = compact_number_x - SCALAR_TRACK_X - SCALAR_NUMBER_GAP;
|
||||
assert!((compact_track - 160.3).abs() < 0.001);
|
||||
assert_eq!(SCALAR_TRACK_INTERACTION_HEIGHT, 10.0);
|
||||
assert_eq!(SCALAR_THUMB_RADIUS, 4.0);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,14 @@
|
||||
use super::{COMPACT_PARAMETER_ROW_HEIGHT, PARAMETER_ROW_HEIGHT};
|
||||
use bevy_egui::egui;
|
||||
|
||||
pub(crate) const WIDE_SECTION_WIDTH: f32 = 569.0;
|
||||
/// Minimum live section width that can safely retain the exported wide-row geometry.
|
||||
///
|
||||
/// The Penpot reference section itself is 569 px wide. In the native Inspector, dock chrome,
|
||||
/// component-card borders, and the floating scrollbar consume up to ten pixels before the
|
||||
/// material parameter body is allocated. Treat that 559 px contained canvas as wide so a 640 px
|
||||
/// Inspector renders the authoritative wide reference instead of incorrectly switching to the
|
||||
/// 420 px two-line rows.
|
||||
pub(crate) const WIDE_SECTION_WIDTH: f32 = 559.0;
|
||||
pub(crate) const RESPONSIVE_BREAKPOINT: f32 = WIDE_SECTION_WIDTH;
|
||||
/// The actor component chrome can consume up to twelve pixels of the exported 372 px compact
|
||||
/// canvas. At 360 px the complete texture row still fits: 12 px inset + 336 px group + 12 px inset.
|
||||
@@ -20,6 +27,7 @@ pub(crate) struct PropertyRowRects {
|
||||
pub row: egui::Rect,
|
||||
pub label: egui::Rect,
|
||||
pub value: egui::Rect,
|
||||
pub color_value: egui::Rect,
|
||||
pub channel: egui::Rect,
|
||||
pub texture_group: egui::Rect,
|
||||
pub texture_field: egui::Rect,
|
||||
@@ -60,8 +68,12 @@ impl PropertyGridGeometry {
|
||||
egui::vec2(82.0, 22.0),
|
||||
),
|
||||
value: egui::Rect::from_min_size(
|
||||
row.min + egui::vec2(96.0, 5.0),
|
||||
egui::vec2(132.0, 22.0),
|
||||
row.min + egui::vec2(103.35, 5.0),
|
||||
egui::vec2(132.8, 22.0),
|
||||
),
|
||||
color_value: egui::Rect::from_min_size(
|
||||
row.min + egui::vec2(107.95, 5.0),
|
||||
egui::vec2(182.55, 22.0),
|
||||
),
|
||||
channel: egui::Rect::from_min_size(
|
||||
row.min + egui::vec2(234.0, 5.0),
|
||||
@@ -86,8 +98,10 @@ impl PropertyGridGeometry {
|
||||
|
||||
let channel_width = 48.0_f32.min(inner_width);
|
||||
let channel_x = inset + inner_width - channel_width;
|
||||
let value_x = (inset + 84.0).min(channel_x);
|
||||
let value_x = (inset + 91.35).min(channel_x);
|
||||
let value_width = (channel_x - value_x - 6.35).max(1.0);
|
||||
let color_value_x = (inset + 95.95).min(channel_x);
|
||||
let color_value_width = (inset + inner_width - color_value_x).max(1.0);
|
||||
let texture_group = egui::Rect::from_min_size(
|
||||
row.min + egui::vec2(inset, 31.0),
|
||||
egui::vec2(inner_width, 22.0),
|
||||
@@ -109,6 +123,10 @@ impl PropertyGridGeometry {
|
||||
row.min + egui::vec2(value_x, 5.0),
|
||||
egui::vec2(value_width, 22.0),
|
||||
),
|
||||
color_value: egui::Rect::from_min_size(
|
||||
row.min + egui::vec2(color_value_x, 5.0),
|
||||
egui::vec2(color_value_width, 22.0),
|
||||
),
|
||||
channel: egui::Rect::from_min_size(
|
||||
row.min + egui::vec2(channel_x, 5.0),
|
||||
egui::vec2(channel_width, 22.0),
|
||||
@@ -151,8 +169,15 @@ mod tests {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn penpot_below_reference_width_reflows_without_compression() {
|
||||
let geometry = PropertyGridGeometry::for_width(568.0);
|
||||
fn native_wide_containment_threshold_keeps_reference_rows() {
|
||||
let geometry = PropertyGridGeometry::for_width(559.0);
|
||||
assert!(!geometry.stacked);
|
||||
assert_eq!(geometry.row_height, 32.0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn below_native_wide_containment_threshold_reflows_without_compression() {
|
||||
let geometry = PropertyGridGeometry::for_width(558.0);
|
||||
assert!(geometry.stacked);
|
||||
assert_eq!(geometry.row_height, 58.0);
|
||||
}
|
||||
@@ -162,9 +187,11 @@ mod tests {
|
||||
let row = egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(569.0, 32.0));
|
||||
let rects = PropertyGridGeometry::for_width(569.0).row_rects(row);
|
||||
assert_eq!(rects.label.min, egui::pos2(12.0, 5.0));
|
||||
assert_eq!(rects.value.min, egui::pos2(96.0, 5.0));
|
||||
assert!((rects.value.width() - 132.0).abs() < 0.001);
|
||||
assert_eq!(rects.value.min, egui::pos2(103.35, 5.0));
|
||||
assert!((rects.value.width() - 132.8).abs() < 0.001);
|
||||
assert_eq!(rects.value.height(), 22.0);
|
||||
assert_eq!(rects.color_value.min, egui::pos2(107.95, 5.0));
|
||||
assert!((rects.color_value.width() - 182.55).abs() < 0.001);
|
||||
assert_eq!(
|
||||
rects.channel,
|
||||
egui::Rect::from_min_size(egui::pos2(234.0, 5.0), egui::vec2(48.0, 22.0))
|
||||
@@ -184,7 +211,10 @@ mod tests {
|
||||
let row = egui::Rect::from_min_size(egui::Pos2::ZERO, egui::vec2(369.0, 58.0));
|
||||
let rects = PropertyGridGeometry::for_width(369.0).row_rects(row);
|
||||
assert_eq!(rects.label.min, egui::pos2(12.0, 5.0));
|
||||
assert_eq!(rects.value.min, egui::pos2(96.0, 5.0));
|
||||
assert_eq!(rects.value.min, egui::pos2(103.35, 5.0));
|
||||
assert!((rects.value.width() - 199.3).abs() < 0.001);
|
||||
assert_eq!(rects.color_value.min, egui::pos2(107.95, 5.0));
|
||||
assert!((rects.color_value.width() - 249.05).abs() < 0.001);
|
||||
assert_eq!(
|
||||
rects.channel,
|
||||
egui::Rect::from_min_size(egui::pos2(309.0, 5.0), egui::vec2(48.0, 22.0))
|
||||
@@ -207,6 +237,7 @@ mod tests {
|
||||
for rect in [
|
||||
rects.label,
|
||||
rects.value,
|
||||
rects.color_value,
|
||||
rects.channel,
|
||||
rects.texture_group,
|
||||
rects.texture_field,
|
||||
@@ -239,6 +270,7 @@ mod tests {
|
||||
let wide = PropertyGridGeometry::for_width(669.0).row_rects(wide_row);
|
||||
assert_eq!(wide.label, reference.label);
|
||||
assert_eq!(wide.value, reference.value);
|
||||
assert_eq!(wide.color_value, reference.color_value);
|
||||
assert_eq!(wide.channel, reference.channel);
|
||||
assert_eq!(
|
||||
wide.texture_field.width(),
|
||||
|
||||
@@ -2,10 +2,6 @@
|
||||
|
||||
use bevy::prelude::*;
|
||||
use bevy_egui::{EguiContext, PrimaryEguiContext};
|
||||
use std::sync::Arc;
|
||||
|
||||
pub(crate) const SOURCE_SANS_REGULAR: &str = "blacksite-source-sans-regular";
|
||||
pub(crate) const SOURCE_SANS_BOLD: &str = "blacksite-source-sans-bold";
|
||||
|
||||
pub struct EditorFontsPlugin;
|
||||
|
||||
@@ -23,55 +19,5 @@ fn configure_editor_fonts(mut contexts: Query<&mut EguiContext, Added<PrimaryEgu
|
||||
}
|
||||
|
||||
pub(crate) fn editor_font_definitions() -> bevy_egui::egui::FontDefinitions {
|
||||
let mut fonts = bevy_egui::egui::FontDefinitions::default();
|
||||
egui_phosphor_icons::add_fonts(&mut fonts);
|
||||
|
||||
fonts.font_data.insert(
|
||||
SOURCE_SANS_REGULAR.to_owned(),
|
||||
Arc::new(bevy_egui::egui::FontData::from_static(include_bytes!(
|
||||
"../../assets/fonts/source-sans/SourceSansPro-Regular.ttf"
|
||||
))),
|
||||
);
|
||||
fonts.font_data.insert(
|
||||
SOURCE_SANS_BOLD.to_owned(),
|
||||
Arc::new(bevy_egui::egui::FontData::from_static(include_bytes!(
|
||||
"../../assets/fonts/source-sans/SourceSansPro-Bold.ttf"
|
||||
))),
|
||||
);
|
||||
|
||||
let proportional = fonts
|
||||
.families
|
||||
.entry(bevy_egui::egui::FontFamily::Proportional)
|
||||
.or_default();
|
||||
proportional.insert(0, SOURCE_SANS_REGULAR.to_owned());
|
||||
fonts.families.insert(
|
||||
bevy_egui::egui::FontFamily::Name(SOURCE_SANS_REGULAR.into()),
|
||||
vec![SOURCE_SANS_REGULAR.to_owned()],
|
||||
);
|
||||
fonts.families.insert(
|
||||
bevy_egui::egui::FontFamily::Name(SOURCE_SANS_BOLD.into()),
|
||||
vec![SOURCE_SANS_BOLD.to_owned(), SOURCE_SANS_REGULAR.to_owned()],
|
||||
);
|
||||
|
||||
// Phosphor families contain icon glyphs only. Text fallbacks give egui a
|
||||
// replacement glyph for malformed/missing icons without changing icon lookup.
|
||||
let text_fallbacks = fonts
|
||||
.families
|
||||
.get(&bevy_egui::egui::FontFamily::Proportional)
|
||||
.cloned()
|
||||
.unwrap_or_default();
|
||||
for (family, font_names) in &mut fonts.families {
|
||||
let bevy_egui::egui::FontFamily::Name(name) = family else {
|
||||
continue;
|
||||
};
|
||||
if !name.starts_with("phosphor-") {
|
||||
continue;
|
||||
}
|
||||
for fallback in &text_fallbacks {
|
||||
if !font_names.contains(fallback) {
|
||||
font_names.push(fallback.clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
fonts
|
||||
editor_ui::fonts::font_definitions()
|
||||
}
|
||||
@@ -1,12 +1,5 @@
|
||||
use super::*;
|
||||
|
||||
const COMPONENT_HEADER_HEIGHT: f32 = 50.0;
|
||||
const COMPONENT_RAIL_X: f32 = 7.0;
|
||||
const COMPONENT_CARET_CENTER_X: f32 = 26.0;
|
||||
const COMPONENT_ICON_CENTER_X: f32 = 51.0;
|
||||
const COMPONENT_IDENTITY_X: f32 = 69.0;
|
||||
const COMPONENT_ACTIONS_WIDTH: f32 = 104.0;
|
||||
|
||||
pub(super) fn material_shader_ui(ui: &mut egui::Ui, material: &mut MaterialDesc) -> bool {
|
||||
let mut changed = false;
|
||||
property_row(ui, "Shader", |ui| {
|
||||
@@ -137,201 +130,41 @@ pub(crate) fn component_card(
|
||||
context: &ComponentCardContext,
|
||||
add_contents: impl FnOnce(&mut egui::Ui),
|
||||
) -> ComponentCardResponse {
|
||||
let mut response = ComponentCardResponse {
|
||||
let options = editor_ui::inspector::ComponentCardOptions {
|
||||
type_name: context.options.type_name,
|
||||
..Default::default()
|
||||
title: context.options.title,
|
||||
icon: context.options.icon,
|
||||
active_toggle: context.options.active_toggle,
|
||||
removable: context.options.removable,
|
||||
reorderable: context.options.reorderable,
|
||||
resettable: context.options.resettable,
|
||||
copyable: context.options.copyable,
|
||||
summary: context.options.summary,
|
||||
body_margin: context.options.body_margin,
|
||||
};
|
||||
crate::ui::design_system::scope(ui, |ui| {
|
||||
egui::Frame::new()
|
||||
.fill(WIDGET_BG)
|
||||
.stroke(egui::Stroke::new(1.0_f32, BORDER))
|
||||
.corner_radius(egui::CornerRadius::same(5))
|
||||
.show(ui, |ui| {
|
||||
let width = ui.available_width().max(1.0);
|
||||
let (header, header_response) = ui.allocate_exact_size(
|
||||
egui::vec2(width, COMPONENT_HEADER_HEIGHT),
|
||||
egui::Sense::click(),
|
||||
);
|
||||
ui.painter().rect_filled(
|
||||
egui::Rect::from_min_size(
|
||||
header.min + egui::vec2(COMPONENT_RAIL_X, 7.0),
|
||||
egui::vec2(3.0, 36.0),
|
||||
),
|
||||
2.0,
|
||||
crate::ui::theme::SELECTION,
|
||||
);
|
||||
let caret_rect = egui::Rect::from_center_size(
|
||||
egui::pos2(header.left() + COMPONENT_CARET_CENTER_X, header.center().y),
|
||||
egui::vec2(20.0, 28.0),
|
||||
);
|
||||
if ui
|
||||
.put(
|
||||
caret_rect,
|
||||
egui::Button::new(phosphor_icon(
|
||||
if context.collapsed {
|
||||
icons::CARET_RIGHT
|
||||
} else {
|
||||
icons::CARET_DOWN
|
||||
},
|
||||
12.0,
|
||||
))
|
||||
.frame(false),
|
||||
)
|
||||
.on_hover_text(if context.collapsed {
|
||||
"Expand component"
|
||||
} else {
|
||||
"Collapse component"
|
||||
})
|
||||
.clicked()
|
||||
{
|
||||
response.collapsed = Some(!context.collapsed);
|
||||
}
|
||||
ui.painter().text(
|
||||
egui::pos2(header.left() + COMPONENT_ICON_CENTER_X, header.center().y),
|
||||
egui::Align2::CENTER_CENTER,
|
||||
context.options.icon.as_str(),
|
||||
egui::FontId::new(18.0, egui::FontFamily::Name("phosphor-regular".into())),
|
||||
TEXT_DIM,
|
||||
);
|
||||
ui.painter().text(
|
||||
egui::pos2(header.left() + COMPONENT_IDENTITY_X, header.top() + 18.0),
|
||||
egui::Align2::LEFT_CENTER,
|
||||
context.options.title,
|
||||
crate::ui::design_system::typography::TypeRole::Title.font(),
|
||||
crate::ui::theme::TEXT,
|
||||
);
|
||||
ui.painter().text(
|
||||
egui::pos2(header.left() + COMPONENT_IDENTITY_X, header.top() + 34.0),
|
||||
egui::Align2::LEFT_CENTER,
|
||||
context.options.summary,
|
||||
crate::ui::design_system::typography::TypeRole::Small.font(),
|
||||
TEXT_MUTED,
|
||||
);
|
||||
let actions_rect = egui::Rect::from_min_size(
|
||||
egui::pos2(
|
||||
header.right() - COMPONENT_ACTIONS_WIDTH - 8.0,
|
||||
header.top() + 11.0,
|
||||
),
|
||||
egui::vec2(COMPONENT_ACTIONS_WIDTH, 28.0),
|
||||
);
|
||||
ui.scope_builder(egui::UiBuilder::new().max_rect(actions_rect), |ui| {
|
||||
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
|
||||
component_actions_menu(ui, context, &mut response);
|
||||
let label = if context.active { "Active" } else { "Off" };
|
||||
let color = if context.active {
|
||||
crate::ui::theme::SUCCESS
|
||||
} else {
|
||||
TEXT_MUTED
|
||||
};
|
||||
let active = ui
|
||||
.horizontal(|ui| {
|
||||
let dot = if context.options.active_toggle {
|
||||
status_dot_button(ui, color, "Toggle component")
|
||||
} else {
|
||||
status_dot(ui, color, "Component active");
|
||||
ui.allocate_response(egui::Vec2::ZERO, egui::Sense::hover())
|
||||
};
|
||||
ui.label(
|
||||
crate::ui::design_system::typography::TypeRole::Small
|
||||
.text(label)
|
||||
.color(TEXT_DIM),
|
||||
);
|
||||
dot
|
||||
})
|
||||
.inner;
|
||||
if context.options.active_toggle && active.clicked() {
|
||||
response.active = Some(!context.active);
|
||||
}
|
||||
});
|
||||
});
|
||||
if header_response.clicked()
|
||||
&& ui
|
||||
.input(|input| input.pointer.interact_pos())
|
||||
.is_some_and(|pointer| {
|
||||
!caret_rect.contains(pointer) && !actions_rect.contains(pointer)
|
||||
})
|
||||
{
|
||||
response.collapsed = Some(!context.collapsed);
|
||||
}
|
||||
if !context.collapsed {
|
||||
egui::Frame::new()
|
||||
.inner_margin(egui::Margin {
|
||||
left: context.options.body_margin,
|
||||
right: context.options.body_margin,
|
||||
top: 10,
|
||||
bottom: context.options.body_margin,
|
||||
})
|
||||
.show(ui, |ui| {
|
||||
ui.set_max_width(ui.available_width());
|
||||
add_contents(ui);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
ui.add_space(6.0);
|
||||
response
|
||||
}
|
||||
|
||||
fn component_actions_menu(
|
||||
ui: &mut egui::Ui,
|
||||
context: &ComponentCardContext,
|
||||
response: &mut ComponentCardResponse,
|
||||
) {
|
||||
let menu = ui.menu_button(
|
||||
phosphor_icon(icons::DOTS_THREE_VERTICAL, 16.0).color(TEXT_DIM),
|
||||
|ui| {
|
||||
ui.set_min_width(160.0);
|
||||
if ui
|
||||
.add_enabled(context.options.resettable, egui::Button::new("Reset"))
|
||||
.clicked()
|
||||
{
|
||||
response.reset = true;
|
||||
ui.close();
|
||||
}
|
||||
if ui
|
||||
.add_enabled(context.options.copyable, egui::Button::new("Copy Values"))
|
||||
.clicked()
|
||||
{
|
||||
response.copy = true;
|
||||
ui.close();
|
||||
}
|
||||
if ui
|
||||
.add_enabled(context.pasteable, egui::Button::new("Paste Values"))
|
||||
.clicked()
|
||||
{
|
||||
response.paste = true;
|
||||
ui.close();
|
||||
}
|
||||
ui.separator();
|
||||
if ui
|
||||
.add_enabled(context.can_move_up, egui::Button::new("Move Up"))
|
||||
.clicked()
|
||||
{
|
||||
response.move_up = true;
|
||||
ui.close();
|
||||
}
|
||||
if ui
|
||||
.add_enabled(context.can_move_down, egui::Button::new("Move Down"))
|
||||
.clicked()
|
||||
{
|
||||
response.move_down = true;
|
||||
ui.close();
|
||||
}
|
||||
ui.separator();
|
||||
ui.add_enabled(false, egui::Button::new("Open Documentation"));
|
||||
if ui
|
||||
.add_enabled(
|
||||
context.options.removable,
|
||||
egui::Button::new(egui::RichText::new("Remove").color(crate::ui::theme::ERROR)),
|
||||
)
|
||||
.clicked()
|
||||
{
|
||||
response.remove = true;
|
||||
ui.close();
|
||||
}
|
||||
let shared = editor_ui::inspector::component_card(
|
||||
ui,
|
||||
&editor_ui::inspector::ComponentCardViewModel {
|
||||
options,
|
||||
active: context.active,
|
||||
collapsed: context.collapsed,
|
||||
pasteable: context.pasteable,
|
||||
can_move_up: context.can_move_up,
|
||||
can_move_down: context.can_move_down,
|
||||
},
|
||||
add_contents,
|
||||
);
|
||||
menu.response.on_hover_text("Component actions");
|
||||
ComponentCardResponse {
|
||||
type_name: shared.type_name,
|
||||
collapsed: shared.collapsed,
|
||||
active: shared.active,
|
||||
reset: shared.reset,
|
||||
copy: shared.copy,
|
||||
paste: shared.paste,
|
||||
move_up: shared.move_up,
|
||||
move_down: shared.move_down,
|
||||
remove: shared.remove,
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn property_row<R>(
|
||||
@@ -501,18 +334,3 @@ pub fn material_editor_ui(world: &mut World, ui: &mut egui::Ui, entity: Entity)
|
||||
set_material_with_history(world, entity, material);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod component_header_geometry_tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn current_penpot_inspector_header_geometry_is_exact() {
|
||||
assert_eq!(COMPONENT_HEADER_HEIGHT, 50.0);
|
||||
assert_eq!(COMPONENT_RAIL_X, 7.0);
|
||||
assert_eq!(COMPONENT_CARET_CENTER_X, 26.0);
|
||||
assert_eq!(COMPONENT_ICON_CENTER_X, 51.0);
|
||||
assert_eq!(COMPONENT_IDENTITY_X, 69.0);
|
||||
assert_eq!(COMPONENT_ACTIONS_WIDTH, 104.0);
|
||||
}
|
||||
}
|
||||
@@ -10,27 +10,6 @@ pub(super) fn ensure_slot_id(entry: &mut StaticMeshRendererEntry, index: usize)
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn status_dot(ui: &mut egui::Ui, color: egui::Color32, tooltip: &str) {
|
||||
let (rect, response) = ui.allocate_exact_size(egui::vec2(18.0, 20.0), egui::Sense::hover());
|
||||
ui.painter().circle_filled(rect.center(), 4.0, color);
|
||||
response.on_hover_text(tooltip);
|
||||
}
|
||||
|
||||
pub(super) fn status_dot_button(
|
||||
ui: &mut egui::Ui,
|
||||
color: egui::Color32,
|
||||
tooltip: &str,
|
||||
) -> egui::Response {
|
||||
let (rect, response) = ui.allocate_exact_size(egui::vec2(18.0, 20.0), egui::Sense::click());
|
||||
let color = if response.hovered() {
|
||||
color.linear_multiply(1.2)
|
||||
} else {
|
||||
color
|
||||
};
|
||||
ui.painter().circle_filled(rect.center(), 4.0, color);
|
||||
response.on_hover_text(tooltip)
|
||||
}
|
||||
|
||||
pub(super) fn material_drop_invalid_reason(
|
||||
world: &World,
|
||||
valid_material_candidate: bool,
|
||||
@@ -62,15 +41,26 @@ pub(super) struct MaterialSlotWidgetResponse {
|
||||
pub(super) accepted_drop: bool,
|
||||
}
|
||||
|
||||
pub(super) struct MaterialSlotWidgetContext<'a> {
|
||||
pub(super) candidates: &'a [AssetRefCandidate],
|
||||
pub(super) drop_candidate: Option<&'a AssetRefCandidate>,
|
||||
pub(super) invalid_drop_reason: Option<&'static str>,
|
||||
pub(super) expanded_header_when_parameters_closed: bool,
|
||||
}
|
||||
|
||||
pub(super) fn material_slot_widget_ui(
|
||||
world: &mut World,
|
||||
ui: &mut egui::Ui,
|
||||
entity: Entity,
|
||||
slot: &mut shared::MaterialSlot,
|
||||
candidates: &[AssetRefCandidate],
|
||||
drop_candidate: Option<&AssetRefCandidate>,
|
||||
invalid_drop_reason: Option<&'static str>,
|
||||
context: MaterialSlotWidgetContext<'_>,
|
||||
) -> MaterialSlotWidgetResponse {
|
||||
let MaterialSlotWidgetContext {
|
||||
candidates,
|
||||
drop_candidate,
|
||||
invalid_drop_reason,
|
||||
expanded_header_when_parameters_closed,
|
||||
} = context;
|
||||
let mut response = MaterialSlotWidgetResponse::default();
|
||||
let actor_widget_id = stable_actor_widget_id(world, entity);
|
||||
let project_default = world
|
||||
@@ -165,6 +155,8 @@ pub(super) fn material_slot_widget_ui(
|
||||
crate::ui::materials::MaterialThumbnailPresentation::Failed
|
||||
} else if let Some(texture) = texture_id {
|
||||
crate::ui::materials::MaterialThumbnailPresentation::Ready(texture)
|
||||
} else if effective.is_none() {
|
||||
crate::ui::materials::MaterialThumbnailPresentation::Empty
|
||||
} else {
|
||||
crate::ui::materials::MaterialThumbnailPresentation::Pending
|
||||
};
|
||||
@@ -227,6 +219,8 @@ pub(super) fn material_slot_widget_ui(
|
||||
can_clear: slot.material.is_some(),
|
||||
can_extract: is_imported_source,
|
||||
can_create_instance: is_project_material,
|
||||
parameters_initially_open: true,
|
||||
expanded_header_when_parameters_closed,
|
||||
};
|
||||
|
||||
let widget_slot_id = slot.id.0.clone();
|
||||
|
||||
@@ -81,9 +81,12 @@ pub(super) fn skinned_mesh_renderer_ui(world: &mut World, ui: &mut egui::Ui, ent
|
||||
ui,
|
||||
entity,
|
||||
slot,
|
||||
&material_candidates,
|
||||
material_drop_candidate.as_ref(),
|
||||
invalid_material_drop,
|
||||
MaterialSlotWidgetContext {
|
||||
candidates: &material_candidates,
|
||||
drop_candidate: material_drop_candidate.as_ref(),
|
||||
invalid_drop_reason: invalid_material_drop,
|
||||
expanded_header_when_parameters_closed: true,
|
||||
},
|
||||
);
|
||||
changed |= widget.changed;
|
||||
accepted_drop |= widget.accepted_drop;
|
||||
@@ -172,7 +175,7 @@ pub(super) fn static_mesh_renderer_ui(world: &mut World, ui: &mut egui::Ui, enti
|
||||
let card = component_card_context(world, entity, options);
|
||||
let card_response = component_card(ui, &card, |ui| {
|
||||
let add_slot = renderer_array_header(ui, renderer.slots.len());
|
||||
ui.add_space(10.0);
|
||||
ui.add_space(26.0);
|
||||
if renderer.slots.is_empty() {
|
||||
ui.label(egui::RichText::new("No renderer slots").color(TEXT_DIM));
|
||||
}
|
||||
@@ -190,65 +193,97 @@ pub(super) fn static_mesh_renderer_ui(world: &mut World, ui: &mut egui::Ui, enti
|
||||
renderer_panel(ui, |ui| {
|
||||
renderer_panel_header(
|
||||
ui,
|
||||
index,
|
||||
&entry.name,
|
||||
thumbnail,
|
||||
RendererPanelHeaderViewModel {
|
||||
index,
|
||||
label: &entry.name,
|
||||
path: entry
|
||||
.mesh
|
||||
.source_path
|
||||
.as_deref()
|
||||
.unwrap_or(&entry.mesh.sub_asset_id),
|
||||
slot_count: 1,
|
||||
texture_id: thumbnail,
|
||||
},
|
||||
&mut renderer_open,
|
||||
|ui| {
|
||||
status_dot(ui, egui::Color32::from_rgb(74, 181, 104), "Slot active");
|
||||
if icon_button_small(ui, icons::TRASH, "Remove slot").clicked() {
|
||||
editor_ui::design_system::controls::icon_button(
|
||||
ui,
|
||||
icons::DOTS_THREE_VERTICAL,
|
||||
"Renderer actions",
|
||||
true,
|
||||
);
|
||||
if editor_ui::design_system::controls::icon_button(
|
||||
ui,
|
||||
icons::TRASH,
|
||||
"Remove slot",
|
||||
true,
|
||||
)
|
||||
.clicked()
|
||||
{
|
||||
remove_entry = Some(index);
|
||||
}
|
||||
ui.label(phosphor_icon(icons::DOTS_THREE_VERTICAL, 16.0).color(TEXT_DIM));
|
||||
editor_ui::design_system::controls::icon_button(
|
||||
ui,
|
||||
icons::CROSSHAIR,
|
||||
"Locate mesh",
|
||||
true,
|
||||
);
|
||||
editor_ui::design_system::controls::icon_button(
|
||||
ui,
|
||||
icons::FOLDER_OPEN,
|
||||
"Browse mesh",
|
||||
true,
|
||||
);
|
||||
},
|
||||
);
|
||||
if !renderer_open {
|
||||
return;
|
||||
}
|
||||
let mut draw_fields = |ui: &mut egui::Ui, entry: &mut StaticMeshRendererEntry| {
|
||||
renderer_properties_header(ui);
|
||||
property_row(ui, "Name", |ui| {
|
||||
changed |= ui
|
||||
.add_sized(
|
||||
[text_field_width(ui), 20.0],
|
||||
egui::TextEdit::singleline(&mut entry.name),
|
||||
)
|
||||
.changed();
|
||||
});
|
||||
let mesh_response = asset_selector_row(
|
||||
ui,
|
||||
"Mesh",
|
||||
icons::CUBE,
|
||||
Some(&entry.mesh),
|
||||
None,
|
||||
false,
|
||||
&mesh_candidates,
|
||||
None,
|
||||
None,
|
||||
AssetSelectorActions::Full,
|
||||
);
|
||||
if let Some(selected) = mesh_response.selected {
|
||||
entry.mesh = selected;
|
||||
changed = true;
|
||||
}
|
||||
if mesh_response.locate {
|
||||
locate_asset_ref(world, Some(&entry.mesh), &mesh_candidates);
|
||||
}
|
||||
|
||||
ui.horizontal_wrapped(|ui| {
|
||||
changed |= ui.checkbox(&mut entry.visible, "Visible").changed();
|
||||
changed |= ui
|
||||
.checkbox(&mut entry.cast_shadows, "Cast shadows")
|
||||
.changed();
|
||||
changed |= ui
|
||||
.checkbox(&mut entry.receive_shadows, "Receive shadows")
|
||||
.changed();
|
||||
});
|
||||
};
|
||||
|
||||
egui::Frame::new()
|
||||
.inner_margin(egui::Margin::symmetric(12, 10))
|
||||
.show(ui, |ui| draw_fields(ui, entry));
|
||||
.show(ui, |ui| {
|
||||
renderer_properties_header(ui);
|
||||
ui.add_space(2.0);
|
||||
property_row(ui, "Name", |ui| {
|
||||
changed |= ui
|
||||
.add_sized(
|
||||
[text_field_width(ui), 20.0],
|
||||
egui::TextEdit::singleline(&mut entry.name),
|
||||
)
|
||||
.changed();
|
||||
});
|
||||
ui.add_space(4.0);
|
||||
let mesh_response = asset_selector_row(
|
||||
ui,
|
||||
"Mesh",
|
||||
icons::CUBE,
|
||||
Some(&entry.mesh),
|
||||
None,
|
||||
false,
|
||||
&mesh_candidates,
|
||||
None,
|
||||
None,
|
||||
AssetSelectorActions::Full,
|
||||
);
|
||||
if let Some(selected) = mesh_response.selected {
|
||||
entry.mesh = selected;
|
||||
changed = true;
|
||||
}
|
||||
if mesh_response.locate {
|
||||
locate_asset_ref(world, Some(&entry.mesh), &mesh_candidates);
|
||||
}
|
||||
ui.add_space(4.0);
|
||||
ui.horizontal_wrapped(|ui| {
|
||||
changed |= ui.checkbox(&mut entry.visible, "Visible").changed();
|
||||
changed |= ui
|
||||
.checkbox(&mut entry.cast_shadows, "Cast shadows")
|
||||
.changed();
|
||||
changed |= ui
|
||||
.checkbox(&mut entry.receive_shadows, "Receive shadows")
|
||||
.changed();
|
||||
});
|
||||
ui.add_space(4.0);
|
||||
});
|
||||
renderer_material_slots_header(ui, 1);
|
||||
if let Some(slot) = material_set.slot_mut(&entry.material_slot_id) {
|
||||
let widget = renderer_material_slot_row(ui, index, |ui| {
|
||||
@@ -257,9 +292,12 @@ pub(super) fn static_mesh_renderer_ui(world: &mut World, ui: &mut egui::Ui, enti
|
||||
ui,
|
||||
entity,
|
||||
slot,
|
||||
&material_candidates,
|
||||
material_drop_candidate.as_ref(),
|
||||
invalid_material_drop,
|
||||
MaterialSlotWidgetContext {
|
||||
candidates: &material_candidates,
|
||||
drop_candidate: material_drop_candidate.as_ref(),
|
||||
invalid_drop_reason: invalid_material_drop,
|
||||
expanded_header_when_parameters_closed: true,
|
||||
},
|
||||
)
|
||||
});
|
||||
changed |= widget.changed;
|
||||
@@ -317,109 +355,3 @@ pub(super) fn static_mesh_renderer_ui(world: &mut World, ui: &mut egui::Ui, enti
|
||||
set_static_mesh_renderer_with_history(world, entity, renderer);
|
||||
}
|
||||
}
|
||||
|
||||
fn renderer_array_header(ui: &mut egui::Ui, count: usize) -> bool {
|
||||
let palette = crate::ui::design_system::palette(ui);
|
||||
let (rect, _) = ui.allocate_exact_size(
|
||||
egui::vec2(ui.available_width().max(1.0), 40.0),
|
||||
egui::Sense::hover(),
|
||||
);
|
||||
ui.painter().rect_filled(rect, 4.0, palette.elevated);
|
||||
ui.painter().text(
|
||||
rect.left_center() + egui::vec2(12.0, 0.0),
|
||||
egui::Align2::LEFT_CENTER,
|
||||
icons::SQUARES_FOUR.as_str(),
|
||||
egui::FontId::new(16.0, egui::FontFamily::Name("phosphor-regular".into())),
|
||||
palette.text_secondary,
|
||||
);
|
||||
ui.painter().text(
|
||||
rect.left_center() + egui::vec2(36.0, 0.0),
|
||||
egui::Align2::LEFT_CENTER,
|
||||
"Mesh renderers",
|
||||
crate::ui::design_system::typography::TypeRole::Section.font(),
|
||||
palette.text_primary,
|
||||
);
|
||||
ui.painter().text(
|
||||
rect.left_center() + egui::vec2(132.0, 0.0),
|
||||
egui::Align2::LEFT_CENTER,
|
||||
format!("{count}"),
|
||||
crate::ui::design_system::typography::TypeRole::Small.font(),
|
||||
palette.text_muted,
|
||||
);
|
||||
let add_rect = egui::Rect::from_min_size(
|
||||
egui::pos2(rect.right() - 116.0, rect.top() + 7.0),
|
||||
egui::vec2(104.0, 26.0),
|
||||
);
|
||||
ui.put(
|
||||
add_rect,
|
||||
egui::Button::new(crate::ui::design_system::controls::icon_label(
|
||||
icons::PLUS,
|
||||
"Add renderer",
|
||||
crate::ui::design_system::typography::TypeRole::Body,
|
||||
12.0,
|
||||
palette.text_primary,
|
||||
)),
|
||||
)
|
||||
.clicked()
|
||||
}
|
||||
|
||||
fn renderer_material_slots_header(ui: &mut egui::Ui, count: usize) {
|
||||
let palette = crate::ui::design_system::palette(ui);
|
||||
let (rect, _) = ui.allocate_exact_size(
|
||||
egui::vec2(ui.available_width().max(1.0), 38.0),
|
||||
egui::Sense::hover(),
|
||||
);
|
||||
ui.painter().text(
|
||||
rect.left_center() + egui::vec2(10.0, 0.0),
|
||||
egui::Align2::LEFT_CENTER,
|
||||
"Material slots",
|
||||
crate::ui::design_system::typography::TypeRole::Section.font(),
|
||||
palette.text_primary,
|
||||
);
|
||||
ui.painter().text(
|
||||
rect.right_center() - egui::vec2(10.0, 0.0),
|
||||
egui::Align2::RIGHT_CENTER,
|
||||
format!("{count}"),
|
||||
crate::ui::design_system::typography::TypeRole::Small.font(),
|
||||
palette.text_muted,
|
||||
);
|
||||
}
|
||||
|
||||
fn renderer_properties_header(ui: &mut egui::Ui) {
|
||||
let palette = crate::ui::design_system::palette(ui);
|
||||
let (rect, _) = ui.allocate_exact_size(
|
||||
egui::vec2(ui.available_width().max(1.0), 18.0),
|
||||
egui::Sense::hover(),
|
||||
);
|
||||
ui.painter().text(
|
||||
rect.left_center(),
|
||||
egui::Align2::LEFT_CENTER,
|
||||
"Renderer properties",
|
||||
crate::ui::design_system::typography::TypeRole::Caption.font(),
|
||||
palette.text_muted,
|
||||
);
|
||||
}
|
||||
|
||||
fn renderer_material_slot_row<R>(
|
||||
ui: &mut egui::Ui,
|
||||
index: usize,
|
||||
add_contents: impl FnOnce(&mut egui::Ui) -> R,
|
||||
) -> R {
|
||||
let palette = crate::ui::design_system::palette(ui);
|
||||
ui.horizontal_top(|ui| {
|
||||
let (index_rect, _) = ui.allocate_exact_size(egui::vec2(31.0, 60.0), egui::Sense::hover());
|
||||
ui.painter().text(
|
||||
index_rect.center_top() + egui::vec2(0.0, 18.0),
|
||||
egui::Align2::CENTER_CENTER,
|
||||
index.to_string(),
|
||||
crate::ui::design_system::typography::TypeRole::Body.font(),
|
||||
palette.text_muted,
|
||||
);
|
||||
ui.vertical(|ui| {
|
||||
ui.set_width(ui.available_width().max(1.0));
|
||||
add_contents(ui)
|
||||
})
|
||||
.inner
|
||||
})
|
||||
.inner
|
||||
}
|
||||
@@ -65,9 +65,12 @@ pub(super) fn primitive_editor_ui(world: &mut World, ui: &mut egui::Ui, entity:
|
||||
ui,
|
||||
entity,
|
||||
&mut primitive.surface,
|
||||
&material_candidates,
|
||||
material_drop_candidate.as_ref(),
|
||||
invalid_material_drop,
|
||||
MaterialSlotWidgetContext {
|
||||
candidates: &material_candidates,
|
||||
drop_candidate: material_drop_candidate.as_ref(),
|
||||
invalid_drop_reason: invalid_material_drop,
|
||||
expanded_header_when_parameters_closed: false,
|
||||
},
|
||||
)
|
||||
});
|
||||
changed |= widget.changed;
|
||||
|
||||
@@ -1,124 +1,5 @@
|
||||
//! Penpot renderer-panel chrome shared by static renderer entries.
|
||||
|
||||
use super::*;
|
||||
|
||||
const EXPANDED_RENDERER_HEADER_HEIGHT: f32 = 84.0;
|
||||
const COLLAPSED_RENDERER_HEADER_HEIGHT: f32 = 58.0;
|
||||
|
||||
pub(super) fn renderer_panel(ui: &mut egui::Ui, add_contents: impl FnOnce(&mut egui::Ui)) {
|
||||
egui::Frame::new()
|
||||
.fill(WIDGET_BG.linear_multiply(0.82))
|
||||
.stroke(egui::Stroke::new(1.0_f32, BORDER))
|
||||
.corner_radius(egui::CornerRadius::same(5))
|
||||
.show(ui, |ui| {
|
||||
ui.set_max_width(ui.available_width());
|
||||
add_contents(ui);
|
||||
});
|
||||
ui.add_space(10.0);
|
||||
}
|
||||
|
||||
pub(super) fn renderer_panel_header(
|
||||
ui: &mut egui::Ui,
|
||||
index: usize,
|
||||
slot_name: &str,
|
||||
texture_id: Option<egui::TextureId>,
|
||||
open: &mut bool,
|
||||
add_actions: impl FnOnce(&mut egui::Ui),
|
||||
) {
|
||||
let palette = crate::ui::design_system::palette(ui);
|
||||
let height = if *open {
|
||||
EXPANDED_RENDERER_HEADER_HEIGHT
|
||||
} else {
|
||||
COLLAPSED_RENDERER_HEADER_HEIGHT
|
||||
};
|
||||
let (rect, header_response) = ui.allocate_exact_size(
|
||||
egui::vec2(ui.available_width().max(1.0), height),
|
||||
egui::Sense::click(),
|
||||
);
|
||||
ui.painter().rect_filled(
|
||||
egui::Rect::from_min_size(
|
||||
rect.min + egui::vec2(6.0, 8.0),
|
||||
egui::vec2(3.0, height - 16.0),
|
||||
),
|
||||
2.0,
|
||||
palette.accent,
|
||||
);
|
||||
ui.painter().text(
|
||||
rect.left_center() + egui::vec2(20.0, 0.0),
|
||||
egui::Align2::CENTER_CENTER,
|
||||
if *open {
|
||||
icons::CARET_DOWN.as_str()
|
||||
} else {
|
||||
icons::CARET_RIGHT.as_str()
|
||||
},
|
||||
egui::FontId::new(12.0, egui::FontFamily::Name("phosphor-regular".into())),
|
||||
palette.text_secondary,
|
||||
);
|
||||
let preview_size = if *open { 58.0 } else { 40.0 };
|
||||
let preview = egui::Rect::from_center_size(
|
||||
egui::pos2(rect.left() + 63.0, rect.center().y),
|
||||
egui::vec2(preview_size, preview_size),
|
||||
);
|
||||
ui.painter().rect(
|
||||
preview,
|
||||
4.0,
|
||||
PANEL_BG_DARK,
|
||||
egui::Stroke::new(1.0_f32, BORDER),
|
||||
egui::StrokeKind::Inside,
|
||||
);
|
||||
if let Some(texture_id) = texture_id {
|
||||
ui.painter().image(
|
||||
texture_id,
|
||||
preview.shrink(3.0),
|
||||
egui::Rect::from_min_max(egui::Pos2::ZERO, egui::pos2(1.0, 1.0)),
|
||||
egui::Color32::WHITE,
|
||||
);
|
||||
}
|
||||
let label = if slot_name.trim().is_empty() {
|
||||
"Mesh renderer"
|
||||
} else {
|
||||
slot_name.trim()
|
||||
};
|
||||
ui.painter().text(
|
||||
egui::pos2(rect.left() + 104.0, rect.center().y - 8.0),
|
||||
egui::Align2::LEFT_CENTER,
|
||||
label,
|
||||
crate::ui::design_system::typography::TypeRole::Title.font(),
|
||||
palette.text_primary,
|
||||
);
|
||||
ui.painter().text(
|
||||
egui::pos2(rect.left() + 104.0, rect.center().y + 10.0),
|
||||
egui::Align2::LEFT_CENTER,
|
||||
format!("Renderer {index}"),
|
||||
crate::ui::design_system::typography::TypeRole::Small.font(),
|
||||
palette.text_muted,
|
||||
);
|
||||
let action_rect = egui::Rect::from_min_size(
|
||||
egui::pos2(rect.right() - 150.0, rect.center().y - 14.0),
|
||||
egui::vec2(140.0, 28.0),
|
||||
);
|
||||
ui.scope_builder(egui::UiBuilder::new().max_rect(action_rect), |ui| {
|
||||
ui.with_layout(
|
||||
egui::Layout::right_to_left(egui::Align::Center),
|
||||
add_actions,
|
||||
);
|
||||
});
|
||||
if header_response.clicked()
|
||||
&& ui
|
||||
.input(|input| input.pointer.interact_pos())
|
||||
.is_some_and(|pointer| !preview.contains(pointer) && !action_rect.contains(pointer))
|
||||
{
|
||||
*open = !*open;
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn renderer_headers_match_current_penpot_heights() {
|
||||
assert_eq!(EXPANDED_RENDERER_HEADER_HEIGHT, 84.0);
|
||||
assert_eq!(COLLAPSED_RENDERER_HEADER_HEIGHT, 58.0);
|
||||
}
|
||||
}
|
||||
pub(super) use editor_ui::renderer::{
|
||||
renderer_array_header, renderer_material_slot_row, renderer_material_slots_header,
|
||||
renderer_panel, renderer_panel_header, renderer_properties_header,
|
||||
RendererPanelHeaderViewModel,
|
||||
};
|
||||
@@ -55,7 +55,7 @@ pub(super) fn unsupported_advanced_preview(ui: &mut egui::Ui) {
|
||||
} else {
|
||||
icons::CARET_RIGHT.as_str()
|
||||
},
|
||||
egui::FontId::new(10.0, egui::FontFamily::Name("phosphor-regular".into())),
|
||||
egui::FontId::new(10.0, egui::FontFamily::Name("phosphor-bold".into())),
|
||||
palette.text_secondary,
|
||||
);
|
||||
ui.painter().text(
|
||||
|
||||
@@ -23,7 +23,7 @@ pub(crate) fn material_asset_editor(
|
||||
.and_then(|selection| {
|
||||
texture_assets
|
||||
.iter()
|
||||
.find(|candidate| candidate.selection == *selection)
|
||||
.find(|candidate| material_locate_matches_selection(&candidate.locate, selection))
|
||||
})
|
||||
.cloned();
|
||||
let original = draft_asset.clone();
|
||||
@@ -53,7 +53,7 @@ pub(crate) fn material_asset_editor(
|
||||
&mut draft_asset.render_state,
|
||||
Some(&mut draft_asset.inputs),
|
||||
);
|
||||
ui.add_space(8.0);
|
||||
ui.add_space(4.0);
|
||||
let input_response = material_input_schema_editor(
|
||||
ui,
|
||||
&input_schema,
|
||||
@@ -62,8 +62,10 @@ pub(crate) fn material_asset_editor(
|
||||
texture_drop_candidate.as_ref(),
|
||||
);
|
||||
accepted_texture_drop |= input_response.accepted_drop;
|
||||
if let Some(selection) = input_response.locate {
|
||||
world.resource_mut::<EditorAssets>().select(selection);
|
||||
if let Some(target) = input_response.locate {
|
||||
world
|
||||
.resource_mut::<EditorAssets>()
|
||||
.select(material_locate_selection(target));
|
||||
crate::ui::request_editor_tab(world, crate::ui::EditorTab::AssetBrowser);
|
||||
}
|
||||
if input_response.browse_library {
|
||||
@@ -112,117 +114,3 @@ fn material_source_diagnostics_ui(ui: &mut egui::Ui, provenance: &shared::Materi
|
||||
});
|
||||
ui.small("Reimport comparison never overwrites an edited project material automatically.");
|
||||
}
|
||||
|
||||
pub(super) fn material_surface_options_ui(
|
||||
ui: &mut egui::Ui,
|
||||
state: &mut shared::MaterialRenderState,
|
||||
packed_inputs: Option<&mut shared::MaterialInputSet>,
|
||||
) {
|
||||
let palette = crate::ui::design_system::palette(ui);
|
||||
let width = ui.available_width().max(1.0);
|
||||
let height = match super::layout::ResponsiveMaterialLayout::for_width(width) {
|
||||
super::layout::ResponsiveMaterialLayout::Reference => {
|
||||
crate::ui::design_system::SURFACE_SECTION_HEIGHT
|
||||
}
|
||||
super::layout::ResponsiveMaterialLayout::Compact => {
|
||||
crate::ui::design_system::COMPACT_SURFACE_SECTION_HEIGHT
|
||||
}
|
||||
super::layout::ResponsiveMaterialLayout::Transient => 100.0,
|
||||
};
|
||||
let (rect, _) = ui.allocate_exact_size(egui::vec2(width, height), egui::Sense::hover());
|
||||
ui.painter().rect(
|
||||
rect,
|
||||
5.0,
|
||||
palette.section,
|
||||
egui::Stroke::new(1.0_f32, palette.border),
|
||||
egui::StrokeKind::Inside,
|
||||
);
|
||||
let geometry = super::layout::SurfaceSectionGeometry::for_rect(rect);
|
||||
ui.painter().text(
|
||||
geometry.title.left_center(),
|
||||
egui::Align2::LEFT_CENTER,
|
||||
"Surface",
|
||||
crate::ui::design_system::typography::TypeRole::Section.font(),
|
||||
palette.text_primary,
|
||||
);
|
||||
clipped_rect_ui(ui, geometry.blend, |ui| {
|
||||
surface_blend_controls(ui, state);
|
||||
});
|
||||
if let Some(inputs) = packed_inputs {
|
||||
clipped_rect_ui(ui, geometry.packed, |ui| {
|
||||
packed_mode_controls(ui, inputs);
|
||||
});
|
||||
}
|
||||
ui.painter().text(
|
||||
geometry.double_sided.left_center() + egui::vec2(7.0, 0.0),
|
||||
egui::Align2::LEFT_CENTER,
|
||||
"Double Sided",
|
||||
crate::ui::design_system::typography::TypeRole::Body.font(),
|
||||
palette.text_secondary,
|
||||
);
|
||||
let switch_rect = egui::Rect::from_min_size(
|
||||
geometry.double_sided.min + egui::vec2(76.0, 3.0),
|
||||
egui::vec2(31.0, 16.0),
|
||||
);
|
||||
clipped_rect_ui(ui, switch_rect, |ui| {
|
||||
crate::ui::design_system::controls::switch(ui, &mut state.double_sided)
|
||||
.on_hover_text("Render both sides of the surface");
|
||||
});
|
||||
}
|
||||
|
||||
fn packed_mode_controls(ui: &mut egui::Ui, inputs: &mut shared::MaterialInputSet) {
|
||||
let arm = super::inputs::packed_map_mode(inputs) == super::inputs::PackedMapMode::Arm;
|
||||
match crate::ui::design_system::controls::two_option_segmented(ui, "Separate", "ORM", arm) {
|
||||
Some(false) => super::inputs::apply_separate_texture_preset(inputs),
|
||||
Some(true) => super::inputs::apply_arm_texture_preset(inputs),
|
||||
None => {}
|
||||
}
|
||||
}
|
||||
|
||||
fn surface_blend_controls(ui: &mut egui::Ui, state: &mut shared::MaterialRenderState) {
|
||||
let width = ui.available_width().max(1.0);
|
||||
let show_cutoff = state.alpha_mode == MaterialAlphaMode::Cutout;
|
||||
let combo_width = if show_cutoff {
|
||||
(width - 58.0).max(1.0)
|
||||
} else {
|
||||
width
|
||||
};
|
||||
let combo_rect = egui::Rect::from_min_size(ui.min_rect().min, egui::vec2(combo_width, 24.0));
|
||||
clipped_rect_ui(ui, combo_rect, |ui| {
|
||||
egui::ComboBox::from_id_salt("material_alpha_mode")
|
||||
.selected_text(match state.alpha_mode {
|
||||
MaterialAlphaMode::Opaque => "Opaque",
|
||||
MaterialAlphaMode::Cutout => "Cutout",
|
||||
})
|
||||
.width(combo_width)
|
||||
.show_ui(ui, |ui| {
|
||||
ui.selectable_value(&mut state.alpha_mode, MaterialAlphaMode::Opaque, "Opaque");
|
||||
ui.selectable_value(&mut state.alpha_mode, MaterialAlphaMode::Cutout, "Cutout");
|
||||
});
|
||||
});
|
||||
if show_cutoff {
|
||||
let cutoff_rect = egui::Rect::from_min_size(
|
||||
ui.min_rect().min + egui::vec2(combo_width + 4.0, 1.0),
|
||||
egui::vec2(54.0_f32.min(width - combo_width - 4.0), 22.0),
|
||||
);
|
||||
ui.put(
|
||||
cutoff_rect,
|
||||
egui::DragValue::new(&mut state.alpha_cutoff)
|
||||
.range(0.0..=1.0)
|
||||
.speed(0.01),
|
||||
)
|
||||
.on_hover_text("Alpha cutoff");
|
||||
}
|
||||
}
|
||||
|
||||
fn clipped_rect_ui<R>(
|
||||
ui: &mut egui::Ui,
|
||||
rect: egui::Rect,
|
||||
add_contents: impl FnOnce(&mut egui::Ui) -> R,
|
||||
) -> R {
|
||||
ui.scope_builder(egui::UiBuilder::new().max_rect(rect), |ui| {
|
||||
ui.set_clip_rect(rect.intersect(ui.clip_rect()));
|
||||
add_contents(ui)
|
||||
})
|
||||
.inner
|
||||
}
|
||||
@@ -269,7 +269,7 @@ pub(super) fn material_texture_candidates(world: &mut World) -> Vec<MaterialText
|
||||
label: asset.label.clone(),
|
||||
detail: path.to_string(),
|
||||
reference,
|
||||
selection: AssetSelection::File(path.to_string()),
|
||||
locate: MaterialLocateTarget::File(path.to_string()),
|
||||
thumbnail: thumbnails.as_ref().map_or(
|
||||
MaterialThumbnailPresentation::Pending,
|
||||
|cache| {
|
||||
@@ -325,11 +325,10 @@ pub(super) fn material_texture_candidates(world: &mut World) -> Vec<MaterialText
|
||||
label: label.clone(),
|
||||
detail: format!("{} | {source_path}", asset.label),
|
||||
reference,
|
||||
selection: AssetSelection::SubAsset {
|
||||
locate: MaterialLocateTarget::SubAsset {
|
||||
parent_path: parent_path.to_string(),
|
||||
sub_asset_id,
|
||||
label,
|
||||
kind: AssetSubAssetKind::Texture,
|
||||
source_path: Some(source_path.clone()),
|
||||
},
|
||||
thumbnail: MaterialThumbnailPresentation::Pending,
|
||||
|
||||
@@ -220,12 +220,21 @@ pub(super) fn material_input_rows(
|
||||
);
|
||||
let rects = geometry.row_rects(row_rect);
|
||||
rect_ui(ui, rects.label, |ui| material_input_label(ui, property));
|
||||
rect_ui(ui, rects.value, |ui| {
|
||||
material_input_value_ui(ui, property, companion, inputs)
|
||||
});
|
||||
rect_ui(ui, rects.channel, |ui| {
|
||||
material_input_channel_ui(ui, property, inputs)
|
||||
});
|
||||
let is_color = matches!(property.property_type, ShaderPropertyType::Color);
|
||||
rect_ui(
|
||||
ui,
|
||||
if is_color {
|
||||
rects.color_value
|
||||
} else {
|
||||
rects.value
|
||||
},
|
||||
|ui| material_input_value_ui(ui, property, companion, inputs),
|
||||
);
|
||||
if !is_color {
|
||||
rect_ui(ui, rects.channel, |ui| {
|
||||
material_input_channel_ui(ui, property, inputs)
|
||||
});
|
||||
}
|
||||
if material_input_uses_texture(property) {
|
||||
let texture = rect_ui(ui, rects.texture_group, |ui| {
|
||||
material_input_texture_ui(
|
||||
@@ -518,7 +527,7 @@ fn readonly_channel(ui: &mut egui::Ui, channel: &str) {
|
||||
rect.right_center() - egui::vec2(8.0, 0.0),
|
||||
egui::Align2::CENTER_CENTER,
|
||||
egui_phosphor_icons::icons::CARET_DOWN.as_str(),
|
||||
egui::FontId::new(9.0, egui::FontFamily::Name("phosphor-regular".into())),
|
||||
egui::FontId::new(9.0, egui::FontFamily::Name("phosphor-bold".into())),
|
||||
palette.text_muted,
|
||||
);
|
||||
response.on_hover_text("Channel is fixed by this material input");
|
||||
|
||||
@@ -29,7 +29,7 @@ pub(crate) fn material_instance_asset_editor(
|
||||
.and_then(|selection| {
|
||||
texture_assets
|
||||
.iter()
|
||||
.find(|candidate| candidate.selection == *selection)
|
||||
.find(|candidate| material_locate_matches_selection(&candidate.locate, selection))
|
||||
})
|
||||
.cloned();
|
||||
let original = draft.clone();
|
||||
@@ -58,13 +58,9 @@ pub(crate) fn material_instance_asset_editor(
|
||||
}
|
||||
ui.add_enabled_ui(false, |ui| {
|
||||
let mut render_state = base_asset.render_state;
|
||||
super::asset_editor::material_surface_options_ui(
|
||||
ui,
|
||||
&mut render_state,
|
||||
Some(&mut draft.overrides),
|
||||
);
|
||||
material_surface_options_ui(ui, &mut render_state, Some(&mut draft.overrides));
|
||||
});
|
||||
ui.add_space(8.0);
|
||||
ui.add_space(4.0);
|
||||
let input_response = super::instance_inputs::material_instance_input_schema_editor(
|
||||
ui,
|
||||
&schema,
|
||||
@@ -73,8 +69,10 @@ pub(crate) fn material_instance_asset_editor(
|
||||
&texture_assets,
|
||||
texture_drop_candidate.as_ref(),
|
||||
);
|
||||
if let Some(selection) = input_response.locate.clone() {
|
||||
world.resource_mut::<EditorAssets>().select(selection);
|
||||
if let Some(target) = input_response.locate.clone() {
|
||||
world
|
||||
.resource_mut::<EditorAssets>()
|
||||
.select(material_locate_selection(target));
|
||||
crate::ui::request_editor_tab(world, crate::ui::EditorTab::AssetBrowser);
|
||||
}
|
||||
if input_response.browse_library {
|
||||
|
||||
@@ -14,7 +14,7 @@ pub(super) fn material_instance_input_schema_editor(
|
||||
let mut effective = normalized_base.clone();
|
||||
overlay_inputs(&mut effective, overrides);
|
||||
|
||||
let response = super::inputs::material_input_schema_editor_with_inheritance(
|
||||
let response = material_input_schema_editor_with_inheritance(
|
||||
ui,
|
||||
schema,
|
||||
&mut effective,
|
||||
@@ -110,6 +110,7 @@ fn upsert_texture(textures: &mut Vec<MaterialTextureBinding>, texture: MaterialT
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use shared::MaterialParameterValue;
|
||||
|
||||
#[test]
|
||||
fn instance_editor_retains_only_values_different_from_base() {
|
||||
|
||||
@@ -7,14 +7,12 @@
|
||||
use std::collections::HashSet;
|
||||
use std::path::Path;
|
||||
|
||||
use bevy::prelude::{Vec2, Vec3, World};
|
||||
use bevy::prelude::World;
|
||||
use bevy_egui::egui;
|
||||
use egui_phosphor_icons::{icons, Icon};
|
||||
use shared::{
|
||||
standard_lit_input_schema, ColorDesc, EditorAssetRef, MaterialAlphaMode, MaterialAsset,
|
||||
MaterialInputDesc, MaterialInputSchema, MaterialInputSet, MaterialInstanceAsset,
|
||||
MaterialParameter, MaterialParameterValue, MaterialRef, MaterialShaderKind,
|
||||
MaterialTextureBinding, ShaderPropertyType, ShaderSchemaAsset, TextureChannel,
|
||||
standard_lit_input_schema, EditorAssetRef, MaterialAsset, MaterialInputSchema,
|
||||
MaterialInputSet, MaterialInstanceAsset, MaterialParameter, MaterialRef, MaterialShaderKind,
|
||||
MaterialTextureBinding, ShaderPropertyType, ShaderSchemaAsset,
|
||||
};
|
||||
|
||||
use crate::asset_db::{ensure_asset_record, find_asset_by_path, save_registry};
|
||||
@@ -29,17 +27,10 @@ use crate::ui::document_status::authored_document_status_ui;
|
||||
|
||||
use super::theme::{ERROR, TEXT_DIM, TEXT_MUTED, WARNING};
|
||||
|
||||
mod advanced_preview;
|
||||
mod asset_editor;
|
||||
mod editor;
|
||||
mod inputs;
|
||||
mod instance_editor;
|
||||
mod instance_inputs;
|
||||
mod layout;
|
||||
mod panel;
|
||||
mod pickers;
|
||||
mod texture_inputs;
|
||||
mod uv_transform;
|
||||
|
||||
pub(crate) use asset_editor::material_asset_editor;
|
||||
pub(crate) use editor::{
|
||||
@@ -47,67 +38,57 @@ pub(crate) use editor::{
|
||||
material_shader_label, set_material_shader_kind,
|
||||
};
|
||||
use editor::{material_shader_settings, material_texture_candidates, shader_schema_assets};
|
||||
pub(crate) use inputs::material_input_schema_editor;
|
||||
use inputs::*;
|
||||
pub(crate) use instance_editor::material_instance_asset_editor;
|
||||
pub(crate) use panel::{
|
||||
material_slot_panel, materials_section, MaterialHealth, MaterialLayerBadge,
|
||||
MaterialPickerCandidate, MaterialSlotAction, MaterialSlotPanelViewModel,
|
||||
MaterialsSectionViewModel,
|
||||
pub(crate) use editor_ui::materials::{
|
||||
compact_text_edit, default_value_for_shader_property, ensure_material_texture_binding,
|
||||
material_input_schema_editor, material_input_schema_editor_with_inheritance,
|
||||
material_slot_panel, material_surface_options_ui, materials_section, optional_path_edit,
|
||||
parameter_value_matches_property, shader_kind_picker, MaterialHealth,
|
||||
MaterialInputEditorResponse, MaterialLayerBadge, MaterialLocateTarget, MaterialPickerCandidate,
|
||||
MaterialSlotAction, MaterialSlotPanelViewModel, MaterialTextureCandidate,
|
||||
MaterialThumbnailPresentation, MaterialsSectionViewModel,
|
||||
};
|
||||
use texture_inputs::*;
|
||||
|
||||
const PHOSPHOR: &str = "phosphor-regular";
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub(crate) struct MaterialTextureCandidate {
|
||||
label: String,
|
||||
detail: String,
|
||||
reference: EditorAssetRef,
|
||||
selection: AssetSelection,
|
||||
thumbnail: MaterialThumbnailPresentation,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
pub(crate) enum MaterialThumbnailPresentation {
|
||||
Ready(egui::TextureId),
|
||||
Pending,
|
||||
Failed,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
enum TextureSlotSelection<'a> {
|
||||
Reference(Option<&'a EditorAssetRef>),
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
struct TextureSlotResponse {
|
||||
selected: Option<MaterialTextureCandidate>,
|
||||
locate: Option<AssetSelection>,
|
||||
clear: bool,
|
||||
accepted_drop: bool,
|
||||
browse_library: bool,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
pub(crate) struct MaterialInputEditorResponse {
|
||||
pub accepted_drop: bool,
|
||||
pub locate: Option<AssetSelection>,
|
||||
pub browse_library: bool,
|
||||
}
|
||||
|
||||
fn fit_width(ui: &egui::Ui, min: f32, max: f32) -> f32 {
|
||||
let available = ui.available_width().max(1.0);
|
||||
available.min(max).max(min.min(available))
|
||||
}
|
||||
|
||||
fn icon_text(icon: Icon, size: f32) -> egui::RichText {
|
||||
egui::RichText::new(icon.as_str()).font(egui::FontId::new(
|
||||
size,
|
||||
egui::FontFamily::Name(PHOSPHOR.into()),
|
||||
))
|
||||
}
|
||||
pub(crate) use instance_editor::material_instance_asset_editor;
|
||||
|
||||
fn natural_cmp(left: &str, right: &str) -> std::cmp::Ordering {
|
||||
left.to_ascii_lowercase().cmp(&right.to_ascii_lowercase())
|
||||
}
|
||||
|
||||
fn material_locate_selection(target: MaterialLocateTarget) -> AssetSelection {
|
||||
match target {
|
||||
MaterialLocateTarget::File(path) => AssetSelection::File(path),
|
||||
MaterialLocateTarget::SubAsset {
|
||||
parent_path,
|
||||
sub_asset_id,
|
||||
label,
|
||||
source_path,
|
||||
} => AssetSelection::SubAsset {
|
||||
parent_path,
|
||||
sub_asset_id,
|
||||
label,
|
||||
kind: AssetSubAssetKind::Texture,
|
||||
source_path,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
fn material_locate_matches_selection(
|
||||
target: &MaterialLocateTarget,
|
||||
selection: &AssetSelection,
|
||||
) -> bool {
|
||||
match (target, selection) {
|
||||
(MaterialLocateTarget::File(left), AssetSelection::File(right)) => left == right,
|
||||
(
|
||||
MaterialLocateTarget::SubAsset {
|
||||
parent_path: left_parent,
|
||||
sub_asset_id: left_sub_asset,
|
||||
..
|
||||
},
|
||||
AssetSelection::SubAsset {
|
||||
parent_path: right_parent,
|
||||
sub_asset_id: right_sub_asset,
|
||||
..
|
||||
},
|
||||
) => left_parent == right_parent && left_sub_asset == right_sub_asset,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
@@ -6,14 +6,18 @@ use shared::{EditorAssetRef, MaterialShaderKind};
|
||||
|
||||
use super::layout::MaterialPanelGeometry;
|
||||
use super::MaterialThumbnailPresentation;
|
||||
use crate::ui::design_system::controls::{icon_button, icon_label, status};
|
||||
use crate::ui::design_system::controls::status;
|
||||
use crate::ui::design_system::typography::TypeRole;
|
||||
use crate::ui::design_system::{self, DesignPalette, HEADER_HEIGHT};
|
||||
use crate::ui::widgets::phosphor_icon;
|
||||
|
||||
mod header_actions;
|
||||
|
||||
use header_actions::{expanded_status_actions, overflow_menu, SLOT_STATUS_ACTION_WIDTH};
|
||||
|
||||
const SLOT_ACCENT_X: f32 = 8.0;
|
||||
const SLOT_CARET_CENTER_X: f32 = 23.0;
|
||||
const SLOT_PREVIEW_X: f32 = 35.0;
|
||||
const SHADER_CONTROL_WIDTH: f32 = 220.0;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub(crate) enum MaterialLayerBadge {
|
||||
@@ -73,6 +77,16 @@ impl MaterialHealth {
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
fn icon(self) -> egui_phosphor_icons::Icon {
|
||||
match self {
|
||||
Self::Healthy => icons::CHECK_CIRCLE,
|
||||
Self::Dirty => icons::PENCIL_SIMPLE,
|
||||
Self::Processing => icons::CIRCLE_NOTCH,
|
||||
Self::Broken => icons::WARNING_CIRCLE,
|
||||
Self::ReadOnly => icons::LOCK_SIMPLE,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
@@ -275,16 +289,19 @@ fn slot_header(
|
||||
egui::pos2(rect.left() + SLOT_CARET_CENTER_X, rect.center().y),
|
||||
egui::vec2(18.0, 28.0),
|
||||
);
|
||||
let caret_icon = if *open {
|
||||
icons::CARET_DOWN
|
||||
} else {
|
||||
icons::CARET_RIGHT
|
||||
};
|
||||
let caret = ui.put(
|
||||
caret_rect,
|
||||
egui::Button::new(phosphor_icon(
|
||||
if *open {
|
||||
icons::CARET_DOWN
|
||||
} else {
|
||||
icons::CARET_RIGHT
|
||||
},
|
||||
12.0,
|
||||
))
|
||||
egui::Button::new(
|
||||
egui::RichText::new(caret_icon.as_str()).font(egui::FontId::new(
|
||||
12.0,
|
||||
egui::FontFamily::Name("phosphor-bold".into()),
|
||||
)),
|
||||
)
|
||||
.frame(false),
|
||||
);
|
||||
if caret.clicked() {
|
||||
@@ -299,7 +316,7 @@ fn slot_header(
|
||||
egui::vec2(preview_size, preview_size),
|
||||
);
|
||||
let preview = material_thumbnail_at(ui, view, preview_rect);
|
||||
let action_width = 140.0;
|
||||
let action_width = SLOT_STATUS_ACTION_WIDTH;
|
||||
let identity_left = preview_rect.right() + 6.0;
|
||||
let actions_left = rect.right() - action_width - 8.0;
|
||||
let identity_right = (identity_left + design_system::MATERIAL_IDENTITY_WIDTH)
|
||||
@@ -323,42 +340,20 @@ fn slot_header(
|
||||
})
|
||||
.inner;
|
||||
let actions_rect = egui::Rect::from_min_size(
|
||||
egui::pos2(actions_left, rect.top() + 7.0),
|
||||
egui::vec2(action_width, height - 14.0),
|
||||
egui::pos2(actions_left, rect.top() + if *open { 9.0 } else { 7.0 }),
|
||||
egui::vec2(action_width, if *open { 64.0 } else { height - 14.0 }),
|
||||
);
|
||||
ui.scope_builder(egui::UiBuilder::new().max_rect(actions_rect), |ui| {
|
||||
if *open {
|
||||
ui.with_layout(egui::Layout::top_down(egui::Align::Max), |ui| {
|
||||
let (color, label, tooltip) = view.health.presentation(palette);
|
||||
ui.horizontal(|ui| status(ui, color, label, tooltip));
|
||||
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
|
||||
overflow_menu(ui, view, actions, diagnostics_ui);
|
||||
if view.can_clear
|
||||
&& icon_button(ui, icons::X, "Clear actor assignment", true).clicked()
|
||||
{
|
||||
actions.push(MaterialSlotAction::Clear);
|
||||
}
|
||||
if view.can_locate
|
||||
&& icon_button(ui, icons::CROSSHAIR, "Locate in Content Browser", true)
|
||||
.clicked()
|
||||
{
|
||||
actions.push(MaterialSlotAction::Locate);
|
||||
}
|
||||
if icon_button(ui, icons::FOLDER_OPEN, "Browse project materials", true)
|
||||
.clicked()
|
||||
{
|
||||
actions.push(MaterialSlotAction::BrowseLibrary);
|
||||
}
|
||||
});
|
||||
});
|
||||
} else {
|
||||
if *open {
|
||||
expanded_status_actions(ui, actions_rect, view, actions, diagnostics_ui, palette);
|
||||
} else {
|
||||
ui.scope_builder(egui::UiBuilder::new().max_rect(actions_rect), |ui| {
|
||||
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
|
||||
overflow_menu(ui, view, actions, diagnostics_ui);
|
||||
let (color, label, tooltip) = view.health.presentation(palette);
|
||||
ui.horizontal(|ui| status(ui, color, label, tooltip));
|
||||
ui.horizontal(|ui| status(ui, view.health.icon(), color, label, tooltip));
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
if response.clicked() {
|
||||
if let Some(pointer) = ui.input(|input| input.pointer.interact_pos()) {
|
||||
if !caret_rect.contains(pointer)
|
||||
@@ -482,7 +477,7 @@ fn material_identity(
|
||||
if let Some(mut kind) = view.shader_kind {
|
||||
egui::ComboBox::from_id_salt("material_identity_shader_kind")
|
||||
.selected_text(&view.shader)
|
||||
.width(150.0_f32.min(ui.available_width().max(1.0)))
|
||||
.width(SHADER_CONTROL_WIDTH.min(ui.available_width().max(1.0)))
|
||||
.show_ui(ui, |ui| {
|
||||
ui.selectable_value(&mut kind, MaterialShaderKind::StandardLit, "Standard Lit");
|
||||
ui.selectable_value(&mut kind, MaterialShaderKind::Unlit, "Unlit");
|
||||
@@ -494,7 +489,10 @@ fn material_identity(
|
||||
}
|
||||
} else {
|
||||
ui.add_sized(
|
||||
[150.0_f32.min(ui.available_width().max(1.0)), 22.0],
|
||||
[
|
||||
SHADER_CONTROL_WIDTH.min(ui.available_width().max(1.0)),
|
||||
22.0,
|
||||
],
|
||||
egui::Label::new(
|
||||
TypeRole::Body
|
||||
.text(&view.shader)
|
||||
@@ -572,72 +570,6 @@ fn material_thumbnail_at(
|
||||
response.on_hover_text(format!("Open {} material picker", view.label))
|
||||
}
|
||||
|
||||
fn overflow_menu(
|
||||
ui: &mut egui::Ui,
|
||||
view: &MaterialSlotPanelViewModel,
|
||||
actions: &mut Vec<MaterialSlotAction>,
|
||||
diagnostics_ui: impl FnOnce(&mut egui::Ui),
|
||||
) {
|
||||
let palette = design_system::palette(ui);
|
||||
ui.menu_button(phosphor_icon(icons::DOTS_THREE, 16.0), |ui| {
|
||||
if view.can_locate && menu_action(ui, icons::CROSSHAIR, "Locate", palette.text_primary) {
|
||||
actions.push(MaterialSlotAction::Locate);
|
||||
ui.close();
|
||||
}
|
||||
if menu_action(
|
||||
ui,
|
||||
icons::FOLDER_OPEN,
|
||||
"Browse Asset Library",
|
||||
palette.text_primary,
|
||||
) {
|
||||
actions.push(MaterialSlotAction::BrowseLibrary);
|
||||
ui.close();
|
||||
}
|
||||
if view.can_clear && menu_action(ui, icons::X, "Clear material", palette.text_primary) {
|
||||
actions.push(MaterialSlotAction::Clear);
|
||||
ui.close();
|
||||
}
|
||||
if view.can_create_instance
|
||||
&& menu_action(
|
||||
ui,
|
||||
icons::COPY,
|
||||
"Create Instance and Assign",
|
||||
palette.text_primary,
|
||||
)
|
||||
{
|
||||
actions.push(MaterialSlotAction::CreateInstance);
|
||||
ui.close();
|
||||
}
|
||||
if view.can_extract
|
||||
&& menu_action(ui, icons::EXPORT, "Extract Editable…", palette.text_primary)
|
||||
{
|
||||
actions.push(MaterialSlotAction::ExtractEditable);
|
||||
ui.close();
|
||||
}
|
||||
ui.separator();
|
||||
ui.label(TypeRole::Section.text("Source & Diagnostics"));
|
||||
diagnostics_ui(ui);
|
||||
})
|
||||
.response
|
||||
.on_hover_text("Material actions and diagnostics");
|
||||
}
|
||||
|
||||
fn menu_action(
|
||||
ui: &mut egui::Ui,
|
||||
icon: egui_phosphor_icons::Icon,
|
||||
label: &str,
|
||||
color: egui::Color32,
|
||||
) -> bool {
|
||||
ui.add(egui::Button::new(icon_label(
|
||||
icon,
|
||||
label,
|
||||
TypeRole::Control,
|
||||
14.0,
|
||||
color,
|
||||
)))
|
||||
.clicked()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
@@ -671,6 +603,8 @@ mod tests {
|
||||
assert_eq!(SLOT_CARET_CENTER_X, 23.0);
|
||||
assert_eq!(SLOT_PREVIEW_X, 35.0);
|
||||
assert_eq!(SLOT_PREVIEW_X - (SLOT_CARET_CENTER_X + 6.0), 6.0);
|
||||
assert_eq!(SLOT_STATUS_ACTION_WIDTH, 140.0);
|
||||
assert_eq!(SHADER_CONTROL_WIDTH, 220.0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -740,4 +674,13 @@ mod tests {
|
||||
assert!(!view.health.presentation(palette).1.is_empty());
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn penpot_material_statuses_use_semantic_phosphor_icons() {
|
||||
assert_eq!(MaterialHealth::Healthy.icon(), icons::CHECK_CIRCLE);
|
||||
assert_eq!(MaterialHealth::Dirty.icon(), icons::PENCIL_SIMPLE);
|
||||
assert_eq!(MaterialHealth::Processing.icon(), icons::CIRCLE_NOTCH);
|
||||
assert_eq!(MaterialHealth::Broken.icon(), icons::WARNING_CIRCLE);
|
||||
assert_eq!(MaterialHealth::ReadOnly.icon(), icons::LOCK_SIMPLE);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,216 @@
|
||||
//! Exact Penpot status/action geometry for an expanded material-slot header.
|
||||
|
||||
use bevy_egui::egui;
|
||||
use egui_phosphor_icons::icons;
|
||||
|
||||
use super::{MaterialSlotAction, MaterialSlotPanelViewModel};
|
||||
use crate::ui::design_system::controls::{icon_button, icon_label, status};
|
||||
use crate::ui::design_system::typography::TypeRole;
|
||||
use crate::ui::design_system::{self, DesignPalette};
|
||||
|
||||
pub(super) const SLOT_STATUS_ACTION_WIDTH: f32 = 140.0;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
struct ExpandedHeaderActionGeometry {
|
||||
status: egui::Rect,
|
||||
menu: egui::Rect,
|
||||
browse: egui::Rect,
|
||||
locate: egui::Rect,
|
||||
clear: egui::Rect,
|
||||
}
|
||||
|
||||
fn geometry(rect: egui::Rect) -> ExpandedHeaderActionGeometry {
|
||||
let status_row = egui::Rect::from_min_size(
|
||||
rect.min + egui::vec2(0.0, 5.333),
|
||||
egui::vec2(SLOT_STATUS_ACTION_WIDTH, 24.0),
|
||||
);
|
||||
let menu = egui::Rect::from_min_size(
|
||||
status_row.min + egui::vec2(116.0, 0.0),
|
||||
egui::vec2(24.0, 24.0),
|
||||
);
|
||||
let action_row = rect.min + egui::vec2(0.0, 34.667);
|
||||
ExpandedHeaderActionGeometry {
|
||||
status: egui::Rect::from_min_max(
|
||||
status_row.min,
|
||||
egui::pos2(menu.left() - 5.0, status_row.bottom()),
|
||||
),
|
||||
menu,
|
||||
browse: egui::Rect::from_min_size(
|
||||
action_row + egui::vec2(56.0, 0.0),
|
||||
egui::vec2(24.0, 24.0),
|
||||
),
|
||||
locate: egui::Rect::from_min_size(
|
||||
action_row + egui::vec2(86.0, 0.0),
|
||||
egui::vec2(24.0, 24.0),
|
||||
),
|
||||
clear: egui::Rect::from_min_size(
|
||||
action_row + egui::vec2(116.0, 0.0),
|
||||
egui::vec2(24.0, 24.0),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn expanded_status_actions(
|
||||
ui: &mut egui::Ui,
|
||||
rect: egui::Rect,
|
||||
view: &MaterialSlotPanelViewModel,
|
||||
actions: &mut Vec<MaterialSlotAction>,
|
||||
diagnostics_ui: impl FnOnce(&mut egui::Ui),
|
||||
palette: DesignPalette,
|
||||
) {
|
||||
let geometry = geometry(rect);
|
||||
rect_scope(ui, geometry.status, |ui| {
|
||||
ui.with_layout(egui::Layout::right_to_left(egui::Align::Center), |ui| {
|
||||
let (color, label, tooltip) = view.health.presentation(palette);
|
||||
status(ui, view.health.icon(), color, label, tooltip);
|
||||
});
|
||||
});
|
||||
rect_scope(ui, geometry.menu, |ui| {
|
||||
overflow_menu(ui, view, actions, diagnostics_ui);
|
||||
});
|
||||
|
||||
for (button_rect, action, enabled, icon, tooltip) in [
|
||||
(
|
||||
geometry.browse,
|
||||
MaterialSlotAction::BrowseLibrary,
|
||||
true,
|
||||
icons::FOLDER_OPEN,
|
||||
"Browse project materials",
|
||||
),
|
||||
(
|
||||
geometry.locate,
|
||||
MaterialSlotAction::Locate,
|
||||
view.can_locate,
|
||||
icons::CROSSHAIR,
|
||||
"Locate in Content Browser",
|
||||
),
|
||||
(
|
||||
geometry.clear,
|
||||
MaterialSlotAction::Clear,
|
||||
view.can_clear,
|
||||
icons::X,
|
||||
"Clear actor assignment",
|
||||
),
|
||||
] {
|
||||
if !enabled {
|
||||
continue;
|
||||
}
|
||||
let clicked = rect_scope(ui, button_rect, |ui| {
|
||||
icon_button(ui, icon, tooltip, true).clicked()
|
||||
});
|
||||
if clicked {
|
||||
actions.push(action);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn overflow_menu(
|
||||
ui: &mut egui::Ui,
|
||||
view: &MaterialSlotPanelViewModel,
|
||||
actions: &mut Vec<MaterialSlotAction>,
|
||||
diagnostics_ui: impl FnOnce(&mut egui::Ui),
|
||||
) {
|
||||
let palette = design_system::palette(ui);
|
||||
ui.menu_button(
|
||||
egui::RichText::new(icons::DOTS_THREE.as_str()).font(egui::FontId::new(
|
||||
16.0,
|
||||
egui::FontFamily::Name("phosphor-bold".into()),
|
||||
)),
|
||||
|ui| {
|
||||
if view.can_locate && menu_action(ui, icons::CROSSHAIR, "Locate", palette.text_primary)
|
||||
{
|
||||
actions.push(MaterialSlotAction::Locate);
|
||||
ui.close();
|
||||
}
|
||||
if menu_action(
|
||||
ui,
|
||||
icons::FOLDER_OPEN,
|
||||
"Browse Asset Library",
|
||||
palette.text_primary,
|
||||
) {
|
||||
actions.push(MaterialSlotAction::BrowseLibrary);
|
||||
ui.close();
|
||||
}
|
||||
if view.can_clear && menu_action(ui, icons::X, "Clear material", palette.text_primary) {
|
||||
actions.push(MaterialSlotAction::Clear);
|
||||
ui.close();
|
||||
}
|
||||
if view.can_create_instance
|
||||
&& menu_action(
|
||||
ui,
|
||||
icons::COPY,
|
||||
"Create Instance and Assign",
|
||||
palette.text_primary,
|
||||
)
|
||||
{
|
||||
actions.push(MaterialSlotAction::CreateInstance);
|
||||
ui.close();
|
||||
}
|
||||
if view.can_extract
|
||||
&& menu_action(ui, icons::EXPORT, "Extract Editable…", palette.text_primary)
|
||||
{
|
||||
actions.push(MaterialSlotAction::ExtractEditable);
|
||||
ui.close();
|
||||
}
|
||||
ui.separator();
|
||||
ui.label(TypeRole::Section.text("Source & Diagnostics"));
|
||||
diagnostics_ui(ui);
|
||||
},
|
||||
)
|
||||
.response
|
||||
.on_hover_text("Material actions and diagnostics");
|
||||
}
|
||||
|
||||
fn menu_action(
|
||||
ui: &mut egui::Ui,
|
||||
icon: egui_phosphor_icons::Icon,
|
||||
label: &str,
|
||||
color: egui::Color32,
|
||||
) -> bool {
|
||||
ui.add(egui::Button::new(icon_label(
|
||||
icon,
|
||||
label,
|
||||
TypeRole::Control,
|
||||
14.0,
|
||||
color,
|
||||
)))
|
||||
.clicked()
|
||||
}
|
||||
|
||||
fn rect_scope<R>(
|
||||
ui: &mut egui::Ui,
|
||||
rect: egui::Rect,
|
||||
add_contents: impl FnOnce(&mut egui::Ui) -> R,
|
||||
) -> R {
|
||||
ui.scope_builder(egui::UiBuilder::new().max_rect(rect), |ui| {
|
||||
ui.set_clip_rect(rect.intersect(ui.clip_rect()));
|
||||
add_contents(ui)
|
||||
})
|
||||
.inner
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn expanded_status_and_actions_match_the_penpot_header_geometry() {
|
||||
let rect = egui::Rect::from_min_size(egui::pos2(448.0, 9.0), egui::vec2(140.0, 64.0));
|
||||
let geometry = geometry(rect);
|
||||
assert_eq!(geometry.menu.min, egui::pos2(564.0, 14.333));
|
||||
assert_eq!(geometry.browse.min, egui::pos2(504.0, 43.667));
|
||||
assert_eq!(geometry.locate.min, egui::pos2(534.0, 43.667));
|
||||
assert_eq!(geometry.clear.min, egui::pos2(564.0, 43.667));
|
||||
assert_eq!(geometry.menu.size(), egui::vec2(24.0, 24.0));
|
||||
assert_eq!(geometry.clear.size(), egui::vec2(24.0, 24.0));
|
||||
for child in [
|
||||
geometry.status,
|
||||
geometry.menu,
|
||||
geometry.browse,
|
||||
geometry.locate,
|
||||
geometry.clear,
|
||||
] {
|
||||
assert!(rect.contains_rect(child));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -261,7 +261,7 @@ fn paint_thumbnail(ui: &egui::Ui, rect: egui::Rect, thumbnail: MaterialThumbnail
|
||||
rect.center(),
|
||||
egui::Align2::CENTER_CENTER,
|
||||
icons::CIRCLE_NOTCH.as_str(),
|
||||
egui::FontId::new(14.0, egui::FontFamily::Name("phosphor-regular".into())),
|
||||
egui::FontId::new(14.0, egui::FontFamily::Name("phosphor-bold".into())),
|
||||
palette.text_muted,
|
||||
);
|
||||
}
|
||||
@@ -270,7 +270,7 @@ fn paint_thumbnail(ui: &egui::Ui, rect: egui::Rect, thumbnail: MaterialThumbnail
|
||||
rect.center(),
|
||||
egui::Align2::CENTER_CENTER,
|
||||
icons::WARNING.as_str(),
|
||||
egui::FontId::new(14.0, egui::FontFamily::Name("phosphor-regular".into())),
|
||||
egui::FontId::new(14.0, egui::FontFamily::Name("phosphor-bold".into())),
|
||||
palette.error,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -372,7 +372,7 @@ fn paint_field_icon(
|
||||
rect.center(),
|
||||
egui::Align2::CENTER_CENTER,
|
||||
icon.as_str(),
|
||||
egui::FontId::new(12.0, egui::FontFamily::Name("phosphor-regular".into())),
|
||||
egui::FontId::new(12.0, egui::FontFamily::Name("phosphor-bold".into())),
|
||||
color,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ fn vec2_group(
|
||||
reset_rect,
|
||||
egui::Button::new(
|
||||
egui::RichText::new(icons::ARROW_COUNTER_CLOCKWISE.as_str()).font(
|
||||
egui::FontId::new(14.0, egui::FontFamily::Name("phosphor-regular".into())),
|
||||
egui::FontId::new(14.0, egui::FontFamily::Name("phosphor-bold".into())),
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
@@ -5,7 +5,7 @@ mod asset_card;
|
||||
mod audio_inspector;
|
||||
mod build;
|
||||
pub mod component_registry;
|
||||
pub(crate) mod design_system;
|
||||
pub(crate) use editor_ui::design_system;
|
||||
mod diagnostics;
|
||||
mod dock_tabs;
|
||||
pub(crate) mod document_status;
|
||||
|
||||
Reference in new issue
Block a user