Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions desktop/src/cef/input/keymap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ pub(crate) trait ToCharRepresentation {
impl ToCharRepresentation for Key {
fn to_char_representation(&self) -> char {
match self {
Key::Named(named) => match named {
Self::Named(named) => match named {
NamedKey::Tab => '\t',
NamedKey::Enter => '\r',
NamedKey::Backspace => '\x08',
NamedKey::Escape => '\x1b',
_ => '\0',
},
Key::Character(char) => char.chars().next().unwrap_or_default(),
Self::Character(char) => char.chars().next().unwrap_or_default(),
_ => '\0',
}
}
Expand Down
16 changes: 8 additions & 8 deletions desktop/src/window/mac/menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,30 +117,30 @@ enum MenuContainer<'a> {
impl<'a> MenuContainer<'a> {
fn items(&self) -> Vec<MenuItemKind> {
match self {
MenuContainer::Menu(menu) => menu.items(),
MenuContainer::Submenu(submenu) => submenu.items(),
Self::Menu(menu) => menu.items(),
Self::Submenu(submenu) => submenu.items(),
}
}
fn remove(&self, item: &dyn IsMenuItem) -> Result<()> {
match self {
MenuContainer::Menu(menu) => menu.remove(item),
MenuContainer::Submenu(submenu) => submenu.remove(item),
Self::Menu(menu) => menu.remove(item),
Self::Submenu(submenu) => submenu.remove(item),
}
}
fn append_items(&self, items: &[&dyn IsMenuItem]) -> Result<()> {
match self {
MenuContainer::Menu(menu) => menu.append_items(items),
MenuContainer::Submenu(submenu) => submenu.append_items(items),
Self::Menu(menu) => menu.append_items(items),
Self::Submenu(submenu) => submenu.append_items(items),
}
}
}
impl<'a> From<&'a MudaMenu> for MenuContainer<'a> {
fn from(menu: &'a MudaMenu) -> Self {
MenuContainer::Menu(menu)
Self::Menu(menu)
}
}
impl<'a> From<&'a Submenu> for MenuContainer<'a> {
fn from(submenu: &'a Submenu) -> Self {
MenuContainer::Submenu(submenu)
Self::Submenu(submenu)
}
}
6 changes: 3 additions & 3 deletions editor/src/messages/frontend/utility_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ pub enum FileType {
impl FileType {
pub fn to_mime(self) -> &'static str {
match self {
FileType::Png => "image/png",
FileType::Jpg => "image/jpeg",
FileType::Svg => "image/svg+xml",
Self::Png => "image/png",
Self::Jpg => "image/jpeg",
Self::Svg => "image/svg+xml",
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions editor/src/messages/layout/utility_types/layout_widget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,17 +351,17 @@ impl Default for LayoutGroup {
}
}
impl From<Vec<WidgetInstance>> for LayoutGroup {
fn from(widgets: Vec<WidgetInstance>) -> LayoutGroup {
LayoutGroup::Row { widgets }
fn from(widgets: Vec<WidgetInstance>) -> Self {
Self::Row { widgets }
}
}

impl LayoutGroup {
/// Applies a tooltip description to all widgets without a tooltip in this row or column.
pub fn with_tooltip_description(self, description: impl Into<String>) -> Self {
let (is_col, mut widgets) = match self {
LayoutGroup::Column { widgets } => (true, widgets),
LayoutGroup::Row { widgets } => (false, widgets),
Self::Column { widgets } => (true, widgets),
Self::Row { widgets } => (false, widgets),
_ => unimplemented!(),
};
let description = description.into();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub struct IconButton {
// Callbacks
#[serde(skip)]
#[derivative(Debug = "ignore", PartialEq = "ignore")]
pub on_update: WidgetCallback<IconButton>,
pub on_update: WidgetCallback<Self>,
#[serde(skip)]
#[derivative(Debug = "ignore", PartialEq = "ignore")]
pub on_commit: WidgetCallback<()>,
Expand Down Expand Up @@ -96,7 +96,7 @@ pub struct ParameterExposeButton {
// Callbacks
#[serde(skip)]
#[derivative(Debug = "ignore", PartialEq = "ignore")]
pub on_update: WidgetCallback<ParameterExposeButton>,
pub on_update: WidgetCallback<Self>,
#[serde(skip)]
#[derivative(Debug = "ignore", PartialEq = "ignore")]
pub on_commit: WidgetCallback<()>,
Expand Down Expand Up @@ -140,7 +140,7 @@ pub struct TextButton {
// Callbacks
#[serde(skip)]
#[derivative(Debug = "ignore", PartialEq = "ignore")]
pub on_update: WidgetCallback<TextButton>,
pub on_update: WidgetCallback<Self>,
#[serde(skip)]
#[derivative(Debug = "ignore", PartialEq = "ignore")]
pub on_commit: WidgetCallback<()>,
Expand Down Expand Up @@ -201,7 +201,7 @@ pub struct ColorInput {
// Callbacks
#[serde(skip)]
#[derivative(Debug = "ignore", PartialEq = "ignore")]
pub on_update: WidgetCallback<ColorInput>,
pub on_update: WidgetCallback<Self>,
#[serde(skip)]
#[derivative(Debug = "ignore", PartialEq = "ignore")]
pub on_commit: WidgetCallback<()>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub struct CheckboxInput {
// Callbacks
#[serde(skip)]
#[derivative(Debug = "ignore", PartialEq = "ignore")]
pub on_update: WidgetCallback<CheckboxInput>,
pub on_update: WidgetCallback<Self>,
#[serde(skip)]
#[derivative(Debug = "ignore", PartialEq = "ignore")]
pub on_commit: WidgetCallback<()>,
Expand Down Expand Up @@ -201,13 +201,13 @@ pub struct NumberInput {
// Callbacks
#[serde(skip)]
#[derivative(Debug = "ignore", PartialEq = "ignore")]
pub increment_callback_increase: WidgetCallback<NumberInput>,
pub increment_callback_increase: WidgetCallback<Self>,
#[serde(skip)]
#[derivative(Debug = "ignore", PartialEq = "ignore")]
pub increment_callback_decrease: WidgetCallback<NumberInput>,
pub increment_callback_decrease: WidgetCallback<Self>,
#[serde(skip)]
#[derivative(Debug = "ignore", PartialEq = "ignore")]
pub on_update: WidgetCallback<NumberInput>,
pub on_update: WidgetCallback<Self>,
#[serde(skip)]
#[derivative(Debug = "ignore", PartialEq = "ignore")]
pub on_commit: WidgetCallback<()>,
Expand Down Expand Up @@ -359,7 +359,7 @@ pub struct TextAreaInput {
// Callbacks
#[serde(skip)]
#[derivative(Debug = "ignore", PartialEq = "ignore")]
pub on_update: WidgetCallback<TextAreaInput>,
pub on_update: WidgetCallback<Self>,
#[serde(skip)]
#[derivative(Debug = "ignore", PartialEq = "ignore")]
pub on_commit: WidgetCallback<()>,
Expand Down Expand Up @@ -396,7 +396,7 @@ pub struct TextInput {
// Callbacks
#[serde(skip)]
#[derivative(Debug = "ignore", PartialEq = "ignore")]
pub on_update: WidgetCallback<TextInput>,
pub on_update: WidgetCallback<Self>,
#[serde(skip)]
#[derivative(Debug = "ignore", PartialEq = "ignore")]
pub on_commit: WidgetCallback<()>,
Expand All @@ -420,7 +420,7 @@ pub struct CurveInput {
// Callbacks
#[serde(skip)]
#[derivative(Debug = "ignore", PartialEq = "ignore")]
pub on_update: WidgetCallback<CurveInput>,
pub on_update: WidgetCallback<Self>,
#[serde(skip)]
#[derivative(Debug = "ignore", PartialEq = "ignore")]
pub on_commit: WidgetCallback<()>,
Expand All @@ -445,7 +445,7 @@ pub struct ReferencePointInput {
// Callbacks
#[serde(skip)]
#[derivative(Debug = "ignore", PartialEq = "ignore")]
pub on_update: WidgetCallback<ReferencePointInput>,
pub on_update: WidgetCallback<Self>,
#[serde(skip)]
#[derivative(Debug = "ignore", PartialEq = "ignore")]
pub on_commit: WidgetCallback<()>,
Expand Down
2 changes: 1 addition & 1 deletion editor/src/messages/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub enum Message {

// Messages
Batched {
messages: Box<[Message]>,
messages: Box<[Self]>,
},
NoOp,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ impl MessageHandler<DocumentMessage, DocumentMessageContext<'_>> for DocumentMes
.deepest_common_ancestor(&selected_nodes, &self.selection_network_path, true)
.unwrap_or(LayerNodeIdentifier::ROOT_PARENT);

let insert_index = DocumentMessageHandler::get_calculated_insert_index(self.metadata(), &self.network_interface.selected_nodes(), parent);
let insert_index = Self::get_calculated_insert_index(self.metadata(), &self.network_interface.selected_nodes(), parent);
responses.add(DocumentMessage::AddTransaction);
responses.add(GraphOperationMessage::NewCustomLayer {
id,
Expand Down Expand Up @@ -430,7 +430,7 @@ impl MessageHandler<DocumentMessage, DocumentMessageContext<'_>> for DocumentMes

layers.sort_by_key(|layer| {
let Some(parent) = layer.parent(self.metadata()) else { return usize::MAX };
DocumentMessageHandler::get_calculated_insert_index(self.metadata(), &SelectedNodes(vec![layer.to_node()]), parent)
Self::get_calculated_insert_index(self.metadata(), &SelectedNodes(vec![layer.to_node()]), parent)
});

for layer in layers.into_iter().rev() {
Expand All @@ -450,7 +450,7 @@ impl MessageHandler<DocumentMessage, DocumentMessageContext<'_>> for DocumentMes

let nodes = self.network_interface.copy_nodes(&copy_ids, &[]).collect::<Vec<(NodeId, NodeTemplate)>>();

let insert_index = DocumentMessageHandler::get_calculated_insert_index(self.metadata(), &SelectedNodes(vec![layer.to_node()]), parent);
let insert_index = Self::get_calculated_insert_index(self.metadata(), &SelectedNodes(vec![layer.to_node()]), parent);

let new_ids: HashMap<_, _> = nodes.iter().map(|(id, _)| (*id, NodeId::new())).collect();

Expand Down Expand Up @@ -637,9 +637,9 @@ impl MessageHandler<DocumentMessage, DocumentMessageContext<'_>> for DocumentMes
let Some(selected_nodes) = &self.network_interface.selected_nodes_in_nested_network(&self.selection_network_path) else {
return;
};
let insert_index = DocumentMessageHandler::get_calculated_insert_index(self.metadata(), selected_nodes, parent);
let insert_index = Self::get_calculated_insert_index(self.metadata(), selected_nodes, parent);

DocumentMessageHandler::group_layers(responses, insert_index, parent, group_folder_type, &mut self.network_interface);
Self::group_layers(responses, insert_index, parent, group_folder_type, &mut self.network_interface);
}
// Artboard workflow
else {
Expand All @@ -657,11 +657,11 @@ impl MessageHandler<DocumentMessage, DocumentMessageContext<'_>> for DocumentMes
let Some(parent) = self.network_interface.deepest_common_ancestor(&child_selected_nodes, &self.selection_network_path, false) else {
continue;
};
let insert_index = DocumentMessageHandler::get_calculated_insert_index(self.metadata(), &child_selected_nodes, parent);
let insert_index = Self::get_calculated_insert_index(self.metadata(), &child_selected_nodes, parent);

responses.add(NodeGraphMessage::SelectedNodesSet { nodes: child_selected_nodes.0 });

new_folders.push(DocumentMessageHandler::group_layers(responses, insert_index, parent, group_folder_type, &mut self.network_interface));
new_folders.push(Self::group_layers(responses, insert_index, parent, group_folder_type, &mut self.network_interface));
}

responses.add(NodeGraphMessage::SelectedNodesSet { nodes: new_folders });
Expand Down Expand Up @@ -1830,7 +1830,7 @@ impl DocumentMessageHandler {
}

pub fn deserialize_document(serialized_content: &str) -> Result<Self, EditorError> {
let document_message_handler = serde_json::from_str::<DocumentMessageHandler>(serialized_content)
let document_message_handler = serde_json::from_str::<Self>(serialized_content)
.or_else(|e| {
log::warn!("Failed to directly load document with the following error: {e}. Trying old DocumentMessageHandler.");
// TODO: Eventually remove this document upgrade code
Expand Down Expand Up @@ -1869,7 +1869,7 @@ impl DocumentMessageHandler {
pub snapping_state: SnappingState,
}

serde_json::from_str::<OldDocumentMessageHandler>(serialized_content).map(|old_message_handler| DocumentMessageHandler {
serde_json::from_str::<OldDocumentMessageHandler>(serialized_content).map(|old_message_handler| Self {
network_interface: NodeNetworkInterface::from_old_network(old_message_handler.network),
collapsed: old_message_handler.collapsed,
commit_hash: old_message_handler.commit_hash,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2144,7 +2144,7 @@ pub struct ParameterWidgetsInfo<'a> {
}

impl<'a> ParameterWidgetsInfo<'a> {
pub fn new(node_id: NodeId, index: usize, blank_assist: bool, context: &'a mut NodePropertiesContext) -> ParameterWidgetsInfo<'a> {
pub fn new(node_id: NodeId, index: usize, blank_assist: bool, context: &'a mut NodePropertiesContext) -> Self {
let (name, description) = context.network_interface.displayed_input_name_and_description(&node_id, index, context.selection_network_path);
let input_type = context
.network_interface
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,12 +217,12 @@ pub struct FrontendXY {

impl From<DVec2> for FrontendXY {
fn from(v: DVec2) -> Self {
FrontendXY { x: v.x as i32, y: v.y as i32 }
Self { x: v.x as i32, y: v.y as i32 }
}
}

impl From<IVec2> for FrontendXY {
fn from(v: IVec2) -> Self {
FrontendXY { x: v.x, y: v.y }
Self { x: v.x, y: v.y }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ pub struct LayerNodeIdentifier(NonZeroU64);

impl core::fmt::Debug for LayerNodeIdentifier {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let node_id = if *self != LayerNodeIdentifier::ROOT_PARENT { self.to_node() } else { NodeId(0) };
let node_id = if *self != Self::ROOT_PARENT { self.to_node() } else { NodeId(0) };

f.debug_tuple("LayerNodeIdentifier").field(&node_id).finish()
}
Expand All @@ -247,7 +247,7 @@ impl Default for LayerNodeIdentifier {

impl LayerNodeIdentifier {
/// A conceptual layer used to represent the parent of layers that feed into the export
pub const ROOT_PARENT: Self = LayerNodeIdentifier::new_unchecked(NodeId(0));
pub const ROOT_PARENT: Self = Self::new_unchecked(NodeId(0));

/// Construct a [`LayerNodeIdentifier`] without checking if it is a layer node
pub const fn new_unchecked(node_id: NodeId) -> Self {
Expand All @@ -271,27 +271,27 @@ impl LayerNodeIdentifier {
}

/// Access the parent layer if possible
pub fn parent(self, metadata: &DocumentMetadata) -> Option<LayerNodeIdentifier> {
pub fn parent(self, metadata: &DocumentMetadata) -> Option<Self> {
metadata.get_relations(self).and_then(|relations| relations.parent)
}

/// Access the previous sibling of this layer (up the Layers panel)
pub fn previous_sibling(self, metadata: &DocumentMetadata) -> Option<LayerNodeIdentifier> {
pub fn previous_sibling(self, metadata: &DocumentMetadata) -> Option<Self> {
metadata.get_relations(self).and_then(|relations| relations.previous_sibling)
}

/// Access the next sibling of this layer (down the Layers panel)
pub fn next_sibling(self, metadata: &DocumentMetadata) -> Option<LayerNodeIdentifier> {
pub fn next_sibling(self, metadata: &DocumentMetadata) -> Option<Self> {
metadata.get_relations(self).and_then(|relations| relations.next_sibling)
}

/// Access the first child of this layer (top most in Layers panel)
pub fn first_child(self, metadata: &DocumentMetadata) -> Option<LayerNodeIdentifier> {
pub fn first_child(self, metadata: &DocumentMetadata) -> Option<Self> {
metadata.get_relations(self).and_then(|relations| relations.first_child)
}

/// Access the last child of this layer (bottom most in Layers panel)
pub fn last_child(self, metadata: &DocumentMetadata) -> Option<LayerNodeIdentifier> {
pub fn last_child(self, metadata: &DocumentMetadata) -> Option<Self> {
metadata.get_relations(self).and_then(|relations| relations.last_child)
}

Expand All @@ -301,12 +301,12 @@ impl LayerNodeIdentifier {
}

/// Is the layer a child of the given layer?
pub fn is_child_of(self, metadata: &DocumentMetadata, parent: &LayerNodeIdentifier) -> bool {
pub fn is_child_of(self, metadata: &DocumentMetadata, parent: &Self) -> bool {
parent.children(metadata).any(|child| child == self)
}

/// Is the layer an ancestor of the given layer?
pub fn is_ancestor_of(self, metadata: &DocumentMetadata, child: &LayerNodeIdentifier) -> bool {
pub fn is_ancestor_of(self, metadata: &DocumentMetadata, child: &Self) -> bool {
child.ancestors(metadata).any(|ancestor| ancestor == self)
}

Expand Down Expand Up @@ -361,7 +361,7 @@ impl LayerNodeIdentifier {
}

/// Add a child towards the top of the Layers panel
pub fn push_front_child(self, metadata: &mut DocumentMetadata, new: LayerNodeIdentifier) {
pub fn push_front_child(self, metadata: &mut DocumentMetadata, new: Self) {
assert!(!metadata.structure.contains_key(&new), "Cannot add already existing layer");
let parent = metadata.get_structure_mut(self);
let old_first_child = parent.first_child.replace(new);
Expand All @@ -374,7 +374,7 @@ impl LayerNodeIdentifier {
}

/// Add a child towards the bottom of the Layers panel
pub fn push_child(self, metadata: &mut DocumentMetadata, new: LayerNodeIdentifier) {
pub fn push_child(self, metadata: &mut DocumentMetadata, new: Self) {
assert!(!metadata.structure.contains_key(&new), "Cannot add already existing layer");
let parent = metadata.get_structure_mut(self);
let old_last_child = parent.last_child.replace(new);
Expand All @@ -387,7 +387,7 @@ impl LayerNodeIdentifier {
}

/// Add sibling above in the Layers panel
pub fn add_before(self, metadata: &mut DocumentMetadata, new: LayerNodeIdentifier) {
pub fn add_before(self, metadata: &mut DocumentMetadata, new: Self) {
assert!(!metadata.structure.contains_key(&new), "Cannot add already existing layer");
metadata.get_structure_mut(new).next_sibling = Some(self);
metadata.get_structure_mut(new).parent = self.parent(metadata);
Expand All @@ -405,7 +405,7 @@ impl LayerNodeIdentifier {
}

/// Add sibling below in the Layers panel
pub fn add_after(self, metadata: &mut DocumentMetadata, new: LayerNodeIdentifier) {
pub fn add_after(self, metadata: &mut DocumentMetadata, new: Self) {
assert!(!metadata.structure.contains_key(&new), "Cannot add already existing layer");
metadata.get_structure_mut(new).previous_sibling = Some(self);
metadata.get_structure_mut(new).parent = self.parent(metadata);
Expand Down
Loading