Skip to content

Commit cd98d96

Browse files
committed
Issue Fix #28
- Variety of small changes made to the widgets tools. - Removed redundant calls to obj.listenForBackgroundChange where BackgroundColorable was involved. - Removed GridOrganized mixin class and created individual grid properties for each widget object - Removed unused ErrorHandling mixins where not used - Cleaned up property accessors to only give access to Component Container or the Widget Test Class. No longer allows access to BaseWidget - Updated copyright from 2021 to 2022 for all Widgets Additionally, for ListSelector and ListSelectorTwoPane: - removed pass-through requestUpdate method - now we just call the update method directly from a button press callback
1 parent 26d8e2f commit cd98d96

14 files changed

+197
-132
lines changed

widgets/+wt/ButtonGrid.m

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
classdef ButtonGrid < matlab.ui.componentcontainer.ComponentContainer & ...
2-
wt.mixin.ErrorHandling & wt.mixin.GridOrganized & ...
32
wt.mixin.BackgroundColorable & ...
43
wt.mixin.Enableable & wt.mixin.FontStyled & wt.mixin.ButtonColorable
54

65
% A grid of buttons with a single callback/event
76

8-
% Copyright 2020-2021 The MathWorks Inc.
7+
% Copyright 2020-2022 The MathWorks Inc.
8+
99

1010

1111
%% Events
@@ -29,6 +29,9 @@
2929

3030
% Tooltip
3131
Tooltip (1,:) string
32+
33+
% Grid
34+
Grid (1,1) matlab.ui.container.GridLayout
3235

3336
% Tag
3437
ButtonTag (1,:) string
@@ -59,7 +62,7 @@
5962

6063
%% Internal Properties
6164
properties ( Transient, NonCopyable, ...
62-
Access = {?matlab.ui.componentcontainer.ComponentContainer} )
65+
Access = {?matlab.ui.componentcontainer.ComponentContainer, ?wt.test.BaseWidgetTest} )
6366

6467
% Buttons (other widgets like ListSelector also access this)
6568
Button (1,:) matlab.ui.control.Button
@@ -73,12 +76,16 @@
7376

7477
function setup(obj)
7578

76-
% Call superclass setup to establish the main grid
77-
obj.establishGrid();
79+
% Create and set Default Grid Properties
80+
obj.Grid = uigridlayout(obj);
81+
obj.Grid.ColumnWidth = {'1x'};
82+
obj.Grid.RowHeight = {'1x'};
83+
obj.Grid.RowSpacing = 2;
84+
obj.Grid.ColumnSpacing = 2;
85+
obj.Grid.Padding = 2;
7886

7987
% Establish Background Color Listener
8088
obj.BackgroundColorableComponents = obj.Grid;
81-
obj.listenForBackgroundChange();
8289

8390
% Set default size
8491
obj.Position(3:4) = [100 30];

widgets/+wt/CheckboxList.m

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
classdef CheckboxList < matlab.ui.componentcontainer.ComponentContainer & ...
2-
wt.mixin.ErrorHandling & wt.mixin.GridOrganized & ...
3-
wt.mixin.Enableable & wt.mixin.FontStyled & wt.mixin.Tooltipable
2+
wt.mixin.Enableable & wt.mixin.FontStyled & wt.mixin.Tooltipable & ...
3+
wt.mixin.BackgroundColorable
44

55

66
% A checkbox list
77

8-
% Copyright 2020-2021 The MathWorks Inc.
8+
% Copyright 2020-2022 The MathWorks Inc.
99

1010

1111
%% Public properties
@@ -20,6 +20,7 @@
2020
"Item 5"
2121
"Item 6"
2222
]
23+
2324

2425
% The current value shown
2526
Value (:,1) logical = true(6,1)
@@ -43,10 +44,13 @@
4344

4445
%% Internal Properties
4546
properties ( Transient, NonCopyable, ...
46-
Access = {?wt.abstract.BaseWidget, ?wt.test.BaseWidgetTest, ?matlab.ui.componentcontainer.ComponentContainer} )
47+
Access = {?wt.test.BaseWidgetTest, ?matlab.ui.componentcontainer.ComponentContainer} )
4748

4849
% Item checkboxes
4950
ItemCheck (1,:) matlab.ui.control.CheckBox
51+
52+
% Grid
53+
Grid (1,1) matlab.ui.container.GridLayout
5054

5155
% Select All checkbox
5256
AllCheck (1,1) matlab.ui.control.CheckBox
@@ -60,13 +64,17 @@
6064

6165
function setup(obj)
6266

63-
% Call Grid setup first to establish the grid
64-
obj.establishGrid();
65-
66-
% Establish Background Color Listener
67-
%obj.BackgroundColorableComponents = obj.Grid;
68-
%obj.listenForBackgroundChange();
67+
% Construct Grid Layout to Manage Building Blocks
68+
obj.Grid = uigridlayout(obj);
69+
obj.Grid.ColumnWidth = {'1x'};
70+
obj.Grid.RowHeight = {'1x'};
71+
obj.Grid.RowSpacing = 2;
72+
obj.Grid.ColumnSpacing = 2;
73+
obj.Grid.Padding = 2;
6974

75+
% Allow Background Color to be Changed
76+
obj.BackgroundColorableComponents = obj.Grid;
77+
7078
% Set default size
7179
obj.Position(3:4) = [100 130];
7280

@@ -77,8 +85,8 @@ function setup(obj)
7785
obj.Grid.RowSpacing = 5;
7886
obj.Grid.Scrollable = true;
7987

80-
% Default background to white
81-
obj.BackgroundColor = [1 1 1];
88+
% Default background to Control Color
89+
obj.BackgroundColor = [0.94 0.94 0.94];
8290

8391
% Create the Select All checkbox
8492
obj.AllCheck = matlab.ui.control.CheckBox(...

widgets/+wt/ColorSelector.m

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
classdef ColorSelector < matlab.ui.componentcontainer.ComponentContainer & ...
2-
wt.mixin.ErrorHandling & wt.mixin.GridOrganized &...
32
wt.mixin.Enableable & wt.mixin.FontStyled & wt.mixin.Tooltipable & ...
43
wt.mixin.FieldColorable
54
% A color selection control with browse button
65

7-
% Copyright 2020-2021 The MathWorks Inc.
6+
% Copyright 2020-2022 The MathWorks Inc.
87

98

109
%% Public properties
@@ -37,10 +36,13 @@
3736

3837
%% Internal Properties
3938
properties ( Transient, NonCopyable, ...
40-
Access = {?wt.abstract.BaseWidget, ?wt.test.BaseWidgetTest, ?matlab.ui.componentcontainerComponentContainer} )
39+
Access = {?wt.test.BaseWidgetTest, ?matlab.ui.componentcontainer.ComponentContainer} )
4140

4241
% Button
4342
ButtonControl (1,1) matlab.ui.control.Button
43+
44+
% Grid
45+
Grid (1,1) matlab.ui.container.GridLayout
4446

4547
% Edit control
4648
EditControl (1,1) matlab.ui.control.EditField
@@ -54,8 +56,13 @@
5456

5557
function setup(obj)
5658

57-
% Call superclass setup first to establish the grid
58-
obj.establishGrid();
59+
% Construct Grid Layout to Manage Building Blocks
60+
obj.Grid = uigridlayout(obj);
61+
obj.Grid.ColumnWidth = {'1x'};
62+
obj.Grid.RowHeight = {'1x'};
63+
obj.Grid.RowSpacing = 2;
64+
obj.Grid.ColumnSpacing = 2;
65+
obj.Grid.Padding = 2;
5966

6067
% Set default size
6168
obj.Position(3:4) = [100 25];

widgets/+wt/DatetimeSelector.m

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
classdef DatetimeSelector < matlab.ui.componentcontainer.ComponentContainer & ...
2-
wt.mixin.ErrorHandling & wt.mixin.GridOrganized & ...
32
wt.mixin.Enableable & wt.mixin.FontStyled & wt.mixin.FieldColorable
43
% A date and time selection control
54

6-
% Copyright 2021 The MathWorks Inc.
5+
% Copyright 2022 The MathWorks Inc.
76

87

98
%% Events
@@ -50,10 +49,13 @@
5049

5150
%% Internal Properties
5251
properties ( Transient, NonCopyable, ...
53-
Access = {?wt.abstract.BaseWidget, ?wt.test.BaseWidgetTest} )
52+
Access = {?wt.test.BaseWidgetTest, ?matlab.ui.componentcontainer.ComponentContainer} )
5453

5554
% Button
5655
DateControl (1,1) matlab.ui.control.DatePicker
56+
57+
% Grid
58+
Grid (1,1) matlab.ui.container.GridLayout
5759

5860
% Hour control
5961
HourControl (1,1) matlab.ui.control.Spinner
@@ -84,8 +86,13 @@ function setup(obj)
8486
"TimeZone","local",...
8587
"Format","dd-MMM-uuuu hh:mm aa");
8688

87-
% Call Grid Mixin first to establish the grid
88-
obj.establishGrid();
89+
% Construct Default Grid Layout to Manage Building Blocks
90+
obj.Grid = uigridlayout(obj);
91+
obj.Grid.ColumnWidth = {'1x'};
92+
obj.Grid.RowHeight = {'1x'};
93+
obj.Grid.RowSpacing = 2;
94+
obj.Grid.ColumnSpacing = 2;
95+
obj.Grid.Padding = 2;
8996

9097
% Configure Grid
9198
obj.Grid.ColumnWidth = {'9x',5,'4x','4x',0,0};

widgets/+wt/FileSelector.m

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
classdef FileSelector < matlab.ui.componentcontainer.ComponentContainer & ...
2-
wt.mixin.ErrorHandling & wt.mixin.GridOrganized &...
2+
wt.mixin.ErrorHandling & ...
33
wt.mixin.Enableable & wt.mixin.FontStyled & wt.mixin.Tooltipable &...
44
wt.mixin.FieldColorable & wt.mixin.ButtonColorable
55
% A file/folder selection control with browse button
66

7-
% Copyright 2020-2021 The MathWorks Inc.
7+
% Copyright 2020-2022 The MathWorks Inc.
88

99

1010
%% Public properties
@@ -71,10 +71,13 @@
7171

7272
%% Internal Properties
7373
properties ( Transient, NonCopyable, ...
74-
Access = {?wt.abstract.BaseWidget, ?wt.test.BaseWidgetTest, ?matlab.ui.componentcontainer.ComponentContainer} )
74+
Access = {?wt.test.BaseWidgetTest, ?matlab.ui.componentcontainer.ComponentContainer} )
7575

7676
% Button
7777
ButtonControl (1,1) matlab.ui.control.Button
78+
79+
% Grid
80+
Grid (1,1) matlab.ui.container.GridLayout
7881

7982
% Edit control or dropdown
8083
EditControl (1,1) matlab.ui.control.EditField
@@ -92,8 +95,13 @@ function setup(obj)
9295
% Adjust default size
9396
obj.Position(3:4) = [200 25];
9497

95-
% Call Grid setup first to establish the grid
96-
obj.establishGrid();
98+
% Construct Grid Layout to Manage Building Blocks
99+
obj.Grid = uigridlayout(obj);
100+
obj.Grid.ColumnWidth = {'1x'};
101+
obj.Grid.RowHeight = {'1x'};
102+
obj.Grid.RowSpacing = 2;
103+
obj.Grid.ColumnSpacing = 2;
104+
obj.Grid.Padding = 2;
97105

98106
% Configure Grid
99107
obj.Grid.ColumnWidth = {'1x',25};

widgets/+wt/ListSelector.m

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
classdef ListSelector < matlab.ui.componentcontainer.ComponentContainer & ...
2-
wt.mixin.ErrorHandling & wt.mixin.BackgroundColorable & ...
3-
wt.mixin.GridOrganized & wt.mixin.Enableable &...
2+
wt.mixin.BackgroundColorable & wt.mixin.Enableable &...
43
wt.mixin.FontStyled & wt.mixin.ButtonColorable &...
54
wt.mixin.FieldColorable
65

76
% Select from an array of items and add them to a list
87

9-
% Copyright 2020-2021 The MathWorks Inc.
8+
% Copyright 2020-2022 The MathWorks Inc.
109

1110

1211
%% Events
@@ -82,10 +81,13 @@
8281

8382
%% Internal Properties
8483
properties (Transient, NonCopyable, ...
85-
Access = {?wt.test.BaseWidgetTest, ?matlab.ui.componentcontainerComponentContainer})
84+
Access = {?wt.test.BaseWidgetTest, ?matlab.ui.componentcontainer.ComponentContainer})
8685

8786
% The ListBox control
8887
ListBox (1,1) matlab.ui.control.ListBox
88+
89+
% Grid
90+
Grid (1,1) matlab.ui.container.GridLayout
8991

9092
% The list sorting buttons
9193
ListButtons wt.ButtonGrid
@@ -102,11 +104,13 @@
102104

103105
function setup(obj)
104106

105-
% Call superclass setup to establish the main grid
106-
obj.establishGrid();
107-
108-
% Establish Background Color Listener
109-
obj.listenForBackgroundChange();
107+
% Construct Default Grid Layout to Manage Building Blocks
108+
obj.Grid = uigridlayout(obj);
109+
obj.Grid.ColumnWidth = {'1x'};
110+
obj.Grid.RowHeight = {'1x'};
111+
obj.Grid.RowSpacing = 2;
112+
obj.Grid.ColumnSpacing = 2;
113+
obj.Grid.Padding = 2;
110114

111115
% Set default size
112116
obj.Position(3:4) = [120 130];
@@ -144,7 +148,7 @@ function setup(obj)
144148
'ButtonPushed',@(h,e)obj.onButtonPushed(e) );
145149

146150
% Update the internal component lists
147-
obj.BackgroundColorableComponents = [obj.ListButtons, obj.UserButtons];
151+
obj.BackgroundColorableComponents = [obj.ListButtons, obj.UserButtons obj.Grid];
148152
obj.FontStyledComponents = [obj.ListBox, obj.UserButtons, obj.ListButtons];
149153
obj.EnableableComponents = [obj.ListBox, obj.UserButtons, obj.ListButtons];
150154
obj.ButtonColorableComponents = [obj.UserButtons obj.ListButtons];
@@ -166,13 +170,6 @@ function update(obj)
166170
obj.updateEnables();
167171

168172
end %function
169-
170-
function requestUpdate(obj)
171-
172-
% Request Update Method to Run
173-
obj.update();
174-
175-
end
176173

177174

178175
function updateEnables(obj)
@@ -267,7 +264,7 @@ function onButtonPushed(obj,evt)
267264
end %switch
268265

269266
% Request update
270-
obj.requestUpdate();
267+
obj.update();
271268

272269
end %function
273270

0 commit comments

Comments
 (0)