AUI Framework  develop
Cross-platform base for C++ UI apps
Loading...
Searching...
No Matches
APathChooserView.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//
   13// Created by alex2 on 15.04.2021.
   14//
   15
   16
   17#pragma once
   18
   19#include <AUI/Platform/ADesktop.h>
   20#include <AUI/Thread/AAsyncHolder.h>
   21#include "AViewContainer.h"
   22#include "ATextField.h"
   23
   28class API_AUI_VIEWS AFileChooserView: public AViewContainerBase {
   29private:
   30    _<ATextField> mPathField;
   31    AAsyncHolder mAsync;
   32
   33public:
   34    explicit AFileChooserView(const APath& defaultPath = "", AVector<ADesktop::FileExtension> extensions = { {"All", "*"} });
   35
   36    void setPath(const APath& path);
   37    APath getPath() const;
   38
   39    auto path() {
   40        return APropertyDef {
   41            this,
   42            &AFileChooserView::getPath,
   43            &AFileChooserView::setPath,
   44            changed,
   45        };
   46    }
   47
   48signals:
   49    emits<APath> changed;
   50};
   51
   52
   53
   54template<>
   56public:
   57    static auto setup(const _<AFileChooserView>& v) {}
   58
   59    static auto property(const _<AFileChooserView>& v) {
   60        return v->path();
   61    }
   62
   63    static auto getGetter() {
   64        return &AFileChooserView::changed;
   65    }
   66    static auto getSetter() {
   67        return &AFileChooserView::setPath;
   68    }
   69};
   70
   75class API_AUI_VIEWS ADirChooserView: public AViewContainerBase {
   76private:
   77    _<ATextField> mPathField;
   78    AAsyncHolder mAsync;
   79
   80public:
   81    explicit ADirChooserView(const APath& defaultPath = "");
   82
   83    void setPath(const APath& path);
   84    APath getPath() const;
   85
   86    auto path() {
   87        return APropertyDef {
   88            this,
   89            &ADirChooserView::getPath,
   90            &ADirChooserView::setPath,
   91            changed,
   92        };
   93    }
   94
   95signals:
   96    emits<APath> changed;
   97};
   98
   99
  100
  101template<>
  103public:
  104    static auto setup(const _<ADirChooserView>& v) {}
  105
  106    static auto property(const _<ADirChooserView>& v) {
  107        return v->path();
  108    }
  109
  110    static auto getGetter() {
  111        return &ADirChooserView::changed;
  112    }
  113    static auto getSetter() {
  114        return &ADirChooserView::setPath;
  115    }
  116};
  117
  118using APathChooserView [[deprecated("APathChooserView was renamed to ADirChooserView")]] = ADirChooserView;
Holds a set of futures keeping them valid.
Definition AAsyncHolder.h:31
A text field with "..." button prompting path to a dir.
Definition APathChooserView.h:75
A text field with "..." button prompting path to a file.
Definition APathChooserView.h:28
An add-on to AString with functions for working with the path.
Definition APath.h:128
A std::vector with AUI extensions.
Definition AVector.h:39
An std::weak_ptr with AUI extensions.
Definition SharedPtrTypes.h:215
ASignal< Args... > emits
A signal declaration.
Definition ASignal.h:577
Defines how View handles properties of FieldType type.
Definition ADataBinding.h:38
static void(View::*)(const FieldType &v) getSetter()
Returns setter for ADataBinding (deprecated)
Definition ADataBinding.h:64
static void setup(const _< View > &view)
Called then view linked with field.
Definition ADataBinding.h:44
static auto property(const _< View > &view)
Returns property definition for FieldType.
Definition ADataBinding.h:50
static ASignal< FieldType >View::* getGetter()
Returns getter for ADataBinding (deprecated)
Definition ADataBinding.h:56
Property implementation to use with custom getter/setter.
Definition APropertyDef.h:23