Expand description

Wraps NSView and UIView across platforms.

This implementation errs towards the UIView side of things, and mostly acts as a wrapper to bring NSView to the modern era. It does this by flipping the coordinate system to be what people expect in 2020, and layer-backing all views by default.

Views implement Autolayout, which enable you to specify how things should appear on the screen.

use cacao::color::Color;
use cacao::layout::{Layout, LayoutConstraint};
use cacao::view::View;
use cacao::appkit::window::{Window, WindowDelegate};

#[derive(Default)]
struct AppWindow {
    content: View,
    red: View,
    window: Window
}

impl WindowDelegate for AppWindow {
    const NAME: &'static str = "RootView";
    fn did_load(&mut self, window: Window) {
        window.set_minimum_content_size(300., 300.);
        self.window = window;

        self.red.set_background_color(Color::rgb(224, 82, 99));
        self.content.add_subview(&self.red);

        self.window.set_content_view(&self.content);

        LayoutConstraint::activate(&[
            self.red.top.constraint_equal_to(&self.content.top).offset(16.),
            self.red.leading.constraint_equal_to(&self.content.leading).offset(16.),
            self.red.trailing.constraint_equal_to(&self.content.trailing).offset(-16.),
            self.red.bottom.constraint_equal_to(&self.content.bottom).offset(-16.),
        ]);
    }
}

For more information on Autolayout, view the module or check out the examples folder.

Structs

A clone-able handler to a ViewController reference in the Objective C runtime. We use this instead of a stock View for easier recordkeeping, since it’ll need to hold the View on that side anyway.

Represents an action that can be displayed when a user swipes-to-reveal on a ListViewRow. You return this from the appropriate delegate method, and the system will handle displaying the necessary pieces for you.

Enums

Represents the “type” or “style” of row action. A Regular action is nothing special; do whatever you want. A Destructive action will have a special animation when being deleted, among any other system specialties.

This enum represents the different stock animations possible for ListView row operations. You can pass it to insert_rows and remove_rows - reloads don’t get animations.

Specifies a row edge.

Traits