raisin::tcp_viewer::ViewerWidget
class · #include <rayrai/TcpViewerWidget.hpp>
The TCP viewer inside a window of another ImGui application.
The viewer runs in an ImGui context of its own (it restyles and re-fonts its context and lays its panes out as top-level windows) and is rendered into a texture that is drawn as an image in the host window. The host's mouse input reaches the viewer only while a press that started on the image is held or the image is hovered, and keys and text only while the host window has focus. A text field of the viewer that has keyboard focus sets the host's io.WantTextInput, and the viewer's clipboard is the host's.
The host's OpenGL context must be current in every call, and the host's ImGui context with the OpenGL3 renderer backend in draw() and drawHidden(). The viewer renders with the host's context: draw(), drawHidden() and shutdown() keep the host's framebuffers, viewport, clear color, pixel pack and unpack state, active texture unit with its 2D texture, program (while it still exists) and vertex array, but not the rest of the GL state (other texture units, buffer bindings, depth, blend, cull), which a host that renders after them sets for itself, as ImGui's renderer backend does.
Constructors & destructor
ViewerWidget
explicit ViewerWidget(ViewerAppConfig config)ViewerWidget(const ViewerWidget &) = delete~ViewerWidget
~ViewerWidget()Calls shutdown() if the host did not.
Public member functions
operator=
ViewerWidget &operator=(const ViewerWidget &) = deletedraw
void draw(const ImVec2 &size, bool forwardKeyboard=true)Runs one viewer frame and draws it at the cursor of the current host window. The viewer is created by the first call.
Parameters
| Parameter | Description |
|---|---|
size | Image size in host points; the viewer's display has this size. |
forwardKeyboard | False while the host uses the keyboard for something else; a text field of the viewer that has keyboard focus still gets the keys. |
drawHidden
void drawHidden()Runs one viewer frame without input at the last size, for a host window that is collapsed or hidden: connections, recordings and local simulations keep running.
ok
bool ok() constFalse once the viewer failed to initialize; draw() then shows a message instead.
shutdown
void shutdown()Releases the viewer and its image. The host must not call it between drawing the widget and rendering that frame's draw data, which still refers to the image: a window that is closed in its frame skips draw() instead.