Skip to content

Commit 0fc43a2

Browse files
committed
Views and Control: add some extensions for layouts
Add the declarations for the subview layout operations. These are triggered through the `SplitViewController`.
1 parent 31c9f78 commit 0fc43a2

File tree

1 file changed

+73
-0
lines changed

1 file changed

+73
-0
lines changed

Sources/SwiftWin32/Views and Controls/View.swift

+73
Original file line numberDiff line numberDiff line change
@@ -919,6 +919,79 @@ public class View: Responder {
919919
set { fatalError("\(#function) not yet implemented") }
920920
}
921921

922+
// MARK - Laying Out Subviews
923+
924+
/// Lays out subviews.
925+
///
926+
/// The default implementation uses any constraints you have set to determine
927+
/// the size and position of any subviews.
928+
///
929+
/// Subclasses can override this method as needed to perform more precise
930+
/// layout of their subviews. You should override this method only if the
931+
/// autoresizing and constraint-based behaviors of the subviews do not offer
932+
/// the behavior you want. You can use your implementation to set the frame
933+
/// rectangles of your subviews directly.
934+
///
935+
/// You should not call this method directly. If you want to force a layout
936+
/// update, call the `setNeedsLayout()` method instead to do so prior to the
937+
/// next drawing update. If you want to update the layout of your views
938+
/// immediately, call the `layoutIfNeeded()` method.
939+
public func layoutSubviews() {
940+
fatalError("\(#function) not yet implemented")
941+
}
942+
943+
/// Invalidates the current layout of the receiver and triggers a layout
944+
/// update during the next update cycle.
945+
///
946+
/// Call this method on your application's main thread when you want to adjust
947+
/// the layout of a view's subviews. This method makes a note of the request
948+
/// and returns immediately. Because this method does not force an immediate
949+
/// update, but instead waits for the next update cycle, you can use it to
950+
/// invalidate the layout of multiple views before any of those views are
951+
/// updated. This behavior allows you to consolidate all of your layout
952+
/// updates to one update cycle, which is usually better for performance.
953+
public func setNeedsLayout() {
954+
fatalError("\(#function) not yet implemented")
955+
}
956+
957+
/// Lays out the subviews immediately, if layout updates are pending.
958+
///
959+
/// Use this method to force the view to update its layout immediately. When
960+
/// using Auto Layout, the layout engine updates the position of views as
961+
/// needed to satisfy changes in constraints. Using the view that receives the
962+
/// message as the root view, this method lays out the view subtree starting
963+
/// at the root. If no layout updates are pending, this method exits without
964+
/// modifying the layout or calling any layout-related callbacks.
965+
public func layoutIfNeeded() {
966+
fatalError("\(#function) not yet implemented")
967+
}
968+
969+
/// A boolean value that indicates whether the receiver depends on the
970+
/// constraint-based layout system.
971+
///
972+
/// Custom views should override this to return true if they cannot layout
973+
/// correctly using autoresizing.
974+
public class var requiresConstraintBasedLayout: Bool { false }
975+
976+
/// A boolean value that determines whether the view's autoresizing mask is
977+
/// translated into Auto Layout constraints.
978+
///
979+
/// If this property's value is `true`, the system creates a set of
980+
/// constraints that duplicate the behavior specified by the view's
981+
/// autoresizing mask. This also lets you modify the view's size and location
982+
/// using the view's `frame`, `bounds`, or `center` properties, allowing you
983+
/// to create a static, frame-based layout within Auto Layout.
984+
///
985+
/// Note that the autoresizing mask constraints fully specify the view's size
986+
/// and position; therefore, you cannot add additional constraints to modify
987+
/// this size or position without introducing conflicts. If you want to use
988+
/// Auto Layout to dynamically calculate the size and position of your view,
989+
/// you must set this property to `false`, and then provide a non ambiguous,
990+
/// nonconflicting set of constraints for the view.
991+
///
992+
/// By default, the property is set to `true`.
993+
public var translatesAutoresizingMaskIntoConstraints: Bool = true
994+
922995
// MARK - Adding and Removing Interactions
923996

924997
/// Adds an interaction to the view.

0 commit comments

Comments
 (0)