Skip to content

Commit 9d8f756

Browse files
committed
fixes to ContextualViewExample for new syntax, fix ZooHierarchy app to prevent warning on load session, update TitleFontStyled to use new default title color in pre-25a. all tests pass in 21a and 25aPR
1 parent 22bc6bb commit 9d8f756

File tree

5 files changed

+87
-92
lines changed

5 files changed

+87
-92
lines changed

test/+wt/+test/ProjectIntegrityChecks.m

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
11
classdef ProjectIntegrityChecks < matlab.unittest.TestCase
22
% Implements a unit test that runs the Project Integrity Checks
33

4-
properties(Access = private)
5-
DoNotRun = verLessThan("MATLAB", "9.9"); %#ok<VERLESSMATLAB> to support running this in < R2020b
6-
end
74

85
methods(Test)
96
function runProjectChecks(testCase)
10-
% do not continue if DoNotRun is set
11-
testCase.assumeFalse(testCase.DoNotRun, "Integrity Checks can only be run on R2020b or newer programmatically.")
127

138
% find project root folder based on this file (3 folders up)
149
prjFolder = fileparts(fileparts(fileparts(fileparts(mfilename("fullpath")))));

test/+wt/+test/ZooHierarchyApp.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -312,9 +312,9 @@ function testSaveLoadSession(testCase)
312312
diag);
313313

314314
% Verify name in view matches
315-
% diag = "Expected updated name to display in the view after loading.";
316-
% actVal = view.NameField.Value;
317-
% testCase.verifyMatches(actVal, newName, diag);
315+
% diag = "Expected updated name to display in the view after loading.";
316+
% actVal = view.NameField.Value;
317+
% testCase.verifyMatches(actVal, newName, diag);
318318

319319
end %function
320320

Lines changed: 83 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,217 +1,217 @@
11
classdef TitleFontStyled < handle
22
% Mixin for component with Font properties
3-
3+
44
% Copyright 2020-2025 The MathWorks Inc.
5-
6-
5+
6+
77
%% Properties
88
properties (AbortSet)
9-
9+
1010
% Font name
1111
TitleFontName char {mustBeNonempty} = 'Helvetica'
12-
12+
1313
% Font size in points
1414
TitleFontSize (1,1) double {mustBePositive,mustBeFinite} = 14
15-
15+
1616
% Font weight (normal/bold)
1717
TitleFontWeight (1,1) wt.enum.FontWeightState = 'bold'
18-
18+
1919
% Font angle (normal/italic)
2020
TitleFontAngle (1,1) wt.enum.FontAngleState = 'normal'
21-
21+
2222
end %properties
23-
24-
23+
24+
2525
properties (AbortSet, Dependent)
26-
26+
2727
% Font Color
2828
TitleColor (1,3) double {mustBeInRange(TitleColor,0,1)}
29-
29+
3030
end %properties
31-
32-
31+
32+
3333
properties (AbortSet, NeverAmbiguous)
34-
34+
3535
% Font color mode
3636
TitleColorMode (1,1) wt.enum.AutoManualState = 'auto'
37-
37+
3838
end %properties
39-
40-
39+
40+
4141
%% Internal properties
4242
properties (AbortSet, Hidden)
43-
43+
4444
% Font Color
45-
TitleColor_I (1,3) double {mustBeInRange(TitleColor_I,0,1)} = [0 0 0]
46-
45+
TitleColor_I (1,3) double {mustBeInRange(TitleColor_I,0,1)} = [0.38 0.38 0.38];
46+
4747
end %properties
48-
49-
48+
49+
5050
properties (AbortSet, Transient, NonCopyable, Hidden, SetAccess = protected)
51-
51+
5252
% List of graphics controls to apply to
5353
TitleFontStyledComponents (:,1) matlab.graphics.Graphics
54-
54+
5555
end %properties
56-
57-
56+
57+
5858
properties (Transient, NonCopyable, Access = private)
59-
59+
6060
% Listener for theme changes
6161
ThemeChangedListener event.listener
62-
62+
6363
end %properties
64-
65-
64+
65+
6666
%% Property Accessors
67-
67+
6868
methods
69-
69+
7070
function set.TitleFontName(obj,value)
7171
obj.TitleFontName = value;
7272
obj.updateTitleFontStyledComponents("FontName",value)
7373
end
74-
74+
7575
function set.TitleFontSize(obj,value)
7676
obj.TitleFontSize = value;
7777
obj.updateTitleFontStyledComponents("FontSize",value)
7878
end
79-
79+
8080
function set.TitleFontWeight(obj,value)
8181
obj.TitleFontWeight = value;
8282
obj.updateTitleFontStyledComponents("FontWeight",value)
8383
end
84-
84+
8585
function set.TitleFontAngle(obj,value)
8686
obj.TitleFontAngle = value;
8787
obj.updateTitleFontStyledComponents("FontAngle",value)
8888
end
89-
89+
9090
function value = get.TitleColor(obj)
9191
value = obj.TitleColor_I;
9292
end
93-
93+
9494
function set.TitleColor(obj, value)
9595
obj.TitleColorMode = 'manual';
9696
obj.TitleColor_I = value;
9797
end
98-
98+
9999
function set.TitleColorMode(obj, value)
100100
obj.TitleColorMode = value;
101101
obj.applyTheme();
102102
end
103-
103+
104104
function set.TitleColor_I(obj,value)
105105
obj.TitleColor_I = value;
106106
obj.updateTitleFontStyledComponents("FontColor", obj.TitleColor_I);
107107
end
108-
108+
109109
function set.TitleFontStyledComponents(obj,value)
110110
obj.TitleFontStyledComponents = value;
111111
obj.applyTheme();
112112
obj.updateTitleFontStyledComponents()
113113
end
114-
114+
115115
end %methods
116-
117-
116+
117+
118118
%% Constructor
119119
methods
120-
120+
121121
function obj = TitleFontStyled()
122-
122+
123123
% Confirm BaseWidget and R2025a or newer
124124
if matches("WidgetThemeChanged", events(obj)) ...
125125
&& ~isMATLABReleaseOlderThan("R2025a")
126-
126+
127127
% Listen to theme changes
128128
obj.ThemeChangedListener = ...
129129
listener(obj, "WidgetThemeChanged", @(~,~)applyTheme(obj));
130-
130+
131131
end %if
132-
132+
133133
end %function
134-
134+
135135
end %methods
136-
137-
136+
137+
138138
%% Protected Methods
139139
methods (Access = protected)
140-
140+
141141
function updateTitleFontStyledComponents(obj,prop,value)
142-
142+
143143
% Get the components
144144
comps = obj.TitleFontStyledComponents;
145-
145+
146146
% Font color properties in prioritized order
147147
colorProps = ["TitleColor","FontColor","ForegroundColor"];
148-
148+
149149
% Updating all or a specific property?
150150
if nargin < 3
151-
151+
152152
% Set all subcomponent properties
153153
wt.utility.setStylePropsInPriority(comps,"FontName",obj.TitleFontName)
154154
wt.utility.setStylePropsInPriority(comps,"FontSize",obj.TitleFontSize)
155155
wt.utility.setStylePropsInPriority(comps,"FontWeight",obj.TitleFontWeight)
156156
wt.utility.setStylePropsInPriority(comps,"FontAngle",obj.TitleFontAngle)
157157
wt.utility.setStylePropsInPriority(comps,colorProps, obj.TitleColor_I);
158-
158+
159159
elseif prop == "FontColor"
160160
% Update just the FontColor property
161-
161+
162162
% Set the subcomponent property
163163
wt.utility.setStylePropsInPriority(comps, colorProps, value);
164-
164+
165165
else
166-
166+
167167
% Set the subcomponent property
168168
wt.utility.setStylePropsInPriority(comps, prop, value);
169-
169+
170170
end %if
171-
171+
172172
end %function
173-
174-
173+
174+
175175
function color = getDefaultTitleColor(obj)
176176
% Returns the default color for 'auto' mode (R2025a and later)
177177
% The result is dependent on theme
178178
% Widget subclass may override this
179-
179+
180180
try
181181
color = obj.getThemeColor("--mw-color-secondary"); %#ok<MCNPN>
182-
182+
183183
catch exception
184-
184+
185185
color = obj.TitleColor_I;
186-
186+
187187
id = "wt:applyTheme:getThemeColorFail";
188188
msg = "Unable to get default theme color: %s";
189189
warning(id, msg, exception.message)
190-
190+
191191
end %try
192-
192+
193193
end %function
194-
194+
195195
end %methods
196-
197-
196+
197+
198198
%% Private Methods
199199
methods (Access = private)
200-
200+
201201
function applyTheme(obj)
202-
202+
203203
% If color mode is auto, use standard theme color
204204
if obj.TitleColorMode == "auto" ...
205205
&& ~isMATLABReleaseOlderThan("R2025a")
206-
206+
207207
% Use standard theme color
208-
obj.TitleColor_I = obj.getDefaultTitleColor();
209-
208+
obj.TitleColor_I = obj.getDefaultTitleColor();
209+
210210
end %if
211-
211+
212212
end %function
213-
213+
214214
end %methods
215-
216-
215+
216+
217217
end %classdef

widgets/examples/+zooexample/+app/@ZooHierarchy/update.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function update(app)
3131
%% Update the ContextualView contents
3232

3333
% What type of selection?
34-
if isscalar(selectionData.Model)
34+
if isscalar(selectionData.Model) && isvalid(selectionData.Model)
3535
% Choose view that matches the model type
3636

3737
% Which view to launch?
-5.52 KB
Binary file not shown.

0 commit comments

Comments
 (0)