Preferences/Config changes for image-surface settings
[ardour.git] / gtk2_ardour / startup_fsm.h
1 /*
2  * Copyright (C) 2019 Paul Davis <paul@linuxaudiosystems.com>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  */
18
19 #ifndef __gtk2_ardour_startup_fsm_h__
20 #define __gtk2_ardour_startup_fsm_h__
21
22 #include <string>
23
24 #include <sigc++/trackable.h>
25
26 #include "ardour/types.h"
27
28 class ArdourDialog;
29 class NewUserWizard;
30 class EngineControl;
31 class SessionDialog;
32 class PluginScanDialog;
33
34 class StartupFSM : public sigc::trackable
35 {
36   public:
37         enum DialogID {
38                 PreReleaseDialog,
39                 NewUserDialog,
40                 NewSessionDialog,
41                 AudioMIDISetup,
42                 PluginDialog
43         };
44
45         enum Result {
46                 LoadSession,
47                 ExitProgram,
48         };
49
50         enum MainState {
51                 WaitingForPreRelease,
52                 WaitingForNewUser,
53                 WaitingForSessionPath,
54                 WaitingForEngineParams,
55                 WaitingForPlugins
56         };
57
58         StartupFSM (EngineControl&);
59         ~StartupFSM ();
60
61         void start ();
62         void reset ();
63
64         std::string session_path;
65         std::string session_name;
66         std::string session_template;
67         int         session_existing_sample_rate;
68         bool        session_is_new;
69         ARDOUR::BusProfile bus_profile;
70
71         /* It's not a dialog but we provide this to make it behave like a (non-modal)
72          * dialog
73          */
74
75         sigc::signal1<void,Result>& signal_response() { return _signal_response; }
76
77         bool brand_new_user() const { return new_user; }
78
79   private:
80         bool new_user;
81         bool new_session_required;
82
83         MainState _state;
84
85         void set_state (MainState);
86         void dialog_response_handler (int response, DialogID);
87         template<typename T> void end_dialog (T**);
88         template<typename T> void end_dialog (T&);
89
90         void show_new_user_dialog ();
91         void show_session_dialog (bool new_session_required);
92         void show_audiomidi_dialog ();
93         void show_pre_release_dialog ();
94         void show_plugin_scan_dialog ();
95
96         void copy_demo_sessions ();
97         void load_from_application_api (std::string const &);
98         bool get_session_parameters_from_command_line (bool new_session_required);
99         bool get_session_parameters_from_path (std::string const & path, std::string const & template_name, bool new_session_required);
100         void queue_finish ();
101         bool ask_about_loading_existing_session (const std::string& session_path);
102         int  check_session_parameters (bool must_be_new);
103         void start_audio_midi_setup ();
104         void engine_running ();
105         void handle_waiting_for_session_path ();
106
107         /* the Audio/MIDI dialog needs to be persistent and is thus owned by
108          * ARDOUR_UI and we use it by reference. All other dialogs can be
109          * created and destroyed within the scope of startup.
110          */
111
112         EngineControl& audiomidi_dialog;
113         NewUserWizard* new_user_dialog;
114         SessionDialog* session_dialog;
115         ArdourDialog* pre_release_dialog;
116         PluginScanDialog* plugin_scan_dialog;
117
118         sigc::connection current_dialog_connection;
119
120         sigc::signal1<void,Result> _signal_response;
121
122         void dialog_hidden (Gtk::Window*);
123 };
124
125 #endif /* __gtk2_ardour_startup_fsm_h__ */