caliper.ui.v1_1¶
Service id caliper.ui.v1_1 is an additive revision of caliper.ui.v1. Its table opens with a byte-identical copy of CaliperUiV1 and adds one entry, dock_hint. With dock_hint, an applet tells the host where each of its windows belongs in the docked layout.
Calls¶
| Call | Signature | Description |
|---|---|---|
imgui_context |
struct ImGuiContext* (void) |
Return the shared ImGuiContext of the host. The pointer stays valid from initialize() through cleanup(). |
implot_context |
struct ImPlotContext* (void) |
Return the shared ImPlotContext of the host. The pointer stays valid from initialize() through cleanup(). |
implot3d_context |
struct ImPlot3DContext* (void) |
Return the shared ImPlot3DContext of the host. The pointer stays valid from initialize() through cleanup(). |
imgui_allocators |
void (CaliperImGuiAllocFn* out_alloc, CaliperImGuiFreeFn* out_free, void** out_user_data) |
Write the allocator pair of the host to out_alloc, out_free, and out_user_data. The applet must install the pair into its copy of the ImGui globals before it makes any allocation, so that every allocation lands on the host heap. |
dock_hint |
void (const char* window_title, uint32_t role) |
Declare the dock role of the window whose Begin() title is window_title. The argument role is a CaliperDockRole value. Call it on the UI thread next to that Begin(), before or after it, and a call in every frame is cheap and changes nothing after the first call for a title. The hint places only a window that has no saved layout, so a layout that the user arranged always wins. A window without a hint docks in the center. |
Types¶
CaliperDockRole¶
The place where a window docks the first time it appears. The values are fixed integers, and the host treats a value it does not know as CALIPER_DOCK_CENTRAL.
| Constant | Value | Description |
|---|---|---|
CALIPER_DOCK_CENTRAL |
0 |
The central area, for the main view of the applet. |
CALIPER_DOCK_SIDE_TOP |
1 |
The upper part of the side column, for controls. |
CALIPER_DOCK_SIDE_BOTTOM |
2 |
The lower part of the side column, for details. |
CaliperUiV1_1¶
The function table of caliper.ui.v1_1. Call every entry from the UI thread.
| Field | Type | Description |
|---|---|---|
struct_size |
uint32_t |
sizeof(CaliperUiV1_1) as the host built it. |
imgui_context |
struct ImGuiContext* (*)(void) |
Return the shared ImGuiContext of the host. The pointer stays valid from initialize() through cleanup(). |
implot_context |
struct ImPlotContext* (*)(void) |
Return the shared ImPlotContext of the host. The pointer stays valid from initialize() through cleanup(). |
implot3d_context |
struct ImPlot3DContext* (*)(void) |
Return the shared ImPlot3DContext of the host. The pointer stays valid from initialize() through cleanup(). |
imgui_allocators |
void (*)(CaliperImGuiAllocFn* out_alloc, CaliperImGuiFreeFn* out_free, void** out_user_data) |
Write the allocator pair of the host to out_alloc, out_free, and out_user_data. The applet must install the pair into its copy of the ImGui globals before it makes any allocation, so that every allocation lands on the host heap. |
dock_hint |
void (*)(const char* window_title, uint32_t role) |
Declare the dock role of the window whose Begin() title is window_title. The argument role is a CaliperDockRole value. Call it on the UI thread next to that Begin(), before or after it, and a call in every frame is cheap and changes nothing after the first call for a title. The hint places only a window that has no saved layout, so a layout that the user arranged always wins. A window without a hint docks in the center. |
Ids¶
| Name | Value | Description |
|---|---|---|
CALIPER_UI_V1_1 |
"caliper.ui.v1_1" |
The id of this service, which get_service takes. |
Semantics¶
- The v1 entries are unchanged. The context getters and
imgui_allocatorsbehave as incaliper.ui.v1. The host also keeps servingcaliper.ui.v1beside this id. - Roles, not positions. The host lays out roles and never names a window.
- Shared nodes. Windows with the same role share a node as tabs, also after a restart. A new side window joins the node where a window of its role is docked already, such as one restored from
imgui.ini. The host splits a side column off the central area only when no such node exists. The host treats a role value it does not know asCALIPER_DOCK_CENTRAL. - Call timing. Call
dock_hinton the UI thread next to the window'sBegin(). It is safe to call it every frame. A hint given before the firstBegin()docks the window in the frame where it first appears. A hint given after it takes effect on the next frame. The first hint for a title counts, and every later call changes nothing. - The user's layout wins. A hint places only a window that has no saved layout, that is, no entry in
imgui.ini. The host places each window once per process, the first time it appears. Thus a window that the user moves or undocks stays where the user put it. A hinted window withImGuiWindowFlags_NoSavedSettingsis docked too, but the host writes nothing about it toimgui.ini. - Windows without a hint. The host docks an ordinary window in the center the first time it appears. An ordinary window is not a child window, a popup, a tooltip or a modal. It also has none of
ImGuiWindowFlags_NoDocking,NoSavedSettings,NoMove,NoResize,NoTitleBarandAlwaysAutoResize. Any other window, such as a tool window that sizes itself, keeps the placement ImGui gives it. To keep an ordinary window floating, such as a non-modal file dialog, give itImGuiWindowFlags_NoDocking. - Optional for the applet. An applet that uses hints lists only
caliper.ui.v1in[services].required. The sugarcaliper::ui::dock_hint(host, title, role)probescaliper.ui.v1_1. On a host that lacks it, the call does nothing and the windows keep the placement ImGui gives them. - Where hints apply. The
caliperexecutable applies hints on its applet page. An embedding host that has no docked layout, such as Caliper Embed, accepts the calls and ignores them.
Worked Example¶
caliper::ui::dock_hint(host, "Viewer: Scene", CALIPER_DOCK_CENTRAL);
ImGui::Begin("Viewer: Scene");
// ...
ImGui::End();
caliper::ui::dock_hint(host, "Viewer: Controls", CALIPER_DOCK_SIDE_TOP);
ImGui::Begin("Viewer: Controls");
// ...
ImGui::End();
The testing fixture (caliper/fixture_host.h) serves this id and records every hint. In an applet test, FixtureHost::dock_role(title) returns the first role hinted for a title, as the host keeps it.