|
102 | 102 | else |
103 | 103 | BpodSystem.GUIData.ParameterGUI.LastParamValues{ParamNum} = ThisParam; |
104 | 104 | end |
| 105 | + ThisParamStyle = 'edit'; % Just initial assumption |
| 106 | + ThisParamCB = ''; |
105 | 107 | if isfield(Meta, ThisParamName) |
106 | 108 | if isstruct(Meta.(ThisParamName)) |
| 109 | + ValidField = false; |
107 | 110 | if isfield(Meta.(ThisParamName), 'Style') |
108 | 111 | ThisParamStyle = Meta.(ThisParamName).Style; |
109 | 112 | if isfield(Meta.(ThisParamName), 'String') |
110 | 113 | ThisParamString = Meta.(ThisParamName).String; |
111 | 114 | else |
112 | 115 | ThisParamString = ''; |
113 | 116 | end |
114 | | - else |
115 | | - error(['Style not specified for parameter ' ThisParamName '.']) |
| 117 | + ValidField = true; |
| 118 | + end |
| 119 | + if isfield(Meta.(ThisParamName), 'Callback') |
| 120 | + ThisParamCB = Meta.(ThisParamName).Callback; |
| 121 | + ValidField = true; |
| 122 | + end |
| 123 | + if ~ValidField |
| 124 | + error(['Style or Callback not specified for parameter ' ThisParamName '.']) |
116 | 125 | end |
117 | 126 | else |
118 | 127 | error(['GUIMeta entry for ' ThisParamName ' must be a struct.']) |
119 | 128 | end |
120 | | - else |
121 | | - ThisParamStyle = 'edit'; |
122 | | - ThisParamValue = NaN; |
123 | 129 | end |
124 | 130 | BpodSystem.GUIHandles.ParameterGUI.Labels(ParamNum) = uicontrol(htab,'Style', 'text', 'String', ThisParamName, 'Position', [HPos+5 VPos+InPanelPos 200 25], 'FontWeight', 'normal', 'FontSize', 12, 'BackgroundColor','white', 'FontName', 'Arial','HorizontalAlignment','Center'); |
125 | 131 | switch lower(ThisParamStyle) |
126 | 132 | case 'edit' |
127 | 133 | BpodSystem.GUIData.ParameterGUI.Styles(ParamNum) = 1; |
128 | | - BpodSystem.GUIHandles.ParameterGUI.Params{ParamNum} = uicontrol(htab,'Style', 'edit', 'String', num2str(ThisParam), 'Position', [HPos+220 VPos+InPanelPos+2 200 25], 'FontWeight', 'normal', 'FontSize', 12, 'BackgroundColor','white', 'FontName', 'Arial','HorizontalAlignment','Center'); |
| 134 | + BpodSystem.GUIHandles.ParameterGUI.Params{ParamNum} = uicontrol(htab,'Style', 'edit', 'String', num2str(ThisParam), 'Position', [HPos+220 VPos+InPanelPos+2 200 25], 'FontWeight', 'normal', 'FontSize', 12, 'BackgroundColor','white', 'FontName', 'Arial','HorizontalAlignment','Center','Callback',ThisParamCB); |
129 | 135 | case 'text' |
130 | 136 | BpodSystem.GUIData.ParameterGUI.Styles(ParamNum) = 2; |
131 | | - BpodSystem.GUIHandles.ParameterGUI.Params{ParamNum} = uicontrol(htab,'Style', 'text', 'String', num2str(ThisParam), 'Position', [HPos+220 VPos+InPanelPos+2 200 25], 'FontWeight', 'normal', 'FontSize', 12, 'BackgroundColor','white', 'FontName', 'Arial','HorizontalAlignment','Center'); |
| 137 | + BpodSystem.GUIHandles.ParameterGUI.Params{ParamNum} = uicontrol(htab,'Style', 'text', 'String', num2str(ThisParam), 'Position', [HPos+220 VPos+InPanelPos+2 200 25], 'FontWeight', 'normal', 'FontSize', 12, 'BackgroundColor','white', 'FontName', 'Arial','HorizontalAlignment','Center','Callback',ThisParamCB); |
132 | 138 | case 'checkbox' |
133 | 139 | BpodSystem.GUIData.ParameterGUI.Styles(ParamNum) = 3; |
134 | | - BpodSystem.GUIHandles.ParameterGUI.Params{ParamNum} = uicontrol(htab,'Style', 'checkbox', 'Value', ThisParam, 'String', ' (check to activate)', 'Position', [HPos+220 VPos+InPanelPos+4 200 25], 'FontWeight', 'normal', 'FontSize', 12, 'BackgroundColor','white', 'FontName', 'Arial','HorizontalAlignment','Center'); |
| 140 | + BpodSystem.GUIHandles.ParameterGUI.Params{ParamNum} = uicontrol(htab,'Style', 'checkbox', 'Value', ThisParam, 'String', ' (check to activate)', 'Position', [HPos+220 VPos+InPanelPos+4 200 25], 'FontWeight', 'normal', 'FontSize', 12, 'BackgroundColor','white', 'FontName', 'Arial','HorizontalAlignment','Center','Callback',ThisParamCB); |
135 | 141 | case 'popupmenu' |
136 | 142 | BpodSystem.GUIData.ParameterGUI.Styles(ParamNum) = 4; |
137 | | - BpodSystem.GUIHandles.ParameterGUI.Params{ParamNum} = uicontrol(htab,'Style', 'popupmenu', 'String', ThisParamString, 'Value', ThisParam, 'Position', [HPos+220 VPos+InPanelPos+2 200 25], 'FontWeight', 'normal', 'FontSize', 12, 'BackgroundColor','white', 'FontName', 'Arial','HorizontalAlignment','Center'); |
| 143 | + BpodSystem.GUIHandles.ParameterGUI.Params{ParamNum} = uicontrol(htab,'Style', 'popupmenu', 'String', ThisParamString, 'Value', ThisParam, 'Position', [HPos+220 VPos+InPanelPos+2 200 25], 'FontWeight', 'normal', 'FontSize', 12, 'BackgroundColor','white', 'FontName', 'Arial','HorizontalAlignment','Center','Callback',ThisParamCB); |
138 | 144 | case 'togglebutton' % INCOMPLETE |
139 | 145 | BpodSystem.GUIData.ParameterGUI.Styles(ParamNum) = 5; |
140 | | - BpodSystem.GUIHandles.ParameterGUI.Params{ParamNum} = uicontrol(htab,'Style', 'togglebutton', 'String', ThisParamString, 'Value', ThisParam, 'Position', [HPos+220 VPos+InPanelPos+2 200 25], 'FontWeight', 'normal', 'FontSize', 12, 'BackgroundColor','white', 'FontName', 'Arial','HorizontalAlignment','Center'); |
| 146 | + BpodSystem.GUIHandles.ParameterGUI.Params{ParamNum} = uicontrol(htab,'Style', 'togglebutton', 'String', ThisParamString, 'Value', ThisParam, 'Position', [HPos+220 VPos+InPanelPos+2 200 25], 'FontWeight', 'normal', 'FontSize', 12, 'BackgroundColor','white', 'FontName', 'Arial','HorizontalAlignment','Center','Callback',ThisParamCB); |
141 | 147 | case 'pushbutton' |
142 | 148 | BpodSystem.GUIData.ParameterGUI.Styles(ParamNum) = 6; |
143 | 149 | BpodSystem.GUIHandles.ParameterGUI.Params{ParamNum} = uicontrol(htab,'Style', 'pushbutton', 'String', ThisParamString,... |
144 | 150 | 'Value', ThisParam, 'Position', [HPos+220 VPos+InPanelPos+2 200 25], 'FontWeight', 'normal', 'FontSize', 12,... |
145 | | - 'BackgroundColor','white', 'FontName', 'Arial','HorizontalAlignment','Center','Callback',Meta.OdorSettings.Callback); |
| 151 | + 'BackgroundColor','white', 'FontName', 'Arial','HorizontalAlignment','Center','Callback',ThisParamCB); |
146 | 152 | case 'table' |
147 | 153 | BpodSystem.GUIData.ParameterGUI.Styles(ParamNum) = 7; |
148 | 154 | columnNames = fieldnames(Params.(ThisParamName)); |
|
166 | 172 | BpodSystem.GUIData.ParameterGUI.LastParamValues{ParamNum} = htable.Data; |
167 | 173 | case 'edittext' |
168 | 174 | BpodSystem.GUIData.ParameterGUI.Styles(ParamNum) = 8; |
169 | | - BpodSystem.GUIHandles.ParameterGUI.Params{ParamNum} = uicontrol(htab,'Style', 'edit', 'String', ThisParam, 'Position', [HPos+220 VPos+InPanelPos+2 200 25], 'FontWeight', 'normal', 'FontSize', 12, 'BackgroundColor','white', 'FontName', 'Arial','HorizontalAlignment','Center'); |
| 175 | + BpodSystem.GUIHandles.ParameterGUI.Params{ParamNum} = uicontrol(htab,'Style', 'edit', 'String', ThisParam, 'Position', [HPos+220 VPos+InPanelPos+2 200 25], 'FontWeight', 'normal', 'FontSize', 12, 'BackgroundColor','white', 'FontName', 'Arial','HorizontalAlignment','Center','Callback',ThisParamCB); |
170 | 176 | case 'slider' |
171 | 177 | BpodSystem.GUIData.ParameterGUI.Styles(ParamNum) = 9; |
172 | | - BpodSystem.GUIHandles.ParameterGUI.Params{ParamNum} = uicontrol(htab,'Style', 'slider', 'String', ThisParamString,... |
| 178 | + BpodSystem.GUIHandles.ParameterGUI.Params{ParamNum} = uicontrol(htab,'Style', 'slider', 'String', ThisParam,... |
173 | 179 | 'Value', ThisParam, 'Position', [HPos+220 VPos+InPanelPos+2 200 25], 'FontWeight', 'normal', 'FontSize', 12,... |
174 | | - 'BackgroundColor','white', 'FontName', 'Arial','HorizontalAlignment','Center', 'min', 0, 'max', 1); |
| 180 | + 'BackgroundColor','white', 'FontName', 'Arial','HorizontalAlignment','Center', 'min', 0, 'max', 1,... |
| 181 | + 'Callback',ThisParamCB); |
| 182 | + |
175 | 183 | otherwise |
176 | 184 | error('Invalid parameter style specified. Valid parameters are: ''edit'', ''text'', ''checkbox'', ''popupmenu'', ''togglebutton'', ''pushbutton'', ''slider'''); |
177 | 185 | end |
|
0 commit comments