Skip to content

Commit 1f8df7f

Browse files
committed
Working on Migrating Widgets Base Class to Separate Mixables
- Modifying PasswordField
1 parent f828222 commit 1f8df7f

File tree

3 files changed

+48
-6
lines changed

3 files changed

+48
-6
lines changed

widgets/+wt/+mixin/GridOrganized.m

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
classdef GridOrganized < handle
2+
% Mixin for component to be organized within a 1x1 UIGridLayout
3+
%
4+
5+
%% Properties
6+
properties (AbortSet, Transient, NonCopyable)
7+
8+
% GridLayout
9+
Grid (1,1) matlab.ui.container.GridLayout = uigridlayout;
10+
11+
% List of graphics controls that BackgroundColor should apply to
12+
BackgroundColorableComponents (:,1) matlab.graphics.Graphics
13+
14+
end
15+
16+
17+
%% Accessors
18+
methods (Access = protected)
19+
20+
function updateBackgroundColorableComponents(obj)
21+
% Update components that are affected by BackgroundColor
22+
23+
hasProp = isprop(obj.BackgroundColorableComponents,'BackgroundColor');
24+
set(obj.BackgroundColorableComponents(hasProp),...
25+
"BackgroundColor",obj.BackgroundColor);
26+
27+
end %function
28+
end
29+
end

widgets/+wt/ButtonGrid.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
classdef ButtonGrid < wt.abstract.BaseWidget &...
1+
classdef ButtonGrid < matlab.ui.componentcontainer.ComponentContainer &...
22
wt.mixin.Enableable & wt.mixin.FontStyled & wt.mixin.ButtonColorable
33
% A grid of buttons with a single callback/event
44

widgets/+wt/PasswordField.m

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
classdef PasswordField < wt.abstract.BaseWidget
1+
classdef PasswordField < matlab.ui.componentcontainer.ComponentContainer & ...
2+
wt.mixin.ErrorHandling & wt.mixin.GridOrganized
3+
24
% A password entry field
35

46
% Copyright 2020-2021 The MathWorks Inc.
@@ -24,8 +26,7 @@
2426

2527

2628
%% Internal Properties
27-
properties ( Transient, NonCopyable, ...
28-
Access = {?wt.abstract.BaseWidget, ?wt.test.BaseWidgetTest} )
29+
properties ( Transient, NonCopyable)
2930

3031
% Password control
3132
PasswordControl (1,1) matlab.ui.control.HTML
@@ -39,8 +40,8 @@
3940

4041
function setup(obj)
4142

42-
% Call superclass setup first to establish the grid
43-
obj.setup@wt.abstract.BaseWidget();
43+
% Establish Grid for Control
44+
obj.establishGrid();
4445

4546
% Set default size
4647
obj.Position(3:4) = [100 25];
@@ -65,6 +66,18 @@ function setup(obj)
6566
'DataChangedFcn',@(h,e)obj.onPasswordChanged(e) );
6667

6768
end %function
69+
70+
function establishGrid(obj)
71+
72+
% Construct Grid Layout to Manage Building Blocks
73+
obj.Grid = uigridlayout(obj);
74+
obj.Grid.ColumnWidth = {'1x'};
75+
obj.Grid.RowHeight = {'1x'};
76+
obj.Grid.RowSpacing = 2;
77+
obj.Grid.ColumnSpacing = 2;
78+
obj.Grid.Padding = [2];
79+
80+
end
6881

6982

7083
function update(obj)

0 commit comments

Comments
 (0)