Now that you have set up your window, you need to set up your custom monitor as well.
Each GenericWindow
class has a member variable of type
GenericMonitor*
named monitor
. In your
window's constructor, you need to set this pointer to point to a child
of the GenericMonitor
class. The base class looks like
this:
class GenericMonitor
{
public:
virtual FVector4 getWorkArea(MonitorData& data) noexcept = 0;
virtual FVector2 getSize(MonitorData& data) noexcept = 0;
virtual String getName(MonitorData& data) noexcept = 0;
virtual double getContentScale(MonitorData& data) noexcept = 0;
virtual float getPixelDensity(MonitorData& data) noexcept = 0;
virtual void* getPlatformHandle(MonitorData& data) noexcept = 0;
};
Our monitor API is intentionally minimal, due to the fact that different libraries, APIs and operating systems provide very different monitor data from each other. Of course, you can cast back to your own monitor at any point to take advantage of additional functionality in your windowing system.
The functions are the same as in the Monitor
class, but
they must act on top of the provided monitor data instead.
C API
The C API for monitors looks like this:
// Allocate a GenericMonitor instance to be used together with a corresponding GenericWindow
// Event safety - Any time
* UImGui_CGenericMonitor_allocate(
UIMGUI_PUBLIC_API UImGui_CGenericMonitor(*getWorkArea)(UImGui_MonitorData*),
UImGui_FVector4double(*getContentScale)(UImGui_MonitorData*),
(*getName)(UImGui_MonitorData*),
UImGui_String(*getSize)(UImGui_MonitorData*),
UImGui_FVector2float(*getPixelDensity)(UImGui_MonitorData*),
void*(*getPlatformHandle)(UImGui_MonitorData*)
);
// CGenericWindow instances automatically call this function in their destructor, but it is given for convenience
// Event safety - Any time
void UImGui_CGenericMonitor_free(UImGui_CGenericMonitor* monitor); UIMGUI_PUBLIC_API
Simply allocate a generic monitor with
UImGui_CGenericMonitor_allocate()
by providing the required
C function pointers for each event. A
UImGui_CGenericMonitor*
will be returned that you can use
as your handle.
You can also prematurely free your instance with
UImGui_CGenericMonitor_free()
, though this is not required
in most cases, since GenericWindows
created with the C API
already free these types of monitors automatically.
To set a CGenericMonitor
as your monitor with the C API
assign it to the monitor
variable of your
UImGui_CGenericWindowInitInfo
struct.
- Home
- Beginner content
- Install guide
- Creating and using the UI components
- The Instance
- The Init Info struct
- Building better titlebar menus
- Textures
- Logging
- Unicode support
- Additional features
- Client-side bar
- Custom type definitions
- Memory management
- C API development
- Config files and Folders
- Interfaces
- Internal Event safety
- Customising the build system
- Modules system
- Collaborating with others
- Advanced content
- Loading dynamic libraries at runtime
- Understanding the library layout
- Compilation mode modifiers
- Supporting plugins
- Production export and deployment
- OS integration tips
- Targeting WASM
- Using a custom rendering engine:
- Using a custom windowing backend:
- Developer and contributor resources
- Misc