VisualFoundation Framework


(Jon Hull) #1

Hi Everyone,

I am not sure whether Swift Evolution’s charter extends to the common foundation framework which will be distributed with Swift (If not, then I hope this request reaches the right people).

I would like to see another open framework distributed with Foundation that holds common base UI related objects. Mainly Color, AttributedString, and Image. I have a lot of code that needs to include UIKit or Cocoa only because of these 3 classes (NS/UIColor, etc…). It would be extremely helpful to be able to use the same code for these across platforms, but they are all visual ideas, and thus are not included in Foundation. If we had a small framework for visual base classes that sits above foundation, a large portion of my code would port to Linux and Windows (if that ends up happening) without changes. This would NOT include platform specific ideas like Views or windows… just the basics of things that are meant to be cross-platform like color, image, and styled text. UIKit and Cocoa would then import this framework and alias NS/UIColor, etc… to it (or at least make them interoperate).

Thoughts?

Thanks,
Jon


(TJ Usiyan) #2

Bezier Paths, CGPoint, CGFloat, CGRect, and something to represent the
origin location would be nice.

···

On Wed, May 31, 2017 at 10:48 PM, Jonathan Hull via swift-evolution < swift-evolution@swift.org> wrote:

Hi Everyone,

I am not sure whether Swift Evolution’s charter extends to the common
foundation framework which will be distributed with Swift (If not, then I
hope this request reaches the right people).

I would like to see another open framework distributed with Foundation
that holds common base UI related objects. Mainly Color, AttributedString,
and Image. I have a lot of code that needs to include UIKit or Cocoa only
because of these 3 classes (NS/UIColor, etc…). It would be extremely
helpful to be able to use the same code for these across platforms, but
they are all visual ideas, and thus are not included in Foundation. If we
had a small framework for visual base classes that sits above foundation, a
large portion of my code would port to Linux and Windows (if that ends up
happening) without changes. This would NOT include platform specific ideas
like Views or windows… just the basics of things that are meant to be
cross-platform like color, image, and styled text. UIKit and Cocoa would
then import this framework and alias NS/UIColor, etc… to it (or at least
make them interoperate).

Thoughts?

Thanks,
Jon
_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution


(Alex Blewitt) #3

These are Apple frameworks, rather than Swift, and so discussion should probably be on the Apple mailing lists instead. In the interim there isn't anything preventing you from having a library that does the appropriate platform-specific #if test, and then uses typealias to associate an identifier such as GenericColor with your NSColor or UIColor as appropriate.

Alex

···

On 1 Jun 2017, at 03:48, Jonathan Hull via swift-evolution <swift-evolution@swift.org> wrote:

Hi Everyone,

I am not sure whether Swift Evolution’s charter extends to the common foundation framework which will be distributed with Swift (If not, then I hope this request reaches the right people).

I would like to see another open framework distributed with Foundation that holds common base UI related objects. Mainly Color, AttributedString, and Image. I have a lot of code that needs to include UIKit or Cocoa only because of these 3 classes (NS/UIColor, etc…). It would be extremely helpful to be able to use the same code for these across platforms, but they are all visual ideas, and thus are not included in Foundation.


(Jon Hull) #4

I could be wrong, but my understanding is that Foundation is being open sourced as well, and distributed with Swift across various platforms.

I can make my own framework, but it wouldn’t be portable in the same way. You couldn’t use my code on Linux, Windows, or even the Watch/TV unless I directly wrote code for it. With a common base that we can all write to, everyone's code is portable across platforms without changes.

Thanks,
Jon

···

On Jun 1, 2017, at 1:37 AM, Alex Blewitt <alblue@apple.com> wrote:

On 1 Jun 2017, at 03:48, Jonathan Hull via swift-evolution <swift-evolution@swift.org> wrote:

Hi Everyone,

I am not sure whether Swift Evolution’s charter extends to the common foundation framework which will be distributed with Swift (If not, then I hope this request reaches the right people).

I would like to see another open framework distributed with Foundation that holds common base UI related objects. Mainly Color, AttributedString, and Image. I have a lot of code that needs to include UIKit or Cocoa only because of these 3 classes (NS/UIColor, etc…). It would be extremely helpful to be able to use the same code for these across platforms, but they are all visual ideas, and thus are not included in Foundation.

These are Apple frameworks, rather than Swift, and so discussion should probably be on the Apple mailing lists instead. In the interim there isn't anything preventing you from having a library that does the appropriate platform-specific #if test, and then uses typealias to associate an identifier such as GenericColor with your NSColor or UIColor as appropriate.

Alex


(Alex Blewitt) #5

It is already open source; the source code for the Swift/Linux port is here:

https://github.com/apple/swift-corelibs-foundation

However, Foundation has never contained any UI code, which on macOS is in the Cocoa framework and on iOS in the UIKit framework. These are both Apple frameworks, which you can discuss on the Apple mailing lists. To find the appropriate one, you can consult https://lists.apple.com/mailman/listinfo - I would suggest the cocoa-dev mailing list.

Alex

···

On 1 Jun 2017, at 09:57, Jonathan Hull <jhull@gbis.com> wrote:

I could be wrong, but my understanding is that Foundation is being open sourced as well, and distributed with Swift across various platforms.


(Jon Hull) #6

I am not suggesting open sourcing UIKit or Cocoa (or any platform specific UI code). I am suggesting creating a very small open source swift-corelib that sits on top of foundation, and adds basic visual concepts like Color, Image, AttributedText, and (hat tip to T.J.) BezierPaths. Things where the concepts themselves are completely cross-platform, and they really should be in foundation, except that they are visual concepts, and thus got packaged with the whole platform framework for historical reasons.

Thanks,
Jon

···

On Jun 1, 2017, at 2:53 AM, Alex Blewitt <alblue@apple.com> wrote:

On 1 Jun 2017, at 09:57, Jonathan Hull <jhull@gbis.com <mailto:jhull@gbis.com>> wrote:

I could be wrong, but my understanding is that Foundation is being open sourced as well, and distributed with Swift across various platforms.

It is already open source; the source code for the Swift/Linux port is here:

https://github.com/apple/swift-corelibs-foundation

However, Foundation has never contained any UI code, which on macOS is in the Cocoa framework and on iOS in the UIKit framework. These are both Apple frameworks, which you can discuss on the Apple mailing lists. To find the appropriate one, you can consult https://lists.apple.com/mailman/listinfo - I would suggest the cocoa-dev mailing list.

Alex


(Erica Sadun) #7

These are inherently cross-platform concepts that can be represented both as literals (like the current color, file, and image) or as Swift-specific types, allowing the realization details to be pushed to platforms (macOS, iOS, common linux libraries).

Some ideas about literals here: https://gist.github.com/erica/c92f6ab115af89d5c4b9161487df6a3c
Some ideas about types and functionality for core graphics here: https://github.com/erica/SwiftGeometry/tree/master/Sources

If this idea has traction, it probably needs to be a separate development list or working group.

-- E

···

On Jun 1, 2017, at 5:33 AM, Jonathan Hull via swift-evolution <swift-evolution@swift.org> wrote:

I am not suggesting open sourcing UIKit or Cocoa (or any platform specific UI code). I am suggesting creating a very small open source swift-corelib that sits on top of foundation, and adds basic visual concepts like Color, Image, AttributedText, and (hat tip to T.J.) BezierPaths. Things where the concepts themselves are completely cross-platform, and they really should be in foundation, except that they are visual concepts, and thus got packaged with the whole platform framework for historical reasons.

Thanks,
Jon

On Jun 1, 2017, at 2:53 AM, Alex Blewitt <alblue@apple.com <mailto:alblue@apple.com>> wrote:

On 1 Jun 2017, at 09:57, Jonathan Hull <jhull@gbis.com <mailto:jhull@gbis.com>> wrote:

I could be wrong, but my understanding is that Foundation is being open sourced as well, and distributed with Swift across various platforms.

It is already open source; the source code for the Swift/Linux port is here:

https://github.com/apple/swift-corelibs-foundation

However, Foundation has never contained any UI code, which on macOS is in the Cocoa framework and on iOS in the UIKit framework. These are both Apple frameworks, which you can discuss on the Apple mailing lists. To find the appropriate one, you can consult https://lists.apple.com/mailman/listinfo - I would suggest the cocoa-dev mailing list.

Alex

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution


(TJ Usiyan) #8

I would like to emphasize how much I would appreciate a standard type such
as this

public enum OriginLocation {
    case lowerLeft
    case upperLeft

    #if os(OSX)
    public static let defaultPlatformLocation: OriginLocation = .lowerLeft
    #endif

    #if os(iOS)
    public static let defaultPlatformLocation: OriginLocation = .upperLeft
    #endif
}
···

On Thu, Jun 1, 2017 at 7:33 AM, Jonathan Hull via swift-evolution < swift-evolution@swift.org> wrote:

I am not suggesting open sourcing UIKit or Cocoa (or any platform specific
UI code). I am suggesting creating a very small open source swift-corelib
that sits on top of foundation, and adds basic visual concepts like Color,
Image, AttributedText, and (hat tip to T.J.) BezierPaths. Things where the
concepts themselves are completely cross-platform, and they really should
be in foundation, except that they are visual concepts, and thus got
packaged with the whole platform framework for historical reasons.

Thanks,
Jon

On Jun 1, 2017, at 2:53 AM, Alex Blewitt <alblue@apple.com> wrote:

On 1 Jun 2017, at 09:57, Jonathan Hull <jhull@gbis.com> wrote:

I could be wrong, but my understanding is that Foundation is being open
sourced as well, and distributed with Swift across various platforms.

It is already open source; the source code for the Swift/Linux port is
here:

https://github.com/apple/swift-corelibs-foundation

However, Foundation has never contained any UI code, which on macOS is in
the Cocoa framework and on iOS in the UIKit framework. These are both Apple
frameworks, which you can discuss on the Apple mailing lists. To find the
appropriate one, you can consult https://lists.apple.com/mailman/listinfo -
I would suggest the cocoa-dev mailing list.

Alex

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution