diff --git a/widgets/+wt/+enum/FontAngleState.m b/widgets/+wt/+enum/FontAngleState.m new file mode 100644 index 0000000..5dd1147 --- /dev/null +++ b/widgets/+wt/+enum/FontAngleState.m @@ -0,0 +1,14 @@ +classdef FontAngleState + %FONTANGLESTATE Represents font angle selections + % Enumerates a list of choices + + + %% Enumerations + enumeration + normal + italic + end %enumeration + + +end %classdef + diff --git a/widgets/+wt/+enum/FontWeightState.m b/widgets/+wt/+enum/FontWeightState.m new file mode 100644 index 0000000..e1fec27 --- /dev/null +++ b/widgets/+wt/+enum/FontWeightState.m @@ -0,0 +1,14 @@ +classdef FontWeightState + %FONTWEIGHTSTATE Represents font weight selections + % Enumerates a list of choices + + + %% Enumerations + enumeration + normal + bold + end %enumeration + + +end %classdef + diff --git a/widgets/+wt/+eventdata/PropertyChangedData.m b/widgets/+wt/+eventdata/PropertyChangedData.m index b83d1ef..24581c3 100644 --- a/widgets/+wt/+eventdata/PropertyChangedData.m +++ b/widgets/+wt/+eventdata/PropertyChangedData.m @@ -24,8 +24,12 @@ % Set the changed property name obj.Property = propName; - % Is input a MATLAB eventdata? - if isa(newValue,'matlab.ui.eventdata.ValueChangedData') + % Is input a MATLAB or widget eventdata? + if isa(newValue,'wt.eventdata.ValueChangedData') || ... + isa(newValue,'wt.eventdata.PropertyChangedData') + obj.Value = newValue.Value; + obj.PreviousValue = newValue.PreviousValue; + elseif isa(newValue,'matlab.ui.eventdata.ValueChangedData') obj.Value = newValue.Value; obj.PreviousValue = newValue.PreviousValue; elseif isa(newValue,'matlab.ui.eventdata.ValueChangingData') @@ -42,9 +46,9 @@ end % Any remaining varargin are dynamic property-value pairs - for idx=1:numel(varargin) - thisProp = varargin{idx}; - thisValue = remArgs.(thisProp); + for idx = 1:floor(numel(varargin) / 2) + thisProp = varargin{(idx - 1) * 2 + 1}; + thisValue = varargin{(idx - 1) * 2 + 2}; obj.addprop(thisProp); obj.(thisProp) = thisValue; end diff --git a/widgets/+wt/+eventdata/ValueChangedData.m b/widgets/+wt/+eventdata/ValueChangedData.m index ed8d763..b84950e 100644 --- a/widgets/+wt/+eventdata/ValueChangedData.m +++ b/widgets/+wt/+eventdata/ValueChangedData.m @@ -25,8 +25,12 @@ previousValue = [] end - % Is input a MATLAB eventdata? - if isa(newValue,'matlab.ui.eventdata.ValueChangedData') + % Is input a MATLAB or widget eventdata? + if isa(newValue,'wt.eventdata.ValueChangedData') || ... + isa(newValue,'wt.eventdata.PropertyChangedData') + obj.Value = newValue.Value; + obj.PreviousValue = newValue.PreviousValue; + elseif isa(newValue,'matlab.ui.eventdata.ValueChangedData') obj.Value = newValue.Value; obj.PreviousValue = newValue.PreviousValue; elseif isa(newValue,'matlab.ui.eventdata.ValueChangingData') diff --git a/widgets/+wt/+mixin/FontStyled.m b/widgets/+wt/+mixin/FontStyled.m index abe3235..3b9d895 100644 --- a/widgets/+wt/+mixin/FontStyled.m +++ b/widgets/+wt/+mixin/FontStyled.m @@ -14,10 +14,10 @@ FontSize (1,1) double {mustBePositive,mustBeFinite} = 12 % Font weight (normal/bold) - FontWeight {mustBeMember(FontWeight,{'normal','bold'})} = 'normal' + FontWeight (1,1) wt.enum.FontWeightState = 'normal' % Font angle (normal/italic) - FontAngle {mustBeMember(FontAngle,{'normal','italic'})} = 'normal' + FontAngle (1,1) wt.enum.FontAngleState = 'normal' % Font color FontColor (1,3) double {wt.validators.mustBeBetweenZeroAndOne} = [0 0 0] diff --git a/widgets/+wt/+utility/convertEnumToValue.m b/widgets/+wt/+utility/convertEnumToValue.m new file mode 100644 index 0000000..b4c77d7 --- /dev/null +++ b/widgets/+wt/+utility/convertEnumToValue.m @@ -0,0 +1,17 @@ +function value = convertEnumToValue(value) +% Convert enumaration value to its double or string associated value + +valueClass = class(value); + +% Is the value enumerate? +if startsWith(valueClass, 'wt.enum') + % Can value be converted? + if ismethod(value, 'double') + value = double(value); + elseif ismethod(value, 'string') + value = string(value); + elseif ismethod(value, 'char') + value = char(value); + end +end %if +end %function \ No newline at end of file diff --git a/widgets/+wt/+utility/setStylePropsInPriority.m b/widgets/+wt/+utility/setStylePropsInPriority.m index 1d9c142..c3a0145 100644 --- a/widgets/+wt/+utility/setStylePropsInPriority.m +++ b/widgets/+wt/+utility/setStylePropsInPriority.m @@ -12,6 +12,9 @@ function setStylePropsInPriority(comps, propNames, value) value end +% Convert enumerate value +value = wt.utility.convertEnumToValue(value); + % Filter any invalid components comps(~isvalid(comps)) = [];