AUI Framework  develop
Cross-platform base for C++ UI apps
Loading...
Searching...
No Matches
ASplitter.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#include <AUI/Util/ALayoutDirection.h>
   15#include <AUI/Layout/AVerticalLayout.h>
   16#include <AUI/Layout/AHorizontalLayout.h>
   17#include "AViewContainer.h"
   18#include "AHDividerView.h"
   19#include "AVDividerView.h"
   20#include "ASplitterHelper.h"
   21#include <AUI/View/ASpacerExpanding.h>
   22
   45class API_AUI_VIEWS ASplitter: public AViewContainerBase
   46{
   47public:
   48    virtual ~ASplitter() = default;
   49
   50    void onPointerPressed(const APointerPressedEvent& event) override;
   51
   52    void onPointerMove(glm::vec2 pos, const APointerMoveEvent& event) override;
   53
   54    void setSize(glm::ivec2 size) override;
   55
   56    void onPointerReleased(const APointerReleasedEvent& event) override;
   57
   58    void onClickPrevented() override;
   59
   60    template<typename Layout>
   61    class Builder;
   62    using Vertical = Builder<AVerticalLayout>;
   63    using Horizontal = Builder<AHorizontalLayout>;
   64
   65private:
   66    template<typename Layout>
   67    friend class Builder;
   68
   69    ASplitterHelper mHelper;
   70
   71    ASplitter();
   72
   73};
   74
   75template<typename Layout>
   77    friend class ASplitter;
   78private:
   79    AVector<_<AView>> mItems;
   80    glm::ivec2 mExpanding{};
   81
   82public:
   83    Builder& withItems(AVector<_<AView>> items) {
   84        mItems = std::move(items);
   85        return *this;
   86    }
   87
   88    Builder& withExpanding(glm::ivec2 expanding = { 2, 2 }) {
   89        mExpanding = expanding;
   90        return *this;
   91    }
   92
   93    API_AUI_VIEWS _<AView> build();
   94
   95    operator _<AView>() {
   96        return build();
   97    }
   98};
Definition ASplitterHelper.h:18
Definition ASplitter.h:76
void onPointerMove(glm::vec2 pos, const APointerMoveEvent &event) override
Handles pointer hover events.
void onPointerPressed(const APointerPressedEvent &event) override
Called on pointer (mouse) released event.
void onClickPrevented() override
Called on AWindowBase::preventClickOnPointerRelease.
void onPointerReleased(const APointerReleasedEvent &event) override
Called on pointer (mouse) released event.
A std::vector with AUI extensions.
Definition AVector.h:39
auto expanding() const
Expansion coefficient. Hints layout manager how much this AView should be extended relative to other ...
Definition AView.h:134
auto size() const
Size, including content area, border and padding.
Definition AView.h:114
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