
/*
 ===============================================
 QUESTIONS:
 ===============================================
 - sizeToFit OR adjustSize or fitSize ?

 ===============================================
 TODO:
 ===============================================
 - Nice introduction https://github.com/stevestreza/Relayout

- min max
    - Think of align as a vertical invisible line running down the page. You can align the text 
      left on that invisible line, right on that invisible line or have the text centered on 
      that invisible line.
    - Justification is a lateral horizontal measurement based on one of two invisible vertical 
       lines - left and right for justified text or left only for unjustified text

    - Example with aView.pin.left().right().marginHorizontal(50).width(200).justify(.left / center / right)


- If a margin is specified but not its corresponding edge, we automatically pin this edge to its parent!
- If align/justify is specified but not its corresponding edges, we automatically pin these edges to its parent!

 - Unit Test for  
        margin(_ top: CGFloat, _ horizontal: CGFloat, _ bottom: CGFloat) -> PinLayout
        margin(_ top: CGFloat, _ right: CGFloat, _ bottom: CGFloat, _ left: CGFloat) -> PinLayout
        margin(_ vertical: CGFloat, _ horizontal: CGFloat) -> PinLayout

 - Add: How to handle traitCollection changes
 - Add: How to adjust parent size to match its childs
 - 

 - Add pin.bottomToContains(views: UIView....) Adjust the bottom to contains all specified UIViews.
   So that we don't have to do: 
        formContainerView.frame.size = CGSize(width: nameField.frame.width, 
                                               height: formTitleLabel.frame.maxY + margin)
    - pin.bottomToContains(views: UIView...)
    - pin.bottom(toContains: UIView...)

 - Add a section that describe example app

 - Add a doc example using width(40%).height(100%)
 - Add also an example using view.pin.top(25%).hCenter(0)

 - Add an image showing hCenter and vCenter (see http://doc.qt.io/qt-5/qtquick-positioning-anchors.html)

 - Antoine Lamy: Suggestion pour ton système de layout (pt déjà le cas): Utiliser une interface entre l'engin de layout et
    UIKit afin de potentiellement être capable de le bridger vers d'autres entitées visuelles qu'une 
    UIView (exemple: CALayer, NSView, ASDisplayNode, etc). L'engin n'a probablement à dealer qu'avec des 
    primitives de CoreGraphics.

    Cette abstraction a été fait dans le framework d'animation POP ce qui fait qu'on peut virtuellement animer 
    n'importe quelle valeur, qu'elle soit liée à une vue ou pas. Ça rend le truc vraiment flexible.
        https://github.com/facebook/pop


 - pinEdgesHorizontal, pinEdgesVertical ??
 - pin.edges(), pin.horizontalEdges(), pin.verticalEdges(), 
   pin.all(), pin.allHorizontal(), pin.allVertical()
   pin.view.fill(), pin.fillHorizontally(), pin.fillVertically()
   pin.toSuperview()

    * `allEdges()`  
    Position 
    * `verticalEdges()`  
    Position 
    * `horizontalEdges()`  
    Position 

 - Percentages  (see https://github.com/freshOS/Stevia/blob/master/Source/Stevia%2BPercentage.swift)
    pin.top(5%)
    pin.left(20%)
    pin.bottom(10%)
    pin.right(15%)
    
 - Add parameter to sizeToFit indiquant si on doit caster ou pas le résultat
 
 - max/max height/width
    - minWidth(CGFloat)
    - minWidth(Percent)
    - maxWidth(CGFloat)
    - maxWidth(Percent)
    - minHeight(CGFloat)
    - minHeight(Percent)
    - maxHeight(CGFloat)
    - maxHeight(Percent)

 - Add size(_ width: CGFloat, _ height: CGFloat)
 - Add size(widthAndHeight: CGFloat)

 - [view3, view2, view1].stack(axis: .horizontal, spacing: 3)

 - frame(of: UIView)
 - frame()
  
 - In CSS
        - negative width and height is not applied, also for percentages
        - right/bottom: negative value and percentage is applyed 
                right: -20px  increase the width by an extra 20 pixels
                right: -50%   increase the width by an extra 50% (width = parent's width * 1.50)
        - negative margins affect the top, left, bottom, right. pixel or percent

 
 - sizeToFit() devrait prendre un parametre indiquant si on doit caster les nouvelles valeur
     de width et de height (forceSize, castSize, ...?)
 
 - dans le calcul des coordonné, ajouter un referenceView is superview then ...
    optimisation
 
 - maxWidth(), minWidth(), maxHeight(), minHeight()
 
 - Unit tests TODO:
    - pinTopLeft(to: Pin, of: UIView), topCenter(to: Pin, of: UIView), ...
    - margins and insets negatifs
    - margin(t: l: b: r:)

 - With SwiftyAttributes, you can write the same thing like this:

        let fancyString = "Hello World!".withTextColor(.blue).withUnderlineStyle(.styleSingle)
    Alternatively, SwiftyAttributes provides an Attribute enum:
        let fancyString = "Hello World!".withAttributes([
            .backgroundColor(.magenta),
            .strokeColor(.orange),
            .strokeWidth(1),
            .baselineOffset(5.2)
        ])
 
 - Inspired by https://github.com/robb/Cartography
     // Other possible syntax
    layout(viewA) { viewA in {
        viewA.pinTopLeft(to: viewB.pin.topLeft).margin(20)
        viewA.width(20).height(20)
    }
 
 //constrain(button1, button2) { button1, button2 in
 //    button1.right == button2.left - 12
 //}
*/
