mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-24 01:18:12 +08:00
Clean up MenuList types and fix many Vue and Clippy warnings
Also remove hard-coded-in-Vue Graphite logo in the menu bar in favor of a Rust definition.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
use super::utility_types::{FrontendDocumentDetails, FrontendImageData, MouseCursorIcon};
|
||||
use crate::messages::layout::utility_types::layout_widget::SubLayout;
|
||||
use crate::messages::layout::utility_types::misc::LayoutTarget;
|
||||
use crate::messages::layout::utility_types::widgets::menu_widgets::MenuColumn;
|
||||
use crate::messages::layout::utility_types::widgets::menu_widgets::MenuBarEntry;
|
||||
use crate::messages::portfolio::document::utility_types::layer_panel::{LayerPanelEntry, RawBuffer};
|
||||
use crate::messages::prelude::*;
|
||||
use crate::messages::tool::utility_types::HintData;
|
||||
@@ -141,7 +141,7 @@ pub enum FrontendMessage {
|
||||
UpdateMenuBarLayout {
|
||||
#[serde(rename = "layoutTarget")]
|
||||
layout_target: LayoutTarget,
|
||||
layout: Vec<MenuColumn>,
|
||||
layout: Vec<MenuBarEntry>,
|
||||
},
|
||||
UpdateMouseCursor {
|
||||
cursor: MouseCursorIcon,
|
||||
|
||||
@@ -30,18 +30,31 @@ impl<F: Fn(&MessageDiscriminant) -> Vec<KeysGroup>> MessageHandler<LayoutMessage
|
||||
self.send_layout(layout_target, responses, &action_input_mapping);
|
||||
}
|
||||
UpdateLayout { layout_target, widget_id, value } => {
|
||||
let layout = &mut self.layouts[layout_target as usize];
|
||||
let widget_holder = layout.iter_mut().find(|widget| widget.widget_id == widget_id);
|
||||
if widget_holder.is_none() {
|
||||
log::trace!(
|
||||
"Could not find widget_id:{} on layout_target:{:?}. This could be an indication of a problem or just a user clicking off of an actively edited layer",
|
||||
// Look up the layout
|
||||
let layout = if let Some(layout) = self.layouts.get_mut(layout_target as usize) {
|
||||
layout
|
||||
} else {
|
||||
log::warn!(
|
||||
"UpdateLayout was called referencing an invalid layout. `widget_id: {}`, `layout_target: {:?}`",
|
||||
widget_id,
|
||||
layout_target
|
||||
);
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
let widget_holder = if let Some(widget_holder) = layout.iter_mut().find(|widget| widget.widget_id == widget_id) {
|
||||
widget_holder
|
||||
} else {
|
||||
log::warn!(
|
||||
"UpdateLayout was called referencing an invalid widget ID, although the layout target was valid. `widget_id: {}`, `layout_target: {:?}`",
|
||||
widget_id,
|
||||
layout_target
|
||||
);
|
||||
return;
|
||||
};
|
||||
|
||||
#[remain::sorted]
|
||||
match &mut widget_holder.unwrap().widget {
|
||||
match &mut widget_holder.widget {
|
||||
Widget::CheckboxInput(checkbox_input) => {
|
||||
let update_value = value.as_bool().expect("CheckboxInput update was not of type: bool");
|
||||
checkbox_input.checked = update_value;
|
||||
|
||||
@@ -9,9 +9,9 @@ use serde::{Deserialize, Serialize};
|
||||
use super::input_widgets::InvisibleStandinInput;
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)]
|
||||
pub struct MenuEntryGroups(pub Vec<Vec<MenuEntry>>);
|
||||
pub struct MenuBarEntryChildren(pub Vec<Vec<MenuBarEntry>>);
|
||||
|
||||
impl MenuEntryGroups {
|
||||
impl MenuBarEntryChildren {
|
||||
pub fn empty() -> Self {
|
||||
Self(Vec::new())
|
||||
}
|
||||
@@ -31,15 +31,23 @@ impl MenuEntryGroups {
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
|
||||
pub struct MenuEntry {
|
||||
pub struct MenuBarEntry {
|
||||
pub label: String,
|
||||
pub icon: Option<String>,
|
||||
pub children: MenuEntryGroups,
|
||||
pub action: WidgetHolder,
|
||||
pub shortcut: Option<ActionKeys>,
|
||||
pub action: WidgetHolder,
|
||||
pub children: MenuBarEntryChildren,
|
||||
}
|
||||
|
||||
impl MenuEntry {
|
||||
impl MenuBarEntry {
|
||||
pub fn new_root(label: String, children: MenuBarEntryChildren) -> Self {
|
||||
Self {
|
||||
label,
|
||||
children,
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn create_action(callback: impl Fn(&()) -> Message + 'static) -> WidgetHolder {
|
||||
WidgetHolder::new(Widget::InvisibleStandinInput(InvisibleStandinInput {
|
||||
on_update: WidgetCallback::new(callback),
|
||||
@@ -47,54 +55,46 @@ impl MenuEntry {
|
||||
}
|
||||
|
||||
pub fn no_action() -> WidgetHolder {
|
||||
MenuEntry::create_action(|_| Message::NoOp)
|
||||
MenuBarEntry::create_action(|_| Message::NoOp)
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for MenuEntry {
|
||||
impl Default for MenuBarEntry {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
action: MenuEntry::create_action(|_| DialogMessage::RequestComingSoonDialog { issue: None }.into()),
|
||||
label: "".into(),
|
||||
icon: None,
|
||||
children: MenuEntryGroups::empty(),
|
||||
shortcut: None,
|
||||
action: MenuBarEntry::no_action(),
|
||||
children: MenuBarEntryChildren::empty(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, Clone, Serialize, Deserialize, PartialEq)]
|
||||
pub struct MenuColumn {
|
||||
pub label: String,
|
||||
pub children: MenuEntryGroups,
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct MenuLayout {
|
||||
pub layout: Vec<MenuColumn>,
|
||||
pub layout: Vec<MenuBarEntry>,
|
||||
}
|
||||
|
||||
impl MenuLayout {
|
||||
pub fn new(layout: Vec<MenuColumn>) -> Self {
|
||||
pub fn new(layout: Vec<MenuBarEntry>) -> Self {
|
||||
Self { layout }
|
||||
}
|
||||
|
||||
pub fn iter(&self) -> impl Iterator<Item = &WidgetHolder> + '_ {
|
||||
MenuLayoutIter {
|
||||
stack: self.layout.iter().flat_map(|column| column.children.0.iter()).flat_map(|group| group.iter()).collect(),
|
||||
}
|
||||
MenuLayoutIter { stack: self.layout.iter().collect() }
|
||||
}
|
||||
|
||||
pub fn iter_mut(&mut self) -> impl Iterator<Item = &mut WidgetHolder> + '_ {
|
||||
MenuLayoutIterMut {
|
||||
stack: self.layout.iter_mut().flat_map(|column| column.children.0.iter_mut()).flat_map(|group| group.iter_mut()).collect(),
|
||||
stack: self.layout.iter_mut().collect(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Default)]
|
||||
pub struct MenuLayoutIter<'a> {
|
||||
pub stack: Vec<&'a MenuEntry>,
|
||||
pub stack: Vec<&'a MenuBarEntry>,
|
||||
}
|
||||
|
||||
impl<'a> Iterator for MenuLayoutIter<'a> {
|
||||
@@ -114,7 +114,7 @@ impl<'a> Iterator for MenuLayoutIter<'a> {
|
||||
}
|
||||
|
||||
pub struct MenuLayoutIterMut<'a> {
|
||||
pub stack: Vec<&'a mut MenuEntry>,
|
||||
pub stack: Vec<&'a mut MenuBarEntry>,
|
||||
}
|
||||
|
||||
impl<'a> Iterator for MenuLayoutIterMut<'a> {
|
||||
|
||||
@@ -47,6 +47,7 @@ impl LayerMetadata {
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
|
||||
pub struct LayerPanelEntry {
|
||||
pub name: String,
|
||||
pub tooltip: String,
|
||||
pub visible: bool,
|
||||
#[serde(rename = "layerType")]
|
||||
pub layer_type: LayerDataTypeDiscriminant,
|
||||
@@ -59,9 +60,16 @@ pub struct LayerPanelEntry {
|
||||
impl LayerPanelEntry {
|
||||
pub fn new(layer_metadata: &LayerMetadata, transform: DAffine2, layer: &Layer, path: Vec<LayerId>, font_cache: &FontCache) -> Self {
|
||||
let name = layer.name.clone().unwrap_or_else(|| String::from(""));
|
||||
|
||||
let tooltip = if cfg!(debug_assertions) {
|
||||
let joined = &path.iter().map(|id| id.to_string()).collect::<Vec<_>>().join(" / ");
|
||||
name.clone() + "\nLayer Path: " + joined.as_str()
|
||||
} else {
|
||||
name.clone()
|
||||
};
|
||||
|
||||
let arr = layer.data.bounding_box(transform, font_cache).unwrap_or([DVec2::ZERO, DVec2::ZERO]);
|
||||
let arr = arr.iter().map(|x| (*x).into()).collect::<Vec<(f64, f64)>>();
|
||||
|
||||
let mut thumbnail = String::new();
|
||||
let mut svg_defs = String::new();
|
||||
let render_data = RenderData::new(ViewMode::Normal, font_cache, None, false);
|
||||
@@ -84,6 +92,7 @@ impl LayerPanelEntry {
|
||||
|
||||
LayerPanelEntry {
|
||||
name,
|
||||
tooltip,
|
||||
visible: layer.visible,
|
||||
layer_type: (&layer.data).into(),
|
||||
layer_metadata: *layer_metadata,
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use crate::messages::input_mapper::utility_types::macros::action_keys;
|
||||
use crate::messages::layout::utility_types::layout_widget::{Layout, PropertyHolder};
|
||||
use crate::messages::layout::utility_types::misc::LayoutTarget;
|
||||
use crate::messages::layout::utility_types::widgets::menu_widgets::{MenuColumn, MenuEntry, MenuEntryGroups, MenuLayout};
|
||||
use crate::messages::layout::utility_types::widgets::menu_widgets::{MenuBarEntry, MenuBarEntryChildren, MenuLayout};
|
||||
use crate::messages::portfolio::document::utility_types::clipboards::Clipboard;
|
||||
use crate::messages::prelude::*;
|
||||
|
||||
@@ -27,295 +27,300 @@ impl MessageHandler<MenuBarMessage, ()> for MenuBarMessageHandler {
|
||||
impl PropertyHolder for MenuBarMessageHandler {
|
||||
fn properties(&self) -> Layout {
|
||||
Layout::MenuLayout(MenuLayout::new(vec![
|
||||
MenuColumn {
|
||||
label: "File".into(),
|
||||
children: MenuEntryGroups(vec![
|
||||
MenuBarEntry {
|
||||
icon: Some("GraphiteLogo".into()),
|
||||
action: MenuBarEntry::create_action(|_| FrontendMessage::TriggerVisitLink { url: "https://graphite.rs".into() }.into()),
|
||||
..Default::default()
|
||||
},
|
||||
MenuBarEntry::new_root(
|
||||
"File".into(),
|
||||
MenuBarEntryChildren(vec![
|
||||
vec![
|
||||
MenuEntry {
|
||||
MenuBarEntry {
|
||||
label: "New…".into(),
|
||||
icon: Some("File".into()),
|
||||
action: MenuEntry::create_action(|_| DialogMessage::RequestNewDocumentDialog.into()),
|
||||
action: MenuBarEntry::create_action(|_| DialogMessage::RequestNewDocumentDialog.into()),
|
||||
shortcut: action_keys!(DialogMessageDiscriminant::RequestNewDocumentDialog),
|
||||
children: MenuEntryGroups::empty(),
|
||||
children: MenuBarEntryChildren::empty(),
|
||||
},
|
||||
MenuEntry {
|
||||
MenuBarEntry {
|
||||
label: "Open…".into(),
|
||||
shortcut: action_keys!(PortfolioMessageDiscriminant::OpenDocument),
|
||||
action: MenuEntry::create_action(|_| PortfolioMessage::OpenDocument.into()),
|
||||
..MenuEntry::default()
|
||||
action: MenuBarEntry::create_action(|_| PortfolioMessage::OpenDocument.into()),
|
||||
..MenuBarEntry::default()
|
||||
},
|
||||
],
|
||||
vec![
|
||||
MenuEntry {
|
||||
MenuBarEntry {
|
||||
label: "Close".into(),
|
||||
shortcut: action_keys!(PortfolioMessageDiscriminant::CloseActiveDocumentWithConfirmation),
|
||||
action: MenuEntry::create_action(|_| PortfolioMessage::CloseActiveDocumentWithConfirmation.into()),
|
||||
..MenuEntry::default()
|
||||
action: MenuBarEntry::create_action(|_| PortfolioMessage::CloseActiveDocumentWithConfirmation.into()),
|
||||
..MenuBarEntry::default()
|
||||
},
|
||||
MenuEntry {
|
||||
MenuBarEntry {
|
||||
label: "Close All".into(),
|
||||
shortcut: action_keys!(DialogMessageDiscriminant::CloseAllDocumentsWithConfirmation),
|
||||
action: MenuEntry::create_action(|_| DialogMessage::CloseAllDocumentsWithConfirmation.into()),
|
||||
..MenuEntry::default()
|
||||
action: MenuBarEntry::create_action(|_| DialogMessage::CloseAllDocumentsWithConfirmation.into()),
|
||||
..MenuBarEntry::default()
|
||||
},
|
||||
],
|
||||
vec![MenuEntry {
|
||||
vec![MenuBarEntry {
|
||||
label: "Save".into(),
|
||||
shortcut: action_keys!(DocumentMessageDiscriminant::SaveDocument),
|
||||
action: MenuEntry::create_action(|_| DocumentMessage::SaveDocument.into()),
|
||||
..MenuEntry::default()
|
||||
action: MenuBarEntry::create_action(|_| DocumentMessage::SaveDocument.into()),
|
||||
..MenuBarEntry::default()
|
||||
}],
|
||||
vec![
|
||||
MenuEntry {
|
||||
MenuBarEntry {
|
||||
label: "Import…".into(),
|
||||
shortcut: action_keys!(PortfolioMessageDiscriminant::Import),
|
||||
action: MenuEntry::create_action(|_| PortfolioMessage::Import.into()),
|
||||
..MenuEntry::default()
|
||||
action: MenuBarEntry::create_action(|_| PortfolioMessage::Import.into()),
|
||||
..MenuBarEntry::default()
|
||||
},
|
||||
MenuEntry {
|
||||
MenuBarEntry {
|
||||
label: "Export…".into(),
|
||||
shortcut: action_keys!(DialogMessageDiscriminant::RequestExportDialog),
|
||||
action: MenuEntry::create_action(|_| DialogMessage::RequestExportDialog.into()),
|
||||
..MenuEntry::default()
|
||||
action: MenuBarEntry::create_action(|_| DialogMessage::RequestExportDialog.into()),
|
||||
..MenuBarEntry::default()
|
||||
},
|
||||
],
|
||||
]),
|
||||
},
|
||||
MenuColumn {
|
||||
label: "Edit".into(),
|
||||
children: MenuEntryGroups(vec![
|
||||
),
|
||||
MenuBarEntry::new_root(
|
||||
"Edit".into(),
|
||||
MenuBarEntryChildren(vec![
|
||||
vec![
|
||||
MenuEntry {
|
||||
MenuBarEntry {
|
||||
label: "Undo".into(),
|
||||
shortcut: action_keys!(DocumentMessageDiscriminant::Undo),
|
||||
action: MenuEntry::create_action(|_| DocumentMessage::Undo.into()),
|
||||
..MenuEntry::default()
|
||||
action: MenuBarEntry::create_action(|_| DocumentMessage::Undo.into()),
|
||||
..MenuBarEntry::default()
|
||||
},
|
||||
MenuEntry {
|
||||
MenuBarEntry {
|
||||
label: "Redo".into(),
|
||||
shortcut: action_keys!(DocumentMessageDiscriminant::Redo),
|
||||
action: MenuEntry::create_action(|_| DocumentMessage::Redo.into()),
|
||||
..MenuEntry::default()
|
||||
action: MenuBarEntry::create_action(|_| DocumentMessage::Redo.into()),
|
||||
..MenuBarEntry::default()
|
||||
},
|
||||
],
|
||||
vec![
|
||||
MenuEntry {
|
||||
MenuBarEntry {
|
||||
label: "Cut".into(),
|
||||
shortcut: action_keys!(PortfolioMessageDiscriminant::Cut),
|
||||
action: MenuEntry::create_action(|_| PortfolioMessage::Cut { clipboard: Clipboard::Device }.into()),
|
||||
..MenuEntry::default()
|
||||
action: MenuBarEntry::create_action(|_| PortfolioMessage::Cut { clipboard: Clipboard::Device }.into()),
|
||||
..MenuBarEntry::default()
|
||||
},
|
||||
MenuEntry {
|
||||
MenuBarEntry {
|
||||
label: "Copy".into(),
|
||||
icon: Some("Copy".into()),
|
||||
shortcut: action_keys!(PortfolioMessageDiscriminant::Copy),
|
||||
action: MenuEntry::create_action(|_| PortfolioMessage::Copy { clipboard: Clipboard::Device }.into()),
|
||||
..MenuEntry::default()
|
||||
action: MenuBarEntry::create_action(|_| PortfolioMessage::Copy { clipboard: Clipboard::Device }.into()),
|
||||
..MenuBarEntry::default()
|
||||
},
|
||||
MenuEntry {
|
||||
MenuBarEntry {
|
||||
label: "Paste".into(),
|
||||
icon: Some("Paste".into()),
|
||||
shortcut: action_keys!(FrontendMessageDiscriminant::TriggerPaste),
|
||||
action: MenuEntry::create_action(|_| FrontendMessage::TriggerPaste.into()),
|
||||
..MenuEntry::default()
|
||||
action: MenuBarEntry::create_action(|_| FrontendMessage::TriggerPaste.into()),
|
||||
..MenuBarEntry::default()
|
||||
},
|
||||
],
|
||||
]),
|
||||
},
|
||||
MenuColumn {
|
||||
label: "Layer".into(),
|
||||
children: MenuEntryGroups(vec![
|
||||
),
|
||||
MenuBarEntry::new_root(
|
||||
"Layer".into(),
|
||||
MenuBarEntryChildren(vec![
|
||||
vec![
|
||||
MenuEntry {
|
||||
MenuBarEntry {
|
||||
label: "Select All".into(),
|
||||
shortcut: action_keys!(DocumentMessageDiscriminant::SelectAllLayers),
|
||||
action: MenuEntry::create_action(|_| DocumentMessage::SelectAllLayers.into()),
|
||||
..MenuEntry::default()
|
||||
action: MenuBarEntry::create_action(|_| DocumentMessage::SelectAllLayers.into()),
|
||||
..MenuBarEntry::default()
|
||||
},
|
||||
MenuEntry {
|
||||
MenuBarEntry {
|
||||
label: "Deselect All".into(),
|
||||
shortcut: action_keys!(DocumentMessageDiscriminant::DeselectAllLayers),
|
||||
action: MenuEntry::create_action(|_| DocumentMessage::DeselectAllLayers.into()),
|
||||
..MenuEntry::default()
|
||||
action: MenuBarEntry::create_action(|_| DocumentMessage::DeselectAllLayers.into()),
|
||||
..MenuBarEntry::default()
|
||||
},
|
||||
],
|
||||
vec![MenuEntry {
|
||||
vec![MenuBarEntry {
|
||||
label: "Delete Selected".into(),
|
||||
icon: Some("Trash".into()),
|
||||
shortcut: action_keys!(DocumentMessageDiscriminant::DeleteSelectedLayers),
|
||||
action: MenuEntry::create_action(|_| DocumentMessage::DeleteSelectedLayers.into()),
|
||||
..MenuEntry::default()
|
||||
action: MenuBarEntry::create_action(|_| DocumentMessage::DeleteSelectedLayers.into()),
|
||||
..MenuBarEntry::default()
|
||||
}],
|
||||
vec![
|
||||
MenuEntry {
|
||||
MenuBarEntry {
|
||||
label: "Grab Selected".into(),
|
||||
shortcut: action_keys!(TransformLayerMessageDiscriminant::BeginGrab),
|
||||
action: MenuEntry::create_action(|_| TransformLayerMessage::BeginGrab.into()),
|
||||
..MenuEntry::default()
|
||||
action: MenuBarEntry::create_action(|_| TransformLayerMessage::BeginGrab.into()),
|
||||
..MenuBarEntry::default()
|
||||
},
|
||||
MenuEntry {
|
||||
MenuBarEntry {
|
||||
label: "Rotate Selected".into(),
|
||||
shortcut: action_keys!(TransformLayerMessageDiscriminant::BeginRotate),
|
||||
action: MenuEntry::create_action(|_| TransformLayerMessage::BeginRotate.into()),
|
||||
..MenuEntry::default()
|
||||
action: MenuBarEntry::create_action(|_| TransformLayerMessage::BeginRotate.into()),
|
||||
..MenuBarEntry::default()
|
||||
},
|
||||
MenuEntry {
|
||||
MenuBarEntry {
|
||||
label: "Scale Selected".into(),
|
||||
shortcut: action_keys!(TransformLayerMessageDiscriminant::BeginScale),
|
||||
action: MenuEntry::create_action(|_| TransformLayerMessage::BeginScale.into()),
|
||||
..MenuEntry::default()
|
||||
action: MenuBarEntry::create_action(|_| TransformLayerMessage::BeginScale.into()),
|
||||
..MenuBarEntry::default()
|
||||
},
|
||||
],
|
||||
vec![MenuEntry {
|
||||
vec![MenuBarEntry {
|
||||
label: "Order".into(),
|
||||
action: MenuEntry::no_action(),
|
||||
children: MenuEntryGroups(vec![vec![
|
||||
MenuEntry {
|
||||
action: MenuBarEntry::no_action(),
|
||||
children: MenuBarEntryChildren(vec![vec![
|
||||
MenuBarEntry {
|
||||
label: "Raise To Front".into(),
|
||||
shortcut: action_keys!(DocumentMessageDiscriminant::SelectedLayersRaiseToFront),
|
||||
action: MenuEntry::create_action(|_| DocumentMessage::SelectedLayersRaiseToFront.into()),
|
||||
..MenuEntry::default()
|
||||
action: MenuBarEntry::create_action(|_| DocumentMessage::SelectedLayersRaiseToFront.into()),
|
||||
..MenuBarEntry::default()
|
||||
},
|
||||
MenuEntry {
|
||||
MenuBarEntry {
|
||||
label: "Raise".into(),
|
||||
shortcut: action_keys!(DocumentMessageDiscriminant::SelectedLayersRaise),
|
||||
action: MenuEntry::create_action(|_| DocumentMessage::SelectedLayersRaise.into()),
|
||||
..MenuEntry::default()
|
||||
action: MenuBarEntry::create_action(|_| DocumentMessage::SelectedLayersRaise.into()),
|
||||
..MenuBarEntry::default()
|
||||
},
|
||||
MenuEntry {
|
||||
MenuBarEntry {
|
||||
label: "Lower".into(),
|
||||
shortcut: action_keys!(DocumentMessageDiscriminant::SelectedLayersLower),
|
||||
action: MenuEntry::create_action(|_| DocumentMessage::SelectedLayersLower.into()),
|
||||
..MenuEntry::default()
|
||||
action: MenuBarEntry::create_action(|_| DocumentMessage::SelectedLayersLower.into()),
|
||||
..MenuBarEntry::default()
|
||||
},
|
||||
MenuEntry {
|
||||
MenuBarEntry {
|
||||
label: "Lower to Back".into(),
|
||||
shortcut: action_keys!(DocumentMessageDiscriminant::SelectedLayersLowerToBack),
|
||||
action: MenuEntry::create_action(|_| DocumentMessage::SelectedLayersLowerToBack.into()),
|
||||
..MenuEntry::default()
|
||||
action: MenuBarEntry::create_action(|_| DocumentMessage::SelectedLayersLowerToBack.into()),
|
||||
..MenuBarEntry::default()
|
||||
},
|
||||
]]),
|
||||
..MenuEntry::default()
|
||||
..MenuBarEntry::default()
|
||||
}],
|
||||
]),
|
||||
},
|
||||
MenuColumn {
|
||||
label: "Document".into(),
|
||||
children: MenuEntryGroups(vec![vec![MenuEntry {
|
||||
),
|
||||
MenuBarEntry::new_root(
|
||||
"Document".into(),
|
||||
MenuBarEntryChildren(vec![vec![MenuBarEntry {
|
||||
label: "Clear Artboards".into(),
|
||||
action: MenuEntry::create_action(|_| ArtboardMessage::ClearArtboards.into()),
|
||||
..MenuEntry::default()
|
||||
action: MenuBarEntry::create_action(|_| ArtboardMessage::ClearArtboards.into()),
|
||||
..MenuBarEntry::default()
|
||||
}]]),
|
||||
},
|
||||
MenuColumn {
|
||||
label: "View".into(),
|
||||
children: MenuEntryGroups(vec![
|
||||
),
|
||||
MenuBarEntry::new_root(
|
||||
"View".into(),
|
||||
MenuBarEntryChildren(vec![
|
||||
vec![
|
||||
MenuEntry {
|
||||
MenuBarEntry {
|
||||
label: "Zoom to Fit".into(),
|
||||
shortcut: action_keys!(DocumentMessageDiscriminant::ZoomCanvasToFitAll),
|
||||
action: MenuEntry::create_action(|_| DocumentMessage::ZoomCanvasToFitAll.into()),
|
||||
..MenuEntry::default()
|
||||
action: MenuBarEntry::create_action(|_| DocumentMessage::ZoomCanvasToFitAll.into()),
|
||||
..MenuBarEntry::default()
|
||||
},
|
||||
MenuEntry {
|
||||
MenuBarEntry {
|
||||
label: "Zoom to 100%".into(),
|
||||
shortcut: action_keys!(DocumentMessageDiscriminant::ZoomCanvasTo100Percent),
|
||||
action: MenuEntry::create_action(|_| DocumentMessage::ZoomCanvasTo100Percent.into()),
|
||||
..MenuEntry::default()
|
||||
action: MenuBarEntry::create_action(|_| DocumentMessage::ZoomCanvasTo100Percent.into()),
|
||||
..MenuBarEntry::default()
|
||||
},
|
||||
MenuEntry {
|
||||
MenuBarEntry {
|
||||
label: "Zoom to 200%".into(),
|
||||
shortcut: action_keys!(DocumentMessageDiscriminant::ZoomCanvasTo200Percent),
|
||||
action: MenuEntry::create_action(|_| DocumentMessage::ZoomCanvasTo200Percent.into()),
|
||||
..MenuEntry::default()
|
||||
action: MenuBarEntry::create_action(|_| DocumentMessage::ZoomCanvasTo200Percent.into()),
|
||||
..MenuBarEntry::default()
|
||||
},
|
||||
],
|
||||
vec![MenuEntry {
|
||||
vec![MenuBarEntry {
|
||||
label: "Node Graph (In Development)".into(),
|
||||
action: MenuEntry::create_action(|_| WorkspaceMessage::NodeGraphToggleVisibility.into()),
|
||||
..MenuEntry::default()
|
||||
action: MenuBarEntry::create_action(|_| WorkspaceMessage::NodeGraphToggleVisibility.into()),
|
||||
..MenuBarEntry::default()
|
||||
}],
|
||||
]),
|
||||
},
|
||||
MenuColumn {
|
||||
label: "Help".into(),
|
||||
children: MenuEntryGroups(vec![
|
||||
vec![MenuEntry {
|
||||
),
|
||||
MenuBarEntry::new_root(
|
||||
"Help".into(),
|
||||
MenuBarEntryChildren(vec![
|
||||
vec![MenuBarEntry {
|
||||
label: "About Graphite".into(),
|
||||
icon: Some("GraphiteLogo".into()),
|
||||
action: MenuEntry::create_action(|_| DialogMessage::RequestAboutGraphiteDialog.into()),
|
||||
..MenuEntry::default()
|
||||
action: MenuBarEntry::create_action(|_| DialogMessage::RequestAboutGraphiteDialog.into()),
|
||||
..MenuBarEntry::default()
|
||||
}],
|
||||
vec![
|
||||
MenuEntry {
|
||||
MenuBarEntry {
|
||||
label: "Report a Bug".into(),
|
||||
action: MenuEntry::create_action(|_| {
|
||||
action: MenuBarEntry::create_action(|_| {
|
||||
FrontendMessage::TriggerVisitLink {
|
||||
url: "https://github.com/GraphiteEditor/Graphite/issues/new".into(),
|
||||
}
|
||||
.into()
|
||||
}),
|
||||
..MenuEntry::default()
|
||||
..MenuBarEntry::default()
|
||||
},
|
||||
MenuEntry {
|
||||
MenuBarEntry {
|
||||
label: "Visit on GitHub".into(),
|
||||
action: MenuEntry::create_action(|_| {
|
||||
action: MenuBarEntry::create_action(|_| {
|
||||
FrontendMessage::TriggerVisitLink {
|
||||
url: "https://github.com/GraphiteEditor/Graphite".into(),
|
||||
}
|
||||
.into()
|
||||
}),
|
||||
..MenuEntry::default()
|
||||
..MenuBarEntry::default()
|
||||
},
|
||||
],
|
||||
vec![
|
||||
MenuEntry {
|
||||
MenuBarEntry {
|
||||
label: "Debug: Print Messages".into(),
|
||||
action: MenuEntry::no_action(),
|
||||
children: MenuEntryGroups(vec![vec![
|
||||
MenuEntry {
|
||||
action: MenuBarEntry::no_action(),
|
||||
children: MenuBarEntryChildren(vec![vec![
|
||||
MenuBarEntry {
|
||||
label: "Off".into(),
|
||||
// icon: Some("Checkmark".into()), // TODO: Find a way to set this icon on the active mode
|
||||
shortcut: action_keys!(DebugMessageDiscriminant::MessageOff),
|
||||
action: MenuEntry::create_action(|_| DebugMessage::MessageOff.into()),
|
||||
..MenuEntry::default()
|
||||
action: MenuBarEntry::create_action(|_| DebugMessage::MessageOff.into()),
|
||||
..MenuBarEntry::default()
|
||||
},
|
||||
MenuEntry {
|
||||
MenuBarEntry {
|
||||
label: "Only Names".into(),
|
||||
shortcut: action_keys!(DebugMessageDiscriminant::MessageNames),
|
||||
action: MenuEntry::create_action(|_| DebugMessage::MessageNames.into()),
|
||||
..MenuEntry::default()
|
||||
action: MenuBarEntry::create_action(|_| DebugMessage::MessageNames.into()),
|
||||
..MenuBarEntry::default()
|
||||
},
|
||||
MenuEntry {
|
||||
MenuBarEntry {
|
||||
label: "Full Contents".into(),
|
||||
shortcut: action_keys!(DebugMessageDiscriminant::MessageContents),
|
||||
action: MenuEntry::create_action(|_| DebugMessage::MessageContents.into()),
|
||||
..MenuEntry::default()
|
||||
action: MenuBarEntry::create_action(|_| DebugMessage::MessageContents.into()),
|
||||
..MenuBarEntry::default()
|
||||
},
|
||||
]]),
|
||||
..MenuEntry::default()
|
||||
..MenuBarEntry::default()
|
||||
},
|
||||
MenuEntry {
|
||||
MenuBarEntry {
|
||||
label: "Debug: Print Trace Logs".into(),
|
||||
icon: Some(if let log::LevelFilter::Trace = log::max_level() { "CheckboxChecked" } else { "CheckboxUnchecked" }.into()),
|
||||
shortcut: action_keys!(DebugMessageDiscriminant::ToggleTraceLogs),
|
||||
action: MenuEntry::create_action(|_| DebugMessage::ToggleTraceLogs.into()),
|
||||
..MenuEntry::default()
|
||||
action: MenuBarEntry::create_action(|_| DebugMessage::ToggleTraceLogs.into()),
|
||||
..MenuBarEntry::default()
|
||||
},
|
||||
MenuEntry {
|
||||
MenuBarEntry {
|
||||
label: "Debug: Print Document".into(),
|
||||
shortcut: action_keys!(DocumentMessageDiscriminant::DebugPrintDocument),
|
||||
action: MenuEntry::create_action(|_| DocumentMessage::DebugPrintDocument.into()),
|
||||
..MenuEntry::default()
|
||||
action: MenuBarEntry::create_action(|_| DocumentMessage::DebugPrintDocument.into()),
|
||||
..MenuBarEntry::default()
|
||||
},
|
||||
MenuEntry {
|
||||
MenuBarEntry {
|
||||
label: "Debug: Panic (DANGER)".into(),
|
||||
action: MenuEntry::create_action(|_| panic!()),
|
||||
..MenuEntry::default()
|
||||
action: MenuBarEntry::create_action(|_| panic!()),
|
||||
..MenuBarEntry::default()
|
||||
},
|
||||
],
|
||||
]),
|
||||
},
|
||||
),
|
||||
]))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user