A2FingerTransformArea#
Handles and processes the multitouch scale, transform and rotation events based on two-finger gestures.
Header: | #include <AUI/View/A2FingerTransformArea.h> |
CMake: | aui_link(my_target PUBLIC aui::views) |
Detailed Description#
Represents a translucent area that handles and processes multi-finger transformation gestures (i.e. pinch-to-zoom, move, rotate). A2FingerTransformArea is a container, so the transformed view should be somewhere inside. A2FingerTransformArea does not apply any transformation though, so you can control transformation behaviour.
The transformation data is emitted on delta basis via transform
signal. This allows to easily incorporate
A2FingerTransformArea to transforming routines, including limit handling.
Consider the following example, where the transformation is applied through ASS styles:
_<AView> multitouchDemo() {
return _new<A2FingerTransformArea>() AUI_LET {
it->setCustomStyle({
MinSize { 256_dp },
Border { 1_px, AColor::BLACK },
});
_<AView> blackRect = Stacked { _new<ALabel>("A2FingerTransformArea") AUI_WITH_STYLE {
FixedSize{200_dp, 100_dp},
BackgroundSolid{AColor::BLACK},
TextColor{AColor::WHITE},
ATextAlign::CENTER,
}};
ALayoutInflater::inflate(it, Stacked { blackRect });
connect(it->transformed, blackRect, [blackRect = blackRect.get(),
keptTransform = _new<A2DTransform>()](const A2DTransform& transform) {
keptTransform->applyDelta(transform);
blackRect->setCustomStyle({
TransformOffset{AMetric(keptTransform->offset.x, AMetric::T_PX),
AMetric(keptTransform->offset.y, AMetric::T_PX)},
TransformScale{keptTransform->scale},
TransformRotate{keptTransform->rotation},
});
});
};
}
This example renders to the following result: