-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Transform cleanup #13452
Transform cleanup #13452
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1579,7 +1579,7 @@ - (void)handlePinchGesture:(UIPinchGestureRecognizer *)pinch | |
{ | ||
CLLocationCoordinate2D centerCoordinate = _previousPinchCenterCoordinate; | ||
self.mbglMap.setLatLng(MGLLatLngFromLocationCoordinate2D(centerCoordinate), | ||
mbgl::ScreenCoordinate { centerPoint.x, centerPoint.y }); | ||
mbgl::EdgeInsets { centerPoint.y, centerPoint.x, self.size.height - centerPoint.y, self.size.width - centerPoint.x }); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's this line doing? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It’s still adjusting the frame of reference for the center coordinate, but now it does so by padding all four sides so that the padding covers the entire view, instead of setting an anchor point explicitly. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes - as @1ec5 mentioned, this was previously done inside an overload for |
||
} | ||
} | ||
[self cameraIsChanging]; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the past, we avoided designated initializer lists because certain compilers we targeted didn’t support them. Is that still the case, or could we use designated initializer lists instead of the builder pattern?
Both syntaxes provide more clarity than unlabeled constructor parameters, but I find designated initializer lists to be more elegant. We already use designated initializer lists liberally in Objective-C++ code in platform/{darwin,ios,macos}/, since Clang supports them as an extension to C++. For example:
mapbox-gl-native/platform/darwin/src/MGLGeometry.mm
Lines 114 to 119 in 0addd51
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Though I'm quite fond of designated initializer lists too, this technique is a bit different as it links chained setters via a reference to the
CameraOptions
object, but the constructor still remains empty. In C++, support for designated initializers comes in C++20, so it'll take a while until all our supported platforms can get availability on this.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For future reference, Clang has supported designated initializers in C++ for years as an extension to the C++ standard. GCC at some point introduced support for “trivial designated initializers”, which means the fields have to come in the same order as they’re declared, like in Swift.
/ref #26 #4722