From 576dcb3817b93a6839b99dec8501f2bd315ec477 Mon Sep 17 00:00:00 2001 From: Martin Ball Date: Thu, 19 Nov 2026 20:57:22 +0000 Subject: [PATCH] fw-rest: resolve the framework sync conflicts (up/next into area/ribbon-fw) - Dialogs: ButtonPlace { Foot, Side, Body } beside the port's refusal notice and ChildDialog; every side_buttons caller (find, hyperlink, paragraph, list manager, form dialogs) takes button_place, keeping the port's held answers, close buttons and name check. - Colour picker: upstream's fixed Full arrangement, CompareSwatch and warning module; the port's shown_model and tabbed Colors dialog kept (its buttons stand in the side column, the Full layout's in the picker's slot); the Compact layout shows the compare block beside its area when the host gives a compare colour; focus_on_open goes as upstream. - Task bar: the grip is the bar's first member on one floating surface, for the task kind only; the selection kind and the close reason stay. - Keymap: lookup_where's accept filter runs through upstream's winners(). - craft-gpu: upstream's provider-neutral crate, with the port's eframe start-up choices behind a startup feature (facade gpu-startup); duplicate facade row removed. - Facade features, ATTRIBUTION, BMP density probe, margin story fit, theme icon-pack and dialog first-field trials: both sides kept; the clipboard presence code stays replaced by the port's offer modules. --- ATTRIBUTION.md | 9 - crates/color-ui/src/ui/mod.rs | 16 +- crates/color-ui/src/ui/picker/compact.rs | 19 +- crates/color-ui/src/ui/picker/full.rs | 34 +-- crates/color-ui/src/ui/picker/mod.rs | 21 +- crates/color-ui/src/ui/picker/stories.rs | 10 +- crates/color-ui/src/ui/picker_dialog.rs | 10 +- crates/color-ui/tests/it/picker.rs | 15 +- crates/craft/Cargo.toml | 17 +- crates/craft/src/lib.rs | 3 - crates/draw/tests/it/transform_box.rs | 6 - crates/gpu/Cargo.toml | 38 ++- crates/gpu/src/lib.rs | 27 +- crates/image-codecs/src/bmp_probe.rs | 6 - crates/keymap/src/keymap.rs | 13 +- crates/keymap/tests/keymap.rs | 5 +- crates/pages/src/ui/margins/stories.rs | 17 -- crates/platform/src/clipboard/backend.rs | 235 ------------------ .../text/src/ui/character/paragraph_dialog.rs | 9 +- crates/text/src/ui/find/dialog.rs | 14 +- crates/text/src/ui/hyperlink.rs | 15 +- crates/theme/src/format_tests.rs | 5 +- .../ui-canvas/src/canvas_controls/task_bar.rs | 41 +-- crates/ui-panels/src/dialog/mod.rs | 5 - crates/ui-panels/src/dialog/modal.rs | 4 +- crates/ui-panels/src/dialog/stories.rs | 7 +- crates/ui-panels/tests/it/dialogs.rs | 6 +- .../src/patterns/form_dialogs/form.rs | 13 +- .../src/patterns/form_dialogs/list_manager.rs | 17 +- .../tests/it/form_dialogs/params.rs | 5 +- .../src/layout_components/stories.rs | 8 - 31 files changed, 90 insertions(+), 560 deletions(-) diff --git a/ATTRIBUTION.md b/ATTRIBUTION.md index 56430f5bb..085306ffe 100644 --- a/ATTRIBUTION.md +++ b/ATTRIBUTION.md @@ -124,8 +124,6 @@ The XML reader in `crates/plist/src/xml.rs` and its base64 compatibility helper `crates/palette` extracts the GPL text parser from AniCraft `crates/doc/src/swatch.rs` at `d875a7feb250e6ab06aa28a37fb78a0699e88330` (MIT OR Apache-2.0), introduced by Tanish Manku in `a64130a9da9bdde545463b852d95d6a6774b1dfd` (AniCraft #270). The import preserves Tanish as primary author. Neutral RGB/name adaptation separates application display-name sanitization and the `Untitled` policy; validation tests and integration are subsequent Dylan M. Taylor changes. The legacy ZIP Zstandard method-20 mapping and bounded-read regression in `crates/zip/src/lenient` are ported from RRFZ's Craft Anything commit `29badae7c9280fdf4c24795927bf3a91f51694c6` (MIT OR Apache-2.0). RRFZ remains the primary Git author. Firmware scanner detection remains app-owned and is not part of this port. -<<<<<<< HEAD -======= ## TAR/CPIO compatibility updates The old GNU sparse-extension traversal, GNU CRC-symlink compatibility and PAX-size precedence fixes and their regression tests in `crates/tar` are ported from RRFZ's Craft Anything PRs #1973 (`8ea2ec66a1bc80f0420f3695baac877a0cb9b9a5`), #1984 (`b226a475f7dce9710e3af7a069386fe7a9720df7`) and #2007 (`d29465c20b0d570ea4973be512a0cb4e212bb60f`). Source is MIT OR Apache-2.0; RRFZ remains the primary Git author of each port. The PAX update adapts to the shared parser's existing `PaxOverrides` structure without changing the source policy. @@ -133,7 +131,6 @@ The old GNU sparse-extension traversal, GNU CRC-symlink compatibility and PAX-si ## Aligned stored ZIP entries The USDZ alignment requirement and compatibility fixture for `Writer::add_stored_aligned` come from TextureCraft `crates/formats/src/mesh_export/usd.rs`, introduced by bflatastic in `bdbb52c9` and maintained through `9eb20086` (MIT OR Apache-2.0). The shared API and alignment validation are subsequent Dylan M. Taylor work. Scene/material mapping remains in TextureCraft. ->>>>>>> up/next The raw gradient wire ordering in `craft-lottie::Gradient::flat_values` follows AniCraft's Lottie exporter by Tanish Manku (`63b39355`, `b9258b7b`), MIT OR Apache-2.0. @@ -143,11 +140,6 @@ Sanitization, animation fitting and numeric output policy remain caller-owned. `crates/video/src/screen_video.rs` extracts AniCraft `crates/xfl/src/video.rs` codec-3 decoding and its synthetic partial-block fixture, introduced by Tanish Manku in `1f3e603b7ff53a3da364e41ec4da8d43dc83aab0` with pixel-loop cleanup `2b7571363b4b647266df758f95b6e397021cfd4d` (MIT OR Apache-2.0). Import commits preserve Tanish as primary author. Caller-owned bounds and neutral RGBA output separate codec work from the consuming app's FLV first-frame/report policy. Boundary tests and integration are subsequent Dylan M. Taylor changes. -<<<<<<< HEAD -## Aligned stored ZIP entries - -The USDZ alignment requirement and compatibility fixture for `Writer::add_stored_aligned` come from TextureCraft `crates/formats/src/mesh_export/usd.rs`, introduced by bflatastic in `bdbb52c9` and maintained through `9eb20086` (MIT OR Apache-2.0). The shared API and alignment validation are subsequent Dylan M. Taylor work. Scene/material mapping remains in TextureCraft. -======= ## Source Map v3 parser and lookup `crates/sourcemap` extracts the bounded parser, source inventory and generated-position lookup from Craft Anything `crates/formats/src/sourcemap.rs` at `e5c9c94106747ed44b9a3fb0decce867c2285f93` (MIT OR Apache-2.0). Core-history ports preserve Brandon Thomas, BFlat, Afloat, RRFZ, Nicolas Bohn and Alex Joaquim Pereira as primary authors, with exact source revisions in each commit. Six regression files preserve their source authors; nine core unit tests retain the original tests. App annotation scanning, data URLs, base64 and file I/O are intentionally not imported. Workspace wiring is a subsequent change; existing limits and errors are unchanged. @@ -187,4 +179,3 @@ The USDZ alignment requirement and compatibility fixture for `Writer::add_stored `crates/xfdf` extracts PDFCraft field reading from #5937 refresh `cb564fd827f572818e9ddb0ea5989a432b1f39fd` (MIT OR Apache-2.0). App-side annotation and form policy remains local; source history is retained in the original repository. Retained XFDF source contributors (move-aware blame): Brandon Thomas, Marco Arnulfo, pkibiego and storybored379; module split by aiongg. Subsequent budget/integration work by Dylan M. Taylor. ->>>>>>> up/next diff --git a/crates/color-ui/src/ui/mod.rs b/crates/color-ui/src/ui/mod.rs index 40aaf0f2e..51814b202 100644 --- a/crates/color-ui/src/ui/mod.rs +++ b/crates/color-ui/src/ui/mod.rs @@ -46,11 +46,7 @@ mod warning; mod wheel; pub use crate::AreaMode; -<<<<<<< HEAD -pub use area::{ColorArea, ColorAreaStyle, smooth_mesh}; -======= -pub use area::{AreaShape, ColorArea, ColorAreaStyle}; ->>>>>>> up/next +pub use area::{AreaShape, ColorArea, ColorAreaStyle, smooth_mesh}; pub use channels::finite_values; pub use choice::{ChosenColor, ColorChoice, ColorChoiceOutput, ColorChoiceWords, NamedColor}; pub use compare::{CompareSwatch, CompareSwatchOutput, CompareSwatchStyle}; @@ -76,16 +72,8 @@ pub use palette::{SwatchPalette, SwatchPaletteOutput}; pub use panel::{ ColorPanel, ColorPanelCommand, ColorPanelMenu, ColorPanelMode, ColorPanelOutput, ColorPanelRamp, ColorPanelState, ColorPanelWords, PanelTarget, }; -<<<<<<< HEAD -pub use picker::{ - ColorConstraint, ColorPicker, ColorPickerLayout, ColorPickerOutput, ColorPickerWords, ColorWarning, ColorWarningChip, ColorWarningChipOutput, - PickedColor, ScreenPickGesture, -}; -pub use picker_dialog::{ColorPickerDialog, ColorPickerDialogLayout, ColorPickerDialogWords, ColorPickerMemory, ColorPickerResult, ColorPickerTab}; -======= pub use picker::{ColorConstraint, ColorPicker, ColorPickerLayout, ColorPickerOutput, ColorPickerWords, PickedColor, ScreenPickGesture}; -pub use picker_dialog::{ColorPickerDialog, ColorPickerDialogWords, ColorPickerMemory, ColorPickerResult}; ->>>>>>> up/next +pub use picker_dialog::{ColorPickerDialog, ColorPickerDialogLayout, ColorPickerDialogWords, ColorPickerMemory, ColorPickerResult, ColorPickerTab}; pub use popover::{ColorPopover, ColorPopoverOutput}; pub use profile_prompts::{ProfileAction, ProfileAnswer, ProfileMismatchDialog, ProfileMode, ProfileQuestion, ProfileStatus, ProfileWords}; pub use ramp::{ColorRamp, ColorRampOutput, ColorRampStyle, ColorRampWords, Gamut, RampKind, RampPick}; diff --git a/crates/color-ui/src/ui/picker/compact.rs b/crates/color-ui/src/ui/picker/compact.rs index c9ebbdf5f..05b29b7fd 100644 --- a/crates/color-ui/src/ui/picker/compact.rs +++ b/crates/color-ui/src/ui/picker/compact.rs @@ -23,6 +23,9 @@ pub(super) struct Body<'a> { pub layout: ColorPickerLayout, pub models: Vec<&'a dyn ColorModel>, pub warnings: Vec, + /// Compact only: the host gave a compare colour, so the compare block stands beside the area (Word's Colors + /// dialog's New over Current). The Full layout always shows it. + pub compare: bool, pub alpha: bool, pub dynamic_tracks: bool, pub eyedropper: bool, @@ -44,16 +47,12 @@ impl<'a> Body<'a> { let words = Env::of(ui).words::(); let model = self.models.iter().copied().find(|m| Some(m.id()) == pass.model); let visible: Vec<&dyn ColorModel> = model.into_iter().chain([pass.mode.model()]).collect(); -<<<<<<< HEAD Row::new().show(ui, |ui, _| { - self.area_and_strip(ui, pass, &visible, got); - if let Some(current) = self.compare { - self.compare_swatch(ui, pass, current, &words, got); + self.area_and_strip(ui, pass, &visible, AreaShape::Plot, got); + if self.compare { + self.compare_block(ui, pass, &words, got); } }); -======= - self.area_and_strip(ui, pass, &visible, AreaShape::Plot, got); ->>>>>>> up/next if let Some(model) = model { FieldGroup::new(words.channels.as_str().to_owned()).labels(LabelScheme::Inspector).show(ui, |ui, _| { let values = pass.shown.values_in(model); @@ -128,12 +127,8 @@ impl<'a> Body<'a> { } } -<<<<<<< HEAD - /// The hex field, at `sizing` when given. The Full layout's first show focuses it. Enter in it + /// The hex field, at `sizing` when given. The picker's first show focuses it, its text selected. Enter in it /// commits the typed digits and does not reach the dialog's OK, as in the production Colors dialog. -======= - /// The hex field, at `sizing` when given. The picker's first show focuses it, its text selected. ->>>>>>> up/next pub(super) fn hex_field(&self, ui: &mut Ui, pass: &Pass<'a>, words: &ColorPickerWords, sizing: Option, got: &mut Collected) { let field = TextField::hex(words.hex.as_str().to_owned(), Bind::given(pass.shows(pass.shown.color.to_rgba()))).empty(pass.shown.color.to_rgba()).submits(); diff --git a/crates/color-ui/src/ui/picker/full.rs b/crates/color-ui/src/ui/picker/full.rs index 799f54976..88f852e10 100644 --- a/crates/color-ui/src/ui/picker/full.rs +++ b/crates/color-ui/src/ui/picker/full.rs @@ -60,39 +60,10 @@ impl<'a> Body<'a> { }); } -<<<<<<< HEAD - /// The compare swatch: the colour being edited over the current one, with their captions; a click on the current - /// half sets it. - pub(super) fn compare_swatch(&self, ui: &mut Ui, pass: &Pass<'a>, current: Mixed, words: &ColorPickerWords, got: &mut Collected) { - let caption = |text: &str| Text::new(text.to_owned()).role(TypeRole::Caption).shade(Shade::Muted); - Stack::new().gap(Gap::Tight).show(ui, |ui, _| { - caption(words.new_caption.as_str()).show(ui); - Stack::new().gap(Gap::None).show(ui, |ui, _| { - Swatch::new(words.new_color.as_str().to_owned(), pass.shows(pass.shown.color)).sizing(Sizing::FillWidth).show(ui); - let restore = words.restore.as_str().to_owned(); - let shown = match current { - Mixed::Same(current) => Mixed::Same(current.color), - Mixed::Mixed => Mixed::Mixed, - }; - if Swatch::new(restore.clone(), shown).tooltip(restore).sizing(Sizing::FillWidth).show(ui).clicked - && let Mixed::Same(current) = current - { - got.clicks.push(current); - } - }); - caption(words.current_caption.as_str()).show(ui); - }); - } - - /// The channel grid: one column of fields per group of models, each column sharing its label column, with the - /// radios of "Field shows" in front of the channels that choose an area mode, and the hex field under the first. - fn grid(&self, ui: &mut Ui, pass: &Pass<'a>, visible: &[&dyn ColorModel], words: &ColorPickerWords, got: &mut Collected) { -======= /// The compare block and the actions cell over the two field groups, in a grid whose columns never stack: the /// actions cell stands over the second group, and both groups start under the taller of the two cells. The radios /// of "Field shows" are one group across both. fn right_half(&self, ui: &mut Ui, pass: &Pass<'a>, visible: &[&dyn ColorModel], words: &ColorPickerWords, got: &mut Collected) { ->>>>>>> up/next let offered = ColorPicker::offered(&self.models); let choice = ModelChoice { visible, offered: &offered, words }; let (first, second): (Vec<&'a dyn ColorModel>, Vec<&'a dyn ColorModel>) = self.models.iter().copied().partition(|m| in_first_group(*m)); @@ -113,8 +84,9 @@ impl<'a> Body<'a> { } /// The compare block, the colour being edited over the one the picker started from, with the warnings column after - /// it; a click on the current half or on a warning sets that colour. - fn compare_block(&self, ui: &mut Ui, pass: &Pass<'a>, words: &ColorPickerWords, got: &mut Collected) { + /// it; a click on the current half or on a warning sets that colour. The Compact layout shows it beside its area + /// when the host gives a compare colour. + pub(super) fn compare_block(&self, ui: &mut Ui, pass: &Pass<'a>, words: &ColorPickerWords, got: &mut Collected) { let current = match pass.compare { Mixed::Same(current) => Mixed::Same(current.color), Mixed::Mixed => Mixed::Mixed, diff --git a/crates/color-ui/src/ui/picker/mod.rs b/crates/color-ui/src/ui/picker/mod.rs index e89110e66..55e27e47d 100644 --- a/crates/color-ui/src/ui/picker/mod.rs +++ b/crates/color-ui/src/ui/picker/mod.rs @@ -308,15 +308,9 @@ pub struct ColorPicker<'a> { /// The host's answer to a screen or canvas pick, for this pass; a `Set` that keeps the picker's alpha. #[prop] sampled: Option, -<<<<<<< HEAD - /// Whether the Full layout focuses its hex field when it first shows; on by default. - #[prop] - focus_on_open: bool, /// The Compact rows' model, held by the host; kept per picker without it. #[prop] shown_model: Option>>, -======= ->>>>>>> up/next } impl<'a> ColorPicker<'a> { @@ -337,11 +331,7 @@ impl<'a> ColorPicker<'a> { warnings: Vec::new(), constrain: None, sampled: None, -<<<<<<< HEAD - focus_on_open: true, shown_model: None, -======= ->>>>>>> up/next } } @@ -399,16 +389,13 @@ impl<'a> ColorPicker<'a> { warnings, constrain, sampled, -<<<<<<< HEAD - focus_on_open, mut shown_model, -======= ->>>>>>> up/next } = self; let full = layout == ColorPickerLayout::Full; let models: Vec<&'a dyn ColorModel> = models .unwrap_or_else(|| builtin_models().into_iter().filter(|m| if full { m.default_on().full } else { m.default_on().compact }).collect()); - let parts = compact::Body { layout, models: models.clone(), warnings, alpha, dynamic_tracks, eyedropper, eyedropper_busy }; + let parts = + compact::Body { layout, models: models.clone(), warnings, compare: compare.is_some(), alpha, dynamic_tracks, eyedropper, eyedropper_busy }; let mut run = Run { name: Arc::from(label.as_str()), full, @@ -478,16 +465,12 @@ impl<'a> Run<'_, 'a> { } let first_show = !memo.opened; -<<<<<<< HEAD let held_model = self.shown_model.as_ref().and_then(|held| held.read(&mut *body)).and_then(|held| held.same().copied()).flatten(); let wanted = if self.shown_model.is_some() { held_model } else { memo.model }; let model = wanted.filter(|id| self.models.iter().any(|m| m.id() == *id)).or_else(|| self.models.first().map(|m| m.id())); -======= - let model = memo.model.filter(|id| self.models.iter().any(|m| m.id() == *id)).or_else(|| self.models.first().map(|m| m.id())); let focus_hex = first_show && body.resolved.enabled; let held = self.value.read(&mut *body).and_then(|held| held.same().copied()); let first = if first_show { held } else { memo.first }; ->>>>>>> up/next { let memo = body.memory::(); memo.mode = mode; diff --git a/crates/color-ui/src/ui/picker/stories.rs b/crates/color-ui/src/ui/picker/stories.rs index ff365703a..63cbaeb17 100644 --- a/crates/color-ui/src/ui/picker/stories.rs +++ b/crates/color-ui/src/ui/picker/stories.rs @@ -10,9 +10,8 @@ use egui::Ui; use super::channel::{ChannelRow, ChannelRule, TrackRamp}; use super::screen_pick::ScreenPickButton; -<<<<<<< HEAD -use super::{ColorPicker, ColorPickerLayout, ColorPickerOutput, ColorWarning, ColorWarningChip, PickedColor}; -use crate::ui::{AreaMode, ColorPickerDialog, ColorPickerDialogLayout, ColorPickerTab}; +use super::{ColorPicker, ColorPickerLayout, ColorPickerOutput, PickedColor}; +use crate::ui::{AreaMode, ColorPickerDialog, ColorPickerDialogLayout, ColorPickerTab, ColorWarning}; /// A colour of full brightness and saturation at `hue` (0 to 1). fn hue_color(hue: f32) -> Srgba { @@ -53,11 +52,6 @@ fn color_picker_dialog_tabbed(ui: &mut Ui, data: &mut StoryData) -> StoryOutput fn color_picker_dialog_tabbed_custom(ui: &mut Ui, data: &mut StoryData) -> StoryOutput { tabbed(ui, data, ColorPickerTab::Custom) } -======= -use super::{ColorPicker, ColorPickerLayout, ColorPickerOutput, PickedColor}; -use crate::ui::{AreaMode, ColorPickerDialog, ColorWarning}; -use craft_ui::dialog::stories::hosted; ->>>>>>> up/next /// A naive CMYK in percent, without a working space: a host's model for the stories. A real host converts through its /// CMYK profile. diff --git a/crates/color-ui/src/ui/picker_dialog.rs b/crates/color-ui/src/ui/picker_dialog.rs index c08e3ee27..69c8fc9d1 100644 --- a/crates/color-ui/src/ui/picker_dialog.rs +++ b/crates/color-ui/src/ui/picker_dialog.rs @@ -15,16 +15,11 @@ use craft_host::Host; use craft_host::target::Caps; use craft_settings::Remembered; use craft_theme::{ColorModel, Srgba, builtin_models}; -<<<<<<< HEAD use craft_ui::choice::{SwatchArrangement, SwatchTable}; use craft_ui::contract::{Bind, CanvasGesture, CollectionEvent, Props as _, Sampler as _, ShowCollection as _, ShowContainer as _}; -use craft_ui::dialog::{Dialog, DialogId, DialogResult, DialogStack, FieldRefusal, StackDialog, dialog_id, serde_fields, set_serde_field}; -======= -use craft_ui::contract::{Bind, CanvasGesture, Sampler as _, ShowContainer as _}; use craft_ui::dialog::{ ButtonPlace, Dialog, DialogId, DialogResult, DialogStack, FieldRefusal, StackDialog, dialog_id, serde_fields, set_serde_field, }; ->>>>>>> up/next use craft_ui::patterns::form_dialogs::{HostRequests, ResetFooter}; use craft_ui::layout_components::Stack; use craft_ui::runtime::env::{Env, Label}; @@ -608,6 +603,9 @@ impl StackDialog for ColorPickerDialog { let arm = self.sampling.then_some(self.canvas).flatten(); let keep_open = self.canvas; let screen = self.eyedropper && self.layout == ColorPickerDialogLayout::Full && env.view().shell().caps.contains(Caps::SCREEN_CAPTURE); + // The Full picker keeps a cell for the buttons; the tabbed body has none, so they stand in the side column, as in + // Word's Colors dialog. + let place = if self.layout == ColorPickerDialogLayout::Full { ButtonPlace::Body } else { ButtonPlace::Side }; let Self { current, opening, compare, memory, screen_busy, sample, pending_screen, open, layout, standard, .. } = self; let mut held: Mixed = current.map_or(Mixed::Mixed, Mixed::Same); let (sampled, busy, compare_with) = (sample.take(), *screen_busy, compare.then(|| opening.map_or(Mixed::Mixed, Mixed::Same))); @@ -616,7 +614,7 @@ impl StackDialog for ColorPickerDialog { let shown = Dialog::new(title.clone()) .opened(Bind::bound(open)) .buttons(buttons) - .button_place(ButtonPlace::Body) + .button_place(place) .close_on_enter(true) .initial_focus(Initial::Keep) .roomy(true) diff --git a/crates/color-ui/tests/it/picker.rs b/crates/color-ui/tests/it/picker.rs index 7f5e291c4..e686e06dd 100644 --- a/crates/color-ui/tests/it/picker.rs +++ b/crates/color-ui/tests/it/picker.rs @@ -4,24 +4,17 @@ use std::cell::RefCell; use std::rc::Rc; use craft_behavior::Mixed; -<<<<<<< HEAD use craft_color_ui::ui::{ - ColorPicker, ColorPickerDialog, ColorPickerDialogLayout, ColorPickerLayout, ColorPickerTab, ColorReadout, PickedColor, + ColorPicker, ColorPickerDialog, ColorPickerDialogLayout, ColorPickerLayout, ColorPickerTab, ColorPopover, ColorReadout, ColorWarning, + PickedColor, }; use craft_host::{AppInfo, Host}; -use craft_theme::{ColorModel, HsbModel, LabModel, ModelValues, RgbModel, Rgba, Srgba}; -use craft_ui::contract::{Bind, Role}; -use craft_ui::dialog::{DialogHost, DialogResult, StackDialog, dialog_id}; -use craft_ui::runtime::env::Label; -======= -use craft_color_ui::ui::{ColorPicker, ColorPickerDialog, ColorPickerLayout, ColorPopover, ColorReadout, ColorWarning, PickedColor}; -use craft_host::{AppInfo, Host}; use craft_theme::{ColorModel, HsbModel, LabModel, ModelValues, OklchModel, RgbModel, Rgba, Size, Srgba, ThemeId}; use craft_ui::contract::{Bind, Role, ShowContainer as _}; -use craft_ui::dialog::{DialogHost, DialogResult, dialog_id}; +use craft_ui::dialog::{DialogHost, DialogResult, StackDialog, dialog_id}; use craft_ui::layout::RowAlign; use craft_ui::layout_components::Row; ->>>>>>> up/next +use craft_ui::runtime::env::Label; use craft_ui::testing::{Fixture, trial}; use egui::{Key, Modifiers, Rect, vec2}; diff --git a/crates/craft/Cargo.toml b/crates/craft/Cargo.toml index 88d423ee3..7e9ff21b1 100644 --- a/crates/craft/Cargo.toml +++ b/crates/craft/Cargo.toml @@ -95,7 +95,6 @@ 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-gpu = { workspace = true, optional = true } craft-hdr = { workspace = true, optional = true } craft-heif = { workspace = true, optional = true } craft-html = { workspace = true, optional = true } @@ -300,11 +299,8 @@ audio-eac3-encode = ["audio", "craft-audio/eac3-encode"] audio-encode = ["audio", "craft-audio/encode"] audio-flac-decode = ["audio", "craft-audio/flac-decode"] audio-flac-encode = ["audio", "craft-audio/flac-encode"] -<<<<<<< HEAD -======= audio-g722 = ["audio", "craft-audio/g722"] audio-g726 = ["audio", "craft-audio/g726"] ->>>>>>> up/next audio-gsm = ["audio", "craft-audio/gsm"] audio-gsm-decode = ["audio", "craft-audio/gsm-decode"] audio-gsm-encode = ["audio", "craft-audio/gsm-encode"] @@ -355,11 +351,8 @@ codepage = ["dep:craft-codepage"] color = ["dep:craft-color"] -<<<<<<< HEAD -======= color-transform = ["dep:craft-color-transform"] ->>>>>>> up/next color-ui = ["dep:craft-color-ui", "keymap", "settings", "window", "platform"] control = ["dep:craft-control"] @@ -382,17 +375,13 @@ deckcraft-format = ["dep:craft-deckcraft-format"] designcraft-format = ["dep:craft-designcraft-format"] -<<<<<<< HEAD -dialogs = ["dep:craft-dialogs", "browse"] # native only: rfd's folder picker and file paths -======= develop = ["dep:craft-develop"] develop-model = ["dep:craft-develop-model"] dex = ["dep:craft-dex"] -dialogs = ["dep:craft-dialogs"] # native only: rfd's folder picker and file paths ->>>>>>> up/next +dialogs = ["dep:craft-dialogs", "browse"] # native only: rfd's folder picker and file paths doc = ["dep:craft-doc"] doc-pcraft-pixels = ["doc", "craft-doc/pcraft-pixels"] @@ -492,9 +481,8 @@ gif = ["dep:craft-gif"] gif-frames = ["gif", "craft-gif/frames"] gpu = ["dep:craft-gpu"] +gpu-startup = ["gpu", "craft-gpu/startup"] -<<<<<<< HEAD -======= gpu-null = ["dep:craft-gpu-null"] gpu-providers = ["dep:craft-gpu-providers"] @@ -506,7 +494,6 @@ gpu-wgpu-native-gles = ["gpu-wgpu", "craft-gpu-wgpu/native-gles"] gpu-wgpu-native-metal = ["gpu-wgpu", "craft-gpu-wgpu/native-metal"] gpu-wgpu-native-vulkan = ["gpu-wgpu", "craft-gpu-wgpu/native-vulkan"] ->>>>>>> up/next gridcraft-format = ["dep:craft-gridcraft-format"] gzip = ["dep:craft-gzip"] diff --git a/crates/craft/src/lib.rs b/crates/craft/src/lib.rs index 85d0b7d46..06a416a30 100644 --- a/crates/craft/src/lib.rs +++ b/crates/craft/src/lib.rs @@ -151,15 +151,12 @@ pub use craft_geom as geom; pub use craft_gif as gif; #[cfg(feature = "gpu")] pub use craft_gpu as gpu; -<<<<<<< HEAD -======= #[cfg(feature = "gpu-null")] pub use craft_gpu_null as gpu_null; #[cfg(feature = "gpu-providers")] pub use craft_gpu_providers as gpu_providers; #[cfg(feature = "gpu-wgpu")] pub use craft_gpu_wgpu as gpu_wgpu; ->>>>>>> up/next #[cfg(feature = "gridcraft-format")] pub use craft_gridcraft_format as gridcraft_format; #[cfg(feature = "gzip")] diff --git a/crates/draw/tests/it/transform_box.rs b/crates/draw/tests/it/transform_box.rs index 46f26ef27..a686e8d23 100644 --- a/crates/draw/tests/it/transform_box.rs +++ b/crates/draw/tests/it/transform_box.rs @@ -56,13 +56,10 @@ struct Config { line: Option, /// Snap targets beside the guides at [`SNAP_XS`]. targets: Vec, -<<<<<<< HEAD /// The key that suspends the canvas's snapping. suspend: SnapSuspend, -======= /// egui runs each frame twice and gives the frame's input to its first pass only. twice: bool, ->>>>>>> up/next } /// What the host keeps of the box and what the passes reported. @@ -109,11 +106,8 @@ fn defaults() -> Config { centre_mark: false, line: None, targets: Vec::new(), -<<<<<<< HEAD suspend: SnapSuspend::Control, -======= twice: false, ->>>>>>> up/next } } diff --git a/crates/gpu/Cargo.toml b/crates/gpu/Cargo.toml index e6fda5635..e2164e0fb 100644 --- a/crates/gpu/Cargo.toml +++ b/crates/gpu/Cargo.toml @@ -1,41 +1,33 @@ [package] name = "craft-gpu" -<<<<<<< HEAD -description = "GPU start-up choices per platform for Craft apps on eframe's wgpu backend: backends, power preference, DX12 compiler and the Linux DRM device pick." -======= -description = "Provider-neutral GPU traits, GpuJob envelope, and registry (no vendor IO)" ->>>>>>> up/next +description = "Provider-neutral GPU traits, GpuJob envelope, and registry (no vendor IO); with `startup`, eframe's wgpu start-up choices per platform" version.workspace = true edition.workspace = true license.workspace = true rust-version.workspace = true -<<<<<<< HEAD repository.workspace = true -[dependencies] -# A `[patch.crates-io]` row at the framework root points egui-wgpu at the pinned egui fork; it is not a workspace dependency. -# Its `wgpu` re-export is the wgpu eframe draws with. -egui-wgpu = { version = "0.37", default-features = false } -log = { workspace = true } - -[target.'cfg(windows)'.dependencies] -# Waits for the DirectX 12 adapter list of the start-up probe. -pollster = "1" - -[dev-dependencies] -tempfile = "3" - [lints] workspace = true -======= -[lints] -workspace = true +[features] +default = [] +# GPU start-up choices for apps on eframe's wgpu backend (`configure`): backends, power preference, DX12 compiler and +# the Linux DRM device pick. Off by default, so the provider-neutral traits pull in no vendor crate. +startup = ["dep:egui-wgpu", "dep:log", "dep:pollster"] [dependencies] serde = { workspace = true } thiserror = { workspace = true } +# A `[patch.crates-io]` row at the framework root points egui-wgpu at the pinned egui fork; it is not a workspace dependency. +# Its `wgpu` re-export is the wgpu eframe draws with. +egui-wgpu = { version = "0.37", default-features = false, optional = true } +log = { workspace = true, optional = true } + +[target.'cfg(windows)'.dependencies] +# Waits for the DirectX 12 adapter list of the start-up probe. +pollster = { version = "1", optional = true } [dev-dependencies] serde_json = { workspace = true } ->>>>>>> up/next +tempfile = "3" diff --git a/crates/gpu/src/lib.rs b/crates/gpu/src/lib.rs index ee991dd90..fd0e86e9a 100644 --- a/crates/gpu/src/lib.rs +++ b/crates/gpu/src/lib.rs @@ -1,28 +1,19 @@ -<<<<<<< HEAD -#![deny(clippy::unwrap_used, clippy::expect_used, clippy::panic, clippy::unimplemented, clippy::todo, clippy::unreachable)] - -//! GPU start-up choices per platform for apps on eframe's wgpu backend: which backends to try, the power preference, -//! the DX12 shader compiler and, on Linux, which DRM device to render on. An app calls [`configure`] on the -//! `WgpuSetupCreateNew` it hands to eframe. -#![warn(missing_docs)] - -mod device; - -pub use device::configure; - -#[cfg(test)] -mod device_tests; -======= //! GPU traits, job envelope, and provider registry for Craft apps and the web runtime. //! //! Application crates register [`GpuProvider`] implementations; generic hosts dispatch //! [`GpuJob`] values by [`GpuJob::provider_id`] without importing app project types. +//! +//! With the `startup` feature, the GPU start-up choices per platform for apps on eframe's wgpu backend: which backends +//! to try, the power preference, the DX12 shader compiler and, on Linux, which DRM device to render on. An app calls +//! `configure` on the `WgpuSetupCreateNew` it hands to eframe. #![deny(clippy::unwrap_used, clippy::expect_used, clippy::panic, clippy::unimplemented, clippy::todo, clippy::unreachable)] mod caps; mod chunk; mod context; +#[cfg(feature = "startup")] +mod device; mod error; mod job; mod provider; @@ -32,12 +23,16 @@ mod registry; #[cfg(test)] mod tests; +#[cfg(all(test, feature = "startup"))] +mod device_tests; + pub use caps::DeviceCaps; pub use chunk::chunk_buffer; pub use context::{GpuContext, ReadOutcome, ReadRequest, WorkerKind}; +#[cfg(feature = "startup")] +pub use device::configure; pub use error::GpuFault; pub use job::{GpuJob, GpuJobOutcome, GpuJobParams, HandleId}; pub use provider::GpuProvider; pub use readback::{f16_rgba_to_f32_bytes, f16_to_f32, f16_to_f32_fast}; pub use registry::ProviderRegistry; ->>>>>>> up/next diff --git a/crates/image-codecs/src/bmp_probe.rs b/crates/image-codecs/src/bmp_probe.rs index 1de6dfada..8bd2c6435 100644 --- a/crates/image-codecs/src/bmp_probe.rs +++ b/crates/image-codecs/src/bmp_probe.rs @@ -2,11 +2,8 @@ use crate::error::CodecError; -<<<<<<< HEAD -======= pub use crate::codecs::bmp::pixels_per_meter; ->>>>>>> up/next /// Recognize a BMP file header with a supported DIB header kind. /// /// This is a format-routing check, not full validation: dimensions and pixel data may still @@ -621,8 +618,6 @@ mod tests { odd.extend_from_slice(©); assert_eq!(dib_layout(odd.clone()), odd); } -<<<<<<< HEAD -======= } #[cfg(test)] @@ -667,5 +662,4 @@ mod density_tests { trailing.extend_from_slice(&[1, 2, 3]); assert_eq!(pixels_per_meter(&trailing), Some((10000, 20000))); } ->>>>>>> up/next } diff --git a/crates/keymap/src/keymap.rs b/crates/keymap/src/keymap.rs index 08f614d4f..3a042d8e2 100644 --- a/crates/keymap/src/keymap.rs +++ b/crates/keymap/src/keymap.rs @@ -390,26 +390,23 @@ impl Keymap { /// [`lookup`](Self::lookup) with the panels around the focused one in `outer` ([`Scopes::rank_nested`]). pub fn lookup_nested(&self, chord: &Chord, double: bool, active: &Active, outer: &[&str]) -> Lookup { -<<<<<<< HEAD self.lookup_where(chord, double, active, outer, &|_| true) } /// [`lookup_nested`](Self::lookup_nested) among the commands `accept` takes: the bindings of a command it refuses /// (one disabled where the press lands) are passed over, so the chord's next binding, in an outer scope, runs. pub fn lookup_where(&self, chord: &Chord, double: bool, active: &Active, outer: &[&str], accept: &dyn Fn(&CommandRef) -> bool) -> Lookup { - let want = Trigger { chord: chord.effective(self.platform), double }; -======= let command = |i: usize| self.catalog[i].command.clone(); - match self.winners(Trigger { chord: chord.effective(self.platform), double }, active, outer) { + match self.winners(Trigger { chord: chord.effective(self.platform), double }, active, outer, accept) { Winners::None => Lookup::None, Winners::Run(i) => Lookup::Run(command(i)), Winners::Cycle(cycle) => Lookup::Cycle(cycle.into_iter().map(command).collect()), } } - /// The commands, by catalog position, that a press of the effective trigger `want` runs with `active` focus. - fn winners(&self, want: Trigger, active: &Active, outer: &[&str]) -> Winners { ->>>>>>> up/next + /// The commands, by catalog position, that a press of the effective trigger `want` runs with `active` focus, among + /// the commands `accept` takes. + fn winners(&self, want: Trigger, active: &Active, outer: &[&str], accept: &dyn Fn(&CommandRef) -> bool) -> Winners { let held = active.typing && !self.typing.fires(&want.chord, self.platform); let Some(holders) = self.by_trigger.get(&want) else { return Winners::None }; // Each command's nearest rank; `holders` is in catalog order. @@ -470,7 +467,7 @@ impl Keymap { ScopeKind::Panel => Active::panel(name[0]), ScopeKind::Context => Active { panel: None, contexts: &name, typing: false }, }; - match self.winners(Trigger { chord: trigger.chord.effective(self.platform), double: false }, &active, &[]) { + match self.winners(Trigger { chord: trigger.chord.effective(self.platform), double: false }, &active, &[], &|_| true) { Winners::None => false, Winners::Run(j) => j == i, Winners::Cycle(cycle) => cycle.contains(&i), diff --git a/crates/keymap/tests/keymap.rs b/crates/keymap/tests/keymap.rs index 5604fdcf3..28984636e 100644 --- a/crates/keymap/tests/keymap.rs +++ b/crates/keymap/tests/keymap.rs @@ -218,7 +218,6 @@ fn the_alt_variant_follows_the_commands_key_and_yields_to_a_bound_alt_chord() { assert!(hit(&km, &alt(Key::F2, false, false)).is_none(), "a command that did not opt in has no Alt variant"); } -<<<<<<< HEAD /// A press passes over the binding of a command the caller refuses (one disabled where it lands): the chord's binding /// in an outer scope runs instead, the lookup says the same, and with every holder refused the press runs nothing. #[test] @@ -257,7 +256,8 @@ fn a_held_shift_runs_the_shift_kept_binding_before_rule_3_drops_it() { assert_eq!(ran(both), Some(cmd("format.superscript")), "the Shift-kept binding wins"); assert_eq!(ran(vec![app("format.subscript", &["Cmd+="])]), Some(cmd("format.subscript")), "unbound, rule 3 holds"); assert_eq!(Layout::new().resolve(&shift_zero), Some(chord("Cmd+=")), "the press is still recorded as rule 3 reads it"); -======= +} + /// Tools that share a chord: within one group a press cycles through them, so each shows the chord; across groups the /// first in catalog order runs, so only it shows the chord. `shown_chord` decides on catalog positions (#15493) and /// must answer as the lookup does. @@ -280,5 +280,4 @@ fn tools_sharing_a_chord_show_it_as_the_lookup_runs_them() { assert_eq!(km.shown_chord(&cmd("tool.artboard")), None, "the other group's tool never runs on V"); // A command with empty parameters is the same command. assert_eq!(km.shown_chord(&CommandRef::with_params("tool.move", serde_json::json!({}))), Some(chord("V"))); ->>>>>>> up/next } diff --git a/crates/pages/src/ui/margins/stories.rs b/crates/pages/src/ui/margins/stories.rs index 4b99e0fd6..4a6168325 100644 --- a/crates/pages/src/ui/margins/stories.rs +++ b/crates/pages/src/ui/margins/stories.rs @@ -11,13 +11,6 @@ use craft_ui::runtime::env::{Message, UnitKind}; use craft_ui::testing::{Drive, Fixture, StoryData, StoryOutput, story}; use egui::{Ui, Vec2}; -<<<<<<< HEAD -/// The pasteboard shown above and to the left of the page, points: the page's corner and its left and top margins lie -/// inside the stage, where a pointer reaches their edges. -const LEAD: f64 = 48.0; - -======= ->>>>>>> up/next /// How far the drag moves the left edge, in drag thresholds. const DRAG_THRESHOLDS: f32 = 12.0; @@ -30,22 +23,12 @@ fn drag_left_edge(fixture: &mut Fixture) { /// The handles over `edges` on a page canvas. fn handles(ui: &mut Ui, edges: Bind<'_, PageEdges>) -> StoryOutput { let full = craft_ui::testing::stage(ui); -<<<<<<< HEAD - // At 100% the page is wider than the stage: the view shows its top-left corner, as a document opens scrolled to it. - let centre = Point::new(f64::from(full.width()) / 2.0 - LEAD, f64::from(full.height()) / 2.0 - LEAD); - let view = CanvasView::new(full, centre, 1.0); -======= let mut view = CanvasView::new(full, Point::ZERO, 1.0); let page = fitted_page(&mut view, ui.ctx().pixels_per_point()); ->>>>>>> up/next let mut edges = edges; Canvas::new("Pages") .view(view) .show_at(ui, full, |ui, body| { -<<<<<<< HEAD - let page = demo_placed(1, CanvasView::new(body.rect, centre, 1.0).to_screen(Point::ZERO)).remove(0); -======= ->>>>>>> up/next Some(MarginHandles::new("Margins", &page, edges.reborrowed()).header_footer().unit(UnitKind::Inches).show_at(ui, body.rect)) }) .inner diff --git a/crates/platform/src/clipboard/backend.rs b/crates/platform/src/clipboard/backend.rs index 7e8484453..d2e97d62e 100644 --- a/crates/platform/src/clipboard/backend.rs +++ b/crates/platform/src/clipboard/backend.rs @@ -157,242 +157,7 @@ pub(super) fn present(read: Result, unconvertible: bool) - } } -<<<<<<< HEAD #[cfg(all(feature = "clipboard-system", not(target_arch = "wasm32")))] -======= -/// Whether the system clipboard offers a format, asked of the system without reading or decoding -/// any content: Windows `IsClipboardFormatAvailable`, macOS the pasteboard's type list, Wayland -/// the offer's MIME types (`wl_clipboard_rs::paste::get_mime_types`), X11 a `TARGETS` request. -/// -/// The macOS and Windows code is not built on the Linux box; it is a few lines each and needs a -/// check on those systems. -#[cfg(all(feature = "clipboard", not(target_arch = "wasm32")))] -mod presence { - #[cfg(any(windows, target_os = "macos"))] - use super::{BITMAP, HTML, RGBA8, TEXT, URI_LIST}; - - pub(super) struct Presence { - #[cfg(any(windows, target_os = "macos"))] - _system: (), - #[cfg(not(any(windows, target_os = "macos")))] - x11: Option, - } - - #[cfg(windows)] - impl Presence { - pub(super) fn new() -> Self { - Self { _system: () } - } - - pub(super) fn any(&mut self, mimes: &[&str]) -> bool { - use clipboard_win::{formats, is_format_avail, register_format}; - let registered = |name: &str| register_format(name).is_some_and(|format| is_format_avail(format.get())); - mimes.iter().any(|&mime| match mime { - TEXT => is_format_avail(formats::CF_UNICODETEXT), - HTML => registered("HTML Format"), - BITMAP | RGBA8 => registered("PNG") || is_format_avail(formats::CF_DIBV5) || is_format_avail(formats::CF_DIB), - URI_LIST => is_format_avail(formats::CF_HDROP), - _ => false, - }) - } - } - - #[cfg(target_os = "macos")] - impl Presence { - pub(super) fn new() -> Self { - Self { _system: () } - } - - pub(super) fn any(&mut self, mimes: &[&str]) -> bool { - use objc2_app_kit::NSPasteboard; - use objc2_foundation::NSString; - // `types` lists the formats on offer; no item's data is fetched. - let Some(types) = NSPasteboard::generalPasteboard().types() else { return false }; - mimes.iter().any(|&mime| { - // The type identifiers AppKit's `NSPasteboardType…` constants hold; the constants are extern statics, - // which only `unsafe` can read, and the workspace forbids unsafe code. - let wanted = match mime { - TEXT => "public.utf8-plain-text", - HTML => "public.html", - BITMAP | RGBA8 => "public.tiff", - URI_LIST => "public.file-url", - _ => return false, - }; - let wanted = NSString::from_str(wanted); - types.iter().any(|offered| offered.isEqualToString(&wanted)) - }) - } - } - - /// Linux and BSD. Wayland when `WAYLAND_DISPLAY` is set and the compositor has a data-control - /// protocol, else X11: the order arboard picks its own backend in. - #[cfg(not(any(windows, target_os = "macos")))] - impl Presence { - pub(super) fn new() -> Self { - Self { x11: None } - } - - pub(super) fn any(&mut self, mimes: &[&str]) -> bool { - let offered = self.offered(); - mimes.iter().any(|&mime| super::offered_has(&offered, mime)) - } - - fn offered(&mut self) -> Vec { - use wl_clipboard_rs::paste::{ClipboardType, Error, Seat, get_mime_types}; - if std::env::var_os("WAYLAND_DISPLAY").is_some() { - match get_mime_types(ClipboardType::Regular, Seat::Unspecified) { - Ok(types) => return types.into_iter().collect(), - // Nothing is copied. - Err(Error::NoSeats | Error::ClipboardEmpty | Error::NoMimeType) => return Vec::new(), - Err(error) => log::debug!("no Wayland data control for the clipboard probe, trying X11: {error}"), - } - } - if self.x11.is_none() { - self.x11 = x11::Targets::connect(); - } - self.x11.as_ref().map(x11::Targets::offered).unwrap_or_default() - } - } - - #[cfg(not(any(windows, target_os = "macos")))] - mod x11 { - use std::time::{Duration, Instant}; - - use x11rb::connection::Connection; - use x11rb::protocol::Event; - use x11rb::protocol::xproto::{Atom, AtomEnum, ConnectionExt, CreateWindowAux, EventMask, WindowClass}; - use x11rb::rust_connection::RustConnection; - use x11rb::{COPY_DEPTH_FROM_PARENT, CURRENT_TIME, NONE}; - - /// How long a `TARGETS` request waits for the owner. The probe's worker waits, not the UI. - const ANSWER_WAIT: Duration = Duration::from_millis(250); - - /// A connection and a window that receive the clipboard owner's `TARGETS` answer. - pub(super) struct Targets { - conn: RustConnection, - window: u32, - clipboard: Atom, - targets: Atom, - property: Atom, - } - - impl Targets { - pub(super) fn connect() -> Option { - let (conn, screen) = RustConnection::connect(None).ok()?; - let root = conn.setup().roots.get(screen)?.root; - let window = conn.generate_id().ok()?; - conn.create_window( - COPY_DEPTH_FROM_PARENT, - window, - root, - 0, - 0, - 1, - 1, - 0, - WindowClass::INPUT_OUTPUT, - 0, - &CreateWindowAux::new().event_mask(EventMask::PROPERTY_CHANGE), - ) - .ok()?; - let atom = |name: &[u8]| conn.intern_atom(false, name).ok()?.reply().ok().map(|reply| reply.atom); - let (clipboard, targets, property) = (atom(b"CLIPBOARD")?, atom(b"TARGETS")?, atom(b"CRAFT_CLIPBOARD_TARGETS")?); - Some(Self { conn, window, clipboard, targets, property }) - } - - /// The target names the CLIPBOARD owner offers; none when nobody owns it or answers. - pub(super) fn offered(&self) -> Vec { - self.ask().unwrap_or_default() - } - - fn ask(&self) -> Option> { - self.conn.delete_property(self.window, self.property).ok()?; - self.conn.convert_selection(self.window, self.clipboard, self.targets, self.property, CURRENT_TIME).ok()?; - self.conn.flush().ok()?; - let end = Instant::now() + ANSWER_WAIT; - while Instant::now() < end { - match self.conn.poll_for_event().ok()? { - Some(Event::SelectionNotify(event)) if event.selection == self.clipboard => { - if event.property == NONE { - return None; - } - let reply = - self.conn.get_property(true, self.window, self.property, AtomEnum::ATOM, 0, u32::MAX / 4).ok()?.reply().ok()?; - let atoms: Vec = reply.value32()?.collect(); - return Some( - atoms - .into_iter() - .filter_map(|atom| { - let name = self.conn.get_atom_name(atom).ok()?.reply().ok()?.name; - String::from_utf8(name).ok() - }) - .collect(), - ); - } - Some(_) => {} - None => std::thread::sleep(Duration::from_millis(1)), - } - } - None - } - } - } -} - -/// Whether the target or MIME names a clipboard `offered` contain a format that [`SystemClipboard`] -/// can read as `mime`. Text includes the X11 text targets; a bitmap is `image/png`, the only -/// bitmap arboard reads on Linux. -#[allow(dead_code, reason = "only the Linux and BSD probe maps names")] -pub(crate) fn offered_has(offered: &[String], mime: &str) -> bool { - let any = |names: &[&str]| offered.iter().any(|offer| names.iter().any(|name| offer.eq_ignore_ascii_case(name))); - match mime { - TEXT => any(&["text/plain", "text/plain;charset=utf-8", "UTF8_STRING", "STRING", "TEXT"]), - HTML => any(&["text/html"]), - BITMAP | RGBA8 => any(&[PNG]), - URI_LIST => any(&[URI_LIST]), - _ => false, - } -} - -/// What a write puts on the system clipboard. -#[cfg(all(feature = "clipboard", not(target_arch = "wasm32")))] -pub(crate) enum Put { - Clear, - Image(ClipboardImage), - Html { html: String, alt: Option }, - Text(String), -} - -/// The first flavor the system clipboard can hold, as its index in `flavors` and what to put -/// there. -#[cfg(all(feature = "clipboard", not(target_arch = "wasm32")))] -pub(crate) fn plan_write(flavors: &[Flavor], decode: Option<&Decode>) -> Result<(usize, Put), ClipboardError> { - if flavors.is_empty() { - return Ok((0, Put::Clear)); - } - let text_of = |f: &Flavor| String::from_utf8_lossy(&f.data).into_owned(); - for (index, flavor) in flavors.iter().enumerate() { - match &*flavor.mime { - RGBA8 => { - if let Some(image) = rgba8_image(&flavor.data).filter(ClipboardImage::is_whole) { - return Ok((index, Put::Image(image))); - } - } - PNG => { - if let Some(image) = decode.and_then(|decode| decode(&flavor.data)).filter(ClipboardImage::is_whole) { - return Ok((index, Put::Image(image))); - } - } - HTML => return Ok((index, Put::Html { html: text_of(flavor), alt: flavors.iter().find(|f| f.mime == TEXT).map(text_of) })), - TEXT => return Ok((index, Put::Text(text_of(flavor)))), - _ => {} - } - } - Err(ClipboardError::NoFormat) -} - -#[cfg(all(feature = "clipboard", not(target_arch = "wasm32")))] ->>>>>>> up/next impl Default for SystemClipboard { fn default() -> Self { Self::new() diff --git a/crates/text/src/ui/character/paragraph_dialog.rs b/crates/text/src/ui/character/paragraph_dialog.rs index 11b656c22..dbf69a5cd 100644 --- a/crates/text/src/ui/character/paragraph_dialog.rs +++ b/crates/text/src/ui/character/paragraph_dialog.rs @@ -18,18 +18,15 @@ use std::cell::Cell; use crate::ui::length::{DocUnit, length_field, shown}; use craft_behavior::{Axis, EditEvent, Metrics, Mixed, NumberCodec, SelectionChange, keyed}; use craft_theme::variant::Tone; -<<<<<<< HEAD use craft_ui::choice::{Checkbox, Radio, RadioGroup}; use craft_ui::contract::{ Bind, CollectionEvent, Common, Component, Cx, Entry, FieldLayout, MeasureCx, PaintUi, Props as _, Role, Show as _, ShowCollection as _, ShowContainer as _, SideLabel, }; -use craft_ui::dialog::{Dialog, DialogId, DialogResult, DialogStack, HeldAnswer, HeldOk, StackDialog, dialog_id, serde_fields, set_serde_field}; +use craft_ui::dialog::{ + ButtonPlace, Dialog, DialogId, DialogResult, DialogStack, HeldAnswer, HeldOk, StackDialog, dialog_id, serde_fields, set_serde_field, +}; use craft_ui::display::Text; -======= -use craft_ui::contract::{Bind, Common, Component, Cx, Entry, MeasureCx, PaintUi, Props as _, Role, Show as _, ShowContainer as _}; -use craft_ui::dialog::{ButtonPlace, Dialog, DialogId, DialogResult, DialogStack, StackDialog, dialog_id}; ->>>>>>> up/next use craft_ui::form::{Field, FieldGroup, Help}; use craft_ui::layout_components::Stack; use craft_ui::pickers::Select; diff --git a/crates/text/src/ui/find/dialog.rs b/crates/text/src/ui/find/dialog.rs index 34b4605eb..b32604bc1 100644 --- a/crates/text/src/ui/find/dialog.rs +++ b/crates/text/src/ui/find/dialog.rs @@ -7,11 +7,9 @@ use craft_behavior::{SelectionChange, keyed}; use craft_ui::buttons::Button; use craft_ui::choice::Checkbox; use craft_ui::contract::{Bind, CollectionEvent, Entry, Props as _, Show as _, ShowCollection as _, ShowContainer as _, Trigger, clicked}; -<<<<<<< HEAD -use craft_ui::dialog::{Dialog, DialogId, DialogResult, DialogStack, FieldRefusal, StackDialog, dialog_id, serde_fields, set_serde_field}; -======= -use craft_ui::dialog::{ButtonPlace, Dialog, DialogId, DialogResult, DialogStack, StackDialog, dialog_id}; ->>>>>>> up/next +use craft_ui::dialog::{ + ButtonPlace, Dialog, DialogId, DialogResult, DialogStack, FieldRefusal, StackDialog, dialog_id, serde_fields, set_serde_field, +}; use craft_ui::display::Text; use craft_ui::form::{Field as FormField, Help}; use craft_ui::menu::Menu; @@ -441,10 +439,9 @@ impl StackDialog for FindReplaceDialog { buttons.push(FooterButton::new(words.close_button.clone(), DialogRole::Cancel)); let close_at = buttons.len() - 1; -<<<<<<< HEAD let shown = Dialog::new(words.title.clone()) .modeless() - .side_buttons(true) + .button_place(ButtonPlace::Side) .buttons(buttons) .settle_buttons(|_, buttons| { if let Some(accept) = buttons.get_mut(0) { @@ -452,9 +449,6 @@ impl StackDialog for FindReplaceDialog { } }) .show(ui, |ui, _| { -======= - let shown = Dialog::new(words.title.clone()).modeless().button_place(ButtonPlace::Side).buttons(buttons).show(ui, |ui, _| { ->>>>>>> up/next if word { let tabs = [ (FindTab::Find, words.find_tab.as_str().to_owned()), diff --git a/crates/text/src/ui/hyperlink.rs b/crates/text/src/ui/hyperlink.rs index 85112a43f..695b5a0bc 100644 --- a/crates/text/src/ui/hyperlink.rs +++ b/crates/text/src/ui/hyperlink.rs @@ -9,11 +9,7 @@ use craft_ui::choice::{Checkbox, Radio, RadioGroup}; use craft_ui::contract::{ Bind, FieldLayout, NoValue, Outcome, Props as _, SelectMode, Show as _, ShowCollection as _, ShowContainer as _, SideLabel, Sizing, }; -<<<<<<< HEAD -use craft_ui::dialog::{Dialog, DialogId, DialogOutput, DialogResult, DialogStack, HeldAnswer, HeldOk, StackDialog, dialog_id}; -======= -use craft_ui::dialog::{ButtonPlace, Dialog, DialogId, DialogOutput, DialogResult, DialogStack, StackDialog, dialog_id}; ->>>>>>> up/next +use craft_ui::dialog::{ButtonPlace, Dialog, DialogId, DialogOutput, DialogResult, DialogStack, HeldAnswer, HeldOk, StackDialog, dialog_id}; use craft_ui::display::Text; use craft_ui::form::{Field, FieldGroup}; use craft_ui::layout_components::{Row, Stack}; @@ -429,18 +425,11 @@ impl HyperlinkDialog { buttons.push(FooterButton::new(words.remove.clone(), DialogRole::Destructive)); } let dialog = Dialog::new(title) -<<<<<<< HEAD - .side_buttons(true) - .buttons(buttons) - .initial_focus(Initial::Default) - .opened(Bind::bound(open)) - .refusal(|| refused.as_ref().filter(|(_, answer)| current.borrow().as_ref() == Some(answer)).map(|(reason, _)| reason.clone())) -======= .button_place(ButtonPlace::Side) .buttons(buttons) .initial_focus(Initial::Default) .opened(Bind::bound(open)) ->>>>>>> up/next + .refusal(|| refused.as_ref().filter(|(_, answer)| current.borrow().as_ref() == Some(answer)).map(|(reason, _)| reason.clone())) .settle_buttons(|_, buttons| { if let Some(accept) = buttons.get_mut(OK) { accept.set_enabled(current.borrow().is_some() && !waiting); diff --git a/crates/theme/src/format_tests.rs b/crates/theme/src/format_tests.rs index 7000cf502..23e6ec1ea 100644 --- a/crates/theme/src/format_tests.rs +++ b/crates/theme/src/format_tests.rs @@ -97,7 +97,6 @@ fn round_trip_keeps_values_and_unknown_keys() { assert_eq!(format::write(&again).unwrap(), text, "writing is stable"); } -<<<<<<< HEAD /// An app's own `shape` replaces the theme's for that app only (WordCraft's rounded-rectangle buttons under /// ArtCraft's capsules), and it is written back. #[test] @@ -117,7 +116,8 @@ fn an_apps_own_shape_replaces_the_themes_for_that_app() { let mut bad = full(); bad["apps"]["photocraft"]["shape"] = json!({ "button_radius": -1 }); assert!(!errors(&bad).is_empty(), "an app's shape is checked as a theme's"); -======= +} + /// A pack set on a file without one is written; clearing it removes the key and keeps the file's unknown keys; a /// value that is not a well-formed pack id is an error at its key. #[test] @@ -143,7 +143,6 @@ fn the_icon_pack_is_added_cleared_and_checked() { assert_eq!(e.len(), 1, "{bad}: {e:?}"); assert!(e[0].starts_with("icon_pack: "), "{bad}: {e:?}"); } ->>>>>>> up/next } /// A theme file with the given light-mode pins. diff --git a/crates/ui-canvas/src/canvas_controls/task_bar.rs b/crates/ui-canvas/src/canvas_controls/task_bar.rs index 759991a81..478475b92 100644 --- a/crates/ui-canvas/src/canvas_controls/task_bar.rs +++ b/crates/ui-canvas/src/canvas_controls/task_bar.rs @@ -221,24 +221,21 @@ impl<'a> TaskBar<'a> { Some(Mixed::Same(held)) => held, _ => TaskBarPlace::default(), }; -<<<<<<< HEAD let hang = shows.then(|| hang_rect(bounds, env.tokens.space.gap.section, side)); let overlay = match kind { TaskBarKind::Task => layer_overlay(&held, hang, area, side), TaskBarKind::Selection => selection_overlay(hang, area, dismiss, side), }; - let layer = TaskBarLayer::new(label, words.task_bar_move.clone(), overlay, shows, kind); + let layer = TaskBarLayer::new(label, overlay, shows, kind); let mut menu = MoreMenu { words: Arc::clone(&words), offered: kind == TaskBarKind::Task, placed: false, pick: None }; -======= - let hang = shows.then(|| hang_rect(bounds, env.tokens.space.gap.section)); - let layer = TaskBarLayer::new(label, layer_overlay(&held, hang, area), shows); - let mut menu = MoreMenu { words: Arc::clone(&words), placed: false, pick: None }; - let grip = words.task_bar_move.clone(); ->>>>>>> up/next + // Only the task bar moves, so only it starts with the grip. + let grip = (kind == TaskBarKind::Task).then(|| words.task_bar_move.clone()); let mut shown = layer.show(ui, |ui, _| { // The bar is the one surface: the grip is its first member, on the members' line inside its padding. Bar::new(Label::Empty, BarKind::Tool).surface(SurfaceKind::Floating).show(ui, |ui, _| { - let _ = Icon::new(IconSpec::svg(IconId::new("grip"))).label(grip.clone()).show(ui); + if let Some(grip) = &grip { + let _ = Icon::new(IconSpec::svg(IconId::new("grip"))).label(grip.clone()).show(ui); + } menu.placed = false; let inner = body(ui, &mut TaskBarCx { menu: &mut menu }); menu.place(ui); @@ -374,10 +371,9 @@ struct TaskBarLayer { } impl TaskBarLayer { -<<<<<<< HEAD - /// A layer for a bar of `kind`: only the task bar has the grip header that moves it. - fn new(label: Label, grip: Label, overlay: Overlay, open: bool, kind: TaskBarKind) -> Self { - let mut props = ContainerProps::new().mount(Mount::Layer(overlay)).surface(SurfaceKind::Floating).pad(Pad::None).sizing(Sizing::Content); + /// A layer for a bar of `kind`: only the task bar has the empty inline header whose move band moves it. + fn new(label: Label, overlay: Overlay, open: bool, kind: TaskBarKind) -> Self { + let mut props = ContainerProps::new().mount(Mount::Layer(overlay)).pad(Pad::None).sizing(Sizing::Content); let salt = match kind { TaskBarKind::Task => { props = props.header(HeaderRegion::new().band(DragBand::Move).inline(true)); @@ -385,16 +381,7 @@ impl TaskBarLayer { } TaskBarKind::Selection => "selection-bar", }; - TaskBarLayer { common: Common::new(), props, grip, open: Bind::given(open), moved: None, closed: None }.label(label).id_salt(salt) -======= - fn new(label: Label, overlay: Overlay, open: bool) -> Self { - let props = ContainerProps::new() - .mount(Mount::Layer(overlay)) - .pad(Pad::None) - .sizing(Sizing::Content) - .header(HeaderRegion::new().band(DragBand::Move).inline(true)); - TaskBarLayer { common: Common::new(), props, open: Bind::given(open), moved: None }.label(label).id_salt("task-bar") ->>>>>>> up/next + TaskBarLayer { common: Common::new(), props, open: Bind::given(open), moved: None, closed: None }.label(label).id_salt(salt) } } @@ -423,18 +410,10 @@ impl Container for TaskBarLayer { Some(self.open.reborrow()) } -<<<<<<< HEAD - /// The grip glyph, named for the move it offers. - fn header(&mut self, ui: &mut Ui, _: &mut BodyCx<'_>) { - let _ = Icon::new(IconSpec::svg(IconId::new("grip"))).label(self.grip.clone()).show(ui); - } - fn closed(&mut self, why: CloseReason) { self.closed.get_or_insert(why); } -======= ->>>>>>> up/next fn placement_changed(&mut self, change: &PlacementChange) { if change.kind == PlacementKind::Move { self.moved = Some(change.rect); diff --git a/crates/ui-panels/src/dialog/mod.rs b/crates/ui-panels/src/dialog/mod.rs index b546e8070..3729e8995 100644 --- a/crates/ui-panels/src/dialog/mod.rs +++ b/crates/ui-panels/src/dialog/mod.rs @@ -28,13 +28,8 @@ pub use frame::{DialogFrame, DialogFrameStyle, DialogOutput, FooterCx, FooterHoo pub use held::{HeldAnswer, HeldOk}; #[doc(hidden)] pub use host::dialog_probe; -<<<<<<< HEAD pub use host::{ChildDialog, DialogHost, DialogResult, FieldRefusal, OpenDialog, StackDialog, StartupStage}; -pub use modal::{Dialog, DialogStyle}; -======= -pub use host::{DialogHost, DialogResult, FieldRefusal, OpenDialog, StackDialog, StartupStage}; pub use modal::{ButtonPlace, Dialog, DialogStyle}; ->>>>>>> up/next pub use prompt::{Prompt, PromptOutput}; pub use prompts::{PromptAnswer, PromptChoice, PromptKind, StandardPrompt, StandardPromptOutput}; pub use recovery::{RecoveredDocument, RecoveryAnswer, RecoveryDialog, RecoveryOutput}; diff --git a/crates/ui-panels/src/dialog/modal.rs b/crates/ui-panels/src/dialog/modal.rs index e455b86e4..a0c0f20c5 100644 --- a/crates/ui-panels/src/dialog/modal.rs +++ b/crates/ui-panels/src/dialog/modal.rs @@ -36,9 +36,8 @@ type OnPickFn<'a> = Box) + 'a>; type SettleFn<'a> = Box, &mut [FooterButton]) + 'a>; -<<<<<<< HEAD type RefusalFn<'a> = Box Option