AUI Framework  develop
Cross-platform base for C++ UI apps
Loading...
Searching...
No Matches
ASlider.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
15#include "AViewContainer.h"
16#include "AProgressBar.h"
17
22class API_AUI_VIEWS ASlider: public AViewContainerBase {
23public:
24 class Handle: public AView {}; // embed class for styling
25
26 ASlider();
27 void onPointerMove(glm::vec2 pos, const APointerMoveEvent& event) override;
28 void onPointerPressed(const APointerPressedEvent& event) override;
29 void onPointerReleased(const APointerReleasedEvent& event) override;
30 void applyGeometryToChildren() override;
31 bool capturesFocus() override;
32
33 [[nodiscard]]
34 bool isDragging() const noexcept {
35 return isPressed();
36 }
37
38 void setValue(aui::float_within_0_1 value) {
39 mProgress->setValue(value);
40 }
41
42 [[nodiscard]]
43 aui::float_within_0_1 value() const noexcept {
44 return mProgress->value();
45 }
46
47 [[nodiscard]]
48 const _<Handle>& handle() const noexcept {
49 return mHandle;
50 }
51
52 [[nodiscard]]
53 const _<AProgressBar>& progressbar() const noexcept {
54 return mProgress;
55 }
56
57signals:
58 emits<aui::float_within_0_1> valueChanging;
60
61private:
62 _<Handle> mHandle;
63 _<AProgressBar> mProgress;
64
65 void updateSliderWithPosition(glm::ivec2 pointerPosition);
66
67 void updateHandlePosition();
68};
Definition ASlider.h:24
void onPointerPressed(const APointerPressedEvent &event) override
Called on pointer (mouse) released event.
Definition AViewContainerBase.cpp:289
void onPointerMove(glm::vec2 pos, const APointerMoveEvent &event) override
Handles pointer hover events.
Definition AViewContainerBase.cpp:244
void onPointerReleased(const APointerReleasedEvent &event) override
Called on pointer (mouse) released event.
Definition AViewContainerBase.cpp:329
bool capturesFocus() override
Definition AViewContainerBase.cpp:547
ASignal< Args... > emits
A signal declaration.
Definition ASignal.h:348
Pointing method move event.
Definition APointerMoveEvent.h:21
Pointing method press event.
Definition APointerPressedEvent.h:21
Pointing method press event.
Definition APointerReleasedEvent.h:19