Skip to content

AEmbedContext#

Helper for applications with custom window initialization.

Header:#include <AUI/Platform/AEmbedContext.h>
CMake:aui_link(my_target PUBLIC aui::views)

Detailed Description#

This class is abstract; use AGLEmbedContext or ASoftwareEmbedAuiWrap instead.

Public Types#


EmbedWindow#

class AEmbedContext::EmbedWindow

Empty structure.

Public Methods#

isUIConsumesMouseAt#


bool AEmbedContext::isUIConsumesMouseAt(int x, int y)
Returns
true if UI is opaque for mouse at specified position

onCharEntered#


void AEmbedContext::onCharEntered(AChar c)

Handle char entered in UI.

Examples:

examples/ui/embedded_sdl/src/main.cpp

SDL3 - This code demonstrates how to integrate the AUI Framework with SDL3 to create a window with OpenGL rendering.

            AUtf8ConstIterator it(text);
            AUtf8ConstIterator it_end(text, text.size());
            for (; it != it_end; ++it) {
                const AChar ch = *it;
                window.onCharEntered(ch);
            }
        } break;
        case SDL_EVENT_MOUSE_MOTION: {
#if AUI_PLATFORM_LINUX
            float display_scale = SDL_GetWindowDisplayScale(window.sdl_window);

onPointerMove#


void AEmbedContext::onPointerMove(int x, int y)

Handle mouse move in UI.

Arguments
x
x position
y
y position

Examples:

examples/7guis/circle_drawer/src/main.cpp

7GUIs Circle Drawer - Undo, redo, dialog control.

                circle.radius, 1);
        }
    }

    void onPointerMove(glm::vec2 pos, const APointerMoveEvent& event) override {
        AView::onPointerMove(pos, event);
        mHoveredCircle = [&] {
            Circle* result = nullptr;
            float nearestDistanceToCursor = std::numeric_limits<float>::max();
            for (auto& circle : mState->circles.raw) {
examples/ui/embedded_sdl/src/main.cpp

SDL3 - This code demonstrates how to integrate the AUI Framework with SDL3 to create a window with OpenGL rendering.

        } break;
        case SDL_EVENT_MOUSE_MOTION: {
#if AUI_PLATFORM_LINUX
            float display_scale = SDL_GetWindowDisplayScale(window.sdl_window);
            window.onPointerMove(event->motion.x * display_scale, event->motion.y * display_scale);
#else
            window.onPointerMove(event->motion.x, event->motion.y);
#endif
        } break;
        case SDL_EVENT_MOUSE_BUTTON_DOWN: {

onPointerPressed#


void AEmbedContext::onPointerPressed(int x, int y, APointerIndex pointerIndex)

Handle mouse pressed in UI.

Arguments
x
x position
y
y position
pointerIndex
mouse button or finger index

Examples:

examples/ui/embedded_sdl/src/main.cpp

SDL3 - This code demonstrates how to integrate the AUI Framework with SDL3 to create a window with OpenGL rendering.

        } break;
        case SDL_EVENT_MOUSE_BUTTON_DOWN: {
#if AUI_PLATFORM_LINUX
            float display_scale = SDL_GetWindowDisplayScale(window.sdl_window);
            window.onPointerPressed(event->button.x * display_scale, event->button.y * display_scale, sdlToAPointer(event->button.button));
#else
            window.onPointerPressed(event->button.x, event->button.y, sdlToAPointer(event->button.button));
#endif
        } break;
        case SDL_EVENT_MOUSE_BUTTON_UP: {
examples/app/game_of_life/src/main.cpp

Game of Life - Game of Life implementation that uses advanced large dynamic data rendering techniques such as ITexture, AImage to be GPU friendly. The computation is performed in AThreadPool.

        };
        drawGrid();
    }

    void onPointerPressed(const APointerPressedEvent& event) override {
        AView::onPointerPressed(event);
        glm::ivec2 position = glm::ivec2(event.position / float(SCALE));
        (*mCells)[position] = !(*mCells)[position];
        updateTexture();
    }

onPointerReleased#


void AEmbedContext::onPointerReleased(int x, int y, APointerIndex pointerIndex)

Handle mouse released in UI.

Arguments
x
x position
y
y position
pointerIndex
mouse button or finger index

Examples:

examples/7guis/circle_drawer/src/main.cpp

7GUIs Circle Drawer - Undo, redo, dialog control.

        };
    }

public:
    void onPointerReleased(const APointerReleasedEvent& event) override {
        AView::onPointerReleased(event);
        if (event.asButton != AInput::LBUTTON) {
            return;
        }
        class ActionAddCircle : public IAction {
examples/ui/embedded_sdl/src/main.cpp

SDL3 - This code demonstrates how to integrate the AUI Framework with SDL3 to create a window with OpenGL rendering.

        } break;
        case SDL_EVENT_MOUSE_BUTTON_UP: {
#if AUI_PLATFORM_LINUX
            float display_scale = SDL_GetWindowDisplayScale(window.sdl_window);
            window.onPointerReleased(event->button.x * display_scale, event->button.y * display_scale, sdlToAPointer(event->button.button));
#else
            window.onPointerPressed(event->button.x, event->button.y, sdlToAPointer(event->button.button));
#endif
        } break;
        case SDL_EVENT_MOUSE_WHEEL:

onScroll#


void AEmbedContext::onScroll(int mouseX, int mouseY, int scrollX, int scrollY)

Handle onScroll in UI.

Examples:

examples/ui/embedded_sdl/src/main.cpp

SDL3 - This code demonstrates how to integrate the AUI Framework with SDL3 to create a window with OpenGL rendering.

            window.onPointerPressed(event->button.x, event->button.y, sdlToAPointer(event->button.button));
#endif
        } break;
        case SDL_EVENT_MOUSE_WHEEL:
            window.onScroll(event->wheel.mouse_x, event->wheel.mouse_y, event->wheel.x, event->wheel.y);
            break;
        default: break;
    }
}
/// [handleSDLEvent]
examples/app/fractal/src/FractalView.cpp

Fractal Example - Fractal viewer application demonstrating usage of custom shaders.

    mShader.use();
    mShader.set(UNIFORM_ITERATIONS, int(it));
}

void FractalView::onScroll(const AScrollEvent& event) {
    AView::onScroll(event);
    auto projectedPos = (glm::dvec2(event.origin) / glm::dvec2(getSize()) - glm::dvec2(0.5)) * 2.0;
    projectedPos.x *= mAspectRatio;
    mTransform = glm::translate(mTransform, glm::vec3 { projectedPos, 0.0 });
    mTransform = glm::scale(mTransform, glm::vec3(1.0 - event.delta.y / 1000.0));
examples/app/fractal/src/FractalView.h

Fractal Example - Fractal viewer application demonstrating usage of custom shaders.

    void onKeyDown(AInput::Key key) override;

    void onKeyRepeat(AInput::Key key) override;

    void onScroll(const AScrollEvent& event) override;

    void setSize(glm::ivec2 size) override;

    gl::Program& getShader() { return mShader; }