Skip to content

armgit / Filee

Public Imported from GitHub
0

Free, open-source file converter. Convert 263 formats offline by drag & drop — images, PDF, Word, Excel, PowerPoint, HWP/HWPX, video, audio, e-books and archives. No upload, no Office needed.

What's new crop slide: from the donut's Crop slice to the dial at the pointer

KnifeLemonaac8d333f7c1
diff --git a/src/Filee.App/Assets/WhatsNew/2.0.0/crop.webp b/src/Filee.App/Assets/WhatsNew/2.0.0/crop.webp
index 280a38de..f9e82206 100644
Binary files a/src/Filee.App/Assets/WhatsNew/2.0.0/crop.webp and b/src/Filee.App/Assets/WhatsNew/2.0.0/crop.webp differ
diff --git a/src/Filee.App/Assets/WhatsNew/2.0.0/slides.json b/src/Filee.App/Assets/WhatsNew/2.0.0/slides.json
index 21a36c1a..83291d4f 100644
--- a/src/Filee.App/Assets/WhatsNew/2.0.0/slides.json
+++ b/src/Filee.App/Assets/WhatsNew/2.0.0/slides.json
@@ -4,7 +4,7 @@
{ "id": "browser", "media": "browser.webp", "poster": 52, "title": "whats_new.2_0_0.browser.title", "text": "whats_new.2_0_0.browser.text" },
{ "id": "flip", "media": "flip.webp", "poster": 75, "title": "whats_new.2_0_0.flip.title", "text": "whats_new.2_0_0.flip.text" },
{ "id": "formats", "media": "formats.webp", "title": "whats_new.2_0_0.formats.title", "text": "whats_new.2_0_0.formats.text" },
- { "id": "crop", "media": "crop.webp", "poster": 72, "title": "whats_new.2_0_0.crop.title", "text": "whats_new.2_0_0.crop.text" },
+ { "id": "crop", "media": "crop.webp", "poster": 57, "title": "whats_new.2_0_0.crop.title", "text": "whats_new.2_0_0.crop.text" },
{ "id": "theme", "media": "theme.webp", "poster": 28, "title": "whats_new.2_0_0.theme.title", "text": "whats_new.2_0_0.theme.text" },
{ "id": "languages", "media": "languages.webp", "title": "whats_new.2_0_0.languages.title", "text": "whats_new.2_0_0.languages.text" },
{ "id": "more", "media": "more.webp", "title": "whats_new.2_0_0.more.title", "text": "whats_new.2_0_0.more.text" }
diff --git a/src/Filee.App/Assets/i18n/ar.json b/src/Filee.App/Assets/i18n/ar.json
index 1e40f8e5..9fe342a7 100644
--- a/src/Filee.App/Assets/i18n/ar.json
+++ b/src/Filee.App/Assets/i18n/ar.json
@@ -879,7 +879,7 @@
"whats_new.2_0_0.formats.title": "صيغ إضافية",
"whats_new.2_0_0.formats.text": "صفحات الويب المحفوظة بصيغة MHTML، والفواتير الإلكترونية بصيغة OFD، وخرائط Shapefile وGeoJSON وKML وGPX، وصور JPEG XR، ونماذج FBX، وقوالب POTM.",
"whats_new.2_0_0.crop.title": "اقتصاص الصور قبل تحويلها",
- "whats_new.2_0_0.crop.text": "يفتح خيار الاقتصاص صورك واحدةً تلو الأخرى. اسحب الإطار واختر نسبة الأبعاد من القرص، ثم اضغط «اقتصاص والتالي».",
+ "whats_new.2_0_0.crop.text": "أفلت الصور على خيار الاقتصاص. اضغط A فوق الصورة لاختيار نسبة الأبعاد في مكانها، ثم اضغط «اقتصاص والتالي».",
"whats_new.2_0_0.theme.title": "مظهر أنعم وبألوانك المفضلة",
"whats_new.2_0_0.theme.text": "اختر أي لون مميّز، وغيّر استدارة الزوايا، واجعل القائمة الدائرية شبه شفافة.",
"whats_new.2_0_0.languages.title": "لغات إضافية في Filee",
diff --git a/src/Filee.App/Assets/i18n/en.json b/src/Filee.App/Assets/i18n/en.json
index 11040a67..287c59be 100644
--- a/src/Filee.App/Assets/i18n/en.json
+++ b/src/Filee.App/Assets/i18n/en.json
@@ -900,7 +900,7 @@
"whats_new.2_0_0.formats.title": "More formats",
"whats_new.2_0_0.formats.text": "Web archives (MHTML), OFD e-invoices, Shapefile, GeoJSON, KML and GPX maps, JPEG XR, FBX models and POTM templates.",
"whats_new.2_0_0.crop.title": "Crop before you convert",
- "whats_new.2_0_0.crop.text": "The Crop slice opens your pictures one by one. Drag the frame, pick a ratio on the dial, then Crop & Next.",
+ "whats_new.2_0_0.crop.text": "Drop pictures on the Crop slice. Press A over a picture to pick a ratio right there, then Crop & Next.",
"whats_new.2_0_0.theme.title": "Softer, and in your colours",
"whats_new.2_0_0.theme.text": "Pick any accent colour, round things off with Softness, and make the donut see-through.",
"whats_new.2_0_0.languages.title": "Filee speaks more languages",
diff --git a/src/Filee.App/Assets/i18n/es.json b/src/Filee.App/Assets/i18n/es.json
index 6a34ed36..31599ceb 100644
--- a/src/Filee.App/Assets/i18n/es.json
+++ b/src/Filee.App/Assets/i18n/es.json
@@ -880,7 +880,7 @@
"whats_new.2_0_0.formats.title": "Más formatos",
"whats_new.2_0_0.formats.text": "Archivos web (MHTML), facturas electrónicas OFD, mapas Shapefile, GeoJSON, KML y GPX, JPEG XR, modelos FBX y plantillas POTM.",
"whats_new.2_0_0.crop.title": "Recorta antes de convertir",
- "whats_new.2_0_0.crop.text": "La porción Recortar abre tus imágenes una a una. Arrastra el marco, elige una proporción en el dial y pulsa «Recortar y seguir».",
+ "whats_new.2_0_0.crop.text": "Suelta imágenes en la porción Recortar. Pulsa A sobre la imagen para elegir la proporción ahí mismo y luego «Recortar y seguir».",
"whats_new.2_0_0.theme.title": "Más suave y con tus colores",
"whats_new.2_0_0.theme.text": "Elige cualquier color de acento, suaviza las formas con Redondeo y haz translúcido el menú circular.",
"whats_new.2_0_0.languages.title": "Filee habla más idiomas",
diff --git a/src/Filee.App/Assets/i18n/hi.json b/src/Filee.App/Assets/i18n/hi.json
index 970c96a3..2beeacf5 100644
--- a/src/Filee.App/Assets/i18n/hi.json
+++ b/src/Filee.App/Assets/i18n/hi.json
@@ -880,7 +880,7 @@
"whats_new.2_0_0.formats.title": "और फ़ॉर्मैट",
"whats_new.2_0_0.formats.text": "वेब आर्काइव (MHTML), OFD ई-इनवॉइस, Shapefile, GeoJSON, KML और GPX नक्शे, JPEG XR, FBX मॉडल और POTM टेम्पलेट।",
"whats_new.2_0_0.crop.title": "बदलने से पहले क्रॉप करें",
- "whats_new.2_0_0.crop.text": "क्रॉप स्लाइस आपके चित्र एक-एक करके खोलता है। फ़्रेम खींचें, डायल पर अनुपात चुनें, फिर “क्रॉप करके अगला” दबाएँ।",
+ "whats_new.2_0_0.crop.text": "चित्रों को क्रॉप स्लाइस पर छोड़ें। चित्र पर A दबाकर वहीं अनुपात चुनें, फिर “क्रॉप करके अगला” दबाएँ।",
"whats_new.2_0_0.theme.title": "ज़्यादा कोमल, आपके रंगों में",
"whats_new.2_0_0.theme.text": "कोई भी एक्सेंट रंग चुनें, कोमलता से आकार गोल करें, और डोनट को अर्ध-पारदर्शी बनाएँ।",
"whats_new.2_0_0.languages.title": "Filee अब और भाषाएँ बोलता है",
diff --git a/src/Filee.App/Assets/i18n/ja.json b/src/Filee.App/Assets/i18n/ja.json
index 4f3fb355..aec6e700 100644
--- a/src/Filee.App/Assets/i18n/ja.json
+++ b/src/Filee.App/Assets/i18n/ja.json
@@ -880,7 +880,7 @@
"whats_new.2_0_0.formats.title": "対応形式が増えました",
"whats_new.2_0_0.formats.text": "Web アーカイブ (MHTML)、OFD 電子請求書、Shapefile・GeoJSON・KML・GPX の地図、JPEG XR、FBX モデル、POTM テンプレート。",
"whats_new.2_0_0.crop.title": "変換の前にトリミング",
- "whats_new.2_0_0.crop.text": "「トリミング」で画像を 1 枚ずつ開けます。枠をドラッグし、ダイヤルで比率を選んで「トリミングして次へ」。",
+ "whats_new.2_0_0.crop.text": "画像を「トリミング」にドロップ。画像の上で A を押すとその場で比率を選べます。続けて「トリミングして次へ」。",
"whats_new.2_0_0.theme.title": "やわらかく、好きな色に",
"whats_new.2_0_0.theme.text": "好きなアクセントカラーを選び、「角の丸み」で丸くして、ドーナツメニューを半透明にできます。",
"whats_new.2_0_0.languages.title": "対応言語が増えました",
diff --git a/src/Filee.App/Assets/i18n/ko.json b/src/Filee.App/Assets/i18n/ko.json
index 29a47af8..ca975504 100644
--- a/src/Filee.App/Assets/i18n/ko.json
+++ b/src/Filee.App/Assets/i18n/ko.json
@@ -900,7 +900,7 @@
"whats_new.2_0_0.formats.title": "더 많은 형식",
"whats_new.2_0_0.formats.text": "웹 보관 파일(MHTML), OFD 전자 세금계산서, Shapefile·GeoJSON·KML·GPX 지도, JPEG XR, FBX 모델, POTM 서식 파일.",
"whats_new.2_0_0.crop.title": "변환하기 전에 자르기",
- "whats_new.2_0_0.crop.text": "자르기 조각을 고르면 그림이 한 장씩 열려요. 틀을 끌고 다이얼에서 비율을 고른 뒤 “자르고 다음으로”를 누르세요.",
+ "whats_new.2_0_0.crop.text": "그림을 자르기 조각에 놓으세요. 그림 위에서 A를 눌러 그 자리에서 비율을 고르고 “자르고 다음으로”를 누르세요.",
"whats_new.2_0_0.theme.title": "더 말랑하게, 내 색으로",
"whats_new.2_0_0.theme.text": "원하는 강조색을 고르고, 말랑함으로 둥글리고, 원형 툴바를 반투명하게 만들 수 있어요.",
"whats_new.2_0_0.languages.title": "더 많은 언어",
diff --git a/src/Filee.App/Assets/i18n/pl.json b/src/Filee.App/Assets/i18n/pl.json
index 7f66d0c0..5ed832fa 100644
--- a/src/Filee.App/Assets/i18n/pl.json
+++ b/src/Filee.App/Assets/i18n/pl.json
@@ -900,7 +900,7 @@
"whats_new.2_0_0.formats.title": "Więcej formatów",
"whats_new.2_0_0.formats.text": "Archiwa stron (MHTML), e-faktury OFD, mapy Shapefile, GeoJSON, KML i GPX, JPEG XR, modele FBX i szablony POTM.",
"whats_new.2_0_0.crop.title": "Kadrowanie przed konwersją",
- "whats_new.2_0_0.crop.text": "Wycinek Kadruj otwiera obrazy po kolei. Przeciągnij ramkę, wybierz proporcje na tarczy i kliknij „Kadruj i dalej”.",
+ "whats_new.2_0_0.crop.text": "Upuść obrazy na wycinek Kadruj. Naciśnij A nad obrazem, wybierz proporcje na miejscu i kliknij „Kadruj i dalej”.",
"whats_new.2_0_0.theme.title": "Łagodniej i w Twoich kolorach",
"whats_new.2_0_0.theme.text": "Wybierz dowolny kolor akcentu, zaokrąglij kształty suwakiem Zaokrąglenie i zrób pierścień półprzezroczystym.",
"whats_new.2_0_0.languages.title": "Filee mówi w większej liczbie języków",
diff --git a/src/Filee.App/Assets/i18n/ru.json b/src/Filee.App/Assets/i18n/ru.json
index c1ef2d79..7c2d633f 100644
--- a/src/Filee.App/Assets/i18n/ru.json
+++ b/src/Filee.App/Assets/i18n/ru.json
@@ -900,7 +900,7 @@
"whats_new.2_0_0.formats.title": "Больше форматов",
"whats_new.2_0_0.formats.text": "Веб-архивы (MHTML), электронные счета OFD, карты Shapefile, GeoJSON, KML и GPX, JPEG XR, модели FBX и шаблоны POTM.",
"whats_new.2_0_0.crop.title": "Обрезка перед конвертацией",
- "whats_new.2_0_0.crop.text": "Сектор «Обрезать» открывает картинки по одной. Перетащите рамку, выберите пропорции на круге и нажмите «Обрезать и дальше».",
+ "whats_new.2_0_0.crop.text": "Бросьте картинки на сектор «Обрезать». Нажмите A над картинкой, выберите пропорции прямо там и нажмите «Обрезать и дальше».",
"whats_new.2_0_0.theme.title": "Мягче и в ваших цветах",
"whats_new.2_0_0.theme.text": "Выберите любой акцентный цвет, скруглите формы настройкой «Скругление» и сделайте круговое меню полупрозрачным.",
"whats_new.2_0_0.languages.title": "Filee говорит на большем числе языков",
diff --git a/src/Filee.App/Assets/i18n/zh-CN.json b/src/Filee.App/Assets/i18n/zh-CN.json
index 73683ee4..762bb381 100644
--- a/src/Filee.App/Assets/i18n/zh-CN.json
+++ b/src/Filee.App/Assets/i18n/zh-CN.json
@@ -900,7 +900,7 @@
"whats_new.2_0_0.formats.title": "更多格式",
"whats_new.2_0_0.formats.text": "网页存档 (MHTML)、OFD 电子发票、Shapefile、GeoJSON、KML 和 GPX 地图、JPEG XR、FBX 模型和 POTM 模板。",
"whats_new.2_0_0.crop.title": "转换前先裁剪",
- "whats_new.2_0_0.crop.text": "“裁剪”会逐张打开图片。拖动选框,在转盘上选择比例,再点“裁剪并下一张”。",
+ "whats_new.2_0_0.crop.text": "把图片拖到“裁剪”上。在图片上按 A,就地选择比例,再点“裁剪并下一张”。",
"whats_new.2_0_0.theme.title": "更柔和,用你的颜色",
"whats_new.2_0_0.theme.text": "任选强调色,用“圆角”让外形更圆润,还能让环形工具栏半透明。",
"whats_new.2_0_0.languages.title": "支持更多语言",
diff --git a/tests/Filee.App.Tests/WhatsNewMedia.cs b/tests/Filee.App.Tests/WhatsNewMedia.cs
index 6291ad3d..770bf402 100644
--- a/tests/Filee.App.Tests/WhatsNewMedia.cs
+++ b/tests/Filee.App.Tests/WhatsNewMedia.cs
@@ -231,11 +231,12 @@ public class WhatsNewMedia
}
/// <summary>
- /// The crop overlay (#307) with three pictures: a corner of the frame is dragged in (the thirds grid fades in, the
- /// size chip follows), the aspect dial opens and 1:1 is picked, then "Crop &amp; next" opens the second picture and
- /// the strip marks the first done. Real pointer input; the canvas's own animations run on the clip's clock
- /// (<see cref="CropCanvas.Clock"/>) and the transitions of the dial, its slices and the strip are played here as the
- /// window's styles time them (the render timer, which runs them in the app, keeps wall-clock time).
+ /// The crop tool (#307): three pictures dragged onto the donut's Crop slice, the crop overlay opening on the first,
+ /// A pressed with the pointer over the picture opening the aspect dial around the pointer, 1:1 picked, then "Crop
+ /// &amp; next" opening the second picture while the strip marks the first done. Real pointer and key input; the
+ /// donut and the canvas animate on the clip's clock (<see cref="CropCanvas.Clock"/>), and the transitions of the
+ /// dial, its slices and the strip are played here as the window's styles time them (the render timer, which runs
+ /// them in the app, keeps wall-clock time).
/// </summary>
private static Clip Crop()
{
@@ -243,6 +244,11 @@ public class WhatsNewMedia
var folder = Directory.CreateTempSubdirectory("filee-whatsnew-crop-").FullName;
var clock = System.Diagnostics.Stopwatch.GetTimestamp();
CropCanvas.Clock = () => clock;
+ // Crop on the donut's front (it ships on the back face, where Tab turns the donut): one drop in a short clip.
+ var images = AppHost.Get<UserDataStore>().Profiles.Single(p => p.Id == "images");
+ var (front, back) = (images.PresetIds.ToList(), images.BackPresetIds?.ToList());
+ images.PresetIds[images.PresetIds.IndexOf("half-size")] = "tool-crop";
+ images.BackPresetIds?.Remove("tool-crop");
CropOverlayWindow? window = null;
try
{
@@ -252,6 +258,9 @@ public class WhatsNewMedia
DrawLandscape(path, i);
return path;
}).ToList();
+ DropOnCrop(clip, files);
+
+ // The overlay opens on the first picture, which settles in on the stepped clock.
var preset = BuiltInData.CreatePresets().Single(p => p.Id == "tool-crop");
var vm = new CropOverlayViewModel(files, preset, AppHost.Get<ILocalizer>(), AppHost.Get<UserDataStore>());
window = new CropOverlayWindow
@@ -263,9 +272,8 @@ public class WhatsNewMedia
};
window.Show();
WaitFor(() => vm.PreviewImage is not null && !vm.IsBusy);
- // The styles' transitions off (played below); the canvas animates again, on the stepped clock.
- window.SettleForCapture();
- window.CropCanvas.PlayAnimations = true;
+ // The styles' transitions off (played below).
+ window.Classes.Set("reduced-motion", true);
Pump();
// 20 frames a second keep the clip within the slides' budget.
@@ -276,42 +284,32 @@ public class WhatsNewMedia
var canvas = window.CropCanvas;
var origin = (Avalonia.Vector)canvas.TranslatePoint(default, window)!.Value;
var image = canvas.CalculateImageBounds().Translate(origin);
- Avalonia.Rect Frame() => canvas.GetScreenCropRect(canvas.CalculateImageBounds()).Translate(origin);
Avalonia.Point Middle(Control control) =>
control.TranslatePoint(new Avalonia.Point(control.Bounds.Width / 2, control.Bounds.Height / 2), window)!.Value;
Avalonia.Point OnPicture(double x, double y) => new(image.X + image.Width * x, image.Y + image.Height * y);
- // Frame 0: the first picture, the frame around all of it.
- scene.Place(new Avalonia.Point(image.Right + 70, image.Center.Y + 30));
- scene.Hold(0.9);
+ scene.Place(OnPicture(0.8, 0.75));
+ scene.Hold(0.7);
- // A corner in: the handle grows under the pointer, the grid shows while it is held.
- scene.MoveTo(Frame().TopLeft, 0.55);
- scene.Hold(0.25);
- scene.Press();
+ // A with the pointer over the picture: the dial opens around the pointer.
+ scene.MoveTo(OnPicture(0.6, 0.45), 0.45);
scene.Hold(0.2);
- scene.MoveTo(OnPicture(0.22, 0.14), 0.9);
- scene.Hold(0.15);
- scene.Release();
- scene.Hold(0.5);
-
- // The aspect dial grows out of its button; 1:1.
- var dialButton = window.GetVisualDescendants().OfType<Button>().Single(b => b.Name == "DialButton");
- scene.MoveTo(Middle(dialButton), 0.55);
- scene.Hold(0.15);
- scene.Click();
+ scene.Key("A", () => window.KeyPress(Key.A, RawInputModifiers.None, PhysicalKey.A, "a"));
+ Assert.True(vm.IsAspectDialOpen);
scene.Hold(0.45);
+ window.KeyRelease(Key.A, RawInputModifiers.None, PhysicalKey.A, "a");
+ scene.HideKey();
var dial = window.AspectDial;
var square = dial.Segments.ToList().FindIndex(s => s.Mode == "1:1");
var onSquare = dial.TranslatePoint(DonutGeometry.PointAt(new Avalonia.Point(dial.Bounds.Width / 2, dial.Bounds.Height / 2),
dial.OuterRadius - 14, DonutGeometry.MidAngle(square, dial.Segments.Count())), window)!.Value; // beside its label
- scene.MoveTo(onSquare, 0.5);
+ scene.MoveTo(onSquare, 0.45);
scene.Hold(0.35);
- // Shown with reduced motion: the dial open, the pointer on 1:1.
+ // Shown with reduced motion: the dial around the pointer, on 1:1.
clip.MarkPoster();
scene.Click();
Assert.Equal("1:1", vm.SelectedAspect);
- scene.Hold(1.1);
+ scene.Hold(1.0);
// Crop & next: the second picture settles in, the strip marks the first one done.
var primary = window.GetVisualDescendants().OfType<Button>().Single(b => b.Name == "PrimaryButton");
@@ -330,6 +328,7 @@ public class WhatsNewMedia
{
window?.Close();
CropCanvas.Clock = System.Diagnostics.Stopwatch.GetTimestamp;
+ (images.PresetIds, images.BackPresetIds) = (front, back);
try
{
Directory.Delete(folder, recursive: true);
@@ -339,6 +338,52 @@ public class WhatsNewMedia
return clip;
}
+ /// <summary>
+ /// The pictures dragged with the gesture key: the donut opens around the pointer, which goes onto the Crop slice
+ /// and drops there (what RadialWindow does with a drag over it, on the donut's own clock).
+ /// </summary>
+ private static void DropOnCrop(Clip clip, IReadOnlyList<string> files)
+ {
+ var (window, vm) = OpenDonut(files, clickMode: false);
+ var donut = window.DonutControl;
+ try
+ {
+ var crop = vm.Presets.ToList().FindIndex(p => p.Id == "tool-crop");
+ Assert.True(crop >= 0, "Crop isn't on the donut");
+ var center = new Avalonia.Point(donut.Bounds.Width / 2, donut.Bounds.Height / 2);
+ var inner = donut.OuterRadius * donut.HoleRatio;
+ Avalonia.Point InWindow(Avalonia.Point p) => donut.TranslatePoint(p, window)!.Value;
+
+ // Its own frame loop would run on wall-clock time: only its clock, stepped here, moves it.
+ var scene = new Scene(window, clip) { FrameLength = 1 / 20.0, RunsRenderTimer = false };
+ scene.Steps.Add(dt =>
+ {
+ var at = window.TranslatePoint(scene.Pointer, donut)!.Value;
+ var hit = donut.HitTest(at);
+ donut.SetExternalHit(hit, at);
+ vm.ShowHint(hit.Kind == DonutHitKind.Segment ? hit.Index : -1, -1, hit.Kind == DonutHitKind.Center);
+ KeepFramesComing(donut);
+ donut.Advance(dt);
+ KeepFramesComing(donut);
+ });
+ scene.Grab(true); // the files are being dragged
+ scene.Place(InWindow(center + new Avalonia.Vector(6, 8)));
+ scene.ShowKey("Ctrl", down: true);
+ donut.PlayOpenAnimation();
+ scene.Hold(0.6);
+ scene.MoveTo(InWindow(DonutGeometry.PointAt(center, (inner + donut.OuterRadius) / 2 + 6,
+ DonutGeometry.MidAngle(crop, donut.Items!.Count) + 0.05)), 0.6);
+ scene.Hold(0.45);
+ Assert.Equal(new DonutHit(DonutHitKind.Segment, crop), donut.HitTest(window.TranslatePoint(scene.Pointer, donut)!.Value));
+ scene.HideKey();
+ }
+ finally
+ {
+ window.Close();
+ donut.SetExternalHighlight(-1);
+ }
+ }
+
/// <summary>
/// What CropOverlayWindow.axaml's transitions do, on the clip's clock: the dial grows out of its button (opacity
/// 0.16 s, scale 0.55 → 1 in 0.34 s) and shrinks away, a slice under the pointer moves out (0.24 s), and the strip's
@@ -591,6 +636,8 @@ public class WhatsNewMedia
private sealed class Scene(TopLevel window, Clip clip, string? version = null)
{
private bool _grabbed;
+ private readonly Glide _key = new(0, 0.12, t => t);
+ private (string Label, bool Down, bool Shown) _keyCap;
public Avalonia.Point Pointer { get; private set; }
public bool Pressed { get; private set; }
@@ -599,6 +646,12 @@ public class WhatsNewMedia
/// <summary>Seconds per frame.</summary>
public double FrameLength { get; init; } = Frame;
+ /// <summary>
+ /// False for a window whose animations the clip steps itself (the donut): the render timer would also run its
+ /// frame loop, on wall-clock time.
+ /// </summary>
+ public bool RunsRenderTimer { get; init; } = true;
+
/// <summary>Puts the pointer somewhere at once (before the first frame).</summary>
public void Place(Avalonia.Point at)
{
@@ -617,11 +670,29 @@ public class WhatsNewMedia
for (var i = 0; i < 3; i++)
{
Dispatcher.UIThread.RunJobs();
- AvaloniaHeadlessPlatform.ForceRenderTimerTick();
+ if (RunsRenderTimer)
+ AvaloniaHeadlessPlatform.ForceRenderTimerTick();
}
if (pointer is not null)
Pointer = pointer();
- clip.Add(Capture(window, version, pointer: Pointer, pressed: Pressed || _grabbed), (int)Math.Round(FrameLength * 1000));
+ var frame = Capture(window, version, pointer: Pointer, pressed: Pressed || _grabbed);
+ var shown = _key.Step(_keyCap.Shown ? 1 : 0, FrameLength);
+ if (shown > 0.01)
+ DrawKeyCap(frame, _keyCap.Label, shown, _keyCap.Down);
+ clip.Add(frame, (int)Math.Round(FrameLength * 1000));
+ }
+
+ /// <summary>A keycap at the bottom left, as the demo videos show the keys held.</summary>
+ public void ShowKey(string label, bool down) => _keyCap = (label, down, true);
+
+ public void HideKey() => _keyCap = _keyCap with { Shown = false };
+
+ /// <summary>A key pressed: shown down, and <paramref name="press"/> sends it.</summary>
+ public void Key(string label, Action press)
+ {
+ ShowKey(label, down: true);
+ press();
+ Tick();
}
public void Hold(double seconds)
@@ -857,6 +928,29 @@ public class WhatsNewMedia
return canvas;
}
+ /// <summary>A keyboard key at the bottom left of the canvas, <paramref name="opacity"/> 0 to 1, pressed or not.</summary>
+ private static void DrawKeyCap(MagickImage canvas, string label, double opacity, bool down)
+ {
+ var font = Path.Combine(RepositoryRoot, "src", "Filee.App", "Assets", "Fonts", "NotoSans-Bold.ttf");
+ var width = Math.Max(46, 22 + 11 * label.Length);
+ var (x, y) = (40.0, CanvasHeight - 70.0 + (down ? 2 : 0));
+ var alpha = (byte)Math.Round(255 * opacity);
+ MagickColor Colour(string hex, double share = 1)
+ {
+ var c = new MagickColor(hex);
+ return new MagickColor(c.R, c.G, c.B, (byte)Math.Round(alpha * share));
+ }
+ var drawing = new Drawables()
+ .StrokeColor(Colour("#000000", 0)).FillColor(Colour("#000000", 0.14)).RoundRectangle(x, y + 4, x + width, y + 38, 9, 9)
+ .FillColor(Colour("#FFFFFF")).StrokeColor(Colour(down ? "#7F77DD" : "#D6D3CB")).StrokeWidth(down ? 1.6 : 1)
+ .RoundRectangle(x, y, x + width, y + 34, 9, 9);
+ if (File.Exists(font))
+ drawing.Font(font);
+ drawing.FontPointSize(15).StrokeColor(Colour("#000000", 0)).FillColor(Colour("#1F1E1D"))
+ .TextAlignment(TextAlignment.Center).Text(x + width / 2.0, y + 23, label)
+ .Draw(canvas);
+ }
+
/// <summary>An arrow pointer with its tip at <paramref name="tip"/>, a little smaller while pressed.</summary>
private static void DrawPointer(MagickImage canvas, PointD tip, bool pressed)
{