Unconditionally save instant.xml on session-close
[ardour.git] / gtk2_ardour / sys_ex.cc
1 /*
2  * Copyright (C) 2013-2017 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 #include <iostream>
20 #include "canvas/flag.h"
21 #include "sys_ex.h"
22 #include "ui_config.h"
23
24 using namespace std;
25
26 SysEx::SysEx (
27         MidiRegionView&             region,
28         ArdourCanvas::Container*    parent,
29         string&                     text,
30         double                      height,
31         double                      x,
32         double                      y,
33         ARDOUR::MidiModel::SysExPtr sysex)
34         : _sysex (sysex)
35 {
36         _flag = new ArdourCanvas::Flag (
37                 parent,
38                 height,
39                 UIConfiguration::instance().color ("midi sysex outline"),
40                 UIConfiguration::instance().color_mod ("midi sysex fill", "midi sysex fill"),
41                 ArdourCanvas::Duple (x, y)
42                 );
43
44         _flag->set_text (text);
45 }
46
47 SysEx::~SysEx()
48 {
49         /* do not delete flag because it was added to a parent/container which
50            will delete it.
51         */
52         _flag = 0;
53 }
54
55 bool
56 SysEx::event_handler (GdkEvent* ev)
57 {
58         switch (ev->type) {
59         case GDK_BUTTON_PRESS:
60                 if (ev->button.button == 3) {
61                         return true;
62                 }
63                 break;
64
65         case GDK_SCROLL:
66                 if (ev->scroll.direction == GDK_SCROLL_UP) {
67                         return true;
68                 } else if (ev->scroll.direction == GDK_SCROLL_DOWN) {
69                         return true;
70                 }
71                 break;
72
73         default:
74                 break;
75         }
76
77         return false;
78 }
79
80 void
81 SysEx::hide ()
82 {
83         _flag->hide ();
84 }
85
86 void
87 SysEx::show ()
88 {
89         _flag->show ();
90 }