Skip to content

DividerWidget: render an optional section label on the divider line #278

Description

@HanSur94

Problem / motivation

DividerWidget is the dashboard's only visual section-separation primitive, but it can draw a line and nothing else. Its render() creates a bare colored uipanel line (libs/Dashboard/DividerWidget.m:67-73) with no text element. It nonetheless stores a Title (a base-class property, restored in fromStruct at DividerWidget.m:116) that is never displayed — verified grep -niE "label|text|title" libs/Dashboard/DividerWidget.m finds only doc-comments, the fromStruct assignment, and zero text-rendering call.

So the idiomatic section header divider — ─── Pressures ─── — is impossible in one widget. Today it costs a separate TextWidget cell stacked above the divider, consuming extra grid rows and breaking the single-primitive model. Organizing complex dashboards into navigable sections is a named core-value of the project, and a labeled rule is exactly the low-cost sectioning primitive that sits between a bare line and a full collapsible GroupWidget.

Proposed feature

Give DividerWidget an optional Label that, when set, renders as centered text over the line (turning the rule into a section header). Empty Label (the default) renders the identical bare line as today.

d.addWidget('divider', 'Label', 'Pressures', 'Position', [1 3 24 1]);
d.addWidget('divider', 'Label', 'Vibration', 'LabelAlignment', 'left');
d.addWidget('divider');   % unchanged: bare line, no text

Rough sketch

  • Lib/class: libs/Dashboard/DividerWidget.m (single file).
  • Public API:
    • Label = '' — section text; empty = bare line (current behavior).
    • LabelAlignment = 'center''center' | 'left' | 'right' (optional).
  • render(): when Label is non-empty, add a uilabel (or uicontrol('style','text')) positioned over the line, themed via the existing theme struct; otherwise the existing line-only path is untouched.
  • Serialization: toStruct emits label/labelAlignment only when non-default; fromStruct reads them under guarded isfield checks.
  • asciiRender(): embed the label inside the dash row (──── Pressures ────).

Value

Medium-High. A MATLAB sensor-analysis engineer laying out a long dashboard wants section headings ("Pressures / Temperatures / Vibration") without spending two grid cells per heading. This directly serves the project's stated goal of organizing dashboards into navigable sections.

Constraints check

  • Toolbox-free: ✅ plain uilabel / uicontrol text — no toolbox.
  • Backward-compatible: ✅ default Label = '' renders byte-identical to today; new serialized fields omitted at default and read under isfield guards, so existing scripts and serialized dashboards keep working.
  • Pure MATLAB/Octave: ✅ no MEX, no external deps.
  • Widget contract: ✅ works entirely through the existing DashboardWidget render/refresh/toStruct/fromStruct contract; no base-class change.

Effort estimate

S — single file: add property (+ optional alignment), conditional text element in render, round-trip in toStruct/fromStruct, label-aware asciiRender.

Dedup

Clean — gh issue list --search "divider" / "section header label" returns only #210 (data export, unrelated). No issue/PR touches DividerWidget, section headers, or labeled separators. Distinct from #233 (TextWidget ContentFcn), which is a free-form text tile, not a separator — the value here is one widget that is both a rule and its heading.


AI-proposed via /feature-scout — needs a human product decision before implementation.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions