Difference between revisions of "macOS extensions"

From Free Pascal wiki
Jump to navigationJump to search
Line 61: Line 61:
 
[[Image:macosformprop editted.png]]
 
[[Image:macosformprop editted.png]]
  
 +
==To be Implemented==
 +
* NSToolbar support
 
==See Also==
 
==See Also==
 
* [[Cocoa Interface]] - LCL implementation of cocoa widgetset
 
* [[Cocoa Interface]] - LCL implementation of cocoa widgetset

Revision as of 18:34, 15 April 2018

The package is intended to provide additional macOS Cocoa specific features.

Note: It's expected that those features will not work on any other system or as well as for deprecated Carbon API on macOS. However, it's expected that a project using the package would still succeffully compile and run on any other target.

General Info

Author: Dmitry 'skalogryz' Boyarintsev

License: modified LGPL (same as the FPC RTL and the Lazarus LCL). You can contact the author if the modified LGPL doesn't work with your project licensing.

Repository: https://github.com/skalogryz/macosext

Extensions

After installation a new "macOS" tab is added to the components palette. All additional components are available in this tab:

macosext mainbar.PNG

TmacOSFormProp

The component is introduced to control MacOS NSWindow specific attributes and features, not available via LCL API.

Appearance

macosformprop apppropeditor.PNG

NSAppearance class was introduced in macOS 10.9 for the first time. It controls window appearance options. The fact that it's per window configuration makes it different from Themes - that's system wide configuration.

Appearance property of TmacOSFormProp component is used to adjust the appearance.

Apple suggests that there are 3 appearance styles currently available in the system:

* NSAppearanceNameAqua
* NSAppearanceNameVibrantDark
* NSAppearanceNameVibrantLight

The property itself is a string. It is not restricted to these 3 options only. It's case-sensitive name of the appearance as provided by macOS.

The value of the property can be changed in design time as well as run-time. As soon as the value is changed, it's expected that the appearance of the form, is changed.

Note: if the form that's hosts TmacOSFormProp is embedded into another form, then the behavior is not defined. However, it's expected the parent form appearance would change.

Using TmacOSFormProp is not desired on any component other than form. I.e. it's possible to use it on a frame, but in that case, the appearance of the hosting would be changed.

In case multiple TmacOSFormProp are used, the later action would be used as preference. Multiple TmacOSFormProp are not desired for use, and might forbidden in future versions.


The implementation is checking for the presence of NSAppearance class dynamically. Thus, if the code is launched on an earlier version of macOS, it would still be able to run, even though will not do anything.

This is how the default Aqua style might look like:

macosformprop aqua.PNG

This is how the Dark style might look like:

macosformprop dark.PNG

(Note that some controls are not affected by Appearance - TMemo. This is macOS default behavior and expected result)

The actual style look as well style availability depends on a certain macOS version, and might change overtime at Apple's decision

You can refer to appearance sample application.

DocEdited

The property indicates if the window should reflect the document as "edited" (true) or not (false).

In systems other than macOS, a change in a document is typically indicated by adding asterisk character to the end of the window caption.

macOS provides a special UI behavior in this case.

macosformprop editted.png

To be Implemented

  • NSToolbar support

See Also