41 lines
1.3 KiB
C
41 lines
1.3 KiB
C
// widgetSpacer.c -- Spacer widget (invisible stretching element)
|
|
//
|
|
// A zero-sized invisible widget with weight=100, used purely for
|
|
// layout control. It absorbs leftover space in box layouts, pushing
|
|
// sibling widgets apart. Common use: place a spacer between buttons
|
|
// in a toolbar to right-align some buttons, or between a label and
|
|
// a control to create elastic spacing.
|
|
//
|
|
// Because calcMinSize returns 0x0, the spacer takes no space when
|
|
// there is none to spare, but greedily absorbs extra space via its
|
|
// weight. This is the simplest possible layout primitive -- no paint,
|
|
// no mouse, no keyboard, no state. The entire widget is effectively
|
|
// just a weight value attached to a position in the sibling list.
|
|
|
|
#include "widgetInternal.h"
|
|
|
|
|
|
// ============================================================
|
|
// wgtSpacer
|
|
// ============================================================
|
|
|
|
WidgetT *wgtSpacer(WidgetT *parent) {
|
|
WidgetT *w = widgetAlloc(parent, WidgetSpacerE);
|
|
|
|
if (w) {
|
|
w->weight = 100; // spacers stretch by default
|
|
}
|
|
|
|
return w;
|
|
}
|
|
|
|
|
|
// ============================================================
|
|
// widgetSpacerCalcMinSize
|
|
// ============================================================
|
|
|
|
void widgetSpacerCalcMinSize(WidgetT *w, const BitmapFontT *font) {
|
|
(void)font;
|
|
w->calcMinW = 0;
|
|
w->calcMinH = 0;
|
|
}
|