Skip to content

Commit 0377ea5

Browse files
committed
Introduce button width/height.
Introduce button width and button height for ListSelector and ListSelectorTwoPane.
1 parent 2367036 commit 0377ea5

File tree

2 files changed

+30
-40
lines changed

2 files changed

+30
-40
lines changed

widgets/+wt/ListSelector.m

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,12 @@
3939
% Items or custom using ButtonPushed event or ButtonPushedFcn)
4040
AddSource (1,1) wt.enum.ListAddSource = wt.enum.ListAddSource.Items
4141

42+
% Width of the buttons
43+
ButtonWidth = 25
44+
45+
% Height of the buttons
46+
ButtonHeight = 25
47+
4248
end %properties
4349

4450
methods
@@ -94,14 +100,6 @@
94100
end %properties
95101

96102

97-
properties (AbortSet, Dependent, UsedInUpdate = false)
98-
99-
% Width of the buttons
100-
ButtonWidth
101-
102-
end %properties
103-
104-
105103
methods
106104

107105
function value = get.ValueIndex(obj)
@@ -166,15 +164,6 @@
166164
end
167165
end
168166

169-
170-
function value = get.ButtonWidth(obj)
171-
value = obj.Grid.ColumnWidth{2};
172-
end
173-
174-
function set.ButtonWidth(obj,value)
175-
obj.Grid.ColumnWidth{2} = value;
176-
end
177-
178167
end %methods
179168

180169

@@ -257,8 +246,8 @@ function setup(obj)
257246

258247
% Configure grid
259248
obj.Grid.Padding = 3;
260-
obj.Grid.ColumnWidth = {'1x',25};
261-
obj.Grid.RowHeight = {106,'1x'};
249+
obj.Grid.ColumnWidth = {'1x','fit'};
250+
obj.Grid.RowHeight = {'fit','1x'};
262251

263252
% Create the list buttons
264253
obj.ListButtons = wt.ButtonGrid(obj.Grid);
@@ -306,6 +295,12 @@ function update(obj)
306295
obj.ListBox.Items = obj.Items(selIdx);
307296
obj.ListBox.ItemsData = selIdx;
308297

298+
% Button width and height
299+
obj.UserButtons.ButtonWidth = obj.ButtonWidth;
300+
obj.ListButtons.ButtonWidth = obj.ButtonWidth;
301+
obj.UserButtons.ButtonHeight = obj.ButtonHeight;
302+
obj.ListButtons.ButtonHeight = obj.ButtonHeight;
303+
309304
% Update button enable states
310305
obj.updateEnables();
311306

widgets/+wt/ListSelectorTwoPane.m

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@
3535
% Indicates whether to allow sort controls
3636
Sortable (1,1) matlab.lang.OnOffSwitchState = true
3737

38+
% Width of the buttons
39+
ButtonWidth = 25
40+
41+
% Height of the buttons
42+
ButtonHeight = 25
43+
3844
end %properties
3945

4046

@@ -66,14 +72,6 @@
6672
end %properties
6773

6874

69-
properties (AbortSet, Dependent, UsedInUpdate = false)
70-
71-
% Width of the buttons
72-
ButtonWidth
73-
74-
end %properties
75-
76-
7775

7876
%% Read-Only properties
7977
properties (SetAccess = private)
@@ -117,14 +115,14 @@ function setup(obj)
117115

118116
% Configure grid
119117
obj.Grid.Padding = 3;
120-
obj.Grid.ColumnWidth = {'1x',28,'1x'};
121-
obj.Grid.RowHeight = {'fit','1x'};
118+
obj.Grid.ColumnWidth = {'1x','fit','1x'};
119+
obj.Grid.RowHeight = {'fit','fit','1x'};
122120

123121
% Create the left Listbox
124122
obj.LeftList = uilistbox(obj.Grid);
125123
obj.LeftList.Multiselect = true;
126124
obj.LeftList.Layout.Column = 1;
127-
obj.LeftList.Layout.Row = [1 2];
125+
obj.LeftList.Layout.Row = [1 3];
128126
obj.LeftList.ValueChangedFcn = @(h,e)obj.onLeftSelectionChanged(e);
129127

130128
% Create the list buttons
@@ -143,7 +141,7 @@ function setup(obj)
143141
obj.RightList = uilistbox(obj.Grid);
144142
obj.RightList.Multiselect = true;
145143
obj.RightList.Layout.Column = 3;
146-
obj.RightList.Layout.Row = [1 2];
144+
obj.RightList.Layout.Row = [1 3];
147145
obj.RightList.ValueChangedFcn = @(h,e)obj.onRightSelectionChanged(e);
148146

149147
% Update listeners
@@ -187,13 +185,17 @@ function update(obj)
187185
if obj.Sortable
188186
obj.ListButtons.Icon = ["right_24.png", "left_24.png", "up_24.png", "down_24.png"];
189187
obj.ListButtons.ButtonTag = ["Add", "Remove", "Up", "Down"];
190-
obj.ListButtons.ButtonHeight = {28 28 28 28};
191188
else
192189
obj.ListButtons.Icon = ["right_24.png", "left_24.png"];
193190
obj.ListButtons.ButtonTag = ["Add", "Remove"];
194-
obj.ListButtons.ButtonHeight = {28 28};
195191
end
196192

193+
% Button width and height
194+
obj.UserButtons.ButtonWidth = obj.ButtonWidth;
195+
obj.ListButtons.ButtonWidth = obj.ButtonWidth;
196+
obj.UserButtons.ButtonHeight = obj.ButtonHeight;
197+
obj.ListButtons.ButtonHeight = obj.ButtonHeight;
198+
197199
% Update button enable states
198200
obj.updateEnables();
199201

@@ -594,13 +596,6 @@ function shiftListBoxIndex(obj, shift)
594596
end
595597
end
596598

597-
function value = get.ButtonWidth(obj)
598-
value = obj.Grid.ColumnWidth{2};
599-
end
600-
function set.ButtonWidth(obj,value)
601-
obj.Grid.ColumnWidth{2} = value;
602-
end
603-
604599
end %methods
605600

606601
end % classdef

0 commit comments

Comments
 (0)