Vkeybd: add a mod-wheel
[ardour.git] / gtk2_ardour / ardour_message.cc
1 /*
2  * Copyright (C) 2019 Robin Gareus <robin@gareus.org>
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 #include "ardour_message.h"
20 #include "splash.h"
21
22 using namespace Gtk;
23
24 ArdourMessageDialog::ArdourMessageDialog (const Glib::ustring& message,
25                                                 bool use_markup,
26                                                 Gtk::MessageType type,
27                                                 Gtk::ButtonsType buttons,
28                                                 bool modal)
29         : Gtk::MessageDialog (message, use_markup, type, buttons, modal)
30         , _splash_pushed (false)
31 {
32         set_position (WIN_POS_MOUSE);
33 }
34
35 ArdourMessageDialog::ArdourMessageDialog (Gtk::Window& parent,
36                                                 const Glib::ustring& message,
37                                                 bool use_markup,
38                                                 Gtk::MessageType type,
39                                                 Gtk::ButtonsType buttons,
40                                                 bool modal)
41         : Gtk::MessageDialog (parent, message, use_markup, type, buttons, modal)
42         , _splash_pushed (false)
43 {
44         set_transient_for (parent);
45         set_position (WIN_POS_MOUSE);
46 }
47
48 ArdourMessageDialog::~ArdourMessageDialog ()
49 {
50         pop_splash ();
51 }
52
53 int
54 ArdourMessageDialog::run ()
55 {
56         push_splash ();
57         int rv = Gtk::MessageDialog::run ();
58         pop_splash ();
59         return rv;
60 }
61
62 void
63 ArdourMessageDialog::show ()
64 {
65         push_splash ();
66         Gtk::MessageDialog::show ();
67 }
68
69 void
70 ArdourMessageDialog::hide ()
71 {
72         Gtk::MessageDialog::hide ();
73         pop_splash ();
74 }
75
76 void
77 ArdourMessageDialog::pop_splash ()
78 {
79         if (_splash_pushed) {
80                 Splash* spl = Splash::instance();
81                 if (spl) {
82                         spl->pop_front();
83                 }
84                 _splash_pushed = false;
85         }
86 }
87
88 void
89 ArdourMessageDialog::push_splash ()
90 {
91         if (Splash::exists()) {
92                 Splash* spl = Splash::instance();
93                 if (spl->is_visible()) {
94                         spl->pop_back_for (*this);
95                         _splash_pushed = true;
96                 }
97         }
98 }