From a44f241375f9f09ec9cedb3a996a9620d271a915 Mon Sep 17 00:00:00 2001 From: Robyn Jackey Date: Mon, 29 Jun 2026 13:43:31 -0400 Subject: [PATCH 1/3] fixes #192 ButtonGrid update errors if there are zero buttons --- test/+wt/+test/ButtonGrid.m | 47 +++++++++++++++++++++++++++++++++++++ widgets/+wt/ButtonGrid.m | 4 ++-- 2 files changed, 49 insertions(+), 2 deletions(-) diff --git a/test/+wt/+test/ButtonGrid.m b/test/+wt/+test/ButtonGrid.m index e887579..a8c7e5a 100644 --- a/test/+wt/+test/ButtonGrid.m +++ b/test/+wt/+test/ButtonGrid.m @@ -35,6 +35,9 @@ function testCreationByIcon(testCase) icon = ["add" "delete" "play" "pause" "stop"] + "_24.png"; testCase.verifySetProperty("Icon", icon); + + diag = "Expected update to run without warnings."; + testCase.verifyWarningFree(@()testCase.Widget.forceUpdate(), diag) end %function @@ -50,6 +53,23 @@ function testCreationByTextAndIcon(testCase) expNum = max(numel(text), numel(icon)); testCase.verifyNumElements(testCase.Widget.Button, expNum) + + diag = "Expected update to run without warnings."; + testCase.verifyWarningFree(@()testCase.Widget.forceUpdate(), diag) + + end %function + + + function testEmptyButtons(testCase) + % Add buttons by Icon and Text + + testCase.verifySetProperty("Icon", strings(1,0)); + testCase.verifySetProperty("Text", strings(1,0)); + + testCase.verifyEmpty(testCase.Widget.Button) + + diag = "Expected update to run without warnings."; + testCase.verifyWarningFree(@()testCase.Widget.forceUpdate(), diag) end %function @@ -65,6 +85,9 @@ function testMissingIcons(testCase) expNum = max(numel(text), numel(icon)); testCase.verifyNumElements(testCase.Widget.Button, expNum) + + diag = "Expected update to run without warnings."; + testCase.verifyWarningFree(@()testCase.Widget.forceUpdate(), diag) end %function @@ -80,6 +103,9 @@ function testMissingText(testCase) expNum = max(numel(text), numel(icon)); testCase.verifyNumElements(testCase.Widget.Button, expNum) + + diag = "Expected update to run without warnings."; + testCase.verifyWarningFree(@()testCase.Widget.forceUpdate(), diag) end %function @@ -97,6 +123,9 @@ function testExtraTooltip(testCase) expNum = max(numel(text), numel(icon)); testCase.verifyNumElements(testCase.Widget.Button, expNum) + + diag = "Expected update to run without warnings."; + testCase.verifyWarningFree(@()testCase.Widget.forceUpdate(), diag) end %function @@ -127,6 +156,9 @@ function testPressButton(testCase) testCase.verifyEqual([evts.Button], buttons) testCase.verifyEqual(string({evts.Text}), text) testCase.verifyEqual(string({evts.Tag}), tag) + + diag = "Expected update to run without warnings."; + testCase.verifyWarningFree(@()testCase.Widget.forceUpdate(), diag) end %function @@ -137,6 +169,9 @@ function testBackgroundColor(testCase) newValue = [1 0.5 0.2]; testCase.verifySetProperty("BackgroundColor", newValue); testCase.verifyEqual(testCase.Widget.Grid.BackgroundColor, newValue); + + diag = "Expected update to run without warnings."; + testCase.verifyWarningFree(@()testCase.Widget.forceUpdate(), diag) end %function @@ -156,6 +191,9 @@ function testOrientation(testCase) testCase.verifySetProperty("Orientation", "vertical"); testCase.verifyNumElements(testCase.Widget.Grid.RowHeight, numel(icon)); testCase.verifyNumElements(testCase.Widget.Grid.ColumnWidth, 1); + + diag = "Expected update to run without warnings."; + testCase.verifyWarningFree(@()testCase.Widget.forceUpdate(), diag) end %function @@ -188,6 +226,9 @@ function testIconAlignment(testCase) newValue = "left"; testCase.verifySetProperty("IconAlignment", newValue); testCase.verifyMatches(button.IconAlignment, newValue); + + diag = "Expected update to run without warnings."; + testCase.verifyWarningFree(@()testCase.Widget.forceUpdate(), diag) end %function @@ -212,6 +253,9 @@ function testButtonWidthHeight(testCase) testCase.verifySetProperty("Text", ["1", "2", "3", "4"], ["1", "2", "3", "4"]) testCase.verifyEqual(testCase.Widget.ButtonWidth, {10 20 30 30}) + diag = "Expected update to run without warnings."; + testCase.verifyWarningFree(@()testCase.Widget.forceUpdate(), diag) + % Change to vertical layout newOrientation = "vertical"; testCase.verifySetProperty("Orientation", newOrientation); @@ -226,6 +270,9 @@ function testButtonWidthHeight(testCase) testCase.verifySetProperty("ButtonWidth", {10 'fit'}, {10}) testCase.verifySetProperty("ButtonWidth", 20, {20}) + + diag = "Expected update to run without warnings."; + testCase.verifyWarningFree(@()testCase.Widget.forceUpdate(), diag) end diff --git a/widgets/+wt/ButtonGrid.m b/widgets/+wt/ButtonGrid.m index 1b1d654..062f6cc 100644 --- a/widgets/+wt/ButtonGrid.m +++ b/widgets/+wt/ButtonGrid.m @@ -181,10 +181,10 @@ function update(obj) end % Remove any extra rows/cols from the grid - if obj.Orientation == "vertical" + if obj.Orientation == "vertical" && numNew > 0 obj.Grid.RowHeight(numNew+1:end) = []; obj.Grid.ColumnWidth = obj.Grid.ColumnWidth(1); - else + elseif obj.Orientation == "horizontal" && numNew > 0 obj.Grid.ColumnWidth(numNew+1:end) = []; obj.Grid.RowHeight = obj.Grid.RowHeight(1); end From f09ca41e83c26d57d08b0fe680861de84b05b68a Mon Sep 17 00:00:00 2001 From: Robyn Jackey Date: Mon, 29 Jun 2026 13:54:12 -0400 Subject: [PATCH 2/3] Update MATLAB versions in CI workflow --- .github/workflows/git-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/git-ci.yml b/.github/workflows/git-ci.yml index 4b9e2b1..71bf17a 100644 --- a/.github/workflows/git-ci.yml +++ b/.github/workflows/git-ci.yml @@ -17,7 +17,7 @@ jobs: platform: [ubuntu-latest, windows-latest] # List of MATLAB releases over which to run the tests. - matlab-version: [R2023b, R2024a, R2024b, latest] + matlab-version: [R2023b, R2024a, R2024b, R2025b, R2026a, latest] # UITest with gestures only from R2023b and later. From 51af7b84025edd678f8346f01933ca33bfc9cc69 Mon Sep 17 00:00:00 2001 From: Robyn Jackey Date: Mon, 29 Jun 2026 14:14:30 -0400 Subject: [PATCH 3/3] provide option for hiding the disp command during forceUpdate --- test/+wt/+test/ButtonGrid.m | 24 +++++++++++----------- widgets/+wt/+abstract/BaseViewChart.m | 12 +++++++++-- widgets/+wt/+abstract/BaseViewController.m | 12 +++++++++-- widgets/+wt/+abstract/BaseWidget.m | 12 +++++++++-- 4 files changed, 42 insertions(+), 18 deletions(-) diff --git a/test/+wt/+test/ButtonGrid.m b/test/+wt/+test/ButtonGrid.m index a8c7e5a..c5d7b79 100644 --- a/test/+wt/+test/ButtonGrid.m +++ b/test/+wt/+test/ButtonGrid.m @@ -37,7 +37,7 @@ function testCreationByIcon(testCase) testCase.verifySetProperty("Icon", icon); diag = "Expected update to run without warnings."; - testCase.verifyWarningFree(@()testCase.Widget.forceUpdate(), diag) + testCase.verifyWarningFree(@()testCase.Widget.forceUpdate(false), diag) end %function @@ -55,7 +55,7 @@ function testCreationByTextAndIcon(testCase) testCase.verifyNumElements(testCase.Widget.Button, expNum) diag = "Expected update to run without warnings."; - testCase.verifyWarningFree(@()testCase.Widget.forceUpdate(), diag) + testCase.verifyWarningFree(@()testCase.Widget.forceUpdate(false), diag) end %function @@ -69,7 +69,7 @@ function testEmptyButtons(testCase) testCase.verifyEmpty(testCase.Widget.Button) diag = "Expected update to run without warnings."; - testCase.verifyWarningFree(@()testCase.Widget.forceUpdate(), diag) + testCase.verifyWarningFree(@()testCase.Widget.forceUpdate(false), diag) end %function @@ -87,7 +87,7 @@ function testMissingIcons(testCase) testCase.verifyNumElements(testCase.Widget.Button, expNum) diag = "Expected update to run without warnings."; - testCase.verifyWarningFree(@()testCase.Widget.forceUpdate(), diag) + testCase.verifyWarningFree(@()testCase.Widget.forceUpdate(false), diag) end %function @@ -105,7 +105,7 @@ function testMissingText(testCase) testCase.verifyNumElements(testCase.Widget.Button, expNum) diag = "Expected update to run without warnings."; - testCase.verifyWarningFree(@()testCase.Widget.forceUpdate(), diag) + testCase.verifyWarningFree(@()testCase.Widget.forceUpdate(false), diag) end %function @@ -125,7 +125,7 @@ function testExtraTooltip(testCase) testCase.verifyNumElements(testCase.Widget.Button, expNum) diag = "Expected update to run without warnings."; - testCase.verifyWarningFree(@()testCase.Widget.forceUpdate(), diag) + testCase.verifyWarningFree(@()testCase.Widget.forceUpdate(false), diag) end %function @@ -158,7 +158,7 @@ function testPressButton(testCase) testCase.verifyEqual(string({evts.Tag}), tag) diag = "Expected update to run without warnings."; - testCase.verifyWarningFree(@()testCase.Widget.forceUpdate(), diag) + testCase.verifyWarningFree(@()testCase.Widget.forceUpdate(false), diag) end %function @@ -171,7 +171,7 @@ function testBackgroundColor(testCase) testCase.verifyEqual(testCase.Widget.Grid.BackgroundColor, newValue); diag = "Expected update to run without warnings."; - testCase.verifyWarningFree(@()testCase.Widget.forceUpdate(), diag) + testCase.verifyWarningFree(@()testCase.Widget.forceUpdate(false), diag) end %function @@ -193,7 +193,7 @@ function testOrientation(testCase) testCase.verifyNumElements(testCase.Widget.Grid.ColumnWidth, 1); diag = "Expected update to run without warnings."; - testCase.verifyWarningFree(@()testCase.Widget.forceUpdate(), diag) + testCase.verifyWarningFree(@()testCase.Widget.forceUpdate(false), diag) end %function @@ -228,7 +228,7 @@ function testIconAlignment(testCase) testCase.verifyMatches(button.IconAlignment, newValue); diag = "Expected update to run without warnings."; - testCase.verifyWarningFree(@()testCase.Widget.forceUpdate(), diag) + testCase.verifyWarningFree(@()testCase.Widget.forceUpdate(false), diag) end %function @@ -254,7 +254,7 @@ function testButtonWidthHeight(testCase) testCase.verifyEqual(testCase.Widget.ButtonWidth, {10 20 30 30}) diag = "Expected update to run without warnings."; - testCase.verifyWarningFree(@()testCase.Widget.forceUpdate(), diag) + testCase.verifyWarningFree(@()testCase.Widget.forceUpdate(false), diag) % Change to vertical layout newOrientation = "vertical"; @@ -272,7 +272,7 @@ function testButtonWidthHeight(testCase) testCase.verifySetProperty("ButtonWidth", 20, {20}) diag = "Expected update to run without warnings."; - testCase.verifyWarningFree(@()testCase.Widget.forceUpdate(), diag) + testCase.verifyWarningFree(@()testCase.Widget.forceUpdate(false), diag) end diff --git a/widgets/+wt/+abstract/BaseViewChart.m b/widgets/+wt/+abstract/BaseViewChart.m index 0953dde..4700a88 100644 --- a/widgets/+wt/+abstract/BaseViewChart.m +++ b/widgets/+wt/+abstract/BaseViewChart.m @@ -64,10 +64,18 @@ %% Debugging Methods methods - function forceUpdateChart(obj) + function forceUpdateChart(obj, showMessage) % Forces update to run (For debugging only!) - disp("DEBUG: Forcing update for " + class(obj)); + arguments + obj + showMessage (1,1) logical = true + end + + if showMessage + disp("DEBUG: Forcing update for " + class(obj)); + end + obj.update(); end %function diff --git a/widgets/+wt/+abstract/BaseViewController.m b/widgets/+wt/+abstract/BaseViewController.m index b735a4b..05185cd 100644 --- a/widgets/+wt/+abstract/BaseViewController.m +++ b/widgets/+wt/+abstract/BaseViewController.m @@ -85,10 +85,18 @@ %% Debugging Methods methods - function forceUpdate(obj) + function forceUpdate(obj, showMessage) % Forces update to run (For debugging only!) - disp("DEBUG: Forcing update for " + class(obj)); + arguments + obj + showMessage (1,1) logical = true + end + + if showMessage + disp("DEBUG: Forcing update for " + class(obj)); + end + obj.update(); end %function diff --git a/widgets/+wt/+abstract/BaseWidget.m b/widgets/+wt/+abstract/BaseWidget.m index 1fa0fbe..113672f 100644 --- a/widgets/+wt/+abstract/BaseWidget.m +++ b/widgets/+wt/+abstract/BaseWidget.m @@ -54,10 +54,18 @@ %% Debugging Methods methods - function forceUpdate(obj) + function forceUpdate(obj, showMessage) % Forces update to run (For debugging only!) - disp("DEBUG: Forcing update for " + class(obj)); + arguments + obj + showMessage (1,1) logical = true + end + + if showMessage + disp("DEBUG: Forcing update for " + class(obj)); + end + obj.update(); end %function