AUI Framework  master
Cross-platform module-based framework for developing C++20 desktop applications
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
Slider control.
Definition: ASlider.h:22
A view that represents a set of views.
Definition: AViewContainerBase.h:68
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
void onPointerReleased(const APointerReleasedEvent &event) override
Called on pointer (mouse) released event.
Definition: AViewContainerBase.cpp:327
bool capturesFocus() override
Definition: AViewContainerBase.cpp:543
Base class of all UI objects.
Definition: AView.h:77
An std::weak_ptr with AUI extensions.
Definition: SharedPtrTypes.h:177
Pointing method move event.
Definition: APointerMoveEvent.h:21
Pointing method press event.
Definition: APointerPressedEvent.h:21
Pointing method press event.
Definition: APointerReleasedEvent.h:19
Clamps the possible values for a number to the specified range: [min;max].
Definition: values.h:452