Fix thinkos in cubasish theme
[ardour.git] / gtk2_ardour / utils.h
1 /*
2  * Copyright (C) 2005-2006 Taybin Rutkin <taybin@taybin.com>
3  * Copyright (C) 2005-2009 Nick Mainsbridge <mainsbridge@gmail.com>
4  * Copyright (C) 2005-2016 Paul Davis <paul@linuxaudiosystems.com>
5  * Copyright (C) 2005 Karsten Wiese <fzuuzf@googlemail.com>
6  * Copyright (C) 2006 Doug McLain <doug@nostar.net>
7  * Copyright (C) 2009-2012 Carl Hetherington <carl@carlh.net>
8  * Copyright (C) 2009 David Robillard <d@drobilla.net>
9  * Copyright (C) 2009 Sampo Savolainen <v2@iki.fi>
10  * Copyright (C) 2013-2019 Robin Gareus <robin@gareus.org>
11  * Copyright (C) 2015 AndrĂ© Nusser <andre.nusser@googlemail.com>
12  * Copyright (C) 2015 Tim Mayberry <mojofunk@gmail.com>
13  *
14  * This program is free software; you can redistribute it and/or modify
15  * it under the terms of the GNU General Public License as published by
16  * the Free Software Foundation; either version 2 of the License, or
17  * (at your option) any later version.
18  *
19  * This program is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22  * GNU General Public License for more details.
23  *
24  * You should have received a copy of the GNU General Public License along
25  * with this program; if not, write to the Free Software Foundation, Inc.,
26  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27  */
28
29 #ifndef __ardour_gtk_utils_h__
30 #define __ardour_gtk_utils_h__
31
32 #include <string>
33 #include <cmath>
34 #include <vector>
35 #include <map>
36
37 #include "ardour/types.h"
38
39 #include <gdkmm/types.h>
40 #include <gtkmm/menushell.h>
41
42 #include "canvas/types.h"
43
44 namespace PBD {
45         class Controllable;
46         class ScopedConnectionList;
47 }
48
49 namespace Gtk {
50         class Window;
51         class ComboBoxText;
52         class Adjustment;
53 }
54
55 namespace ArdourCanvas {
56         class Item;
57 }
58
59 namespace ARDOUR_UI_UTILS {
60
61 gint   just_hide_it (GdkEventAny*, Gtk::Window*);
62 void add_item_with_sensitivity (Gtk::Menu_Helpers::MenuList &, Gtk::Menu_Helpers::MenuElem, bool);
63
64 bool engine_is_running ();
65
66 unsigned char* xpm2rgb  (const char** xpm, uint32_t& w, uint32_t& h);
67 unsigned char* xpm2rgba (const char** xpm, uint32_t& w, uint32_t& h);
68
69 ArdourCanvas::Points* get_canvas_points (std::string who, uint32_t npoints);
70
71 Pango::FontDescription sanitized_font (std::string const&);
72 Pango::FontDescription get_font_for_style (std::string widgetname);
73
74 void decorate (Gtk::Window& w, Gdk::WMDecoration d);
75
76 Gdk::Color gdk_color_from_rgb (uint32_t);
77 Gdk::Color gdk_color_from_rgba (uint32_t);
78 uint32_t gdk_color_to_rgba (Gdk::Color const&);
79
80 void set_color_from_rgb (Gdk::Color&, uint32_t);
81 void set_color_from_rgba (Gdk::Color&, uint32_t);
82
83 bool relay_key_press (GdkEventKey* ev, Gtk::Window* win);
84 bool key_press_focus_accelerator_handler (Gtk::Window& window, GdkEventKey* ev);
85 bool emulate_key_event (unsigned int);
86
87 Glib::RefPtr<Gdk::Pixbuf> get_xpm (std::string);
88 std::vector<std::string> get_icon_sets ();
89 void get_color_themes (std::map<std::string,std::string>&);
90 std::string get_icon_path (const char*, std::string icon_set = std::string(), bool is_image = true);
91 Glib::RefPtr<Gdk::Pixbuf> get_icon (const char*, std::string icon_set = std::string());
92 static std::map<std::string, Glib::RefPtr<Gdk::Pixbuf> > xpm_map;
93 const char* const *get_xpm_data (std::string path);
94 std::string longest (std::vector<std::string>&);
95 bool key_is_legal_for_numeric_entry (guint keyval);
96
97 void resize_window_to_proportion_of_monitor (Gtk::Window*, int, int);
98
99 std::string escape_underscores (std::string const &);
100
101 Gdk::Color unique_random_color (std::list<Gdk::Color> &);
102
103 std::string rate_as_string (float r);
104 std::string samples_as_time_string (ARDOUR::samplecnt_t s, float r, bool show_samples = false);
105
106 bool windows_overlap (Gtk::Window *a, Gtk::Window *b);
107
108 bool overwrite_file_dialog (Gtk::Window& parent, std::string title, std::string text);
109 bool running_from_source_tree ();
110
111 void inhibit_screensaver (bool);
112
113 } // namespace
114 #endif /* __ardour_gtk_utils_h__ */