function uimenuCrossF(source, evnt, handles)
% uimenuCrossF

%   Project: IMPACT
%   Title of Code: uimenuCrossF
%   Relevant additional documentation:
%   Developer: Carlos Gonzalez
%   External Dependencies: NA
%
%   Disclaimer
%   CAUTION: It is strongly recommended that changes to this code
%   should be avoided without first consulting with authors.

str = get(source, 'Label');
hFig = findobj('type', 'figure', 'tag', 'mlsDesignView');
handlesFig = guidata(hFig);
if strcmpi(str, 'freeze')
    % freeze
    set(handles.CrossF.freeze, 'Checked', 'On');
    set(handles.CrossF.move, 'Checked', 'Off');

    % window
    uiColor = get(0,'defaultUicontrolBackgroundColor');

    h=figureMLS('Visible','off','Position',[100 450 300 150],'Resize','off',...
        'MenuBar','none','Name','Freeze gain crossover frequency', 'NumberTitle', 'off',...
        'color', uiColor, 'WindowStyle', 'modal'); % open a new figure
    
    uicontrol('Style','text',...
        'Position',[10,120,160,12],'String','Crossover frequency',...
        'HorizontalAlignment','left');
    hEdit = uicontrol('Style','edit', 'tag', 'edit_crossF',...
        'Position',[10,90,40,17],'String', num2str(handlesFig.Data.crossF),...
        'HorizontalAlignment','left', 'backGroundColor', 'white');
    uicontrol('Style','text',...
        'Position',[60,90,160,12],'String','[rad/s]',...
        'HorizontalAlignment','left');
    uicontrol('Style','pushbutton',...
        'Position',[180,30,40,20],'String', 'OK',...
        'HorizontalAlignment','left',...
        'Callback',{@pushbutton_okay_Callback, hEdit, hFig, handlesFig});
    set(h, 'CloseRequestFcn', {@pushbutton_okay_Callback, hEdit hFig, handlesFig})
    movegui(gcf, 'center');
    set(h,'Visible','on');
else
    set(handles.CrossF.freeze, 'Checked', 'Off');
    set(handles.CrossF.move, 'Checked', 'On');
end


function pushbutton_okay_Callback(source, evnt, hEdit, hFig, handles)

str = get(hEdit, 'String');
val = str2double(str);
if ~isFiniteNum(val, [0, inf; 0, 0])
    errordlgMLS('Crossover frequency must be a value between 0 and infinity.');
    return;
end
delete(gcf);
handles.Data.crossF = val;
guidata(hFig, handles);

% update crossover frequency
updatePlot(handles);
