classdef AutoResizeChildrenNoPanelAppExample < matlab.apps.AppBase

    % Properties that correspond to app components
    properties (Access = public)
        WithoutPanelUIFigure     matlab.ui.Figure
        UIAxes                   matlab.ui.control.UIAxes
        SurfButton               matlab.ui.control.Button
        MeshButton               matlab.ui.control.Button
        ContourButton            matlab.ui.control.Button
        SelectgridDropDownLabel  matlab.ui.control.Label
        SelectgridDropDown       matlab.ui.control.DropDown
    end


    

    % Callbacks that handle component events
    methods (Access = private)

        % Code that executes after component creation
        function startupFcn(app)
            mesh(app.UIAxes,membrane);
            grid(app.UIAxes, 'on')
        end

        % Button pushed function: SurfButton
        function SurfButtonPushed(app, event)
        surf(app.UIAxes,membrane);    
        end

        % Value changed function: SelectgridDropDown
        function SelectgridDropDownValueChanged(app, event)
            switch app.SelectgridDropDown.Value
                case 'on'
                    grid(app.UIAxes, 'on')
                    
                case 'off'
                    grid(app.UIAxes, 'off')
            end
        end

        % Button pushed function: MeshButton
        function MeshButtonPushed(app, event)
            mesh(app.UIAxes,membrane);    
        end

        % Button pushed function: ContourButton
        function ContourButtonPushed(app, event)
            contour(app.UIAxes,membrane);    
        end
    end

    % Component initialization
    methods (Access = private)

        % Create UIFigure and components
        function createComponents(app)

            % Create WithoutPanelUIFigure and hide until all components are created
            app.WithoutPanelUIFigure = uifigure('Visible', 'off');
            app.WithoutPanelUIFigure.Position = [100 100 487 282];
            app.WithoutPanelUIFigure.Name = 'Without Panel';

            % Create UIAxes
            app.UIAxes = uiaxes(app.WithoutPanelUIFigure);
            app.UIAxes.GridAlpha = 0.15;
            app.UIAxes.MinorGridAlpha = 0.25;
            app.UIAxes.Position = [23 42 262 199];

            % Create SurfButton
            app.SurfButton = uibutton(app.WithoutPanelUIFigure, 'push');
            app.SurfButton.ButtonPushedFcn = createCallbackFcn(app, @SurfButtonPushed, true);
            app.SurfButton.Position = [350 201 84 28];
            app.SurfButton.Text = 'Surf';

            % Create MeshButton
            app.MeshButton = uibutton(app.WithoutPanelUIFigure, 'push');
            app.MeshButton.ButtonPushedFcn = createCallbackFcn(app, @MeshButtonPushed, true);
            app.MeshButton.Position = [350 158 84 28];
            app.MeshButton.Text = 'Mesh';

            % Create ContourButton
            app.ContourButton = uibutton(app.WithoutPanelUIFigure, 'push');
            app.ContourButton.ButtonPushedFcn = createCallbackFcn(app, @ContourButtonPushed, true);
            app.ContourButton.Position = [350 116 84 28];
            app.ContourButton.Text = 'Contour';

            % Create SelectgridDropDownLabel
            app.SelectgridDropDownLabel = uilabel(app.WithoutPanelUIFigure);
            app.SelectgridDropDownLabel.HorizontalAlignment = 'right';
            app.SelectgridDropDownLabel.VerticalAlignment = 'top';
            app.SelectgridDropDownLabel.Position = [360 73 61 15];
            app.SelectgridDropDownLabel.Text = 'Select grid:';

            % Create SelectgridDropDown
            app.SelectgridDropDown = uidropdown(app.WithoutPanelUIFigure);
            app.SelectgridDropDown.Items = {'off', 'on'};
            app.SelectgridDropDown.ValueChangedFcn = createCallbackFcn(app, @SelectgridDropDownValueChanged, true);
            app.SelectgridDropDown.Position = [350 42 84 22];
            app.SelectgridDropDown.Value = 'on';

            % Show the figure after all components are created
            app.WithoutPanelUIFigure.Visible = 'on';
        end
    end

    % App creation and deletion
    methods (Access = public)

        % Construct app
        function app = AutoResizeChildrenNoPanelAppExample

            % Create UIFigure and components
            createComponents(app)

            % Register the app with App Designer
            registerApp(app, app.WithoutPanelUIFigure)

            % Execute the startup function
            runStartupFcn(app, @startupFcn)

            if nargout == 0
                clear app
            end
        end

        % Code that executes before app deletion
        function delete(app)

            % Delete UIFigure when app is deleted
            delete(app.WithoutPanelUIFigure)
        end
    end
end