AUI Framework  develop
Cross-platform base for C++ UI apps
Loading...
Searching...
No Matches
ADragArea.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//
13// Created by alex2 on 29.11.2020.
14//
15
16#pragma once
17
18
19#include "AViewContainer.h"
20
26class API_AUI_VIEWS ADragArea: public AViewContainer {
27private:
28 _weak<AViewContainerBase> mDraggedContainer;
29 glm::ivec2 mInitialMousePos;
30
31
32 void setValidPositionFor(const _<AView>& targetView, const glm::ivec2& newPosition);
33public:
34 ADragArea();
35 void startDragging(AViewContainerBase* container);
36 void handleMouseMove();
37
38 void endDragging();
39
40 void applyGeometryToChildren() override;
41
42 class API_AUI_VIEWS ADraggableHandle: public AViewContainerBase {
43 friend class ADragArea;
44 private:
45 std::tuple<ADragArea*, AViewContainerBase*> getDragAreaAndDraggingView();
46 bool mDragging = false;
47 bool mCheckForClickConsumption = true;
48
49 public:
50 ADraggableHandle(bool checkForClickConsumption = false) : mCheckForClickConsumption(checkForClickConsumption) {}
51
52 void onPointerPressed(const APointerPressedEvent& event) override;
53 void onPointerReleased(const APointerReleasedEvent& event) override;
54
55 signals:
56 emits<glm::ivec2> mouseMove;
57 };
58
59 static _<AView> convertToDraggable(const _<AView>& view, bool checkForClickConsumption = true);
60 static _<ADraggableHandle> convertToDraggableContainer(const _<AViewContainer>& view, bool checkForClickConsumption = true);
61};
62
63
void onPointerPressed(const APointerPressedEvent &event) override
Called on pointer (mouse) released event.
Definition AViewContainerBase.cpp:289
void onPointerReleased(const APointerReleasedEvent &event) override
Called on pointer (mouse) released event.
Definition AViewContainerBase.cpp:329
An std::weak_ptr with AUI extensions.
Definition SharedPtrTypes.h:178
ASignal< Args... > emits
A signal declaration.
Definition ASignal.h:348
Pointing method press event.
Definition APointerPressedEvent.h:21
Pointing method press event.
Definition APointerReleasedEvent.h:19
An std::weak_ptr with AUI extensions.
Definition SharedPtrTypes.h:51