AUI Framework  develop
Cross-platform base for C++ UI apps
Loading...
Searching...
No Matches
ACursor.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 <variant>
   16#include <AUI/Image/AImage.h>
   17#include "AUI/Image/IDrawable.h"
   18
   19class AWindow;
   20
   25class API_AUI_VIEWS ACursor
   26{
   27public:
   28    enum System {
   34        DEFAULT,
   35
   41        POINTER,
   42
   48        TEXT,
   49
   55        MOVE,
   56
   62        EW_RESIZE,
   63
   69        NS_RESIZE,
   70    };
   71
   72    ACursor(System systemCursor): mValue(systemCursor) {}
   73    explicit ACursor(AImageView image, int size = 16);
   74    explicit ACursor(aui::non_null<_<IDrawable>> drawable, int size = 16);
   75    explicit ACursor(AUrl imageUrl, int size = 16);
   76
   77    ~ACursor();
   78
   79    void applyNativeCursor(AWindow* pWindow) const;
   80
   81    struct Custom {
   82        virtual ~Custom() = default;
   83    };
   84    const std::variant<System, _<Custom>, _<IDrawable>>& value() const { return mValue; }
   85    int size() const { return mSize; }
   86
   87private:
   88    std::variant<System, _<Custom>, _<IDrawable>> mValue;
   89    int mSize;
   90};
Represents cursor type.
Definition ACursor.h:26
System
Definition ACursor.h:28
@ MOVE
Something to be moved. Crosshair-like cursor.
Definition ACursor.h:55
@ TEXT
'I' beam.
Definition ACursor.h:48
@ DEFAULT
Default arrow.
Definition ACursor.h:34
@ NS_RESIZE
Bidirectional resize cursor north-south.
Definition ACursor.h:69
@ EW_RESIZE
Bidirectional resize cursor east-west. <->
Definition ACursor.h:62
@ POINTER
Pointing finger.
Definition ACursor.h:41
Represents a window in the underlying windowing system.
Definition AWindow.h:45
An std::weak_ptr with AUI extensions.
Definition SharedPtrTypes.h:179
Definition ACursor.h:81