X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Faudio_clock.cc;h=b64e54e95e6413d1f7120adac40de3c98ac31f59;hb=2d47183dc962bddd2084676b59e9f2c4a0abe33b;hp=15fd85c229d5eb5d8db35efc995a3a41f3fddf15;hpb=47110c983c48fb683a9f78b50923b06db5e341c8;p=ardour.git diff --git a/gtk2_ardour/audio_clock.cc b/gtk2_ardour/audio_clock.cc index 15fd85c229..b64e54e95e 100644 --- a/gtk2_ardour/audio_clock.cc +++ b/gtk2_ardour/audio_clock.cc @@ -55,7 +55,7 @@ using Gtkmm2ext::Keyboard; sigc::signal AudioClock::ModeChanged; vector AudioClock::clocks; -const double AudioClock::info_font_scale_factor = 0.60; +const double AudioClock::info_font_scale_factor = 0.68; const double AudioClock::separator_height = 0.0; const double AudioClock::x_leading_padding = 6.0; @@ -65,13 +65,15 @@ const double AudioClock::x_leading_padding = 6.0; #define TXTSPAN "" AudioClock::AudioClock (const string& clock_name, bool transient, const string& widget_name, - bool allow_edit, bool follows_playhead, bool duration, bool with_info) + bool allow_edit, bool follows_playhead, bool duration, bool with_info, + bool accept_on_focus_out) : ops_menu (0) , _name (clock_name) , is_transient (transient) , is_duration (duration) , editable (allow_edit) , _follows_playhead (follows_playhead) + , _accept_on_focus_out (accept_on_focus_out) , _off (false) , em_width (0) , _edit_by_click_field (false) @@ -334,7 +336,7 @@ AudioClock::render (cairo_t* cr, cairo_rectangle_t*) if (mode_based_info_ratio != 1.0) { - double left_rect_width = round (((get_width() - separator_height) * mode_based_info_ratio) + 0.5); + double left_rect_width = get_left_rect_width(); if (_need_bg) { if (corner_radius) { @@ -470,7 +472,10 @@ AudioClock::set_clock_dimensions (Gtk::Requisition& req) tmp->set_font_description (font); /* this string is the longest thing we will ever display */ - tmp->set_text (" 88:88:88,888"); + if (_mode == MinSec) + tmp->set_text (" 88:88:88,888 "); + else + tmp->set_text (" 88:88:88,88 "); tmp->get_pixel_size (req.width, req.height); layout_height = req.height; @@ -1685,7 +1690,7 @@ AudioClock::on_focus_out_event (GdkEventFocus* ev) bool ret = CairoWidget::on_focus_out_event (ev); if (editing) { - end_edit (false); + end_edit (_accept_on_focus_out); } return ret; @@ -2079,6 +2084,24 @@ AudioClock::frames_from_audioframes_string (const string& str) const return f; } +void +AudioClock::copy_text_to_clipboard () const +{ + string val; + if (editing) { + val = pre_edit_string; + } else { + val = _layout->get_text (); + } + const size_t trim = val.find_first_not_of(" "); + if (trim == string::npos) { + assert(0); // empty clock, can't be right. + return; + } + Glib::RefPtr cl = Gtk::Clipboard::get(); + cl->set_text (val.substr(trim)); +} + void AudioClock::build_ops_menu () { @@ -2099,6 +2122,8 @@ AudioClock::build_ops_menu () ops_items.push_back (MenuElem (_("Set From Playhead"), sigc::mem_fun(*this, &AudioClock::set_from_playhead))); ops_items.push_back (MenuElem (_("Locate to This Time"), sigc::mem_fun(*this, &AudioClock::locate))); } + ops_items.push_back (SeparatorElem()); + ops_items.push_back (MenuElem (_("Copy to clipboard"), sigc::mem_fun(*this, &AudioClock::copy_text_to_clipboard))); } void @@ -2135,6 +2160,9 @@ AudioClock::set_mode (Mode m) _layout->set_text (""); + Gtk::Requisition req; + set_clock_dimensions (req); + if (_left_layout) { _left_layout->set_attributes (info_attributes);