Skip to content

GroupWidget: per-tab widget access (getTabWidgets / getChildWidgets / getWidgetByTitle) #281

Description

@HanSur94

Problem / motivation

GroupWidget is the dashboard's nested-layout container (panel / collapsible / tabbed — the project's named "tabs, collapsible groups" core value). Last run added the names read side via #280 (getTabNames() / hasTab() / getActiveTab()), but the contents read side is still missing:

  • getNestedWidgets() (libs/Dashboard/GroupWidget.m:248) returns a flat cell of all widgets (Children + every tab's widgets concatenated). It cannot answer "what is in the Details tab?".
  • Panel-mode Children is public (GroupWidget.m:40), but tabbed-mode contents live in the private Tabs{i}.widgets struct field (struct('name',…,'widgets',{{…}}), :41/:84/:90). To read one tab's widgets, a caller must know and traverse that internal struct shape.
  • There is no title-based widget lookup across the group.

Verified grep -rnE "getTabWidgets|getWidgetByTitle|getChildWidgets" libs/ examples/ returns nothing.

The natural call after getTabNames() (#280) is "now give me that tab's widgets" — which has no public API today. This is the documented read-side follow-on to #280 and the directly-analogous container to #274 (DashboardPage per-page getWidget/getWidgetByTitle).

Proposed feature

Three small read-only methods on GroupWidget, completing the read side opened by #280:

Rough sketch

Single file, libs/Dashboard/GroupWidget.m, in methods (Access = public), reusing the existing private findTab (:429) and the existing Children/Tabs state:

function ws = getTabWidgets(obj, tabName)
%GETTABWIDGETS Return the named tab's widgets as a cell (tabbed mode).
    tIdx = obj.findTab(tabName);
    if tIdx == 0
        error('GroupWidget:unknownTab', 'Unknown tab "%s"', tabName);
    end
    ws = obj.Tabs{tIdx}.widgets;
end

function ws = getChildWidgets(obj)
%GETCHILDWIDGETS Return the panel/collapsible Children cell.
    ws = obj.Children;
end

function w = getWidgetByTitle(obj, title)
%GETWIDGETBYTITLE First widget in this group whose Title matches, or [].
    w = [];
    all = obj.getNestedWidgets();
    for i = 1:numel(all)
        if isprop(all{i}, 'Title') && strcmp(all{i}.Title, title)
            w = all{i};
            return;
        end
    end
end

getTabWidgets errors GroupWidget:unknownTab, consistent with the existing removeTab/removeChild siblings.

Value

Medium. Addressable per-tab access is the primitive a "jump to tab then act on its contents" control, a FastSenseCompanion inspector, or a structural test assertion needs — without coupling to the private Tabs struct layout. getWidgetByTitle mirrors the DashboardPage convenience (#274) and is the obvious lookup once a group holds many widgets.

Constraints check

  • Toolbox-free: yes — plain cell indexing + strcmp/isprop.
  • Backward-compatible: yes — purely additive read-only methods; no existing method touched; no toStruct/fromStruct change (Tabs/Children already round-trip).
  • Pure MATLAB/Octave: yes.
  • Contract: works entirely through the existing DashboardWidget/GroupWidget contract.

Effort estimate

S — single file (GroupWidget.m), three small methods over existing state.

Dedup

Clean. #280 is names-only introspection (the sibling, not the contents read); #274 is DashboardPage (different class); #239 is .m-export child config. No issue/PR touches per-tab widget access or title lookup on GroupWidget.


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