Commit graph

34 commits

Author SHA1 Message Date
simlay e4785bb50f
iOS support for label, text input, font, more tests (#55)
* Added a bunch of unit tests and added text input to uikit feature

* cargo fmt

* I dunno what this is but it wasnt checked in

* Fix uikit unit tests

* maybe fix cargo fmt

* Fix iOS run

* fix cargo fmt

* Maybe fix cargo fmt

* maybe fix cargo fmt

* cargo fmt

* Try to fix cargo fmt one more time

* cargo fmt
2023-07-10 00:42:46 -07:00
Luke Rogers 81fa4e698e Fixed building for iOS. 2023-05-31 12:00:19 +01:00
Alexander Czernay ff85e24055 Applies rustfmt.toml rules 2023-04-17 21:35:49 +02:00
Alexander Czernay 718c831bc4 Refactor to use load_or_register_class 2023-04-16 21:24:44 +02:00
Alexander Czernay 2803922f3a Fixes possible duplicate objc class registration.
This can happen in environments like plugins, where cacao can exist multiple times and thus tries to create and register its objc classes more than once.
2023-04-16 10:47:32 +02:00
Benedikt Terhechte 7e724934a5 add support for popovers 2023-03-03 12:15:28 +01:00
Ryan McGrath c58de62f1d Nightly fmt pass 2022-08-21 19:21:26 -04:00
Ryan McGrath cf11a935de Formatting hell 2022-08-21 19:21:26 -04:00
Ryan McGrath 8b43d43caf Block off AppKit animator proxy to fix iOS compiling 2022-08-21 19:21:26 -04:00
Sebastian Imlay 8bffc30ac1 fix cargo test 2022-08-14 15:44:53 -04:00
Mads Marquart 56f748910e Always specify function ABI 2022-07-15 16:14:03 +02: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 87533d576f
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.
2021-08-09 02:09:08 -07: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 46ee9e2ea8
Add in .layer support for Views.
- Cleans up `View` implementation so there's less boilerplate all
  around.

- Adds in a `Layer` wrapper for `CALayer`s on widgets.
2021-03-26 16:25:57 -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 10c513edad
A rather large and not very clean update.
- Adds support for NSSplitViewController.
- Reworks NSMenu support to be cleaner with enum variants.
- Reworks the Foundation underpinnings to be a bit safer and more clear
  in how they're used and passed around.
- Changes to docs structure for push towards v0.1.
- Examples updated to account for changes.
2021-03-04 17:24:39 -08:00
Ryan McGrath 5cd59b5636
Begin reworking many internals to push for v0.1.
- Beginning to transition View types to use Rc/RefCell internally,
  which should provide better guarantees about ownership on the Rust side.
  This is also important for certain Objective-C side scenarios where we
  may need to set an ivar after creation, which requires some level of
  mutability. This may also possibly help bring down the unsafe usage,
  which would be cool.

- Rewrote the Color module; this now handles system colors better, and
  provides support for dynamic color creation. Supporting combinations
  of dark/light/contrast is now possible with handler passed in via
  `Color::dynamic`. This still has work to do in terms of some accessor
  methods and such, but it works well for now. The `to_platform...`
  method should be removed before v0.1.

- Added a new feature for enabling fallback color usage on older macOS
  versions that don't support system colors. This may honestly never be
  used, but it cost nothing to implement.

- Fixed a bug in the Autolayout wrapper where dereferencing could cause
  constraints to crash at runtime.

- Support setting text color on labels.

- Support setting text color on buttons, albeit very hacky right now.
  This needs to be extracted and/or cleaned up, but getting it sketched
  out was important for this commit.

- Support setting a key equivalent on buttons.

- Creating a local event monitor is now possible.

- Examples updated; Calculator clone example added.

The only API breaking change in this commit from earlier commits should
be `color::rgb` needing to be `color::Color` followed by a
`Color::rgb(...)` call.
2021-02-12 17:57:06 -08:00
Ryan McGrath a167be8383
More features and cleanup.
- Reconfigured subclass creation, as there was a
  subtle-but-big-when-it-hit bug in the prior method where bridge
  callbacks would lose context of the appropriate delegate when calling
  the trait method. The new approach found in `src/foundation/class.rs`
  maps and caches subclass creation, and subclasses are now more
  apparent when debugging from the Objective-C side as we can carry
  their intended name/usage through. Not applied to all yet, but
  eventually.

- Cleaned up a number of linter warnings that had grown over time.

- Delegate traits now require an associated const `NAME`, which is used
  for subclass creation.

- (macOS) Toolbars now supported setting selected items, which is
  typically used in preferences screens.

- (macOS) Windows now support setting the toolbar display style. On Big
  Sur, this works as intended - it's a noop on older OS's that don't
  support it.

- Support for system icons for macOS preferences windows.

Still a bit to go to flesh this all out, but it's getting there - at
which point then iOS supoort can be folded in easier.
2021-02-07 20:25:56 -08:00
Ryan McGrath 121a2f938e
Some updates. API still in flux, but you can build
- Added support for Image
- Added a QuickLook feature, to enable thumbnail generation.
- Added support for NSButton.
- Fixed a bug where App activation under Big Sur would leave menus
  without the ability to be used.
- Added the ability for Buttons and ToolbarItems to execute callbacks.
- Added support for Labels and TextFields.
- Added support for MenuItems to have callbacks as well.
- Preliminary ListView support; you have to cache your ListViewRow items
  yourself for the time being, but it works.
- Animation support for ListView operations.
- Support for ScrollViews.
- Helpers for dispatching actions to the main thread (for UI work).
- Updated the Dispatcher trait to make thread handling simpler.
- Basic font support.
2021-01-16 17:11:04 -08:00
Ryan McGrath 784727748c
Missing files from last commit, whoops. Also begin the long arduous process of bringing in NSNotificationName. Just end me now. 2020-04-05 00:09:17 -07:00
Ryan McGrath ba59b06177
Ensure macOS still works, and make these things call super when need be 2020-04-04 21:12:17 -07:00
Ryan McGrath 4ff69c008a
Very rough experimental support for iOS13+ Scenes. Not ready for use or comment yet. 2020-04-04 19:50:58 -07:00
Ryan McGrath d69f59d284
Further work on splitting for macOS/iOS support 2020-03-29 22:33:51 -07:00
Ryan McGrath 4266c4c8dc
Ongoing cleaning efforts 2020-03-28 22:05:40 -07:00
Ryan McGrath 6b8aad4a94
Fix up the repo so examples work as they should 2020-03-26 18:06:11 -07:00