rename ArdourMenu to ArdourDropdown
[ardour.git] / gtk2_ardour / ardour_dropdown.cc
1 /*
2     Copyright (C) 2014 Paul Davis
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
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #include <iostream>
21 #include <cmath>
22 #include <algorithm>
23
24 #include <pangomm/layout.h>
25
26 #include "pbd/compose.h"
27 #include "pbd/error.h"
28 #include "pbd/stacktrace.h"
29
30 #include "gtkmm2ext/utils.h"
31 #include "gtkmm2ext/rgb_macros.h"
32 #include "gtkmm2ext/gui_thread.h"
33
34 #include "ardour/rc_configuration.h" // for widget prelight preference
35
36 #include "ardour_dropdown.h"
37 #include "ardour_ui.h"
38 #include "global_signals.h"
39
40 #include "i18n.h"
41
42 #define REFLECTION_HEIGHT 2
43
44 using namespace Gdk;
45 using namespace Gtk;
46 using namespace Glib;
47 using namespace PBD;
48 using std::max;
49 using std::min;
50 using namespace std;
51
52
53 ArdourDropdown::ArdourDropdown (Element e)
54 {
55         signal_button_press_event().connect (sigc::mem_fun(*this, &ArdourDropdown::on_mouse_pressed));
56
57         add_elements(e);
58         add_elements(ArdourButton::Menu);
59 }
60
61 ArdourDropdown::~ArdourDropdown ()
62 {
63 }
64
65 bool
66 ArdourDropdown::on_mouse_pressed (GdkEventButton*)
67 {
68         _menu.popup (1, gtk_get_current_event_time());  
69         return true;
70 }
71
72
73 void
74 ArdourDropdown::AddMenuElem (Menu_Helpers::MenuElem e)
75 {
76         using namespace Menu_Helpers;
77
78         MenuList& items = _menu.items ();
79         
80         items.push_back (e);
81 }
82
83