libAlgAudio  v1.99-440-g08538e5-dirty
The development library for AlgAudio framework.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
MainWindow.hpp
Go to the documentation of this file.
1 #ifndef MAINWINDOW_HPP
2 #define MAINWINDOW_HPP
3 /*
4 This file is part of AlgAudio.
5 
6 AlgAudio, Copyright (C) 2015 CeTA - Audiovisual Technology Center
7 
8 AlgAudio is free software: you can redistribute it and/or modify
9 it under the terms of the GNU Lesser General Public License as
10 published by the Free Software Foundation, either version 3 of the
11 License, or (at your option) any later version.
12 
13 AlgAudio is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU Lesser General Public License for more details.
17 
18 You should have received a copy of the GNU Lesser General Public License
19 along with AlgAudio. If not, see <http://www.gnu.org/licenses/>.
20 */
21 
22 #include "Window.hpp"
23 #include "ModuleSelector.hpp"
24 #include "UI/UIBox.hpp"
25 #include "UI/UIButton.hpp"
26 #include "UI/UILayered.hpp"
27 #include "UI/UILabel.hpp"
28 #include "UI/UISeparator.hpp"
29 #include "UI/UIAlert.hpp"
30 #include "UI/UISeparator.hpp"
31 #include "UI/UICentered.hpp"
32 #include "UI/UILabel.hpp"
33 #include "CanvasView.hpp"
34 #include "Alertable.hpp"
35 
36 namespace AlgAudio{
37 
38 /* MainWindow is an implementation of a Window specialised to display
39  * the main window interface, embeding, among others, a CanvasView, a
40  * ModuleSelector etc.
41  * This class implements the Alertable interface.
42  */
43 class MainWindow : public Window{
44 public:
45  static std::shared_ptr<MainWindow> Create();
46  // Returns 0 if the first button was clicked, 1, if the second.
48  std::string message,
49  std::string button1_text,
50  std::string button2_text,
52  Color button1_color = Theme::Get("bg-button-neutral"),
53  Color button2_color = Theme::Get("bg-button-neutral")
54  ) override;
55  LateReturn<> ShowErrorAlert(std::string message, std::string button_text) override;
58 
59  void ProcessCloseEvent() override;
60  void ProcessKeyboardEvent(KeyData data) override;
61 
63 
64  bool SaveAs();
65  bool Save();
66  bool Save(std::string path);
68 
71  void AskToSaveBeforeCalling(std::function<void()> f);
72 
74  void Open();
76  void New();
77 private:
78  MainWindow();
79  void init();
80 
81  void UpdatePathLabel();
82 
83 std::shared_ptr<UIVBox> mainvbox;
84  std::shared_ptr<UIHBox> toolbarbox;
85  std::shared_ptr<UIButton> addbutton;
86  std::shared_ptr<UIButton> removebutton;
87  std::shared_ptr<UISeparator> toolbar_separator1;
88  std::shared_ptr<UIButton> newbutton;
89  std::shared_ptr<UIButton> openbutton;
90  std::shared_ptr<UIButton> savebutton;
91  std::shared_ptr<UIButton> saveasbutton;
92  std::shared_ptr<UISeparator> toolbar_separator2;
93  std::shared_ptr<UIButton> allnodes;
94  std::shared_ptr<UISeparator> toolbar_separator3;
95  std::shared_ptr<UIButton> quitbutton;
96  std::shared_ptr<UILayered> layered;
97  std::shared_ptr<UIVBox> canvasbox;
98  std::shared_ptr<UIHBox> canvaspathbox;
99  std::shared_ptr<UIButton> canvaspathback;
100  std::shared_ptr<UILabel> canvaspathlabel;
101  std::shared_ptr<CanvasView> canvasview;
102  std::shared_ptr<ModuleSelector> selector;
103  std::shared_ptr<UILayered> layered_alert;
104  std::shared_ptr<UICentered> centered_alert;
105  std::shared_ptr<UIAlert> alert;
106 
107 
108  Subscription sub_alert_reply;
109 
110  // Stored for SaveAs.
111  std::string current_file_path = "";
112  std::string file_name = "Unsaved file";
113 };
114 
115 } //namespace AlgAudio
116 #endif // MAINWINDOW_HPP
SaveAlertReply
Definition: MainWindow.hpp:56
Definition: Color.hpp:28
LateReturn ShowErrorAlert(std::string message, std::string button_text) override
LateReturn< SaveAlertReply > ShowDoYouWantToSaveAlert()
Definition: MainWindow.hpp:43
LateReturn< int > ShowSimpleAlert(std::string message, std::string button1_text, std::string button2_text, AlertType type=AlertType::NONE, Color button1_color=Theme::Get("bg-button-neutral"), Color button2_color=Theme::Get("bg-button-neutral")) override
Definition: Window.hpp:37
Definition: Alertable.hpp:26
Definition: Signal.hpp:44
void ProcessCloseEvent() override
static std::shared_ptr< MainWindow > Create()
Definition: LateReturn.hpp:35
AlertType
Definition: Alertable.hpp:42
static const Color & Get(const std::string &)
void ProcessKeyboardEvent(KeyData data) override
Definition: Utilities.hpp:157
void AskToSaveBeforeCalling(std::function< void()> f)