mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-12-02 00:01:59 -10:00
Add demo artwork
This commit is contained in:
1 parent
0e97a256b7
commit
0dcfafbf64
33 files changed
+2133
-1050
No files matched your search
@@ -0,0 +1 @@
|
||||
{"document_legacy":{"root":{"visible":true,"name":null,"data":{"Folder":{"next_assignment_id":13643235450655197966,"layer_ids":[4286540567702010292,3254766648155634092,17415633221414408275,1161233993161842223,15641090605066649985,13643235450655197965,16725151141597012532],"layers":[{"visible":true,"name":"Body","data":{"Folder":{"next_assignment_id":10109464023417252632,"layer_ids":[16818477173353643355,2192367616431910590,10109464023417252631],"layers":[{"visible":true,"name":"Right Arm","data":{"Layer":{"network":{"inputs":[0],"outputs":[{"node_id":4,"node_output_index":0}],"nodes":{"0":{"name":"Shape","inputs":[{"Value":{"tagged_value":{"Subpaths":[{"manipulator_groups":[{"anchor":[0.20720720720723182,0.01851851851851611],"in_handle":[0.20720720720723168,0.34391534391534156],"out_handle":[0.20720720720723196,-0.31481481481481727],"id":7178084202058322780},{"anchor":[1.108108108108135,0.06613756613756133],"in_handle":[1.1260998607797994,-0.2667098582882754],"out_handle":[1.0900900900901194,0.39947089947089415],"id":11846787974084478976},{"anchor":[1.117117117117146,0.9761904761904703],"in_handle":[1.336160108448177,0.7249310901770023],"out_handle":[0.9258882487736064,1.1955448949558483],"id":3092702294994998772},{"anchor":[-0.5585585585585304,1.4682539682539635],"in_handle":[-0.5585585585585304,1.4682539682539635],"out_handle":[-0.5585585585585304,1.4682539682539635],"id":7011943185054330211},{"anchor":[-0.5045045045044768,1.1587301587301522],"in_handle":[-0.5045045045044768,1.1587301587301522],"out_handle":[-0.5045045045044768,1.1587301587301522],"id":8288217643137533080},{"anchor":[0.1891891891891933,0.8597883597883553],"in_handle":[0.08823229399159119,1.0554331726475863],"out_handle":[0.32253596208046964,0.6013750599673464],"id":15832048236603096330}],"closed":true}]},"exposed":false}},{"Value":{"tagged_value":{"ManipulatorGroupIds":[7178084202058322780,11846787974084478976,3092702294994998772,15832048236603096330]},"exposed":false}}],"implementation":{"Unresolved":{"name":"graphene_core::vector::generator_nodes::PathGenerator<_>"}},"metadata":{"position":[0,4]},"path":null},"2":{"name":"Fill","inputs":[{"Node":{"node_id":1,"output_index":0,"lambda":false}},{"Value":{"tagged_value":{"FillType":"Gradient"},"exposed":false}},{"Value":{"tagged_value":{"OptionalColor":{"red":0.21176471,"green":0.43137255,"blue":0.2901961,"alpha":1.0}},"exposed":false}},{"Value":{"tagged_value":{"GradientType":"Linear"},"exposed":false}},{"Value":{"tagged_value":{"DVec2":[0.5849339554076831,0.8762537511548164]},"exposed":false}},{"Value":{"tagged_value":{"DVec2":[0.5849339554076813,0.06398480655241934]},"exposed":false}},{"Value":{"tagged_value":{"DAffine2":[58.937834420052454,0.0,0.0,196.63895722428214,659.5252593895156,175.69437610905126]},"exposed":false}},{"Value":{"tagged_value":{"GradientPositions":[[0.0,{"red":0.21176471,"green":0.43137255,"blue":0.2901961,"alpha":1.0}],[1.0,{"red":0.3281021,"green":0.5957031,"blue":0.423674,"alpha":1.0}]]},"exposed":false}}],"implementation":{"Unresolved":{"name":"graphene_core::vector::SetFillNode<_, _, _, _, _, _, _>"}},"metadata":{"position":[16,4]},"path":null},"3":{"name":"Stroke","inputs":[{"Node":{"node_id":2,"output_index":0,"lambda":false}},{"Value":{"tagged_value":{"OptionalColor":null},"exposed":false}},{"Value":{"tagged_value":{"F32":5.0},"exposed":false}},{"Value":{"tagged_value":{"VecF32":[]},"exposed":false}},{"Value":{"tagged_value":{"F32":0.0},"exposed":false}},{"Value":{"tagged_value":{"LineCap":"Butt"},"exposed":false}},{"Value":{"tagged_value":{"LineJoin":"Miter"},"exposed":false}},{"Value":{"tagged_value":{"F32":4.0},"exposed":false}}],"implementation":{"Unresolved":{"name":"graphene_core::vector::SetStrokeNode<_, _, _, _, _, _, _>"}},"metadata":{"position":[24,4]},"path":null},"4":{"name":"Output","inputs":[{"Node":{"node_id":3,"output_index":0,"lambda":false}}],"implementation":{"Unresolved":{"name":"graphene_core::ops::IdNode"}},"metadata":{"position":[32,4]},"path":null},"1":{"name":"Transform","inputs":[{"Node":{"node_id":0,"output_index":0,"lambda":false}},{"Value":{"tagged_value":{"DVec2":[-206.63510000303063,-252.28255153320856]},"exposed":false}},{"Value":{"tagged_value":{"F32":0.0},"exposed":false}},{"Value":{"tagged_value":{"DVec2":[37.0,126.0]},"exposed":false}},{"Value":{"tagged_value":{"DVec2":[0.0,0.0]},"exposed":false}},{"Value":{"tagged_value":{"DVec2":[0.5,0.5]},"exposed":false}}],"implementation":{"Unresolved":{"name":"graphene_core::transform::TransformNode<_, _, _, _, _>"}},"metadata":{"position":[8,4]},"path":null}},"disabled":[],"previous_outputs":null}}},"transform":{"matrix2":[37.0,0.0,0.0,126.0],"translation":[-218.33333333333442,-330.99999999999926]},"preserve_aspect":true,"pivot":[0.5,0.5],"blend_mode":"Normal","opacity":1.0},{"visible":true,"name":"Left Arm","data":{"Layer":{"network":{"inputs":[0],"outputs":[{"node_id":4,"node_output_index":0}],"nodes":{"0":{"name":"Shape","inputs":[{"Value":{"tagged_value":{"Subpaths":[{"manipulatLine truncated
|
||||
@@ -0,0 +1 @@
|
||||
{"document_legacy":{"root":{"visible":true,"name":null,"data":{"Folder":{"next_assignment_id":10126658866505271994,"layer_ids":[10126658866505271993,14969652073177018928],"layers":[{"visible":true,"name":"Artwork","data":{"Folder":{"next_assignment_id":8035559641245869000,"layer_ids":[7775976068501052000,11557254171291498000,17672025103261094000,8035559641245869000,9725225577436094000,6841083957124290000],"layers":[{"visible":true,"name":"Sky","data":{"Layer":{"network":{"inputs":[0],"outputs":[{"node_id":5,"node_output_index":0}],"nodes":{"2":{"name":"Transform","inputs":[{"Node":{"node_id":1,"output_index":0,"lambda":false}},{"Value":{"tagged_value":{"DVec2":[0.0,0.0]},"exposed":false}},{"Value":{"tagged_value":{"F32":0.0},"exposed":false}},{"Value":{"tagged_value":{"DVec2":[1024.0,600.0]},"exposed":false}},{"Value":{"tagged_value":{"DVec2":[0.0,0.0]},"exposed":false}},{"Value":{"tagged_value":{"DVec2":[0.0,0.0]},"exposed":false}}],"implementation":{"Network":{"inputs":[0,0,0,0,0,0],"outputs":[{"node_id":0,"node_output_index":0}],"nodes":{"0":{"name":"Transform_impl","inputs":[{"Network":{"Concrete":{"name":"graphene_core::vector::vector_data::VectorData","size":0,"align":0}}},{"Network":{"Concrete":{"name":"glam::f32::dvec2::DVec2","size":0,"align":0}}},{"Network":{"Concrete":{"name":"f32","size":0,"align":0}}},{"Network":{"Concrete":{"name":"glam::f32::dvec2::DVec2","size":0,"align":0}}},{"Network":{"Concrete":{"name":"glam::f32::dvec2::DVec2","size":0,"align":0}}},{"Network":{"Concrete":{"name":"glam::f32::dvec2::DVec2","size":0,"align":0}}}],"implementation":{"Unresolved":{"name":"graphene_core::transform::TransformNode<_, _, _, _, _>"}},"metadata":{"position":[0,0]},"skip_deduplication":false,"path":null}},"disabled":[],"previous_outputs":null}},"metadata":{"position":[16,4]},"skip_deduplication":false,"path":null},"1":{"name":"Path Generator","inputs":[{"Value":{"tagged_value":{"Subpaths":[{"manipulator_groups":[{"anchor":[0.0,0.0],"in_handle":[0.0,0.0],"out_handle":[0.0,0.0],"id":16102767591708207000},{"anchor":[1.0,0.0],"in_handle":[1.0,0.0],"out_handle":[1.0,0.0],"id":7338082854565002000},{"anchor":[1.0,1.0],"in_handle":[1.0,1.0],"out_handle":[1.0,1.0],"id":5176822188264250000},{"anchor":[0.0,1.0],"in_handle":[0.0,1.0],"out_handle":[0.0,1.0],"id":4512392189214677000}],"closed":true}]},"exposed":false}},{"Value":{"tagged_value":{"ManipulatorGroupIds":[]},"exposed":false}}],"implementation":{"Network":{"inputs":[0,0],"outputs":[{"node_id":0,"node_output_index":0}],"nodes":{"0":{"name":"Path Generator_impl","inputs":[{"Network":{"Concrete":{"name":"alloc::vec::Vec<bezier_rs::subpath::Subpath<graphene_core::uuid::ManipulatorGroupId>>","size":0,"align":0}}},{"Network":{"Concrete":{"name":"alloc::vec::Vec<graphene_core::uuid::ManipulatorGroupId>","size":0,"align":0}}}],"implementation":{"Unresolved":{"name":"graphene_core::vector::generator_nodes::PathGenerator<_>"}},"metadata":{"position":[0,0]},"skip_deduplication":false,"path":null}},"disabled":[],"previous_outputs":null}},"metadata":{"position":[8,4]},"skip_deduplication":false,"path":null},"4":{"name":"Stroke","inputs":[{"Node":{"node_id":3,"output_index":0,"lambda":false}},{"Value":{"tagged_value":{"OptionalColor":{"red":0.0,"green":0.0,"blue":0.0,"alpha":1.0}},"exposed":false}},{"Value":{"tagged_value":{"F32":0.0},"exposed":false}},{"Value":{"tagged_value":{"VecF32":[]},"exposed":false}},{"Value":{"tagged_value":{"F32":0.0},"exposed":false}},{"Value":{"tagged_value":{"LineCap":"Butt"},"exposed":false}},{"Value":{"tagged_value":{"LineJoin":"Miter"},"exposed":false}},{"Value":{"tagged_value":{"F32":4.0},"exposed":false}}],"implementation":{"Network":{"inputs":[0,0,0,0,0,0,0,0],"outputs":[{"node_id":0,"node_output_index":0}],"nodes":{"0":{"name":"Stroke_impl","inputs":[{"Network":{"Concrete":{"name":"graphene_core::vector::vector_data::VectorData","size":0,"align":0}}},{"Network":{"Concrete":{"name":"core::option::Option<graphene_core::raster::color::Color>","size":0,"align":0}}},{"Network":{"Concrete":{"name":"f32","size":0,"align":0}}},{"Network":{"Concrete":{"name":"alloc::vec::Vec<f32>","size":0,"align":0}}},{"Network":{"Concrete":{"name":"f32","size":0,"align":0}}},{"Network":{"Concrete":{"name":"graphene_core::vector::style::LineCap","size":0,"align":0}}},{"Network":{"Concrete":{"name":"graphene_core::vector::style::LineJoin","size":0,"align":0}}},{"Network":{"Concrete":{"name":"f32","size":0,"align":0}}}],"implementation":{"Unresolved":{"name":"graphene_core::vector::SetStrokeNode<_, _, _, _, _, _, _>"}},"metadata":{"position":[0,0]},"skip_deduplication":false,"path":null}},"disabled":[],"previous_outputs":null}},"metadata":{"position":[32,4]},"skip_deduplication":false,"path":null},"3":{"name":"Fill","inputs":[{"Node":{"node_id":2,"output_index":0,"lambda":false}},{"Value":{"tagged_value":{"FillType":"Gradient"},"exposed":false}},{"Value":{"tagged_value":{"OptionalColor":{"red":0.24313726,"green":0.18431373,"blue":0.19215687,"alpha":1.0}},Line truncated
|
||||
@@ -1 +0,0 @@
|
||||
{"document_legacy":{"commit_hash": "", "root":{"visible":true,"name":null,"data":{"Folder":{"next_assignment_id":15997858604048146086,"layer_ids":[17969178651777368768,3643066017826641933,16075447627426792792,10598788542653937530,6240415495114589106,5260049129070821769,6431150803620977111,13779825621578452744,3547353463246861192],"layers":[{"visible":true,"name":null,"data":{"Shape":{"shape":{"elements":[{"points":[{"position":[201.95915125256778,132.20589235454912],"manipulator_type":"Anchor"},{"position":[201.95915125256778,132.20589235454912],"manipulator_type":"InHandle"},{"position":[201.95915125256778,132.20589235454912],"manipulator_type":"OutHandle"}]},{"points":[{"position":[347.5538879474682,92.26397343824904],"manipulator_type":"Anchor"},{"position":[347.5538879474682,51.03360552464895],"manipulator_type":"InHandle"},{"position":[347.5538879474682,133.49434135184913],"manipulator_type":"OutHandle"}]},{"points":[{"position":[283.131438082468,237.85871013314937],"manipulator_type":"Anchor"},{"position":[337.2462959690681,281.6659760413495],"manipulator_type":"InHandle"},{"position":[229.01658019586787,194.05144422494925],"manipulator_type":"OutHandle"}]},{"points":[{"position":[154.28653835246766,246.87785311424938],"manipulator_type":"Anchor"},{"position":[154.28653835246766,246.87785311424938],"manipulator_type":"InHandle"},{"position":[154.28653835246766,246.87785311424938],"manipulator_type":"OutHandle"}]}],"element_ids":[1,2,3,4],"next_id":5},"style":{"stroke":{"color":{"red":0.0,"green":0.0,"blue":0.0,"alpha":1.0},"weight":5.0,"dash_lengths":[0.0],"dash_offset":0.0,"line_cap":"Butt","line_join":"Miter","line_join_miter_limit":4.0},"fill":"None"},"render_index":1}},"transform":{"matrix2":[1.0,0.0,0.0,1.0],"translation":[0.0,0.0]},"pivot":[0.5,0.5],"blend_mode":"Normal","opacity":1.0},{"visible":true,"name":null,"data":{"Shape":{"shape":{"elements":[{"points":[{"position":[433.87997076656836,163.73088039119517],"manipulator_type":"Anchor"},{"position":[433.87997076656836,163.73088039119517],"manipulator_type":"InHandle"},{"position":[433.87997076656836,163.73088039119517],"manipulator_type":"OutHandle"}]},{"points":[{"position":[592.3591974344687,156.68642330324917],"manipulator_type":"Anchor"},{"position":[592.3591974344687,156.68642330324917],"manipulator_type":"InHandle"},{"position":[592.3591974344687,156.68642330324917],"manipulator_type":"OutHandle"}]},{"points":[{"position":[463.51429770446845,311.3003029792495],"manipulator_type":"Anchor"},{"position":[463.51429770446845,311.3003029792495],"manipulator_type":"InHandle"},{"position":[463.51429770446845,311.3003029792495],"manipulator_type":"OutHandle"}]}],"element_ids":[1,2,3],"next_id":4},"style":{"stroke":{"color":{"red":0.0,"green":0.0,"blue":0.0,"alpha":1.0},"weight":5.0,"dash_lengths":[0.0],"dash_offset":0.0,"line_cap":"Butt","line_join":"Miter","line_join_miter_limit":4.0},"fill":"None"},"render_index":1}},"transform":{"matrix2":[1.0,0.0,0.0,1.0],"translation":[0.0,0.0]},"pivot":[0.5,0.5],"blend_mode":"Normal","opacity":1.0},{"visible":true,"name":null,"data":{"Shape":{"shape":{"elements":[{"points":[{"position":[801.087934997069,163.7308803911952],"manipulator_type":"Anchor"},{"position":[801.087934997069,163.7308803911952],"manipulator_type":"InHandle"},{"position":[801.087934997069,163.7308803911952],"manipulator_type":"OutHandle"}]},{"points":[{"position":[767.5882610672691,295.8389150116495],"manipulator_type":"Anchor"},{"position":[767.5882610672691,295.8389150116495],"manipulator_type":"InHandle"},{"position":[767.5882610672691,295.8389150116495],"manipulator_type":"OutHandle"}]},{"points":[{"position":[652.9163003075688,233.99336314124935],"manipulator_type":"Anchor"},{"position":[652.9163003075688,233.99336314124935],"manipulator_type":"InHandle"},{"position":[652.9163003075688,233.99336314124935],"manipulator_type":"OutHandle"}]},{"points":[{"position":[735.377036134769,74.22568747604898],"manipulator_type":"Anchor"},{"position":[735.377036134769,74.22568747604898],"manipulator_type":"InHandle"},{"position":[735.377036134769,74.22568747604898],"manipulator_type":"OutHandle"}]},{"points":[null,null,null]}],"element_ids":[1,2,3,4,6],"next_id":6},"style":{"stroke":{"color":{"red":0.0,"green":0.0,"blue":0.0,"alpha":1.0},"weight":5.0,"dash_lengths":[0.0],"dash_offset":0.0,"line_cap":"Butt","line_join":"Miter","line_join_miter_limit":4.0},"fill":"None"},"render_index":1}},"transform":{"matrix2":[1.0,0.0,0.0,1.0],"translation":[0.0,0.0]},"pivot":[0.5,0.5],"blend_mode":"Normal","opacity":1.0},{"visible":true,"name":null,"data":{"Shape":{"shape":{"elements":[{"points":[{"position":[106.61392545236757,387.3187938199497],"manipulator_type":"Anchor"},null,null]},{"points":[{"position":[107.90237444966755,387.3187938199497],"manipulator_type":"Anchor"},null,null]},{"points":[{"position":[125.94066041186761,374.43430384694966],"manipulator_type":"Anchor"},null,null]},{"points":[{"position":[140.11359938216765,364.12671186854965],"maniLine truncated
|
||||
@@ -79,7 +79,7 @@ pub const DEFAULT_FONT_FAMILY: &str = "Merriweather";
|
||||
pub const DEFAULT_FONT_STYLE: &str = "Normal (400)";
|
||||
|
||||
// Document
|
||||
pub const GRAPHITE_DOCUMENT_VERSION: &str = "0.0.17"; // Remember to save a simple document and replace the test file `graphite-test-document.graphite`
|
||||
pub const GRAPHITE_DOCUMENT_VERSION: &str = "0.0.17"; // Remember to update the demo artwork in /demos with both this version number and the contents so it remains editable
|
||||
pub const DEFAULT_DOCUMENT_NAME: &str = "Untitled Document";
|
||||
pub const FILE_SAVE_SUFFIX: &str = ".graphite";
|
||||
pub const MAX_UNDO_HISTORY_LEN: usize = 100; // TODO: Add this to user preferences
|
||||
|
||||
+20
-13
@@ -555,7 +555,8 @@ mod test {
|
||||
println!("-------------------------------------------------");
|
||||
println!("Failed test due to receiving a DisplayDialogError while loading the Graphite sample file.");
|
||||
println!("This is most likely caused by forgetting to bump the `GRAPHITE_DOCUMENT_VERSION` in `editor/src/consts.rs`");
|
||||
println!("After bumping this version number, replace `graphite-test-document.graphite` with a valid file by saving a document from the editor.");
|
||||
println!("After bumping this version number, update the documents in `/demo-artwork` by editing their JSON to");
|
||||
println!("ensure they remain compatible with both the bumped version number and the serialization format change.");
|
||||
println!("DisplayDialogError details:");
|
||||
println!();
|
||||
println!("Description: {}", value);
|
||||
@@ -567,19 +568,25 @@ mod test {
|
||||
init_logger();
|
||||
let mut editor = Editor::create();
|
||||
|
||||
let test_file = include_str!("../graphite-test-document.graphite");
|
||||
let responses = editor.handle_message(PortfolioMessage::OpenDocumentFile {
|
||||
document_name: "Graphite Version Test".into(),
|
||||
document_serialized_content: test_file.into(),
|
||||
});
|
||||
let test_files = [
|
||||
("Just a Potted Cactus", include_str!("../../demo-artwork/just-a-potted-cactus.graphite")),
|
||||
("Valley of Spires", include_str!("../../demo-artwork/valley-of-spires.graphite")),
|
||||
];
|
||||
|
||||
for response in responses {
|
||||
// Check for the existence of the file format incompatibility warning dialog after opening the test file
|
||||
if let FrontendMessage::UpdateDialogDetails { layout_target: _, diff } = response {
|
||||
if let DiffUpdate::SubLayout(sub_layout) = &diff[0].new_value {
|
||||
if let LayoutGroup::Row { widgets } = &sub_layout[0] {
|
||||
if let Widget::TextLabel(TextLabel { value, .. }) = &widgets[0].widget {
|
||||
print_problem_to_terminal_on_failure(value);
|
||||
for (document_name, document_serialized_content) in test_files {
|
||||
let responses = editor.handle_message(PortfolioMessage::OpenDocumentFile {
|
||||
document_name: document_name.into(),
|
||||
document_serialized_content: document_serialized_content.into(),
|
||||
});
|
||||
|
||||
for response in responses {
|
||||
// Check for the existence of the file format incompatibility warning dialog after opening the test file
|
||||
if let FrontendMessage::UpdateDialogDetails { layout_target: _, diff } = response {
|
||||
if let DiffUpdate::SubLayout(sub_layout) = &diff[0].new_value {
|
||||
if let LayoutGroup::Row { widgets } = &sub_layout[0] {
|
||||
if let Widget::TextLabel(TextLabel { value, .. }) = &widgets[0].widget {
|
||||
print_problem_to_terminal_on_failure(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ pub enum DialogMessage {
|
||||
RequestComingSoonDialog {
|
||||
issue: Option<i32>,
|
||||
},
|
||||
RequestDemoArtworkDialog,
|
||||
RequestExportDialog,
|
||||
RequestNewDocumentDialog,
|
||||
RequestPreferencesDialog,
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
use super::simple_dialogs::{self, AboutGraphiteDialog, ComingSoonDialog};
|
||||
use super::simple_dialogs::{self, AboutGraphiteDialog, ComingSoonDialog, DemoArtworkDialog};
|
||||
use crate::messages::layout::utility_types::widget_prelude::*;
|
||||
use crate::messages::prelude::*;
|
||||
|
||||
/// Stores the dialogs which require state. These are the ones that have their own message handlers, and are not the ones defined in `simple_dialogs`.
|
||||
#[derive(Debug, Default, Clone)]
|
||||
pub struct DialogMessageHandler {
|
||||
export_dialog: ExportDialogMessageHandler,
|
||||
@@ -53,6 +54,11 @@ impl MessageHandler<DialogMessage, (&PortfolioMessageHandler, &PreferencesMessag
|
||||
coming_soon.send_layout(responses, LayoutTarget::DialogDetails);
|
||||
responses.add(FrontendMessage::DisplayDialog { icon: "Warning".to_string() });
|
||||
}
|
||||
DialogMessage::RequestDemoArtworkDialog => {
|
||||
let demo_artwork_dialog = DemoArtworkDialog;
|
||||
demo_artwork_dialog.send_layout(responses, LayoutTarget::DialogDetails);
|
||||
responses.add(FrontendMessage::DisplayDialog { icon: "Image".to_string() });
|
||||
}
|
||||
DialogMessage::RequestExportDialog => {
|
||||
if let Some(document) = portfolio.active_document() {
|
||||
let artboard_handler = &document.artboard_message_handler;
|
||||
|
||||
+1
-1
@@ -50,7 +50,7 @@ impl MessageHandler<NewDocumentDialogMessage, ()> for NewDocumentDialogMessageHa
|
||||
|
||||
impl LayoutHolder for NewDocumentDialogMessageHandler {
|
||||
fn layout(&self) -> Layout {
|
||||
let title = vec![TextLabel::new("New document").bold(true).widget_holder()];
|
||||
let title = vec![TextLabel::new("New Document").bold(true).widget_holder()];
|
||||
|
||||
let name = vec![
|
||||
TextLabel::new("Name").table_align(true).widget_holder(),
|
||||
|
||||
@@ -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;
|
||||
@@ -67,6 +67,9 @@ pub enum FrontendMessage {
|
||||
document: String,
|
||||
name: String,
|
||||
},
|
||||
TriggerFetchAndOpenDocument {
|
||||
url: String,
|
||||
},
|
||||
TriggerFontLoad {
|
||||
font: Font,
|
||||
#[serde(rename = "isDefault")]
|
||||
|
||||
@@ -158,6 +158,7 @@ impl<F: Fn(&MessageDiscriminant) -> Vec<KeysGroup>> MessageHandler<LayoutMessage
|
||||
responses.add(callback_message);
|
||||
}
|
||||
Widget::IconLabel(_) => {}
|
||||
Widget::ImageLabel(_) => {}
|
||||
Widget::InvisibleStandinInput(invisible) => {
|
||||
let callback_message = (invisible.on_update.callback)(&());
|
||||
responses.add(callback_message);
|
||||
|
||||
@@ -288,6 +288,7 @@ impl LayoutGroup {
|
||||
Widget::FontInput(x) => &mut x.tooltip,
|
||||
Widget::IconButton(x) => &mut x.tooltip,
|
||||
Widget::IconLabel(x) => &mut x.tooltip,
|
||||
Widget::ImageLabel(x) => &mut x.tooltip,
|
||||
Widget::LayerReferenceInput(x) => &mut x.tooltip,
|
||||
Widget::NumberInput(x) => &mut x.tooltip,
|
||||
Widget::OptionalInput(x) => &mut x.tooltip,
|
||||
@@ -438,6 +439,7 @@ pub enum Widget {
|
||||
FontInput(FontInput),
|
||||
IconButton(IconButton),
|
||||
IconLabel(IconLabel),
|
||||
ImageLabel(ImageLabel),
|
||||
InvisibleStandinInput(InvisibleStandinInput),
|
||||
LayerReferenceInput(LayerReferenceInput),
|
||||
NumberInput(NumberInput),
|
||||
@@ -516,6 +518,7 @@ impl DiffUpdate {
|
||||
Widget::PopoverButton(widget) => Some((&mut widget.tooltip, &mut widget.tooltip_shortcut)),
|
||||
Widget::TextButton(widget) => Some((&mut widget.tooltip, &mut widget.tooltip_shortcut)),
|
||||
Widget::IconLabel(_)
|
||||
| Widget::ImageLabel(_)
|
||||
| Widget::CurveInput(_)
|
||||
| Widget::InvisibleStandinInput(_)
|
||||
| Widget::PivotAssist(_)
|
||||
|
||||
@@ -12,6 +12,18 @@ pub struct IconLabel {
|
||||
pub tooltip: String,
|
||||
}
|
||||
|
||||
#[derive(Clone, Serialize, Deserialize, Derivative, Debug, Default, PartialEq, Eq, WidgetBuilder, specta::Type)]
|
||||
pub struct ImageLabel {
|
||||
#[widget_builder(constructor)]
|
||||
pub image: String,
|
||||
|
||||
pub width: Option<String>,
|
||||
|
||||
pub height: Option<String>,
|
||||
|
||||
pub tooltip: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Default, PartialEq, Eq, Serialize, Deserialize, WidgetBuilder, specta::Type)]
|
||||
pub struct Separator {
|
||||
pub direction: SeparatorDirection,
|
||||
|
||||
@@ -49,10 +49,17 @@ impl LayoutHolder for MenuBarMessageHandler {
|
||||
},
|
||||
MenuBarEntry {
|
||||
label: "Open…".into(),
|
||||
icon: Some("Folder".into()),
|
||||
shortcut: action_keys!(PortfolioMessageDiscriminant::OpenDocument),
|
||||
action: MenuBarEntry::create_action(|_| PortfolioMessage::OpenDocument.into()),
|
||||
..MenuBarEntry::default()
|
||||
},
|
||||
MenuBarEntry {
|
||||
label: "Open Demo Artwork…".into(),
|
||||
icon: Some("Image".into()),
|
||||
action: MenuBarEntry::create_action(|_| DialogMessage::RequestDemoArtworkDialog.into()),
|
||||
..MenuBarEntry::default()
|
||||
},
|
||||
],
|
||||
vec![
|
||||
MenuBarEntry {
|
||||
|
||||
+11
-2
@@ -1,12 +1,21 @@
|
||||
{
|
||||
"extends": "@parcel/config-default",
|
||||
"transformers": {
|
||||
"*.svelte": [
|
||||
"parcel-transformer-svelte3-plus"
|
||||
],
|
||||
"*.svg": [
|
||||
"...",
|
||||
"@parcel/transformer-inline-string"
|
||||
],
|
||||
"*.svelte": [
|
||||
"parcel-transformer-svelte3-plus"
|
||||
"*.png, *.jpg": [
|
||||
"...",
|
||||
"@parcel/transformer-inline-string"
|
||||
]
|
||||
},
|
||||
"optimizers": {
|
||||
"*.png, *.jpg": [
|
||||
"@parcel/optimizer-data-url"
|
||||
]
|
||||
}
|
||||
}
|
||||
File renamed without changes.
|
Before Width: | Height: | Size: 189 B After Width: | Height: | Size: 189 B |
Binary file not shown.
|
After Width: | Height: | Size: 7.0 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 13 KiB |
Generated
+1869
-1011
File diff suppressed because it is too large.
Load diff
@@ -34,17 +34,18 @@
|
||||
"reflect-metadata": "^0.1.13"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@parcel/config-default": "^2.8.3",
|
||||
"@parcel/packager-raw-url": "^2.8.3",
|
||||
"@parcel/transformer-inline-string": "^2.8.3",
|
||||
"@parcel/transformer-webmanifest": "^2.8.3",
|
||||
"@parcel/config-default": "^2.9.3",
|
||||
"@parcel/packager-raw-url": "^2.9.3",
|
||||
"@parcel/optimizer-data-url": "^2.9.3",
|
||||
"@parcel/transformer-inline-string": "^2.9.3",
|
||||
"@parcel/transformer-webmanifest": "^2.9.3",
|
||||
"@types/license-checker-webpack-plugin": "^0.2.1",
|
||||
"@types/node": "^18.16.2",
|
||||
"@types/webpack": "^5.28.1",
|
||||
"buffer": "^5.7.1",
|
||||
"concurrently": "^8.0.1",
|
||||
"license-checker-webpack-plugin": "^0.2.1",
|
||||
"parcel": "^2.8.3",
|
||||
"parcel": "^2.9.3",
|
||||
"parcel-transformer-svelte3-plus": "^0.2.9",
|
||||
"postcss": "^8.4.23",
|
||||
"process": "^0.11.10",
|
||||
|
||||
@@ -84,6 +84,10 @@
|
||||
height: auto;
|
||||
}
|
||||
|
||||
.image-label {
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
.panic-buttons-row {
|
||||
height: 32px;
|
||||
align-items: center;
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
import TextAreaInput from "@graphite/components/widgets/inputs/TextAreaInput.svelte";
|
||||
import TextInput from "@graphite/components/widgets/inputs/TextInput.svelte";
|
||||
import IconLabel from "@graphite/components/widgets/labels/IconLabel.svelte";
|
||||
import ImageLabel from "@graphite/components/widgets/labels/ImageLabel.svelte";
|
||||
import Separator from "@graphite/components/widgets/labels/Separator.svelte";
|
||||
import TextLabel from "@graphite/components/widgets/labels/TextLabel.svelte";
|
||||
import { getContext } from "svelte";
|
||||
@@ -120,6 +121,10 @@
|
||||
{#if iconLabel}
|
||||
<IconLabel {...exclude(iconLabel)} />
|
||||
{/if}
|
||||
{@const imageLabel = narrowWidgetProps(component.props, "ImageLabel")}
|
||||
{#if imageLabel}
|
||||
<ImageLabel {...exclude(imageLabel)} />
|
||||
{/if}
|
||||
{@const layerReferenceInput = narrowWidgetProps(component.props, "LayerReferenceInput")}
|
||||
{#if layerReferenceInput}
|
||||
<LayerReferenceInput {...exclude(layerReferenceInput)} on:value={({ detail }) => updateLayout(index, detail)} />
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
<script lang="ts">
|
||||
import { IMAGE_BASE64_STRINGS } from "@graphite/utility-functions/images";
|
||||
|
||||
let className = "";
|
||||
export { className as class };
|
||||
export let classes: Record<string, boolean> = {};
|
||||
|
||||
export let image: string;
|
||||
export let width: string | undefined;
|
||||
export let height: string | undefined;
|
||||
export let tooltip: string | undefined = undefined;
|
||||
|
||||
$: extraClasses = Object.entries(classes)
|
||||
.flatMap((classAndState) => (classAndState[1] ? [classAndState[0]] : []))
|
||||
.join(" ");
|
||||
</script>
|
||||
|
||||
<img src={IMAGE_BASE64_STRINGS[image]} style:width style:height class={`image-label ${className} ${extraClasses}`.trim()} title={tooltip} alt="" />
|
||||
|
||||
<style lang="scss" global>
|
||||
.image-label {
|
||||
width: auto;
|
||||
height: auto;
|
||||
|
||||
+ .image-label {
|
||||
margin-left: 8px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -40,14 +40,6 @@
|
||||
|
||||
let tabElements: (LayoutRow | undefined)[] = [];
|
||||
|
||||
function newDocument() {
|
||||
editor.instance.newDocumentDialog();
|
||||
}
|
||||
|
||||
function openDocument() {
|
||||
editor.instance.documentOpen();
|
||||
}
|
||||
|
||||
function platformModifiers(reservedKey: boolean): LayoutKeysGroup {
|
||||
// TODO: Remove this by properly feeding these keys from a layout provided by the backend
|
||||
|
||||
@@ -128,7 +120,7 @@
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<TextButton label="New Document" icon="File" action={() => newDocument()} />
|
||||
<TextButton label="New Document" icon="File" action={() => editor.instance.newDocumentDialog()} />
|
||||
</td>
|
||||
<td>
|
||||
<UserInputLabel keysWithLabelsGroups={[[...platformModifiers(true), { key: "KeyN", label: "N" }]]} />
|
||||
@@ -136,12 +128,17 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<TextButton label="Open Document" icon="Folder" action={() => openDocument()} />
|
||||
<TextButton label="Open Document" icon="Folder" action={() => editor.instance.openDocument()} />
|
||||
</td>
|
||||
<td>
|
||||
<UserInputLabel keysWithLabelsGroups={[[...platformModifiers(false), { key: "KeyO", label: "O" }]]} />
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<TextButton label="Open Demo Artwork" icon="Image" action={() => editor.instance.demoArtworkDialog()} />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</LayoutRow>
|
||||
</LayoutCol>
|
||||
|
||||
Vendored
+10
@@ -5,3 +5,13 @@ declare module "*.svg" {
|
||||
const content: string;
|
||||
export default content;
|
||||
}
|
||||
|
||||
declare module "*.png" {
|
||||
const content: string;
|
||||
export default content;
|
||||
}
|
||||
|
||||
declare module "*.jpg" {
|
||||
const content: string;
|
||||
export default content;
|
||||
}
|
||||
@@ -8,10 +8,10 @@ import { type Editor } from "@graphite/wasm-communication/editor";
|
||||
import {
|
||||
type FrontendDocumentDetails,
|
||||
TriggerCopyToClipboardBlobUrl,
|
||||
TriggerFetchAndOpenDocument,
|
||||
TriggerDownloadBlobUrl,
|
||||
TriggerDownloadRaster,
|
||||
TriggerDownloadTextFile,
|
||||
TriggerImaginateCheckServerStatus,
|
||||
TriggerImport,
|
||||
TriggerOpenDocument,
|
||||
TriggerRasterizeRegionBelowLayer,
|
||||
@@ -45,6 +45,19 @@ export function createPortfolioState(editor: Editor) {
|
||||
return state;
|
||||
})
|
||||
});
|
||||
editor.subscriptions.subscribeJsMessage(TriggerFetchAndOpenDocument, async (triggerFetchAndOpenDocument) => {
|
||||
try {
|
||||
const url = new URL(triggerFetchAndOpenDocument.url);
|
||||
const data = await fetch(url);
|
||||
|
||||
const filename = url.pathname.split("/").pop() || "Untitled";
|
||||
const content = await data.text();
|
||||
|
||||
editor.instance.openDocumentFile(filename, content);
|
||||
} catch {
|
||||
editor.instance.errorDialog("Failed to open document", "The file could not be reached over the internet. You may be offline, or it may be missing.");
|
||||
}
|
||||
});
|
||||
editor.subscriptions.subscribeJsMessage(TriggerOpenDocument, async () => {
|
||||
const extension = editor.instance.fileSaveSuffix();
|
||||
const data = await upload(extension, "text");
|
||||
|
||||
@@ -113,7 +113,7 @@ import NodeBlur from "@graphite-frontend/assets/icon-16px-solid/node-blur.svg";
|
||||
import NodeBrushwork from "@graphite-frontend/assets/icon-16px-solid/node-brushwork.svg";
|
||||
import NodeColorCorrection from "@graphite-frontend/assets/icon-16px-solid/node-color-correction.svg";
|
||||
import NodeGradient from "@graphite-frontend/assets/icon-16px-solid/node-gradient.svg";
|
||||
import NodeImage from "@graphite-frontend/assets/icon-16px-solid/node-image.svg";
|
||||
import Image from "@graphite-frontend/assets/icon-16px-solid/image.svg";
|
||||
import NodeImaginate from "@graphite-frontend/assets/icon-16px-solid/node-imaginate.svg";
|
||||
import NodeMagicWand from "@graphite-frontend/assets/icon-16px-solid/node-magic-wand.svg";
|
||||
import NodeMask from "@graphite-frontend/assets/icon-16px-solid/node-mask.svg";
|
||||
@@ -176,7 +176,7 @@ const SOLID_16PX = {
|
||||
NodeBrushwork: { svg: NodeBrushwork, size: 16 },
|
||||
NodeColorCorrection: { svg: NodeColorCorrection, size: 16 },
|
||||
NodeGradient: { svg: NodeGradient, size: 16 },
|
||||
NodeImage: { svg: NodeImage, size: 16 },
|
||||
Image: { svg: Image, size: 16 },
|
||||
NodeImaginate: { svg: NodeImaginate, size: 16 },
|
||||
NodeMagicWand: { svg: NodeMagicWand, size: 16 },
|
||||
NodeMask: { svg: NodeMask, size: 16 },
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
/* eslint-disable import/first */
|
||||
|
||||
// Demo artwork
|
||||
import ThumbnailJustAPottedCactus from "@graphite-frontend/assets/images/demo-artwork/thumbnail-just-a-potted-cactus.png";
|
||||
import ThumbnailValleyOfSpires from "@graphite-frontend/assets/images/demo-artwork/thumbnail-valley-of-spires.png";
|
||||
|
||||
const DEMO_ARTWORK = {
|
||||
ThumbnailJustAPottedCactus,
|
||||
ThumbnailValleyOfSpires,
|
||||
} as const;
|
||||
|
||||
// All images
|
||||
const IMAGE_LIST = {
|
||||
...DEMO_ARTWORK,
|
||||
} as const;
|
||||
|
||||
// Exported images and types
|
||||
export const IMAGES: ImageDefinitionType<typeof IMAGE_LIST> = IMAGE_LIST;
|
||||
export const IMAGE_BASE64_STRINGS = Object.fromEntries(Object.entries(IMAGES).map(([name, data]) => [name, data]));
|
||||
|
||||
// See `icons.ts` for explanation about how this works
|
||||
type EvaluateType<T> = T extends infer O ? { [K in keyof O]: O[K] } : never;
|
||||
type ImageDefinitionType<T extends Record<string, string>> = EvaluateType<{ [key in keyof T]: string }>;
|
||||
@@ -89,6 +89,21 @@ export function createEditor() {
|
||||
// Subscriptions: Allows subscribing to messages in JS that are sent from the WASM backend
|
||||
const subscriptions: SubscriptionRouter = createSubscriptionRouter();
|
||||
|
||||
// Check if the URL hash fragment has any demo artwork to be loaded
|
||||
(async () => {
|
||||
const demoArtwork = window.location.hash.trim().match(/#demo\/(.*)/)?.[1];
|
||||
if (!demoArtwork) return;
|
||||
|
||||
try {
|
||||
const url = new URL(`https://raw.githubusercontent.com/GraphiteEditor/Graphite/master/demo-artwork/${demoArtwork}.graphite`);
|
||||
const data = await fetch(url);
|
||||
|
||||
const filename = url.pathname.split("/").pop() || "Untitled";
|
||||
const content = await data.text();
|
||||
instance.openDocumentFile(filename, content);
|
||||
} catch {}
|
||||
})();
|
||||
|
||||
return {
|
||||
raw,
|
||||
instance,
|
||||
|
||||
@@ -513,6 +513,10 @@ export class TriggerLoadAutoSaveDocuments extends JsMessage { }
|
||||
|
||||
export class TriggerLoadPreferences extends JsMessage { }
|
||||
|
||||
export class TriggerFetchAndOpenDocument extends JsMessage {
|
||||
readonly url!: string;
|
||||
}
|
||||
|
||||
export class TriggerOpenDocument extends JsMessage { }
|
||||
|
||||
export class TriggerImport extends JsMessage { }
|
||||
@@ -874,6 +878,19 @@ export class IconLabel extends WidgetProps {
|
||||
tooltip!: string | undefined;
|
||||
}
|
||||
|
||||
export class ImageLabel extends WidgetProps {
|
||||
image!: IconName;
|
||||
|
||||
@Transform(({ value }: { value: string }) => value || undefined)
|
||||
width!: string | undefined;
|
||||
|
||||
@Transform(({ value }: { value: string }) => value || undefined)
|
||||
height!: string | undefined;
|
||||
|
||||
@Transform(({ value }: { value: string }) => value || undefined)
|
||||
tooltip!: string | undefined;
|
||||
}
|
||||
|
||||
export class LayerReferenceInput extends WidgetProps {
|
||||
@Transform(({ value }: { value: BigUint64Array | undefined }) => (value ? String(value) : undefined))
|
||||
value!: string | undefined;
|
||||
@@ -1120,6 +1137,7 @@ const widgetSubTypes = [
|
||||
{ value: FontInput, name: "FontInput" },
|
||||
{ value: IconButton, name: "IconButton" },
|
||||
{ value: IconLabel, name: "IconLabel" },
|
||||
{ value: ImageLabel, name: "ImageLabel" },
|
||||
{ value: LayerReferenceInput, name: "LayerReferenceInput" },
|
||||
{ value: NumberInput, name: "NumberInput" },
|
||||
{ value: OptionalInput, name: "OptionalInput" },
|
||||
@@ -1367,6 +1385,7 @@ export const messageMakers: Record<string, MessageMaker> = {
|
||||
DisplayRemoveEditableTextbox,
|
||||
TriggerAboutGraphiteLocalizedCommitDate,
|
||||
TriggerCopyToClipboardBlobUrl,
|
||||
TriggerFetchAndOpenDocument,
|
||||
TriggerDownloadBlobUrl,
|
||||
TriggerDownloadRaster,
|
||||
TriggerDownloadTextFile,
|
||||
|
||||
@@ -308,12 +308,18 @@ impl JsEditorHandle {
|
||||
self.dispatch(message);
|
||||
}
|
||||
|
||||
#[wasm_bindgen(js_name = documentOpen)]
|
||||
pub fn document_open(&self) {
|
||||
#[wasm_bindgen(js_name = openDocument)]
|
||||
pub fn open_document(&self) {
|
||||
let message = PortfolioMessage::OpenDocument;
|
||||
self.dispatch(message);
|
||||
}
|
||||
|
||||
#[wasm_bindgen(js_name = demoArtworkDialog)]
|
||||
pub fn demo_artwork_dialog(&self) {
|
||||
let message = DialogMessage::RequestDemoArtworkDialog;
|
||||
self.dispatch(message);
|
||||
}
|
||||
|
||||
#[wasm_bindgen(js_name = openDocumentFile)]
|
||||
pub fn open_document_file(&self, document_name: String, document_serialized_content: String) {
|
||||
let message = PortfolioMessage::OpenDocumentFile {
|
||||
|
||||
Reference in new issue
Block a user