mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-16 23:24:24 +00:00
Merge remote-tracking branch 'upstream/next' into area/fwb2-f12
This commit is contained in:
Generated
+94
@@ -1396,53 +1396,145 @@ dependencies = [
|
||||
name = "craft"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"craft-aaf",
|
||||
"craft-aep",
|
||||
"craft-affinity",
|
||||
"craft-ai-core",
|
||||
"craft-assuan",
|
||||
"craft-atomic",
|
||||
"craft-audio",
|
||||
"craft-automation",
|
||||
"craft-behavior",
|
||||
"craft-browse",
|
||||
"craft-captions",
|
||||
"craft-cfb",
|
||||
"craft-cms",
|
||||
"craft-codepage",
|
||||
"craft-color",
|
||||
"craft-crs",
|
||||
"craft-crw",
|
||||
"craft-csv",
|
||||
"craft-dav",
|
||||
"craft-designcraft-format",
|
||||
"craft-dialogs",
|
||||
"craft-doc",
|
||||
"craft-doc-binary",
|
||||
"craft-docpath",
|
||||
"craft-document-bundle",
|
||||
"craft-docx",
|
||||
"craft-dpx",
|
||||
"craft-draw",
|
||||
"craft-drawingml",
|
||||
"craft-dwg",
|
||||
"craft-dxf",
|
||||
"craft-ecproj-format",
|
||||
"craft-eps",
|
||||
"craft-epub",
|
||||
"craft-ews",
|
||||
"craft-exr",
|
||||
"craft-fig",
|
||||
"craft-figcraft-format",
|
||||
"craft-figma-rest",
|
||||
"craft-file-formats",
|
||||
"craft-file-import",
|
||||
"craft-flags",
|
||||
"craft-flow",
|
||||
"craft-font-catalog",
|
||||
"craft-font-manager",
|
||||
"craft-font-store",
|
||||
"craft-font-subset",
|
||||
"craft-gainmap",
|
||||
"craft-gcode",
|
||||
"craft-gif",
|
||||
"craft-hdr",
|
||||
"craft-heif",
|
||||
"craft-host",
|
||||
"craft-html",
|
||||
"craft-i18n",
|
||||
"craft-ical",
|
||||
"craft-idml",
|
||||
"craft-imaging",
|
||||
"craft-indd",
|
||||
"craft-jmap",
|
||||
"craft-jpeg",
|
||||
"craft-keymap",
|
||||
"craft-kiwi",
|
||||
"craft-kra",
|
||||
"craft-latex",
|
||||
"craft-layers",
|
||||
"craft-lottie",
|
||||
"craft-markdown",
|
||||
"craft-materialx",
|
||||
"craft-math",
|
||||
"craft-media",
|
||||
"craft-menu",
|
||||
"craft-mesh",
|
||||
"craft-metadata",
|
||||
"craft-metafile",
|
||||
"craft-midi",
|
||||
"craft-mime",
|
||||
"craft-odf",
|
||||
"craft-ods",
|
||||
"craft-offcrypto",
|
||||
"craft-opc",
|
||||
"craft-openpgp",
|
||||
"craft-ora",
|
||||
"craft-pages",
|
||||
"craft-pcraft-bundle",
|
||||
"craft-pcraft-format",
|
||||
"craft-pdf 0.1.0",
|
||||
"craft-pdn",
|
||||
"craft-penpot",
|
||||
"craft-pkcs7",
|
||||
"craft-platform",
|
||||
"craft-plotter",
|
||||
"craft-pptx",
|
||||
"craft-prc",
|
||||
"craft-prepress",
|
||||
"craft-print",
|
||||
"craft-proof",
|
||||
"craft-psd",
|
||||
"craft-pst",
|
||||
"craft-quit",
|
||||
"craft-raster-codecs",
|
||||
"craft-raw",
|
||||
"craft-review",
|
||||
"craft-rtf",
|
||||
"craft-scraft-format",
|
||||
"craft-settings",
|
||||
"craft-sf2",
|
||||
"craft-sheet",
|
||||
"craft-silhouette-studio",
|
||||
"craft-sketch",
|
||||
"craft-stencilcraft-document",
|
||||
"craft-stencilcraft-format",
|
||||
"craft-stream-codecs",
|
||||
"craft-svg",
|
||||
"craft-table",
|
||||
"craft-text",
|
||||
"craft-tga",
|
||||
"craft-theme",
|
||||
"craft-theme-store",
|
||||
"craft-tiff",
|
||||
"craft-time",
|
||||
"craft-timeline",
|
||||
"craft-ui",
|
||||
"craft-update",
|
||||
"craft-vcard",
|
||||
"craft-vectorcraft-format",
|
||||
"craft-vectordrawable",
|
||||
"craft-video",
|
||||
"craft-web-api",
|
||||
"craft-web-host",
|
||||
"craft-webp",
|
||||
"craft-window",
|
||||
"craft-wordmodel",
|
||||
"craft-xcf",
|
||||
"craft-xls",
|
||||
"craft-xlsx",
|
||||
"craft-xml",
|
||||
"craft-y4m",
|
||||
"craft-zip",
|
||||
"egui",
|
||||
"toml",
|
||||
]
|
||||
@@ -2812,6 +2904,7 @@ version = "0.1.0"
|
||||
dependencies = [
|
||||
"craft-atomic",
|
||||
"craft-host",
|
||||
"craft-settings",
|
||||
"dirs",
|
||||
"serde",
|
||||
"serde_json",
|
||||
@@ -2927,6 +3020,7 @@ dependencies = [
|
||||
"craft-behavior",
|
||||
"craft-font-manager",
|
||||
"craft-host",
|
||||
"craft-keymap",
|
||||
"craft-theme",
|
||||
"craft-ui",
|
||||
"egui",
|
||||
|
||||
@@ -138,6 +138,7 @@ craft-sheet = { path = "crates/sheet" }
|
||||
craft-sketch = { path = "crates/sketch" }
|
||||
craft-review = { path = "crates/review" }
|
||||
craft-settings = { path = "crates/settings" }
|
||||
craft-figcraft-format = { path = "crates/figcraft-format" }
|
||||
craft-scraft-format = { path = "crates/scraft-format" }
|
||||
craft-time = { path = "crates/time" }
|
||||
craft-silhouette-studio = { path = "crates/silhouette-studio" }
|
||||
|
||||
@@ -390,6 +390,10 @@ fn stage(
|
||||
.map_err(|e| permissions_error(e, path))
|
||||
})
|
||||
.and_then(|()| fs.sync(&file).map_err(|e| write_error(e, path, dir, existed)));
|
||||
#[allow(
|
||||
clippy::drop_non_drop,
|
||||
reason = "File has no drop glue on wasm32-unknown-unknown; on other targets the drop closes it before the next step"
|
||||
)]
|
||||
drop(file);
|
||||
if written.is_err() {
|
||||
let _ = fs.remove(&tmp);
|
||||
@@ -489,6 +493,10 @@ fn copy_new(fs: &dyn AtomicFs, tmp: &Path, target: &Path, permissions: NewFilePe
|
||||
}
|
||||
fs.sync(&to)
|
||||
});
|
||||
#[allow(
|
||||
clippy::drop_non_drop,
|
||||
reason = "File has no drop glue on wasm32-unknown-unknown; on other targets the drop closes it before the next step"
|
||||
)]
|
||||
drop(to);
|
||||
if copied.is_err() {
|
||||
let _ = fs.remove(target);
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
use std::cell::{Cell, RefCell};
|
||||
use std::rc::Rc;
|
||||
|
||||
use craft_automation::synthetic::{At, MAX_CLICKS, NOT_FINITE, MAX_SCREEN_POINT, NO_DOCUMENT, input_method};
|
||||
use craft_automation::synthetic::{At, MAX_CLICKS, MAX_SCREEN_POINT, NO_DOCUMENT, NOT_FINITE, input_method};
|
||||
use craft_ui::contract::{Bind, Show as _};
|
||||
use craft_ui::runtime::egui::injected::hook_without_pass;
|
||||
use craft_ui::runtime::windows::WindowHost;
|
||||
|
||||
@@ -61,6 +61,98 @@ craft-web-api = { workspace = true, optional = true }
|
||||
craft-web-host = { workspace = true, optional = true }
|
||||
craft-window = { workspace = true, optional = true }
|
||||
craft-ui = { workspace = true, optional = true }
|
||||
craft-aaf = { workspace = true, optional = true }
|
||||
craft-aep = { workspace = true, optional = true }
|
||||
craft-affinity = { workspace = true, optional = true }
|
||||
craft-assuan = { workspace = true, optional = true }
|
||||
craft-captions = { workspace = true, optional = true }
|
||||
craft-cfb = { workspace = true, optional = true }
|
||||
craft-codepage = { workspace = true, optional = true }
|
||||
craft-crs = { workspace = true, optional = true }
|
||||
craft-csv = { workspace = true, optional = true }
|
||||
craft-dav = { workspace = true, optional = true }
|
||||
craft-designcraft-format = { workspace = true, optional = true }
|
||||
craft-doc-binary = { workspace = true, optional = true }
|
||||
craft-document-bundle = { workspace = true, optional = true }
|
||||
craft-docx = { workspace = true, optional = true }
|
||||
craft-dpx = { workspace = true, optional = true }
|
||||
craft-drawingml = { workspace = true, optional = true }
|
||||
craft-dwg = { workspace = true, optional = true }
|
||||
craft-dxf = { workspace = true, optional = true }
|
||||
craft-eps = { workspace = true, optional = true }
|
||||
craft-epub = { workspace = true, optional = true }
|
||||
craft-ews = { workspace = true, optional = true }
|
||||
craft-exr = { workspace = true, optional = true }
|
||||
craft-fig = { workspace = true, optional = true }
|
||||
craft-figcraft-format = { workspace = true, optional = true }
|
||||
craft-figma-rest = { workspace = true, optional = true }
|
||||
craft-file-formats = { workspace = true, optional = true }
|
||||
craft-file-import = { workspace = true, optional = true }
|
||||
craft-flags = { workspace = true, optional = true }
|
||||
craft-flow = { workspace = true, optional = true }
|
||||
craft-gainmap = { workspace = true, optional = true }
|
||||
craft-gcode = { workspace = true, optional = true }
|
||||
craft-gif = { workspace = true, optional = true }
|
||||
craft-hdr = { workspace = true, optional = true }
|
||||
craft-heif = { workspace = true, optional = true }
|
||||
craft-html = { workspace = true, optional = true }
|
||||
craft-ical = { workspace = true, optional = true }
|
||||
craft-idml = { workspace = true, optional = true }
|
||||
craft-indd = { workspace = true, optional = true }
|
||||
craft-jmap = { workspace = true, optional = true }
|
||||
craft-kiwi = { workspace = true, optional = true }
|
||||
craft-kra = { workspace = true, optional = true }
|
||||
craft-latex = { workspace = true, optional = true }
|
||||
craft-lottie = { workspace = true, optional = true }
|
||||
craft-markdown = { workspace = true, optional = true }
|
||||
craft-materialx = { workspace = true, optional = true }
|
||||
craft-math = { workspace = true, optional = true }
|
||||
craft-mesh = { workspace = true, optional = true }
|
||||
craft-metadata = { workspace = true, optional = true }
|
||||
craft-metafile = { workspace = true, optional = true }
|
||||
craft-midi = { workspace = true, optional = true }
|
||||
craft-mime = { workspace = true, optional = true }
|
||||
craft-odf = { workspace = true, optional = true }
|
||||
craft-ods = { workspace = true, optional = true }
|
||||
craft-offcrypto = { workspace = true, optional = true }
|
||||
craft-opc = { workspace = true, optional = true }
|
||||
craft-openpgp = { workspace = true, optional = true }
|
||||
craft-ora = { workspace = true, optional = true }
|
||||
craft-pcraft-bundle = { workspace = true, optional = true }
|
||||
craft-pdn = { workspace = true, optional = true }
|
||||
craft-penpot = { workspace = true, optional = true }
|
||||
craft-pkcs7 = { workspace = true, optional = true }
|
||||
craft-plotter = { workspace = true, optional = true }
|
||||
craft-pptx = { workspace = true, optional = true }
|
||||
craft-prc = { workspace = true, optional = true }
|
||||
craft-psd = { workspace = true, optional = true }
|
||||
craft-pst = { workspace = true, optional = true }
|
||||
craft-raster-codecs = { workspace = true, optional = true }
|
||||
craft-raw = { workspace = true, optional = true }
|
||||
craft-rtf = { workspace = true, optional = true }
|
||||
craft-scraft-format = { workspace = true, optional = true }
|
||||
craft-sf2 = { workspace = true, optional = true }
|
||||
craft-sheet = { workspace = true, optional = true }
|
||||
craft-silhouette-studio = { workspace = true, optional = true }
|
||||
craft-sketch = { workspace = true, optional = true }
|
||||
craft-stencilcraft-document = { workspace = true, optional = true }
|
||||
craft-stencilcraft-format = { workspace = true, optional = true }
|
||||
craft-stream-codecs = { workspace = true, optional = true }
|
||||
craft-svg = { workspace = true, optional = true }
|
||||
craft-tga = { workspace = true, optional = true }
|
||||
craft-tiff = { workspace = true, optional = true }
|
||||
craft-time = { workspace = true, optional = true }
|
||||
craft-vcard = { workspace = true, optional = true }
|
||||
craft-vectordrawable = { workspace = true, optional = true }
|
||||
craft-video = { workspace = true, optional = true }
|
||||
craft-webp = { workspace = true, optional = true }
|
||||
craft-wordmodel = { workspace = true, optional = true }
|
||||
craft-xcf = { workspace = true, optional = true }
|
||||
craft-xls = { workspace = true, optional = true }
|
||||
craft-xlsx = { workspace = true, optional = true }
|
||||
craft-xml = { workspace = true, optional = true }
|
||||
craft-y4m = { workspace = true, optional = true }
|
||||
craft-zip = { workspace = true, optional = true }
|
||||
|
||||
[features]
|
||||
ui = [
|
||||
@@ -107,18 +199,39 @@ screen-testing = [
|
||||
"craft-timeline?/screen-testing",
|
||||
"craft-update?/screen-testing",
|
||||
]
|
||||
aaf = ["dep:craft-aaf"]
|
||||
|
||||
aep = ["dep:craft-aep"]
|
||||
|
||||
affinity = ["dep:craft-affinity"]
|
||||
affinity-synth = ["affinity", "craft-affinity/synth"]
|
||||
|
||||
ai-core = ["dep:craft-ai-core"]
|
||||
|
||||
assuan = ["dep:craft-assuan"]
|
||||
|
||||
atomic = ["dep:craft-atomic"]
|
||||
|
||||
audio = ["dep:craft-audio"]
|
||||
audio-aac-decode = ["audio", "craft-audio/aac-decode"]
|
||||
audio-aac-encode = ["audio", "craft-audio/aac-encode"]
|
||||
audio-ac3-decode = ["audio", "craft-audio/ac3-decode"]
|
||||
audio-ac3-encode = ["audio", "craft-audio/ac3-encode"]
|
||||
audio-alac-decode = ["audio", "craft-audio/alac-decode"]
|
||||
audio-alac-encode = ["audio", "craft-audio/alac-encode"]
|
||||
audio-decode = ["audio", "craft-audio/decode"]
|
||||
audio-decode-native = ["audio", "craft-audio/decode-native"]
|
||||
audio-eac3-encode = ["audio", "craft-audio/eac3-encode"]
|
||||
audio-encode = ["audio", "craft-audio/encode"]
|
||||
audio-flac-encode = ["audio", "craft-audio/flac-encode"]
|
||||
audio-lossless-encode = ["audio", "craft-audio/lossless-encode"]
|
||||
audio-mp3-decode = ["audio", "craft-audio/mp3-decode"]
|
||||
audio-mp3-encode = ["audio", "craft-audio/mp3-encode"]
|
||||
audio-mpa-decode = ["audio", "craft-audio/mpa-decode"]
|
||||
audio-opus-decode = ["audio", "craft-audio/opus-decode"]
|
||||
audio-pcm-encode = ["audio", "craft-audio/pcm-encode"]
|
||||
audio-peaks = ["audio", "craft-audio/peaks"]
|
||||
audio-rayon = ["audio", "craft-audio/rayon"]
|
||||
audio-serde = ["audio", "craft-audio/serde"]
|
||||
audio-symphonia = ["audio", "craft-audio/symphonia"]
|
||||
|
||||
@@ -126,23 +239,75 @@ automation = ["dep:craft-automation", "keymap"]
|
||||
|
||||
browse = ["dep:craft-browse"]
|
||||
|
||||
captions = ["dep:craft-captions"]
|
||||
|
||||
cfb = ["dep:craft-cfb"]
|
||||
|
||||
cms = ["dep:craft-cms"]
|
||||
|
||||
codepage = ["dep:craft-codepage"]
|
||||
|
||||
color = ["dep:craft-color", "keymap", "settings", "window", "platform"]
|
||||
|
||||
crs = ["dep:craft-crs"]
|
||||
|
||||
crw = ["dep:craft-crw"]
|
||||
|
||||
csv = ["dep:craft-csv"]
|
||||
|
||||
dav = ["dep:craft-dav"]
|
||||
|
||||
designcraft-format = ["dep:craft-designcraft-format"]
|
||||
|
||||
dialogs = ["dep:craft-dialogs"] # native only: rfd's folder picker and file paths
|
||||
|
||||
doc = ["dep:craft-doc"]
|
||||
doc-pcraft-pixels = ["doc", "craft-doc/pcraft-pixels"]
|
||||
|
||||
doc-binary = ["dep:craft-doc-binary"]
|
||||
|
||||
docpath = ["dep:craft-docpath"]
|
||||
|
||||
document-bundle = ["dep:craft-document-bundle"]
|
||||
|
||||
docx = ["dep:craft-docx"]
|
||||
|
||||
dpx = ["dep:craft-dpx"]
|
||||
|
||||
draw = ["dep:craft-draw", "keymap", "color", "settings"]
|
||||
|
||||
drawingml = ["dep:craft-drawingml"]
|
||||
|
||||
dwg = ["dep:craft-dwg"]
|
||||
|
||||
dxf = ["dep:craft-dxf"]
|
||||
|
||||
ecproj-format = ["dep:craft-ecproj-format"]
|
||||
|
||||
eps = ["dep:craft-eps"]
|
||||
eps-paths = ["eps", "craft-eps/paths"]
|
||||
|
||||
epub = ["dep:craft-epub"]
|
||||
|
||||
ews = ["dep:craft-ews"]
|
||||
|
||||
exr = ["dep:craft-exr"]
|
||||
exr-decode = ["exr", "craft-exr/decode"]
|
||||
|
||||
fig = ["dep:craft-fig"]
|
||||
|
||||
figcraft-format = ["dep:craft-figcraft-format"]
|
||||
|
||||
figma-rest = ["dep:craft-figma-rest"]
|
||||
|
||||
file-formats = ["dep:craft-file-formats"]
|
||||
|
||||
file-import = ["dep:craft-file-import"]
|
||||
|
||||
flags = ["dep:craft-flags"]
|
||||
|
||||
flow = ["dep:craft-flow"]
|
||||
|
||||
font-catalog = ["dep:craft-font-catalog"]
|
||||
font-catalog-system = ["font-catalog", "craft-font-catalog/system"]
|
||||
|
||||
@@ -153,46 +318,141 @@ font-store-bundled-index = ["font-store", "craft-font-store/bundled-index"]
|
||||
|
||||
font-subset = ["dep:craft-font-subset"] # native only: HarfBuzz's C++ builds with the target's C++ compiler
|
||||
|
||||
gainmap = ["dep:craft-gainmap"]
|
||||
|
||||
gcode = ["dep:craft-gcode"]
|
||||
|
||||
gif = ["dep:craft-gif"]
|
||||
gif-frames = ["gif", "craft-gif/frames"]
|
||||
|
||||
hdr = ["dep:craft-hdr"]
|
||||
|
||||
heif = ["dep:craft-heif"]
|
||||
heif-decode = ["heif", "craft-heif/decode"]
|
||||
heif-metadata = ["heif", "craft-heif/metadata"]
|
||||
heif-testdata = ["heif", "craft-heif/testdata"]
|
||||
|
||||
html = ["dep:craft-html"]
|
||||
html-flow = ["html", "craft-html/flow"]
|
||||
|
||||
i18n-collate = ["craft-i18n/collate"]
|
||||
|
||||
ical = ["dep:craft-ical"]
|
||||
|
||||
idml = ["dep:craft-idml"]
|
||||
|
||||
imaging = ["dep:craft-imaging", "keymap"]
|
||||
|
||||
indd = ["dep:craft-indd"]
|
||||
|
||||
jmap = ["dep:craft-jmap"]
|
||||
|
||||
jpeg = ["dep:craft-jpeg"]
|
||||
|
||||
keymap = ["dep:craft-keymap"]
|
||||
keymap-egui = ["keymap", "craft-keymap/egui"]
|
||||
|
||||
kiwi = ["dep:craft-kiwi"]
|
||||
|
||||
kra = ["dep:craft-kra"]
|
||||
|
||||
latex = ["dep:craft-latex"]
|
||||
|
||||
layers = ["dep:craft-layers"]
|
||||
|
||||
lottie = ["dep:craft-lottie"]
|
||||
|
||||
markdown = ["dep:craft-markdown"]
|
||||
|
||||
materialx = ["dep:craft-materialx"]
|
||||
|
||||
math = ["dep:craft-math"]
|
||||
|
||||
media = ["dep:craft-media"]
|
||||
media-avi = ["media", "craft-media/avi"]
|
||||
media-bitstream = ["media", "craft-media/bitstream"]
|
||||
media-isobmff = ["media", "craft-media/isobmff"]
|
||||
media-matroska = ["media", "craft-media/matroska"]
|
||||
media-mpegts = ["media", "craft-media/mpegts"]
|
||||
media-mxf = ["media", "craft-media/mxf"]
|
||||
media-ogg = ["media", "craft-media/ogg"]
|
||||
media-serde = ["media", "craft-media/serde"]
|
||||
|
||||
menu = ["dep:craft-menu"]
|
||||
|
||||
mesh = ["dep:craft-mesh"]
|
||||
mesh-fbx = ["mesh", "craft-mesh/fbx"]
|
||||
mesh-gltf = ["mesh", "craft-mesh/gltf"]
|
||||
mesh-obj = ["mesh", "craft-mesh/obj"]
|
||||
mesh-ply = ["mesh", "craft-mesh/ply"]
|
||||
mesh-stl = ["mesh", "craft-mesh/stl"]
|
||||
mesh-threemf = ["mesh", "craft-mesh/threemf"]
|
||||
|
||||
metadata = ["dep:craft-metadata"]
|
||||
|
||||
metafile = ["dep:craft-metafile"]
|
||||
metafile-write = ["metafile", "craft-metafile/write"]
|
||||
|
||||
midi = ["dep:craft-midi"]
|
||||
midi-serde = ["midi", "craft-midi/serde"]
|
||||
|
||||
mime = ["dep:craft-mime"]
|
||||
mime-detect = ["mime", "craft-mime/detect"]
|
||||
|
||||
odf = ["dep:craft-odf"]
|
||||
odf-text = ["odf", "craft-odf/text"]
|
||||
|
||||
ods = ["dep:craft-ods"]
|
||||
|
||||
offcrypto = ["dep:craft-offcrypto"]
|
||||
|
||||
opc = ["dep:craft-opc"]
|
||||
opc-test-support = ["opc", "craft-opc/test-support"]
|
||||
|
||||
openpgp = ["dep:craft-openpgp"]
|
||||
|
||||
ora = ["dep:craft-ora"]
|
||||
|
||||
pages = ["dep:craft-pages"]
|
||||
|
||||
pcraft-bundle = ["dep:craft-pcraft-bundle"]
|
||||
|
||||
pcraft-format = ["dep:craft-pcraft-format"]
|
||||
|
||||
pdf = ["dep:craft-pdf"]
|
||||
pdf-cos = ["pdf", "craft-pdf/cos"]
|
||||
pdf-crypt = ["pdf", "craft-pdf/crypt"]
|
||||
pdf-filters = ["pdf", "craft-pdf/filters"]
|
||||
pdf-interpret = ["pdf", "craft-pdf/interpret"]
|
||||
pdf-paths = ["pdf", "craft-pdf/paths"]
|
||||
pdf-raster = ["pdf", "craft-pdf/raster"]
|
||||
pdf-read = ["pdf", "craft-pdf/read"]
|
||||
pdf-write = ["pdf", "craft-pdf/write"]
|
||||
pdf-write-pdf = ["pdf", "craft-pdf/write-pdf"]
|
||||
pdf-write-simple-text = ["pdf", "craft-pdf/write-simple-text"]
|
||||
|
||||
pdn = ["dep:craft-pdn"]
|
||||
|
||||
penpot = ["dep:craft-penpot"]
|
||||
|
||||
pkcs7 = ["dep:craft-pkcs7"]
|
||||
|
||||
platform = ["dep:craft-platform"]
|
||||
platform-appearance = ["platform", "craft-platform/appearance"]
|
||||
platform-browser = ["platform", "craft-platform/browser"]
|
||||
platform-clipboard = ["platform", "craft-platform/clipboard"]
|
||||
platform-pointer = ["platform", "craft-platform/pointer"]
|
||||
platform-screen = ["platform", "craft-platform/screen"]
|
||||
platform-testing = ["platform", "craft-platform/testing"]
|
||||
platform-usage = ["platform", "craft-platform/usage"]
|
||||
|
||||
plotter = ["dep:craft-plotter"]
|
||||
plotter-serde = ["plotter", "craft-plotter/serde"]
|
||||
|
||||
pptx = ["dep:craft-pptx"]
|
||||
|
||||
prc = ["dep:craft-prc"]
|
||||
|
||||
prepress = ["dep:craft-prepress"]
|
||||
prepress-flatten = ["prepress", "craft-prepress/flatten"]
|
||||
|
||||
@@ -200,12 +460,67 @@ print = ["dep:craft-print"]
|
||||
|
||||
proof = ["dep:craft-proof"]
|
||||
|
||||
psd = ["dep:craft-psd"]
|
||||
psd-corpus = ["psd", "craft-psd/corpus"]
|
||||
psd-serde = ["psd", "craft-psd/serde"]
|
||||
psd-testgen = ["psd", "craft-psd/testgen"]
|
||||
|
||||
pst = ["dep:craft-pst"]
|
||||
pst-test-writer = ["pst", "craft-pst/test-writer"]
|
||||
|
||||
quit = ["dep:craft-quit"]
|
||||
|
||||
raster-codecs = ["dep:craft-raster-codecs"]
|
||||
|
||||
raw = ["dep:craft-raw"]
|
||||
raw-arw = ["raw", "craft-raw/arw"]
|
||||
raw-cr2 = ["raw", "craft-raw/cr2"]
|
||||
raw-cr3 = ["raw", "craft-raw/cr3"]
|
||||
raw-crw = ["raw", "craft-raw/crw"]
|
||||
raw-dng = ["raw", "craft-raw/dng"]
|
||||
raw-erf = ["raw", "craft-raw/erf"]
|
||||
raw-hasselblad = ["raw", "craft-raw/hasselblad"]
|
||||
raw-jxl = ["raw", "craft-raw/jxl"]
|
||||
raw-kodak = ["raw", "craft-raw/kodak"]
|
||||
raw-mef = ["raw", "craft-raw/mef"]
|
||||
raw-mrw = ["raw", "craft-raw/mrw"]
|
||||
raw-nef = ["raw", "craft-raw/nef"]
|
||||
raw-orf = ["raw", "craft-raw/orf"]
|
||||
raw-pef = ["raw", "craft-raw/pef"]
|
||||
raw-raf = ["raw", "craft-raw/raf"]
|
||||
raw-rw2 = ["raw", "craft-raw/rw2"]
|
||||
raw-srw = ["raw", "craft-raw/srw"]
|
||||
|
||||
review = ["dep:craft-review", "keymap"]
|
||||
|
||||
rtf = ["dep:craft-rtf"]
|
||||
rtf-doc = ["rtf", "craft-rtf/doc"]
|
||||
rtf-outlook = ["rtf", "craft-rtf/outlook"]
|
||||
|
||||
scraft-format = ["dep:craft-scraft-format"]
|
||||
|
||||
settings = ["dep:craft-settings"]
|
||||
|
||||
sf2 = ["dep:craft-sf2"]
|
||||
sf2-test-support = ["sf2", "craft-sf2/test-support"]
|
||||
|
||||
sheet = ["dep:craft-sheet"]
|
||||
|
||||
silhouette-studio = ["dep:craft-silhouette-studio"]
|
||||
|
||||
sketch = ["dep:craft-sketch"]
|
||||
|
||||
stencilcraft-document = ["dep:craft-stencilcraft-document"]
|
||||
|
||||
stencilcraft-format = ["dep:craft-stencilcraft-format"]
|
||||
|
||||
stream-codecs = ["dep:craft-stream-codecs"]
|
||||
|
||||
svg = ["dep:craft-svg"]
|
||||
svg-tree = ["svg", "craft-svg/tree"]
|
||||
svg-tree-system-fonts = ["svg", "craft-svg/tree-system-fonts"]
|
||||
svg-tree-text = ["svg", "craft-svg/tree-text"]
|
||||
|
||||
table = ["dep:craft-table", "keymap"]
|
||||
|
||||
text = ["dep:craft-text"]
|
||||
@@ -270,9 +585,17 @@ text-turkish = ["text", "craft-text/turkish"]
|
||||
text-turkmen = ["text", "craft-text/turkmen"]
|
||||
text-ukrainian = ["text", "craft-text/ukrainian"]
|
||||
|
||||
tga = ["dep:craft-tga"]
|
||||
|
||||
theme-store = ["dep:craft-theme-store"]
|
||||
|
||||
tiff = ["dep:craft-tiff"]
|
||||
|
||||
time = ["dep:craft-time"]
|
||||
|
||||
timeline = ["dep:craft-timeline", "keymap"]
|
||||
timeline-otio = ["timeline", "craft-timeline/otio"]
|
||||
timeline-xml = ["timeline", "craft-timeline/xml"]
|
||||
|
||||
ui-app = ["ui", "craft-ui/app"]
|
||||
ui-color_fonts = ["ui", "craft-ui/color_fonts"]
|
||||
@@ -282,11 +605,63 @@ ui-testing = ["ui", "craft-ui/testing"]
|
||||
|
||||
update = ["dep:craft-update"] # native only: downloads and installs through getrandom without wasm support
|
||||
|
||||
vcard = ["dep:craft-vcard"]
|
||||
|
||||
vectorcraft-format = ["dep:craft-vectorcraft-format"]
|
||||
|
||||
vectordrawable = ["dep:craft-vectordrawable"]
|
||||
|
||||
video = ["dep:craft-video"]
|
||||
video-apv = ["video", "craft-video/apv"]
|
||||
video-apv-decode = ["video", "craft-video/apv-decode"]
|
||||
video-apv-encode = ["video", "craft-video/apv-encode"]
|
||||
video-av1 = ["video", "craft-video/av1"]
|
||||
video-av1-decode = ["video", "craft-video/av1-decode"]
|
||||
video-av1-encode = ["video", "craft-video/av1-encode"]
|
||||
video-dnx = ["video", "craft-video/dnx"]
|
||||
video-h264 = ["video", "craft-video/h264"]
|
||||
video-h264-decode = ["video", "craft-video/h264-decode"]
|
||||
video-h264-encode = ["video", "craft-video/h264-encode"]
|
||||
video-hevc = ["video", "craft-video/hevc"]
|
||||
video-hevc-decode = ["video", "craft-video/hevc-decode"]
|
||||
video-hevc-encode = ["video", "craft-video/hevc-encode"]
|
||||
video-mpeg2 = ["video", "craft-video/mpeg2"]
|
||||
video-mpeg2-decode = ["video", "craft-video/mpeg2-decode"]
|
||||
video-mpeg2-encode = ["video", "craft-video/mpeg2-encode"]
|
||||
video-mpeg4 = ["video", "craft-video/mpeg4"]
|
||||
video-mpeg4-encode = ["video", "craft-video/mpeg4-encode"]
|
||||
video-prores = ["video", "craft-video/prores"]
|
||||
video-threads = ["video", "craft-video/threads"]
|
||||
video-vp8 = ["video", "craft-video/vp8"]
|
||||
video-vp8-decode = ["video", "craft-video/vp8-decode"]
|
||||
video-vp8-encode = ["video", "craft-video/vp8-encode"]
|
||||
video-vp9 = ["video", "craft-video/vp9"]
|
||||
video-vp9-decode = ["video", "craft-video/vp9-decode"]
|
||||
video-vp9-encode = ["video", "craft-video/vp9-encode"]
|
||||
|
||||
web-api = ["dep:craft-web-api"]
|
||||
|
||||
web-host = ["dep:craft-web-host"]
|
||||
|
||||
webp = ["dep:craft-webp"]
|
||||
webp-frames = ["webp", "craft-webp/frames"]
|
||||
webp-vp8 = ["webp", "craft-webp/vp8"]
|
||||
|
||||
window = ["dep:craft-window"]
|
||||
window-appkit = ["window", "craft-window/appkit"]
|
||||
|
||||
wordmodel = ["dep:craft-wordmodel"]
|
||||
wordmodel-test-support = ["wordmodel", "craft-wordmodel/test-support"]
|
||||
|
||||
xcf = ["dep:craft-xcf"]
|
||||
|
||||
xls = ["dep:craft-xls"]
|
||||
|
||||
xlsx = ["dep:craft-xlsx"]
|
||||
|
||||
xml = ["dep:craft-xml"]
|
||||
|
||||
y4m = ["dep:craft-y4m"]
|
||||
|
||||
zip = ["dep:craft-zip"]
|
||||
zip-test-support = ["zip", "craft-zip/test-support"]
|
||||
|
||||
@@ -6,8 +6,16 @@ pub mod egui_fork;
|
||||
|
||||
#[cfg(all(feature = "ui-system_fonts", target_arch = "wasm32"))]
|
||||
compile_error!("`ui-system_fonts` is desktop-only: the system font index needs fontique, which has no web build");
|
||||
#[cfg(feature = "aaf")]
|
||||
pub use craft_aaf as aaf;
|
||||
#[cfg(feature = "aep")]
|
||||
pub use craft_aep as aep;
|
||||
#[cfg(feature = "affinity")]
|
||||
pub use craft_affinity as affinity;
|
||||
#[cfg(feature = "ai-core")]
|
||||
pub use craft_ai_core as ai_core;
|
||||
#[cfg(feature = "assuan")]
|
||||
pub use craft_assuan as assuan;
|
||||
#[cfg(feature = "atomic")]
|
||||
pub use craft_atomic as atomic;
|
||||
#[cfg(feature = "audio")]
|
||||
@@ -17,22 +25,72 @@ pub use craft_automation as automation;
|
||||
pub use craft_behavior as behavior;
|
||||
#[cfg(feature = "browse")]
|
||||
pub use craft_browse as browse;
|
||||
#[cfg(feature = "captions")]
|
||||
pub use craft_captions as captions;
|
||||
#[cfg(feature = "cfb")]
|
||||
pub use craft_cfb as cfb;
|
||||
#[cfg(feature = "cms")]
|
||||
pub use craft_cms as cms;
|
||||
#[cfg(feature = "codepage")]
|
||||
pub use craft_codepage as codepage;
|
||||
#[cfg(feature = "color")]
|
||||
pub use craft_color as color;
|
||||
#[cfg(feature = "crs")]
|
||||
pub use craft_crs as crs;
|
||||
#[cfg(feature = "crw")]
|
||||
pub use craft_crw as crw;
|
||||
#[cfg(feature = "csv")]
|
||||
pub use craft_csv as csv;
|
||||
#[cfg(feature = "dav")]
|
||||
pub use craft_dav as dav;
|
||||
#[cfg(feature = "designcraft-format")]
|
||||
pub use craft_designcraft_format as designcraft_format;
|
||||
#[cfg(feature = "dialogs")]
|
||||
pub use craft_dialogs as dialogs;
|
||||
#[cfg(feature = "doc")]
|
||||
pub use craft_doc as doc;
|
||||
#[cfg(feature = "doc-binary")]
|
||||
pub use craft_doc_binary as doc_binary;
|
||||
#[cfg(feature = "docpath")]
|
||||
pub use craft_docpath as docpath;
|
||||
#[cfg(feature = "document-bundle")]
|
||||
pub use craft_document_bundle as document_bundle;
|
||||
#[cfg(feature = "docx")]
|
||||
pub use craft_docx as docx;
|
||||
#[cfg(feature = "dpx")]
|
||||
pub use craft_dpx as dpx;
|
||||
#[cfg(feature = "draw")]
|
||||
pub use craft_draw as draw;
|
||||
#[cfg(feature = "drawingml")]
|
||||
pub use craft_drawingml as drawingml;
|
||||
#[cfg(feature = "dwg")]
|
||||
pub use craft_dwg as dwg;
|
||||
#[cfg(feature = "dxf")]
|
||||
pub use craft_dxf as dxf;
|
||||
#[cfg(feature = "ecproj-format")]
|
||||
pub use craft_ecproj_format as ecproj_format;
|
||||
#[cfg(feature = "eps")]
|
||||
pub use craft_eps as eps;
|
||||
#[cfg(feature = "epub")]
|
||||
pub use craft_epub as epub;
|
||||
#[cfg(feature = "ews")]
|
||||
pub use craft_ews as ews;
|
||||
#[cfg(feature = "exr")]
|
||||
pub use craft_exr as exr;
|
||||
#[cfg(feature = "fig")]
|
||||
pub use craft_fig as fig;
|
||||
#[cfg(feature = "figcraft-format")]
|
||||
pub use craft_figcraft_format as figcraft_format;
|
||||
#[cfg(feature = "figma-rest")]
|
||||
pub use craft_figma_rest as figma_rest;
|
||||
#[cfg(feature = "file-formats")]
|
||||
pub use craft_file_formats as file_formats;
|
||||
#[cfg(feature = "file-import")]
|
||||
pub use craft_file_import as file_import;
|
||||
#[cfg(feature = "flags")]
|
||||
pub use craft_flags as flags;
|
||||
#[cfg(feature = "flow")]
|
||||
pub use craft_flow as flow;
|
||||
#[cfg(feature = "font-catalog")]
|
||||
pub use craft_font_catalog as font_catalog;
|
||||
#[cfg(feature = "font-manager")]
|
||||
@@ -41,61 +99,187 @@ pub use craft_font_manager as font_manager;
|
||||
pub use craft_font_store as font_store;
|
||||
#[cfg(feature = "font-subset")]
|
||||
pub use craft_font_subset as font_subset;
|
||||
#[cfg(feature = "gainmap")]
|
||||
pub use craft_gainmap as gainmap;
|
||||
#[cfg(feature = "gcode")]
|
||||
pub use craft_gcode as gcode;
|
||||
#[cfg(feature = "gif")]
|
||||
pub use craft_gif as gif;
|
||||
#[cfg(feature = "hdr")]
|
||||
pub use craft_hdr as hdr;
|
||||
#[cfg(feature = "heif")]
|
||||
pub use craft_heif as heif;
|
||||
pub use craft_host as host;
|
||||
#[cfg(feature = "html")]
|
||||
pub use craft_html as html;
|
||||
pub use craft_i18n as i18n;
|
||||
#[cfg(feature = "ical")]
|
||||
pub use craft_ical as ical;
|
||||
#[cfg(feature = "idml")]
|
||||
pub use craft_idml as idml;
|
||||
#[cfg(feature = "imaging")]
|
||||
pub use craft_imaging as imaging;
|
||||
#[cfg(feature = "indd")]
|
||||
pub use craft_indd as indd;
|
||||
#[cfg(feature = "jmap")]
|
||||
pub use craft_jmap as jmap;
|
||||
#[cfg(feature = "jpeg")]
|
||||
pub use craft_jpeg as jpeg;
|
||||
#[cfg(feature = "keymap")]
|
||||
pub use craft_keymap as keymap;
|
||||
#[cfg(feature = "kiwi")]
|
||||
pub use craft_kiwi as kiwi;
|
||||
#[cfg(feature = "kra")]
|
||||
pub use craft_kra as kra;
|
||||
#[cfg(feature = "latex")]
|
||||
pub use craft_latex as latex;
|
||||
#[cfg(feature = "layers")]
|
||||
pub use craft_layers as layers;
|
||||
#[cfg(feature = "lottie")]
|
||||
pub use craft_lottie as lottie;
|
||||
#[cfg(feature = "markdown")]
|
||||
pub use craft_markdown as markdown;
|
||||
#[cfg(feature = "materialx")]
|
||||
pub use craft_materialx as materialx;
|
||||
#[cfg(feature = "math")]
|
||||
pub use craft_math as math;
|
||||
#[cfg(feature = "media")]
|
||||
pub use craft_media as media;
|
||||
#[cfg(feature = "menu")]
|
||||
pub use craft_menu as menu;
|
||||
#[cfg(feature = "mesh")]
|
||||
pub use craft_mesh as mesh;
|
||||
#[cfg(feature = "metadata")]
|
||||
pub use craft_metadata as metadata;
|
||||
#[cfg(feature = "metafile")]
|
||||
pub use craft_metafile as metafile;
|
||||
#[cfg(feature = "midi")]
|
||||
pub use craft_midi as midi;
|
||||
#[cfg(feature = "mime")]
|
||||
pub use craft_mime as mime;
|
||||
#[cfg(feature = "odf")]
|
||||
pub use craft_odf as odf;
|
||||
#[cfg(feature = "ods")]
|
||||
pub use craft_ods as ods;
|
||||
#[cfg(feature = "offcrypto")]
|
||||
pub use craft_offcrypto as offcrypto;
|
||||
#[cfg(feature = "opc")]
|
||||
pub use craft_opc as opc;
|
||||
#[cfg(feature = "openpgp")]
|
||||
pub use craft_openpgp as openpgp;
|
||||
#[cfg(feature = "ora")]
|
||||
pub use craft_ora as ora;
|
||||
#[cfg(feature = "pages")]
|
||||
pub use craft_pages as pages;
|
||||
#[cfg(feature = "pcraft-bundle")]
|
||||
pub use craft_pcraft_bundle as pcraft_bundle;
|
||||
#[cfg(feature = "pcraft-format")]
|
||||
pub use craft_pcraft_format as pcraft_format;
|
||||
#[cfg(feature = "pdf")]
|
||||
pub use craft_pdf as pdf;
|
||||
#[cfg(feature = "pdn")]
|
||||
pub use craft_pdn as pdn;
|
||||
#[cfg(feature = "penpot")]
|
||||
pub use craft_penpot as penpot;
|
||||
#[cfg(feature = "pkcs7")]
|
||||
pub use craft_pkcs7 as pkcs7;
|
||||
#[cfg(feature = "platform")]
|
||||
pub use craft_platform as platform;
|
||||
#[cfg(feature = "plotter")]
|
||||
pub use craft_plotter as plotter;
|
||||
#[cfg(feature = "pptx")]
|
||||
pub use craft_pptx as pptx;
|
||||
#[cfg(feature = "prc")]
|
||||
pub use craft_prc as prc;
|
||||
#[cfg(feature = "prepress")]
|
||||
pub use craft_prepress as prepress;
|
||||
#[cfg(feature = "print")]
|
||||
pub use craft_print as print;
|
||||
#[cfg(feature = "proof")]
|
||||
pub use craft_proof as proof;
|
||||
#[cfg(feature = "psd")]
|
||||
pub use craft_psd as psd;
|
||||
#[cfg(feature = "pst")]
|
||||
pub use craft_pst as pst;
|
||||
#[cfg(feature = "quit")]
|
||||
pub use craft_quit as quit;
|
||||
#[cfg(feature = "raster-codecs")]
|
||||
pub use craft_raster_codecs as raster_codecs;
|
||||
#[cfg(feature = "raw")]
|
||||
pub use craft_raw as raw;
|
||||
#[cfg(feature = "review")]
|
||||
pub use craft_review as review;
|
||||
#[cfg(feature = "rtf")]
|
||||
pub use craft_rtf as rtf;
|
||||
#[cfg(feature = "scraft-format")]
|
||||
pub use craft_scraft_format as scraft_format;
|
||||
#[cfg(feature = "settings")]
|
||||
pub use craft_settings as settings;
|
||||
#[cfg(feature = "sf2")]
|
||||
pub use craft_sf2 as sf2;
|
||||
#[cfg(feature = "sheet")]
|
||||
pub use craft_sheet as sheet;
|
||||
#[cfg(feature = "silhouette-studio")]
|
||||
pub use craft_silhouette_studio as silhouette_studio;
|
||||
#[cfg(feature = "sketch")]
|
||||
pub use craft_sketch as sketch;
|
||||
#[cfg(feature = "stencilcraft-document")]
|
||||
pub use craft_stencilcraft_document as stencilcraft_document;
|
||||
#[cfg(feature = "stencilcraft-format")]
|
||||
pub use craft_stencilcraft_format as stencilcraft_format;
|
||||
#[cfg(feature = "stream-codecs")]
|
||||
pub use craft_stream_codecs as stream_codecs;
|
||||
#[cfg(feature = "svg")]
|
||||
pub use craft_svg as svg;
|
||||
#[cfg(feature = "table")]
|
||||
pub use craft_table as table;
|
||||
#[cfg(feature = "text")]
|
||||
pub use craft_text as text;
|
||||
#[cfg(feature = "tga")]
|
||||
pub use craft_tga as tga;
|
||||
pub use craft_theme as theme;
|
||||
#[cfg(feature = "theme-store")]
|
||||
pub use craft_theme_store as theme_store;
|
||||
#[cfg(feature = "tiff")]
|
||||
pub use craft_tiff as tiff;
|
||||
#[cfg(feature = "time")]
|
||||
pub use craft_time as time;
|
||||
#[cfg(feature = "timeline")]
|
||||
pub use craft_timeline as timeline;
|
||||
#[cfg(feature = "ui")]
|
||||
pub use craft_ui as ui;
|
||||
#[cfg(feature = "update")]
|
||||
pub use craft_update as update;
|
||||
#[cfg(feature = "vcard")]
|
||||
pub use craft_vcard as vcard;
|
||||
#[cfg(feature = "vectorcraft-format")]
|
||||
pub use craft_vectorcraft_format as vectorcraft_format;
|
||||
#[cfg(feature = "vectordrawable")]
|
||||
pub use craft_vectordrawable as vectordrawable;
|
||||
#[cfg(feature = "video")]
|
||||
pub use craft_video as video;
|
||||
#[cfg(feature = "web-api")]
|
||||
pub use craft_web_api as web_api;
|
||||
#[cfg(feature = "web-host")]
|
||||
pub use craft_web_host as web_host;
|
||||
#[cfg(feature = "webp")]
|
||||
pub use craft_webp as webp;
|
||||
#[cfg(feature = "window")]
|
||||
pub use craft_window as window;
|
||||
#[cfg(feature = "wordmodel")]
|
||||
pub use craft_wordmodel as wordmodel;
|
||||
#[cfg(feature = "xcf")]
|
||||
pub use craft_xcf as xcf;
|
||||
#[cfg(feature = "xls")]
|
||||
pub use craft_xls as xls;
|
||||
#[cfg(feature = "xlsx")]
|
||||
pub use craft_xlsx as xlsx;
|
||||
#[cfg(feature = "xml")]
|
||||
pub use craft_xml as xml;
|
||||
#[cfg(feature = "y4m")]
|
||||
pub use craft_y4m as y4m;
|
||||
#[cfg(feature = "zip")]
|
||||
pub use craft_zip as zip;
|
||||
#[cfg(feature = "ui")]
|
||||
pub use egui;
|
||||
|
||||
|
||||
@@ -15,6 +15,14 @@ pub const NOT_IN_FACADE: &[(&str, &str)] = &[
|
||||
("ui-bench", "a tool: the release-mode benchmark of the UI library"),
|
||||
("ui-gallery", "a tool: the story gallery application"),
|
||||
("ui-macros", "a proc-macro crate that craft-ui re-exports"),
|
||||
("svg-paths", "the former name of craft-svg's geometry reader; re-exports it"),
|
||||
("ui-canvas", "part of craft-ui, which the facade exposes as `ui`"),
|
||||
("ui-contract", "part of craft-ui, which the facade exposes as `ui`"),
|
||||
("ui-panels", "part of craft-ui, which the facade exposes as `ui`"),
|
||||
("ui-patterns", "part of craft-ui, which the facade exposes as `ui`"),
|
||||
("ui-shell", "part of craft-ui, which the facade exposes as `ui`"),
|
||||
("ui-test-kit", "test support shared by craft-ui's integration binaries"),
|
||||
("ui-widgets", "part of craft-ui, which the facade exposes as `ui`"),
|
||||
("win32", "the `unsafe` Win32 calls behind a safe API, used by craft-window"),
|
||||
];
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
//! The facade's `[features]` table is written from the member crates' manifests.
|
||||
//! `UPDATE_FACADE=1 cargo test -p craft -- integration::features` rewrites the checked-in table.
|
||||
//! `UPDATE_FACADE=1 cargo test -p craft -- integration::features` rewrites the checked-in table, and
|
||||
//! first adds the optional dependency line and the `pub use` line of every member the facade lacks.
|
||||
|
||||
use super::common;
|
||||
|
||||
@@ -114,6 +115,46 @@ fn checked_in(manifest: &str) -> (usize, usize) {
|
||||
(start, end)
|
||||
}
|
||||
|
||||
/// Adds `craft-x = { workspace = true, optional = true }` to the facade manifest's `[dependencies]` and
|
||||
/// `pub use craft_x as x;` to `src/lib.rs` for every member that has neither, leaving the hand-written lines alone.
|
||||
fn add_missing_members(members: &[Member], manifest_path: &std::path::Path) {
|
||||
let manifest = std::fs::read_to_string(manifest_path).unwrap();
|
||||
let have: toml::Table = manifest.parse().unwrap();
|
||||
let deps = have["dependencies"].as_table().unwrap();
|
||||
let missing: Vec<&Member> = members.iter().filter(|m| !deps.contains_key(&format!("craft-{}", m.dir))).collect();
|
||||
if !missing.is_empty() {
|
||||
let at = manifest.find("\n[features]").expect("[features] section");
|
||||
let head = manifest[..at].trim_end();
|
||||
let mut text = head.to_owned();
|
||||
for m in &missing {
|
||||
text += &format!("\ncraft-{} = {{ workspace = true, optional = true }}", m.dir);
|
||||
}
|
||||
text += "\n";
|
||||
text += &manifest[at..];
|
||||
std::fs::write(manifest_path, text).unwrap();
|
||||
}
|
||||
|
||||
let lib_path = manifest_path.with_file_name("src/lib.rs");
|
||||
let lib = std::fs::read_to_string(&lib_path).unwrap();
|
||||
let mut lines: Vec<String> = lib.lines().map(str::to_owned).collect();
|
||||
for m in members.iter().filter(|m| !m.always_on() && m.dir != "ui") {
|
||||
let ident = m.dir.replace('-', "_");
|
||||
if lines.iter().any(|l| l.starts_with(&format!("pub use craft_{ident} as "))) {
|
||||
continue;
|
||||
}
|
||||
let name_of = |l: &String| l.strip_prefix("pub use craft_").and_then(|r| r.split(' ').next()).map(str::to_owned);
|
||||
let at = lines
|
||||
.iter()
|
||||
.position(|l| name_of(l).is_some_and(|n| n > ident))
|
||||
.or_else(|| lines.iter().position(|l| l == "pub use egui;"))
|
||||
.expect("re-export block");
|
||||
let at = if lines[at - 1].starts_with("#[cfg(") { at - 1 } else { at };
|
||||
lines.insert(at, format!("pub use craft_{ident} as {ident};"));
|
||||
lines.insert(at, format!("#[cfg(feature = \"{}\")]", m.dir));
|
||||
}
|
||||
std::fs::write(&lib_path, lines.join("\n") + "\n").unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn features_table_matches_member_manifests() {
|
||||
let members = members();
|
||||
@@ -122,6 +163,9 @@ fn features_table_matches_member_manifests() {
|
||||
let manifest = std::fs::read_to_string(&path).unwrap();
|
||||
let (start, end) = checked_in(&manifest);
|
||||
if std::env::var_os("UPDATE_FACADE").is_some() {
|
||||
add_missing_members(&members, &path);
|
||||
let manifest = std::fs::read_to_string(&path).unwrap();
|
||||
let (start, end) = checked_in(&manifest);
|
||||
let mut text = manifest[..start].to_owned();
|
||||
text += &want;
|
||||
text += &manifest[end..];
|
||||
|
||||
@@ -153,8 +153,8 @@ impl Boards {
|
||||
let page = |(index, item): (usize, &ArtboardItem)| {
|
||||
let page = PageFrame::new(item.rect.abs()).name(item.name.clone()).active(self.selected.contains(&index));
|
||||
match item.background {
|
||||
ArtboardBackground::White => page.fill(DataColor(Color32::WHITE)),
|
||||
ArtboardBackground::Black => page.fill(DataColor(Color32::BLACK)),
|
||||
ArtboardBackground::White => page.fill(DataColor(Color32::WHITE)), // design: allow[raw-colour/const](the artboard background is document data)
|
||||
ArtboardBackground::Black => page.fill(DataColor(Color32::BLACK)), // design: allow[raw-colour/const](the artboard background is document data)
|
||||
ArtboardBackground::Custom(color) => page.fill(DataColor(Color32::from(color))),
|
||||
_ => page,
|
||||
}
|
||||
|
||||
@@ -364,7 +364,7 @@ impl<'a, K: Value + Eq + Hash> BrushPresetPicker<'a, K> {
|
||||
let next_search = Cell::new(before.search);
|
||||
let tool_picks: RefCell<Vec<BrushPick<K>>> = RefCell::new(Vec::new());
|
||||
let (mut diameter, mut hardness, mut tip) = (EditEvents::new(), EditEvents::new(), EditEvents::new());
|
||||
let browser_id = ui.make_persistent_id("browser");
|
||||
let browser_id = ui.scope_id().with("browser");
|
||||
let has_app_rows = gear_rows.is_some();
|
||||
let head = |ui: &mut Ui, _: &mut BodyCx<'_>| {
|
||||
Row::new().show(ui, |ui, _| {
|
||||
|
||||
@@ -16,8 +16,8 @@ use craft_ui::primitives::{Draw, PaintShape, StrokeWidth};
|
||||
use craft_ui::runtime::env::Env;
|
||||
use egui::Pos2;
|
||||
|
||||
use super::session::{CropDocKey, DocOwner};
|
||||
use super::perspective_crop::{PerspectiveCropOutput, PerspectiveCropQuad, PerspectiveQuad, grid_color, grid_lines, grid_step, is_valid, ordered};
|
||||
use super::session::{CropDocKey, DocOwner};
|
||||
use super::words::CropWords;
|
||||
|
||||
/// The key of the Perspective Crop To... command form.
|
||||
|
||||
@@ -75,11 +75,14 @@ impl GradientRef {
|
||||
/// ```
|
||||
/// use craft_theme::Srgba;
|
||||
/// use craft_color::ui::gradient::{ColorStop, GradientStops};
|
||||
/// use craft_draw::ui::{GradientGroup, GradientItem, GradientPalette};
|
||||
/// use craft_draw::ui::{GradientGroup, GradientItem, GradientPalette, GradientRef};
|
||||
/// use craft_ui::contract::{Bind, Show as _};
|
||||
/// use craft_ui::patterns::presets::PresetState;
|
||||
/// # egui::__run_test_ui(|ui| {
|
||||
/// let stops = GradientStops::new(vec![ColorStop::new(0.0, Srgba::rgb(0.0, 0.0, 0.0)), ColorStop::new(1.0, Srgba::rgb(1.0, 1.0, 1.0))]);
|
||||
/// let groups = [GradientGroup::new("Basics", vec![GradientItem::new("Black, White", stops)])];
|
||||
/// let picked = GradientPalette::new("presets", "Gradient presets", &groups).show(ui);
|
||||
/// let mut state = PresetState::<GradientRef>::new();
|
||||
/// let picked = GradientPalette::new("Gradient presets", &groups, Bind::bound(&mut state)).show(ui);
|
||||
/// if let Some(pick) = picked.picked {
|
||||
/// // copy the preset's stops into the host's gradient
|
||||
/// let _ = pick;
|
||||
|
||||
@@ -70,8 +70,8 @@ pub use connector::{
|
||||
pub use corner::{CornerEdit, CornerKind, CornerRadii, CornerStyle, CornerWidgets};
|
||||
pub use crop::{
|
||||
CropBar, CropBarOutput, CropBarWords, CropCommit, CropDocument, CropEvent, CropFill, CropInput, CropLength, CropOptionsMenu, CropOutput,
|
||||
CropOverlayMenu, CropPresetChoice, CropRatio, CropRatioChange, CropSession, CropSettings, CropSizePreset, CropShown, CropTarget, CropTool, CropToolPass,
|
||||
CropUserPreset, CropWords, PerspectiveCropOutput, PerspectiveCropTool, ResolutionUnit,
|
||||
CropOverlayMenu, CropPresetChoice, CropRatio, CropRatioChange, CropSession, CropSettings, CropShown, CropSizePreset, CropTarget, CropTool,
|
||||
CropToolPass, CropUserPreset, CropWords, PerspectiveCropOutput, PerspectiveCropTool, ResolutionUnit,
|
||||
};
|
||||
pub use crop::{
|
||||
CropPresetList, CropPresetListOutput, CropSizeTarget, PerspectiveCropBar, PerspectiveCropBarOutput, PerspectiveCropPass, PerspectiveInput,
|
||||
|
||||
@@ -8,9 +8,9 @@
|
||||
//! use craft_draw::ui::slice::{SliceCommand, SliceEvent, SliceItem, SliceOverlay, SliceTool};
|
||||
//! use craft_ui::canvas::{Canvas, ToolHost, ToolPath};
|
||||
//! use craft_ui::contract::{Show as _, ShowContainer as _};
|
||||
//! # fn demo(ui: &mut egui::Ui, tool: &mut SliceTool, slices: &[SliceItem], selected: Option<usize>, locked: bool) {
|
||||
//! # fn demo(ui: &mut egui::Ui, tool: &mut SliceTool, slices: &[SliceItem], selected: usize, locked: bool) {
|
||||
//! let shown = Canvas::new("Document").show(ui, |ui, body| {
|
||||
//! SliceOverlay::new("Slices", slices).selected(selected).pick(true).locked(locked).show_at(ui, body.rect)
|
||||
//! SliceOverlay::new("Slices", slices).selected_slice(selected).pick(true).locked(locked).show_at(ui, body.rect)
|
||||
//! });
|
||||
//! let _ = ToolHost::new().run(ui, &shown.output, tool);
|
||||
//! let mut events = tool.take_events();
|
||||
|
||||
@@ -68,7 +68,17 @@ pub struct TransformOverlay<'a, W> {
|
||||
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, mods: None, menu_rows: &[], move_reach: 0.0, id: IdSource::Auto }
|
||||
Self {
|
||||
label: label.into(),
|
||||
session,
|
||||
settings,
|
||||
rules: None,
|
||||
pixel_grid: false,
|
||||
mods: None,
|
||||
menu_rows: &[],
|
||||
move_reach: 0.0,
|
||||
id: IdSource::Auto,
|
||||
}
|
||||
}
|
||||
|
||||
/// Salts the box's id with `salt`, as [`Props::id_salt`](craft_ui::contract::Props::id_salt) does: a host that
|
||||
|
||||
@@ -30,7 +30,6 @@ craft_ui::words! {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// The label of an axis: its name when the font gives one, else the registered tag's
|
||||
/// (`Weight`, `Width`, `Slant`, `Italic`), else the tag itself.
|
||||
pub fn axis_label(axis: &FontAxis) -> String {
|
||||
|
||||
@@ -104,7 +104,8 @@ pub use scopes::{
|
||||
ScopeView, ScopeWords, ToneZone, ToneZones, VectorscopeFrame, VectorscopePlot, ZoneScale, ZoneValues, scope_point,
|
||||
};
|
||||
pub use select::{
|
||||
LassoTool, MagneticLassoTool, MagneticOutlineView, MagneticSettings, MarqueeKind, MarqueeTool, PolygonLassoTool, SelectEvent, SelectWords, SelectionShape,
|
||||
LassoTool, MagneticLassoTool, MagneticOutlineView, MagneticSettings, MarqueeKind, MarqueeTool, PolygonLassoTool, SelectEvent, SelectWords,
|
||||
SelectionShape,
|
||||
operations::{SelectionOpWords, selection_operations},
|
||||
};
|
||||
pub use select_mask::{
|
||||
|
||||
@@ -334,7 +334,13 @@ impl<T: EdgeTracer> MagneticLassoTool<T> {
|
||||
|
||||
/// The outline in progress, `None` while none is open.
|
||||
pub fn outline(&self) -> Option<MagneticOutlineView<'_>> {
|
||||
self.outline.as_ref().map(|o| MagneticOutlineView { path: &o.path, anchors: &o.anchors, live: &o.live, operation: o.operation, freehand: o.freehand })
|
||||
self.outline.as_ref().map(|o| MagneticOutlineView {
|
||||
path: &o.path,
|
||||
anchors: &o.anchors,
|
||||
live: &o.live,
|
||||
operation: o.operation,
|
||||
freehand: o.freehand,
|
||||
})
|
||||
}
|
||||
|
||||
/// An outline with the operation New is open: the app hides the selection's ants.
|
||||
|
||||
@@ -256,7 +256,7 @@ impl PictureEdges {
|
||||
fn normal(&self, p: Point) -> Vec2 {
|
||||
let d = |dx: f64, dy: f64| self.image.subject_distance(p.x + dx, p.y + dy);
|
||||
let g = Vec2::new(d(1.0, 0.0) - d(-1.0, 0.0), d(0.0, 1.0) - d(0.0, -1.0));
|
||||
if g.hypot() > 0.0 { g / g.hypot() } else { Vec2::new(0.0, -1.0) }
|
||||
if g.hypot() > 0.0 { g / g.hypot() } else { Vec2::from((0.0, -1.0)) }
|
||||
}
|
||||
|
||||
/// The point of the outline nearest `p`; `None` beyond the search's width or where the edge is weaker than its
|
||||
|
||||
@@ -16,7 +16,7 @@ use craft_imaging::ui::fill::{
|
||||
use craft_imaging::ui::select_mask::EditMode;
|
||||
use craft_imaging::ui::wide_angle::PreviewDone;
|
||||
use craft_ui::canvas::{PixelRect, RasterSource};
|
||||
use craft_ui::dialog::{DialogHost, FullWindowWorkspace as _, DialogResult, HostedWorkspace};
|
||||
use craft_ui::dialog::{DialogHost, DialogResult, FullWindowWorkspace as _, HostedWorkspace};
|
||||
use craft_ui::primitives::Revision;
|
||||
use craft_ui::runtime::access::Role;
|
||||
use craft_ui::runtime::memory::{SaveKey, saved_value};
|
||||
|
||||
@@ -669,7 +669,7 @@ impl<'a> LayerFilterBar<'a> {
|
||||
pub fn show(self, ui: &mut Ui) -> LayerFilterOutput {
|
||||
let Self { mut filter, blend_modes, focus_name, types: offered } = self;
|
||||
if offered.is_empty() {
|
||||
return LayerFilterOutput { response: ui.allocate_response(egui::Vec2::ZERO, egui::Sense::hover()), changed: false, edit: None };
|
||||
return LayerFilterOutput { response: Row::new().show(ui, |_, _| {}).output, changed: false, edit: None };
|
||||
}
|
||||
let words = Env::of(ui).words::<LayerFilterWords>();
|
||||
let mut edit = None;
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
//! Stories of `LayerFilterBar`: each filter type in one card, with the count of a document's layers it lets through;
|
||||
//! and `LayersPanel` filtered by Artboard and by Group, which keep each group open or closed.
|
||||
//! Stories of `LayerFilterBar`: each filter type in one card, with the count of a document's layers it lets through.
|
||||
|
||||
use super::{EffectKind, FilterBy, FilterKind, LayerAttribute, LayerFilter, LayerFilterBar, SmartKind};
|
||||
use crate::ui::mock::FakeLayers;
|
||||
use crate::ui::panel::LayersPanel;
|
||||
use crate::ui::tree::LayerTree as _;
|
||||
use craft_theme::LabelColor;
|
||||
use craft_ui::contract::Bind;
|
||||
@@ -87,19 +85,3 @@ fn by_group(ui: &mut Ui, data: &mut StoryData) -> StoryOutput {
|
||||
let filter = data.value("filter", LayerFilter { by: FilterBy::Group, ..LayerFilter::default() });
|
||||
show(ui, filter)
|
||||
}
|
||||
|
||||
/// The artboard that holds the selected "Oak", with its contents.
|
||||
#[story(LayersPanel<'static, FakeLayers>, covers = [], drive = Drive::Never)]
|
||||
fn layers_panel_by_artboard(ui: &mut Ui, data: &mut StoryData) -> StoryOutput {
|
||||
let tree = FakeLayers::boards();
|
||||
let filter = data.value("filter", LayerFilter { by: FilterBy::Artboard, ..LayerFilter::default() });
|
||||
StoryOutput::from(LayersPanel::new(&tree).filter(Bind::bound(filter)).show(ui))
|
||||
}
|
||||
|
||||
/// Every group with its contents; the closed groups stay closed.
|
||||
#[story(LayersPanel<'static, FakeLayers>, covers = [], drive = Drive::Never)]
|
||||
fn layers_panel_by_group(ui: &mut Ui, data: &mut StoryData) -> StoryOutput {
|
||||
let tree = FakeLayers::fifty();
|
||||
let filter = data.value("filter", LayerFilter { by: FilterBy::Group, ..LayerFilter::default() });
|
||||
StoryOutput::from(LayersPanel::new(&tree).filter(Bind::bound(filter)).show(ui))
|
||||
}
|
||||
|
||||
@@ -225,11 +225,11 @@ pub(super) fn clip_cursor<T: LayerTree>(tree: &T, above: &LayerRowKey<T::Id>, be
|
||||
return None;
|
||||
}
|
||||
let icon = if tree.info(upper).clipped { "clip_release" } else { "clip_below" };
|
||||
Some(Cursor::Painted(PaintedCursor::tool(IconId::new(icon), CLIP_HOTSPOT, None)))
|
||||
Some(Cursor::Painted(PaintedCursor::tool(IconId::new(icon), egui::Vec2::from(CLIP_HOTSPOT), None)))
|
||||
}
|
||||
|
||||
/// The tip of the clip cursors' arrow in their 24-unit icon box.
|
||||
const CLIP_HOTSPOT: egui::Vec2 = egui::Vec2::new(15.0, 16.0);
|
||||
const CLIP_HOTSPOT: [f32; 2] = [15.0, 16.0];
|
||||
|
||||
/// The reorder event of the list as the panel reports it: one `Set` per drop.
|
||||
pub(super) fn drop_event<K: Clone + PartialEq>(
|
||||
|
||||
@@ -179,6 +179,7 @@ pub struct LayersPanel<'a, T: LayerTree> {
|
||||
|
||||
/// What a reveal ([`LayersPanel::reveal`]) does with the closed groups that hold the layer.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
#[non_exhaustive]
|
||||
pub enum Groups {
|
||||
/// They open ([`LayersEvent::Open`]) and the layer's own row scrolls into view.
|
||||
Open,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
//! Stories of `LayersPanel`: a tree with groups, masks and effects; no active layer; a filtered
|
||||
//! tree; extra columns; effects and Smart Filters open.
|
||||
//! tree; extra columns; effects and Smart Filters open; filtered by Artboard and by Group, which keep each group open or
|
||||
//! closed.
|
||||
|
||||
use craft_ui::contract::Bind;
|
||||
use craft_ui::testing::{Drive, StoryData, StoryOutput, story};
|
||||
@@ -99,3 +100,21 @@ fn layers_panel_effects_open(ui: &mut Ui, data: &mut StoryData) -> StoryOutput {
|
||||
let shown = LayersPanel::new(&tree).show(ui);
|
||||
with_readout(data, shown)
|
||||
}
|
||||
|
||||
/// The artboard that holds the selected "Oak", with its contents.
|
||||
#[story(LayersPanel<'static, FakeLayers>, covers = [], drive = Drive::Never)]
|
||||
fn layers_panel_by_artboard(ui: &mut Ui, data: &mut StoryData) -> StoryOutput {
|
||||
let tree = FakeLayers::boards();
|
||||
let filter = data.value("filter", LayerFilter { by: FilterBy::Artboard, ..LayerFilter::default() });
|
||||
let shown = LayersPanel::new(&tree).filter(Bind::bound(filter)).show(ui);
|
||||
with_readout(data, shown)
|
||||
}
|
||||
|
||||
/// Every group with its contents; the closed groups stay closed.
|
||||
#[story(LayersPanel<'static, FakeLayers>, covers = [], drive = Drive::Never)]
|
||||
fn layers_panel_by_group(ui: &mut Ui, data: &mut StoryData) -> StoryOutput {
|
||||
let tree = FakeLayers::fifty();
|
||||
let filter = data.value("filter", LayerFilter { by: FilterBy::Group, ..LayerFilter::default() });
|
||||
let shown = LayersPanel::new(&tree).filter(Bind::bound(filter)).show(ui);
|
||||
with_readout(data, shown)
|
||||
}
|
||||
|
||||
@@ -726,6 +726,7 @@ impl ChordChip {
|
||||
ChordChip { common: Common::new(), chord, pressed: false }
|
||||
}
|
||||
|
||||
#[cfg(feature = "screen-testing")]
|
||||
fn sample() -> Self {
|
||||
ChordChip::new("Ctrl+S".to_owned()).label("Save, Ctrl+S")
|
||||
}
|
||||
|
||||
@@ -21,12 +21,14 @@ mod probe;
|
||||
mod types;
|
||||
|
||||
pub use backend::*;
|
||||
pub(crate) use convert::*;
|
||||
pub use event::*;
|
||||
pub use facade::*;
|
||||
pub use probe::*;
|
||||
pub use types::*;
|
||||
|
||||
#[cfg(test)]
|
||||
pub(crate) use convert::rgba8_image;
|
||||
|
||||
// The probe's backend lives on its worker.
|
||||
const _: () = {
|
||||
const fn sendable<T: Send>() {}
|
||||
|
||||
@@ -41,6 +41,7 @@ fn payload_message(payload: &(dyn std::any::Any + Send)) -> String {
|
||||
payload.downcast_ref::<&str>().map(|s| (*s).to_owned()).or_else(|| payload.downcast_ref::<String>().cloned()).unwrap_or_else(|| "panic".into())
|
||||
}
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
fn unix_secs() -> u64 {
|
||||
(crate::clock::unix_ms() / 1000.0) as u64
|
||||
}
|
||||
|
||||
@@ -140,7 +140,6 @@ fn run(stop: &AtomicBool, _scale: f32) -> Result<Capture, ScreenError> {
|
||||
backend::capture(stop).map(Capture::Images)
|
||||
}
|
||||
|
||||
|
||||
/// The scale a monitor image gets: the app's native pixels per point, or 1 when it has none.
|
||||
#[cfg(all(unix, not(target_os = "macos"), not(target_arch = "wasm32")))]
|
||||
fn usable_scale(scale: f32) -> f32 {
|
||||
|
||||
@@ -127,7 +127,7 @@ trait Sink {
|
||||
pub(super) const MORE: PartKey = PartKey::new("more");
|
||||
|
||||
/// A card or a heading of the card collection.
|
||||
#[derive(craft_ui::contract::Component)]
|
||||
#[derive(craft_ui::contract::Component, craft_ui::contract::Props)]
|
||||
pub(crate) struct CommentRow<'r> {
|
||||
#[common]
|
||||
common: Common,
|
||||
@@ -138,7 +138,8 @@ pub(crate) struct CommentRow<'r> {
|
||||
now: i64,
|
||||
editing: Option<(usize, &'r str)>,
|
||||
reply: &'r str,
|
||||
/// The activation key reached the card this pass: the reply box takes the focus.
|
||||
/// The activation key reached the card this pass: its reply box takes the focus, when it shows one.
|
||||
#[prop]
|
||||
focus_reply: bool,
|
||||
words: Option<Arc<CommentsWords>>,
|
||||
/// The heights the editor field and the reply field measured, for the paint of the same pass.
|
||||
@@ -190,12 +191,6 @@ impl<'r> CommentRow<'r> {
|
||||
self
|
||||
}
|
||||
|
||||
/// The activation key reached the card this pass: its reply box takes the focus, when it shows one.
|
||||
pub(crate) fn focus_reply(mut self, on: bool) -> Self {
|
||||
self.focus_reply = on;
|
||||
self
|
||||
}
|
||||
|
||||
/// The message being edited and its draft, and the reply draft.
|
||||
pub(crate) fn drafts(mut self, editing: Option<(usize, &'r str)>, reply: &'r str) -> Self {
|
||||
self.editing = editing;
|
||||
|
||||
@@ -60,9 +60,12 @@ pub struct LegacyFile<T> {
|
||||
/// store reports them in [`LoadReport::section_errors`](crate::LoadReport::section_errors), the
|
||||
/// same place a `config.toml` load puts its own. An `Err` means the file is unusable and the
|
||||
/// next legacy file is tried.
|
||||
pub parse: fn(&[u8]) -> Result<(T, Vec<SectionError>), String>,
|
||||
pub parse: ParseLegacy<T>,
|
||||
}
|
||||
|
||||
/// Parses a legacy file's bytes: the value and the values reset to defaults, or why the file is unusable.
|
||||
pub type ParseLegacy<T> = fn(&[u8]) -> Result<(T, Vec<SectionError>), String>;
|
||||
|
||||
/// A legacy file that parsed: its value, the values reset to defaults, and where it was.
|
||||
pub type Imported<T> = (T, Vec<SectionError>, PathBuf);
|
||||
|
||||
|
||||
@@ -378,7 +378,7 @@ impl MediaControls {
|
||||
let mut slider =
|
||||
Slider::new(Bind::given(position), range).step(NUDGE).sizing(Sizing::FillWidth).enabled(playable).label(words.seek.clone());
|
||||
if let Some((start, end)) = trim.filter(|_| playable) {
|
||||
slider = slider.trim(start, end);
|
||||
slider = slider.trim(start..=end);
|
||||
}
|
||||
let edit = slider.show(ui);
|
||||
seek = edit.events;
|
||||
|
||||
@@ -191,7 +191,11 @@ pub struct Canvas<'a> {
|
||||
context_key: bool,
|
||||
/// The ease the app asked for from the view it drew ([`ease_from`](Self::ease_from)).
|
||||
ease: Option<Steer>,
|
||||
/// The app's tool moves the view with the pointer this pass ([`view_follows_pointer`](Self::view_follows_pointer)).
|
||||
/// The app's tool moves the view with the pointer this pass (an image-moving crop slides the view by fractional
|
||||
/// pointer distances under a frame that stays put): the shown view stays as given, not [`pixel_aligned`], so the
|
||||
/// picture and the frame do not jitter by part of a pixel as the pointer moves. P-15: the tool host passes the
|
||||
/// framework `CropTool`'s image mode.
|
||||
#[prop(name = "view_follows_pointer")]
|
||||
follows_pointer: bool,
|
||||
/// The slot the body's paint reserved for the picture, published in the [`CanvasSpace`]; none in a measuring pass.
|
||||
picture: Option<space::PictureSlot>,
|
||||
@@ -280,16 +284,6 @@ impl<'a> Canvas<'a> {
|
||||
self
|
||||
}
|
||||
|
||||
/// The app's tool moves the view with the pointer this pass (an image-moving crop slides the view by fractional
|
||||
/// pointer distances under a frame that stays put): the shown view stays as given, not [`pixel_aligned`], so the
|
||||
/// picture and the frame do not jitter by part of a pixel as the pointer moves. P-15: the tool host passes the
|
||||
/// framework `CropTool`'s image mode.
|
||||
#[must_use]
|
||||
pub fn view_follows_pointer(mut self, follows: bool) -> Self {
|
||||
self.follows_pointer = follows;
|
||||
self
|
||||
}
|
||||
|
||||
/// Leaves the view commands to the instance around the canvas that owns its view (a full-window dialog's): the
|
||||
/// canvas is no instance of them, so the chords reach that instance while the canvas has the focus.
|
||||
#[must_use]
|
||||
|
||||
@@ -35,7 +35,7 @@ impl Outcome for NavigateBarOutput {
|
||||
}
|
||||
|
||||
/// The members of one tool's bar.
|
||||
#[expect(clippy::large_enum_variant, reason = "built once per frame and matched at once; boxing the Zoom variant would allocate every frame")]
|
||||
#[allow(clippy::large_enum_variant, reason = "built once per frame and matched at once; boxing the Zoom variant would allocate every frame")]
|
||||
enum Members<'a> {
|
||||
Zoom { view: Bind<'a, CanvasView>, target: ViewTarget, options: &'a mut NavigationOptions, out: Bind<'a, bool> },
|
||||
RotateView { view: Bind<'a, CanvasView> },
|
||||
|
||||
@@ -24,10 +24,10 @@ const ROTATE_STEP_DEG: f64 = 15.0;
|
||||
|
||||
/// The room Fit Artboard on Screen leaves around the board, in points: at the sides, and above and below (the board's
|
||||
/// name sits above it).
|
||||
const ARTBOARD_MARGIN: Vec2 = Vec2::new(30.0, 40.0);
|
||||
const ARTBOARD_MARGIN: Vec2 = Vec2::new(30.0, 40.0); // design: allow[literal-size/vec2](view-fit room in screen points, not a look)
|
||||
|
||||
/// The room Fit Layers on Screen leaves around the layers' bounds, in points.
|
||||
const LAYERS_MARGIN: Vec2 = Vec2::new(20.0, 20.0);
|
||||
const LAYERS_MARGIN: Vec2 = Vec2::new(20.0, 20.0); // design: allow[literal-size/vec2](view-fit room in screen points, not a look)
|
||||
|
||||
/// Photoshop's default Screen Resolution (Preferences, Units & Rulers), in pixels per inch.
|
||||
const SCREEN_PPI: f64 = 72.0;
|
||||
|
||||
@@ -161,7 +161,7 @@ fn tip_of(tip: StoryTip, dimensions: BrushDimensions, pointer: Option<Point>) ->
|
||||
let normal = (edge.core() + edge.reach()) / 2.0;
|
||||
match tip {
|
||||
StoryTip::Round => (BrushTip::round(dimensions.diameter, normal), TipPose::upright()),
|
||||
StoryTip::ThinEllipse => (BrushTip::round(dimensions.diameter, normal), TipPose::new(Vec2::new(1.0, 0.0), Vec2::new(0.0, THIN))),
|
||||
StoryTip::ThinEllipse => (BrushTip::round(dimensions.diameter, normal), TipPose::new(Vec2::from((1.0, 0.0)), Vec2::from((0.0, THIN)))),
|
||||
StoryTip::Star => {
|
||||
let share = (normal / full.max(f64::EPSILON)) as f32;
|
||||
let scaled =
|
||||
|
||||
@@ -826,7 +826,7 @@ impl<C: Container> ShapeHooks<C> for BodyHooks<'_> {
|
||||
let body_env = line_env.derive_local(|scoped| {
|
||||
let label_width = label_extra.x;
|
||||
self.scope_body(scoped, &props, id, BodyScope { room, real, sizing, content_column, scroll, label_width, beside: regions.beside });
|
||||
scoped.inside_label = inside;
|
||||
scoped.inside_label = inside.map(|inside| inside as crate::runtime::env::Held);
|
||||
scoped.cell_fills = cell_fills;
|
||||
// A scrolling body shows its first child wherever the view is: the container has no first line there.
|
||||
scoped.first_line = (!real && scroll.is_none()).then_some(first_body);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
//! A collection's columns: kinds, specs, alignment, toggle columns and the sort.
|
||||
|
||||
pub use crate::runtime::env::ColumnAlign;
|
||||
use crate::runtime::env::Label;
|
||||
use craft_behavior::{ColumnKey, ColumnWidth};
|
||||
use craft_keymap::Chord;
|
||||
@@ -96,16 +97,6 @@ pub struct ColumnSpec {
|
||||
pub hideable: bool,
|
||||
}
|
||||
|
||||
/// Where a column's content sits.
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
|
||||
pub enum ColumnAlign {
|
||||
/// At the start edge.
|
||||
#[default]
|
||||
Start,
|
||||
/// At the end edge.
|
||||
End,
|
||||
}
|
||||
|
||||
impl ColumnSpec {
|
||||
/// A content column with a header and a width; the other settings off.
|
||||
pub fn new(key: ColumnKey, header: impl Into<Label>, width: ColumnWidth) -> Self {
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
use super::columns::{ColumnSort, ColumnSpec};
|
||||
use super::events::ListDrag;
|
||||
use crate::contract::Notch;
|
||||
pub use crate::runtime::env::RowPressed;
|
||||
use crate::runtime::env::{Counted, Label};
|
||||
use crate::style::StyleCx;
|
||||
use craft_behavior::{Axis, ColumnKey};
|
||||
@@ -594,22 +595,6 @@ impl CollectionProps {
|
||||
}
|
||||
}
|
||||
|
||||
/// Where the collection holds a primary press on a row, within slop, or the press a part of the row holds.
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
#[non_exhaustive]
|
||||
pub enum RowPressed {
|
||||
/// On the row's own area.
|
||||
Row,
|
||||
/// On the cell of this toggle column, which the press flips.
|
||||
Cell(ColumnKey),
|
||||
/// On a part of the item that took the press itself (a row's trailing button).
|
||||
#[non_exhaustive]
|
||||
Part {
|
||||
/// The row held the lead when the press began: a press on a part moves the lead to its row.
|
||||
was_lead: bool,
|
||||
},
|
||||
}
|
||||
|
||||
/// What an item reads of its place in the collection; the item step joins it to the item's flags at step 12.
|
||||
#[derive(Clone, Debug, Default, PartialEq, Eq)]
|
||||
pub struct RowState {
|
||||
|
||||
@@ -15,7 +15,8 @@ use craft_theme::ControlSize;
|
||||
use craft_theme::variant::Tone;
|
||||
use egui::Rect;
|
||||
|
||||
pub use crate::runtime::env::ThemeScope;
|
||||
pub use crate::runtime::env::{InBar, PaneEdge, ThemeScope};
|
||||
pub use crate::style::BandFill;
|
||||
|
||||
/// Where a container lives.
|
||||
#[derive(Clone, Debug, Default, PartialEq)]
|
||||
@@ -65,23 +66,6 @@ impl Mount {
|
||||
}
|
||||
}
|
||||
|
||||
/// Where a shell pane sits.
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
|
||||
#[non_exhaustive]
|
||||
pub enum PaneEdge {
|
||||
/// What the edge panes leave.
|
||||
#[default]
|
||||
Center,
|
||||
/// The start edge: left in reading order, right under right-to-left.
|
||||
Start,
|
||||
/// The end edge.
|
||||
End,
|
||||
/// The top edge.
|
||||
Top,
|
||||
/// The bottom edge.
|
||||
Bottom,
|
||||
}
|
||||
|
||||
/// One of `AppShell`'s panes.
|
||||
///
|
||||
/// A pane is placed one of three ways. With [`at`](Self::at) it fills the rect its caller laid out, takes no room from
|
||||
@@ -259,6 +243,7 @@ impl HeaderParts {
|
||||
|
||||
/// An edge of a header's line, where a container's own header parts sit.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
#[non_exhaustive]
|
||||
pub enum HeaderEdge {
|
||||
/// The start edge: the parts there come before the header's children, in Tab order too.
|
||||
Start,
|
||||
@@ -266,16 +251,6 @@ pub enum HeaderEdge {
|
||||
End,
|
||||
}
|
||||
|
||||
/// What the band behind a header paints.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
#[non_exhaustive]
|
||||
pub enum BandFill {
|
||||
/// A surface's fill.
|
||||
Surface(SurfaceKind),
|
||||
/// A tone's tinted fill (`Tone::soft_fill`).
|
||||
Tone(Tone),
|
||||
}
|
||||
|
||||
/// A header region, filled by `Container::header`.
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
|
||||
#[non_exhaustive]
|
||||
@@ -670,20 +645,6 @@ pub enum Gap {
|
||||
Inline,
|
||||
}
|
||||
|
||||
/// Set by a bar for its body: its fields put `space.gap.item` between a caption and the control, a vertical divider
|
||||
/// takes a box wider than its line, a select fits its widest entry up to a field length, a rule shows only with the
|
||||
/// member after it, and a row too long for its room narrows its last units first. A layer or pane opened from the bar
|
||||
/// starts without it.
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
|
||||
#[doc(hidden)]
|
||||
pub struct InBar(pub bool);
|
||||
|
||||
impl EnvValue for InBar {
|
||||
fn root() -> Self {
|
||||
InBar(false)
|
||||
}
|
||||
}
|
||||
|
||||
/// Set by a menu for its body: a horizontal divider takes `space.gap.inline` above and below its line, since the rows
|
||||
/// of a menu touch.
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
|
||||
|
||||
@@ -396,7 +396,7 @@ pub(crate) fn child_env(env: &Env, under: &Under) -> Env {
|
||||
env.derive_local(|scoped| {
|
||||
scoped.enabled &= under.enabled;
|
||||
scoped.size = under.size;
|
||||
scoped.inside_label.clone_from(&under.inside);
|
||||
scoped.inside_label = under.inside.clone().map(|inside| inside as crate::runtime::env::Held);
|
||||
scoped.cell_fills = false;
|
||||
})
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
//! image a window shows as its cursor. Both come from the one list, so the two look the same.
|
||||
|
||||
use crate::primitives::SvgIcon;
|
||||
use crate::runtime::cursor::CursorBitmap;
|
||||
use crate::runtime::cursor::{CursorArt, CursorBitmap};
|
||||
use egui::{Color32, Painter, Pos2, Rect, Shape, Stroke, Vec2};
|
||||
use resvg::tiny_skia;
|
||||
use std::sync::Arc;
|
||||
@@ -95,7 +95,7 @@ impl Art {
|
||||
/// The art as a cursor image at `scale` device pixels per point, its hotspot on the centre pixel of an odd square;
|
||||
/// `None` for art with no marks, with a size that is not finite, or wider than `max_side` pixels. The size is
|
||||
/// checked before anything is allocated.
|
||||
pub(crate) fn rasterise(&self, scale: f32, max_side: u16) -> Option<CursorBitmap> {
|
||||
fn rasterise_art(&self, scale: f32, max_side: u16) -> Option<CursorBitmap> {
|
||||
if !scale.is_finite() || scale <= 0.0 {
|
||||
return None;
|
||||
}
|
||||
@@ -244,3 +244,9 @@ fn composite(pixmap: &mut tiny_skia::Pixmap, mask: &egui::ColorImage, left: i64,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl CursorArt for Art {
|
||||
fn rasterise(&self, scale: f32, max_side: u16) -> Option<CursorBitmap> {
|
||||
self.rasterise_art(scale, max_side)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -154,6 +154,14 @@ impl InsideLabel {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> EnvView<'a> {
|
||||
/// The inside label the component shows in its slot, when it is the control of a side label with
|
||||
/// `FieldLayout::Inside`.
|
||||
pub fn inside_label(&self) -> Option<&'a InsideLabel> {
|
||||
self.inside_held().and_then(|held| held.downcast_ref())
|
||||
}
|
||||
}
|
||||
|
||||
/// The inside label a control under `side` shows in its slot: `Some` for a glyph label with `FieldLayout::Inside`.
|
||||
pub(crate) fn inside(env: EnvView<'_>, side: &SideLabel, enabled: bool) -> Option<Arc<InsideLabel>> {
|
||||
let LabelKind::Glyph(glyph) = &side.kind else { return None };
|
||||
|
||||
@@ -289,7 +289,10 @@ pub(crate) fn flow_leaf<C: Show>(
|
||||
report_after_reach(ui.ctx(), &env, &side, (avail, control), extent);
|
||||
}
|
||||
// The child runs under the inside label its measures saw.
|
||||
let installed = under.inside.clone().map(|inside| Env::install_for(ui, env.derive_local(|scoped| scoped.inside_label = Some(inside))));
|
||||
let installed = under
|
||||
.inside
|
||||
.clone()
|
||||
.map(|inside| Env::install_for(ui, env.derive_local(|scoped| scoped.inside_label = Some(inside as crate::runtime::env::Held))));
|
||||
// The control and its label are one member of a bar's line: judged together, and hidden together, as the label
|
||||
// step hid the label.
|
||||
let shown_clip = ui.clip_rect();
|
||||
|
||||
@@ -51,6 +51,7 @@ fn stored_opening(ctx: &Context, id: Id) -> Option<Opening> {
|
||||
/// bar stay below the bar ([`OverlayUi::contain_popups_below`](super::OverlayUi::contain_popups_below)). `None`, the
|
||||
/// root's, lets popups take the whole safe rect.
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq)]
|
||||
#[non_exhaustive]
|
||||
pub struct PopupRegion(pub Option<Rect>);
|
||||
|
||||
impl crate::runtime::env::EnvValue for PopupRegion {
|
||||
|
||||
@@ -6,11 +6,11 @@ use super::run::{self, FaceSource, ShowAt};
|
||||
use super::{ContentPainter, Cx, Show, TipFn};
|
||||
use super::{InsideLabel, SideLabel};
|
||||
use crate::primitives::sensing::PartResults;
|
||||
use crate::primitives::{ContentPainterCx, DataMode, Draw, DrawEnv, PaintRecord, TextRun, Wrap};
|
||||
use crate::primitives::text_adapter;
|
||||
use crate::primitives::{ContentPainterCx, DataMode, Draw, DrawEnv, PaintRecord, TextRun};
|
||||
use crate::runtime::access;
|
||||
use crate::runtime::egui::{alloc, child, focus as egui_focus, text_edit};
|
||||
use crate::runtime::egui::{alloc, child};
|
||||
use crate::runtime::env::{Env, Label};
|
||||
use crate::runtime::focus::KeepKeys;
|
||||
use crate::runtime::layout_memory;
|
||||
use crate::runtime::memory::sub;
|
||||
use crate::style::{Flags, Ink, Stateful, StyleColor, StyleCx};
|
||||
@@ -76,46 +76,12 @@ impl PaintUi<'_> {
|
||||
}
|
||||
let (layout, at) = self.draw().place_text(rect, run);
|
||||
self.record.borrow_mut().baseline.get_or_insert(at.y + layout.first_baseline);
|
||||
let ctx = self.ui.ctx().clone();
|
||||
let widget = super::text::selection_id(self.id, part);
|
||||
let multiline = run.wrap == Wrap::Wrap;
|
||||
let keep = if multiline { KeepKeys::BlockArrows } else { KeepKeys::InlineArrows };
|
||||
let mut shown = layout.full.clone();
|
||||
// A line longer than its room is cut at the room's edge, as a field's is.
|
||||
let mut cut = (layout.size().x > rect.width()).then(|| {
|
||||
let mut cut = alloc::child(self.ui, egui::UiBuilder::new().max_rect(rect));
|
||||
cut.set_clip_rect(rect.intersect(cut.clip_rect()));
|
||||
cut
|
||||
});
|
||||
text_edit::show(
|
||||
cut.as_mut().unwrap_or(&mut *self.ui),
|
||||
text_edit::Edit {
|
||||
id: widget,
|
||||
rect: layout.galley.rect.translate(at.to_vec2()),
|
||||
text: &mut shown,
|
||||
read_only: true,
|
||||
enabled: self.enabled,
|
||||
focusable: self.enabled,
|
||||
pointer: true,
|
||||
multiline,
|
||||
password: false,
|
||||
hint: None,
|
||||
mono: false,
|
||||
role: run.role,
|
||||
ink: crate::style::ink_color(&self.env.tokens, self.ink),
|
||||
filter: egui_focus::event_filter(keep, false),
|
||||
char_limit: None,
|
||||
preedit: None,
|
||||
rtl: false,
|
||||
centred: false,
|
||||
caret_visible: false,
|
||||
underline: 0.0,
|
||||
galley: Some(layout.galley.clone()),
|
||||
},
|
||||
let ink = crate::style::ink_color(&self.env.tokens, self.ink);
|
||||
text_adapter::show_selectable(
|
||||
self.ui,
|
||||
text_adapter::Selectable { widget, owner: self.id, rect, layout: &layout, at, run, enabled: self.enabled, ink },
|
||||
);
|
||||
if crate::runtime::egui::access::enabled(&ctx, widget) {
|
||||
crate::runtime::egui::access::fold_widget(&ctx, widget, self.id);
|
||||
}
|
||||
}
|
||||
|
||||
/// The content-paint API for painting `part`: as [`draw`](Self::draw), and when the part was declared
|
||||
|
||||
@@ -1208,7 +1208,7 @@ pub(crate) struct BarRules(HashMap<Id, Vec<HeldRule>>);
|
||||
|
||||
/// A rule's paint: `shapes` of the paint list of `layer`, in the pass `pass`.
|
||||
struct HeldRule {
|
||||
layer: egui::LayerId,
|
||||
layer: crate::runtime::egui::areas::Layer,
|
||||
shapes: std::ops::Range<usize>,
|
||||
pass: u64,
|
||||
}
|
||||
|
||||
@@ -262,6 +262,7 @@ struct Reported {
|
||||
|
||||
/// The widths of a unit of a row that shrinks to fit: the width it asks for and the least it narrows to.
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
#[non_exhaustive]
|
||||
pub struct ShrinkUnit {
|
||||
/// The width the unit takes where the row has room.
|
||||
pub ideal: f32,
|
||||
@@ -269,6 +270,13 @@ pub struct ShrinkUnit {
|
||||
pub least: f32,
|
||||
}
|
||||
|
||||
impl ShrinkUnit {
|
||||
/// A unit that asks for `ideal` and narrows to `least`.
|
||||
pub const fn new(ideal: f32, least: f32) -> Self {
|
||||
ShrinkUnit { ideal, least }
|
||||
}
|
||||
}
|
||||
|
||||
/// The units each `Row` body counting this pass reported, in order, by body id.
|
||||
#[derive(Default)]
|
||||
pub(crate) struct ShrinkReports(HashMap<Id, Vec<Reported>>);
|
||||
|
||||
@@ -180,7 +180,7 @@ impl DataMode {
|
||||
/// The mode of a component painting in `state`: `Dimmed` in its Disabled state, which step 12 gives a disabled
|
||||
/// component that is not faded as a whole.
|
||||
pub(crate) fn of(state: &crate::style::StateSet) -> Self {
|
||||
if state.state == craft_theme::State::Disabled { DataMode::Dimmed } else { DataMode::Full }
|
||||
if state.is_disabled() { DataMode::Dimmed } else { DataMode::Full }
|
||||
}
|
||||
|
||||
/// A colour from data as this mode paints it.
|
||||
|
||||
@@ -119,6 +119,7 @@ impl Checker {
|
||||
|
||||
/// Where a [`Checker`] paints.
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
#[non_exhaustive]
|
||||
pub enum CheckerArea {
|
||||
/// A rect with these corners.
|
||||
Rect(Rect, CornerRadius),
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
use crate::fonts::StackFacts;
|
||||
use crate::runtime::egui::text_layout;
|
||||
pub use crate::style::Span;
|
||||
use crate::style::text_measure::{paragraph_job, span_format};
|
||||
use crate::style::{StyleColor, TypeRole, UiTokens};
|
||||
use craft_i18n::Direction;
|
||||
@@ -53,95 +54,6 @@ pub enum HAlign {
|
||||
End,
|
||||
}
|
||||
|
||||
/// One styled stretch of a run.
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
#[non_exhaustive]
|
||||
pub struct Span<'a> {
|
||||
/// The text.
|
||||
pub text: Cow<'a, str>,
|
||||
/// Italic.
|
||||
pub italic: bool,
|
||||
/// Tabular figures.
|
||||
pub tabular: bool,
|
||||
/// The monospace face.
|
||||
pub mono: bool,
|
||||
/// The muted text colour.
|
||||
pub muted: bool,
|
||||
/// A shortcut hint: muted.
|
||||
pub shortcut: bool,
|
||||
/// A search match highlight.
|
||||
pub highlight: bool,
|
||||
/// Underlined in the span's colour, `stroke.thin` wide, along the bottom of the line box.
|
||||
pub underline: bool,
|
||||
/// The role's semibold face, at the role's size.
|
||||
pub strong: bool,
|
||||
}
|
||||
|
||||
impl<'a> Span<'a> {
|
||||
/// A plain span.
|
||||
pub fn new(text: impl Into<Cow<'a, str>>) -> Self {
|
||||
Span {
|
||||
text: text.into(),
|
||||
italic: false,
|
||||
tabular: false,
|
||||
mono: false,
|
||||
muted: false,
|
||||
shortcut: false,
|
||||
highlight: false,
|
||||
underline: false,
|
||||
strong: false,
|
||||
}
|
||||
}
|
||||
|
||||
/// Italic.
|
||||
pub fn italic(mut self) -> Self {
|
||||
self.italic = true;
|
||||
self
|
||||
}
|
||||
|
||||
/// Tabular figures.
|
||||
pub fn tabular(mut self) -> Self {
|
||||
self.tabular = true;
|
||||
self
|
||||
}
|
||||
|
||||
/// The monospace face.
|
||||
pub fn mono(mut self) -> Self {
|
||||
self.mono = true;
|
||||
self
|
||||
}
|
||||
|
||||
/// The muted colour.
|
||||
pub fn muted(mut self) -> Self {
|
||||
self.muted = true;
|
||||
self
|
||||
}
|
||||
|
||||
/// A shortcut hint.
|
||||
pub fn shortcut(mut self) -> Self {
|
||||
self.shortcut = true;
|
||||
self
|
||||
}
|
||||
|
||||
/// A match highlight.
|
||||
pub fn highlight(mut self) -> Self {
|
||||
self.highlight = true;
|
||||
self
|
||||
}
|
||||
|
||||
/// Underlined: a link, or the mnemonic letter of a menu title.
|
||||
pub fn underline(mut self) -> Self {
|
||||
self.underline = true;
|
||||
self
|
||||
}
|
||||
|
||||
/// The role's semibold face: a short mark that stands out among the row's other text, such as a layer's `fx`.
|
||||
pub fn strong(mut self) -> Self {
|
||||
self.strong = true;
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
/// The one description of UI text.
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
#[non_exhaustive]
|
||||
|
||||
@@ -320,7 +320,7 @@ pub(crate) fn select(ctx: &Context, id: Id, anchor: usize, caret: usize) {
|
||||
/// `TextOptions::arrows_from_end`: before the widget reads a plain Left or Right, a selection of the whole text
|
||||
/// collapses to its end.
|
||||
fn arrows_from_end(ctx: &Context, widget: Id, len: usize) {
|
||||
let arrow = ctx.input(|input| input.modifiers.is_none() && (input.key_pressed(egui::Key::ArrowLeft) || input.key_pressed(egui::Key::ArrowRight)));
|
||||
let arrow = egui_input::plain_horizontal_arrow_pressed(ctx);
|
||||
let whole = selection(ctx, widget).is_some_and(|(caret, anchor)| caret.min(anchor) == 0 && caret.max(anchor) == len);
|
||||
if arrow && len > 0 && whole {
|
||||
select(ctx, widget, len, len);
|
||||
@@ -486,3 +486,65 @@ pub(crate) fn run(state: &mut TextState, mut input: AdapterIn<'_>) -> AdapterOut
|
||||
let baseline = (!layout.full.is_empty()).then_some(shown.galley_pos.y + layout.first_baseline);
|
||||
AdapterOut { layout, focused: shown.focused, baseline }
|
||||
}
|
||||
|
||||
/// What [`show_selectable`] shows: the read-only text of a selection part.
|
||||
pub(crate) struct Selectable<'a> {
|
||||
/// The id of the selection widget.
|
||||
pub widget: Id,
|
||||
/// The component the widget's access node folds into.
|
||||
pub owner: Id,
|
||||
/// The room the text is painted in; a line wider than it is cut at its edge.
|
||||
pub rect: Rect,
|
||||
/// The laid-out text and the point it was placed at.
|
||||
pub layout: &'a TextLayout,
|
||||
pub at: Pos2,
|
||||
pub run: &'a crate::primitives::TextRun<'a>,
|
||||
pub enabled: bool,
|
||||
/// The text colour.
|
||||
pub ink: egui::Color32,
|
||||
}
|
||||
|
||||
/// Shows `text` as a read-only selectable widget over its painted lines: the selection behind the characters, the copy
|
||||
/// command and the pointer's selecting, without a caret.
|
||||
pub(crate) fn show_selectable(ui: &mut Ui, text: Selectable<'_>) {
|
||||
let Selectable { widget, owner, rect, layout, at, run, enabled, ink } = text;
|
||||
let ctx = ui.ctx().clone();
|
||||
let multiline = run.wrap == crate::primitives::Wrap::Wrap;
|
||||
let keep = if multiline { KeepKeys::BlockArrows } else { KeepKeys::InlineArrows };
|
||||
let mut shown = layout.full.clone();
|
||||
// A line longer than its room is cut at the room's edge, as a field's is.
|
||||
let mut cut = (layout.size().x > rect.width()).then(|| {
|
||||
let mut cut = crate::runtime::egui::alloc::child(ui, egui::UiBuilder::new().max_rect(rect));
|
||||
cut.set_clip_rect(rect.intersect(cut.clip_rect()));
|
||||
cut
|
||||
});
|
||||
text_edit::show(
|
||||
cut.as_mut().unwrap_or(&mut *ui),
|
||||
text_edit::Edit {
|
||||
id: widget,
|
||||
rect: layout.galley.rect.translate(at.to_vec2()),
|
||||
text: &mut shown,
|
||||
read_only: true,
|
||||
enabled,
|
||||
focusable: enabled,
|
||||
pointer: true,
|
||||
multiline,
|
||||
password: false,
|
||||
hint: None,
|
||||
mono: false,
|
||||
role: run.role,
|
||||
ink,
|
||||
filter: egui_focus::event_filter(keep, false),
|
||||
char_limit: None,
|
||||
preedit: None,
|
||||
rtl: false,
|
||||
centred: false,
|
||||
caret_visible: false,
|
||||
underline: 0.0,
|
||||
galley: Some(layout.galley.clone()),
|
||||
},
|
||||
);
|
||||
if crate::runtime::egui::access::enabled(&ctx, widget) {
|
||||
crate::runtime::egui::access::fold_widget(&ctx, widget, owner);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,13 +82,7 @@ impl Role {
|
||||
/// or flips a value on a click (a check box, radio button, switch or colour well); none for the rest.
|
||||
pub const fn hover_cursor(self) -> Option<craft_behavior::CursorIcon> {
|
||||
match self {
|
||||
Role::Node(
|
||||
accesskit::Role::Link
|
||||
| accesskit::Role::CheckBox
|
||||
| accesskit::Role::RadioButton
|
||||
| accesskit::Role::Switch
|
||||
| accesskit::Role::ColorWell,
|
||||
) => Some(craft_behavior::CursorIcon::PointingHand),
|
||||
Role::LINK | Role::CHECK_BOX | Role::RADIO_BUTTON | Role::SWITCH | Role::COLOR_WELL => Some(craft_behavior::CursorIcon::PointingHand),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
//! The cursor service (8.5): requests of a pass collect here, the end hook picks the winner and records it, and a
|
||||
//! painted winner reaches the window as its cursor image where the window shows one.
|
||||
|
||||
use crate::contract::ghost::Art;
|
||||
use crate::runtime::egui::{output, pass, viewports};
|
||||
use crate::runtime::frame::PerViewport;
|
||||
use crate::runtime::windows;
|
||||
@@ -9,6 +8,7 @@ use craft_behavior::cursor::pick;
|
||||
use craft_behavior::{Cursor, CursorIcon, CursorPriority, PaintedCursor};
|
||||
use craft_host::target::Os;
|
||||
use egui::{Context, ViewportId};
|
||||
use std::any::Any;
|
||||
use std::sync::Arc;
|
||||
|
||||
/// The largest side of a cursor image in device pixels on Linux, where X servers and hardware cursor planes commonly
|
||||
@@ -44,7 +44,7 @@ pub(crate) struct State {
|
||||
record: Option<Cursor>,
|
||||
/// The last image handed to the window with the art and scale it was drawn from. egui-winit uploads an image to
|
||||
/// the OS whenever its `Arc` changes, so an unchanged pointer hands over the same one.
|
||||
image: Option<(Art, f32, CursorBitmap)>,
|
||||
image: Option<(Box<dyn Any + Send + Sync>, f32, CursorBitmap)>,
|
||||
}
|
||||
|
||||
/// Requests `cursor` for the running pass of this viewport.
|
||||
@@ -104,19 +104,25 @@ pub(crate) fn image_target(ctx: &Context) -> Option<ImageTarget> {
|
||||
})
|
||||
}
|
||||
|
||||
/// A painted pointer the window can take as its cursor image: drawn at a scale, compared with the last one handed over.
|
||||
pub(crate) trait CursorArt: Any + Clone + PartialEq + Send + Sync {
|
||||
/// The image at `scale` device pixels per point, `None` where the art has none at that size.
|
||||
fn rasterise(&self, scale: f32, max_side: u16) -> Option<CursorBitmap>;
|
||||
}
|
||||
|
||||
/// Hands `art` to the window as its cursor image at `target`, drawing it only when the art or the scale changed since
|
||||
/// the last image; the crosshair is the system cursor an integration that cannot take the image falls back to.
|
||||
/// Returns false, and hands nothing over, when the art has no image at that size.
|
||||
pub(crate) fn show_image(ctx: &Context, art: &Art, target: ImageTarget) -> bool {
|
||||
pub(crate) fn show_image<A: CursorArt>(ctx: &Context, art: &A, target: ImageTarget) -> bool {
|
||||
let bitmap = PerViewport::<State>::with(ctx, pass::current_viewport(ctx), |state| {
|
||||
if let Some((last, scale, bitmap)) = &state.image
|
||||
&& last == art
|
||||
&& last.downcast_ref::<A>() == Some(art)
|
||||
&& *scale == target.scale
|
||||
{
|
||||
return Some(bitmap.clone());
|
||||
}
|
||||
let bitmap = art.rasterise(target.scale, target.max_side)?;
|
||||
state.image = Some((art.clone(), target.scale, bitmap.clone()));
|
||||
state.image = Some((Box::new(art.clone()), target.scale, bitmap.clone()));
|
||||
Some(bitmap)
|
||||
});
|
||||
let Some(bitmap) = bitmap else { return false };
|
||||
|
||||
@@ -141,7 +141,7 @@ pub struct DropZone {
|
||||
|
||||
impl DropZone {
|
||||
/// The zone `rect` on `layer` (the `layer_id` of the `Ui` that draws the area), in that layer's space.
|
||||
pub const fn new(layer: egui::LayerId, rect: Rect) -> Self {
|
||||
pub const fn new(layer: crate::runtime::egui::areas::Layer, rect: Rect) -> Self {
|
||||
DropZone { layer, rect }
|
||||
}
|
||||
|
||||
|
||||
@@ -44,6 +44,16 @@ fn behind_modal(ctx: &Context, viewport: ViewportId, layer: egui::LayerId) -> bo
|
||||
crate::runtime::commands::modal_root(ctx, viewport).is_some() && !ctx.memory(|memory| memory.is_above_modal_layer(layer))
|
||||
}
|
||||
|
||||
/// The AccessKit id of a node, as a host test holds it.
|
||||
#[cfg(feature = "testing")]
|
||||
pub type NodeId = accesskit::NodeId;
|
||||
|
||||
/// The AccessKit id of the node of `id`.
|
||||
#[cfg(feature = "testing")]
|
||||
pub(crate) fn node_id(id: Id) -> NodeId {
|
||||
id.accesskit_id()
|
||||
}
|
||||
|
||||
/// The AccessKit role of a node.
|
||||
pub(crate) type NodeRole = accesskit::Role;
|
||||
|
||||
|
||||
@@ -399,3 +399,26 @@ pub(crate) fn widest_layer(ctx: &Context) -> f32 {
|
||||
.fold(0.0, f32::max)
|
||||
})
|
||||
}
|
||||
|
||||
/// Whether an egui popup of the running viewport is open: an app's own popup or menu, which reads its keys from egui.
|
||||
pub(crate) fn popup_open(ctx: &Context) -> bool {
|
||||
egui::Popup::is_any_open(ctx)
|
||||
}
|
||||
|
||||
/// A host's own egui popup `id` at `at`, shown while egui's memory holds it open.
|
||||
#[cfg(feature = "testing")]
|
||||
pub(crate) fn host_popup(ui: &Ui, id: egui::Id, at: Pos2) {
|
||||
egui::Popup::new(id, ui.ctx().clone(), at, ui.layer_id()).open_memory(None).show(|ui| ui.allocate_space(ui.spacing().interact_size));
|
||||
}
|
||||
|
||||
/// Opens the host's egui popup `id`.
|
||||
#[cfg(feature = "testing")]
|
||||
pub(crate) fn open_host_popup(ctx: &Context, id: egui::Id) {
|
||||
egui::Popup::open_id(ctx, id);
|
||||
}
|
||||
|
||||
/// Whether the host's egui popup `id` is open.
|
||||
#[cfg(feature = "testing")]
|
||||
pub(crate) fn host_popup_open(ctx: &Context, id: egui::Id) -> bool {
|
||||
egui::Popup::is_id_open(ctx, id)
|
||||
}
|
||||
|
||||
@@ -443,21 +443,6 @@ pub(crate) fn host_label(ui: &mut Ui, text: &str) -> Rect {
|
||||
ui.add(egui::Label::new(text).selectable(true)).rect
|
||||
}
|
||||
|
||||
/// A host's own egui popup `id` at `at`, shown while egui's memory holds it open.
|
||||
pub(crate) fn host_popup(ui: &Ui, id: egui::Id, at: Pos2) {
|
||||
egui::Popup::new(id, ui.ctx().clone(), at, ui.layer_id()).open_memory(None).show(|ui| ui.allocate_space(ui.spacing().interact_size));
|
||||
}
|
||||
|
||||
/// Opens the host's egui popup `id`.
|
||||
pub(crate) fn open_host_popup(ctx: &Context, id: egui::Id) {
|
||||
egui::Popup::open_id(ctx, id);
|
||||
}
|
||||
|
||||
/// Whether the host's egui popup `id` is open.
|
||||
pub(crate) fn host_popup_open(ctx: &Context, id: egui::Id) -> bool {
|
||||
egui::Popup::is_id_open(ctx, id)
|
||||
}
|
||||
|
||||
/// The egui layer `ui` paints on.
|
||||
pub(crate) fn layer_of(ui: &Ui) -> egui::LayerId {
|
||||
ui.layer_id()
|
||||
|
||||
@@ -27,11 +27,6 @@ pub(crate) fn focused(ctx: &Context) -> Option<Id> {
|
||||
ctx.memory(|memory| memory.focused())
|
||||
}
|
||||
|
||||
/// Whether an egui popup of the running viewport is open: an app's own popup or menu, which reads its keys from egui.
|
||||
pub(crate) fn popup_open(ctx: &Context) -> bool {
|
||||
egui::Popup::is_any_open(ctx)
|
||||
}
|
||||
|
||||
/// Whether egui holds a label text selection, which egui copies on a copy or cut event.
|
||||
pub(crate) fn label_selection(ctx: &Context) -> bool {
|
||||
ctx.with_plugin::<egui::text_selection::LabelSelectionState, _>(|state| state.has_selection()).unwrap_or(false)
|
||||
|
||||
@@ -610,3 +610,18 @@ pub(crate) fn prepare(ctx: &Context, input: &mut RawInput) {
|
||||
let events = &mut input.events;
|
||||
PerViewport::<RawState>::with(ctx, input.viewport_id, |state| state.control_click.normalize(events, macos));
|
||||
}
|
||||
|
||||
/// The widget egui holds a drag on.
|
||||
pub(crate) fn dragged(ctx: &Context) -> Option<Id> {
|
||||
ctx.dragged_id()
|
||||
}
|
||||
|
||||
/// Where the press that is held down began, while a button is down.
|
||||
pub(crate) fn held_press_origin(ctx: &Context) -> Option<Pos2> {
|
||||
ctx.input(|input| if input.pointer.any_down() { input.pointer.press_origin() } else { None })
|
||||
}
|
||||
|
||||
/// A plain Left or Right arrow press reached egui this pass, with no modifier held.
|
||||
pub(crate) fn plain_horizontal_arrow_pressed(ctx: &Context) -> bool {
|
||||
ctx.input(|input| input.modifiers.is_none() && (input.key_pressed(Key::ArrowLeft) || input.key_pressed(Key::ArrowRight)))
|
||||
}
|
||||
|
||||
@@ -29,6 +29,9 @@ use egui::{Context, Id, Ui, ViewportId};
|
||||
use std::ops::Deref;
|
||||
use std::sync::Arc;
|
||||
|
||||
/// A value a higher layer defines and the env only carries: the layer that defines it reads it back by its type.
|
||||
pub(crate) type Held = Arc<dyn std::any::Any + Send + Sync>;
|
||||
|
||||
mod app_values;
|
||||
mod host_words;
|
||||
mod overrides;
|
||||
@@ -48,7 +51,7 @@ pub(crate) use tokens::TokenInputs;
|
||||
#[cfg(feature = "testing")]
|
||||
pub(crate) use tokens::root_token_resolves;
|
||||
use tokens::tokens_for;
|
||||
pub use values::{ArenaId, MotionPolicy, Scale};
|
||||
pub use values::{ArenaId, ColumnAlign, InBar, MotionPolicy, PaneEdge, RowPressed, Scale};
|
||||
pub use view::EnvView;
|
||||
|
||||
/// The inherited context of a `Ui`: one `Arc` clone per read.
|
||||
@@ -158,7 +161,7 @@ pub struct Scoped {
|
||||
/// The view of the innermost scroll area, for the children that run only in view (`contract::Lazy`).
|
||||
pub(crate) lazy: Option<crate::runtime::lazy::View>,
|
||||
/// The window edge of the innermost edge pane that encloses the scope (`Mount::Pane`).
|
||||
pub(crate) pane_edge: Option<crate::contract::PaneEdge>,
|
||||
pub(crate) pane_edge: Option<PaneEdge>,
|
||||
/// The id of the collection item the scope shows: its root is not a Tab stop (17.3).
|
||||
pub(crate) item: Option<Id>,
|
||||
/// The roving group of the collection row the scope shows: the stops of its components and parts join it, so
|
||||
@@ -168,7 +171,7 @@ pub struct Scoped {
|
||||
pub(crate) item_facts: Option<Arc<ItemFacts>>,
|
||||
/// The inside label of the side label whose control the scope shows (`FieldLayout::Inside`). Only that control
|
||||
/// sees it: a component's children and a container's regions start without one.
|
||||
pub(crate) inside_label: Option<Arc<crate::contract::InsideLabel>>,
|
||||
pub(crate) inside_label: Option<Held>,
|
||||
/// The scope is the body of a beside label in an inspector (`LabelScheme::Inspector`): the control shown there
|
||||
/// fills the width the label leaves. Only that control sees it, as with `inside_label`.
|
||||
pub(crate) cell_fills: bool,
|
||||
@@ -292,10 +295,10 @@ pub struct ItemFacts {
|
||||
/// Each column's alignment and whether its figures are tabular, from its `ColumnSpec`: a row places its cells'
|
||||
/// text by them.
|
||||
#[doc(hidden)]
|
||||
pub aligns: Vec<(craft_behavior::ColumnKey, crate::contract::ColumnAlign, bool)>,
|
||||
pub aligns: Vec<(craft_behavior::ColumnKey, ColumnAlign, bool)>,
|
||||
/// Where the collection holds a press on the row (`RowState::pressed`).
|
||||
#[doc(hidden)]
|
||||
pub pressed: Option<crate::contract::RowPressed>,
|
||||
pub pressed: Option<RowPressed>,
|
||||
/// The row's menu is open (`RowState::menu_open`).
|
||||
#[doc(hidden)]
|
||||
pub menu_open: bool,
|
||||
@@ -353,7 +356,7 @@ impl Scoped {
|
||||
self.item_facts = None;
|
||||
self.ink = Ink::default();
|
||||
self.surface = SurfaceKind::Background;
|
||||
self.inherited_mut().values.set(crate::contract::InBar(false));
|
||||
self.inherited_mut().values.set(InBar(false));
|
||||
}
|
||||
|
||||
/// Ends the layout room of the enclosing body: its flow grid and content column.
|
||||
@@ -576,7 +579,7 @@ impl Env {
|
||||
scoped.lazy = None;
|
||||
scoped.measure = None;
|
||||
// A pane opened from a bar is not the bar's line.
|
||||
scoped.inherited_mut().values.set(crate::contract::InBar(false));
|
||||
scoped.inherited_mut().values.set(InBar(false));
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
+59
-1
@@ -1,6 +1,7 @@
|
||||
//! The library values the env carries: scale, motion policy and arena id.
|
||||
|
||||
use craft_behavior::MotionMode;
|
||||
use super::EnvValue;
|
||||
use craft_behavior::{ColumnKey, MotionMode};
|
||||
use craft_theme::MotionTokens;
|
||||
use egui::Id;
|
||||
use std::hash::Hash;
|
||||
@@ -51,3 +52,60 @@ impl ArenaId {
|
||||
ArenaId(id)
|
||||
}
|
||||
}
|
||||
|
||||
/// Where a column's content sits.
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
|
||||
pub enum ColumnAlign {
|
||||
/// At the start edge.
|
||||
#[default]
|
||||
Start,
|
||||
/// At the end edge.
|
||||
End,
|
||||
}
|
||||
|
||||
/// Where the collection holds a primary press on a row, within slop, or the press a part of the row holds.
|
||||
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||
#[non_exhaustive]
|
||||
pub enum RowPressed {
|
||||
/// On the row's own area.
|
||||
Row,
|
||||
/// On the cell of this toggle column, which the press flips.
|
||||
Cell(ColumnKey),
|
||||
/// On a part of the item that took the press itself (a row's trailing button).
|
||||
#[non_exhaustive]
|
||||
Part {
|
||||
/// The row held the lead when the press began: a press on a part moves the lead to its row.
|
||||
was_lead: bool,
|
||||
},
|
||||
}
|
||||
|
||||
/// Set by a bar for its body: its fields put `space.gap.item` between a caption and the control, a vertical divider
|
||||
/// takes a box wider than its line, a select fits its widest entry up to a field length, a rule shows only with the
|
||||
/// member after it, and a row too long for its room narrows its last units first. A layer or pane opened from the bar
|
||||
/// starts without it.
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
|
||||
#[doc(hidden)]
|
||||
pub struct InBar(pub bool);
|
||||
|
||||
impl EnvValue for InBar {
|
||||
fn root() -> Self {
|
||||
InBar(false)
|
||||
}
|
||||
}
|
||||
|
||||
/// Where a shell pane sits.
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
|
||||
#[non_exhaustive]
|
||||
pub enum PaneEdge {
|
||||
/// What the edge panes leave.
|
||||
#[default]
|
||||
Center,
|
||||
/// The start edge: left in reading order, right under right-to-left.
|
||||
Start,
|
||||
/// The end edge.
|
||||
End,
|
||||
/// The top edge.
|
||||
Top,
|
||||
/// The bottom edge.
|
||||
Bottom,
|
||||
}
|
||||
|
||||
+4
-5
@@ -4,7 +4,7 @@ use super::app_values::EnvValue;
|
||||
use super::label::Label;
|
||||
use super::units::{PointSize, UnitWords, Units};
|
||||
use super::values::{MotionPolicy, Scale};
|
||||
use super::{ItemFacts, Scoped};
|
||||
use super::{Held, ItemFacts, Scoped};
|
||||
use crate::runtime::commands::CommandChain;
|
||||
use craft_host::Host;
|
||||
use craft_host::target::ShellInfo;
|
||||
@@ -58,10 +58,9 @@ impl<'a> EnvView<'a> {
|
||||
self.scoped.roving
|
||||
}
|
||||
|
||||
/// The inside label the component shows in its slot, when it is the control of a side label with
|
||||
/// `FieldLayout::Inside`.
|
||||
pub fn inside_label(&self) -> Option<&'a crate::contract::InsideLabel> {
|
||||
self.scoped.inside_label.as_deref()
|
||||
/// The inside label the scope carries ([`inside_label`](EnvView::inside_label) reads it back).
|
||||
pub(crate) fn inside_held(&self) -> Option<&'a Held> {
|
||||
self.scoped.inside_label.as_ref()
|
||||
}
|
||||
|
||||
/// The surface the component sits on: the innermost container or collection surface that paints a fill, else the
|
||||
|
||||
@@ -765,7 +765,7 @@ pub(crate) fn end(ctx: &Context) {
|
||||
// Escape over a captured framework press or drag cancels it (`frame::begin_pass`), whatever egui has focused.
|
||||
let captured = crate::runtime::pointer::press_captured(ctx) || crate::runtime::drag::running(ctx);
|
||||
let host_focus = !captured && with(ctx, |state| state.focus_now).is_some_and(app_widget);
|
||||
let foreign = host_focus || (!captured && egui_focus::popup_open(ctx));
|
||||
let foreign = host_focus || (!captured && crate::runtime::egui::areas::popup_open(ctx));
|
||||
let label_selection = egui_focus::label_selection(ctx);
|
||||
let host_text = host_focus && ctx.text_edit_focused();
|
||||
with(ctx, |state| {
|
||||
|
||||
@@ -3,11 +3,12 @@
|
||||
//! with its box and access facts, the hit areas the sensing core registered and the focus stops in Tab order.
|
||||
|
||||
use crate::runtime::egui::areas;
|
||||
use crate::runtime::egui::areas::Layer;
|
||||
use crate::runtime::egui::sizing::{Rerun, request_discard};
|
||||
use crate::runtime::reads::{self, BindKey};
|
||||
use crate::runtime::{focus, measure, pass_state, pointer};
|
||||
use craft_behavior::PartRef;
|
||||
use egui::{Context, Id, LayerId, Rect, Ui};
|
||||
use egui::{Context, Id, Rect, Ui};
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::sync::Arc;
|
||||
|
||||
@@ -181,8 +182,8 @@ impl Recorded {
|
||||
/// A region being recorded.
|
||||
struct Open {
|
||||
/// The layer the region is shown on, which the record's rects are in.
|
||||
layer: LayerId,
|
||||
elements: Vec<(Element, LayerId)>,
|
||||
layer: Layer,
|
||||
elements: Vec<(Element, Layer)>,
|
||||
parts: Vec<Element>,
|
||||
/// The elements whose show has not finished, outermost first.
|
||||
stack: Vec<usize>,
|
||||
@@ -286,7 +287,7 @@ fn edited(ctx: &Context, read: BindKey, editor: Id) {
|
||||
/// component.
|
||||
fn finish(ctx: &Context, open: Open) -> Recorded {
|
||||
let from_screen = areas::layer_to_screen(ctx, open.layer).inverse();
|
||||
let to_region = |layer: LayerId, rect: Rect| from_screen * (areas::layer_to_screen(ctx, layer) * rect);
|
||||
let to_region = |layer: Layer, rect: Rect| from_screen * (areas::layer_to_screen(ctx, layer) * rect);
|
||||
let ids: HashSet<Id> = open.elements.iter().map(|(element, _)| element.id).collect();
|
||||
let mut elements: Vec<Element> = Vec::with_capacity(open.elements.len() + open.parts.len());
|
||||
let mut parts = open.parts;
|
||||
|
||||
@@ -1188,6 +1188,7 @@ pub(crate) mod guard {
|
||||
("contract::steps::id::IdPass", "id registration: a measuring run keeps the ids it uses out of the pass (keeping_ids)"),
|
||||
// Read in measuring runs; written by real runs, the frame hooks or the host.
|
||||
("runtime::env::ViewportEnvs", "env per viewport: installs the run restores, and reads"),
|
||||
("runtime::env::system::Source", "OS appearance: read; written by install, the input hook and the host's reader"),
|
||||
("runtime::frame::FrameState", "frame state: read"),
|
||||
("runtime::frame::ViewportRecord", "viewport record: read"),
|
||||
("runtime::windows::Shared", "window shells: read"),
|
||||
|
||||
@@ -13,12 +13,13 @@
|
||||
//! that run to the pass again in place of running, in view or not, inside a scroll area or not. It is settled when
|
||||
//! nothing the framework tracks has changed for it since that run (`settled`).
|
||||
|
||||
use crate::runtime::egui::pass;
|
||||
use crate::runtime::egui::areas::Layer;
|
||||
use crate::runtime::egui::{focus as focus_state, input as input_state, pass};
|
||||
use crate::runtime::focus::{self, Transcript};
|
||||
use crate::runtime::frame::{self, PerViewport};
|
||||
use crate::runtime::reads::BindKey;
|
||||
use crate::runtime::replay::{self, Record};
|
||||
use egui::{Context, Id, LayerId, Layout, Rect, Vec2};
|
||||
use egui::{Context, Id, Layout, Rect, Vec2};
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use std::sync::Arc;
|
||||
|
||||
@@ -124,7 +125,7 @@ pub(crate) struct Place {
|
||||
/// The region its parent offered it.
|
||||
pub(crate) room: Rect,
|
||||
pub(crate) clip: Rect,
|
||||
pub(crate) layer: LayerId,
|
||||
pub(crate) layer: Layer,
|
||||
pub(crate) layout: Layout,
|
||||
pub(crate) pixels_per_point: f32,
|
||||
}
|
||||
@@ -261,7 +262,7 @@ pub(crate) fn settled(ctx: &Context, owner: Option<Id>, id: Id, sizing: bool, pl
|
||||
});
|
||||
let targets = focus::targets(ctx);
|
||||
let now = frame::clock(ctx);
|
||||
let held = (ctx.dragged_id(), ctx.memory(|memory| memory.focused()));
|
||||
let held = (input_state::dragged(ctx), focus_state::focused(ctx));
|
||||
let settled = with(ctx, |store, pass_nr, frame| {
|
||||
if store.changes.scanned != pass_nr {
|
||||
store.changes.scanned = pass_nr;
|
||||
@@ -318,8 +319,7 @@ pub(crate) fn settled(ctx: &Context, owner: Option<Id>, id: Id, sizing: bool, pl
|
||||
fn engaged(ctx: &Context, settled: &Settled) -> bool {
|
||||
let rect = settled.rect.intersect(settled.place.clip);
|
||||
let screen = ctx.layer_transform_to_global(settled.place.layer).map_or(rect, |transform| transform * rect);
|
||||
ctx.rect_contains_pointer(settled.place.layer, rect)
|
||||
|| ctx.input(|input| input.pointer.any_down() && input.pointer.press_origin().is_some_and(|origin| screen.contains(origin)))
|
||||
ctx.rect_contains_pointer(settled.place.layer, rect) || input_state::held_press_origin(ctx).is_some_and(|origin| screen.contains(origin))
|
||||
}
|
||||
|
||||
/// Adds the last real run of the settling child `id` to the running pass, in place of running it.
|
||||
|
||||
@@ -415,8 +415,8 @@ pub(crate) fn part_bounds(ctx: &Context, owner: Id, part: craft_behavior::PartRe
|
||||
|
||||
/// [`part_bounds`] of the owner whose AccessKit node is `node`, for a test that holds the node it found, not the id.
|
||||
#[cfg(feature = "testing")]
|
||||
pub(crate) fn node_part_bounds(ctx: &Context, node: accesskit::NodeId, part: craft_behavior::PartRef) -> Option<egui::Rect> {
|
||||
owned_part_bounds(ctx, |shape_owner| shape_owner.accesskit_id() == node, part)
|
||||
pub(crate) fn node_part_bounds(ctx: &Context, node: crate::runtime::egui::access::NodeId, part: craft_behavior::PartRef) -> Option<egui::Rect> {
|
||||
owned_part_bounds(ctx, |shape_owner| crate::runtime::egui::access::node_id(shape_owner) == node, part)
|
||||
}
|
||||
|
||||
fn owned_part_bounds(ctx: &Context, owner: impl Fn(Id) -> bool, part: craft_behavior::PartRef) -> Option<egui::Rect> {
|
||||
|
||||
@@ -9,11 +9,12 @@
|
||||
//! to be shown again, and whether it did something a replay cannot repeat (an overlay it shows, paint on another
|
||||
//! layer, a label scope open around it). Such a record is never replayed: the region runs.
|
||||
|
||||
use crate::runtime::egui::areas::Layer;
|
||||
use crate::runtime::focus::{self, Transcript};
|
||||
use crate::runtime::frame;
|
||||
use crate::runtime::pass_state;
|
||||
use crate::runtime::reads::BindKey;
|
||||
use egui::{Context, Id, LayerId};
|
||||
use egui::{Context, Id};
|
||||
use std::collections::HashSet;
|
||||
use std::sync::Arc;
|
||||
use std::sync::atomic::{AtomicUsize, Ordering};
|
||||
@@ -86,7 +87,7 @@ pub(crate) fn open(ctx: &Context) {
|
||||
}
|
||||
|
||||
/// Ends the innermost record, the one around a run on `layer`: paint or widgets on another layer block it.
|
||||
pub(crate) fn close(ctx: &Context, layer: LayerId) -> Record {
|
||||
pub(crate) fn close(ctx: &Context, layer: Layer) -> Record {
|
||||
OPEN.fetch_sub(1, Ordering::AcqRel);
|
||||
let (open, journal) = pass_state::with::<Recorder, _>(ctx, |recorder| {
|
||||
// A close with no open record ends one that holds nothing and is never replayed.
|
||||
|
||||
@@ -7,6 +7,7 @@ mod key;
|
||||
mod look;
|
||||
mod paint;
|
||||
mod replacements;
|
||||
mod span;
|
||||
mod state;
|
||||
mod surface;
|
||||
mod surround;
|
||||
@@ -29,8 +30,9 @@ pub use paint::{
|
||||
};
|
||||
pub(crate) use paint::{min_thumb, scroll_bar_look};
|
||||
pub use replacements::{DuplicateStyle, StyleReplacements};
|
||||
pub use span::Span;
|
||||
pub use state::StateSet;
|
||||
pub use surface::{SurfaceEdge, SurfaceStyle};
|
||||
pub use surface::{BandFill, SurfaceEdge, SurfaceStyle};
|
||||
pub use surround::{SurroundLook, paint_surround};
|
||||
pub use tokens::UiTokens;
|
||||
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
//! `Span`: one styled stretch of a text run.
|
||||
|
||||
use std::borrow::Cow;
|
||||
|
||||
/// One styled stretch of a run.
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
#[non_exhaustive]
|
||||
pub struct Span<'a> {
|
||||
/// The text.
|
||||
pub text: Cow<'a, str>,
|
||||
/// Italic.
|
||||
pub italic: bool,
|
||||
/// Tabular figures.
|
||||
pub tabular: bool,
|
||||
/// The monospace face.
|
||||
pub mono: bool,
|
||||
/// The muted text colour.
|
||||
pub muted: bool,
|
||||
/// A shortcut hint: muted.
|
||||
pub shortcut: bool,
|
||||
/// A search match highlight.
|
||||
pub highlight: bool,
|
||||
/// Underlined in the span's colour, `stroke.thin` wide, along the bottom of the line box.
|
||||
pub underline: bool,
|
||||
/// The role's semibold face, at the role's size.
|
||||
pub strong: bool,
|
||||
}
|
||||
|
||||
impl<'a> Span<'a> {
|
||||
/// A plain span.
|
||||
pub fn new(text: impl Into<Cow<'a, str>>) -> Self {
|
||||
Span {
|
||||
text: text.into(),
|
||||
italic: false,
|
||||
tabular: false,
|
||||
mono: false,
|
||||
muted: false,
|
||||
shortcut: false,
|
||||
highlight: false,
|
||||
underline: false,
|
||||
strong: false,
|
||||
}
|
||||
}
|
||||
|
||||
/// Italic.
|
||||
pub fn italic(mut self) -> Self {
|
||||
self.italic = true;
|
||||
self
|
||||
}
|
||||
|
||||
/// Tabular figures.
|
||||
pub fn tabular(mut self) -> Self {
|
||||
self.tabular = true;
|
||||
self
|
||||
}
|
||||
|
||||
/// The monospace face.
|
||||
pub fn mono(mut self) -> Self {
|
||||
self.mono = true;
|
||||
self
|
||||
}
|
||||
|
||||
/// The muted colour.
|
||||
pub fn muted(mut self) -> Self {
|
||||
self.muted = true;
|
||||
self
|
||||
}
|
||||
|
||||
/// A shortcut hint.
|
||||
pub fn shortcut(mut self) -> Self {
|
||||
self.shortcut = true;
|
||||
self
|
||||
}
|
||||
|
||||
/// A match highlight.
|
||||
pub fn highlight(mut self) -> Self {
|
||||
self.highlight = true;
|
||||
self
|
||||
}
|
||||
|
||||
/// Underlined: a link, or the mnemonic letter of a menu title.
|
||||
pub fn underline(mut self) -> Self {
|
||||
self.underline = true;
|
||||
self
|
||||
}
|
||||
|
||||
/// The role's semibold face: a short mark that stands out among the row's other text, such as a layer's `fx`.
|
||||
pub fn strong(mut self) -> Self {
|
||||
self.strong = true;
|
||||
self
|
||||
}
|
||||
}
|
||||
@@ -21,6 +21,11 @@ impl StateSet {
|
||||
StateSet { state, flags, t }
|
||||
}
|
||||
|
||||
/// The component is disabled.
|
||||
pub fn is_disabled(&self) -> bool {
|
||||
self.state == State::Disabled
|
||||
}
|
||||
|
||||
/// The value of `look` in this state.
|
||||
pub fn resolve<T: Mix>(&self, look: &Stateful<T>) -> T {
|
||||
look.resolve(self.state, self.flags, self.t)
|
||||
|
||||
@@ -2,10 +2,20 @@
|
||||
|
||||
use super::look::SurfaceKind;
|
||||
use super::tokens::UiTokens;
|
||||
use crate::contract::BandFill;
|
||||
use craft_theme::variant::Tone;
|
||||
use craft_theme::{Edge, Elevation, Rgba, Stroke as StrokeStep};
|
||||
use egui::{Color32, CornerRadius, Shadow, Stroke};
|
||||
|
||||
/// What the band behind a header paints.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
#[non_exhaustive]
|
||||
pub enum BandFill {
|
||||
/// A surface's fill.
|
||||
Surface(SurfaceKind),
|
||||
/// A tone's tinted fill (`Tone::soft_fill`).
|
||||
Tone(Tone),
|
||||
}
|
||||
|
||||
/// A surface's edge, resolved from the theme's edge style.
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
#[non_exhaustive]
|
||||
@@ -81,7 +91,6 @@ fn shadow(e: Elevation) -> Option<Shadow> {
|
||||
(shadow.color.a() > 0).then_some(shadow)
|
||||
}
|
||||
|
||||
/// The look of `kind` in `tokens`.
|
||||
/// The colour a band behind a header paints: the surface's fill, or the tone's tinted fill.
|
||||
pub(crate) fn band_color(tokens: &UiTokens, fill: BandFill) -> Color32 {
|
||||
match fill {
|
||||
@@ -90,6 +99,7 @@ pub(crate) fn band_color(tokens: &UiTokens, fill: BandFill) -> Color32 {
|
||||
}
|
||||
}
|
||||
|
||||
/// The look of `kind` in `tokens`.
|
||||
pub(crate) fn surface_style(tokens: &UiTokens, kind: SurfaceKind) -> SurfaceStyle {
|
||||
use SurfaceKind as K;
|
||||
let c = &tokens.color;
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
//! the width of a line. `TextRun` lays out through the first two and `StyleCx::text_width` through the third, so the
|
||||
//! sizes that follow the text agree with the text that is drawn.
|
||||
|
||||
use super::Span;
|
||||
use super::tokens::UiTokens;
|
||||
use crate::fonts::StackFacts;
|
||||
use crate::primitives::Span;
|
||||
use crate::runtime::egui::text_layout;
|
||||
use craft_i18n::Direction;
|
||||
use craft_theme::TypeRole;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
use crate::runtime::commands::{CommandInput, CommandSet as _, EditCommands, NavCommand};
|
||||
use crate::runtime::drag::{self, DragPreview};
|
||||
use crate::runtime::egui::fixture;
|
||||
use crate::runtime::egui::{areas, fixture};
|
||||
use crate::runtime::env::RootEnv;
|
||||
use crate::runtime::focus::{EditSet, FocusTarget, KeepKeys, KeyUse, host_canvas, request};
|
||||
use crate::runtime::frame::{ChromeToggle, take_output};
|
||||
@@ -163,16 +163,16 @@ fn an_open_egui_popup_keeps_escape() {
|
||||
let (host, mut base) = host_window();
|
||||
let mut show = move |ui: &mut Ui| {
|
||||
base(ui);
|
||||
fixture::host_popup(ui, popup, Pos2::ZERO);
|
||||
areas::host_popup(ui, popup, Pos2::ZERO);
|
||||
};
|
||||
let mut frames = Frames::new();
|
||||
frames.frame(Vec::new(), &mut show);
|
||||
fixture::open_host_popup(&frames.ctx, popup);
|
||||
areas::open_host_popup(&frames.ctx, popup);
|
||||
frames.frame(Vec::new(), &mut show);
|
||||
assert!(fixture::host_popup_open(&frames.ctx, popup));
|
||||
assert!(areas::host_popup_open(&frames.ctx, popup));
|
||||
press_key(&mut frames, &mut show, Key::Escape);
|
||||
assert_eq!(seen(&host), (vec![Key::Escape], 0), "the popup's Escape is egui's");
|
||||
assert!(!fixture::host_popup_open(&frames.ctx, popup), "egui closed the popup");
|
||||
assert!(!areas::host_popup_open(&frames.ctx, popup), "egui closed the popup");
|
||||
frames.frame(Vec::new(), &mut show);
|
||||
press_key(&mut frames, &mut show, Key::Escape);
|
||||
assert_eq!(seen(&host), (Vec::new(), 1), "with the popup closed, Escape is the window's Cancel again");
|
||||
|
||||
@@ -95,7 +95,11 @@ pub fn cancel_captured_presses(ctx: &egui::Context) {
|
||||
/// pass: how a host test that found a component by its node (a list row by its name) finds a pointer-only part of it
|
||||
/// (a thumbnail, a drag handle), which has no node of its own. [`Fixture::part_rect`](super::Fixture::part_rect) is
|
||||
/// the same lookup by the component's id. Callers assert how rects relate (inside, below), not their size.
|
||||
pub fn part_rect_of_node(ctx: &egui::Context, node: accesskit::NodeId, part: impl Into<craft_behavior::PartRef>) -> Option<egui::Rect> {
|
||||
pub fn part_rect_of_node(
|
||||
ctx: &egui::Context,
|
||||
node: crate::runtime::egui::access::NodeId,
|
||||
part: impl Into<craft_behavior::PartRef>,
|
||||
) -> Option<egui::Rect> {
|
||||
crate::runtime::pointer::node_part_bounds(ctx, node, part.into())
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,26 @@ pub fn above(a: Rect, b: Rect) -> bool {
|
||||
a.max.y <= b.min.y + EPS
|
||||
}
|
||||
|
||||
/// `lower` starts below where `upper` ends, with a gap between them.
|
||||
pub fn apart_above(upper: Rect, lower: Rect) -> bool {
|
||||
lower.min.y > upper.max.y + EPS
|
||||
}
|
||||
|
||||
/// `inner` ends above the foot of `outer`, not on it.
|
||||
pub fn off_foot(inner: Rect, outer: Rect) -> bool {
|
||||
inner.max.y < outer.max.y - EPS
|
||||
}
|
||||
|
||||
/// `a` and `b` start at the same left edge.
|
||||
pub fn aligned_left(a: Rect, b: Rect) -> bool {
|
||||
(a.min.x - b.min.x).abs() <= EPS
|
||||
}
|
||||
|
||||
/// `a` and `b` stand in one column: the same left edge and the same width.
|
||||
pub fn same_column(a: Rect, b: Rect) -> bool {
|
||||
aligned_left(a, b) && (a.width() - b.width()).abs() <= EPS
|
||||
}
|
||||
|
||||
/// `inner` lies within `outer`.
|
||||
pub fn inside(inner: Rect, outer: Rect) -> bool {
|
||||
inner.min.x >= outer.min.x - EPS && inner.min.y >= outer.min.y - EPS && inner.max.x <= outer.max.x + EPS && inner.max.y <= outer.max.y + EPS
|
||||
|
||||
@@ -331,7 +331,12 @@ impl StoryBody {
|
||||
}
|
||||
if let (Some((key, layers)), Some(recorded)) = (self.inspect, recorded) {
|
||||
let pointed = inspect::pointed(ui.ctx(), key);
|
||||
InspectOverlay::new(recorded).layers(layers).pointed(pointed).show_at(ui, surface.output.rect);
|
||||
let overlay = InspectOverlay::new(recorded).layers(layers);
|
||||
let overlay = match pointed {
|
||||
Some(index) => overlay.pointed(index),
|
||||
None => overlay,
|
||||
};
|
||||
overlay.show_at(ui, surface.output.rect);
|
||||
}
|
||||
if let Some(shown) = ran.get() {
|
||||
let dialog = &mut state.dialog;
|
||||
|
||||
@@ -31,6 +31,7 @@ const ONE: &[ColumnWidth] = &[ColumnWidth::fill(1.0)];
|
||||
const TWO: &[ColumnWidth] = &[ColumnWidth::fill(1.0); 2];
|
||||
|
||||
/// One story of a card to show.
|
||||
#[non_exhaustive]
|
||||
pub struct SpecStory {
|
||||
/// The index of the story in the catalog.
|
||||
pub index: usize,
|
||||
@@ -49,6 +50,7 @@ impl SpecStory {
|
||||
}
|
||||
|
||||
/// The card of one component to show, before it is laid out.
|
||||
#[non_exhaustive]
|
||||
pub struct Spec {
|
||||
/// The id scope of the card.
|
||||
pub key: String,
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
use craft_behavior::{CancelReason, EditEvent, EditEvents, EditPolicy as Policy, GestureId};
|
||||
use craft_ui::buttons::Button;
|
||||
use craft_ui::contract::{Bind, Gap, Pad, Pattern, Props, Show as _, ShowContainer as _};
|
||||
use craft_ui::contract::{Bind, Gap, Pad, Pattern, Props, Show as _, ShowContainer as _, clicked};
|
||||
use craft_ui::display::{Shade, Text};
|
||||
use craft_ui::layout_components::{Row, Stack};
|
||||
use craft_ui::runtime::edit::cancel_all;
|
||||
@@ -160,10 +160,10 @@ impl EditPolicy {
|
||||
state.events("field", &label, Before::Label);
|
||||
});
|
||||
Row::new().gap(Gap::Item).show(ui, |ui, _| {
|
||||
if Button::new("Undo during gesture").show(ui).clicked() {
|
||||
if clicked(&Button::new("Undo during gesture").show(ui)) {
|
||||
state.undo(ui);
|
||||
}
|
||||
if Button::new("Switch document").show(ui).clicked() {
|
||||
if clicked(&Button::new("Switch document").show(ui)) {
|
||||
state.switch(ui);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -146,11 +146,6 @@ fn a_settled_overview_card_runs_no_component() {
|
||||
}
|
||||
}
|
||||
|
||||
/// The registered type name of the component listed as `name`.
|
||||
fn type_of(name: &str) -> &'static str {
|
||||
Catalog::linked().components.iter().find(|component| component.name == name).unwrap_or_else(|| panic!("{name} is listed")).type_name
|
||||
}
|
||||
|
||||
fn painted(fixture: &Fixture, text: &str) -> bool {
|
||||
fixture.texts().iter().any(|run| run.text == text)
|
||||
}
|
||||
@@ -179,32 +174,31 @@ fn level_of(name: &str) -> &'static str {
|
||||
fn a_storys_dialog_starts_closed_opens_over_the_view_and_closes_back_to_the_opener() {
|
||||
let (mut store, report) = SettingsStore::<GallerySettings>::open_with(OpenOptions::new(Location::Memory));
|
||||
let mut settings = store.get().clone();
|
||||
settings.level = level_of("Dialog").to_owned();
|
||||
settings.filter = "Dialog".to_owned();
|
||||
settings.stories.insert(type_of("Dialog").to_owned(), "dialog".to_owned());
|
||||
settings.level = level_of("FindReplaceDialog").to_owned();
|
||||
settings.filter = "FindReplaceDialog".to_owned();
|
||||
store.set(settings);
|
||||
let mut gallery = Gallery::new(Catalog::linked(), Persisted::new(store, &report));
|
||||
let mut fixture = Fixture::new(move |ui| gallery.ui(ui));
|
||||
fixture.room(Vec2::new(1400.0, 900.0)).settle();
|
||||
// Other cards of the filter show the same body in flow.
|
||||
let (closed, inline) = (openers(&fixture), painted_times(&fixture, "Snap to grid"));
|
||||
// The body shows only while the dialog is open.
|
||||
let (closed, inline) = (openers(&fixture), painted_times(&fixture, "Find what:"));
|
||||
assert!(closed >= 1, "the picked story shows its opener");
|
||||
// The Dialog card's opener: the first under the card's title, in its column.
|
||||
let title = fixture.texts().iter().find(|run| run.text == "Dialog").expect("the Dialog card's title").rect;
|
||||
// The card's opener: the first under the card's title, in its column.
|
||||
let title = fixture.texts().iter().find(|run| run.text == "FindReplaceDialog").expect("the card's title").rect;
|
||||
let opener = fixture
|
||||
.by_role(Role::BUTTON)
|
||||
.into_iter()
|
||||
.filter(|button| fixture.tree().name_of(button.node) == Some("Show dialog"))
|
||||
.filter(|button| button.rect.top() > title.top() && button.rect.left() < title.right() && button.rect.right() > title.left() - 40.0)
|
||||
.min_by(|a, b| a.rect.top().total_cmp(&b.rect.top()))
|
||||
.expect("the Dialog card's opener");
|
||||
.expect("the card's opener");
|
||||
fixture.click(&opener).settle();
|
||||
assert_eq!(painted_times(&fixture, "Snap to grid"), inline + 1, "the opener opens the dialog");
|
||||
assert_eq!(painted_times(&fixture, "Find what:"), inline + 1, "the opener opens the dialog");
|
||||
assert_eq!(openers(&fixture), closed - 1, "the opener gives way to the story");
|
||||
fixture.key(egui::Key::Escape, egui::Modifiers::NONE).settle();
|
||||
// The exit fade runs on the fixture's clock.
|
||||
fixture.advance(1.0).settle();
|
||||
assert_eq!(painted_times(&fixture, "Snap to grid"), inline, "the dialog closed");
|
||||
assert_eq!(painted_times(&fixture, "Find what:"), inline, "the dialog closed");
|
||||
assert_eq!(openers(&fixture), closed, "closing the story's dialog brings the opener back");
|
||||
}
|
||||
|
||||
|
||||
@@ -25,9 +25,9 @@ mod words;
|
||||
pub use alert::{Alert, AlertOutput, HostedAlert};
|
||||
pub use blocking::{BlockingOverlay, BlockingOverlayStyle};
|
||||
pub use frame::{DialogFrame, DialogFrameStyle, DialogOutput, FooterCx, FooterHooks};
|
||||
pub use held::{HeldAnswer, HeldOk};
|
||||
#[doc(hidden)]
|
||||
pub use host::dialog_probe;
|
||||
pub use held::{HeldAnswer, HeldOk};
|
||||
pub use host::{DialogHost, DialogResult, FieldRefusal, OpenDialog, StackDialog, StartupStage};
|
||||
pub use modal::{Dialog, DialogStyle};
|
||||
pub use prompt::{Prompt, PromptOutput};
|
||||
|
||||
@@ -10,6 +10,7 @@ use crate::layout_components::Row;
|
||||
use crate::runtime::overlay::CloseReason;
|
||||
use crate::sections::{DialogRole, FooterButton};
|
||||
use crate::testing::input::key_press;
|
||||
use crate::testing::relations::{apart_above, grows_with, inside, off_foot, same_column};
|
||||
use crate::testing::{Fixture, Frames, trial};
|
||||
use crate::text::TextField;
|
||||
use egui::{Key, Modifiers, Rect, Ui};
|
||||
@@ -171,9 +172,9 @@ fn a_dialogs_body_stands_apart_from_its_header_and_its_footer() {
|
||||
else {
|
||||
panic!("every part is shown");
|
||||
};
|
||||
assert!(body.min.y > title.max.y + 1.0, "a space separates the body from the title row's rule: {title:?} {body:?}");
|
||||
assert!(ok.min.y > body.max.y + 1.0, "a space separates the body from the footer: {body:?} {ok:?}");
|
||||
assert!(ok.max.y < dialog.max.y - 1.0, "the buttons stay off the dialog's foot: {ok:?} {dialog:?}");
|
||||
assert!(apart_above(title, body), "a space separates the body from the title row's rule: {title:?} {body:?}");
|
||||
assert!(apart_above(body, ok), "a space separates the body from the footer: {body:?} {ok:?}");
|
||||
assert!(inside(ok, dialog) && off_foot(ok, dialog), "the buttons stay off the dialog's foot: {ok:?} {dialog:?}");
|
||||
}
|
||||
|
||||
#[trial]
|
||||
@@ -215,10 +216,10 @@ fn side_buttons_stand_in_one_column_beside_the_body() {
|
||||
};
|
||||
assert!(ok.max.y <= cancel.min.y && cancel.max.y <= other.min.y, "OK, Cancel, then the other button, top to bottom");
|
||||
for button in [cancel, other] {
|
||||
assert!((button.min.x - ok.min.x).abs() < 0.5 && (button.width() - ok.width()).abs() < 0.5, "one column, one width: {ok:?} {button:?}");
|
||||
assert!(same_column(ok, button), "one column, one width: {ok:?} {button:?}");
|
||||
}
|
||||
assert!(ok.min.x >= body.max.x, "the column stands past the body's end edge");
|
||||
assert!((ok.min.y - body.min.y).abs() < 4.0, "the column starts at the body's top: {ok:?} {body:?}");
|
||||
assert!(grows_with(body.min.y, ok.min.y) && ok.min.y <= body.center().y, "the column starts at the body's top: {ok:?} {body:?}");
|
||||
assert!(preview.min.y >= other.max.y, "the footer content sits under the buttons");
|
||||
}
|
||||
|
||||
|
||||
@@ -284,7 +284,7 @@ impl<'a, P: Clone + Hash + Send + Sync + 'static> DockGroup<'a, P> {
|
||||
}
|
||||
|
||||
/// Whether the panel menu button shows: it is asked for and the menu has rows.
|
||||
fn menu_button(&self) -> bool {
|
||||
fn shows_menu_button(&self) -> bool {
|
||||
self.panel_menu_shown && !self.menu.is_empty()
|
||||
}
|
||||
|
||||
@@ -324,7 +324,7 @@ impl<P: Clone + Hash + Send + Sync + 'static> Component for DockGroup<'_, P> {
|
||||
let (band, rest) = flow.take_start(grip_width(&cx.tokens.size.handle));
|
||||
let sense = if self.movable { Sense::CLICK | Sense::DRAG | Sense::FOCUS } else { Sense::CLICK | Sense::FOCUS };
|
||||
let _ = cx.header_part(HeaderEdge::End, GRIP, band).sense(sense).focusable();
|
||||
if self.menu_button() {
|
||||
if self.shows_menu_button() {
|
||||
// An icon button is square: its side is the slot's room past the band and the gap.
|
||||
let side = (slot.width() - grip_width(&cx.tokens.size.handle) - cx.tokens.space.gap.item).max(0.0);
|
||||
let end = rest.take_end(side).0;
|
||||
@@ -414,8 +414,11 @@ impl<P: Clone + Hash + Send + Sync + 'static> Container for DockGroup<'_, P> {
|
||||
/// The drag band, then the panel menu button when it shows, at the header's end edge.
|
||||
fn header_parts(&self, cx: &MeasureCx<'_, Self>) -> HeaderParts {
|
||||
let band = grip_width(&cx.tokens.size.handle);
|
||||
let button =
|
||||
if self.menu_button() { cx.tokens.space.gap.item + cx.face(Self::menu_face(cx.words::<DockWords>().panel_menu.clone())).x } else { 0.0 };
|
||||
let button = if self.shows_menu_button() {
|
||||
cx.tokens.space.gap.item + cx.face(Self::menu_face(cx.words::<DockWords>().panel_menu.clone())).x
|
||||
} else {
|
||||
0.0
|
||||
};
|
||||
HeaderParts::NONE.end(band + button)
|
||||
}
|
||||
|
||||
@@ -445,7 +448,7 @@ impl<P: Clone + Hash + Send + Sync + 'static> Container for DockGroup<'_, P> {
|
||||
let drags = crate::runtime::drag::started(ui.ctx());
|
||||
let layout = if rtl { egui::Layout::right_to_left(egui::Align::Min) } else { egui::Layout::left_to_right(egui::Align::Min) };
|
||||
ui.with_layout(layout, |ui| {
|
||||
ui.spacing_mut().item_spacing.x = gap;
|
||||
ui.spacing_mut().item_spacing.x = gap; // design: allow[style-mutation](the header lays its title cells with an egui layout and sets that layout's gap)
|
||||
if let Some(hook) = extra.as_mut() {
|
||||
hook.run(ui, cx);
|
||||
}
|
||||
|
||||
@@ -121,7 +121,7 @@ pub struct IconicColumnStyle {
|
||||
/// The ink of a panel's name in a wide column.
|
||||
name: StyleColor,
|
||||
/// The ink of the name of the panel whose flyout is open.
|
||||
name_selected: StyleColor,
|
||||
name_open: StyleColor,
|
||||
/// The room between an icon and its name.
|
||||
name_gap: f32,
|
||||
}
|
||||
@@ -368,7 +368,7 @@ impl<P: Value + Hash + 'static> Component for IconicColumn<'_, P> {
|
||||
metrics: Metrics::new(),
|
||||
sizes: IconicSizes::style(cx),
|
||||
name: cx.color(colors.text.normal),
|
||||
name_selected: cx.color(colors.accent.text),
|
||||
name_open: cx.color(colors.accent.text),
|
||||
name_gap: cx.tokens.space.gap.item,
|
||||
}
|
||||
}
|
||||
@@ -502,7 +502,7 @@ impl<P: Value + Hash + 'static> Component for IconicColumn<'_, P> {
|
||||
if let Some(name) = self.laid.as_ref().and_then(|plan| plan.names.get(at)) {
|
||||
let style = &cx.style;
|
||||
let room = if cx.flow.is_rtl() { name.with_max_x(name.max.x - style.name_gap) } else { name.with_min_x(name.min.x + style.name_gap) };
|
||||
let ink = if selected { style.name_selected } else { style.name };
|
||||
let ink = if selected { style.name_open } else { style.name };
|
||||
let _ = ui.draw().text(room, &TextRun::new(spec.label.as_str().to_owned()).color(ink).elide());
|
||||
}
|
||||
ui.face(CELL.at(at as u64), IconButton::new(icon).label(spec.label).selected(selected));
|
||||
@@ -632,10 +632,7 @@ impl<P: Value + Hash + 'static> Container for IconicColumn<'_, P> {
|
||||
/// The chevron's square at the bar's outer end.
|
||||
fn header_parts(&self, cx: &MeasureCx<'_, Self>) -> HeaderParts {
|
||||
let side = cx.style.sizes.column.bar;
|
||||
match chevron_edge(self.edge) {
|
||||
HeaderEdge::Start => HeaderParts::NONE.start(side),
|
||||
HeaderEdge::End => HeaderParts::NONE.end(side),
|
||||
}
|
||||
if chevron_edge(self.edge) == HeaderEdge::End { HeaderParts::NONE.end(side) } else { HeaderParts::NONE.start(side) }
|
||||
}
|
||||
|
||||
/// The column bar, over the icons. What the user did on it is read in `finish`.
|
||||
|
||||
@@ -27,7 +27,7 @@ fn at_stage<'a>(
|
||||
) -> IconicColumnOutput<u8> {
|
||||
let room = stage(ui);
|
||||
let env = Env::of(ui);
|
||||
let width = env.tokens.tokens().size.rail.width;
|
||||
let width = env.tokens.tokens().size.rail.width; // design: allow[style/token-read](a story sizes its stage from the rail token)
|
||||
let cell = if env.direction.is_rtl() {
|
||||
Rect::from_min_max(room.min, egui::pos2(room.left() + width, room.bottom()))
|
||||
} else {
|
||||
|
||||
@@ -17,6 +17,9 @@ fn spec(panel: &u8) -> PanelSpec {
|
||||
PanelSpec::new(if *panel == 0 { "Brushes" } else { "Swatches" })
|
||||
}
|
||||
|
||||
/// The width of the column that shows names beside its icons.
|
||||
const WIDE_COLUMN: f32 = 200.0;
|
||||
|
||||
/// A column `width` wide over two icon-less panels, and the panel whose flyout is open.
|
||||
fn column(width: f32) -> (Fixture, Rc<Cell<Option<u8>>>) {
|
||||
let open = Rc::new(Cell::new(None));
|
||||
@@ -44,10 +47,10 @@ fn an_icon_less_panel_shows_its_initial_and_a_wide_column_shows_names_that_open_
|
||||
assert!(painted(&narrow, "B") && painted(&narrow, "S"), "each icon-less panel shows its initial");
|
||||
assert!(!painted(&narrow, "Brushes"), "a narrow column shows no names");
|
||||
|
||||
let (mut wide, open) = column(200.0);
|
||||
let (mut wide, open) = column(WIDE_COLUMN);
|
||||
assert!(painted(&wide, "Brushes") && painted(&wide, "Swatches"), "a wide column shows the names");
|
||||
let icon = wide.by_label("Swatches").expect("the Swatches icon");
|
||||
assert!(icon.rect.width() < 200.0 / 2.0, "the icon keeps its square at the start: {:?}", icon.rect);
|
||||
assert!(icon.rect.width() < WIDE_COLUMN, "the icon keeps its square at the start: {:?}", icon.rect);
|
||||
// The name has no node of its own: the icon is its keyboard stop. Click on it, past the icon.
|
||||
wide.click_at(icon.rect.right_center() + Vec2::new(icon.rect.width(), 0.0)).idle(3);
|
||||
assert_eq!(open.get(), Some(1), "a click on the name opens its panel's flyout");
|
||||
|
||||
@@ -67,6 +67,9 @@ pub struct DockRoot<'a, T: 'static> {
|
||||
props: ContainerProps,
|
||||
take_drop: TakeDrop<'a, T>,
|
||||
dropped: Option<T>,
|
||||
/// The arrangement the pattern shows, which the drags started in the body record.
|
||||
#[doc(hidden)]
|
||||
#[prop]
|
||||
shows: Option<Arrangement>,
|
||||
}
|
||||
|
||||
@@ -82,13 +85,6 @@ impl<'a, T: 'static> DockRoot<'a, T> {
|
||||
shows: None,
|
||||
}
|
||||
}
|
||||
|
||||
/// The arrangement the pattern shows, which the drags started in the body record.
|
||||
#[doc(hidden)]
|
||||
pub fn shows(mut self, arrangement: Arrangement) -> Self {
|
||||
self.shows = Some(arrangement);
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: 'static> Component for DockRoot<'_, T> {
|
||||
|
||||
@@ -7,6 +7,7 @@ use crate::contract::Show as _;
|
||||
use crate::rails::tool::stories::{StoryTools, tools};
|
||||
use crate::runtime::commands::CommandState;
|
||||
use crate::testing::pointer::{moved, wheel};
|
||||
use crate::testing::relations::{above, grows_with};
|
||||
use crate::testing::{Fixture, trial};
|
||||
use egui::{Rect, Shape, Vec2};
|
||||
use std::cell::Cell;
|
||||
@@ -41,8 +42,8 @@ fn in_a_short_window_the_icons_scroll_above_the_footer_that_stays_in_view() {
|
||||
}
|
||||
fixture.settle();
|
||||
let last = rect(&fixture, "Clone Stamp");
|
||||
assert!(last.top() >= first.top() - 0.5, "{height}: the last icon is in view after scrolling: {last:?}");
|
||||
assert!(last.bottom() <= foot.top() + 0.5, "{height}: the last icon is above the footer after scrolling: {last:?}");
|
||||
assert!(grows_with(first.top(), last.top()), "{height}: the last icon is in view after scrolling: {last:?}");
|
||||
assert!(above(last, foot), "{height}: the last icon is above the footer after scrolling: {last:?}");
|
||||
assert_eq!(rect(&fixture, "Foot"), foot, "{height}: the footer stays put");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -510,7 +510,9 @@ impl<'a> ParamDialog<'a> {
|
||||
}
|
||||
for answer in cx.take_answers() {
|
||||
let answered = match &answer {
|
||||
HostAnswer::Color { key, .. } | HostAnswer::Eyedropper { key, .. } | HostAnswer::Path { key, .. } => params.iter().find(|param| param.key == *key),
|
||||
HostAnswer::Color { key, .. } | HostAnswer::Eyedropper { key, .. } | HostAnswer::Path { key, .. } => {
|
||||
params.iter().find(|param| param.key == *key)
|
||||
}
|
||||
HostAnswer::Listing { .. } => None,
|
||||
};
|
||||
let held = answered.and_then(|param| values.get(¶m.key).cloned());
|
||||
@@ -1138,9 +1140,7 @@ impl StackDialog for HostedParamDialog {
|
||||
result.id = self.id;
|
||||
Some(DialogResult::Ok(result))
|
||||
}
|
||||
(None, Some(CloseReason::Activated)) if finish => {
|
||||
Some(self.held.finish().map_or(DialogResult::Cancel, DialogResult::Ok))
|
||||
}
|
||||
(None, Some(CloseReason::Activated)) if finish => Some(self.held.finish().map_or(DialogResult::Cancel, DialogResult::Ok)),
|
||||
(None, Some(_)) => Some(DialogResult::Cancel),
|
||||
(None, None) => None,
|
||||
}
|
||||
|
||||
@@ -186,8 +186,22 @@ impl<'a> ExportAsDialog<'a> {
|
||||
|
||||
/// Shows the dialog.
|
||||
pub fn show(self, ui: &mut Ui) -> ExportAsOutput {
|
||||
let ExportAsDialog { file_name, source, bound, formats, methods, title, open, defaults, preview, answers, saving, mut presets, remember, opening } =
|
||||
self;
|
||||
let ExportAsDialog {
|
||||
file_name,
|
||||
source,
|
||||
bound,
|
||||
formats,
|
||||
methods,
|
||||
title,
|
||||
open,
|
||||
defaults,
|
||||
preview,
|
||||
answers,
|
||||
saving,
|
||||
mut presets,
|
||||
remember,
|
||||
opening,
|
||||
} = self;
|
||||
let env = Env::of(ui);
|
||||
let words = env.words::<ExportWords>();
|
||||
// A frame can run the body twice: the library lives in a cell the passes share, and `events` collects the edits
|
||||
@@ -210,8 +224,11 @@ impl<'a> ExportAsDialog<'a> {
|
||||
let wanted = RefCell::new(None::<PreviewRequest<ExportOptions>>);
|
||||
let latest = RefCell::new(None::<ExportOptions>);
|
||||
let answered = RefCell::new(None::<PathBuf>);
|
||||
let mut dialog =
|
||||
FormDialog::new(title.unwrap_or_else(|| words.title.clone()), bound).ok_label(words.export.clone()).ok_enabled(!saving).accept_stays_open(true).answers(answers);
|
||||
let mut dialog = FormDialog::new(title.unwrap_or_else(|| words.title.clone()), bound)
|
||||
.ok_label(words.export.clone())
|
||||
.ok_enabled(!saving)
|
||||
.accept_stays_open(true)
|
||||
.answers(answers);
|
||||
if let Some(open) = open {
|
||||
dialog = dialog.opened(open);
|
||||
}
|
||||
@@ -545,7 +562,13 @@ impl StackDialog for HostedExportAs {
|
||||
|
||||
/// The settings the dialog opens with: the remembered ones when there are any, else `base`, fitted to the formats and
|
||||
/// the source.
|
||||
fn opened_options(base: ExportOptions, last: Option<ExportOptions>, formats: &[ExportFormat], methods: &[Resample], source: PixelSize) -> ExportOptions {
|
||||
fn opened_options(
|
||||
base: ExportOptions,
|
||||
last: Option<ExportOptions>,
|
||||
formats: &[ExportFormat],
|
||||
methods: &[Resample],
|
||||
source: PixelSize,
|
||||
) -> ExportOptions {
|
||||
last.unwrap_or(base).fitted(formats, methods, source)
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ use crate::canvas_data::{Guide, GuideColor};
|
||||
use crate::contract::{Bind, SaveKey};
|
||||
use crate::runtime::env::UnitKind;
|
||||
use crate::runtime::requests::ColorRequest;
|
||||
use crate::testing::relations::{aligned_left, grows_with};
|
||||
use crate::testing::{Fixture, trial};
|
||||
use craft_behavior::Axis;
|
||||
use craft_theme::Rgba;
|
||||
@@ -32,7 +33,7 @@ fn the_preview_check_box_under_the_side_buttons_starts_on_at_every_open() {
|
||||
let (Some(preview), Some(ok)) = (fixture.by_label("Preview"), fixture.by_label("OK")) else {
|
||||
panic!("the Preview check box and OK are shown");
|
||||
};
|
||||
assert!(preview.rect.min.y >= ok.rect.max.y && (preview.rect.min.x - ok.rect.min.x).abs() < 0.5, "Preview sits under the buttons");
|
||||
assert!(grows_with(ok.rect.max.y, preview.rect.min.y) && aligned_left(ok.rect, preview.rect), "Preview sits under the buttons");
|
||||
fixture.click(&preview);
|
||||
fixture.settle();
|
||||
assert!(!previewing.get(), "with Preview off the dialog previews nothing");
|
||||
|
||||
@@ -266,7 +266,7 @@ pub struct PreviewPane<'a> {
|
||||
click_centres: bool,
|
||||
/// The well's width over its height: the pane is as tall as its width over this. Without one, the height is the
|
||||
/// one its container gives, at least the plot height.
|
||||
#[prop]
|
||||
#[prop(quantity = "aspect ratio")]
|
||||
aspect: Option<f32>,
|
||||
/// The view after this pass, when the user changed it.
|
||||
moved: Option<PreviewView>,
|
||||
|
||||
@@ -230,7 +230,7 @@ impl RowData {
|
||||
/// One line: the label, then the menu path, which drops out when the label would get too narrow, and the chord
|
||||
/// at the end.
|
||||
fn row(&self) -> ListRow<'static> {
|
||||
let row = ListRow::new(self.label.clone()).option().command().enabled(self.enabled);
|
||||
let row = ListRow::new(self.label.clone()).option().command_row().enabled(self.enabled);
|
||||
// The first trailing item is the outermost: the chord ends the row and the path sits before it.
|
||||
let row = match &self.chord {
|
||||
Some(chord) => row.trailing(chord.clone()),
|
||||
|
||||
@@ -23,9 +23,9 @@ use std::cell::RefCell;
|
||||
use std::sync::Arc;
|
||||
|
||||
/// The size the window opens at until the user resizes it.
|
||||
pub const DEFAULT_SIZE: Vec2 = vec2(1040.0, 800.0);
|
||||
pub const DEFAULT_SIZE: Vec2 = vec2(1040.0, 800.0); // design: allow[literal-size/vec2](the window's own opening size in points)
|
||||
/// The least size the window may be resized to.
|
||||
pub const MIN_SIZE: Vec2 = vec2(560.0, 400.0);
|
||||
pub const MIN_SIZE: Vec2 = vec2(560.0, 400.0); // design: allow[literal-size/vec2](the window's own least size in points)
|
||||
|
||||
/// What the window keeps between passes; the host owns it and binds it with [`PreferencesWindow::new`].
|
||||
#[derive(Clone, Debug, Default, PartialEq)]
|
||||
|
||||
@@ -252,7 +252,7 @@ pub struct PresetBrowser<'a, K: Clone + Eq + Hash + Send + Sync + 'static> {
|
||||
max_rows: Option<u16>,
|
||||
/// The browser takes the presets' height, up to `room_height` (then they scroll), instead of the available
|
||||
/// height: for a host that sizes to its content, such as a floating panel.
|
||||
#[prop]
|
||||
#[prop(quantity = "room the host's panel offers, in points")]
|
||||
room_height: Option<f32>,
|
||||
/// The columns of tiles the grid asks for where it takes its width from its content (a popover): its width holds
|
||||
/// this many tiles. 0 asks for none.
|
||||
|
||||
@@ -177,11 +177,16 @@ fn new_document_lists_its_clipboard_size_at_once_and_keeps_a_set_made_before_the
|
||||
let mut fixture = fixture(&host);
|
||||
let ctx = fixture.ctx().clone();
|
||||
let clipboard = PixelSize::new(640, 480);
|
||||
let dialog = HostedNewDocument::new(&ctx, DocumentOptions::default(), move |options| NewDocumentDialog::new(Bind::bound(options)).clipboard(clipboard));
|
||||
let dialog =
|
||||
HostedNewDocument::new(&ctx, DocumentOptions::default(), move |options| NewDocumentDialog::new(Bind::bound(options)).clipboard(clipboard));
|
||||
let id = host.borrow_mut().open(dialog);
|
||||
let fields = |host: &Rc<RefCell<DialogHost>>| host.borrow().open_dialogs().into_iter().find(|open| open.id == id).and_then(|open| open.fields);
|
||||
let opened = fields(&host).expect("the dialog lists its settings");
|
||||
assert_eq!((opened["size"]["width"].as_u64(), opened["size"]["height"].as_u64()), (Some(640), Some(480)), "the clipboard's size, before the first pass");
|
||||
assert_eq!(
|
||||
(opened["size"]["width"].as_u64(), opened["size"]["height"].as_u64()),
|
||||
(Some(640), Some(480)),
|
||||
"the clipboard's size, before the first pass"
|
||||
);
|
||||
assert!(opened["name"].as_str().is_some_and(|name| !name.is_empty()), "the default name, before the first pass");
|
||||
assert_eq!(host.borrow_mut().set_json_field(&ctx, id, "size", json!({"width": 800, "height": 600})), Ok(()));
|
||||
fixture.idle(10);
|
||||
|
||||
@@ -268,7 +268,10 @@ pub struct AppShell<'a, S> {
|
||||
window: WindowKey,
|
||||
bare: bool,
|
||||
embedded: bool,
|
||||
/// An embedded shell as tall as its content, with the most a body that fills takes.
|
||||
/// An embedded shell as wide as the room of the flow it is shown in and as tall as its body's content and its top
|
||||
/// and bottom slots, from the measure its body keeps while its inputs hold; a body that fills takes at most this
|
||||
/// room. Shown with [`show`](Self::show), it takes that room in the flow.
|
||||
#[prop(name = "content_height", quantity = "room the host's flow offers, in points")]
|
||||
content_room: Option<f32>,
|
||||
/// The screen mode. Without a binding the shell keeps it, starting at `Standard`.
|
||||
#[prop]
|
||||
@@ -329,13 +332,6 @@ impl<'a, S> AppShell<'a, S> {
|
||||
AppShell { embedded: true, ..Self::new(window) }
|
||||
}
|
||||
|
||||
/// An embedded shell as wide as the room of the flow it is shown in and as tall as its body's content and its top
|
||||
/// and bottom slots, from the measure its body keeps while its inputs hold; a body that fills takes at most `room`.
|
||||
/// Shown with [`show`](Self::show), it takes that room in the flow.
|
||||
pub fn content_height(self, room: f32) -> Self {
|
||||
AppShell { embedded: true, content_room: Some(room), ..self }
|
||||
}
|
||||
|
||||
/// The title bar slot, the first top slot, keyed `"title"`: visible, and revealing in body-only mode. The title bar
|
||||
/// types fill it.
|
||||
pub fn title_bar(self, add: impl FnMut(&mut Ui, &mut BodyCx<'_>, &mut S) + 'a) -> Self {
|
||||
@@ -430,6 +426,7 @@ impl<'a, S> AppShell<'a, S> {
|
||||
slots,
|
||||
mut body,
|
||||
} = self;
|
||||
let embedded = embedded || content_room.is_some();
|
||||
if let Some(title) = window_title
|
||||
&& !embedded
|
||||
&& !ui.is_sizing_pass()
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
//! [`crate::runtime::keys::with_window_intents`], last in the app's UI.
|
||||
|
||||
use crate::fonts::{Stack, UiFonts};
|
||||
#[cfg(feature = "app")]
|
||||
use crate::runtime::egui::memory;
|
||||
use crate::runtime::frame::{FrameInput, FrameOutput, set_input, take_output};
|
||||
use crate::runtime::windows;
|
||||
use crate::runtime::{InstallError, InstallSpec};
|
||||
@@ -62,15 +64,19 @@ pub fn before_ui(ctx: &Context, frame: &eframe::Frame) {
|
||||
fit_once(ctx);
|
||||
}
|
||||
|
||||
/// Whether the fit has run for this context.
|
||||
#[cfg(feature = "app")]
|
||||
#[derive(Default)]
|
||||
struct Fitted(bool);
|
||||
|
||||
/// Runs [`fit_first`] from the first passes until its monitor is known, then never again for this context.
|
||||
#[cfg(feature = "app")]
|
||||
fn fit_once(ctx: &Context) {
|
||||
let key = egui::Id::unique("craft_ui_shell::embed::fitted");
|
||||
if ctx.data(|data| data.get_temp::<bool>(key)).unwrap_or(false) {
|
||||
if memory::with::<Fitted, _>(ctx, |fitted| fitted.0) {
|
||||
return;
|
||||
}
|
||||
if fit_first(ctx) {
|
||||
ctx.data_mut(|data| data.insert_temp(key, true));
|
||||
memory::with::<Fitted, _>(ctx, |fitted| fitted.0 = true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,10 @@ impl Outcome for ViewportWindowOutput {
|
||||
#[derive(Pattern, Props)]
|
||||
pub struct ViewportWindow {
|
||||
title: Label,
|
||||
/// What lies over the app's other windows while this one is open and blocks them; `None` blocks nothing.
|
||||
/// Makes the app's other windows ignore input while this one is open, with `backdrop` over them where the window is
|
||||
/// a layer (`Backdrop::Scrim` dims them, `Backdrop::None` leaves them as they are). Without it the window blocks
|
||||
/// nothing.
|
||||
#[prop(name = "app_modal")]
|
||||
modal: Option<Backdrop>,
|
||||
/// Changes the layer the window has where windows are unavailable, whose limits and place its OS window takes.
|
||||
overlay: Option<Box<dyn FnOnce(Overlay) -> Overlay>>,
|
||||
@@ -59,13 +62,6 @@ impl ViewportWindow {
|
||||
ViewportWindow { title: title.into(), modal: None, overlay: None, remember: None }
|
||||
}
|
||||
|
||||
/// Makes the app's other windows ignore input while this one is open, with `backdrop` over them where the window is
|
||||
/// a layer (`Backdrop::Scrim` dims them, `Backdrop::None` leaves them as they are).
|
||||
pub fn app_modal(mut self, backdrop: Backdrop) -> Self {
|
||||
self.modal = Some(backdrop);
|
||||
self
|
||||
}
|
||||
|
||||
/// Changes the layer the window falls back to, which starts as the resizable dialog layer: the smallest and
|
||||
/// largest size (`Overlay::size_limits`), the place (`Overlay::placed`) and the resizability. Calls compose in
|
||||
/// order.
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user