summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gtk2_ardour/ardour_ui_dialogs.cc6
-rw-r--r--libs/gtkmm2ext/gtkmm2ext/utils.h4
-rw-r--r--libs/gtkmm2ext/utils.cc20
3 files changed, 21 insertions, 9 deletions
diff --git a/gtk2_ardour/ardour_ui_dialogs.cc b/gtk2_ardour/ardour_ui_dialogs.cc
index 108229a16a..bb7140bf74 100644
--- a/gtk2_ardour/ardour_ui_dialogs.cc
+++ b/gtk2_ardour/ardour_ui_dialogs.cc
@@ -380,15 +380,15 @@ ARDOUR_UI::tabs_page_added (Widget*,guint)
editor_visibility_button.drag_source_set_icon (Gtkmm2ext::pixbuf_from_string (editor->name(),
Pango::FontDescription ("Sans 24"),
- 40, 20,
+ 0, 0,
Gdk::Color ("red")));
mixer_visibility_button.drag_source_set_icon (Gtkmm2ext::pixbuf_from_string (mixer->name(),
Pango::FontDescription ("Sans 24"),
- 40, 20,
+ 0, 0,
Gdk::Color ("red")));
prefs_visibility_button.drag_source_set_icon (Gtkmm2ext::pixbuf_from_string (rc_option_editor->name(),
Pango::FontDescription ("Sans 24"),
- 40, 20,
+ 0, 0,
Gdk::Color ("red")));
}
}
diff --git a/libs/gtkmm2ext/gtkmm2ext/utils.h b/libs/gtkmm2ext/gtkmm2ext/utils.h
index 5e95a52229..a57de26ae3 100644
--- a/libs/gtkmm2ext/gtkmm2ext/utils.h
+++ b/libs/gtkmm2ext/gtkmm2ext/utils.h
@@ -54,8 +54,8 @@ namespace Gtkmm2ext {
LIBGTKMM2EXT_API std::string fit_to_pixels (const std::string&, int pixel_width, Pango::FontDescription& font, int& actual_width, bool with_ellipses = false);
LIBGTKMM2EXT_API std::pair<std::string, double> fit_to_pixels (cairo_t *, std::string, double);
- LIBGTKMM2EXT_API int pixel_width (const std::string& str, Pango::FontDescription& font);
- LIBGTKMM2EXT_API void pixel_size (const std::string& str, Pango::FontDescription& font, int& width, int& height);
+ LIBGTKMM2EXT_API int pixel_width (const std::string& str, const Pango::FontDescription& font);
+ LIBGTKMM2EXT_API void pixel_size (const std::string& str, const Pango::FontDescription& font, int& width, int& height);
LIBGTKMM2EXT_API void get_ink_pixel_size (Glib::RefPtr<Pango::Layout>,
int& width, int& height);
diff --git a/libs/gtkmm2ext/utils.cc b/libs/gtkmm2ext/utils.cc
index 7fed1b8aee..2b0eb86a9c 100644
--- a/libs/gtkmm2ext/utils.cc
+++ b/libs/gtkmm2ext/utils.cc
@@ -272,6 +272,18 @@ Gtkmm2ext::pixbuf_from_string(const string& name, const Pango::FontDescription&
return *empty_pixbuf;
}
+ if (clip_width <= 0 || clip_height <= 0) {
+ /* negative values mean padding around natural size */
+ int width, height;
+ pixel_size (name, font, width, height);
+ if (clip_width <= 0) {
+ clip_width = width - clip_width;
+ }
+ if (clip_height <= 0) {
+ clip_height = height - clip_height;
+ }
+ }
+
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);
@@ -678,7 +690,7 @@ Gtkmm2ext::window_to_draw_on (Gtk::Widget& w, Gtk::Widget** parent)
}
int
-Gtkmm2ext::pixel_width (const string& str, Pango::FontDescription& font)
+Gtkmm2ext::pixel_width (const string& str, const Pango::FontDescription& font)
{
Glib::RefPtr<Pango::Context> context = Glib::wrap (gdk_pango_context_get());
Glib::RefPtr<Pango::Layout> layout = Pango::Layout::create (context);
@@ -706,7 +718,7 @@ Gtkmm2ext::pixel_width (const string& str, Pango::FontDescription& font)
}
void
-Gtkmm2ext::pixel_size (const string& str, Pango::FontDescription& font, int& width, int& height)
+Gtkmm2ext::pixel_size (const string& str, const Pango::FontDescription& font, int& width, int& height)
{
Gtk::Label foo;
Glib::RefPtr<Pango::Layout> layout = foo.create_pango_layout ("");
@@ -732,9 +744,9 @@ Gtkmm2ext::fit_to_pixels (const string& str, int pixel_width, Pango::FontDescrip
layout->set_width (pixel_width * PANGO_SCALE);
if (with_ellipses) {
- layout->set_ellipsize (Pango::ELLIPSIZE_END);
+ layout->set_ellipsize (Pango::ELLIPSIZE_END);
} else {
- layout->set_wrap (Pango::WRAP_CHAR);
+ layout->set_wrap (Pango::WRAP_CHAR);
}
line = layout->get_line (0);