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>
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.
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.
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.
29 #ifndef __ardour_gtk_utils_h__
30 #define __ardour_gtk_utils_h__
37 #include "ardour/types.h"
39 #include <gdkmm/types.h>
40 #include <gtkmm/menushell.h>
42 #include "canvas/types.h"
46 class ScopedConnectionList;
55 namespace ArdourCanvas {
59 namespace ARDOUR_UI_UTILS {
61 gint just_hide_it (GdkEventAny*, Gtk::Window*);
62 void add_item_with_sensitivity (Gtk::Menu_Helpers::MenuList &, Gtk::Menu_Helpers::MenuElem, bool);
64 bool engine_is_running ();
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);
69 ArdourCanvas::Points* get_canvas_points (std::string who, uint32_t npoints);
71 Pango::FontDescription sanitized_font (std::string const&);
72 Pango::FontDescription get_font_for_style (std::string widgetname);
74 void decorate (Gtk::Window& w, Gdk::WMDecoration d);
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&);
80 void set_color_from_rgb (Gdk::Color&, uint32_t);
81 void set_color_from_rgba (Gdk::Color&, uint32_t);
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);
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);
97 void resize_window_to_proportion_of_monitor (Gtk::Window*, int, int);
99 std::string escape_underscores (std::string const &);
101 Gdk::Color unique_random_color (std::list<Gdk::Color> &);
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);
106 bool windows_overlap (Gtk::Window *a, Gtk::Window *b);
108 bool overwrite_file_dialog (Gtk::Window& parent, std::string title, std::string text);
109 bool running_from_source_tree ();
111 void inhibit_screensaver (bool);
114 #endif /* __ardour_gtk_utils_h__ */