open source · MIT
mydear: Dear ImGui apps on every platform.
You write one frame(). It brings the rest.
A small C++20 toolkit around Dear ImGui. No browser engine, no runtime.
mydear opens the window, sets up the graphics backend and the Dear ImGui backends, runs a frame loop that idles when nothing changes, and fills the gaps between ImGui and each operating system: a title bar with the real OS buttons, touch and the soft keyboard on phones and tablets, native views in the layout, fonts, file dialogs, haptics and auto-update. Dear ImGui stays yours, compiled once by your project. It grew out of DearSQL, a SQL client for desktop, iPad and iPhone, where it runs everything between the OS and the UI.
> Platforms
## The whole app
A delegate draws a frame; mydear::Run does the rest. The same file builds for every platform above.
#include "mydear/app.hpp"
#include "mydear/button.hpp"
struct Hello : mydear::Delegate {
int clicks = 0;
void frame() override {
const mydear::Rect r = mydear::ContentRect(); // under the title bar, inside the safe area
ImGui::SetNextWindowPos(r.pos);
ImGui::SetNextWindowSize(r.size);
ImGui::Begin("hello", nullptr, ImGuiWindowFlags_NoDecoration);
if (mydear::Button("Click me", mydear::ButtonVariant::Primary))
++clicks;
ImGui::Text("Clicked %d times", clicks);
ImGui::End();
}
};
int main() {
static Hello hello;
return mydear::Run({.title = "Hello", .titleBar = true}, hello);
}In CMake, next to your own Dear ImGui:
set(MYDEAR_IMGUI_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external/imgui)
add_subdirectory(external/mydear)
add_executable(app main.cpp ${IMGUI_SOURCES})
target_link_libraries(app PRIVATE mydear::mydear) # + mydear::components, optional## What it has
- * Platform shell: the window, the graphics backend, input, and a loop that idles when nothing changes and skips frames identical to the last.
- * Title bar: draw your own bar in ImGui; mydear keeps the OS buttons, dragging, snap layouts and double-click zoom.
- * Touch: tap to click, long press for menus or the text toolbar, drag to scroll with momentum.
- * Native views: a real NSView, UIView, HWND or GtkWidget (a text field, a map, a web view) in the ImGui layout.
- * Themes and widgets: eighteen palettes; buttons, selects, toggles, splitters, spinners, menus and modal alerts that follow them.
- * Components: optional text fields, cards, badges, callouts, progress, avatars, metrics, chips and toasts.
- * Fonts and files: one UI font from a text font, icon fonts and the system's CJK font; file dialogs; fonts and images baked into the binary.
- * Auto-update: Sparkle, WinSparkle or a checked AppImage swap, behind one call.