psychic-ui 0.0.0
Loading...
Searching...
No Matches
psychic_ui::GLFWSystemWindow Class Reference

#include <GLFWSystemWindow.hpp>

Inheritance diagram for psychic_ui::GLFWSystemWindow:
psychic_ui::SystemWindow

Classes

struct  Callbacks

Public Member Functions

 GLFWSystemWindow (std::shared_ptr< Window > window, GLFWwindow *glfwWindow)
 GLFWSystemWindow (const GLFWSystemWindow &)=delete
GLFWSystemWindow & operator= (const GLFWSystemWindow &)=delete
 GLFWSystemWindow (GLFWSystemWindow &&)=delete
GLFWSystemWindow & operator= (GLFWSystemWindow &&)=delete
GLFWwindow * glfwWindow () const
bool render () override
GLProc glProcAddress (const char *name) const override
void setTitle (const std::string &title) override
void setFullscreen (bool fullscreen) override
bool getMinimized () const override
void setMinimized (bool minimized) override
bool getMaximized () const override
void setMaximized (bool maximized) override
void setVisible (bool visible) override
void setCursor (Cursor cursor) override
void startDrag () override
void stopDrag () override
bool supportsDrag () const override
void wake () override
void setSize (int width, int height) override
void setPosition (int x, int y) override
std::string getClipboardText () const override
void setClipboardText (const std::string &text) override
Public Member Functions inherited from psychic_ui::SystemWindow
 SystemWindow (std::shared_ptr< Window > window)
 SystemWindow (const SystemWindow &)=delete
SystemWindow & operator= (const SystemWindow &)=delete
 SystemWindow (SystemWindow &&)=delete
SystemWindow & operator= (SystemWindow &&)=delete
std::shared_ptr< Window > window () const
bool sharesContext () const
void setSharesContext (bool sharesContext)
int getX () const
int getY () const
int getWidth () const
int getHeight () const
int getFramebufferWidth () const
int getFramebufferHeight () const
float getPixelRatio () const
int getSamples () const
int getStencilBits () const
virtual std::chrono::nanoseconds gestureTime () const
virtual ColorScheme colorScheme () const
virtual void startTextInput ()
virtual void stopTextInput ()
virtual void setTextInputArea (int x, int y, int width, int height, int cursor)

Static Public Member Functions

static Mod mapMods (int mods)
static Key mapKey (int key)

Additional Inherited Members

Public Types inherited from psychic_ui::SystemWindow
using GLProc = void (*)()
Protected Member Functions inherited from psychic_ui::SystemWindow
void detach ()
void readFramebufferFormat ()
Protected Attributes inherited from psychic_ui::SystemWindow
std::shared_ptr< Window > _window
bool _sharesContext {false}
bool _dragging {false}
int _stencilBits {8}
int _samples {0}
float _mouseX {0}
float _mouseY {0}
int _x {0}
int _y {0}
int _width {0}
int _height {0}
int _fbWidth {0}
int _fbHeight {0}
bool _focused {false}
bool _minimized {false}
bool _maximized {false}

Detailed Description

Shows a Psychic UI Window in a GLFW window that a host application owns. The host initializes GLFW, creates the window with an OpenGL 3.3+ context and runs the loop; the adapter only installs its input callbacks over the host's, chaining to them, and draws on request:

GLFWwindow *glfwWindow = glfwCreateWindow(1280, 720, "Host", nullptr, nullptr);
glfwMakeContextCurrent(glfwWindow);
glfwSetKeyCallback(glfwWindow, hostKeyCallback);      // still called: the adapter chains to it

auto ui = std::make_shared<MyWindow>();
psychic_ui::GLFWSystemWindow adapter(ui, glfwWindow);

while (!glfwWindowShouldClose(glfwWindow)) {
    glfwPollEvents();
    adapter.render();                                   // makes the context current and draws
    glfwSwapBuffers(glfwWindow);
}

Install your own callbacks before creating the adapter: it calls the ones it replaces first, then handles the event. Destroy the adapter before the window: it puts those callbacks back.

Limits are GLFW's: no input method composition (characters arrive as typed), and on Wayland the window can't be moved from inside (supportsDrag() is false), so use system decorations there rather than a custom title bar. GLFW has no touch input either: the window stays in pointer mode, whatever the system makes of fingers, and the adapter never changes the mode, so a host with touch input of its own can hand it to Window::handleTouchPress and the others.

Member Function Documentation

◆ getClipboardText()

std::string psychic_ui::GLFWSystemWindow::getClipboardText ( ) const
nodiscardoverridevirtual

The system clipboard's text, in UTF-8. Without a system clipboard (this default), a clipboard that only lives in this system window.

Reimplemented from psychic_ui::SystemWindow.

◆ getMaximized()

bool psychic_ui::GLFWSystemWindow::getMaximized ( ) const
nodiscardoverridevirtual

◆ getMinimized()

bool psychic_ui::GLFWSystemWindow::getMinimized ( ) const
nodiscardoverridevirtual

◆ glProcAddress()

SystemWindow::GLProc psychic_ui::GLFWSystemWindow::glProcAddress ( const char * name) const
overridevirtual

Address of an OpenGL function in this window's context, which Skia builds its GL interface from

Implements psychic_ui::SystemWindow.

◆ render()

bool psychic_ui::GLFWSystemWindow::render ( )
overridevirtual

Draws the window. When the window was closed from inside (a title bar's close button), marks the GLFW window as to be closed and returns false.

Implements psychic_ui::SystemWindow.

◆ setClipboardText()

void psychic_ui::GLFWSystemWindow::setClipboardText ( const std::string & text)
overridevirtual

Reimplemented from psychic_ui::SystemWindow.

◆ setCursor()

void psychic_ui::GLFWSystemWindow::setCursor ( Cursor cursor)
overridevirtual

◆ setFullscreen()

void psychic_ui::GLFWSystemWindow::setFullscreen ( bool fullscreen)
overridevirtual

◆ setMaximized()

void psychic_ui::GLFWSystemWindow::setMaximized ( bool maximized)
overridevirtual

◆ setMinimized()

void psychic_ui::GLFWSystemWindow::setMinimized ( bool minimized)
overridevirtual

◆ setPosition()

void psychic_ui::GLFWSystemWindow::setPosition ( int x,
int y )
overridevirtual

◆ setSize()

void psychic_ui::GLFWSystemWindow::setSize ( int width,
int height )
overridevirtual

◆ setTitle()

void psychic_ui::GLFWSystemWindow::setTitle ( const std::string & title)
overridevirtual

◆ setVisible()

void psychic_ui::GLFWSystemWindow::setVisible ( bool visible)
overridevirtual

◆ startDrag()

void psychic_ui::GLFWSystemWindow::startDrag ( )
overridevirtual

◆ stopDrag()

void psychic_ui::GLFWSystemWindow::stopDrag ( )
overridevirtual

◆ supportsDrag()

bool psychic_ui::GLFWSystemWindow::supportsDrag ( ) const
nodiscardoverridevirtual

Whether the window can be moved from inside it, by Window::isDragArea or startDrag()

Reimplemented from psychic_ui::SystemWindow.

◆ wake()

void psychic_ui::GLFWSystemWindow::wake ( )
overridevirtual

glfwPostEmptyEvent, which ends a host's glfwWaitEvents: a host that waits draws when Window::untilNextFrame says so

Reimplemented from psychic_ui::SystemWindow.


The documentation for this class was generated from the following files: