pub use crate::core::selection_info_ops::{
align_oncurve_nodes_to_background, collect_adjacent_offcurve_positions,
compute_radially_scaled_handle_pos, enforce_smooth_collinearity_around_oncurve,
find_first_offcurve_node_id, find_first_oncurve_with_adjacent_offcurve,
project_point_to_background_contours, resolve_tethered_oncurve_for_offcurve,
translate_oncurve_with_adjacent_handles, update_offcurve_with_smooth_constraint,
};
use crate::core::{FontPoint, NodeId, NodeType, TransformGridAnchor};
use crate::snapping::SelectedGuideRef;
use serde::{Deserialize, Serialize};
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
pub enum GuideAlignment {
#[default]
Lsb,
Center,
Rsb,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize)]
pub struct AnchorId(pub u64);
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct CanvasAnchor {
pub id: AnchorId,
pub name: String,
pub position: FontPoint,
pub selected: bool,
}
impl CanvasAnchor {
#[must_use]
pub fn new(id: AnchorId, name: impl Into<String>, position: FontPoint) -> Self {
Self {
id,
name: name.into(),
position,
selected: false,
}
}
}
#[derive(Clone, Debug, PartialEq)]
pub struct GlyphBaseInfo {
pub glyph_name: String,
pub bbox_x: f64,
pub bbox_y: f64,
pub bbox_w: f64,
pub bbox_h: f64,
pub lsb: f64,
pub rsb: f64,
pub advance_width: f64,
pub active_slot_kerning_left: Option<i32>,
pub kern_with_prev: Option<i32>,
pub kern_with_next: Option<i32>,
pub transform_anchor: TransformGridAnchor,
pub proportional_scale: bool,
pub contour_count: usize,
pub total_node_count: usize,
}
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct SingleOnCurveInfo {
pub node_id: NodeId,
pub x: f64,
pub y: f64,
pub node_type: NodeType,
}
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct SingleOffCurveInfo {
pub node_id: NodeId,
pub anchor_node_id: NodeId,
pub tethered_oncurve_id: NodeId,
pub x: f64,
pub y: f64,
pub delta_x: f64,
pub delta_y: f64,
pub length: f64,
}
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct MultiNodeInfo {
pub origin_anchor: TransformGridAnchor,
pub origin_x: f64,
pub origin_y: f64,
pub width: f64,
pub height: f64,
pub proportional_scale: bool,
pub selected_node_count: usize,
pub total_layer_node_count: usize,
}
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct GuideInfo {
pub guide_ref: SelectedGuideRef,
pub x: f64,
pub y: f64,
pub angle_deg: f64,
pub alignment: GuideAlignment,
pub lock_angle: bool,
pub show_measurement: bool,
}
#[derive(Clone, Debug, PartialEq)]
pub enum SelectionInfo {
GlyphBase(GlyphBaseInfo),
SingleOnCurve(SingleOnCurveInfo),
SingleOffCurve(SingleOffCurveInfo),
MultiNode(MultiNodeInfo),
Guide(GuideInfo),
}
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub enum SelectionInfoAction {
SetLsb(f64),
SetRsb(f64),
SetAdvanceWidth(f64),
CenterInWidth,
SetOnCurvePosition(FontPoint),
ToggleOnCurveSmooth,
SetOffCurvePosition(FontPoint),
SetOffCurveDelta {
dx: f64,
dy: f64,
},
SetHandleLength(f64),
SetMultiAnchor(TransformGridAnchor),
SetMultiProportional(bool),
SetMultiOrigin(FontPoint),
SetMultiSize {
width: Option<f64>,
height: Option<f64>,
},
SetGuideOrigin(FontPoint),
SetGuideAngle(f64),
SetGuideAlignment(GuideAlignment),
SetGuideLockAngle(bool),
SetGuideMeasurement(bool),
SetAnchorPosition(FontPoint),
SetAnchorName(String),
ResetDefaultAnchors,
SetComponentTransform(crate::core::anchors_components::Affine2D),
SetComponentLocked(bool),
SetComponentAutoAlignment(bool),
DecomposeComponents,
}