struct mola::gui::TextPanel
Overview
A multi-line text panel.
Read-only mode:
nanogui : a non-editable nanogui::TextBox with vertical scroll, or a sequence of nanogui::Label lines inside a scroll panel. Content is refreshed from
live_texteach spinOnce tick.ImGui : ImGui::InputTextMultiline with ImGuiInputTextFlags_ReadOnly. live_text->pollIntoDisplay() is called each frame; the widget reads display directly. No copy into a separate buffer needed because ReadOnly mode does not write back.
Editable mode:
nanogui : nanogui::TextBox (multiline variant) with setEditable(true). on_change fires when the user commits (focus lost / Enter).
ImGui : ImGui::InputTextMultiline with a caller-owned std::string buffer (ImGui 1.89+ supports std::string via InputTextCallback or the imgui_stdlib.h helper - use InputTextMultiline overload that takes std::string*). on_change fires every frame the content differs from the last committed snapshot.
size_pixels sets the widget’s (width, height) in pixels. {0, 0} means “fill available width, auto height” for ImGui (ImVec2(0,0) default) and a reasonable fixed size for nanogui.
When editable is false, on_change is ignored and may be left empty. When editable is true, live_text is still used for the initial content (set it before calling create_subwindow_from_description); after that the ImGui backend owns the buffer and live_text is not polled. The nanogui backend follows the same convention.
#include <GuiWidgetDescription.h> struct TextPanel { // fields std::string label; LiveString::Ptr live_text; bool editable = false; std::array<int, 2> size_pixels = {0, 0}; std::function<void(const std::string&)> on_change; };
Fields
std::string label
optional heading above the panel
LiveString::Ptr live_text
content; never null
std::array<int, 2> size_pixels = {0, 0}
{width, height}, 0 = auto
std::function<void(const std::string&)> on_change
editable only