Skip to content

Commit 7f680a3

Browse files
authored
Merge pull request #93 from compio-rs/dev/stub
feat: stub implementation
2 parents 6609c0c + abe090a commit 7f680a3

31 files changed

+1797
-24
lines changed

.github/workflows/test.yml

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
setup:
2222
- os: 'ubuntu-24.04'
2323
deps: 'qtbase5-dev qtmultimedia5-dev qtwebengine5-dev libgtk-4-dev libwebkitgtk-6.0-dev'
24-
features: 'media,webview,qt-opengl'
24+
features: 'all,qt-opengl'
2525
- os: 'ubuntu-24.04'
2626
deps: 'qt6-base-dev libgtk-4-dev'
2727
- os: 'ubuntu-24.04'
@@ -34,29 +34,36 @@ jobs:
3434
features: 'gtk,webview'
3535
no_default_features: true
3636
deps: 'qt6-base-dev qt6-webengine-dev libgtk-4-dev libwebkitgtk-6.0-dev'
37+
- os: 'ubuntu-24.04'
38+
deps: 'qtbase5-dev qtmultimedia5-dev qtwebengine5-dev libgtk-4-dev libwebkitgtk-6.0-dev'
39+
features: 'all'
40+
no_default_features: true
3741
- os: 'windows-latest'
3842
target: 'x86_64-pc-windows-msvc'
3943
- os: 'windows-latest'
4044
target: 'x86_64-pc-windows-msvc'
4145
features: 'webview'
4246
- os: 'windows-latest'
4347
target: 'i686-pc-windows-msvc'
44-
features: 'media,webview,win32-dark-mode,winui-enable-cbs,winui-webview-system'
48+
features: 'all,win32-dark-mode,winui-enable-cbs,winui-webview-system'
4549
- os: 'windows-latest'
4650
target: 'x86_64-pc-windows-gnullvm'
47-
features: 'win32,media,webview'
51+
features: 'win32,all'
4852
no_default_features: true
4953
- os: 'windows-latest'
5054
target: 'x86_64-pc-windows-msvc'
5155
features: 'winui,win32-dark-mode,media'
5256
no_default_features: true
53-
- os: 'macos-13'
54-
- os: 'macos-13'
57+
- os: 'windows-latest'
58+
features: 'all'
59+
no_default_features: true
60+
- os: 'macos-14'
61+
- os: 'macos-14'
5562
features: 'media'
56-
- os: 'macos-13'
63+
- os: 'macos-14'
5764
features: 'webview'
58-
- os: 'macos-13'
59-
features: 'media,webview'
65+
- os: 'macos-14'
66+
features: 'all'
6067
steps:
6168
- uses: actions/checkout@v4
6269
- name: Setup Rust Toolchain

winio-ui-windows-common/src/darkmode/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ unsafe fn u16_string_eq_ignore_case(s1: &U16CStr, s2: *const u16) -> bool {
7474
///
7575
/// `s2` should be a valid null-terminated UTF-16 string.
7676
#[inline]
77+
#[allow(unused)]
7778
unsafe fn u16_string_starts_with_ignore_case(s1: &U16CStr, s2: *const u16) -> bool {
7879
unsafe { FindStringOrdinal(FIND_STARTSWITH, s1.as_ptr(), s1.len() as _, s2, -1, 1) >= 0 }
7980
}

winio/Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ plotters-backend = { version = "0.3", optional = true }
2727
thiserror = { workspace = true }
2828

2929
[target.'cfg(windows)'.dependencies]
30+
winio-ui-windows-common = { workspace = true }
3031
winio-ui-win32 = { workspace = true, optional = true }
3132
winio-ui-winui = { workspace = true, optional = true }
3233

@@ -37,6 +38,9 @@ winio-ui-app-kit = { workspace = true }
3738
winio-ui-gtk = { workspace = true, optional = true }
3839
winio-ui-qt = { workspace = true, optional = true }
3940

41+
[build-dependencies]
42+
cfg_aliases = "0.2"
43+
4044
[dev-dependencies]
4145
compio = { workspace = true, default-features = true, features = [
4246
"time",
@@ -93,13 +97,15 @@ raw-window-handle = ["winio-handle/raw-window-handle"]
9397

9498
gen_blocks = ["winio-elm/gen_blocks"]
9599
once_cell_try = [
100+
"winio-ui-windows-common/once_cell_try",
96101
"winio-ui-win32?/once_cell_try",
97102
"winio-ui-winui?/once_cell_try",
98103
]
99104
nightly = [
100105
"gen_blocks",
101106
"once_cell_try",
102107
"winio-elm/nightly",
108+
"winio-ui-windows-common/nightly",
103109
"winio-ui-win32?/nightly",
104110
"winio-ui-winui?/nightly",
105111
"compio/nightly",

winio/build.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
use cfg_aliases::cfg_aliases;
2+
3+
fn main() {
4+
cfg_aliases! {
5+
win32: { all(windows, feature = "win32") },
6+
winui: { all(windows, feature = "winui") },
7+
}
8+
}

winio/src/lib.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,33 +17,33 @@ pub use winio_primitive as primitive;
1717

1818
cfg_if::cfg_if! {
1919
if #[cfg(windows)] {
20-
#[cfg(any(
21-
all(not(feature = "win32"), not(feature = "winui")),
22-
all(feature = "win32", feature = "winui")
23-
))]
20+
#[cfg(all(feature = "win32", feature = "winui"))]
2421
compile_error!("You must choose only one of these features: [\"win32\", \"winui\"]");
2522

2623
cfg_if::cfg_if! {
2724
if #[cfg(feature = "winui")] {
2825
use winio_ui_winui as sys;
29-
} else {
26+
} else if #[cfg(feature = "win32")] {
3027
use winio_ui_win32 as sys;
28+
} else {
29+
mod stub;
30+
use stub as sys;
3131
}
3232
}
3333
} else if #[cfg(target_os = "macos")] {
3434
use winio_ui_app_kit as sys;
3535
} else {
36-
#[cfg(any(
37-
all(not(feature = "gtk"), not(feature = "qt")),
38-
all(feature = "gtk", feature = "qt")
39-
))]
36+
#[cfg(all(feature = "gtk", feature = "qt"))]
4037
compile_error!("You must choose only one of these features: [\"gtk\", \"qt\"]");
4138

4239
cfg_if::cfg_if! {
4340
if #[cfg(feature = "qt")] {
4441
use winio_ui_qt as sys;
45-
} else {
42+
} else if #[cfg(feature = "gtk")] {
4643
use winio_ui_gtk as sys;
44+
} else {
45+
mod stub;
46+
use stub as sys;
4747
}
4848
}
4949
}

winio/src/stub/mod.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/// A stub error type.
2+
#[derive(Debug)]
3+
pub struct Error(std::convert::Infallible);
4+
5+
impl std::fmt::Display for Error {
6+
fn fmt(&self, _f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
7+
not_impl()
8+
}
9+
}
10+
11+
impl std::error::Error for Error {}
12+
13+
/// A stub result type.
14+
pub type Result<T, E = Error> = std::result::Result<T, E>;
15+
16+
pub fn not_impl() -> ! {
17+
unimplemented!("stub implementation")
18+
}
19+
20+
mod runtime;
21+
pub use runtime::*;
22+
23+
mod ui;
24+
pub use ui::*;

winio/src/stub/runtime.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
use std::future::Future;
2+
3+
use super::{Result, not_impl};
4+
5+
pub struct Runtime;
6+
7+
impl Runtime {
8+
pub fn new() -> Result<Self> {
9+
not_impl()
10+
}
11+
12+
#[cfg(not(windows))]
13+
pub fn set_app_id(&mut self, _app_id: &str) -> Result<()> {
14+
not_impl()
15+
}
16+
17+
pub fn block_on<F: Future>(&self, _future: F) -> F::Output {
18+
not_impl()
19+
}
20+
}

winio/src/stub/ui/button.rs

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
use inherit_methods_macro::inherit_methods;
2+
use winio_handle::AsContainer;
3+
use winio_primitive::{Point, Size};
4+
5+
use crate::stub::{Result, Widget, not_impl};
6+
7+
#[derive(Debug)]
8+
pub struct Button {
9+
handle: Widget,
10+
}
11+
12+
#[inherit_methods(from = "self.handle")]
13+
impl Button {
14+
pub fn new(_parent: impl AsContainer) -> Result<Self> {
15+
not_impl()
16+
}
17+
18+
pub fn is_visible(&self) -> Result<bool>;
19+
20+
pub fn set_visible(&mut self, v: bool) -> Result<()>;
21+
22+
pub fn is_enabled(&self) -> Result<bool>;
23+
24+
pub fn set_enabled(&mut self, v: bool) -> Result<()>;
25+
26+
pub fn preferred_size(&self) -> Result<Size>;
27+
28+
pub fn loc(&self) -> Result<Point>;
29+
30+
pub fn set_loc(&mut self, p: Point) -> Result<()>;
31+
32+
pub fn size(&self) -> Result<Size>;
33+
34+
pub fn set_size(&mut self, v: Size) -> Result<()>;
35+
36+
pub fn tooltip(&self) -> Result<String>;
37+
38+
pub fn set_tooltip(&mut self, s: impl AsRef<str>) -> Result<()>;
39+
40+
pub fn text(&self) -> Result<String>;
41+
42+
pub fn set_text(&mut self, s: impl AsRef<str>) -> Result<()>;
43+
44+
pub async fn wait_click(&self) {
45+
not_impl()
46+
}
47+
}
48+
49+
winio_handle::impl_as_widget!(Button, handle);

0 commit comments

Comments
 (0)