Menu bar definition in backend (#681)

* initial menu layout working

* removed api.rs functions

* no action shortcut for no-op

* code review

* nitpicks
This commit is contained in:
mfish33
2022-06-18 18:46:23 -06:00
committed by Keavon Chambers
parent 9bd27ec3f8
commit 5d6d2b22bc
35 changed files with 781 additions and 475 deletions

View File

@@ -8,7 +8,7 @@ pub struct AboutGraphite {
}
impl PropertyHolder for AboutGraphite {
fn properties(&self) -> WidgetLayout {
fn properties(&self) -> Layout {
let links = [
("Website", "https://graphite.rs"),
("Credits", "https://github.com/GraphiteEditor/Graphite/graphs/contributors"),
@@ -25,28 +25,28 @@ impl PropertyHolder for AboutGraphite {
}))
})
.collect();
WidgetLayout::new(vec![
LayoutRow::Row {
Layout::WidgetLayout(WidgetLayout::new(vec![
LayoutGroup::Row {
widgets: vec![WidgetHolder::new(Widget::TextLabel(TextLabel {
value: "Graphite".to_string(),
bold: true,
..Default::default()
}))],
},
LayoutRow::Row {
LayoutGroup::Row {
widgets: vec![WidgetHolder::new(Widget::TextLabel(TextLabel {
value: release_series(),
..Default::default()
}))],
},
LayoutRow::Row {
LayoutGroup::Row {
widgets: vec![WidgetHolder::new(Widget::TextLabel(TextLabel {
value: commit_info_localized(self.localized_commit_date.as_str()),
multiline: true,
..Default::default()
}))],
},
LayoutRow::Row { widgets: link_widgets },
])
LayoutGroup::Row { widgets: link_widgets },
]))
}
}

View File

@@ -5,7 +5,7 @@ use crate::message_prelude::{DialogMessage, FrontendMessage, PortfolioMessage};
pub struct CloseAllDocuments;
impl PropertyHolder for CloseAllDocuments {
fn properties(&self) -> WidgetLayout {
fn properties(&self) -> Layout {
let button_widgets = vec![
WidgetHolder::new(Widget::TextButton(TextButton {
label: "Discard All".to_string(),
@@ -26,22 +26,22 @@ impl PropertyHolder for CloseAllDocuments {
})),
];
WidgetLayout::new(vec![
LayoutRow::Row {
Layout::WidgetLayout(WidgetLayout::new(vec![
LayoutGroup::Row {
widgets: vec![WidgetHolder::new(Widget::TextLabel(TextLabel {
value: "Close all documents?".to_string(),
bold: true,
..Default::default()
}))],
},
LayoutRow::Row {
LayoutGroup::Row {
widgets: vec![WidgetHolder::new(Widget::TextLabel(TextLabel {
value: "Unsaved work will be lost!".to_string(),
multiline: true,
..Default::default()
}))],
},
LayoutRow::Row { widgets: button_widgets },
])
LayoutGroup::Row { widgets: button_widgets },
]))
}
}

View File

@@ -8,7 +8,7 @@ pub struct CloseDocument {
}
impl PropertyHolder for CloseDocument {
fn properties(&self) -> WidgetLayout {
fn properties(&self) -> Layout {
let document_id = self.document_id;
let button_widgets = vec![
@@ -43,22 +43,22 @@ impl PropertyHolder for CloseDocument {
})),
];
WidgetLayout::new(vec![
LayoutRow::Row {
Layout::WidgetLayout(WidgetLayout::new(vec![
LayoutGroup::Row {
widgets: vec![WidgetHolder::new(Widget::TextLabel(TextLabel {
value: "Save changes before closing?".to_string(),
bold: true,
..Default::default()
}))],
},
LayoutRow::Row {
LayoutGroup::Row {
widgets: vec![WidgetHolder::new(Widget::TextLabel(TextLabel {
value: self.document_name.clone(),
multiline: true,
..Default::default()
}))],
},
LayoutRow::Row { widgets: button_widgets },
])
LayoutGroup::Row { widgets: button_widgets },
]))
}
}

View File

@@ -8,7 +8,7 @@ pub struct ComingSoon {
}
impl PropertyHolder for ComingSoon {
fn properties(&self) -> WidgetLayout {
fn properties(&self) -> Layout {
let mut details = "This feature is not implemented yet".to_string();
let mut buttons = vec![WidgetHolder::new(Widget::TextButton(TextButton {
label: "OK".to_string(),
@@ -31,22 +31,22 @@ impl PropertyHolder for ComingSoon {
..Default::default()
})));
}
WidgetLayout::new(vec![
LayoutRow::Row {
Layout::WidgetLayout(WidgetLayout::new(vec![
LayoutGroup::Row {
widgets: vec![WidgetHolder::new(Widget::TextLabel(TextLabel {
value: "Coming soon".to_string(),
bold: true,
..Default::default()
}))],
},
LayoutRow::Row {
LayoutGroup::Row {
widgets: vec![WidgetHolder::new(Widget::TextLabel(TextLabel {
value: details,
multiline: true,
..Default::default()
}))],
},
LayoutRow::Row { widgets: buttons },
])
LayoutGroup::Row { widgets: buttons },
]))
}
}

View File

@@ -7,23 +7,23 @@ pub struct Error {
}
impl PropertyHolder for Error {
fn properties(&self) -> WidgetLayout {
WidgetLayout::new(vec![
LayoutRow::Row {
fn properties(&self) -> Layout {
Layout::WidgetLayout(WidgetLayout::new(vec![
LayoutGroup::Row {
widgets: vec![WidgetHolder::new(Widget::TextLabel(TextLabel {
value: self.title.clone(),
bold: true,
..Default::default()
}))],
},
LayoutRow::Row {
LayoutGroup::Row {
widgets: vec![WidgetHolder::new(Widget::TextLabel(TextLabel {
value: self.description.clone(),
multiline: true,
..Default::default()
}))],
},
LayoutRow::Row {
LayoutGroup::Row {
widgets: vec![WidgetHolder::new(Widget::TextButton(TextButton {
label: "OK".to_string(),
emphasized: true,
@@ -32,6 +32,6 @@ impl PropertyHolder for Error {
..Default::default()
}))],
},
])
]))
}
}

View File

@@ -18,7 +18,7 @@ pub struct Export {
}
impl PropertyHolder for Export {
fn properties(&self) -> WidgetLayout {
fn properties(&self) -> Layout {
let file_name = vec![
WidgetHolder::new(Widget::TextLabel(TextLabel {
value: "File Name".into(),
@@ -132,20 +132,20 @@ impl PropertyHolder for Export {
})),
];
WidgetLayout::new(vec![
LayoutRow::Row {
Layout::WidgetLayout(WidgetLayout::new(vec![
LayoutGroup::Row {
widgets: vec![WidgetHolder::new(Widget::TextLabel(TextLabel {
value: "Export".to_string(),
bold: true,
..Default::default()
}))],
},
LayoutRow::Row { widgets: file_name },
LayoutRow::Row { widgets: export_type },
LayoutRow::Row { widgets: resolution },
LayoutRow::Row { widgets: export_area },
LayoutRow::Row { widgets: button_widgets },
])
LayoutGroup::Row { widgets: file_name },
LayoutGroup::Row { widgets: export_type },
LayoutGroup::Row { widgets: resolution },
LayoutGroup::Row { widgets: export_area },
LayoutGroup::Row { widgets: button_widgets },
]))
}
}

View File

@@ -14,7 +14,7 @@ pub struct NewDocument {
}
impl PropertyHolder for NewDocument {
fn properties(&self) -> WidgetLayout {
fn properties(&self) -> Layout {
let title = vec![WidgetHolder::new(Widget::TextLabel(TextLabel {
value: "New document".into(),
bold: true,
@@ -112,13 +112,13 @@ impl PropertyHolder for NewDocument {
})),
];
WidgetLayout::new(vec![
LayoutRow::Row { widgets: title },
LayoutRow::Row { widgets: name },
LayoutRow::Row { widgets: infinite },
LayoutRow::Row { widgets: scale },
LayoutRow::Row { widgets: button_widgets },
])
Layout::WidgetLayout(WidgetLayout::new(vec![
LayoutGroup::Row { widgets: title },
LayoutGroup::Row { widgets: name },
LayoutGroup::Row { widgets: infinite },
LayoutGroup::Row { widgets: scale },
LayoutGroup::Row { widgets: button_widgets },
]))
}
}