fix cargo test
This commit is contained in:
parent
fb9d456a5d
commit
8bffc30ac1
|
@ -2,6 +2,7 @@
|
||||||
//! work with autolayout, and some basic ways to handle colors.
|
//! work with autolayout, and some basic ways to handle colors.
|
||||||
|
|
||||||
use cacao::notification_center::Dispatcher;
|
use cacao::notification_center::Dispatcher;
|
||||||
|
#[cfg(feature = "webview")]
|
||||||
use cacao::webview::{WebView, WebViewConfig, WebViewDelegate};
|
use cacao::webview::{WebView, WebViewConfig, WebViewDelegate};
|
||||||
|
|
||||||
use cacao::appkit::menu::{Menu, MenuItem};
|
use cacao::appkit::menu::{Menu, MenuItem};
|
||||||
|
@ -72,6 +73,8 @@ impl Dispatcher for BasicApp {
|
||||||
|
|
||||||
fn on_ui_message(&self, message: Self::Message) {
|
fn on_ui_message(&self, message: Self::Message) {
|
||||||
let window = self.window.delegate.as_ref().unwrap();
|
let window = self.window.delegate.as_ref().unwrap();
|
||||||
|
#[cfg(feature = "webview")]
|
||||||
|
{
|
||||||
let webview = &window.content;
|
let webview = &window.content;
|
||||||
|
|
||||||
match message {
|
match message {
|
||||||
|
@ -87,14 +90,17 @@ impl Dispatcher for BasicApp {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct WebViewInstance;
|
pub struct WebViewInstance;
|
||||||
|
|
||||||
|
#[cfg(feature = "webview")]
|
||||||
impl WebViewDelegate for WebViewInstance {}
|
impl WebViewDelegate for WebViewInstance {}
|
||||||
|
|
||||||
struct AppWindow {
|
struct AppWindow {
|
||||||
toolbar: Toolbar<BrowserToolbar>,
|
toolbar: Toolbar<BrowserToolbar>,
|
||||||
|
#[cfg(feature = "webview")]
|
||||||
content: WebView<WebViewInstance>
|
content: WebView<WebViewInstance>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,12 +108,14 @@ impl AppWindow {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
AppWindow {
|
AppWindow {
|
||||||
toolbar: Toolbar::new("com.example.BrowserToolbar", BrowserToolbar::new()),
|
toolbar: Toolbar::new("com.example.BrowserToolbar", BrowserToolbar::new()),
|
||||||
|
#[cfg(feature = "webview")]
|
||||||
content: WebView::with(WebViewConfig::default(), WebViewInstance::default())
|
content: WebView::with(WebViewConfig::default(), WebViewInstance::default())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn load_url(&self, url: &str) {
|
pub fn load_url(&self, url: &str) {
|
||||||
self.toolbar.delegate.as_ref().unwrap().set_url(url);
|
self.toolbar.delegate.as_ref().unwrap().set_url(url);
|
||||||
|
#[cfg(feature = "webview")]
|
||||||
self.content.load_url(url);
|
self.content.load_url(url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -121,6 +129,7 @@ impl WindowDelegate for AppWindow {
|
||||||
window.set_minimum_content_size(400., 400.);
|
window.set_minimum_content_size(400., 400.);
|
||||||
|
|
||||||
window.set_toolbar(&self.toolbar);
|
window.set_toolbar(&self.toolbar);
|
||||||
|
#[cfg(feature = "webview")]
|
||||||
window.set_content_view(&self.content);
|
window.set_content_view(&self.content);
|
||||||
|
|
||||||
self.load_url("https://www.duckduckgo.com/");
|
self.load_url("https://www.duckduckgo.com/");
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
use std::sync::RwLock;
|
use std::sync::RwLock;
|
||||||
|
|
||||||
|
#[cfg(targe_os = "ios")]
|
||||||
use cacao::uikit::{App, AppDelegate, Scene, SceneConfig, SceneConnectionOptions, SceneSession, Window, WindowSceneDelegate};
|
use cacao::uikit::{App, AppDelegate, Scene, SceneConfig, SceneConnectionOptions, SceneSession, Window, WindowSceneDelegate};
|
||||||
|
|
||||||
use cacao::color::Color;
|
use cacao::color::Color;
|
||||||
|
@ -9,6 +10,7 @@ use cacao::view::{View, ViewController, ViewDelegate};
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
struct TestApp;
|
struct TestApp;
|
||||||
|
|
||||||
|
#[cfg(target_os= "ios")]
|
||||||
impl AppDelegate for TestApp {
|
impl AppDelegate for TestApp {
|
||||||
fn config_for_scene_session(&self, session: SceneSession, _options: SceneConnectionOptions) -> SceneConfig {
|
fn config_for_scene_session(&self, session: SceneSession, _options: SceneConnectionOptions) -> SceneConfig {
|
||||||
SceneConfig::new("Default Configuration", session.role())
|
SceneConfig::new("Default Configuration", session.role())
|
||||||
|
@ -55,10 +57,12 @@ impl ViewDelegate for RootView {
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct WindowScene {
|
pub struct WindowScene {
|
||||||
|
#[cfg(target_os= "ios")]
|
||||||
pub window: RwLock<Option<Window>>,
|
pub window: RwLock<Option<Window>>,
|
||||||
pub root_view_controller: RwLock<Option<ViewController<RootView>>>
|
pub root_view_controller: RwLock<Option<ViewController<RootView>>>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(target_os= "ios")]
|
||||||
impl WindowSceneDelegate for WindowScene {
|
impl WindowSceneDelegate for WindowScene {
|
||||||
fn will_connect(&self, scene: Scene, session: SceneSession, options: SceneConnectionOptions) {
|
fn will_connect(&self, scene: Scene, session: SceneSession, options: SceneConnectionOptions) {
|
||||||
let bounds = scene.get_bounds();
|
let bounds = scene.get_bounds();
|
||||||
|
@ -80,5 +84,6 @@ impl WindowSceneDelegate for WindowScene {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
#[cfg(target_os= "ios")]
|
||||||
App::new(TestApp::default(), || Box::new(WindowScene::default())).run();
|
App::new(TestApp::default(), || Box::new(WindowScene::default())).run();
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@ use cacao::appkit::toolbar::Toolbar;
|
||||||
use cacao::appkit::window::{Window, WindowConfig, WindowDelegate, WindowToolbarStyle};
|
use cacao::appkit::window::{Window, WindowConfig, WindowDelegate, WindowToolbarStyle};
|
||||||
use cacao::appkit::{App, AppDelegate};
|
use cacao::appkit::{App, AppDelegate};
|
||||||
|
|
||||||
|
#[cfg(feature = "webview")]
|
||||||
use cacao::webview::{WebView, WebViewConfig, WebViewDelegate};
|
use cacao::webview::{WebView, WebViewConfig, WebViewDelegate};
|
||||||
|
|
||||||
struct BasicApp {
|
struct BasicApp {
|
||||||
|
@ -22,6 +23,7 @@ impl AppDelegate for BasicApp {
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct WebViewInstance;
|
pub struct WebViewInstance;
|
||||||
|
|
||||||
|
#[cfg(feature = "webview")]
|
||||||
impl WebViewDelegate for WebViewInstance {
|
impl WebViewDelegate for WebViewInstance {
|
||||||
fn on_custom_protocol_request(&self, path: &str) -> Option<Vec<u8>> {
|
fn on_custom_protocol_request(&self, path: &str) -> Option<Vec<u8>> {
|
||||||
let requested_asset_path = path.replace("cacao://", "");
|
let requested_asset_path = path.replace("cacao://", "");
|
||||||
|
@ -62,9 +64,11 @@ impl WebViewDelegate for WebViewInstance {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct AppWindow {
|
struct AppWindow {
|
||||||
|
#[cfg(feature = "webview")]
|
||||||
content: WebView<WebViewInstance>
|
content: WebView<WebViewInstance>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "webview")]
|
||||||
impl AppWindow {
|
impl AppWindow {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
let mut webview_config = WebViewConfig::default();
|
let mut webview_config = WebViewConfig::default();
|
||||||
|
@ -82,6 +86,7 @@ impl AppWindow {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "webview")]
|
||||||
impl WindowDelegate for AppWindow {
|
impl WindowDelegate for AppWindow {
|
||||||
const NAME: &'static str = "WindowDelegate";
|
const NAME: &'static str = "WindowDelegate";
|
||||||
|
|
||||||
|
@ -97,9 +102,12 @@ impl WindowDelegate for AppWindow {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "webview")]
|
||||||
fn main() {
|
fn main() {
|
||||||
App::new("com.test.window", BasicApp {
|
App::new("com.test.window", BasicApp {
|
||||||
window: Window::with(WindowConfig::default(), AppWindow::new())
|
window: Window::with(WindowConfig::default(), AppWindow::new())
|
||||||
})
|
})
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
#[cfg(not(feature = "webview"))]
|
||||||
|
fn main() {}
|
||||||
|
|
|
@ -7,13 +7,13 @@
|
||||||
//! If you want to show a complex view in an alert-esque fashion, you may consider looking at
|
//! If you want to show a complex view in an alert-esque fashion, you may consider looking at
|
||||||
//! `Sheet`.
|
//! `Sheet`.
|
||||||
//!
|
//!
|
||||||
//! ```rust
|
//! ```rust,no_run
|
||||||
//! use cacao::appkit::{App, AppDelegate, Alert};
|
//! use cacao::appkit::{App, AppDelegate, Alert};
|
||||||
//!
|
//!
|
||||||
//! #[derive(Default)]
|
//! #[derive(Default)]
|
||||||
//! struct ExampleApp;
|
//! struct ExampleApp;
|
||||||
//!
|
//!
|
||||||
//! impl AppDelegate {
|
//! impl AppDelegate for ExampleApp {
|
||||||
//! fn did_finish_launching(&self) {
|
//! fn did_finish_launching(&self) {
|
||||||
//!
|
//!
|
||||||
//! }
|
//! }
|
||||||
|
|
|
@ -4,8 +4,8 @@
|
||||||
//! heavily by lifecycle events - in this case, your boilerplate would look something like this:
|
//! heavily by lifecycle events - in this case, your boilerplate would look something like this:
|
||||||
//!
|
//!
|
||||||
//! ```rust,no_run
|
//! ```rust,no_run
|
||||||
//! use cacao::app::{App, AppDelegate};
|
//! use cacao::appkit::{App, AppDelegate};
|
||||||
//! use cacao::window::Window;
|
//! use cacao::appkit::window::Window;
|
||||||
//!
|
//!
|
||||||
//! #[derive(Default)]
|
//! #[derive(Default)]
|
||||||
//! struct BasicApp;
|
//! struct BasicApp;
|
||||||
|
|
|
@ -77,7 +77,14 @@ pub enum CursorType {
|
||||||
/// For a very abbreviated example:
|
/// For a very abbreviated example:
|
||||||
///
|
///
|
||||||
/// ```rust,no_run
|
/// ```rust,no_run
|
||||||
|
/// use cacao::appkit::Cursor;
|
||||||
|
/// use cacao::appkit::CursorType;
|
||||||
|
/// use cacao::dragdrop::DragInfo;
|
||||||
|
/// use cacao::dragdrop::DragOperation;
|
||||||
|
/// use cacao::view::ViewDelegate;
|
||||||
|
/// struct MyView;
|
||||||
/// impl ViewDelegate for MyView {
|
/// impl ViewDelegate for MyView {
|
||||||
|
/// const NAME: &'static str = "RootView";
|
||||||
/// fn dragging_entered(&self, _info: DragInfo) -> DragOperation {
|
/// fn dragging_entered(&self, _info: DragInfo) -> DragOperation {
|
||||||
/// Cursor::push(CursorType::DragCopy);
|
/// Cursor::push(CursorType::DragCopy);
|
||||||
/// DragOperation::Copy
|
/// DragOperation::Copy
|
||||||
|
|
|
@ -66,8 +66,9 @@ pub enum ItemIdentifier {
|
||||||
///
|
///
|
||||||
/// For example:
|
/// For example:
|
||||||
///
|
///
|
||||||
/// ``` rust
|
/// ``` rust,no_run
|
||||||
/// vec![ItemIdentifier::ToggleSidebar, ItemIdentifier::SidebarTracker, ItemIdentifier::Print]
|
/// use cacao::appkit::toolbar::ItemIdentifier;
|
||||||
|
/// vec![ItemIdentifier::ToggleSidebar, ItemIdentifier::SidebarTracker, ItemIdentifier::Print];
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// Would result in the toggle sidebar item showing up in the sidebar on the left, and the
|
/// Would result in the toggle sidebar item showing up in the sidebar on the left, and the
|
||||||
|
|
|
@ -12,13 +12,14 @@
|
||||||
//! # How to use
|
//! # How to use
|
||||||
//!
|
//!
|
||||||
//! ```rust,no_run
|
//! ```rust,no_run
|
||||||
//! use cacao::appkit::app::AppDelegate;
|
//! use cacao::appkit::AppDelegate;
|
||||||
//! use cacao::appkit::window::{WindowController, WindowDelegate};
|
//! use cacao::appkit::window::{WindowController, WindowDelegate};
|
||||||
//!
|
//!
|
||||||
//! #[derive(Default)]
|
//! #[derive(Default)]
|
||||||
//! struct MyWindow;
|
//! struct MyWindow;
|
||||||
//!
|
//!
|
||||||
//! impl WindowDelegate for MyWindow {
|
//! impl WindowDelegate for MyWindow {
|
||||||
|
//! const NAME: &'static str = "RootView";
|
||||||
//! // Your implementation here...
|
//! // Your implementation here...
|
||||||
//! }
|
//! }
|
||||||
//!
|
//!
|
||||||
|
|
|
@ -6,12 +6,16 @@
|
||||||
//! Some properties are platform-specific; see the documentation for further information.
|
//! Some properties are platform-specific; see the documentation for further information.
|
||||||
//!
|
//!
|
||||||
//! ```rust,no_run
|
//! ```rust,no_run
|
||||||
|
//! use cacao::button::Button;
|
||||||
|
//! use cacao::view::View;
|
||||||
|
//! use crate::cacao::layout::Layout;
|
||||||
//! let mut button = Button::new("My button title");
|
//! let mut button = Button::new("My button title");
|
||||||
//! button.set_text_equivalent("c");
|
//! button.set_key_equivalent("c");
|
||||||
//!
|
//!
|
||||||
//! button.set_action(|| {
|
//! button.set_action(|| {
|
||||||
//! println!("My button was clicked.");
|
//! println!("My button was clicked.");
|
||||||
//! });
|
//! });
|
||||||
|
//! let my_view : View<()> = todo!();
|
||||||
//!
|
//!
|
||||||
//! // Make sure you don't let your Button drop for as long as you need it.
|
//! // Make sure you don't let your Button drop for as long as you need it.
|
||||||
//! my_view.add_subview(&button);
|
//! my_view.add_subview(&button);
|
||||||
|
@ -56,12 +60,16 @@ pub use enums::*;
|
||||||
/// Some properties are platform-specific; see the documentation for further information.
|
/// Some properties are platform-specific; see the documentation for further information.
|
||||||
///
|
///
|
||||||
/// ```rust,no_run
|
/// ```rust,no_run
|
||||||
|
/// use cacao::button::Button;
|
||||||
|
/// use cacao::view::View;
|
||||||
|
/// use crate::cacao::layout::Layout;
|
||||||
/// let mut button = Button::new("My button title");
|
/// let mut button = Button::new("My button title");
|
||||||
/// button.set_text_equivalent("c");
|
/// button.set_key_equivalent("c");
|
||||||
///
|
///
|
||||||
/// button.set_action(|| {
|
/// button.set_action(|| {
|
||||||
/// println!("My button was clicked.");
|
/// println!("My button was clicked.");
|
||||||
/// });
|
/// });
|
||||||
|
/// let my_view : View<()> = todo!();
|
||||||
///
|
///
|
||||||
/// // Make sure you don't let your Button drop for as long as you need it.
|
/// // Make sure you don't let your Button drop for as long as you need it.
|
||||||
/// my_view.add_subview(&button);
|
/// my_view.add_subview(&button);
|
||||||
|
|
|
@ -246,18 +246,16 @@ impl Color {
|
||||||
let g = green as CGFloat / 255.0;
|
let g = green as CGFloat / 255.0;
|
||||||
let b = blue as CGFloat / 255.0;
|
let b = blue as CGFloat / 255.0;
|
||||||
let a = alpha as CGFloat / 255.0;
|
let a = alpha as CGFloat / 255.0;
|
||||||
|
|
||||||
Color::Custom(Arc::new(RwLock::new(unsafe {
|
|
||||||
#[cfg(feature = "appkit")]
|
#[cfg(feature = "appkit")]
|
||||||
{
|
let ptr = unsafe {
|
||||||
Id::from_ptr(msg_send![class!(NSColor), colorWithCalibratedRed:r green:g blue:b alpha:a])
|
Id::from_ptr(msg_send![class!(NSColor), colorWithCalibratedRed:r green:g blue:b alpha:a])
|
||||||
}
|
};
|
||||||
|
#[cfg(all(feature = "uikit", not(feature = "appkit")))]
|
||||||
#[cfg(feature = "uikit")]
|
let ptr = unsafe {
|
||||||
{
|
|
||||||
Id::from_ptr(msg_send![class!(UIColor), colorWithRed:r green:g blue:b alpha:a])
|
Id::from_ptr(msg_send![class!(UIColor), colorWithRed:r green:g blue:b alpha:a])
|
||||||
}
|
};
|
||||||
})))
|
|
||||||
|
Color::Custom(Arc::new(RwLock::new(ptr)))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates and returns a color in the RGB space, with the alpha level
|
/// Creates and returns a color in the RGB space, with the alpha level
|
||||||
|
@ -280,7 +278,7 @@ impl Color {
|
||||||
Id::from_ptr(msg_send![class!(NSColor), colorWithCalibratedHue:h saturation:s brightness:b alpha:a])
|
Id::from_ptr(msg_send![class!(NSColor), colorWithCalibratedHue:h saturation:s brightness:b alpha:a])
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "uikit")]
|
#[cfg(all(feature = "uikit", not(feature = "appkit")))]
|
||||||
{
|
{
|
||||||
Id::from_ptr(msg_send![class!(UIColor), colorWithHue:h saturation:s brightness:b alpha:a])
|
Id::from_ptr(msg_send![class!(UIColor), colorWithHue:h saturation:s brightness:b alpha:a])
|
||||||
}
|
}
|
||||||
|
@ -302,7 +300,7 @@ impl Color {
|
||||||
Id::from_ptr(msg_send![class!(NSColor), colorWithCalibratedWhite:level alpha:alpha])
|
Id::from_ptr(msg_send![class!(NSColor), colorWithCalibratedWhite:level alpha:alpha])
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "uikit")]
|
#[cfg(all(feature = "uikit", not(feature = "appkit")))]
|
||||||
{
|
{
|
||||||
Id::from_ptr(msg_send![class!(UIColor), colorWithWhite:level alpha:alpha])
|
Id::from_ptr(msg_send![class!(UIColor), colorWithWhite:level alpha:alpha])
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,12 +22,13 @@
|
||||||
//! let mut defaults = UserDefaults::standard();
|
//! let mut defaults = UserDefaults::standard();
|
||||||
//!
|
//!
|
||||||
//! defaults.register({
|
//! defaults.register({
|
||||||
//! let map = HashMap::new();
|
//! let mut map = HashMap::new();
|
||||||
//! map.insert("test", Value::string("value"));
|
//! map.insert("test", Value::string("value"));
|
||||||
//! map
|
//! map
|
||||||
//! });
|
//! });
|
||||||
//!
|
//!
|
||||||
//! let value = defaults.get("test").unwrap().as_str().unwrap();
|
//! let value = defaults.get("test").unwrap();
|
||||||
|
//! let value = value.as_str().unwrap();
|
||||||
//! assert_eq!(value, "value");
|
//! assert_eq!(value, "value");
|
||||||
//! ```
|
//! ```
|
||||||
|
|
||||||
|
@ -160,13 +161,14 @@ impl UserDefaults {
|
||||||
/// Note that this also returns owned values, not references. `NSUserDefaults` explicitly
|
/// Note that this also returns owned values, not references. `NSUserDefaults` explicitly
|
||||||
/// returns new immutable copies each time, so we're free to vend them as such.
|
/// returns new immutable copies each time, so we're free to vend them as such.
|
||||||
///
|
///
|
||||||
/// ```rust
|
/// ```rust,no_run
|
||||||
/// use cacao::defaults::{UserDefaults, Value};
|
/// use cacao::defaults::{UserDefaults, Value};
|
||||||
///
|
///
|
||||||
/// let mut defaults = UserDefaults::standard();
|
/// let mut defaults = UserDefaults::standard();
|
||||||
/// defaults.insert("test", Value::string("value"));
|
/// defaults.insert("test", Value::string("value"));
|
||||||
///
|
///
|
||||||
/// let value = defaults.get("test").unwrap().as_str().unwrap();
|
/// let value = defaults.get("test").unwrap();
|
||||||
|
/// let value = value.as_str().unwrap();
|
||||||
/// assert_eq!(value, "value");
|
/// assert_eq!(value, "value");
|
||||||
/// ```
|
/// ```
|
||||||
pub fn get<K: AsRef<str>>(&self, key: K) -> Option<Value> {
|
pub fn get<K: AsRef<str>>(&self, key: K) -> Option<Value> {
|
||||||
|
|
|
@ -15,7 +15,7 @@ lazy_static! {
|
||||||
/// constantly calling into the runtime, we store pointers to Class types here after first lookup
|
/// constantly calling into the runtime, we store pointers to Class types here after first lookup
|
||||||
/// and/or creation. The general store format is (roughly speaking) as follows:
|
/// and/or creation. The general store format is (roughly speaking) as follows:
|
||||||
///
|
///
|
||||||
/// ```no_run
|
/// ```ignore
|
||||||
/// {
|
/// {
|
||||||
/// "subclass_type": {
|
/// "subclass_type": {
|
||||||
/// "superclass_type": *const Class as usize
|
/// "superclass_type": *const Class as usize
|
||||||
|
|
|
@ -5,24 +5,27 @@
|
||||||
//! TextFields implement Autolayout, which enable you to specify how things should appear on the screen.
|
//! TextFields implement Autolayout, which enable you to specify how things should appear on the screen.
|
||||||
//!
|
//!
|
||||||
//! ```rust,no_run
|
//! ```rust,no_run
|
||||||
//! use cacao::color::rgb;
|
//! use cacao::color::Color;
|
||||||
//! use cacao::layout::{Layout, LayoutConstraint};
|
//! use cacao::layout::{Layout, LayoutConstraint};
|
||||||
//! use cacao::view::TextField;
|
//! use cacao::input::TextField;
|
||||||
//! use cacao::window::{Window, WindowDelegate};
|
//! use cacao::view::View;
|
||||||
|
//! use cacao::appkit::window::{Window, WindowDelegate};
|
||||||
//!
|
//!
|
||||||
//! #[derive(Default)]
|
//! #[derive(Default)]
|
||||||
//! struct AppWindow {
|
//! struct AppWindow {
|
||||||
//! content: TextField,
|
//! content: TextField,
|
||||||
//! label: TextField,
|
//! label: TextField,
|
||||||
|
//! red: View,
|
||||||
//! window: Window
|
//! window: Window
|
||||||
//! }
|
//! }
|
||||||
//!
|
//!
|
||||||
//! impl WindowDelegate for AppWindow {
|
//! impl WindowDelegate for AppWindow {
|
||||||
|
//! const NAME: &'static str = "RootView";
|
||||||
//! fn did_load(&mut self, window: Window) {
|
//! fn did_load(&mut self, window: Window) {
|
||||||
//! window.set_minimum_content_size(300., 300.);
|
//! window.set_minimum_content_size(300., 300.);
|
||||||
//! self.window = window;
|
//! self.window = window;
|
||||||
//!
|
//!
|
||||||
//! self.label.set_background_color(rgb(224, 82, 99));
|
//! self.label.set_background_color(Color::rgb(224, 82, 99));
|
||||||
//! self.label.set_text("LOL");
|
//! self.label.set_text("LOL");
|
||||||
//! self.content.add_subview(&self.red);
|
//! self.content.add_subview(&self.red);
|
||||||
//!
|
//!
|
||||||
|
|
|
@ -5,6 +5,8 @@
|
||||||
//!
|
//!
|
||||||
//! ```rust,no_run
|
//! ```rust,no_run
|
||||||
//! // Create a rounded red box
|
//! // Create a rounded red box
|
||||||
|
//! use cacao::view::View;
|
||||||
|
//! use cacao::color::Color;
|
||||||
//! let view = View::default();
|
//! let view = View::default();
|
||||||
//! view.set_background_color(Color::SystemRed);
|
//! view.set_background_color(Color::SystemRed);
|
||||||
//! view.layer.set_corner_radius(4.0);
|
//! view.layer.set_corner_radius(4.0);
|
||||||
|
@ -24,6 +26,8 @@ use crate::utils::properties::ObjcProperty;
|
||||||
///
|
///
|
||||||
/// ```rust,no_run
|
/// ```rust,no_run
|
||||||
/// // Create a rounded red box
|
/// // Create a rounded red box
|
||||||
|
/// use cacao::view::View;
|
||||||
|
/// use cacao::color::Color;
|
||||||
/// let view = View::default();
|
/// let view = View::default();
|
||||||
/// view.set_background_color(Color::SystemRed);
|
/// view.set_background_color(Color::SystemRed);
|
||||||
/// view.layer.set_corner_radius(4.0);
|
/// view.layer.set_corner_radius(4.0);
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
//! # Hello World
|
//! # Hello World
|
||||||
//!
|
//!
|
||||||
//! ```rust,no_run
|
//! ```rust,no_run
|
||||||
//! use cacao::appkit::app::{App, AppDelegate};
|
//! use cacao::appkit::{App, AppDelegate};
|
||||||
//! use cacao::appkit::window::Window;
|
//! use cacao::appkit::window::Window;
|
||||||
//!
|
//!
|
||||||
//! #[derive(Default)]
|
//! #[derive(Default)]
|
||||||
|
|
|
@ -7,10 +7,10 @@
|
||||||
//! Views implement Autolayout, which enable you to specify how things should appear on the screen.
|
//! Views implement Autolayout, which enable you to specify how things should appear on the screen.
|
||||||
//!
|
//!
|
||||||
//! ```rust,no_run
|
//! ```rust,no_run
|
||||||
//! use cacao::color::rgb;
|
//! use cacao::color::Color;
|
||||||
//! use cacao::layout::{Layout, LayoutConstraint};
|
//! use cacao::layout::{Layout, LayoutConstraint};
|
||||||
//! use cacao::view::View;
|
//! use cacao::view::View;
|
||||||
//! use cacao::window::{Window, WindowDelegate};
|
//! use cacao::appkit::window::{Window, WindowDelegate};
|
||||||
//!
|
//!
|
||||||
//! #[derive(Default)]
|
//! #[derive(Default)]
|
||||||
//! struct AppWindow {
|
//! struct AppWindow {
|
||||||
|
@ -20,11 +20,12 @@
|
||||||
//! }
|
//! }
|
||||||
//!
|
//!
|
||||||
//! impl WindowDelegate for AppWindow {
|
//! impl WindowDelegate for AppWindow {
|
||||||
|
//! const NAME: &'static str = "RootView";
|
||||||
//! fn did_load(&mut self, window: Window) {
|
//! fn did_load(&mut self, window: Window) {
|
||||||
//! window.set_minimum_content_size(300., 300.);
|
//! window.set_minimum_content_size(300., 300.);
|
||||||
//! self.window = window;
|
//! self.window = window;
|
||||||
//!
|
//!
|
||||||
//! self.red.set_background_color(rgb(224, 82, 99));
|
//! self.red.set_background_color(Color::rgb(224, 82, 99));
|
||||||
//! self.content.add_subview(&self.red);
|
//! self.content.add_subview(&self.red);
|
||||||
//!
|
//!
|
||||||
//! self.window.set_content_view(&self.content);
|
//! self.window.set_content_view(&self.content);
|
||||||
|
@ -532,6 +533,9 @@ impl<T> ListView<T> {
|
||||||
/// `reload_rows`, or `remove_rows` from there.
|
/// `reload_rows`, or `remove_rows` from there.
|
||||||
///
|
///
|
||||||
/// ```rust,no_run
|
/// ```rust,no_run
|
||||||
|
/// use cacao::listview::ListView;
|
||||||
|
/// use cacao::listview::RowAnimation;
|
||||||
|
/// let list_view: ListView<()> = todo!();
|
||||||
/// list_view.perform_batch_updates(|listview| {
|
/// list_view.perform_batch_updates(|listview| {
|
||||||
/// listview.insert_rows(&[0, 2], RowAnimation::SlideDown);
|
/// listview.insert_rows(&[0, 2], RowAnimation::SlideDown);
|
||||||
/// });
|
/// });
|
||||||
|
@ -712,7 +716,13 @@ impl<T> ListView<T> {
|
||||||
/// For example (minus the other necessary ListViewDelegate pieces):
|
/// For example (minus the other necessary ListViewDelegate pieces):
|
||||||
///
|
///
|
||||||
/// ```rust,no_run
|
/// ```rust,no_run
|
||||||
|
/// use cacao::appkit::menu::MenuItem;
|
||||||
|
/// use cacao::listview::{ListViewDelegate, ListView, ListViewRow};
|
||||||
|
/// struct MyListView {
|
||||||
|
/// list_view: ListView<()>,
|
||||||
|
/// };
|
||||||
/// impl ListViewDelegate for MyListView {
|
/// impl ListViewDelegate for MyListView {
|
||||||
|
/// const NAME: &'static str = "RootListView";
|
||||||
/// fn context_menu(&self) -> Vec<MenuItem> {
|
/// fn context_menu(&self) -> Vec<MenuItem> {
|
||||||
/// let clicked_row = self.list_view.get_clicked_row_index();
|
/// let clicked_row = self.list_view.get_clicked_row_index();
|
||||||
///
|
///
|
||||||
|
@ -724,6 +734,9 @@ impl<T> ListView<T> {
|
||||||
/// // User right-clicked on a row, so let's show an edit menu.
|
/// // User right-clicked on a row, so let's show an edit menu.
|
||||||
/// vec![MenuItem::new("Edit")]
|
/// vec![MenuItem::new("Edit")]
|
||||||
/// }
|
/// }
|
||||||
|
/// fn did_load(&mut self, _: ListView) { todo!() }
|
||||||
|
/// fn number_of_items(&self) -> usize { todo!() }
|
||||||
|
/// fn item_for(&self, _: usize) -> ListViewRow { todo!() }
|
||||||
/// }
|
/// }
|
||||||
/// ```
|
/// ```
|
||||||
pub fn get_clicked_row_index(&self) -> NSInteger {
|
pub fn get_clicked_row_index(&self) -> NSInteger {
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
//!
|
//!
|
||||||
//! Views implement Autolayout, which enable you to specify how things should appear on the screen.
|
//! Views implement Autolayout, which enable you to specify how things should appear on the screen.
|
||||||
//!
|
//!
|
||||||
//! ```rust,no_run
|
//! ```rust,compile_fail
|
||||||
//! use cacao::color::rgb;
|
//! use cacao::color::rgb;
|
||||||
//! use cacao::layout::{Layout, LayoutConstraint};
|
//! use cacao::layout::{Layout, LayoutConstraint};
|
||||||
//! use cacao::view::View;
|
//! use cacao::view::View;
|
||||||
|
@ -20,6 +20,7 @@
|
||||||
//! }
|
//! }
|
||||||
//!
|
//!
|
||||||
//! impl WindowDelegate for AppWindow {
|
//! impl WindowDelegate for AppWindow {
|
||||||
|
//! const NAME: &'static str = "RootView";
|
||||||
//! fn did_load(&mut self, window: Window) {
|
//! fn did_load(&mut self, window: Window) {
|
||||||
//! window.set_minimum_content_size(300., 300.);
|
//! window.set_minimum_content_size(300., 300.);
|
||||||
//! self.window = window;
|
//! self.window = window;
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
/// performance, but is good enough for many applications. Implement this trait on your struct
|
/// performance, but is good enough for many applications. Implement this trait on your struct
|
||||||
/// that implements `AppDelegate`, and then dispatch messages like the following:
|
/// that implements `AppDelegate`, and then dispatch messages like the following:
|
||||||
///
|
///
|
||||||
/// ```rust,no_run
|
/// ```rust,compile_fail
|
||||||
/// App::<YourAppDelegate, YourMessageType>::dispatch_main(your_message);
|
/// App::<YourAppDelegate, YourMessageType>::dispatch_main(your_message);
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
//! (where you have a fixed start and end) and indeterminate (infinite; it will go and go until you
|
//! (where you have a fixed start and end) and indeterminate (infinite; it will go and go until you
|
||||||
//! tell it to stop).
|
//! tell it to stop).
|
||||||
//!
|
//!
|
||||||
//! ```rust,no_run
|
//! ```rust,compile_fail
|
||||||
//! let indicator = ProgressIndicator::new();
|
//! let indicator = ProgressIndicator::new();
|
||||||
//! indicator.set_indeterminate(true);
|
//! indicator.set_indeterminate(true);
|
||||||
//! my_view.add_subview(&indicator);
|
//! my_view.add_subview(&indicator);
|
||||||
|
|
|
@ -7,10 +7,10 @@
|
||||||
//! Views implement Autolayout, which enable you to specify how things should appear on the screen.
|
//! Views implement Autolayout, which enable you to specify how things should appear on the screen.
|
||||||
//!
|
//!
|
||||||
//! ```rust,no_run
|
//! ```rust,no_run
|
||||||
//! use cacao::color::rgb;
|
//! use cacao::color::Color;;
|
||||||
//! use cacao::layout::{Layout, LayoutConstraint};
|
//! use cacao::layout::{Layout, LayoutConstraint};
|
||||||
//! use cacao::view::View;
|
//! use cacao::view::View;
|
||||||
//! use cacao::window::{Window, WindowDelegate};
|
//! use cacao::appkit::window::{Window, WindowDelegate};
|
||||||
//!
|
//!
|
||||||
//! #[derive(Default)]
|
//! #[derive(Default)]
|
||||||
//! struct AppWindow {
|
//! struct AppWindow {
|
||||||
|
@ -20,11 +20,12 @@
|
||||||
//! }
|
//! }
|
||||||
//!
|
//!
|
||||||
//! impl WindowDelegate for AppWindow {
|
//! impl WindowDelegate for AppWindow {
|
||||||
|
//! const NAME: &'static str = "WindowDelegate";
|
||||||
//! fn did_load(&mut self, window: Window) {
|
//! fn did_load(&mut self, window: Window) {
|
||||||
//! window.set_minimum_content_size(300., 300.);
|
//! window.set_minimum_content_size(300., 300.);
|
||||||
//! self.window = window;
|
//! self.window = window;
|
||||||
//!
|
//!
|
||||||
//! self.red.set_background_color(rgb(224, 82, 99));
|
//! self.red.set_background_color(Color::rgb(224, 82, 99));
|
||||||
//! self.content.add_subview(&self.red);
|
//! self.content.add_subview(&self.red);
|
||||||
//!
|
//!
|
||||||
//! self.window.set_content_view(&self.content);
|
//! self.window.set_content_view(&self.content);
|
||||||
|
|
|
@ -28,8 +28,13 @@ use crate::layout::{LayoutAnchorDimension, LayoutAnchorX, LayoutAnchorY};
|
||||||
/// Some properties are platform-specific; see the documentation for further information.
|
/// Some properties are platform-specific; see the documentation for further information.
|
||||||
///
|
///
|
||||||
/// ```rust,no_run
|
/// ```rust,no_run
|
||||||
|
/// use cacao::select::Select;
|
||||||
|
/// use cacao::view::View;
|
||||||
|
/// use crate::cacao::layout::Layout;
|
||||||
|
///
|
||||||
/// let mut dropdown = Select::new();
|
/// let mut dropdown = Select::new();
|
||||||
///
|
///
|
||||||
|
/// let my_view : View<()> = todo!();
|
||||||
/// // Make sure you don't let your Select drop for as long as you need it.
|
/// // Make sure you don't let your Select drop for as long as you need it.
|
||||||
/// my_view.add_subview(&dropdown);
|
/// my_view.add_subview(&dropdown);
|
||||||
/// ```
|
/// ```
|
||||||
|
|
|
@ -4,25 +4,28 @@
|
||||||
//!
|
//!
|
||||||
//! Labels implement Autolayout, which enable you to specify how things should appear on the screen.
|
//! Labels implement Autolayout, which enable you to specify how things should appear on the screen.
|
||||||
//!
|
//!
|
||||||
//! ```rust,no_run
|
//! ```rust
|
||||||
//! use cacao::color::rgb;
|
//! use cacao::color::Color;
|
||||||
//! use cacao::layout::{Layout, LayoutConstraint};
|
//! use cacao::layout::{Layout, LayoutConstraint};
|
||||||
//! use cacao::view::Label;
|
//! use cacao::text::Label;
|
||||||
//! use cacao::window::{Window, WindowDelegate};
|
//! use cacao::view::View;
|
||||||
|
//! use cacao::appkit::window::{Window, WindowDelegate};
|
||||||
//!
|
//!
|
||||||
//! #[derive(Default)]
|
//! #[derive(Default)]
|
||||||
//! struct AppWindow {
|
//! struct AppWindow {
|
||||||
//! content: Label,
|
//! content: Label,
|
||||||
//! label: Label,
|
//! label: Label,
|
||||||
|
//! red: View,
|
||||||
//! window: Window
|
//! window: Window
|
||||||
//! }
|
//! }
|
||||||
//!
|
//!
|
||||||
//! impl WindowDelegate for AppWindow {
|
//! impl WindowDelegate for AppWindow {
|
||||||
|
//! const NAME: &'static str = "RootView";
|
||||||
//! fn did_load(&mut self, window: Window) {
|
//! fn did_load(&mut self, window: Window) {
|
||||||
//! window.set_minimum_content_size(300., 300.);
|
//! window.set_minimum_content_size(300., 300.);
|
||||||
//! self.window = window;
|
//! self.window = window;
|
||||||
//!
|
//!
|
||||||
//! self.label.set_background_color(rgb(224, 82, 99));
|
//! self.label.set_background_color(Color::rgb(224, 82, 99));
|
||||||
//! self.label.set_text("LOL");
|
//! self.label.set_text("LOL");
|
||||||
//! self.content.add_subview(&self.red);
|
//! self.content.add_subview(&self.red);
|
||||||
//!
|
//!
|
||||||
|
@ -107,25 +110,28 @@ fn allocate_view(registration_fn: fn() -> *const Class) -> id {
|
||||||
///
|
///
|
||||||
/// Labels implement Autolayout, which enable you to specify how things should appear on the screen.
|
/// Labels implement Autolayout, which enable you to specify how things should appear on the screen.
|
||||||
///
|
///
|
||||||
/// ```rust,no_run
|
/// ```rust
|
||||||
/// use cacao::color::rgb;
|
/// use cacao::color::Color;
|
||||||
/// use cacao::layout::{Layout, LayoutConstraint};
|
/// use cacao::layout::{Layout, LayoutConstraint};
|
||||||
/// use cacao::view::Label;
|
/// use cacao::text::Label;
|
||||||
/// use cacao::window::{Window, WindowDelegate};
|
/// use cacao::appkit::window::{Window, WindowDelegate};
|
||||||
|
/// use cacao::view::View;
|
||||||
///
|
///
|
||||||
/// #[derive(Default)]
|
/// #[derive(Default)]
|
||||||
/// struct AppWindow {
|
/// struct AppWindow {
|
||||||
/// content: Label,
|
/// content: Label,
|
||||||
/// label: Label,
|
/// label: Label,
|
||||||
|
/// red: View,
|
||||||
/// window: Window
|
/// window: Window
|
||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
/// impl WindowDelegate for AppWindow {
|
/// impl WindowDelegate for AppWindow {
|
||||||
|
/// const NAME: &'static str = "RootView";
|
||||||
/// fn did_load(&mut self, window: Window) {
|
/// fn did_load(&mut self, window: Window) {
|
||||||
/// window.set_minimum_content_size(300., 300.);
|
/// window.set_minimum_content_size(300., 300.);
|
||||||
/// self.window = window;
|
/// self.window = window;
|
||||||
///
|
///
|
||||||
/// self.label.set_background_color(rgb(224, 82, 99));
|
/// self.label.set_background_color(Color::rgb(224, 82, 99));
|
||||||
/// self.label.set_text("LOL");
|
/// self.label.set_text("LOL");
|
||||||
/// self.content.add_subview(&self.red);
|
/// self.content.add_subview(&self.red);
|
||||||
///
|
///
|
||||||
|
|
|
@ -22,9 +22,13 @@ mod native_interface;
|
||||||
///
|
///
|
||||||
/// ## Example
|
/// ## Example
|
||||||
/// ```rust,no_run
|
/// ```rust,no_run
|
||||||
|
/// use cacao::view::ViewDelegate;
|
||||||
|
///
|
||||||
/// struct ContentViewDelegate;
|
/// struct ContentViewDelegate;
|
||||||
///
|
///
|
||||||
/// impl ViewDelegate for ContentViewDelegate {
|
/// impl ViewDelegate for ContentViewDelegate {
|
||||||
|
/// const NAME: &'static str = "ContentViewDelegate";
|
||||||
|
///
|
||||||
/// fn will_appear(&self, animated: bool) {
|
/// fn will_appear(&self, animated: bool) {
|
||||||
/// println!("This controller is about to appear!");
|
/// println!("This controller is about to appear!");
|
||||||
/// }
|
/// }
|
||||||
|
|
|
@ -6,11 +6,11 @@
|
||||||
//!
|
//!
|
||||||
//! Views implement Autolayout, which enable you to specify how things should appear on the screen.
|
//! Views implement Autolayout, which enable you to specify how things should appear on the screen.
|
||||||
//!
|
//!
|
||||||
//! ```rust,no_run
|
//! ```rust
|
||||||
//! use cacao::color::Color;
|
//! use cacao::color::Color;
|
||||||
//! use cacao::layout::{Layout, LayoutConstraint};
|
//! use cacao::layout::{Layout, LayoutConstraint};
|
||||||
//! use cacao::view::View;
|
//! use cacao::view::View;
|
||||||
//! use cacao::window::{Window, WindowDelegate};
|
//! use cacao::appkit::window::{Window, WindowDelegate};
|
||||||
//!
|
//!
|
||||||
//! #[derive(Default)]
|
//! #[derive(Default)]
|
||||||
//! struct AppWindow {
|
//! struct AppWindow {
|
||||||
|
@ -20,6 +20,7 @@
|
||||||
//! }
|
//! }
|
||||||
//!
|
//!
|
||||||
//! impl WindowDelegate for AppWindow {
|
//! impl WindowDelegate for AppWindow {
|
||||||
|
//! const NAME: &'static str = "RootView";
|
||||||
//! fn did_load(&mut self, window: Window) {
|
//! fn did_load(&mut self, window: Window) {
|
||||||
//! window.set_minimum_content_size(300., 300.);
|
//! window.set_minimum_content_size(300., 300.);
|
||||||
//! self.window = window;
|
//! self.window = window;
|
||||||
|
|
Loading…
Reference in a new issue