Skip to content
ModernUI A DaneTrades developer library

Spacing, Radius, and Typography

ModernUI exposes common visual controls through theme defaults and short setters.

Use these to make panels feel consistent without editing Paint() methods or forking controls.

Core setters

Setter Use it for
Pad(x,y) Internal padding
Radius(r) Corner radius
SizePt(pt) Font size override
Size(w,h) Fixed size
RowHeight(h) Data/list/table row height where supported
HeaderHeight(h) Header height where supported

Legacy names such as Padding, CornerRadius, and FontSize remain supported where the control exposes them.

Padding

UI build fragment
MuiButtonAction *button=Mui::Button(parent,"Save",NULL,160.0,0.0);
button.Pad(14.0,8.0);

Padding affects preferred size and layout. It usually causes a layout update.

Use padding for:

  • button breathing room
  • panel interior spacing
  • compact/comfortable variants
  • custom row layouts

Radius

UI build fragment
MuiPanel *panel=Mui::Panel(parent,320.0,200.0);
panel.Radius(14.0);

MuiButtonAction *square=Mui::Button(parent,"Square",NULL,160.0,0.0);
square.Radius(0.0);

Use radius to match the panel’s visual style.

Common values:

Radius Effect
0.0 square
6.0 small rounding
8.0 standard rounding
14.0 larger card/window rounding

Font size

UI build fragment
MuiLabel *label=Mui::Label(parent,"Ready");
label.SizePt(12);

Use SizePt for one-off text changes.

For app-wide typography, use theme font methods.

Theme font scale

MuiTheme supports a five-step font scale.

UI build fragment
MuiTheme theme;
theme.SetFontScale(10,11,12,14,16);
theme.SetFontFamily("Verdana");

g_ui.SetTheme(theme);

A shorter three-size setter also exists:

UI build fragment
MuiTheme theme;
theme.SetFonts(11,12,14);
g_ui.SetTheme(theme);

Theme typography is best for global consistency. SizePt is best for local overrides.

Dense mode

Dense mode reduces common control sizes and uses a smaller typography preset.

UI build fragment
MuiTheme theme;
theme.Dense(true);
g_ui.SetTheme(theme);

Use dense mode for compact panels such as trade managers, sidebars, and small settings tools.

Avoid dense mode when:

  • the UI contains long descriptions
  • users need touch-like spacing
  • the panel is a tutorial or documentation-heavy view

Component metrics

ModernUI uses theme methods for default sizes.

Examples:

Reference excerpt
theme.ButtonHeight();
theme.InputHeight();
theme.ComboHeight();
theme.SliderHeight();
theme.ListRowHeight();
theme.TableRowHeight();
theme.TableHeaderHeight();
theme.TabHeight();
theme.CardPadding();

Factories use these when size arguments are 0.0.

That means this:

UI build fragment
Mui::Button(parent,"Save",handler,160.0,0.0);

uses the theme button height.

Crisp paint snapping

ModernUI keeps layout in logical units, then snaps final paint rectangles to physical pixels before drawing chrome. This helps avoid random one-pixel border gaps at non-integer Windows or UI scales.

For normal users this is automatic. If you build custom controls, keep the same rule: use logical coordinates for layout and hit testing, then snap final paint bounds before drawing borders, fills, and small chrome.

Fixed size

Use Size(w,h) when a control should be fixed.

UI build fragment
button.Size(180.0,32.0);

Prefer theme defaults unless a fixed size is needed.

Layout vs paint changes

Not every visual change has the same cost.

Change Usually affects
Text that changes width/height Layout and paint
Padding Layout and paint
Font size Layout and paint
Radius Paint
Colour Paint
Row height Layout and paint
Fixed size Layout and paint

This matters for live updates. Do not call layout-heavy setters on every mouse move or timer tick unless needed.

Common mistakes

Making compact panels too cramped

Dense mode is useful, but still leave enough vertical rhythm for inputs and status rows.

Using fixed sizes everywhere

Let theme defaults handle most control sizing. Use fixed sizes where the layout genuinely needs them.

Overriding font sizes randomly

A few text sizes are better than many one-off sizes.

Related pages