feat(editor): finalize M2 content workspace UX
This commit is contained in:
1 parent
93e23ba194
commit
106d947c98
69 files changed
+5893
-4343
No files matched your search
@@ -12,5 +12,18 @@
|
||||
"border_strong": "#40474F",
|
||||
"success": "#54BE7F",
|
||||
"warning": "#EBB448",
|
||||
"error": "#E25E5E"
|
||||
"error": "#E25E5E",
|
||||
"asset_types": {
|
||||
"primitive": "#8A9BAD",
|
||||
"light": "#F4D35E",
|
||||
"model": "#5B8FF9",
|
||||
"texture": "#54BE7F",
|
||||
"material": "#EBB448",
|
||||
"audio": "#D07DE8",
|
||||
"level": "#41C6CF",
|
||||
"prefab": "#4FB6A6",
|
||||
"post_process": "#A78BFA",
|
||||
"rendering_profile": "#9AA7B8",
|
||||
"shader": "#F07C63"
|
||||
}
|
||||
}
|
||||
@@ -80,7 +80,7 @@ impl UiGalleryApp {
|
||||
}
|
||||
}
|
||||
Self {
|
||||
preset: GalleryPreset::Materials620,
|
||||
preset: GalleryPreset::ContentBrowser1240,
|
||||
comparison: ComparisonMode::SideBySide,
|
||||
overlay_opacity: 0.5,
|
||||
fixture_id,
|
||||
@@ -142,9 +142,17 @@ impl UiGalleryApp {
|
||||
|
||||
fn handle_shortcuts(&mut self, ctx: &egui::Context) {
|
||||
let (function_key, shift, previous_fixture, next_fixture) = ctx.input(|input| {
|
||||
let function_key = [egui::Key::F1, egui::Key::F2, egui::Key::F3, egui::Key::F4]
|
||||
.into_iter()
|
||||
.position(|key| input.key_pressed(key));
|
||||
let function_key = [
|
||||
egui::Key::F1,
|
||||
egui::Key::F2,
|
||||
egui::Key::F3,
|
||||
egui::Key::F4,
|
||||
egui::Key::F5,
|
||||
egui::Key::F6,
|
||||
egui::Key::F7,
|
||||
]
|
||||
.into_iter()
|
||||
.position(|key| input.key_pressed(key));
|
||||
(
|
||||
function_key,
|
||||
input.modifiers.shift,
|
||||
@@ -154,7 +162,9 @@ impl UiGalleryApp {
|
||||
});
|
||||
if let Some(index) = function_key {
|
||||
if shift {
|
||||
self.select_comparison(ComparisonMode::ALL[index]);
|
||||
if let Some(comparison) = ComparisonMode::ALL.get(index).copied() {
|
||||
self.select_comparison(comparison);
|
||||
}
|
||||
} else {
|
||||
self.select_preset(ctx, GalleryPreset::ALL[index]);
|
||||
}
|
||||
@@ -270,7 +280,7 @@ impl UiGalleryApp {
|
||||
ui.separator();
|
||||
ui.small("Theme and fixture JSON reload without rebuilding");
|
||||
ui.separator();
|
||||
ui.small("F1–F4 presets · Shift+F1–F4 modes · PgUp/PgDn fixtures");
|
||||
ui.small("F1–F7 presets · Shift+F1–F4 modes · PgUp/PgDn fixtures");
|
||||
if let Some(stats) = self.difference_stats {
|
||||
ui.separator();
|
||||
ui.small(format!(
|
||||
@@ -351,11 +361,12 @@ impl UiGalleryApp {
|
||||
let size = egui::vec2(self.preset.width(), self.preset.target_height());
|
||||
let (rect, _) = ui.allocate_exact_size(size, egui::Sense::hover());
|
||||
let palette = editor_ui::design_system::palette(ui);
|
||||
let (canvas_fill, canvas_radius) = if self.preset.is_renderer() {
|
||||
(palette.recessed, 4.0)
|
||||
} else {
|
||||
(palette.panel, 7.0)
|
||||
};
|
||||
let (canvas_fill, canvas_radius) =
|
||||
if self.preset.is_content_browser() || self.preset.is_renderer() {
|
||||
(palette.recessed, 4.0)
|
||||
} else {
|
||||
(palette.panel, 7.0)
|
||||
};
|
||||
ui.painter().rect(
|
||||
rect,
|
||||
canvas_radius,
|
||||
@@ -379,7 +390,13 @@ impl UiGalleryApp {
|
||||
.iter()
|
||||
.map(|fixture| fixture.inputs.clone())
|
||||
.collect::<Vec<_>>();
|
||||
if self.preset.is_renderer() {
|
||||
if self.preset.is_content_browser() {
|
||||
crate::content_browser::render_content_browser_fixture(
|
||||
&mut child,
|
||||
self.preset.width(),
|
||||
self.preset.target_height(),
|
||||
);
|
||||
} else if self.preset.is_renderer() {
|
||||
self.render_renderer_fixture(&mut child);
|
||||
} else {
|
||||
self.render_material_fixture(&mut child);
|
||||
|
||||
@@ -0,0 +1,326 @@
|
||||
use editor_ui::content_browser::{
|
||||
content_browser_asset_card, content_browser_content_header, content_browser_detail_path_row,
|
||||
content_browser_detail_row, content_browser_details_header,
|
||||
content_browser_details_pane_heading, content_browser_details_section,
|
||||
content_browser_grid_inset, content_browser_grid_surface_background,
|
||||
content_browser_pane_background, content_browser_pane_heading, content_browser_source_row,
|
||||
content_browser_status_bar, content_browser_toolbar, ContentBrowserAssetTone,
|
||||
ContentBrowserBadgeTone, ContentBrowserCardStatus, ContentBrowserCardViewModel,
|
||||
ContentBrowserChrome, ContentBrowserContentHeaderViewModel,
|
||||
ContentBrowserDetailsHeaderViewModel, ContentBrowserKindFilter, ContentBrowserSort,
|
||||
ContentBrowserSourceRowViewModel, ContentBrowserStatusViewModel, ContentBrowserThumbnail,
|
||||
ContentBrowserToolbarViewModel, ContentBrowserViewMode, ContentPathSegment, ASSET_CARD_GAP,
|
||||
DETAILS_WIDTH, SOURCES_WIDTH, STATUS_BAR_HEIGHT,
|
||||
};
|
||||
use egui_phosphor_icons::{icons, Icon};
|
||||
|
||||
pub fn render_content_browser_fixture(ui: &mut egui::Ui, width: f32, height: f32) {
|
||||
ui.spacing_mut().item_spacing = egui::Vec2::ZERO;
|
||||
let compact = width < editor_ui::content_browser::COMPACT_BREAKPOINT;
|
||||
let model = toolbar_model();
|
||||
let _ = content_browser_toolbar(ui, &model);
|
||||
let toolbar_height = model.chrome.height(width);
|
||||
let body_height = (height - toolbar_height - STATUS_BAR_HEIGHT).max(1.0);
|
||||
let (body, _) = ui.allocate_exact_size(egui::vec2(width, body_height), egui::Sense::hover());
|
||||
let mut body_ui = ui.new_child(
|
||||
egui::UiBuilder::new()
|
||||
.max_rect(body)
|
||||
.layout(egui::Layout::left_to_right(egui::Align::Min)),
|
||||
);
|
||||
body_ui.set_clip_rect(body.intersect(ui.clip_rect()));
|
||||
body_ui.spacing_mut().item_spacing = egui::Vec2::ZERO;
|
||||
if compact {
|
||||
draw_grid(&mut body_ui, width, body_height);
|
||||
} else {
|
||||
draw_sources(&mut body_ui, body_height);
|
||||
draw_grid(
|
||||
&mut body_ui,
|
||||
(width - SOURCES_WIDTH - DETAILS_WIDTH).max(1.0),
|
||||
body_height,
|
||||
);
|
||||
draw_details(&mut body_ui, body_height);
|
||||
}
|
||||
content_browser_status_bar(
|
||||
ui,
|
||||
ContentBrowserStatusViewModel {
|
||||
catalog: "Catalog ready",
|
||||
processing: "2 thumbnails processing",
|
||||
selection: "metal_office_desk selected",
|
||||
healthy: true,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
fn toolbar_model() -> ContentBrowserToolbarViewModel {
|
||||
ContentBrowserToolbarViewModel {
|
||||
chrome: ContentBrowserChrome::Standalone,
|
||||
path: ["Project", "assets", "Props", "Office"]
|
||||
.into_iter()
|
||||
.scan(String::new(), |path, label| {
|
||||
if !path.is_empty() {
|
||||
path.push('/');
|
||||
}
|
||||
path.push_str(label);
|
||||
Some(ContentPathSegment {
|
||||
path: path.clone(),
|
||||
label: label.to_owned(),
|
||||
})
|
||||
})
|
||||
.collect(),
|
||||
search: String::new(),
|
||||
kind_filter: ContentBrowserKindFilter::All,
|
||||
sort: ContentBrowserSort::Name,
|
||||
view: ContentBrowserViewMode::Grid,
|
||||
recursive: false,
|
||||
show_sources: false,
|
||||
show_details: false,
|
||||
thumbnail_size: 96.0,
|
||||
can_go_parent: true,
|
||||
can_go_back: true,
|
||||
can_go_forward: true,
|
||||
can_edit_folder: true,
|
||||
can_rename: true,
|
||||
can_edit_selection: true,
|
||||
can_paste: true,
|
||||
can_undo: true,
|
||||
pending_repairs: 0,
|
||||
direct_folder_count: 3,
|
||||
direct_asset_count: 12,
|
||||
}
|
||||
}
|
||||
|
||||
fn draw_sources(ui: &mut egui::Ui, height: f32) {
|
||||
let (rect, _) = ui.allocate_exact_size(egui::vec2(SOURCES_WIDTH, height), egui::Sense::hover());
|
||||
let mut sources = ui.new_child(
|
||||
egui::UiBuilder::new()
|
||||
.max_rect(rect)
|
||||
.layout(egui::Layout::top_down(egui::Align::Min)),
|
||||
);
|
||||
sources.set_clip_rect(rect.intersect(ui.clip_rect()));
|
||||
sources.spacing_mut().item_spacing = egui::Vec2::ZERO;
|
||||
content_browser_pane_background(&sources);
|
||||
content_browser_pane_heading(&mut sources, "SOURCES", false);
|
||||
for (index, (label, count, depth, children, expanded)) in [
|
||||
("Built-ins", 14, 0, false, false),
|
||||
("assets", 42, 0, true, true),
|
||||
("Furniture", 8, 1, true, true),
|
||||
("Office", 12, 1, false, false),
|
||||
("Materials", 9, 1, false, false),
|
||||
("Textures", 16, 1, false, false),
|
||||
("Levels", 3, 1, false, false),
|
||||
]
|
||||
.into_iter()
|
||||
.enumerate()
|
||||
{
|
||||
let id = format!("gallery-source-{index}");
|
||||
let _ = content_browser_source_row(
|
||||
&mut sources,
|
||||
ContentBrowserSourceRowViewModel {
|
||||
id: &id,
|
||||
label,
|
||||
count,
|
||||
depth,
|
||||
has_children: children,
|
||||
expanded,
|
||||
selected: label == "Office",
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
fn draw_grid(ui: &mut egui::Ui, width: f32, height: f32) {
|
||||
let (rect, _) = ui.allocate_exact_size(egui::vec2(width, height), egui::Sense::hover());
|
||||
let mut grid = ui.new_child(
|
||||
egui::UiBuilder::new()
|
||||
.max_rect(rect)
|
||||
.layout(egui::Layout::top_down(egui::Align::Min)),
|
||||
);
|
||||
grid.set_clip_rect(rect.intersect(ui.clip_rect()));
|
||||
grid.spacing_mut().item_spacing = egui::Vec2::ZERO;
|
||||
content_browser_pane_background(&grid);
|
||||
content_browser_content_header(
|
||||
&mut grid,
|
||||
ContentBrowserContentHeaderViewModel {
|
||||
folder: "Office",
|
||||
item_count: 12,
|
||||
sort: "Name",
|
||||
selection_count: 1,
|
||||
},
|
||||
);
|
||||
content_browser_grid_surface_background(&grid);
|
||||
content_browser_grid_inset(&mut grid, |ui| {
|
||||
ui.spacing_mut().item_spacing = egui::vec2(ASSET_CARD_GAP, ASSET_CARD_GAP);
|
||||
ui.horizontal_wrapped(|ui| {
|
||||
for card in fixture_cards() {
|
||||
let _ = content_browser_asset_card(ui, card.view_model(), 96.0);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
enum CardState {
|
||||
Normal,
|
||||
Dirty,
|
||||
Failed,
|
||||
Processing,
|
||||
Selected,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
struct FixtureCard {
|
||||
label: &'static str,
|
||||
kind: &'static str,
|
||||
icon: Icon,
|
||||
state: CardState,
|
||||
}
|
||||
|
||||
impl FixtureCard {
|
||||
fn view_model(self) -> ContentBrowserCardViewModel<'static> {
|
||||
ContentBrowserCardViewModel {
|
||||
label: self.label,
|
||||
kind: self.kind,
|
||||
icon: self.icon,
|
||||
icon_style: if self.kind == "Folder" {
|
||||
editor_ui::design_system::controls::PhosphorIconStyle::Fill
|
||||
} else {
|
||||
editor_ui::design_system::controls::PhosphorIconStyle::Regular
|
||||
},
|
||||
thumbnail: if matches!(self.state, CardState::Failed) {
|
||||
ContentBrowserThumbnail::Failed
|
||||
} else if matches!(self.state, CardState::Processing) {
|
||||
ContentBrowserThumbnail::Pending
|
||||
} else {
|
||||
ContentBrowserThumbnail::Placeholder
|
||||
},
|
||||
asset_tone: fixture_asset_tone(self.kind),
|
||||
selected: matches!(self.state, CardState::Selected),
|
||||
status: ContentBrowserCardStatus {
|
||||
dirty: matches!(self.state, CardState::Dirty),
|
||||
processing: matches!(self.state, CardState::Processing),
|
||||
error: matches!(self.state, CardState::Failed),
|
||||
},
|
||||
failure_tooltip: matches!(self.state, CardState::Failed)
|
||||
.then_some("Thumbnail render failed"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn fixture_asset_tone(kind: &str) -> ContentBrowserAssetTone {
|
||||
match kind {
|
||||
"Primitive" => ContentBrowserAssetTone::Primitive,
|
||||
"Light" => ContentBrowserAssetTone::Light,
|
||||
"Model" => ContentBrowserAssetTone::Model,
|
||||
"Texture" => ContentBrowserAssetTone::Texture,
|
||||
"Material" => ContentBrowserAssetTone::Material,
|
||||
"Audio Clip" => ContentBrowserAssetTone::Audio,
|
||||
"Level" => ContentBrowserAssetTone::Level,
|
||||
"Prefab" => ContentBrowserAssetTone::Prefab,
|
||||
"Post Process Volume" | "Post FX" => ContentBrowserAssetTone::PostProcess,
|
||||
"Rendering Profile" => ContentBrowserAssetTone::RenderingProfile,
|
||||
"Shader Schema" => ContentBrowserAssetTone::Shader,
|
||||
_ => ContentBrowserAssetTone::None,
|
||||
}
|
||||
}
|
||||
|
||||
fn fixture_cards() -> [FixtureCard; 8] {
|
||||
[
|
||||
FixtureCard {
|
||||
label: "office_lamp",
|
||||
kind: "Model",
|
||||
icon: icons::CUBE,
|
||||
state: CardState::Normal,
|
||||
},
|
||||
FixtureCard {
|
||||
label: "pebble_bricks",
|
||||
kind: "Material",
|
||||
icon: icons::PALETTE,
|
||||
state: CardState::Dirty,
|
||||
},
|
||||
FixtureCard {
|
||||
label: "office_lamp",
|
||||
kind: "Model",
|
||||
icon: icons::CUBE,
|
||||
state: CardState::Normal,
|
||||
},
|
||||
FixtureCard {
|
||||
label: "damaged_fixture",
|
||||
kind: "Model",
|
||||
icon: icons::CUBE,
|
||||
state: CardState::Failed,
|
||||
},
|
||||
FixtureCard {
|
||||
label: "metal_arm_2k",
|
||||
kind: "Texture",
|
||||
icon: icons::IMAGE,
|
||||
state: CardState::Processing,
|
||||
},
|
||||
FixtureCard {
|
||||
label: "pebble_bricks",
|
||||
kind: "Material",
|
||||
icon: icons::PALETTE,
|
||||
state: CardState::Dirty,
|
||||
},
|
||||
FixtureCard {
|
||||
label: "metal_office_desk",
|
||||
kind: "Model",
|
||||
icon: icons::CUBE,
|
||||
state: CardState::Selected,
|
||||
},
|
||||
FixtureCard {
|
||||
label: "textures",
|
||||
kind: "Folder",
|
||||
icon: icons::FOLDER_OPEN,
|
||||
state: CardState::Normal,
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
fn draw_details(ui: &mut egui::Ui, height: f32) {
|
||||
let (rect, _) = ui.allocate_exact_size(egui::vec2(DETAILS_WIDTH, height), egui::Sense::hover());
|
||||
let mut details = ui.new_child(
|
||||
egui::UiBuilder::new()
|
||||
.max_rect(rect)
|
||||
.layout(egui::Layout::top_down(egui::Align::Min)),
|
||||
);
|
||||
details.set_clip_rect(rect.intersect(ui.clip_rect()));
|
||||
details.spacing_mut().item_spacing = egui::Vec2::ZERO;
|
||||
content_browser_pane_background(&details);
|
||||
content_browser_details_pane_heading(&mut details, "DETAILS", true);
|
||||
let _ = content_browser_details_header(
|
||||
&mut details,
|
||||
ContentBrowserDetailsHeaderViewModel {
|
||||
label: "metal_office_desk_2k",
|
||||
kind: "Model",
|
||||
icon: icons::CUBE,
|
||||
thumbnail: ContentBrowserThumbnail::Placeholder,
|
||||
badge: Some(("UNTRACKED", ContentBrowserBadgeTone::Neutral)),
|
||||
badge_tooltip: Some("Git: untracked"),
|
||||
unsaved: false,
|
||||
can_locate: true,
|
||||
},
|
||||
);
|
||||
content_browser_details_section(&mut details, "IDENTITY");
|
||||
content_browser_detail_path_row(
|
||||
&mut details,
|
||||
"Path",
|
||||
"assets/Props/Office/metal_office_desk_2k.gltf",
|
||||
);
|
||||
content_browser_detail_path_row(&mut details, "Folder", "assets/Props/Office");
|
||||
content_browser_detail_row(
|
||||
&mut details,
|
||||
"Asset ID",
|
||||
"c07a5b05-f27d-46c6-8b8c-9de9cdd14720",
|
||||
);
|
||||
content_browser_details_section(&mut details, "DEPENDENCIES");
|
||||
content_browser_detail_path_row(
|
||||
&mut details,
|
||||
"Ready",
|
||||
"textures/metal_office_desk_diff_2k.png",
|
||||
);
|
||||
content_browser_detail_path_row(
|
||||
&mut details,
|
||||
"Ready",
|
||||
"textures/metal_office_desk_arm_2k.png",
|
||||
);
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
mod app;
|
||||
mod content_browser;
|
||||
mod fixtures;
|
||||
mod reference;
|
||||
mod reload;
|
||||
|
||||
@@ -2,6 +2,9 @@ use std::path::{Path, PathBuf};
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum GalleryPreset {
|
||||
ContentBrowser1240,
|
||||
ContentBrowser1600,
|
||||
ContentBrowser620,
|
||||
Materials620,
|
||||
Materials420,
|
||||
Renderer760,
|
||||
@@ -9,15 +12,21 @@ pub enum GalleryPreset {
|
||||
}
|
||||
|
||||
impl GalleryPreset {
|
||||
pub const ALL: [Self; 4] = [
|
||||
pub const ALL: [Self; 7] = [
|
||||
Self::ContentBrowser1240,
|
||||
Self::ContentBrowser620,
|
||||
Self::Materials620,
|
||||
Self::Materials420,
|
||||
Self::Renderer760,
|
||||
Self::Renderer480,
|
||||
Self::ContentBrowser1600,
|
||||
];
|
||||
|
||||
pub const fn label(self) -> &'static str {
|
||||
match self {
|
||||
Self::ContentBrowser1240 => "Content Browser · 1240",
|
||||
Self::ContentBrowser1600 => "Content Browser · 1600 expanded",
|
||||
Self::ContentBrowser620 => "Content Browser · 620",
|
||||
Self::Materials620 => "Materials · 620",
|
||||
Self::Materials420 => "Materials · 420",
|
||||
Self::Renderer760 => "Renderer · 760",
|
||||
@@ -27,6 +36,9 @@ impl GalleryPreset {
|
||||
|
||||
pub const fn width(self) -> f32 {
|
||||
match self {
|
||||
Self::ContentBrowser1240 => 1240.0,
|
||||
Self::ContentBrowser1600 => 1600.0,
|
||||
Self::ContentBrowser620 => 620.0,
|
||||
Self::Materials620 => 620.0,
|
||||
Self::Materials420 => 420.0,
|
||||
Self::Renderer760 => 760.0,
|
||||
@@ -36,6 +48,7 @@ impl GalleryPreset {
|
||||
|
||||
pub const fn target_height(self) -> f32 {
|
||||
match self {
|
||||
Self::ContentBrowser1240 | Self::ContentBrowser1600 | Self::ContentBrowser620 => 650.0,
|
||||
Self::Materials620 => 539.0,
|
||||
Self::Materials420 => 735.0,
|
||||
Self::Renderer760 => 1233.0,
|
||||
@@ -45,6 +58,9 @@ impl GalleryPreset {
|
||||
|
||||
pub const fn file_name(self) -> &'static str {
|
||||
match self {
|
||||
Self::ContentBrowser1240 => "content-browser-wide-1240.png",
|
||||
Self::ContentBrowser1600 => "content-browser-expanded-1600.png",
|
||||
Self::ContentBrowser620 => "content-browser-compact-620.png",
|
||||
Self::Materials620 => "materials-wide-620.png",
|
||||
Self::Materials420 => "materials-narrow-420.png",
|
||||
Self::Renderer760 => "static-mesh-renderer-wide-760.png",
|
||||
@@ -56,12 +72,21 @@ impl GalleryPreset {
|
||||
matches!(self, Self::Renderer760 | Self::Renderer480)
|
||||
}
|
||||
|
||||
pub const fn is_content_browser(self) -> bool {
|
||||
matches!(
|
||||
self,
|
||||
Self::ContentBrowser1240 | Self::ContentBrowser1600 | Self::ContentBrowser620
|
||||
)
|
||||
}
|
||||
|
||||
/// Production-content canvas inside the exported Penpot reference.
|
||||
///
|
||||
/// Material boards include the Inspector border and its 12 px horizontal / 10 px top inset;
|
||||
/// renderer boards are already complete component canvases.
|
||||
pub fn content_rect(self, canvas: egui::Rect) -> egui::Rect {
|
||||
if self.is_renderer() {
|
||||
if self.is_content_browser() {
|
||||
canvas
|
||||
} else if self.is_renderer() {
|
||||
egui::Rect::from_min_max(
|
||||
canvas.min + egui::vec2(0.0, 12.0),
|
||||
egui::pos2(canvas.right(), canvas.bottom()),
|
||||
|
||||
@@ -27,6 +27,23 @@ pub struct ThemeOverrides {
|
||||
pub success: Option<String>,
|
||||
pub warning: Option<String>,
|
||||
pub error: Option<String>,
|
||||
pub asset_types: AssetTypeThemeOverrides,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Default, Serialize, Deserialize)]
|
||||
#[serde(default)]
|
||||
pub struct AssetTypeThemeOverrides {
|
||||
pub primitive: Option<String>,
|
||||
pub light: Option<String>,
|
||||
pub model: Option<String>,
|
||||
pub texture: Option<String>,
|
||||
pub material: Option<String>,
|
||||
pub audio: Option<String>,
|
||||
pub level: Option<String>,
|
||||
pub prefab: Option<String>,
|
||||
pub post_process: Option<String>,
|
||||
pub rendering_profile: Option<String>,
|
||||
pub shader: Option<String>,
|
||||
}
|
||||
|
||||
impl ThemeOverrides {
|
||||
@@ -54,6 +71,24 @@ impl ThemeOverrides {
|
||||
apply!(success);
|
||||
apply!(warning);
|
||||
apply!(error);
|
||||
macro_rules! apply_asset_type {
|
||||
($field:ident) => {
|
||||
if let Some(value) = self.asset_types.$field.as_deref() {
|
||||
palette.asset_types.$field = parse_color(value)?;
|
||||
}
|
||||
};
|
||||
}
|
||||
apply_asset_type!(primitive);
|
||||
apply_asset_type!(light);
|
||||
apply_asset_type!(model);
|
||||
apply_asset_type!(texture);
|
||||
apply_asset_type!(material);
|
||||
apply_asset_type!(audio);
|
||||
apply_asset_type!(level);
|
||||
apply_asset_type!(prefab);
|
||||
apply_asset_type!(post_process);
|
||||
apply_asset_type!(rendering_profile);
|
||||
apply_asset_type!(shader);
|
||||
Ok(palette)
|
||||
}
|
||||
}
|
||||
@@ -240,4 +275,21 @@ mod tests {
|
||||
);
|
||||
assert!(parse_color("#not-a-color").is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn asset_category_colors_are_runtime_theme_overrides() {
|
||||
let overrides: ThemeOverrides =
|
||||
serde_json::from_str(r##"{"asset_types":{"model":"#010203","shader":"#A0B0C0"}}"##)
|
||||
.expect("asset type theme overrides");
|
||||
let palette = overrides.palette().expect("resolved theme palette");
|
||||
assert_eq!(palette.asset_types.model, egui::Color32::from_rgb(1, 2, 3));
|
||||
assert_eq!(
|
||||
palette.asset_types.shader,
|
||||
egui::Color32::from_rgb(160, 176, 192)
|
||||
);
|
||||
assert_eq!(
|
||||
palette.asset_types.material,
|
||||
editor_ui::theme::ASSET_TYPES.material
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user