Bodge around visual glitch where the ranges & markers list would overlap the editor...
[ardour.git] / gtk2_ardour / utils.cc
index 72b128c02fa44cebc5b0f4e49d525a3d2c86f69b..e50a39b397d193135fc5ffbb0bd3d301c882288d 100644 (file)
@@ -36,7 +36,7 @@
 
 #include <gtkmm2ext/utils.h>
 #include "ardour/configuration.h"
-#include "ardour/configuration.h"
+#include "ardour/rc_configuration.h"
 
 #include "ardour/filesystem_paths.h"
 
@@ -879,6 +879,14 @@ possibly_translate_keyval_to_make_legal_accelerator (uint32_t& keyval)
                fakekey = GDK_leftarrow;
                break;
 
+       case GDK_Return:
+               fakekey = GDK_3270_Enter;
+               break;
+
+       case GDK_KP_Enter:
+               fakekey = GDK_F35;
+               break;
+
        default:
                break;
        }
@@ -891,6 +899,42 @@ possibly_translate_keyval_to_make_legal_accelerator (uint32_t& keyval)
        return false;
 }
 
+uint32_t
+possibly_translate_legal_accelerator_to_real_key (uint32_t keyval)
+{
+       switch (keyval) {
+       case GDK_nabla:
+               return GDK_Tab;
+               break;
+
+       case GDK_uparrow:
+               return GDK_Up;
+               break;
+
+       case GDK_downarrow:
+               return GDK_Down;
+               break;
+
+       case GDK_rightarrow:
+               return GDK_Right;
+               break;
+
+       case GDK_leftarrow:
+               return GDK_Left;
+               break;
+
+       case GDK_3270_Enter:
+               return GDK_Return;
+
+       case GDK_F35:
+               return GDK_KP_Enter;
+               break;
+       }
+
+       return keyval;
+}
+
+
 
 inline guint8
 convert_color_channel (guint8 src,
@@ -936,3 +980,40 @@ resize_window_to_proportion_of_monitor (Gtk::Window* window, int max_width, int
 
        window->resize (w, h);
 }
+
+Glib::RefPtr<Gdk::Pixbuf>
+pixbuf_from_ustring(const ustring& name, Pango::FontDescription* font, int clip_width, int clip_height)
+{
+       static Glib::RefPtr<Gdk::Pixbuf>* empty_pixbuf = 0;
+
+       if (name.empty()) {
+               if (empty_pixbuf == 0) {
+                       empty_pixbuf = new Glib::RefPtr<Gdk::Pixbuf>;
+                       *empty_pixbuf = Gdk::Pixbuf::create(Gdk::COLORSPACE_RGB, true, 8, clip_width, clip_height);
+               }
+               cerr << "\n\nUSE EMPTY PIXBUF\n";
+               return *empty_pixbuf;
+       }
+
+       Glib::RefPtr<Gdk::Pixbuf> buf = Gdk::Pixbuf::create(Gdk::COLORSPACE_RGB, true, 8, clip_width, clip_height);
+
+       cairo_surface_t* surface = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, clip_width, clip_height);
+       cairo_t* cr = cairo_create (surface);
+       cairo_text_extents_t te;
+       
+       cairo_set_source_rgba (cr, 0.0, 0.0, 0.0, 1.0);
+       cairo_select_font_face (cr, font->get_family().c_str(),
+                               CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);
+       cairo_set_font_size (cr,  font->get_size() / Pango::SCALE);
+       cairo_text_extents (cr, name.c_str(), &te);
+       
+       cairo_move_to (cr, 0.5, 0.5 - te.height / 2 - te.y_bearing + clip_height / 2);
+       cairo_show_text (cr, name.c_str());
+       
+       convert_bgra_to_rgba(cairo_image_surface_get_data (surface), buf->get_pixels(), clip_width, clip_height);
+
+       cairo_destroy(cr);
+       cairo_surface_destroy(surface);
+
+       return buf;
+}