AUI Framework  master
Cross-platform module-based framework for developing C++20 desktop applications
A2FingerTransformArea.h
1/*
2 * AUI Framework - Declarative UI toolkit for modern C++20
3 * Copyright (C) 2020-2024 Alex2772 and Contributors
4 *
5 * SPDX-License-Identifier: MPL-2.0
6 *
7 * This Source Code Form is subject to the terms of the Mozilla Public
8 * License, v. 2.0. If a copy of the MPL was not distributed with this
9 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 */
11
12#pragma once
13
14#include "AUI/View/AViewContainer.h"
15#include "AView.h"
16#include "AUI/Util/AAngleRadians.h"
17
18
20 glm::vec2 offset = {0.f, 0.f};
21 AAngleRadians rotation;
22 float scale = 1.f;
23
24
25 void applyDelta(const A2DTransform& other) {
26 scale *= other.scale;
27 offset += other.offset;
28 rotation += other.rotation;
29 }
30};
31
76class API_AUI_VIEWS A2FingerTransformArea: public AViewContainer
77{
78public:
80
81 void onPointerPressed(const APointerPressedEvent& event) override;
82 void onPointerMove(glm::vec2 pos, const APointerMoveEvent& event) override;
83 void onPointerReleased(const APointerReleasedEvent& event) override;
84
85 bool consumesClick(const glm::ivec2& pos) override;
86
87signals:
88 emits<A2DTransform> transformed;
89
90private:
91 struct TrackedPoint {
92 glm::vec2 pos;
93 APointerIndex pointerIndex;
94 };
95 ASmallVector<TrackedPoint, 8> mTrackedPoints;
96
97};
Handles and processes the multitouch scale, transform and rotation events based on two-finger gesture...
Definition: A2FingerTransformArea.h:77
Strong type used to store angle in radians.
Definition: AAngleRadians.h:42
Wrapper class that stores either mouse button index or finger index.
Definition: APointerIndex.h:21
Vector-like container consisting of few elements on stack and switches to dynamic allocation vector i...
Definition: ASmallVector.h:34
void onPointerPressed(const APointerPressedEvent &event) override
Called on pointer (mouse) released event.
Definition: AViewContainerBase.cpp:287
void onPointerMove(glm::vec2 pos, const APointerMoveEvent &event) override
Handles pointer hover events.
Definition: AViewContainerBase.cpp:242
bool consumesClick(const glm::ivec2 &pos) override
Determines whether this AView processes this click or passes it thru.
Definition: AViewContainerBase.cpp:369
void onPointerReleased(const APointerReleasedEvent &event) override
Called on pointer (mouse) released event.
Definition: AViewContainerBase.cpp:327
A trivial modifiable view that represents a set of views.
Definition: AViewContainer.h:33
Definition: A2FingerTransformArea.h:19
Pointing method move event.
Definition: APointerMoveEvent.h:21
Pointing method press event.
Definition: APointerPressedEvent.h:21
Pointing method press event.
Definition: APointerReleasedEvent.h:19