Commit Graph

144 Commits

Author SHA1 Message Date
Oluseyi Sonaiya 135fce2385 Use bitflags from_bits_truncate to ensure value retrieved from msg_send maps to declared fields. Prefer truncate because macOS may use reserved bits for private purposes, or introduce new values in future versions. 2017-03-22 11:35:32 -04:00
Oluseyi Sonaiya 7f9ba0f7d5 Rename NSWindowMask to NSWindowStyleMask to match the Cocoa AppKit type 2017-03-22 11:33:12 -04:00
Oluseyi Sonaiya c964442d55 NSWindowMask, as an enumeration in Objective-C, degrades to NSUInteger and is therefore bitwise-combinable, though it loses type information. Instead of implementing NSWindowMask as a packed-data object with a u64 representational form, we ought to employ bit flags to generate a strong type that remains combinable in the manner Cocoa programmers are accustomed to. Also easier than manually implementing std::ops::BitOr for the type. 2017-03-22 09:59:03 -04:00
Paul Rouget 142bf3bbc0 Add appearance names 2017-03-15 13:51:02 +01:00
Paul Rouget 73455d52ad More NSButton methods 2017-02-01 09:49:16 +01:00
Paul Rouget 128a1ab460 NSTextField support 2017-02-01 09:49:04 +01:00
Corey Farwell 5b9a27e4cb Init NSColor trait, add clearColor constructor. 2016-11-26 15:06:06 -05:00
Corey Farwell 7cb21cfb61 Add UIKit classes and methods to support layout constraints.
Written primarily for https://github.com/tomaka/winit/issues/80.
2016-11-23 00:10:51 -05:00
bors-servo a21ac5970c Auto merge of #137 - burtonageo:NSDictionary, r=pcwalton
Add NSDictionary + tests, define NSComparator and NSComparisonResult

<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/cocoa-rs/137)
<!-- Reviewable:end -->
2016-10-23 15:24:57 -05:00
Rafael Barbosa edcf333e8a Updated the NSTabView and NSTabViewItem bindings to match the current codebase. Updated the tab_view example 2016-07-26 23:53:07 +01:00
Rafael Barbosa 3f0c4ce8e6 Merge remote-tracking branch 'upstream/master'
Conflicts:
	src/appkit.rs
2016-07-24 22:22:56 +01:00
George Burton 0b4616d1c3 Add more NSImage methods, and add associated enums + string constants 2016-07-10 10:36:09 +01:00
George Burton 0b07a7962d Add NSDictionary + tests, define NSComparator and NSComparisonResult 2016-07-09 15:39:32 +01:00
George Burton 575fd9ea92 Add NSSound 2016-07-07 20:54:55 +01:00
George Burton 3c86fc88bb Add NSData and associated constants 2016-07-03 22:13:58 +01:00
George Burton 6367782ef8 Add NSPasteboard, NSPasteboardItem, NSPasteboardReading, NSPasteboardWriting, NSPasteboardReadingOptions, NSPasteboardWriting options, and various other constants 2016-07-03 15:08:09 +01:00
mitchmindtree a7b905f263 Add missing cocoa Data Type constants 2016-06-24 15:48:16 +10:00
Patrick Walton 866cdb1ec8 Add bindings for +[NSRunLoop currentRunLoop] and
`-[NSRunLoop performSelector:target:argument:order:modes:]`
2016-06-10 18:34:41 -07:00
Patrick Walton 44d3744515 appkit: Lengthen NSAnyEventMask to (-1 as u64) rather than (-1 as
u32), to fix the problem whereby windows don't reappear and don't appear
on top on startup.

The window restoration feature in Mac OS X from Lion onward prevents
windows from appearing until restoration is complete and the app is
launched. Internally, the persistent UI restorer detects the app launch
by listening to the Carbon event `kAEOpenApplication`, which, as an
Apple event, has the event class `kEventClassAppleEvent`.

Like `-[NSApplication run]` does, Glutin uses the method
`-[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:]` to
pump the application event loop. The event mask provided is an
`NSEventMask`; events that do not match this mask are filtered out. When
pumping the Carbon event loop, the Cocoa framework internally converts
this `NSEventMask` to a Carbon event mask. The logic to perform this
conversion proceeds in two steps:

1. If the provided `NSEventMask` is exactly equal to `NSAnyEventMask`,
then the rest of the logic is skipped and the resulting Carbon event
mask is a null mask--i.e. a mask that matches all events.

2. Otherwise, the framework constructs a blank Carbon mask--that is, a
mask that matches no events at all. The various bits of the
`NSEventMask` are examined, translated to their Carbon equivalents, and
added to the mask. Then that Carbon mask is returned.

In Glutin prior to this patch, our definition of `NSAnyEventMask` was a
mask that effectively matched all events but was not equal to the real
`NSAnyEventMask` that, for example, `-[NSApplication run]` supplies to
`-[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:]`. This
means that our code causes the system to take path (2) above, whereas
standard Cocoa apps take path (1). Now it might seem that these paths
are equivalent, but in fact they are very different. This is because
*there are classes of Carbon events that do not correspond to Cocoa
events selectable via `NSEventMask`*. One of these Carbon-only event
types is Apple events.

This fact is what made Glutin apps prior to this patch go wrong. The
Carbon framework would deliver the `kAEOpenApplication` event to the
application, but it was always masked out and ignored because the
`NSEventMask` we supplied to `-[NSApplication
nextEventMatchingMask:untilDate:inMode:dequeue:]` did not translate to a
Carbon event mask that included Apple events. This, in turn, caused the
persistent UI restorer to never notice that the app finished launching.
Thus the flag that inhibited windows from appearing would never be
cleared, and all windows would end up invisible.

This patch fixes the issue by lengthening `NSAnyEventMask` to its true
64-bit value, allowing the expected Carbon event filter to be used
during app startup and enabling the app startup event to be handled
properly.
2016-06-07 22:23:11 -07:00
Patrick Walton 37b5ce6113 Add bindings to NSInsetRect and NSRectToCGRect, and make various
geometry types copyable.
2016-05-27 13:25:32 -07:00
bors-servo 24f7593061 Auto merge of #125 - pcwalton:menu-additions, r=larsbergstrom
Add bindings for a few more menu-related functions.

Bindings added include:

* `-[NSApplication mainMenu]`
* `-[NSApplication setWindowsMenu:]`
* `+[NSMenu alloc]`
* `-[NSMenu initWithTitle:]`
* `-[NSMenu itemAtIndex:]`

r? @metajack

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/cocoa-rs/125)
<!-- Reviewable:end -->
2016-05-16 10:05:07 -07:00
bors-servo 48342f557c Auto merge of #126 - servo:bitflags, r=Wafflespeanut
Update bitflags to 0.7

<!-- Reviewable:start -->
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/cocoa-rs/126)
<!-- Reviewable:end -->
2016-05-15 03:26:39 -07:00
Anthony Ramine 20b52d82c4 Update bitflags to 0.7 2016-05-15 12:06:35 +02:00
Patrick Walton 7aa45dc0a5 Add bindings for a few more menu-related functions.
Bindings added include:

* `-[NSApplication mainMenu]`
* `-[NSApplication setWindowsMenu:]`
* `+[NSMenu alloc]`
* `-[NSMenu initWithTitle:]`
* `-[NSMenu itemAtIndex:]`
2016-05-12 16:37:10 -07:00
Patrick Walton e1ac9a3821 Add -[NSApplication setApplicationIconImage:] and `-[NSImage
isValid]`.

These are useful for setting icons.
2016-05-10 18:05:52 -07:00
Patrick Walton 2028cee801 Add the venerable NSRectFill. 2016-05-09 11:02:38 -07:00
Patrick Walton f461b65eda Add autosizing-related methods and constants to NSView. 2016-05-09 11:01:02 -07:00
Corey Farwell 976e6dbc70 Derive common traits for AppKit integer repr enums. 2016-04-28 19:15:23 -04:00
Corey Farwell f037498244 Add NSApplicationActivationPolicyProhibited.
https://developer.apple.com/library/mac/documentation/AppKit/Reference/NSRunningApplication_Class/#//apple_ref/c/tdef/NSApplicationActivationPolicy
2016-04-28 10:35:50 -04:00
Conrad Kramer d874e1d9d8 Added basic NSFastEnumeration implementation 2016-03-31 13:08:05 -07:00
Josh Matthews 768538d630 Merge pull request #116 from fkaa/foundation-nsrange
Add NSRange
2016-02-27 16:48:30 -05:00
Felix Kaaman ff18c50631 Add NSRange 2016-02-27 22:12:50 +01:00
Felix Kaaman e403c78fee Add NSView functions 2016-02-27 22:02:09 +01:00
Paul Rouget f21ffe6dc1 add NSEventTypePressure event type 2016-02-16 13:09:30 +01:00
Patrick Walton bf4879fa00 Add bindings to -[NSWindow standardWindowButton:] and -[NSView
removeFromSuperview].
2016-02-03 14:53:45 -08:00
Patrick Walton 3d09c6517a Add a binding to -[NSView superview]. 2016-02-03 14:15:18 -08:00
hc 20c994ecaa NSImage methods and version bump
added some methods to NSImage and version bump to 0.2.3
2016-01-29 22:22:01 -05:00
hc 36f4d4cab3 NSStatusBar
mostly complete, missing `thickness` property, unsure how to access
this property
2016-01-29 21:29:53 -05:00
hc 5d3fd95607 forgot _ for NSStatusItem setLength
whoops forget to add _ for setLength
2016-01-29 21:06:46 -05:00
hc 94efc59d57 NSStatusItem
NSStatusItem fully implemented
2016-01-29 21:04:49 -05:00
hc a96019726c init status bar button (icon)
the minimum to get a status bar button (icon) to appear
2016-01-29 12:19:51 -05:00
Josh Matthews c21f19bba2 Add various initializing methods for NSString, NSArray, and NSValue. 2015-11-27 10:26:39 -05:00
Simon Génier fe8cc9fcdf Implement objc::Encode for NSRect. 2015-11-16 22:09:00 -05:00
Mathieu Rheaume e8d5c36740 Implement NSString Len + init_str use initWithBytes:length:encoding 2015-09-28 02:42:22 -04:00
Rob.Gowin b82bcbe5c5 Added NSRunningApplication and two associated functions.
Added ability to call [[NSRunningApplication currentApplication]
     activateWithOptions: NSApplicationActivateIgnoringOtherApps]
which is used in the example to fix the missing menu bar when
the example app starts.
2015-09-22 22:34:31 -05:00
bors-servo 22791ddd4d Auto merge of #93 - fkaa:menubar-stuff, r=metajack
Add various methods related to menubars



<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/cocoa-rs/93)
<!-- Reviewable:end -->
2015-09-22 13:43:41 -06:00
bors-servo e0f37a07a5 Auto merge of #97 - sgnr:nswindow-managing-responders, r=metajack
Add responder management to NSWindow.

As described [in the documentation for `NSWindow`](https://developer.apple.com/library/mac/documentation/Cocoa/Reference/ApplicationKit/Classes/NSWindow_Class/).

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/cocoa-rs/97)
<!-- Reviewable:end -->
2015-09-22 13:38:07 -06:00
Paul Rouget 99cf2944cb add addSubview method 2015-09-22 09:27:56 +02:00
Paul Rouget 06d64a18c8 Add support for titleVisibility and titlebarAppearsTransparent 2015-09-21 11:28:11 +02:00
Simon Génier fd19702e84 Add responder management to NSWindow. 2015-09-12 14:18:58 -04:00