AUI Framework  develop
Cross-platform base for C++ UI apps
Loading...
Searching...
No Matches
AGridSplitter.h
    1/*
    2 * AUI Framework - Declarative UI toolkit for modern C++20
    3 * Copyright (C) 2020-2025 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 "ASplitterHelper.h"
   17#include <AUI/Util/UIBuildingHelpers.h>
   18
   26class API_AUI_VIEWS AGridSplitter: public AViewContainerBase {
   27public:
   28    friend class AGridSplitterLayout;
   29    class Builder {
   30        friend class ASplitter;
   31    private:
   32        AVector<AVector<_<AView>>> mItems;
   33        bool mAddSpacers = true;
   34
   35    public:
   36        Builder& withItems(AVector<AVector<_<AView>>> items) {
   37            mItems = std::move(items);
   38            return *this;
   39        }
   40
   41        Builder& noDefaultSpacers() {
   42            mAddSpacers = false;
   43            return *this;
   44        }
   45
   46        _<AView> build() {
   47            auto splitter = aui::ptr::manage(new AGridSplitter);
   48            if (mAddSpacers) {
   49                for (auto& row: mItems) {
   50                    row.push_back(_new<ASpacerExpanding>());
   51                }
   52                mItems.push_back(
   53                        AVector<_<AView>>::generate(mItems.first().size(), [](size_t) { return _new<ASpacerExpanding>(); }));
   54            }
   55            splitter->mItems = std::move(mItems);
   56            splitter->updateSplitterItems();
   57            return splitter;
   58        }
   59
   60        operator _<AView>() {
   61            return build();
   62        }
   63    };
   64
   65private:
   66    friend class Builder;
   67    AVector<AVector<_<AView>>> mItems;
   68    ASplitterHelper mHorizontalHelper;
   69    ASplitterHelper mVerticalHelper;
   70
   71    AGridSplitter();
   72
   73    glm::bvec2 isDraggingArea(glm::ivec2 position);
   74
   75public:
   76    void updateSplitterItems();
   77
   78    void onPointerPressed(const APointerPressedEvent& event) override;
   79
   80    void onPointerMove(glm::vec2 pos, const APointerMoveEvent& event) override;
   81
   82    void onPointerReleased(const APointerReleasedEvent& event) override;
   83
   84    bool consumesClick(const glm::ivec2& pos) override;
   85};
   86
   87
Definition AGridSplitter.h:29
void onPointerMove(glm::vec2 pos, const APointerMoveEvent &event) override
Handles pointer hover events.
void onPointerReleased(const APointerReleasedEvent &event) override
Called on pointer (mouse) released event.
void onPointerPressed(const APointerPressedEvent &event) override
Called on pointer (mouse) released event.
bool consumesClick(const glm::ivec2 &pos) override
Determines whether this AView processes this click or passes it thru.
Definition ASplitterHelper.h:18
A std::vector with AUI extensions.
Definition AVector.h:39
auto position() const
Top left corner's position relative to top left corner's position of the parent AView.
Definition AView.h:102
An std::weak_ptr with AUI extensions.
Definition SharedPtrTypes.h:179
Pointing method move event.
Definition APointerMoveEvent.h:21
Pointing method press event.
Definition APointerPressedEvent.h:21
Pointing method press event.
Definition APointerReleasedEvent.h:19
static _< T > manage(T *raw)
Delegates memory management of the raw pointer T* raw to the shared pointer, which is returned.
Definition SharedPtrTypes.h:424