Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 54 additions & 0 deletions +labkit/+ui/+app/create.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
function ui = create(spec, varargin)
%CREATE Build a LabKit UI 2.0 workbench from declarative specs.
%
% App-facing contract:
% ui = labkit.ui.app.create(spec, "debug", debugContext)
%
% Inputs:
% spec - scalar app spec from labkit.ui.spec.app. The app spec owns
% controlTabs and workspace specs; all controls use globally unique ids.
% debug - optional labkit.ui.diag debug context. When supplied, the created
% figure is instrumented and the first logPanel mirrors trace lines.
%
% Output:
% ui - registry struct with figure/fig, shell handles, controls, sections,
% tabs, workspace, original spec, and optional debug context. Stable app
% code should use semantic ids and named labkit.ui.view helpers rather
% than adapter internals.

opts = parseOptions(varargin);
validateAppSpec(spec);

debug = optionValue(opts, 'debug', []);
ui = buildShellFromSpec(spec, debug);
ui = buildControlTabs(ui, spec.props.controlTabs, debug);
ui = buildWorkspace(ui, spec.props.workspace, debug);

if isDebugEnabled(debug) && isfield(debug, 'instrumentFigure')
debug.instrumentFigure(ui.figure);
end
setappdata(ui.figure, 'labkitUiRegistry', ui);
end

function opts = parseOptions(args)
if mod(numel(args), 2) ~= 0
error('labkit:ui:app:InvalidOptions', ...
'labkit.ui.app.create options must be name/value pairs.');
end
opts = struct();
for k = 1:2:numel(args)
opts.(char(string(args{k}))) = args{k + 1};
end
end

function value = optionValue(opts, name, defaultValue)
value = defaultValue;
if isstruct(opts) && isfield(opts, name)
value = opts.(name);
end
end

function tf = isDebugEnabled(debugContext)
tf = isstruct(debugContext) && isfield(debugContext, 'enabled') && ...
logical(debugContext.enabled);
end
72 changes: 0 additions & 72 deletions +labkit/+ui/+app/createShell.m

This file was deleted.

4 changes: 2 additions & 2 deletions +labkit/+ui/+app/private/attachColumnResize.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ function attachColumnResize(fig, grid, leftColumn, separatorColumn, opts)
% WindowButtonMotionFcn/WindowButtonUpFcn callbacks while dragging.
%
% Notes:
% This helper mutates layout handles only; apps should normally request
% resizable shells through labkit.ui.app.createShell.
% This helper mutates layout handles only; apps request resizable workbench
% layouts through labkit.ui.app.create.

if nargin < 5
opts = struct();
Expand Down
Loading
Loading