AUI Framework  develop
Cross-platform base for C++ UI apps
Loading...
Searching...
No Matches
AEmbedAuiWrap.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 6/6/2021.
   14//
   15
   16
   17#pragma once
   18
   19
   20#include <AUI/View/AViewContainer.h>
   21#include "AWindowBase.h"
   22
   28class API_AUI_VIEWS AEmbedAuiWrap: public IEventLoop {
   29private:
   30    IEventLoop::Handle mEventLoopHandle;
   31
   32protected:
   33    class EmbedWindow;
   34    _<EmbedWindow> mContainer;
   35    glm::ivec2 mSize;
   36    AOptional<float> mCustomDpiRatio;
   37    void windowInit(_unique<IRenderingContext> context);
   38    void windowMakeCurrent();
   39    void windowRender();
   40
   41    virtual void onNotifyProcessMessages() = 0;
   42public:
   43    explicit AEmbedAuiWrap();
   44
   45    void clearFocus();
   46
   47    void setContainer(const _<AViewContainer>& container);
   48    virtual void setViewportSize(int width, int height);
   49
   50    void setCustomDpiRatio(float r);
   51
   52    bool requiresRedraw();
   53
   54    void notifyProcessMessages() override;
   55
   59    bool isUIConsumesMouseAt(int x, int y);
   60
   67    void onPointerPressed(int x, int y, APointerIndex pointerIndex);
   68
   75    void onPointerReleased(int x, int y, APointerIndex pointerIndex);
   76
   82    void onPointerMove(int x, int y);
   83
   87    void onCharEntered(wchar_t c);
   88
   92    void onScroll(int mouseX, int mouseY, int scrollX, int scrollY);
   93
   94
   95    void onKeyPressed(AInput::Key key);
   96    void onKeyReleased(AInput::Key key);
   97
   98    AWindowBase* getWindow();
   99
  100    void loop() override;
  101};
  102
  103
void loop() override
Do message processing loop.
void onCharEntered(wchar_t c)
Handle char entered in UI.
void onPointerMove(int x, int y)
Handle mouse move in UI.
void onPointerReleased(int x, int y, APointerIndex pointerIndex)
Handle mouse released in UI.
void onScroll(int mouseX, int mouseY, int scrollX, int scrollY)
Handle onScroll in UI.
bool isUIConsumesMouseAt(int x, int y)
void onPointerPressed(int x, int y, APointerIndex pointerIndex)
Handle mouse pressed in UI.
void notifyProcessMessages() override
Notifies this IEventLoop that its thread got a new message to process.
Utility wrapper implementing the stack-allocated (fast) optional idiom.
Definition AOptional.h:33
Wrapper class that stores either mouse button index or finger index.
Definition APointerIndex.h:21
Definition AWindowBase.h:33
Definition IEventLoop.h:33
An std::weak_ptr with AUI extensions.
Definition SharedPtrTypes.h:179