summaryrefslogtreecommitdiff
path: root/gtk2_ardour/time_axis_view_item.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2006-04-27 09:04:24 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2006-04-27 09:04:24 +0000
commit982d639d44f23ac46aa19ddb08055fa8cec9b0fd (patch)
tree2acfb1920e1bf4b8eb0390a34db131302c85a71e /gtk2_ardour/time_axis_view_item.cc
parentd2ff9e40e3d1990eba4024b945bdf0a6bb1625cf (diff)
"The In-Flight Hack, 2006"
a) measure lines extend the full height of the canvas b) region name color bars and text positioning now adjusted to match font size for different display resolutions c) vertical scrollbar limited to cover visible tracks only git-svn-id: svn://localhost/trunk/ardour2@486 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour/time_axis_view_item.cc')
-rw-r--r--gtk2_ardour/time_axis_view_item.cc45
1 files changed, 36 insertions, 9 deletions
diff --git a/gtk2_ardour/time_axis_view_item.cc b/gtk2_ardour/time_axis_view_item.cc
index 270cbde0b8..f54688ddfb 100644
--- a/gtk2_ardour/time_axis_view_item.cc
+++ b/gtk2_ardour/time_axis_view_item.cc
@@ -23,6 +23,8 @@
#include <ardour/types.h>
#include <ardour/ardour.h>
+#include <gtkmm2ext/utils.h>
+
#include "public_editor.h"
#include "time_axis_view_item.h"
#include "time_axis_view.h"
@@ -38,15 +40,17 @@ using namespace Editing;
using namespace Glib;
//------------------------------------------------------------------------------
-/** Initialize static memeber data */
+/** Initialize const static memeber data */
+
Pango::FontDescription TimeAxisViewItem::NAME_FONT;
bool TimeAxisViewItem::have_name_font = false;
const double TimeAxisViewItem::NAME_X_OFFSET = 15.0;
-const double TimeAxisViewItem::NAME_Y_OFFSET = 15.0 ; /* XXX depends a lot on the font size, sigh. */
-const double TimeAxisViewItem::NAME_HIGHLIGHT_SIZE = 15.0 ; /* ditto */
-const double TimeAxisViewItem::NAME_HIGHLIGHT_THRESH = 32.0 ; /* ditto */
const double TimeAxisViewItem::GRAB_HANDLE_LENGTH = 6 ;
+double TimeAxisViewItem::NAME_Y_OFFSET;
+double TimeAxisViewItem::NAME_HIGHLIGHT_SIZE;
+double TimeAxisViewItem::NAME_HIGHLIGHT_THRESH;
+
//---------------------------------------------------------------------------------------//
// Constructor / Desctructor
@@ -68,7 +72,26 @@ TimeAxisViewItem::TimeAxisViewItem(const string & it_name, ArdourCanvas::Group&
: trackview (tv)
{
if (!have_name_font) {
+
+ /* first constructed item sets up font info */
+
NAME_FONT = get_font_for_style (N_("TimeAxisViewItemName"));
+
+ Gtk::Window win;
+ Gtk::Label foo;
+ win.add (foo);
+
+ Glib::RefPtr<Pango::Layout> layout = foo.create_pango_layout (X_("Hg")); /* ascender + descender */
+ int width;
+ int height;
+
+ layout->set_font_description (NAME_FONT);
+ Gtkmm2ext::get_ink_pixel_size (layout, width, height);
+
+ NAME_Y_OFFSET = height + 4;
+ NAME_HIGHLIGHT_SIZE = height + 6;
+ NAME_HIGHLIGHT_THRESH = NAME_HIGHLIGHT_SIZE * 2;
+
have_name_font = true;
}
@@ -150,7 +173,10 @@ TimeAxisViewItem::TimeAxisViewItem(const string & it_name, ArdourCanvas::Group&
if (visibility & ShowNameText) {
name_text = new ArdourCanvas::Text (*group);
name_text->property_x() = (double) TimeAxisViewItem::NAME_X_OFFSET;
- name_text->property_y() = (double) trackview.height + 1.0 - TimeAxisViewItem::NAME_Y_OFFSET;
+ /* trackview.height is the bottom of the trackview. subtract 1 to get back to the bottom of the highlight,
+ then NAME_Y_OFFSET to position the text in the vertical center of the highlight
+ */
+ name_text->property_y() = (double) trackview.height - 1.0 - TimeAxisViewItem::NAME_Y_OFFSET;
name_text->property_font_desc() = NAME_FONT;
name_text->property_anchor() = Gtk::ANCHOR_NW;
@@ -872,6 +898,7 @@ TimeAxisViewItem::reset_name_width (double pixel_width)
}
int width;
+
ustring ustr = fit_to_pixels (item_name, (int) floor (pixel_width - NAME_X_OFFSET), NAME_FONT, width);
if (ustr.empty()) {
@@ -934,8 +961,8 @@ TimeAxisViewItem::remove_this_item(void* src)
gint
TimeAxisViewItem::idle_remove_this_item(TimeAxisViewItem* item, void* src)
{
- item->ItemRemoved(item->get_item_name(), src) ; /* EMIT_SIGNAL */
- delete item ;
- item = 0 ;
- return(false) ;
+ item->ItemRemoved (item->get_item_name(), src) ; /* EMIT_SIGNAL */
+ delete item;
+ item = 0;
+ return false;
}