Add demo artwork

This commit is contained in:
Keavon Chambers
2023-08-22 03:26:59 -07:00
parent 0e97a256b7
commit 0dcfafbf64
33 changed files with 2133 additions and 1050 deletions
@@ -8,6 +8,7 @@ impl LayoutHolder for CloseAllDocumentsDialog {
fn layout(&self) -> Layout {
let discard = TextButton::new("Discard All")
.min_width(96)
.emphasized(true)
.on_update(|_| {
DialogMessage::CloseDialogAndThen {
followups: vec![PortfolioMessage::CloseAllDocuments.into()],
@@ -0,0 +1,50 @@
use crate::messages::layout::utility_types::widget_prelude::*;
use crate::messages::prelude::*;
/// A dialog to let the user browse a gallery of demo artwork that can be opened.
pub struct DemoArtworkDialog;
impl LayoutHolder for DemoArtworkDialog {
fn layout(&self) -> Layout {
let artwork = [
(
"Valley of Spires",
"ThumbnailValleyOfSpires",
"https://raw.githubusercontent.com/GraphiteEditor/Graphite/master/demo-artwork/valley-of-spires.graphite",
),
(
"Just a Potted Cactus",
"ThumbnailJustAPottedCactus",
"https://raw.githubusercontent.com/GraphiteEditor/Graphite/master/demo-artwork/just-a-potted-cactus.graphite",
),
];
let image_widgets = artwork
.into_iter()
.map(|(_, thumbnail, _)| ImageLabel::new(thumbnail.to_string()).width(Some("256px".into())).widget_holder())
.collect();
let button_widgets = artwork
.into_iter()
.map(|(label, _, url)| {
TextButton::new(label)
.min_width(256)
.on_update(|_| {
DialogMessage::CloseDialogAndThen {
followups: vec![FrontendMessage::TriggerFetchAndOpenDocument { url: url.to_string() }.into()],
}
.into()
})
.widget_holder()
})
.collect();
Layout::WidgetLayout(WidgetLayout::new(vec![
LayoutGroup::Row {
widgets: vec![TextLabel::new("Demo Artwork".to_string()).bold(true).widget_holder()],
},
LayoutGroup::Row { widgets: image_widgets },
LayoutGroup::Row { widgets: button_widgets },
]))
}
}
@@ -2,10 +2,12 @@ mod about_graphite_dialog;
mod close_all_documents_dialog;
mod close_document_dialog;
mod coming_soon_dialog;
mod demo_artwork_dialog;
mod error_dialog;
pub use about_graphite_dialog::AboutGraphiteDialog;
pub use close_all_documents_dialog::CloseAllDocumentsDialog;
pub use close_document_dialog::CloseDocumentDialog;
pub use coming_soon_dialog::ComingSoonDialog;
pub use demo_artwork_dialog::DemoArtworkDialog;
pub use error_dialog::ErrorDialog;