|
|
| 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 |
|
| 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) |
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.