// widgetSeparator.c -- Separator widget (horizontal and vertical) // // A purely decorative widget that draws a 2px etched line (shadow + // highlight pair) to visually divide groups of widgets. The etched // line technique (dark line followed by light line offset by 1px) // creates a subtle 3D groove that matches the Motif/Win3.1 aesthetic. // // Separate constructors (wgtHSeparator/wgtVSeparator) rather than a // runtime orientation parameter because separators are always fixed // orientation at construction time. // // The min size in the cross-axis is SEPARATOR_THICKNESS (2px), while // the main axis min is 0 -- the separator stretches to fill the // available width/height in its parent layout. This makes separators // work correctly in both HBox and VBox containers without explicit // sizing. // // No mouse/key handlers -- purely decorative, non-focusable. #include "widgetInternal.h" // ============================================================ // wgtHSeparator // ============================================================ WidgetT *wgtHSeparator(WidgetT *parent) { WidgetT *w = widgetAlloc(parent, WidgetSeparatorE); if (w) { w->as.separator.vertical = false; } return w; } // ============================================================ // wgtVSeparator // ============================================================ WidgetT *wgtVSeparator(WidgetT *parent) { WidgetT *w = widgetAlloc(parent, WidgetSeparatorE); if (w) { w->as.separator.vertical = true; } return w; } // ============================================================ // widgetSeparatorCalcMinSize // ============================================================ void widgetSeparatorCalcMinSize(WidgetT *w, const BitmapFontT *font) { (void)font; if (w->as.separator.vertical) { w->calcMinW = SEPARATOR_THICKNESS; w->calcMinH = 0; } else { w->calcMinW = 0; w->calcMinH = SEPARATOR_THICKNESS; } } // ============================================================ // widgetSeparatorPaint // ============================================================ void widgetSeparatorPaint(WidgetT *w, DisplayT *d, const BlitOpsT *ops, const BitmapFontT *font, const ColorSchemeT *colors) { (void)font; if (w->as.separator.vertical) { int32_t cx = w->x + w->w / 2; drawVLine(d, ops, cx, w->y, w->h, colors->windowShadow); drawVLine(d, ops, cx + 1, w->y, w->h, colors->windowHighlight); } else { int32_t cy = w->y + w->h / 2; drawHLine(d, ops, w->x, cy, w->w, colors->windowShadow); drawHLine(d, ops, w->x, cy + 1, w->w, colors->windowHighlight); } }