diff options
author | Carl Hetherington <carl@carlh.net> | 2009-01-25 06:47:11 +0000 |
---|---|---|
committer | Carl Hetherington <carl@carlh.net> | 2009-01-25 06:47:11 +0000 |
commit | 49510ba1d7fc1c85e767c05f10f9481998ef94b0 (patch) | |
tree | e04210728fb9b5e52864eb8cdc0774e4d0b9d7f2 /gtk2_ardour/port_matrix_component.cc | |
parent | a9d67a2cc97b28795a9112a176ba1f2c1ab470d3 (diff) |
Some refactoring. Add port group headers to the port matrix.
git-svn-id: svn://localhost/ardour2/branches/3.0@4443 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour/port_matrix_component.cc')
-rw-r--r-- | gtk2_ardour/port_matrix_component.cc | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/gtk2_ardour/port_matrix_component.cc b/gtk2_ardour/port_matrix_component.cc index e2d1e07027..74f989934e 100644 --- a/gtk2_ardour/port_matrix_component.cc +++ b/gtk2_ardour/port_matrix_component.cc @@ -105,3 +105,35 @@ PortMatrixComponent::dimensions () return std::make_pair (_width, _height); } + +std::pair<std::string, double> +PortMatrixComponent::display_port_name (cairo_t* cr, std::string const &n, double avail) const +{ + /* XXX hopefully there exists a more efficient way of doing this */ + + Glib::ustring name = Glib::ustring (n).uppercase (); + bool abbreviated = false; + uint32_t width = 0; + + while (1) { + if (name.length() <= 2) { + break; + } + + cairo_text_extents_t ext; + cairo_text_extents (cr, name.c_str(), &ext); + if (ext.width < avail) { + width = ext.width; + break; + } + + if (abbreviated) { + name = name.substr (0, name.length() - 2) + "."; + } else { + name = name.substr (0, name.length() - 1) + "."; + abbreviated = true; + } + } + + return std::make_pair (name, width); +} |