Fix errors when compiling docs.
Feature flags that clash are no fun. This reworks a few things so that docs can properly build with all feature flags at once and note their support. Also adds a supported table to the README for ease of discovery.
This commit is contained in:
parent
93424f74c0
commit
87533d576f
41
README.md
41
README.md
|
@ -23,6 +23,11 @@ rampant for wrapped controls. This does **not** mean you can't assess, review, o
|
||||||
usage - just know it's happening, and in large part it's not going away. Issues pertaining to the mere
|
usage - just know it's happening, and in large part it's not going away. Issues pertaining to the mere
|
||||||
existence of unsafe will be closed without comment._
|
existence of unsafe will be closed without comment._
|
||||||
|
|
||||||
|
If you're looking to build the docs for this on your local machine, you'll want the following due to the way feature flags work
|
||||||
|
with `cargo doc`:
|
||||||
|
|
||||||
|
`RUSTDOCFLAGS="--cfg docsrs" cargo +nightly doc --all-features --open`
|
||||||
|
|
||||||
# Hello World
|
# Hello World
|
||||||
|
|
||||||
```rust
|
```rust
|
||||||
|
@ -62,22 +67,28 @@ ensures the application has had time to initialize and do any housekeeping neces
|
||||||
scenes.
|
scenes.
|
||||||
|
|
||||||
## Currently Supported
|
## Currently Supported
|
||||||
In terms of mostly working pieces, the following currently work. This list is not exhaustive and you're encouraged to check out the documentation for more info:
|
In terms of mostly working pieces, the table below showcases the level of support for varying features. This list is not exhaustive just by virtue of documentation updating being hell - so you're encouraged to check out the code-built documentation for more info:
|
||||||
|
|
||||||
- `App` initialization and event delegation
|
Note that while iOS has green checkmarks, some components still aren't as well defined (e.g, Views/ViewControllers are still very alpha there).
|
||||||
- `Window` construction, handling, and event delegation
|
|
||||||
- `View` construction, basic styling, some event delegation
|
Non-Apple platforms that shim or provide a form of AppKit may be able to use a good chunk of the AppKit support in this library.
|
||||||
- `ViewController` construction, lifecycle delegation
|
|
||||||
- `Color`, for handling system-established color types
|
| Component | Description | AppKit | iOS | tvOS |
|
||||||
- `ListView` support, including cell reuse (still needs testing)
|
| ------------------- | ----------------------------------- | ------ | --- | ---- |
|
||||||
- `Button` support, as well as enabling them in Toolbars
|
| App | Initialization & events | ✅ | ✅ | ❌ |
|
||||||
- `Label` and `TextField` support for basic text handling.
|
| Window | Construction, handling, events | ✅ | ✅ | ❌ |
|
||||||
- `Image`, `ImageView` and `SystemIcon` for image usage. Images can use a custom draw handler, and draw graphics with the [core_graphics]() crate
|
| View | Construction, styling, events | ✅ | ✅ | ❌ |
|
||||||
- `Toolbar` construction and basic API
|
| ViewController | Construction, lifecycle events | ✅ | ✅ | ❌ |
|
||||||
- `SplitViewController` support, including some Big-Sur-only additions
|
| Color | System-backed colors, theming | ✅ | ✅ | ❌ |
|
||||||
- `WebView` with a basic API for handling callbacks
|
| ListView | Reusable list w/ cached rows | ✅ | ❌ | ❌ |
|
||||||
- `UserDefaults` for persisting small pieces of data per-application
|
| Button | Styling, events, toolbar support | ✅ | ❌ | ❌ |
|
||||||
- `Autolayout` for View layout and such
|
| Label/TextField | Text rendering & input | ✅ | ❌ | ❌ |
|
||||||
|
| Image/ImageView | Loading, drawing, etc | ✅ | ❌ | ❌ |
|
||||||
|
| Toolbar | Basic native toolbar | ✅ | ❌ | ❌ |
|
||||||
|
| SplitViewController | Split views (Big Sur friendly) | ✅ | ❌ | ❌ |
|
||||||
|
| WebView | Wrapper for WKWebView | ✅ | ❌ | ❌ |
|
||||||
|
| UserDefaults | Persisting small data | ✅ | ✅ | ❌ |
|
||||||
|
| Autolayout | View layout for varying screens | ✅ | ✅ | ❌ |
|
||||||
|
|
||||||
## Optional Features
|
## Optional Features
|
||||||
|
|
||||||
|
|
2
build.rs
2
build.rs
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
println!("cargo:rustc-link-lib=framework=Foundation");
|
println!("cargo:rustc-link-lib=framework=Foundation");
|
||||||
|
|
||||||
#[cfg(feature = "appkit")]
|
#[cfg(feature = "appkit")]
|
||||||
println!("cargo:rustc-link-lib=framework=AppKit");
|
println!("cargo:rustc-link-lib=framework=AppKit");
|
||||||
|
|
||||||
|
|
|
@ -16,11 +16,11 @@ mod appkit;
|
||||||
#[cfg(feature = "appkit")]
|
#[cfg(feature = "appkit")]
|
||||||
use appkit::register_image_view_class;
|
use appkit::register_image_view_class;
|
||||||
|
|
||||||
#[cfg(feature = "uikit")]
|
//#[cfg(feature = "uikit")]
|
||||||
mod uikit;
|
//mod uikit;
|
||||||
|
|
||||||
#[cfg(feature = "uikit")]
|
//#[cfg(feature = "uikit")]
|
||||||
use ios::register_image_view_class;
|
//use uikit::register_image_view_class;
|
||||||
|
|
||||||
mod image;
|
mod image;
|
||||||
pub use image::{Image, DrawConfig, ResizeBehavior};
|
pub use image::{Image, DrawConfig, ResizeBehavior};
|
||||||
|
|
|
@ -59,11 +59,11 @@ mod appkit;
|
||||||
#[cfg(feature = "appkit")]
|
#[cfg(feature = "appkit")]
|
||||||
use appkit::{register_view_class, register_view_class_with_delegate};
|
use appkit::{register_view_class, register_view_class_with_delegate};
|
||||||
|
|
||||||
#[cfg(feature = "uikit")]
|
//#[cfg(feature = "uikit")]
|
||||||
mod uikit;
|
//mod uikit;
|
||||||
|
|
||||||
#[cfg(feature = "uikit")]
|
//#[cfg(feature = "uikit")]
|
||||||
use uikit::{register_view_class, register_view_class_with_delegate};
|
//use uikit::{register_view_class, register_view_class_with_delegate};
|
||||||
|
|
||||||
mod traits;
|
mod traits;
|
||||||
pub use traits::TextFieldDelegate;
|
pub use traits::TextFieldDelegate;
|
||||||
|
|
13
src/lib.rs
13
src/lib.rs
|
@ -61,7 +61,6 @@
|
||||||
//!
|
//!
|
||||||
//! - `appkit`: Implements appkit-specific APIs (menus, toolbars, windowing, and so on).
|
//! - `appkit`: Implements appkit-specific APIs (menus, toolbars, windowing, and so on).
|
||||||
//! - `uikit`: Implements uikit-specific APIs (scenes, navigation controllers, and so on).
|
//! - `uikit`: Implements uikit-specific APIs (scenes, navigation controllers, and so on).
|
||||||
//! - `tvos`: Implements tvOS-specific APIs. Currently not actually implemented.
|
|
||||||
//!
|
//!
|
||||||
//! The rest of the features in this framework attempt to expose a common API across the three
|
//! The rest of the features in this framework attempt to expose a common API across the three
|
||||||
//! aforementioned feature platforms; if you need something else, you can often implement it
|
//! aforementioned feature platforms; if you need something else, you can often implement it
|
||||||
|
@ -72,6 +71,8 @@
|
||||||
//!
|
//!
|
||||||
//! The following are a list of [Cargo features][cargo-features] that can be enabled or disabled.
|
//! The following are a list of [Cargo features][cargo-features] that can be enabled or disabled.
|
||||||
//!
|
//!
|
||||||
|
//! - `autolayout`: Enables the use of AutoLayout across all widget types. This is a default
|
||||||
|
//! feature, but is gated to enable platforms that might shim AppKit without AutoLayout support.
|
||||||
//! - `cloudkit`: Links `CloudKit.framework` and provides some wrappers around CloudKit
|
//! - `cloudkit`: Links `CloudKit.framework` and provides some wrappers around CloudKit
|
||||||
//! functionality. Currently not feature complete.
|
//! functionality. Currently not feature complete.
|
||||||
//! - `color_fallbacks`: Provides fallback colors for older systems where `systemColor` types don't
|
//! - `color_fallbacks`: Provides fallback colors for older systems where `systemColor` types don't
|
||||||
|
@ -83,7 +84,7 @@
|
||||||
//! code-signed, and will not work without it.
|
//! code-signed, and will not work without it.
|
||||||
//! - `webview`: Links `WebKit.framework` and provides a `WebView` control backed by `WKWebView`.
|
//! - `webview`: Links `WebKit.framework` and provides a `WebView` control backed by `WKWebView`.
|
||||||
//! This feature will not be supported on tvOS, as the platform has no webview control.
|
//! This feature will not be supported on tvOS, as the platform has no webview control.
|
||||||
//! - `webview-downloading-appkit`: Enables downloading files from the `WebView` via a private
|
//! - `webview-downloading-macos`: Enables downloading files from the `WebView` via a private
|
||||||
//! interface. This is not an App-Store-safe feature, so be aware of that before enabling. This
|
//! interface. This is not an App-Store-safe feature, so be aware of that before enabling. This
|
||||||
//! feature is not supported on uikit (a user would handle downloads very differently) or tvOS
|
//! feature is not supported on uikit (a user would handle downloads very differently) or tvOS
|
||||||
//! (there's no web browser there at all).
|
//! (there's no web browser there at all).
|
||||||
|
@ -96,15 +97,15 @@ pub use objc;
|
||||||
pub use url;
|
pub use url;
|
||||||
pub use lazy_static;
|
pub use lazy_static;
|
||||||
|
|
||||||
#[cfg(all(feature = "appkit", feature = "uikit", not(feature = "no-intrinsics")))]
|
//#[cfg(all(feature = "appkit", feature = "uikit", not(feature = "doc_cfg")))]
|
||||||
compile_error!("The \"appkit\" and \"uikit\" features cannot be enabled together. Pick one. :)");
|
//compile_error!("The \"appkit\" and \"uikit\" features cannot be enabled together. Pick one. :)");
|
||||||
|
|
||||||
#[cfg(feature = "appkit")]
|
#[cfg(feature = "appkit")]
|
||||||
#[cfg_attr(docsrs, doc(cfg(target_os = "appkit")))]
|
#[cfg_attr(docsrs, doc(cfg(feature = "appkit")))]
|
||||||
pub mod appkit;
|
pub mod appkit;
|
||||||
|
|
||||||
#[cfg(feature = "uikit")]
|
#[cfg(feature = "uikit")]
|
||||||
#[cfg_attr(docsrs, doc(cfg(target_os = "uikit")))]
|
#[cfg_attr(docsrs, doc(cfg(feature = "uikit")))]
|
||||||
pub mod uikit;
|
pub mod uikit;
|
||||||
|
|
||||||
#[cfg(feature = "appkit")]
|
#[cfg(feature = "appkit")]
|
||||||
|
|
|
@ -61,11 +61,11 @@ mod appkit;
|
||||||
#[cfg(feature = "appkit")]
|
#[cfg(feature = "appkit")]
|
||||||
use appkit::{register_scrollview_class, register_scrollview_class_with_delegate};
|
use appkit::{register_scrollview_class, register_scrollview_class_with_delegate};
|
||||||
|
|
||||||
#[cfg(feature = "uikit")]
|
//#[cfg(feature = "uikit")]
|
||||||
mod ios;
|
//mod ios;
|
||||||
|
|
||||||
#[cfg(feature = "uikit")]
|
//#[cfg(feature = "uikit")]
|
||||||
use ios::{register_view_class, register_view_class_with_delegate};
|
//use ios::{register_view_class, register_view_class_with_delegate};
|
||||||
|
|
||||||
mod traits;
|
mod traits;
|
||||||
pub use traits::ScrollViewDelegate;
|
pub use traits::ScrollViewDelegate;
|
||||||
|
|
|
@ -59,11 +59,11 @@ mod appkit;
|
||||||
#[cfg(feature = "appkit")]
|
#[cfg(feature = "appkit")]
|
||||||
use appkit::{register_view_class, register_view_class_with_delegate};
|
use appkit::{register_view_class, register_view_class_with_delegate};
|
||||||
|
|
||||||
#[cfg(feature = "uikit")]
|
//#[cfg(feature = "uikit")]
|
||||||
mod uikit;
|
//mod uikit;
|
||||||
|
|
||||||
#[cfg(feature = "uikit")]
|
//#[cfg(feature = "uikit")]
|
||||||
use uikit::{register_view_class, register_view_class_with_delegate};
|
//use uikit::{register_view_class, register_view_class_with_delegate};
|
||||||
|
|
||||||
mod traits;
|
mod traits;
|
||||||
pub use traits::LabelDelegate;
|
pub use traits::LabelDelegate;
|
||||||
|
|
|
@ -7,17 +7,9 @@ use crate::layout::Layout;
|
||||||
use crate::view::{VIEW_DELEGATE_PTR, View, ViewDelegate};
|
use crate::view::{VIEW_DELEGATE_PTR, View, ViewDelegate};
|
||||||
use crate::utils::Controller;
|
use crate::utils::Controller;
|
||||||
|
|
||||||
#[cfg(feature = "appkit")]
|
#[cfg_attr(feature = "appkit", path = "appkit.rs")]
|
||||||
mod appkit;
|
#[cfg_attr(feature = "uikit", path = "uikit.rs")]
|
||||||
|
mod native_interface;
|
||||||
#[cfg(feature = "appkit")]
|
|
||||||
use appkit::register_view_controller_class;
|
|
||||||
|
|
||||||
#[cfg(feature = "uikit")]
|
|
||||||
mod uikit;
|
|
||||||
|
|
||||||
#[cfg(feature = "uikit")]
|
|
||||||
use uikit::register_view_controller_class;
|
|
||||||
|
|
||||||
/// A `ViewController` is a wrapper around `NSViewController` in AppKit, and `UIViewController` in
|
/// A `ViewController` is a wrapper around `NSViewController` in AppKit, and `UIViewController` in
|
||||||
/// UIKit
|
/// UIKit
|
||||||
|
@ -52,7 +44,7 @@ where
|
||||||
{
|
{
|
||||||
/// Creates and returns a new `ViewController` with the provided `delegate`.
|
/// Creates and returns a new `ViewController` with the provided `delegate`.
|
||||||
pub fn new(delegate: T) -> Self {
|
pub fn new(delegate: T) -> Self {
|
||||||
let class = register_view_controller_class::<T>(&delegate);
|
let class = native_interface::register_view_controller_class::<T>(&delegate);
|
||||||
let view = View::with(delegate);
|
let view = View::with(delegate);
|
||||||
|
|
||||||
let objc = unsafe {
|
let objc = unsafe {
|
||||||
|
|
|
@ -56,17 +56,9 @@ use crate::layout::{LayoutAnchorX, LayoutAnchorY, LayoutAnchorDimension};
|
||||||
#[cfg(feature = "appkit")]
|
#[cfg(feature = "appkit")]
|
||||||
use crate::pasteboard::PasteboardType;
|
use crate::pasteboard::PasteboardType;
|
||||||
|
|
||||||
#[cfg(feature = "appkit")]
|
#[cfg_attr(feature = "appkit", path = "appkit.rs")]
|
||||||
mod appkit;
|
#[cfg_attr(feature = "uikit", path = "uikit.rs")]
|
||||||
|
mod native_interface;
|
||||||
#[cfg(feature = "appkit")]
|
|
||||||
use appkit::{register_view_class, register_view_class_with_delegate};
|
|
||||||
|
|
||||||
#[cfg(feature = "uikit")]
|
|
||||||
mod uikit;
|
|
||||||
|
|
||||||
#[cfg(feature = "uikit")]
|
|
||||||
use uikit::{register_view_class, register_view_class_with_delegate};
|
|
||||||
|
|
||||||
mod controller;
|
mod controller;
|
||||||
pub use controller::ViewController;
|
pub use controller::ViewController;
|
||||||
|
@ -211,7 +203,7 @@ impl View {
|
||||||
/// Returns a default `View`, suitable for customizing and displaying.
|
/// Returns a default `View`, suitable for customizing and displaying.
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
View::init(unsafe {
|
View::init(unsafe {
|
||||||
msg_send![register_view_class(), new]
|
msg_send![native_interface::register_view_class(), new]
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -220,7 +212,7 @@ impl<T> View<T> where T: ViewDelegate + 'static {
|
||||||
/// Initializes a new View with a given `ViewDelegate`. This enables you to respond to events
|
/// Initializes a new View with a given `ViewDelegate`. This enables you to respond to events
|
||||||
/// and customize the view as a module, similar to class-based systems.
|
/// and customize the view as a module, similar to class-based systems.
|
||||||
pub fn with(delegate: T) -> View<T> {
|
pub fn with(delegate: T) -> View<T> {
|
||||||
let class = register_view_class_with_delegate(&delegate);
|
let class = native_interface::register_view_class_with_delegate(&delegate);
|
||||||
let mut delegate = Box::new(delegate);
|
let mut delegate = Box::new(delegate);
|
||||||
|
|
||||||
let view = unsafe {
|
let view = unsafe {
|
||||||
|
|
|
@ -26,7 +26,7 @@ use crate::layer::Layer;
|
||||||
use crate::utils::properties::ObjcProperty;
|
use crate::utils::properties::ObjcProperty;
|
||||||
|
|
||||||
#[cfg(feature = "autolayout")]
|
#[cfg(feature = "autolayout")]
|
||||||
use crate::layout::LayoutAnchorX, LayoutAnchorY, LayoutAnchorDimension};
|
use crate::layout::{LayoutAnchorX, LayoutAnchorY, LayoutAnchorDimension};
|
||||||
|
|
||||||
mod actions;
|
mod actions;
|
||||||
pub use actions::*;
|
pub use actions::*;
|
||||||
|
|
Loading…
Reference in a new issue