Commit graph

15 commits

Author SHA1 Message Date
Mads Marquart 094ed59a04
Initial conversion to objc2 (#30)
* Use objc2

* Replace `objc_id`

* Remove sel_impl import

* Fix `add_method` calls

* Fix accessing raw FFI functions

* Fix Encode impl

* Fix message sends arguments that do not implement `Encode`

* Use immutable reference in a few places where now necessary

See https://github.com/madsmtm/objc2/pull/150 for a bit of background

* Add a few Send + Sync bounds where examples require it

This is something we'll need to look into properly

* Use `&'static Class` instead of `*const Class`

Safer and more ergonomic. Also required for `msg_send_id!` macro

* Use msg_send_id! and rc::Id

* Update objc2 to v0.3.0-beta.2

* Replace `BOOL` with `Bool` when declaring delegates

This makes cacao compile on Aarch64 again

* Remove a few impossible to use correctly `into_inner` functions

These consumed `self`, and hence also dropped `Id` variable that was responsible for keeping the returned pointer alive

* Remove a few impossible to use correctly `From` implementations

* Quickly fix UB with using BACKGROUND_COLOR ivar

* Fix double-freeing of windows

* Fix double freeing of strings

* Fix a few remaining double-frees
2023-09-11 09:59:21 -07:00
Sebastian Imlay 7c917ee0ea Removed some compile_fail parts 2022-08-14 15:59:05 -04:00
Sebastian Imlay 8bffc30ac1 fix cargo test 2022-08-14 15:44:53 -04:00
Mads Marquart db4f2c0720 Run cargo fmt 2022-07-15 16:14:02 +02:00
Mads Marquart 02f5d6aa87 Remove trailing whitespace 2022-07-15 16:13:27 +02:00
Ryan McGrath 4ecfbd0928
A large smattering of updates.
- Added basic animation support, via NSAnimationContext proxy objects.
  These can be used to animate layout constraints and alpha values,
  currently.

- Fixed a bug in ListView where the underlying NSTableView would not
  redraw the full correct virtual height in some conditions.

- Added safe layout guide support to some views.

- Added a new trait to buffer ObjC object access for view and control
  types. This is the supertrait of the Layout and Control traits.

- Added a Control trait, which implements various NSControl pieces.

- Added a Select control, which is a Select-ish HTML dropdown lookalike.

- Added NSURL support, which is one of the few types to expose here.

- Filesystem and pasteboard types now work with NSURLs. Users who need
  pathbufs can use the provided conversion method on NSURL.

- Fixed a bug where some Window and ViewController types could wind up
  in a double-init scenario.
2022-01-02 02:35:12 -08:00
Ryan McGrath 93424f74c0
Throw autolayout behind a feature flag.
- AutoLayout is now behind a feature flag (that is defaulted) to enable
  building and running on platforms that do _not_ support AutoLayout.

- Added a frame-based Layout example for platforms that don't have
  AutoLayout support.

- Fixed a bug in geometry.rs where x/y coordinates would get swapped on
  conversion to `CGRect`.

- Added a README to the examples directory to aid in first time users
  running examples.
2021-08-08 18:42:07 -07:00
Ryan McGrath c713194262
v0.3.
- Changes internal target_os flags to be feature flags; macOS is now
  appkit, and iOS/tvOS are now uikit. This enables platforms that are
  not Apple-specific platforms that use frameworks to be compiled for.

- Updates the examples to handle closing/quitting better.
2021-08-07 22:31:48 -07:00
Ryan McGrath f558f8e24d
iOS works again, lol.
- Corrects `feature` -> `target_os` checks.
- Updates the old iOS scene delegate pieces to use the new class
  structure.
- Bundles in an iOS demo app.
- Blocks off most things that should not even attempt to compile for
  iOS.
2021-04-15 17:13:59 -07:00
Ryan McGrath 1b0be74fc8
Begin moving certain core methods to Layout.
- Drag and drop, hidden, and so on now live on on the `Layout` trait,
  which helps make the logic less of a hassle to support (these methods
  are almost always guaranteed to exist on any view type, and it's
  easier to just noop them on a specific view if need be).

- Begin reworking auto-drop-remove-from-superview logic by including an
  `is_handle` flag on `View`; will need to extend this work to others.
2021-03-26 17:51:37 -07:00
Ryan McGrath 2f9a5b5e67
Rework the Layout trait implementation.
- Adds a new `ObjcProperty` type, which wraps our Objective-C objects in
  a Rust-backed Rc/Refcell combo. This in general makes understanding
  reference counting/storage more digestable when reading through the
  codebase and leans more on Rust to do its thing than the Objective-C
  runtime.

- Most widgets that need to implement `Layout` now only need to provide
  a slot for running a handler with the underlying node.

- Further documentation work ongoing.
2021-03-26 13:29:39 -07:00
Ryan McGrath 9446092169
Clean up AutoLayout wrapper.
- Anchors are now enums, which help in debugging constraint issues.

- Enum types that are acceptable for constraint generation are now
  matched at runtime, and provide better error messages if a constraint
  can't be satisfied and crashes the app.

- `left` and `right` anchors are now supported on all widgets, fixing an
  oversight from early iterations of the framework.

- Reduces `unsafe` usage by a decent amount when setting constraint
  pointers for widget types.
2021-03-16 18:21:31 -07:00
Ryan McGrath 696907aa73
Ongoing documentation and cleanup work. 2021-03-15 17:09:50 -07:00
Ryan McGrath bc54b49475
Ongoing push to a v0.1.
- Basic support for `AttributedString` type.
- `Debug` implementations across the board to ease debugging issues.
- Methods that take `Color` and `Font` types now accept an `AsRef` to
  make implementing less of a headache.
- Cleanup of the `utils` module.
2021-03-05 14:11:17 -08:00
Ryan McGrath 62cebab691
Some more updates for macOS.
- Added support for basic Cursor management.
- Added support for NSWindow cancelOperation: callbacks. It's not...
  perfect, but it works as a discrete hook.
- Added support for NSProgressIndicator.
- Properly forward Error types from QuickLook generation calls, and
  future-proof the ThumbnailQuality enum.
- Add support for configuring Label line break mode.
2021-01-19 00:11:52 -08:00