Commit graph

211 commits

Author SHA1 Message Date
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 01d12396ef
Add custom image drawing example
Useful for Issue #21.
2021-11-20 17:35:25 -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 2a9a8f8635
Push 0.2.1 2021-07-08 15:26:57 -07:00
Ryan McGrath 87eda8f94a
Merge pull request #15 from rrebelo62/trunk
Fixes issue #14: Unlike all controls, WebView has 'fn did_load(&self, …)' with self as non-mutable
2021-07-06 19:04:14 -07:00
Rui A. Rebelo 1f6f334edb
Merge branch 'ryanmcgrath:trunk' into trunk 2021-07-05 15:34:16 -06:00
Rui A. Rebelo f98ac60239 Resolves #14. Unlike all controls, WebView has 'fn did_load(&self,...)' with self as non-mutable 2021-07-05 15:32:50 -06:00
Ryan McGrath 1e132d9080
Merge pull request #13 from rrebelo62/trunk
Resolves #12. Avoid Segmentation Fault, retains the body of a message from a webpage to a webview
2021-07-04 15:05:24 -07:00
Rui A. Rebelo 2f7ebbf2ad Resolves #12. To avoid a Segmentation Fault retains the body of a message from a webpate to a webview 2021-07-03 21:51:02 -06:00
Ryan McGrath aba18412cd
Resolves #11. Pass the actual value, which should compile on macOS 10.15.7 and lower. 2021-06-28 13:11:41 -07:00
Ryan McGrath 9b3f85294f
0.2.0 2021-06-09 16:48:45 -07:00
Ryan McGrath 87354a7161
0.2.0 2021-06-09 16:46:28 -07:00
Ryan McGrath 7acc060601
Quiet this for 0.2.0 2021-06-09 16:38:52 -07:00
Ryan McGrath 644b1228ee
Bump for 0.2.0 release 2021-06-09 16:37:51 -07:00
Ryan McGrath 33123c6790
Merge pull request #10 from lemarier/feat/webview-load-url-string
feat(webview): Allow loading of HTML string instead of URL.
2021-04-26 14:22:22 -07:00
Ryan McGrath eb35b647f7
Update mod.rs
Slight edit for docstring + dereferencing the `NSString`s.
2021-04-26 14:22:07 -07:00
David Lemarier 5ec3b172e8
feat(webview): Allow loading of HTML string instead of URL. 2021-04-26 08:09:13 -04:00
Ryan McGrath be6ff21d11
Merge pull request #9 from lemarier/feat/webview-handlers
feat(webview): Add custom protocol (scheme) support
2021-04-25 17:21:25 -07:00
David Lemarier 7827dd6490
Make infer optional 2021-04-25 19:39:27 -04:00
Ryan McGrath 650d8c472d
Merge pull request #8 from lemarier/fix/webview-ios
fix(webview): `setWantsLayer` selector is not available on iOS
2021-04-25 16:07:20 -07:00
David Lemarier c9d665963a
feat(webview): Add custom protocol (scheme) support
This is a basic implementation of the custom protocol, with built-in mimetype extraction from the content, backed by URI detection.

To make it clear, I added an example and can be run with:

```
cargo run --example webview_custom_protocol --features webview
```
2021-04-25 12:07:45 -04:00
David Lemarier 1531043943
fix(webview): setWantsLayer is not available on iOS 2021-04-25 08:19:45 -04:00
Ryan McGrath 813f452deb
Basic architecture document. 2021-04-23 16:56:44 -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 5f2f1f21b0
Fix NSTextField string dealloc bug 2021-04-14 22:47:13 -07:00
Ryan McGrath 8a9c45af61
Building out browser example.
- Includes test case to reproduce textfield dealloc bug.
2021-04-14 19:00:34 -07:00
Ryan McGrath 80ec654d8d
Adds a text_input example to act as a test.
- TextFieldDelegate methods needed to retain the string, otherwise it
  could crash under fast usage.
- Work on improving the browser example; WIP.
2021-04-12 18:17:36 -07:00
Ryan McGrath 420422187a
Fixes #6 and updates WebView to new layout system.
- Includes a (basic) `browser` example to make testing the feature
  easier.
2021-04-08 17:54:32 -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 2894699ace
Fix button callbacks and avoid double-locks in listview. 2021-03-26 14:26:17 -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 5748e76a97
Pasteboard documentation 2021-03-24 18:58:50 -07:00
Ryan McGrath d8d73e45ad
bool -> BOOL, per note in Pull Request #4. 2021-03-18 11:33:43 -07:00
Ryan McGrath 42e4a0d798
Cleans up a few pieces of #5.
- Changes trait callbacks to receive a `&str` rather than `String`.

- Fixes a bug where multiple text field types with different delegates
  would not receive the right delegate type when coming from the
  Objective-C side.

- Minor cleanup.
2021-03-17 21:57:52 -07:00
Ryan McGrath c3922633b9
Merge branch 'trunk' of github.com:ryanmcgrath/cacao into trunk
* 'trunk' of github.com:ryanmcgrath/cacao:
  Standard macOS event handlers for TextField
2021-03-17 21:45:21 -07:00
Ryan McGrath ce1bca84ce
Merge pull request #5 from MerlinDE/TextField_event_handler
Standard macOS event handlers for TextField
2021-03-17 21:43:46 -07:00
Ryan McGrath 85eaedca2a Merge branch 'trunk' of github.com:ryanmcgrath/cacao into trunk
* 'trunk' of github.com:ryanmcgrath/cacao:
  implemented applicationShouldTerminateAfterLastWindowClosed
2021-03-17 21:42:18 -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
Alexander Czernay a85f41be79 Standard macOS event handlers for TextField
added text_should_begin_editing(), text_did_begin_editing(), text_did_change(), text_should_end_editing() and text_did_end_editing() event handlers

for now these only take the value from the TextField and hand it over as a String
2021-03-14 17:41:36 +01: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 400e763160
Merge pull request #3 from jussiniinikoski/trunk
implement applicationShouldTerminateAfterLastWindowClosed
2021-03-01 09:51:55 -08:00
jussiniinikoski 6b53b30565 implemented applicationShouldTerminateAfterLastWindowClosed 2021-03-01 13:32:14 +02: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 9511a5a82c BOOL handling differs on M1 vs x64.
The M1 ruined me. Fixes building and running on Intel-based Macs.
2021-02-08 11:54:35 -08:00
Ryan McGrath 724b40e5a8
Add a (useful) example: a todo list.
- Adds a Todo list example.
- Updates ListView to support ending the row actions visible state.
- Support setting Label text color.
2021-02-07 23:37:25 -08:00