mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-17 16:54:45 +00:00
ui-contract: testing::windows::set_os sets the shell's OS and egui's in one call
This commit is contained in:
@@ -576,15 +576,6 @@ pub(crate) fn access_set_value(target: egui::Id, value: f64) -> Event {
|
||||
})
|
||||
}
|
||||
|
||||
/// Tells the context which operating system it runs on.
|
||||
pub(crate) fn set_os(ctx: &Context, os: craft_host::target::Os) {
|
||||
ctx.set_os(match os {
|
||||
craft_host::target::Os::Mac => egui::os::OperatingSystem::Mac,
|
||||
craft_host::target::Os::Windows => egui::os::OperatingSystem::Windows,
|
||||
_ => egui::os::OperatingSystem::Nix,
|
||||
});
|
||||
}
|
||||
|
||||
/// An IME preedit event of `text` with no cursor range.
|
||||
pub fn ime_preedit(text: &str) -> Event {
|
||||
Event::Ime(egui::ImeEvent::Preedit { text: text.into(), active_range_chars: None })
|
||||
|
||||
@@ -28,9 +28,14 @@ pub fn os_of(ctx: &Context) -> Os {
|
||||
}
|
||||
|
||||
/// Makes the shell run on `os`, as a test of the OS matrix does: the capabilities and the menu placement of a
|
||||
/// native build follow it. egui's own OS is the caller's to set.
|
||||
/// native build follow it, and so does egui's own OS (its text editing keys).
|
||||
#[cfg(feature = "testing")]
|
||||
pub(crate) fn set_os(ctx: &Context, os: Os) {
|
||||
ctx.set_os(match os {
|
||||
Os::Mac => egui::os::OperatingSystem::Mac,
|
||||
Os::Windows => egui::os::OperatingSystem::Windows,
|
||||
_ => egui::os::OperatingSystem::Nix,
|
||||
});
|
||||
shared(ctx, |shared| {
|
||||
let root_chrome = shared.root_frame.as_ref().map(chrome_of);
|
||||
let shell = shared.shell.get_or_insert_with(ShellInfo::default);
|
||||
|
||||
@@ -304,7 +304,6 @@ impl Fixture {
|
||||
/// text editing.
|
||||
pub fn os(&mut self, os: Os) -> &mut Self {
|
||||
crate::runtime::windows::set_os(&self.frames.ctx, os);
|
||||
fixture::set_os(&self.frames.ctx, os);
|
||||
self
|
||||
}
|
||||
|
||||
|
||||
@@ -13,6 +13,12 @@ pub fn install_spec() -> InstallSpec {
|
||||
InstallSpec::new(ShellInfo::default(), Arc::new(NoWindows))
|
||||
}
|
||||
|
||||
/// Makes the shell of `ctx` run on `os`, for a test of the OS matrix: the key table, the chords shown, the chrome,
|
||||
/// the capabilities of a native build and egui's own OS all follow it.
|
||||
pub fn set_os(ctx: &egui::Context, os: craft_host::target::Os) {
|
||||
crate::runtime::windows::set_os(ctx, os);
|
||||
}
|
||||
|
||||
/// The window actions the platform applies out of reach of egui's commands (`SetOpacity`) since the last call.
|
||||
pub fn applied_actions(ctx: &egui::Context) -> Vec<(egui::ViewportId, crate::runtime::windows::WindowAction)> {
|
||||
crate::runtime::windows::take_sent(ctx)
|
||||
|
||||
Reference in New Issue
Block a user