Fluent-style controls for Win32 programs. Header-only C++17, with no dependencies outside the Windows SDK.
Micula renders with Direct2D into a DirectComposition swap chain, so Windows 11 can draw Mica behind the window. It draws its own title bar and keeps snap layouts working. On Windows 10, and on Windows 11 before 22H2, the window gets a solid background instead.
It is meant for small tools: settings windows, installers, configuration dialogs. The
library adds about 85 KB to an x64 executable, and a program built with /MT runs on a
machine with nothing installed.
Button, CheckBox, ToggleSwitch, Segmented, Slider, ScrollBar, DropDown, SideNav, TextBox, ProgressBar, ProgressRing, ImageView.
CardGroup joins existing cards with coordinated corners, spacing and clipped row transitions; CardExpander reveals a group below
a card header. StackLayout::maxWidth optionally centres a bounded content column. See
grouped cards and examples/cards (micula-cards.exe).
Colors, sizes and animation timings come from WinUI's control templates and the Fluent design tokens. The accent color and the light or dark theme are read from the system.
#include <micula/micula.h>
struct Hello : micula::Window {
bool on = false;
const wchar_t *ClassName() const override { return L"Hello"; }
const wchar_t *Title() const override { return L"Hello"; }
void Layout() override {
ClearWidgets();
auto *sw = Add(new micula::ToggleSwitch(L"Enabled", on, [this](bool v) { on = v; }));
sw->rect = micula::Rect(24, 56, 280, 32);
auto *ok = Add(new micula::Button(L"Close", micula::ButtonStyle::Accent,
[this] { Close(); }));
ok->rect = micula::Rect(24, 104, 120, 32);
}
};
int WINAPI wWinMain(HINSTANCE, HINSTANCE, wchar_t *, int) {
micula::EnablePerMonitorDpi();
CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED);
Hello w;
return w.Create(340, 170, false, nullptr) ? w.Run() : 1;
}examples/settings is the window in the screenshot. examples/gallery puts every
control on one scrolling page. examples/nav is the navigation pane with the switches
that shape it on the page beside it, for trying them out.
tools/glyphpicker.ps1 is a window for choosing the icons in glyphs.h: it draws a
range of code points in a Segoe font, dims the ones the font does not have, marks the
ones that only one of the two icon fonts has, and copies the literal of the cell you
click. Hover a cell and it says what the icon is -- U+E734 FavoriteStar,
U+E713 Settings/Setting where the two tables disagree about the name, U+E733 Blocked (仅 Fluent), or U+F106 PageList 无字形 where this machine's font has no glyph for a name
Microsoft still lists -- out of tools/glyph-names.csv.
tools/glyphaudit.ps1 checks that header against Microsoft's two published icon tables,
which are the only place the names live: every trailing name is compared with the name
Microsoft gives that code point, and every family the header groups (the battery ramps,
the alignments, the speeds) is checked for members it might have missed -- SettingsBattery
is an empty battery whose name is nowhere near the rest of its ramp. It is also what writes
glyph-names.csv, and it fails when that copy no longer matches the tables.
The headers link the libraries they need through #pragma comment, so with MSVC this is
enough:
cl /std:c++17 /EHsc /O1 /MT /DUNICODE /D_UNICODE /I include app.cpp /link /SUBSYSTEM:WINDOWSWith CMake, add this directory and link micula::micula. Building the repository itself
builds both examples.
A program using Micula has to:
- compile with
UNICODEand_UNICODEdefined. The headers call the wide API, and a program that does not define them still gets the A variants of everything in<windows.h>-- including the names it hands this window, which are wide strings here. The CMake target defines both for you. - initialize COM on the UI thread (apartment-threaded) before
Window::Create. The title bar icon andWindow::Imageuse WIC. - be per-monitor DPI aware, through its manifest or
micula::EnablePerMonitorDpi(). - leave timer IDs 2 to 7 to Micula.
Each window is a subclass of micula::Window. Layout() deletes the controls and
creates them again from the window's own fields, so a callback should update those
fields rather than the control. Layout() may be called from inside a callback. Text and
backgrounds that are not controls are drawn in PaintPage(). Coordinates are in DIPs.
For a scrolling page, return the scrolling area from ClipRect(), set scrolls on the
controls inside it, and move them by returning an offset from ContentTransform() -- so a
wheel notch costs a transform and a repaint rather than a Layout(), and the page is not
rebuilt as it scrolls. examples/gallery does this.
- Overview: headers and core concepts
- Window: creating a window, page callbacks, input, scrolling
- Controls: the nine controls
- Custom controls: writing a control of your own
- Drawing: painter, palette, fonts, icons, animation
- Layout: the retained object tree a page is arranged by, and the migration that brought it here
MIT License. Micula is not affiliated with Microsoft.