classdef AppExampleTrackSlider < matlab.apps.AppBase

    % Properties that correspond to app components
    properties (Access = public)
        TrackSliderUIFigure  matlab.ui.Figure
        Gauge                matlab.ui.control.SemicircularGauge
        Slider               matlab.ui.control.Slider
    end

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

        % Value changing function: Slider
        function SliderValueChanging(app, event)
            % Get latest slider value
            changingValue = event.Value; 
            
            % Set gauge needle to latest slider value
            app.Gauge.Value = changingValue; 
        end
    end

    % Component initialization
    methods (Access = private)

        % Create UIFigure and components
        function createComponents(app)

            % Create TrackSliderUIFigure and hide until all components are created
            app.TrackSliderUIFigure = uifigure('Visible', 'off');
            app.TrackSliderUIFigure.Position = [100 100 388 280];
            app.TrackSliderUIFigure.Name = 'Track Slider';

            % Create Gauge
            app.Gauge = uigauge(app.TrackSliderUIFigure, 'semicircular');
            app.Gauge.Position = [100 121 190 103];

            % Create Slider
            app.Slider = uislider(app.TrackSliderUIFigure);
            app.Slider.ValueChangingFcn = createCallbackFcn(app, @SliderValueChanging, true);
            app.Slider.Position = [120 82 150 3];

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

    % App creation and deletion
    methods (Access = public)

        % Construct app
        function app = AppExampleTrackSlider

            % Create UIFigure and components
            createComponents(app)

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

            if nargout == 0
                clear app
            end
        end

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

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