mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-17 00:34:25 +00:00
Contract stubs: craft-draw (part 4: transform, crop bar, slice, exports)
This commit is contained in:
@@ -114,18 +114,26 @@ pub struct BoxAllow {
|
||||
pub skew: bool,
|
||||
/// Distorting and perspective are allowed.
|
||||
pub distort: bool,
|
||||
/// Warping is allowed.
|
||||
pub warp: bool,
|
||||
}
|
||||
|
||||
impl BoxAllow {
|
||||
/// What the content allows: turning, skewing and distorting.
|
||||
pub const fn new(rotate: bool, skew: bool, distort: bool) -> Self {
|
||||
BoxAllow { rotate, skew, distort }
|
||||
BoxAllow { rotate, skew, distort, warp: true }
|
||||
}
|
||||
|
||||
/// Whether the content allows warping.
|
||||
pub const fn with_warp(mut self, warp: bool) -> Self {
|
||||
self.warp = warp;
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for BoxAllow {
|
||||
fn default() -> Self {
|
||||
BoxAllow { rotate: true, skew: true, distort: true }
|
||||
BoxAllow { rotate: true, skew: true, distort: true, warp: true }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -121,13 +121,13 @@ impl<'a> CropBar<'a> {
|
||||
/// Shows the bar's children.
|
||||
pub fn show(self, ui: &mut Ui) -> CropBarOutput {
|
||||
let Self { settings, document, user_presets, straighten, angle, help, can_reset } = self;
|
||||
let _ = (help, can_reset); // P3(tools-w14): pn.C20, pn.C21 the Reset and help buttons.
|
||||
let env = Env::of(ui);
|
||||
let words = env.words::<CropBarWords>();
|
||||
let units = env.units();
|
||||
let has_document = document.size.width > 0.0 && document.size.height > 0.0;
|
||||
let before = settings.clone();
|
||||
let mut report = Report::default();
|
||||
let (mut help_pressed, mut reset_pressed) = (false, false);
|
||||
// The options are the bar's members, spaced as the bar spaces them.
|
||||
let shown = Row::new().gap(Gap::Item).show(ui, |ui, cx| {
|
||||
preset_list(ui, settings, &words, document, has_document, user_presets, &units, &mut report);
|
||||
@@ -162,6 +162,10 @@ impl<'a> CropBar<'a> {
|
||||
settings.fill = fill;
|
||||
}
|
||||
});
|
||||
if let Some(label) = help.clone() {
|
||||
help_pressed = clicked(&IconButton::new(IconId::new("info")).label(label).show(ui));
|
||||
}
|
||||
reset_pressed = clicked(&IconButton::new(IconId::new("undo_2")).label(words.reset_tip.clone()).enabled(can_reset).show(ui));
|
||||
});
|
||||
let changed = *settings != before;
|
||||
CropBarOutput {
|
||||
@@ -173,8 +177,8 @@ impl<'a> CropBar<'a> {
|
||||
delete_preset: report.delete_preset,
|
||||
pick_color: report.pick_color,
|
||||
settings_changed: changed,
|
||||
help: false,
|
||||
reset: false,
|
||||
help: help_pressed,
|
||||
reset: reset_pressed,
|
||||
selection: false,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,6 +62,14 @@ craft_ui::words! {
|
||||
fill_name: "cropBar.fillName" = "Fill";
|
||||
fill_background: "cropBar.fillBackground" = "Background (Default)";
|
||||
fill_content_aware: "cropBar.fillContentAware" = "Content-Aware Fill";
|
||||
/// The preset list's From Selection entry.
|
||||
selection: "cropBar.selection" = "From Selection";
|
||||
/// The Fill select's first entry while Delete Cropped Pixels is off.
|
||||
fill_transparent: "cropBar.fillTransparent" = "Transparent";
|
||||
/// The Reset button's name and tooltip.
|
||||
reset_tip: "cropBar.resetTip" = "Reset crop box";
|
||||
/// The perspective bar's Show Grid check box.
|
||||
show_grid: "cropBar.showGrid" = "Show Grid";
|
||||
commit: "cropBar.commit" = "Commit current crop operation";
|
||||
cancel: "cropBar.cancel" = "Cancel current crop operation";
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ pub use perspective_bar::{PerspectiveCropBar, PerspectiveCropBarOutput};
|
||||
pub use perspective_crop::{
|
||||
PerspectiveCropOutput, PerspectiveCropQuad, PerspectiveCropStyle, PerspectiveQuad, grid_lines, grid_steps, is_valid, ordered,
|
||||
};
|
||||
pub use perspective_tool::{PerspectiveCropEvent, PerspectiveCropTool, perspective_to_form};
|
||||
pub use perspective_tool::{PerspectiveCropEvent, PerspectiveCropPass, PerspectiveCropTool, PerspectiveInput, perspective_to_form};
|
||||
pub use preset_list::{CropPresetList, CropPresetListOutput};
|
||||
pub use session::{CropDocKey, CropDocument, CropKept, CropSession, CropStep, LeaveFrame, StraightenState};
|
||||
pub use size_cells::CropSizeTarget;
|
||||
|
||||
@@ -104,6 +104,71 @@ fn boxed(anchor: Point, to: Point) -> PerspectiveQuad {
|
||||
(x1 > x0 && y1 > y0).then_some([Point::new(x0, y0), Point::new(x1, y0), Point::new(x1, y1), Point::new(x0, y1)])
|
||||
}
|
||||
|
||||
/// What the host hands the perspective crop pass each frame.
|
||||
#[derive(Clone, Copy, Debug, Default)]
|
||||
#[non_exhaustive]
|
||||
pub struct PerspectiveInput<'a> {
|
||||
/// Whether the quad's grid shows.
|
||||
pub show_grid: bool,
|
||||
/// Ties the input to the pass's lifetime until the shield (tl.T44, not in this checkout) joins it.
|
||||
pub marker: std::marker::PhantomData<&'a ()>,
|
||||
}
|
||||
|
||||
/// This pass's perspective crop tool for the host, borrowing its input; it is the canvas tool while the pass lives.
|
||||
pub struct PerspectiveCropPass<'a> {
|
||||
tool: &'a mut PerspectiveCropTool,
|
||||
input: PerspectiveInput<'a>,
|
||||
}
|
||||
|
||||
impl PerspectiveCropTool {
|
||||
/// This pass's tool for the host, borrowing `input`'s data.
|
||||
pub fn pass<'a>(&'a mut self, input: PerspectiveInput<'a>) -> PerspectiveCropPass<'a> {
|
||||
PerspectiveCropPass { tool: self, input }
|
||||
}
|
||||
}
|
||||
|
||||
impl PerspectiveCropPass<'_> {
|
||||
/// Shows the quad over the canvas at `canvas_rect` and reports its edits.
|
||||
pub fn show_quad(&mut self, ui: &mut egui::Ui, canvas_rect: egui::Rect) -> super::PerspectiveCropOutput {
|
||||
let _ = (&self.tool, &self.input, ui, canvas_rect);
|
||||
todo!("tl.T48")
|
||||
}
|
||||
}
|
||||
|
||||
impl CanvasTool for PerspectiveCropPass<'_> {
|
||||
fn press(&mut self, pointer: &ToolPointer, cx: &mut ToolContext<'_>) -> ToolAction {
|
||||
self.tool.press(pointer, cx)
|
||||
}
|
||||
|
||||
fn drag(&mut self, pointer: &ToolPointer, cx: &mut ToolContext<'_>) {
|
||||
self.tool.drag(pointer, cx);
|
||||
}
|
||||
|
||||
fn release(&mut self, pointer: &ToolPointer, cx: &mut ToolContext<'_>) {
|
||||
self.tool.release(pointer, cx);
|
||||
}
|
||||
|
||||
fn cancel(&mut self, reason: CancelReason, cx: &mut ToolContext<'_>) {
|
||||
self.tool.cancel(reason, cx);
|
||||
}
|
||||
|
||||
fn key(&mut self, key: &ToolKey, cx: &mut ToolContext<'_>) -> bool {
|
||||
self.tool.key(key, cx)
|
||||
}
|
||||
|
||||
fn paint(&self, draw: &Draw<'_>, cx: &ToolContext<'_>) {
|
||||
self.tool.paint(draw, cx);
|
||||
}
|
||||
|
||||
fn cursor(&self, cx: &ToolContext<'_>) -> Cursor {
|
||||
self.tool.cursor(cx)
|
||||
}
|
||||
|
||||
fn command_form(&self) -> ToolPath {
|
||||
self.tool.command_form()
|
||||
}
|
||||
}
|
||||
|
||||
impl CanvasTool for PerspectiveCropTool {
|
||||
fn press(&mut self, pointer: &ToolPointer, cx: &mut ToolContext<'_>) -> ToolAction {
|
||||
let Some(space) = cx.space() else { return ToolAction::Ignored };
|
||||
|
||||
@@ -40,19 +40,21 @@ pub mod pattern;
|
||||
pub mod pen;
|
||||
pub mod picture_fill;
|
||||
pub mod shape;
|
||||
pub mod shape_presets;
|
||||
pub mod shape_drag;
|
||||
pub mod shape_presets;
|
||||
pub mod slice;
|
||||
pub mod stroke;
|
||||
pub mod symmetry;
|
||||
pub mod transform;
|
||||
|
||||
pub use add_beside::{AddBesideHandles, AddBesideOutput, AddBesideWords, AddSide, add_beside_places};
|
||||
pub use artboard::ArtboardBarTarget;
|
||||
pub use artboard::{
|
||||
ArtboardBackground, ArtboardBar, ArtboardBarOutput, ArtboardEvent, ArtboardItem, ArtboardPreset, ArtboardProperties, ArtboardPropertiesOutput,
|
||||
ArtboardRules, ArtboardTool,
|
||||
};
|
||||
pub use brush_presets::{BrushPick, BrushPickerSettings, BrushPickerState, BrushPickerValues, BrushPresetPicker, BrushPresetPickerOutput};
|
||||
pub use brush_presets::{BrushesPanel, BrushesPanelOutput};
|
||||
pub use brush_settings::{
|
||||
BrushPanelAction, BrushSection, BrushSectionEvent, BrushSectionKind, BrushSectionList, BrushSettingsPanel, BrushSettingsPanelOutput,
|
||||
BrushSizeField, BrushStrokeStrip, DynamicControl, TipEllipse,
|
||||
@@ -67,34 +69,45 @@ pub use crop::{
|
||||
CropOverlayMenu, CropPresetChoice, CropRatio, CropRatioChange, CropSession, CropSettings, CropSizePreset, CropTarget, CropTool, CropToolPass,
|
||||
CropUserPreset, CropWords, PerspectiveCropOutput, PerspectiveCropTool, ResolutionUnit,
|
||||
};
|
||||
pub use crop::{
|
||||
CropPresetList, CropPresetListOutput, CropSizeTarget, PerspectiveCropBar, PerspectiveCropBarOutput, PerspectiveCropPass, PerspectiveInput,
|
||||
};
|
||||
pub use crop::{PerspectiveCropQuad, PerspectiveQuad};
|
||||
pub use gradient::{
|
||||
ColorStop, GradientEditor, GradientExtent, GradientGroup, GradientItem, GradientLine, GradientMap, GradientMapEditor, GradientMapOutput,
|
||||
GradientOverlay, GradientPalette, GradientRamp, GradientRef, GradientStops, GradientSwatch, LineGradient, LinePart, OpacityStop,
|
||||
Sampler as StopSampler, StopDrop, StopRef, StopRow, StopRows, StopRules, default_sampler,
|
||||
};
|
||||
pub use gradient::{GradientFill, GradientFillEditor, GradientFillEditorOutput, GradientFillWords, GradientStyle};
|
||||
pub use measure::{MIN_LINE, RulerBar, RulerBarOutput, RulerLine, RulerOverlay, RulerPass, RulerTool, RulerWords, box_distances, ruler_line_form};
|
||||
pub use paint_bar::{
|
||||
EraserMode, MIXER_COMBINATIONS, MIXER_GROUP_STARTS, MixerValues, PaintBar, PaintBarOutput, PaintBarWords, PaintTool, PaintValues, Smoothing,
|
||||
};
|
||||
pub use paths::{PathKind, PathRow, PathsCommands, PathsEvent, PathsFooterButton, PathsOutput, PathsPanel, PathsWords};
|
||||
pub use pattern::{
|
||||
PatternColors, PatternFillDialog, PatternFillEditor, PatternFillOptions, PatternFillOutput, PatternSwatch, PatternWords, SwatchPainter,
|
||||
};
|
||||
pub use pen::{AnchorDelete, PenEnd};
|
||||
pub use pen::{AnchorsShown, HitMark, PATH_OPTIONS_COLOR_KEY, PathMode, PathOptionsPopover, PathOptionsSettings, PathTool, PenMode, SegmentMark};
|
||||
pub use pen::{
|
||||
BezierHit, BezierOverlay, BezierStyle, BezierTool, EditPath, EditSubpath, HandleSide, HandlesShown, Knot, KnotRef, MAX_ANCHORS, PathEdit,
|
||||
PathSelection, PenStyle,
|
||||
};
|
||||
pub use picture_fill::{PictureFill, PictureFillEditor, PictureFillOutput, PictureMode};
|
||||
pub use shape::{Arrowheads, ArrowheadsOutput, ArrowheadsPopover, LINE_WEIGHT_RANGE, RADIUS_RANGE, StrokeCells, VectorMode, VectorModeSelect};
|
||||
pub use shape::{
|
||||
ChipSetup, LiveShape, ShapeAppearance, ShapeBar, ShapeBarOutput, ShapeChange, ShapePaint, ShapePanel, ShapePanelOutput, ShapeToolSettings,
|
||||
ShapeWords,
|
||||
};
|
||||
pub use shape_drag::{CreateShapeDialog, CreateShapeOptions, CreatedShape, ShapeDragEvent, ShapeDragOptions, ShapeDragTool, ShapeKind};
|
||||
pub use shape_presets::{ShapeMenu, ShapePresetWords};
|
||||
pub use slice::{
|
||||
DivideBy, DivideSlices, DivideSlicesDialog, SliceBar, SliceBarOutput, SliceCommand, SliceEvent, SliceItem, SliceKind, SliceMode, SliceOptions,
|
||||
SliceOptionsDialog, SliceOverlay, SliceTool, SliceToolSettings,
|
||||
};
|
||||
pub use stroke::{DashUnit, LineCap, LineJoin, LineStyle, StrokeAlign, StrokeButton, StrokeEditor, StrokePreview, StrokeStyle};
|
||||
pub use stroke::{DashAlign, DashUnit, LineCap, LineJoin, LineStyle, StrokeAlign, StrokeButton, StrokeEditor, StrokePreview, StrokeStyle};
|
||||
pub use symmetry::{Symmetry, SymmetryChoice, SymmetryCommand, SymmetryEvent, SymmetryMenu, SymmetryMode, SymmetryOverlay, SymmetryTransform};
|
||||
pub use transform::{BarGroups, RotateZone, SizeUnit, TransformBox, TransformField, TransformFields, TransformRow};
|
||||
pub use transform::{ApplyBy, RotateZone, SizeUnit, TransformBox, TransformField, TransformFields, TransformGroups, TransformRow};
|
||||
pub use transform::{
|
||||
Interpolation, TransformBar, TransformBarOutput, TransformChoice, TransformEdit, TransformOverlay, TransformPhase, TransformPreset,
|
||||
TransformRequest, TransformResult, TransformSession, TransformSettings, TransformWarp,
|
||||
|
||||
@@ -70,7 +70,9 @@ pub(super) fn anchor_click(tool: BezierTool, hit: BezierHit, mods: Mods, report:
|
||||
// pc: crates/ui-egui/src/tools/anchor_tools.rs:88-114 `pointer`, `click`; :130-150 `apply`.
|
||||
match (hit, tool.acting(mods)) {
|
||||
(BezierHit::Segment { path, segment, t }, BezierTool::AddAnchor | BezierTool::AutoAddDelete) => report.insert = Some((path, segment, t)),
|
||||
(BezierHit::Anchor { path, knot }, BezierTool::DeleteAnchor | BezierTool::AutoAddDelete) => report.delete = Some(AnchorDelete::new(path, vec![knot], false)), // P3(tools-w9): tl.T32
|
||||
(BezierHit::Anchor { path, knot }, BezierTool::DeleteAnchor | BezierTool::AutoAddDelete) => {
|
||||
report.delete = Some(AnchorDelete::new(path, vec![knot], false))
|
||||
} // P3(tools-w9): tl.T32
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,8 +13,8 @@ mod tool;
|
||||
mod words;
|
||||
|
||||
pub use bezier::{
|
||||
AnchorDelete, AnchorsShown, BezierHit, BezierOutput, BezierOverlay, BezierStyle, BezierTool, BezierWords, EditPath, EditSubpath, HandleSide, HandlesShown,
|
||||
HitMark, Knot, KnotRef, MAX_ANCHORS, PathEdit, PathSelection, SegmentMark,
|
||||
AnchorDelete, AnchorsShown, BezierHit, BezierOutput, BezierOverlay, BezierStyle, BezierTool, BezierWords, EditPath, EditSubpath, HandleSide,
|
||||
HandlesShown, HitMark, Knot, KnotRef, MAX_ANCHORS, PathEdit, PathSelection, SegmentMark,
|
||||
};
|
||||
pub use mode::{PathMode, PathTool, PenMode};
|
||||
pub use options::{PATH_OPTIONS_COLOR_KEY, PathOptionsOutput, PathOptionsPopover, PathOptionsSettings, PathOptionsWords};
|
||||
|
||||
@@ -14,16 +14,16 @@ mod arrowheads;
|
||||
mod bar;
|
||||
mod mode_select;
|
||||
mod panel;
|
||||
mod stroke_cells;
|
||||
#[cfg(feature = "screen-testing")]
|
||||
pub(crate) mod stories;
|
||||
mod stroke_cells;
|
||||
mod words;
|
||||
|
||||
pub use arrowheads::{ArrowheadsOutput, ArrowheadsPopover};
|
||||
pub use mode_select::VectorModeSelect;
|
||||
pub use stroke_cells::StrokeCells;
|
||||
pub use bar::{ShapeBar, ShapeBarOutput};
|
||||
pub use mode_select::VectorModeSelect;
|
||||
pub use panel::{ChipSetup, ShapePaint, ShapePanel, ShapePanelOutput};
|
||||
pub use stroke_cells::StrokeCells;
|
||||
pub use words::ShapeWords;
|
||||
|
||||
/// The drawing mode of the vector tools.
|
||||
@@ -278,7 +278,15 @@ impl Default for ShapeToolSettings {
|
||||
/// Fill on, square corners, 5 sides, a plain polygon, weight 3, no stroke (PhotoCraft's
|
||||
/// `ToolOptions::default`, `state/tool_options.rs:405-412`).
|
||||
fn default() -> Self {
|
||||
ShapeToolSettings { fill_on: true, corner_radius: 0.0, sides: 5, star_ratio: 1.0, line_weight: 3.0, stroke_width: 0.0, arrowheads: Arrowheads::default() }
|
||||
ShapeToolSettings {
|
||||
fill_on: true,
|
||||
corner_radius: 0.0,
|
||||
sides: 5,
|
||||
star_ratio: 1.0,
|
||||
line_weight: 3.0,
|
||||
stroke_width: 0.0,
|
||||
arrowheads: Arrowheads::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
use std::ops::RangeInclusive;
|
||||
|
||||
use super::{RADIUS_RANGE, LiveShape, ShapeAppearance, ShapeChange, ShapeWords};
|
||||
use super::{LiveShape, RADIUS_RANGE, ShapeAppearance, ShapeChange, ShapeWords};
|
||||
use crate::ui::stroke::StrokeButton;
|
||||
use craft_behavior::{EditEvent, EditEvents, NumberCodec};
|
||||
use craft_color::ui::{Paint, PaintChip, PaintChipOutput, ScreenPickGesture};
|
||||
@@ -11,8 +11,8 @@ use craft_theme::Srgba;
|
||||
use craft_ui::contract::{Bind, GlyphLabel, LabelKind, LabelScheme, Props as _, Show as _, ShowContainer as _, SideLabel};
|
||||
use craft_ui::form::{Field, FieldGroup};
|
||||
use craft_ui::layout_components::Row;
|
||||
use craft_ui::runtime::requests::ColorRequest;
|
||||
use craft_ui::runtime::env::{Env, Label, LengthUnits, UnitKind, Units, with_env};
|
||||
use craft_ui::runtime::requests::ColorRequest;
|
||||
use craft_ui::sections::Section;
|
||||
use craft_ui::text::NumberField;
|
||||
use egui::Ui;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
//! The shape menu: the preset glyphs, their words and [`ShapeMenu`].
|
||||
|
||||
use crate::geometry::presets::ShapePreset;
|
||||
use craft_ui::style::UiTokens;
|
||||
use craft_ui::primitives::Glyph;
|
||||
use craft_ui::runtime::env::Label;
|
||||
use craft_ui::style::UiTokens;
|
||||
use egui::{Color32, Painter, Rect, Ui};
|
||||
|
||||
craft_ui::words! {
|
||||
|
||||
@@ -53,12 +53,19 @@ pub struct SliceBar<'a> {
|
||||
mode: SliceMode,
|
||||
settings: &'a mut SliceToolSettings,
|
||||
size_units: Option<SizeUnits<'a>>,
|
||||
locked: bool,
|
||||
}
|
||||
|
||||
impl<'a> SliceBar<'a> {
|
||||
/// The members of `mode` over `settings`, which the Style, Width, Height and Hide Auto Slices write through.
|
||||
pub fn new(mode: SliceMode, settings: &'a mut SliceToolSettings) -> Self {
|
||||
SliceBar { mode, settings, size_units: None }
|
||||
SliceBar { mode, settings, size_units: None, locked: false }
|
||||
}
|
||||
|
||||
/// Shows the muted "slices are locked" notice after the members in both modes.
|
||||
pub fn locked(mut self, on: bool) -> Self {
|
||||
self.locked = on;
|
||||
self
|
||||
}
|
||||
|
||||
/// Shows Fixed Size in `unit`, with `units` in the units menu (the app's ruler units), converting through the
|
||||
@@ -70,7 +77,8 @@ impl<'a> SliceBar<'a> {
|
||||
|
||||
/// Adds the members to the bar's row.
|
||||
pub fn show(self, ui: &mut Ui) -> SliceBarOutput {
|
||||
let SliceBar { mode, settings, size_units } = self;
|
||||
let SliceBar { mode, settings, size_units, locked } = self;
|
||||
let _ = locked; // P3(tools-w19): tl.T57
|
||||
let words = Env::of(ui).words::<SliceWords>();
|
||||
let text = |commands: &[SliceCommand]| {
|
||||
BarItems::new(commands.iter().map(|&command| BarItem::new(command).display(ItemDisplay::Text)).collect()).label(words.commands.clone())
|
||||
|
||||
@@ -39,6 +39,16 @@ pub struct SliceTool {
|
||||
events: Vec<SliceEvent>,
|
||||
drag: Option<Drag>,
|
||||
ids: GestureId,
|
||||
#[allow(dead_code)] // P3(tools-w19): tl.T57
|
||||
color: Option<craft_theme::Srgba>,
|
||||
}
|
||||
|
||||
impl SliceTool {
|
||||
/// The colour the slice lines draw in; `None` is the theme's.
|
||||
pub fn color(&mut self, color: Option<craft_theme::Srgba>) -> &mut Self {
|
||||
self.color = color;
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
/// A new slice between presses.
|
||||
|
||||
@@ -19,7 +19,7 @@ use craft_ui::primitives::ContentPainterCx;
|
||||
use craft_ui::runtime::env::Label;
|
||||
use egui::Rect;
|
||||
|
||||
pub use crate::stroke::{DashUnit, LineCap, LineJoin, LineStyle, StrokeAlign, StrokeError, StrokeStyle};
|
||||
pub use crate::stroke::{DashAlign, DashUnit, LineCap, LineJoin, LineStyle, StrokeAlign, StrokeError, StrokeStyle};
|
||||
pub use button::StrokeButton;
|
||||
pub use editor::{StrokeEditor, StrokeEditorOutput};
|
||||
pub use preview::StrokePreview;
|
||||
|
||||
@@ -13,5 +13,5 @@ pub use session::{
|
||||
};
|
||||
pub use session_bar::{BarSlot, TransformBar, TransformBarOutput, TransformBarWords};
|
||||
pub use session_overlay::{TransformOverlay, TransformOverlayOutput, TransformTool};
|
||||
pub use transform_box::{BOX, RotateZone, TransformBox, TransformBoxOutput, TransformBoxStyle, TransformBoxWords};
|
||||
pub use transform_fields::{BarGroups, SizeUnit, TransformField, TransformFieldWords, TransformFields, TransformFieldsOutput, TransformRow};
|
||||
pub use transform_box::{ApplyBy, BOX, RotateZone, TransformBox, TransformBoxOutput, TransformBoxStyle, TransformBoxWords};
|
||||
pub use transform_fields::{SizeUnit, TransformField, TransformFieldWords, TransformFields, TransformFieldsOutput, TransformGroups, TransformRow};
|
||||
|
||||
@@ -238,8 +238,8 @@ impl<W: TransformWarp> TransformSession<W> {
|
||||
|
||||
/// The persisted section the session opens with: its interpolation and whether the reference
|
||||
/// point shows.
|
||||
pub fn settings(mut self, settings: &TransformSettings) -> Self {
|
||||
self.interpolation = settings.interpolation;
|
||||
pub fn settings(mut self, settings: &TransformSettings, default_interpolation: Interpolation) -> Self {
|
||||
self.interpolation = settings.interpolation.unwrap_or(default_interpolation);
|
||||
self.reference_point = settings.show_reference_point;
|
||||
self
|
||||
}
|
||||
|
||||
@@ -94,11 +94,13 @@ pub enum TransformChoice {
|
||||
Warp,
|
||||
/// Apply as [`TransformEdit::Preset`].
|
||||
Preset(TransformPreset),
|
||||
/// The app's menu row at this index in [`TransformOverlay::menu_rows`](super::super::TransformOverlay::menu_rows).
|
||||
Row(usize),
|
||||
}
|
||||
|
||||
/// Free Transform's persisted section: the app keeps it with its preferences. Unknown fields are
|
||||
/// ignored, missing ones take their defaults.
|
||||
#[derive(Clone, Debug, Default, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
||||
#[derive(Clone, Debug, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
|
||||
#[serde(default, rename_all = "camelCase")]
|
||||
#[non_exhaustive]
|
||||
pub struct TransformSettings {
|
||||
@@ -111,12 +113,29 @@ pub struct TransformSettings {
|
||||
/// Show Reference Point: off by default (Photoshop CC 2019 and later, LC2). Hidden, the point
|
||||
/// is not drawn, hit or picked; its stored position still pivots ⌥ scaling and rotating.
|
||||
pub show_reference_point: bool,
|
||||
/// The interpolation a new session starts with.
|
||||
pub interpolation: Interpolation,
|
||||
/// The interpolation a new session starts with; `None` follows the General preference until one is picked.
|
||||
pub interpolation: Option<Interpolation>,
|
||||
/// The W and H fields' unit; percent when unset. Saved preferences may spell it as the legacy names
|
||||
/// (`"Pixels"`, `"Percent"`, `"Inches"`, `"Centimetres"`, `"Millimetres"`, `"Points"`, `"Picas"`).
|
||||
#[serde(deserialize_with = "unit_or_legacy")]
|
||||
pub size_unit: Option<UnitKind>,
|
||||
/// X and Y show and move the reference point's offset from where it started.
|
||||
pub relative_position: bool,
|
||||
}
|
||||
|
||||
impl Default for TransformSettings {
|
||||
/// Free Transform's defaults: proportions linked, no legacy scaling, the reference point hidden, interpolation
|
||||
/// from the General preference.
|
||||
fn default() -> Self {
|
||||
TransformSettings {
|
||||
legacy: false,
|
||||
aspect_linked: true,
|
||||
show_reference_point: false,
|
||||
interpolation: None,
|
||||
size_unit: None,
|
||||
relative_position: false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Reads a unit by the spelling `UnitKind` serializes to or by the legacy spelling, whatever the case.
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
mod stories;
|
||||
|
||||
use super::session::{TransformEdit, TransformPhase, TransformSession, TransformSettings, TransformWarp};
|
||||
use super::transform_fields::{BarGroups, TransformFields, TransformRow, size_unit_of};
|
||||
use super::transform_fields::{TransformFields, TransformGroups, TransformRow, size_unit_of};
|
||||
use craft_behavior::{EditEvent, IconId, Mixed, RulerUnits};
|
||||
use craft_ui::bars::{Bar, BarKind};
|
||||
use craft_ui::buttons::IconButton;
|
||||
@@ -95,7 +95,7 @@ pub struct TransformBar<'a, W> {
|
||||
label: Label,
|
||||
session: &'a TransformSession<W>,
|
||||
settings: Bind<'a, TransformSettings>,
|
||||
groups: BarGroups,
|
||||
groups: TransformGroups,
|
||||
mode_switch: bool,
|
||||
warp_fields: Option<BarSlot<'a>>,
|
||||
extra: Option<BarSlot<'a>>,
|
||||
@@ -111,7 +111,7 @@ impl<'a, W: TransformWarp> TransformBar<'a, W> {
|
||||
label: label.into(),
|
||||
session,
|
||||
settings,
|
||||
groups: BarGroups::ALL,
|
||||
groups: TransformGroups::ALL,
|
||||
mode_switch: true,
|
||||
warp_fields: None,
|
||||
extra: None,
|
||||
@@ -121,7 +121,7 @@ impl<'a, W: TransformWarp> TransformBar<'a, W> {
|
||||
}
|
||||
|
||||
/// Which groups of the fields show; all by default.
|
||||
pub fn groups(mut self, groups: BarGroups) -> Self {
|
||||
pub fn groups(mut self, groups: TransformGroups) -> Self {
|
||||
self.groups = groups;
|
||||
self
|
||||
}
|
||||
@@ -249,7 +249,7 @@ impl<'a, W: TransformWarp> TransformBar<'a, W> {
|
||||
}
|
||||
if let Some(choice) = shown.interpolation {
|
||||
edits.push(TransformEdit::Interpolation(choice));
|
||||
settings.interpolation = choice;
|
||||
settings.interpolation = Some(choice);
|
||||
}
|
||||
if let Some(unit) = shown.unit_picked {
|
||||
settings.size_unit = Some(unit);
|
||||
|
||||
@@ -9,14 +9,16 @@ use craft_behavior::geometry::SnapTargets;
|
||||
use craft_behavior::geometry::quad::{BoxPart, BoxRules};
|
||||
use craft_keymap::Mods;
|
||||
use craft_ui::canvas::{CanvasTool, ToolAction, ToolContext, ToolKey, ToolPath, ToolPointer};
|
||||
use craft_ui::contract::Bind;
|
||||
use craft_ui::contract::Show as _;
|
||||
use craft_ui::contract::{Bind, Entry};
|
||||
use craft_ui::menu::Menu;
|
||||
use craft_ui::primitives::Draw;
|
||||
use craft_ui::runtime::env::{Env, Label};
|
||||
use egui::{Rect, Ui};
|
||||
|
||||
use super::{TransformBox, TransformChoice, TransformEdit, TransformMenuWords, TransformPhase, TransformSession, TransformSettings, TransformWarp};
|
||||
use super::{
|
||||
ApplyBy, TransformBox, TransformChoice, TransformEdit, TransformMenuWords, TransformPhase, TransformSession, TransformSettings, TransformWarp,
|
||||
};
|
||||
|
||||
/// What the overlay reported this pass.
|
||||
#[derive(Debug)]
|
||||
@@ -25,11 +27,15 @@ pub struct TransformOverlayOutput<W> {
|
||||
/// The edits in the order they happened; the app applies each with [`TransformSession::apply`].
|
||||
pub edits: Vec<TransformEdit<W>>,
|
||||
/// Enter, a click outside or a double click inside: the app calls [`TransformSession::commit`] after the edits.
|
||||
pub apply: bool,
|
||||
pub apply: Option<ApplyBy>,
|
||||
/// Escape with no drag running: the app calls [`TransformSession::discard`] after the edits.
|
||||
pub discard: bool,
|
||||
/// The keyboard's picked part while the box has focus.
|
||||
pub picked: Option<BoxPart>,
|
||||
/// The snap lines of the point being dragged, from the box.
|
||||
pub snapped: Vec<craft_behavior::geometry::SnapLine>,
|
||||
/// The value of the app's menu row that was picked.
|
||||
pub menu_row: Option<String>,
|
||||
}
|
||||
|
||||
/// The open [`TransformSession`]'s box on the canvas.
|
||||
@@ -55,12 +61,28 @@ pub struct TransformOverlay<'a, W> {
|
||||
pixel_grid: bool,
|
||||
snap: Option<&'a SnapTargets>,
|
||||
mods: Option<Mods>,
|
||||
#[allow(dead_code)] // P3(tools-w2): cw.C38
|
||||
menu_rows: &'a [Entry<String>],
|
||||
#[allow(dead_code)] // P3(tools-w2): tl.T62
|
||||
move_reach: f32,
|
||||
}
|
||||
|
||||
impl<'a, W: TransformWarp> TransformOverlay<'a, W> {
|
||||
/// The overlay of `session` named `label`, with the box rules `settings` give.
|
||||
pub fn new(label: impl Into<Label>, session: &'a TransformSession<W>, settings: &'a TransformSettings) -> Self {
|
||||
Self { label: label.into(), session, settings, rules: None, pixel_grid: false, snap: None, mods: None }
|
||||
Self { label: label.into(), session, settings, rules: None, pixel_grid: false, snap: None, mods: None, menu_rows: &[], move_reach: 0.0 }
|
||||
}
|
||||
|
||||
/// The app's rows after Warp in the box menu; a pick is reported as [`TransformOverlayOutput::menu_row`].
|
||||
pub fn menu_rows(mut self, rows: &'a [Entry<String>]) -> Self {
|
||||
self.menu_rows = rows;
|
||||
self
|
||||
}
|
||||
|
||||
/// While a session is open, a plain press within `points` screen points outside the frame moves the box (0: off).
|
||||
pub fn move_reach(mut self, points: f32) -> Self {
|
||||
self.move_reach = points;
|
||||
self
|
||||
}
|
||||
|
||||
/// The app's own box rules in place of [`TransformSession::box_rules`]: a 45° rotate step, a Move tool's rules.
|
||||
@@ -96,7 +118,7 @@ impl<'a, W: TransformWarp> TransformOverlay<'a, W> {
|
||||
/// Shows the box at `rect`, the canvas body's rect (Box phase); in the Warp phase returns an empty output.
|
||||
pub fn show_at(self, ui: &mut Ui, rect: Rect) -> TransformOverlayOutput<W> {
|
||||
let session = self.session;
|
||||
let mut out = TransformOverlayOutput { edits: Vec::new(), apply: false, discard: false, picked: None };
|
||||
let mut out = TransformOverlayOutput { edits: Vec::new(), apply: None, discard: false, picked: None, snapped: Vec::new(), menu_row: None };
|
||||
if session.phase() == TransformPhase::Warp {
|
||||
return out;
|
||||
}
|
||||
@@ -126,6 +148,7 @@ impl<'a, W: TransformWarp> TransformOverlay<'a, W> {
|
||||
TransformChoice::Mode(mode) => TransformEdit::Mode(mode),
|
||||
TransformChoice::Warp => TransformEdit::WarpRequested,
|
||||
TransformChoice::Preset(preset) => TransformEdit::Preset(preset),
|
||||
TransformChoice::Row(_) => todo!("cw.C38"),
|
||||
});
|
||||
}
|
||||
out
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//! Stories of the transform overlay: the open session's box, run live under its options bar.
|
||||
|
||||
use super::{TransformOverlay, TransformTool};
|
||||
use crate::ui::transform::{TransformBar, TransformEdit, TransformPhase, TransformRequest, TransformSession, TransformSettings};
|
||||
use crate::ui::transform::{Interpolation, TransformBar, TransformEdit, TransformPhase, TransformRequest, TransformSession, TransformSettings};
|
||||
use craft_behavior::CanvasView;
|
||||
use craft_behavior::geometry::quad::BoxState;
|
||||
use craft_behavior::kurbo::{Line, Rect as DocRect};
|
||||
@@ -63,7 +63,7 @@ fn sample_settings() -> TransformSettings {
|
||||
|
||||
/// A session on the layer, its box at `state`.
|
||||
fn open(state: BoxState, settings: &TransformSettings) -> TransformSession<()> {
|
||||
TransformSession::with_state(FRAME, state).settings(settings)
|
||||
TransformSession::with_state(FRAME, state).settings(settings, Interpolation::default())
|
||||
}
|
||||
|
||||
/// Free Transform live over the layer, under its options bar: the box and the bar's fields edit the session; Enter, a
|
||||
@@ -104,7 +104,7 @@ fn transform_phase(ui: &mut Ui, data: &mut StoryData) -> StoryOutput {
|
||||
let _ = run.host.run(&mut tool);
|
||||
let (key_apply, key_discard) = tool.take_keys();
|
||||
let (edits, apply, discard) = match run.shown {
|
||||
Some(shown) => (shown.edits, shown.apply, shown.discard),
|
||||
Some(shown) => (shown.edits, shown.apply.is_some(), shown.discard),
|
||||
None => (Vec::new(), false, false),
|
||||
};
|
||||
let edits: Vec<TransformEdit<()>> = edits.into_iter().chain(bar.edits).collect();
|
||||
|
||||
@@ -115,10 +115,25 @@ pub struct TransformBoxStyle {
|
||||
pivot_arm: f32,
|
||||
}
|
||||
|
||||
/// Why the box asks to apply.
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
#[non_exhaustive]
|
||||
pub enum ApplyBy {
|
||||
/// Enter.
|
||||
Key,
|
||||
/// A double click inside the box.
|
||||
DoubleClick,
|
||||
/// A click outside the box, at `at` in document units.
|
||||
ClickOutside {
|
||||
/// Where the click landed.
|
||||
at: Point,
|
||||
},
|
||||
}
|
||||
|
||||
/// What the box reports beyond its edit.
|
||||
#[derive(Clone, Copy, Debug, Default)]
|
||||
struct Report {
|
||||
apply: bool,
|
||||
apply: Option<ApplyBy>,
|
||||
discard: bool,
|
||||
hovered: Option<BoxPart>,
|
||||
picked: Option<BoxPart>,
|
||||
@@ -193,6 +208,9 @@ pub struct TransformBox<'a> {
|
||||
/// The host's snapping of a dragged point.
|
||||
#[prop]
|
||||
snap: Option<&'a SnapTargets>,
|
||||
/// Enlarges corner 2 with the overflow plus (a text frame whose text does not fit).
|
||||
#[prop]
|
||||
overflow: bool,
|
||||
report: Report,
|
||||
}
|
||||
|
||||
@@ -212,11 +230,17 @@ impl<'a> TransformBox<'a> {
|
||||
pixel_grid: false,
|
||||
mods: None,
|
||||
snap: None,
|
||||
overflow: false,
|
||||
report: Report::default(),
|
||||
}
|
||||
.label(label)
|
||||
}
|
||||
|
||||
/// A resize-only box for a text frame: sides of at least 4 units, no reference point, no inside move.
|
||||
pub fn text_frame(label: impl Into<Label>, state: Bind<'a, BoxState>, start: DocRect) -> Self {
|
||||
Self::new(label, state, start, 0.0).rules(BoxRules::default().with_min_side(4.0)).reference_point(false).inside_moves(false)
|
||||
}
|
||||
|
||||
/// The parts the keyboard walks, in order.
|
||||
fn keyboard_parts(&self) -> Vec<BoxPart> {
|
||||
let corners = (0..4u8).map(BoxPart::Corner);
|
||||
@@ -363,13 +387,13 @@ impl<'a> TransformBox<'a> {
|
||||
PressPhase::Release { start, click, .. } => {
|
||||
// A double click inside applies, whether or not the first press of the release was seen.
|
||||
if click && start.clicks >= 2 && start.button == PointerButton::Primary && part == BoxPart::Inside {
|
||||
self.report.apply = true;
|
||||
self.report.apply = Some(ApplyBy::DoubleClick);
|
||||
}
|
||||
let Some(grip) = held.take() else { continue };
|
||||
if grip.began {
|
||||
cx.commit();
|
||||
} else if grip.part == BoxPart::Outside && click && start.clicks <= 1 {
|
||||
self.report.apply = true;
|
||||
self.report.apply = Some(ApplyBy::ClickOutside { at: space.view.to_doc(start.origin) });
|
||||
} else if grip.moves_pivot && click {
|
||||
cx.set(grip.start);
|
||||
}
|
||||
@@ -399,7 +423,9 @@ impl<'a> TransformBox<'a> {
|
||||
}
|
||||
}
|
||||
}
|
||||
self.report.apply |= cx.intents().take(Intent::Submit);
|
||||
if cx.intents().take(Intent::Submit) {
|
||||
self.report.apply = Some(ApplyBy::Key);
|
||||
}
|
||||
if !pressing && cx.intents().take(Intent::Cancel) {
|
||||
self.report.discard = true;
|
||||
}
|
||||
@@ -552,7 +578,7 @@ impl Component for TransformBox<'_> {
|
||||
|
||||
fn finish(self, cx: Cx<'_, Self>) -> TransformBoxOutput {
|
||||
let Report { apply, discard, hovered, picked } = self.report;
|
||||
TransformBoxOutput { edit: cx.edit_response(), apply, discard, picked, hovered }
|
||||
TransformBoxOutput { edit: cx.edit_response(), apply, discard, picked, hovered, snapped: Vec::new() } // P3(tools-w2): tl.N21
|
||||
}
|
||||
}
|
||||
|
||||
@@ -563,14 +589,16 @@ pub struct TransformBoxOutput {
|
||||
/// A drag (`Begin` on the first move, `Update`, `Commit` on the release; Escape cancels it) or an arrow key's
|
||||
/// `Set`.
|
||||
pub edit: EditResponse<BoxState>,
|
||||
/// Apply the box: Enter, a click outside it, a double click inside it.
|
||||
pub apply: bool,
|
||||
/// Apply the box, and why: Enter, a click outside it, a double click inside it.
|
||||
pub apply: Option<ApplyBy>,
|
||||
/// Close the box without applying it: Escape while no drag is on.
|
||||
pub discard: bool,
|
||||
/// The part the keys act on, while the box has the keyboard.
|
||||
pub picked: Option<BoxPart>,
|
||||
/// The part a press at the pointer would take; `None` where it is the tool's.
|
||||
pub hovered: Option<BoxPart>,
|
||||
/// The snap lines of the point being dragged, for the host's one drawing site.
|
||||
pub snapped: Vec<craft_behavior::geometry::SnapLine>,
|
||||
}
|
||||
|
||||
impl Outcome for TransformBoxOutput {
|
||||
|
||||
@@ -33,6 +33,8 @@ craft_ui::words! {
|
||||
pub struct TransformFieldWords {
|
||||
x_glyph: "transform.xGlyph" = "X";
|
||||
x_name: "transform.xName" = "X position";
|
||||
/// The relative-position toggle between X and Y.
|
||||
relative: "transform.relativePosition" = "Use relative positioning for reference point";
|
||||
y_glyph: "transform.yGlyph" = "Y";
|
||||
y_name: "transform.yName" = "Y position";
|
||||
w_glyph: "transform.wGlyph" = "W";
|
||||
@@ -49,10 +51,10 @@ craft_ui::words! {
|
||||
}
|
||||
}
|
||||
|
||||
/// The groups of cells the options-bar form shows; [`BarGroups::ALL`] is all of them.
|
||||
/// The groups of cells the options-bar form shows; [`TransformGroups::ALL`] is all of them.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
#[non_exhaustive]
|
||||
pub struct BarGroups {
|
||||
pub struct TransformGroups {
|
||||
/// The reference point picker.
|
||||
pub reference: bool,
|
||||
/// X and Y.
|
||||
@@ -67,12 +69,14 @@ pub struct BarGroups {
|
||||
pub interpolation: bool,
|
||||
}
|
||||
|
||||
impl BarGroups {
|
||||
impl TransformGroups {
|
||||
/// Every group shown.
|
||||
pub const ALL: Self = Self { reference: true, position: true, size: true, angle: true, skew: true, interpolation: true };
|
||||
/// No group shown; a host starts from it and sets fields.
|
||||
pub const NONE: Self = Self { reference: false, position: false, size: false, angle: false, skew: false, interpolation: false };
|
||||
}
|
||||
|
||||
impl Default for BarGroups {
|
||||
impl Default for TransformGroups {
|
||||
fn default() -> Self {
|
||||
Self::ALL
|
||||
}
|
||||
@@ -155,6 +159,8 @@ pub struct TransformFieldsOutput {
|
||||
pub linked: Option<bool>,
|
||||
/// The interpolation picked this pass.
|
||||
pub interpolation: Option<Interpolation>,
|
||||
/// The relative-position toggle was set to this state.
|
||||
pub relative: Option<bool>,
|
||||
}
|
||||
|
||||
impl Outcome for TransformFieldsOutput {
|
||||
@@ -198,10 +204,12 @@ pub struct TransformFields<'a> {
|
||||
x: RulerText,
|
||||
y: RulerText,
|
||||
bar: bool,
|
||||
groups: BarGroups,
|
||||
groups: TransformGroups,
|
||||
interpolation: Option<Bind<'a, Interpolation>>,
|
||||
size_units: Option<&'a [Entry<UnitKind>]>,
|
||||
enabled: bool,
|
||||
relative: Option<Bind<'a, bool>>,
|
||||
document: Option<craft_behavior::kurbo::Size>,
|
||||
}
|
||||
|
||||
impl<'a> TransformFields<'a> {
|
||||
@@ -217,10 +225,12 @@ impl<'a> TransformFields<'a> {
|
||||
x: pixels,
|
||||
y: pixels,
|
||||
bar: false,
|
||||
groups: BarGroups::ALL,
|
||||
groups: TransformGroups::ALL,
|
||||
interpolation: None,
|
||||
size_units: None,
|
||||
enabled: true,
|
||||
relative: None,
|
||||
document: None,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -244,11 +254,23 @@ impl<'a> TransformFields<'a> {
|
||||
}
|
||||
|
||||
/// The groups the bar form shows (all by default).
|
||||
pub fn groups(mut self, groups: BarGroups) -> Self {
|
||||
pub fn groups(mut self, groups: TransformGroups) -> Self {
|
||||
self.groups = groups;
|
||||
self
|
||||
}
|
||||
|
||||
/// The Δ toggle between X and Y: X and Y show and move the reference point's offset while it is on.
|
||||
pub fn relative(mut self, on: Bind<'a, bool>) -> Self {
|
||||
self.relative = Some(on);
|
||||
self
|
||||
}
|
||||
|
||||
/// The document's size: X and Y read a typed percentage against its sides.
|
||||
pub fn document(mut self, size: craft_behavior::kurbo::Size) -> Self {
|
||||
self.document = Some(size);
|
||||
self
|
||||
}
|
||||
|
||||
/// The bar form's interpolation select, last in the strip.
|
||||
pub fn interpolation(mut self, interpolation: Bind<'a, Interpolation>) -> Self {
|
||||
self.interpolation = Some(interpolation);
|
||||
@@ -269,7 +291,9 @@ impl<'a> TransformFields<'a> {
|
||||
|
||||
/// Shows the fields.
|
||||
pub fn show(self, ui: &mut Ui) -> TransformFieldsOutput {
|
||||
let TransformFields { label, row, start, linked, size_unit, x, y, bar, groups, interpolation, size_units, enabled } = self;
|
||||
let TransformFields { label, row, start, linked, size_unit, x, y, bar, groups, interpolation, size_units, enabled, relative, document } =
|
||||
self;
|
||||
let _ = (relative, document); // P3(panels-w12): tl.R5, pn.C48
|
||||
let env = Env::of(ui);
|
||||
let mut cells = Cells {
|
||||
words: env.words::<TransformFieldWords>(),
|
||||
@@ -294,7 +318,7 @@ impl<'a> TransformFields<'a> {
|
||||
FieldGroup::new(label).enabled(enabled).show(ui, |ui, cx| cells.rows(ui, cx)).output
|
||||
};
|
||||
let Out { events, unit_picked, linked, interpolation } = cells.out;
|
||||
TransformFieldsOutput { response, events, unit_picked, linked, interpolation }
|
||||
TransformFieldsOutput { response, events, unit_picked, linked, interpolation, relative: None }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -321,7 +345,7 @@ struct Cells<'a> {
|
||||
size_unit: SizeUnit,
|
||||
x: RulerText,
|
||||
y: RulerText,
|
||||
groups: BarGroups,
|
||||
groups: TransformGroups,
|
||||
enabled: bool,
|
||||
out: Out,
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ fn harness(state: BoxState, setup: impl FnOnce(&mut Config)) -> Harness {
|
||||
let mut host = shown_host.borrow_mut();
|
||||
host.guide_events += guide_edits;
|
||||
host.id = output.edit.response.id;
|
||||
host.applied += usize::from(output.apply);
|
||||
host.applied += usize::from(output.apply.is_some());
|
||||
host.discarded += usize::from(output.discard);
|
||||
(host.picked, host.hovered) = (output.picked, output.hovered);
|
||||
for event in &output.edit.events {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
use craft_behavior::EditEvent;
|
||||
use craft_behavior::geometry::quad::BoxState;
|
||||
use craft_behavior::kurbo::{Point, Rect};
|
||||
use craft_draw::ui::transform::{BarGroups, SizeUnit, TransformFields, TransformRow};
|
||||
use craft_draw::ui::transform::{SizeUnit, TransformFields, TransformGroups, TransformRow};
|
||||
use craft_ui::canvas::RulerText;
|
||||
use craft_ui::contract::Bind;
|
||||
use craft_ui::testing::{Fixture, Target, trial};
|
||||
@@ -26,7 +26,7 @@ struct Config {
|
||||
bar: bool,
|
||||
size_unit: SizeUnit,
|
||||
units: Option<RulerText>,
|
||||
groups: BarGroups,
|
||||
groups: TransformGroups,
|
||||
}
|
||||
|
||||
struct Harness {
|
||||
@@ -35,7 +35,7 @@ struct Harness {
|
||||
}
|
||||
|
||||
fn plain() -> Config {
|
||||
Config { bar: false, size_unit: SizeUnit::default(), units: None, groups: BarGroups::ALL }
|
||||
Config { bar: false, size_unit: SizeUnit::default(), units: None, groups: TransformGroups::ALL }
|
||||
}
|
||||
|
||||
fn harness_of(row: TransformRow, config: Config) -> Harness {
|
||||
|
||||
Reference in New Issue
Block a user