Skip to content
Merged
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
2 changes: 2 additions & 0 deletions editor/src/messages/input_mapper/input_mappings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,8 @@ pub fn input_mappings() -> Mapping {
entry!(KeyDown(MouseMiddle); action_dispatch=NavigationMessage::BeginCanvasPan),
entry!(KeyDown(MouseLeft); modifiers=[Space], action_dispatch=NavigationMessage::BeginCanvasPan),
entry!(KeyDown(NumpadAdd); modifiers=[Accel], action_dispatch=NavigationMessage::CanvasZoomIncrease { center_on_mouse: false }),
// `FakeKeyPlus` is a nonfunctional key mapping that must be accompanied by its real `Equal` key counterpart. This is used only to set the canonical key label so it shows "+" instead of "=" in the UI.
entry!(KeyDown(FakeKeyPlus); modifiers=[Accel], canonical, action_dispatch=NavigationMessage::CanvasZoomIncrease { center_on_mouse: false }),
entry!(KeyDown(Equal); modifiers=[Accel], action_dispatch=NavigationMessage::CanvasZoomIncrease { center_on_mouse: false }),
entry!(KeyDown(Minus); modifiers=[Accel], action_dispatch=NavigationMessage::CanvasZoomDecrease { center_on_mouse: false }),
entry!(KeyDown(KeyF); modifiers=[Alt], action_dispatch=NavigationMessage::CanvasFlip),
Expand Down
23 changes: 17 additions & 6 deletions editor/src/messages/input_mapper/utility_types/input_keyboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ pub enum Key {
Digit7,
Digit8,
Digit9,
//

KeyA,
KeyB,
KeyC,
Expand All @@ -88,7 +88,7 @@ pub enum Key {
KeyX,
KeyY,
KeyZ,
//

Backquote,
Backslash,
BracketLeft,
Expand Down Expand Up @@ -197,6 +197,8 @@ pub enum Key {
Unidentified,

// Other keys that aren't part of the W3C spec
//
/// "Cmd" on Mac (not present on other platforms)
Command,
/// "Ctrl" on Windows/Linux, "Cmd" on Mac
Accel,
Expand All @@ -206,8 +208,14 @@ pub enum Key {
MouseBack,
MouseForward,

// This has to be the last element in the enum
NumKeys,
// Fake keys for displaying special labels in the UI
//
/// Not a physical key that can be pressed. May be used so that an actual shortcut bound to `Equal` can separately map this fake "key" as an additional binding to display the "+" shortcut label in the UI.
FakeKeyPlus,
/// Not a physical key that can be pressed. May be used so that an actual shortcut bound to all ten number keys (0, ..., 9) can separately map this fake "key" as an additional binding to display the "0–9" shortcut label in the UI.
FakeKeyNumbers,

_KeysVariantCount, // This has to be the last element in the enum
}

impl fmt::Display for Key {
Expand Down Expand Up @@ -293,7 +301,10 @@ impl fmt::Display for Key {
Self::MouseMiddle => "MMB",
Self::MouseBack => "Mouse Back",
Self::MouseForward => "Mouse Fwd",
Self::NumKeys => "0–9",

// Fake keys for displaying special labels in the UI
Self::FakeKeyPlus => "+",
Self::FakeKeyNumbers => "0–9",

_ => key_name.as_str(),
};
Expand All @@ -314,7 +325,7 @@ pub struct LayoutKey {
label: String,
}

pub const NUMBER_OF_KEYS: usize = Key::NumKeys as usize;
pub const NUMBER_OF_KEYS: usize = Key::_KeysVariantCount as usize - 1;

/// Only `Key`s that exist on a physical keyboard should be used.
#[derive(Debug, Clone, Default, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ impl TransformOperation {
}
let mut typing_hints = vec![HintInfo::keys([Key::Minus], "Negate Direction")];
if self.can_begin_typing() {
typing_hints.push(HintInfo::keys([Key::NumKeys], "Enter Number"));
typing_hints.push(HintInfo::keys([Key::FakeKeyNumbers], "Enter Number"));
if self.is_typing() {
typing_hints.push(HintInfo::keys([Key::Backspace], "Delete Digit"));
}
Expand Down
36 changes: 18 additions & 18 deletions node-graph/gcore/src/vector/vector_nodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1141,11 +1141,11 @@ async fn sample_polyline(
.collect()
}

/// Cuts a path at a given progress from 0 to 1 along the path, creating two new subpaths from the original one (if the path is initially open) or one open subpath (if the path is initially closed).
/// Cuts a path at a given progression from 0 to 1 along the path, creating two new subpaths from the original one (if the path is initially open) or one open subpath (if the path is initially closed).
///
/// If multiple subpaths make up the path, the whole number part of the progress value selects the subpath and the decimal part determines the position along it.
/// If multiple subpaths make up the path, the whole number part of the progression value selects the subpath and the decimal part determines the position along it.
#[node_macro::node(category("Vector: Modifier"), path(graphene_core::vector))]
async fn cut_path(_: impl Ctx, mut content: Table<Vector>, progress: Fraction, parameterized_distance: bool, reverse: bool) -> Table<Vector> {
async fn cut_path(_: impl Ctx, mut content: Table<Vector>, progression: Fraction, parameterized_distance: bool, reverse: bool) -> Table<Vector> {
let euclidian = !parameterized_distance;

let bezpaths = content
Expand All @@ -1155,7 +1155,7 @@ async fn cut_path(_: impl Ctx, mut content: Table<Vector>, progress: Fraction, p
.collect::<Vec<_>>();

let bezpath_count = bezpaths.len() as f64;
let t_value = progress.clamp(0., bezpath_count);
let t_value = progression.clamp(0., bezpath_count);
let t_value = if reverse { bezpath_count - t_value } else { t_value };
let index = if t_value >= bezpath_count { (bezpath_count - 1.) as usize } else { t_value as usize };

Expand Down Expand Up @@ -1241,16 +1241,16 @@ async fn cut_segments(_: impl Ctx, mut content: Table<Vector>) -> Table<Vector>
content
}

/// Determines the position of a point on the path, given by its progress from 0 to 1 along the path.
/// Determines the position of a point on the path, given by its progression from 0 to 1 along the path.
///
/// If multiple subpaths make up the path, the whole number part of the progress value selects the subpath and the decimal part determines the position along it.
/// If multiple subpaths make up the path, the whole number part of the progression value selects the subpath and the decimal part determines the position along it.
#[node_macro::node(name("Position on Path"), category("Vector: Measure"), path(graphene_core::vector))]
async fn position_on_path(
_: impl Ctx,
/// The path to traverse.
content: Table<Vector>,
/// The factor from the start to the end of the path, 0–1 for one subpath, 1–2 for a second subpath, and so on.
progress: Fraction,
progression: Fraction,
/// Swap the direction of the path.
reverse: bool,
/// Traverse the path using each segment's Bézier curve parameterization instead of the Euclidean distance. Faster to compute but doesn't respect actual distances.
Expand All @@ -1266,12 +1266,12 @@ async fn position_on_path(
})
.collect::<Vec<_>>();
let bezpath_count = bezpaths.len() as f64;
let progress = progress.clamp(0., bezpath_count);
let progress = if reverse { bezpath_count - progress } else { progress };
let index = if progress >= bezpath_count { (bezpath_count - 1.) as usize } else { progress as usize };
let progression = progression.clamp(0., bezpath_count);
let progression = if reverse { bezpath_count - progression } else { progression };
let index = if progression >= bezpath_count { (bezpath_count - 1.) as usize } else { progression as usize };

bezpaths.get_mut(index).map_or(DVec2::ZERO, |(bezpath, transform)| {
let t = if progress == bezpath_count { 1. } else { progress.fract() };
let t = if progression == bezpath_count { 1. } else { progression.fract() };
let t = if euclidian { TValue::Euclidean(t) } else { TValue::Parametric(t) };

bezpath.apply_affine(Affine::new(transform.to_cols_array()));
Expand All @@ -1280,16 +1280,16 @@ async fn position_on_path(
})
}

/// Determines the angle of the tangent at a point on the path, given by its progress from 0 to 1 along the path.
/// Determines the angle of the tangent at a point on the path, given by its progression from 0 to 1 along the path.
///
/// If multiple subpaths make up the path, the whole number part of the progress value selects the subpath and the decimal part determines the position along it.
/// If multiple subpaths make up the path, the whole number part of the progression value selects the subpath and the decimal part determines the position along it.
#[node_macro::node(name("Tangent on Path"), category("Vector: Measure"), path(graphene_core::vector))]
async fn tangent_on_path(
_: impl Ctx,
/// The path to traverse.
content: Table<Vector>,
/// The factor from the start to the end of the path, 0–1 for one subpath, 1–2 for a second subpath, and so on.
progress: Fraction,
progression: Fraction,
/// Swap the direction of the path.
reverse: bool,
/// Traverse the path using each segment's Bézier curve parameterization instead of the Euclidean distance. Faster to compute but doesn't respect actual distances.
Expand All @@ -1307,12 +1307,12 @@ async fn tangent_on_path(
})
.collect::<Vec<_>>();
let bezpath_count = bezpaths.len() as f64;
let progress = progress.clamp(0., bezpath_count);
let progress = if reverse { bezpath_count - progress } else { progress };
let index = if progress >= bezpath_count { (bezpath_count - 1.) as usize } else { progress as usize };
let progression = progression.clamp(0., bezpath_count);
let progression = if reverse { bezpath_count - progression } else { progression };
let index = if progression >= bezpath_count { (bezpath_count - 1.) as usize } else { progression as usize };

let angle = bezpaths.get_mut(index).map_or(0., |(bezpath, transform)| {
let t = if progress == bezpath_count { 1. } else { progress.fract() };
let t = if progression == bezpath_count { 1. } else { progression.fract() };
let t_value = |t: f64| if euclidian { TValue::Euclidean(t) } else { TValue::Parametric(t) };

bezpath.apply_affine(Affine::new(transform.to_cols_array()));
Expand Down
Loading