first round of audio-clock font rendering update
authorRobin Gareus <robin@gareus.org>
Sun, 11 Nov 2012 02:45:01 +0000 (02:45 +0000)
committerRobin Gareus <robin@gareus.org>
Sun, 11 Nov 2012 02:45:01 +0000 (02:45 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@13425 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/audio_clock.cc
gtk2_ardour/audio_clock.h
libs/ardour/ardour/slave.h
libs/ardour/ltc_slave.cc
libs/ardour/midi_clock_slave.cc
libs/ardour/mtc_slave.cc

index 3797d1c9c1ec2aee7236cd2ba664d5de06871298..1d690a5dfc379ff6fdfcafb9dcb83542d44c8180 100644 (file)
@@ -53,7 +53,7 @@ using Gtkmm2ext::Keyboard;
 
 sigc::signal<void> AudioClock::ModeChanged;
 vector<AudioClock*> AudioClock::clocks;
-const double AudioClock::info_font_scale_factor = 0.6;
+const double AudioClock::info_font_scale_factor = 0.5;
 const double AudioClock::separator_height = 0.0;
 const double AudioClock::x_leading_padding = 6.0;
 
@@ -83,6 +83,7 @@ AudioClock::AudioClock (const string& clock_name, bool transient, const string&
        , upper_height (0)
        , mode_based_info_ratio (1.0)
        , corner_radius (9)
+       , font_size (10240)
        , editing (false)
        , bbt_reference_time (-1)
        , last_when(0)
@@ -151,7 +152,6 @@ AudioClock::set_font ()
        Glib::RefPtr<Gtk::Style> style = get_style ();
        Pango::FontDescription font; 
        Pango::AttrFontDesc* font_attr;
-       uint32_t font_size;
 
        if (!is_realized()) {
                font = get_font_for_style (get_name());
@@ -177,13 +177,6 @@ AudioClock::set_font ()
 
        /* and an even smaller one */
 
-       delete font_attr;
-       font.set_size ((int) lrint (font_size * info_font_scale_factor * 0.75));
-       font.set_weight (Pango::WEIGHT_BOLD);
-       font_attr = new Pango::AttrFontDesc (Pango::Attribute::create_attr_font_desc (font));
-       small_info_attributes.change (*font_attr);
-       
        delete font_attr;
 
        /* get the figure width for the font. This doesn't have to super
@@ -263,7 +256,6 @@ AudioClock::set_colors ()
        
        normal_attributes.change (*foreground_attr);
        info_attributes.change (*foreground_attr);
-       small_info_attributes.change (*foreground_attr);
        editing_attributes.change (*foreground_attr);
        editing_attributes.change (*editing_attr);
 
@@ -274,13 +266,8 @@ AudioClock::set_colors ()
        }
 
        if (_left_layout) {
-               if (_mode == Timecode) {
-                       _left_layout->set_attributes (small_info_attributes);
-                       _right_layout->set_attributes (small_info_attributes);
-               } else {
-                       _left_layout->set_attributes (info_attributes);
-                       _right_layout->set_attributes (info_attributes);
-               }
+               _left_layout->set_attributes (info_attributes);
+               _right_layout->set_attributes (info_attributes);
        }
 
        queue_draw ();
@@ -364,7 +351,7 @@ AudioClock::render (cairo_t* cr)
                                if (x < x_leading_padding + left_rect_width + separator_height) {
                                        x = x_leading_padding + left_rect_width + separator_height;
                                }
-                               cairo_move_to (cr, x, upper_height + separator_height + ((h - info_height)/2.0));
+                               cairo_move_to (cr, x, upper_height + separator_height + ((h - rh)/2.0));
                        } else {
                                cairo_move_to (cr, x_leading_padding + left_rect_width + separator_height, upper_height + separator_height + ((h - info_height)/2.0));
                        }
@@ -1128,6 +1115,7 @@ AudioClock::set_timecode (framepos_t when, bool /*force*/)
        _layout->set_text (Timecode::timecode_format_time(TC));
 
        if (_left_layout && _right_layout) {
+
                SyncSource sync_src = Config->get_sync_source();
 
                if (_session->config.get_external_sync()) {
@@ -1143,7 +1131,8 @@ AudioClock::set_timecode (framepos_t when, bool /*force*/)
                                if (slave) {
                                        _left_layout->set_text (string_compose ("%1",
                                                                dynamic_cast<TimecodeSlave*>(slave)->approximate_current_position()));
-                                       _right_layout->set_text (slave->approximate_current_delta());
+                                       _right_layout->set_markup (string_compose ("<span size=\"%1\" foreground=\"white\">%2</span>",
+                                                               (int)round(font_size * info_font_scale_factor * .9), slave->approximate_current_delta()));
                                } else {
                                        _left_layout->set_text (string_compose ("--pending--",
                                                                sync_source_to_string(sync_src, true)));
@@ -1154,7 +1143,8 @@ AudioClock::set_timecode (framepos_t when, bool /*force*/)
                                if (slave) {
                                        _left_layout->set_text (string_compose ("%1",
                                                                sync_source_to_string(sync_src, true)));
-                                       _right_layout->set_text (slave->approximate_current_delta());
+                                       _right_layout->set_markup (string_compose ("<span size=\"%1\" foreground=\"white\">%2</span>",
+                                                               (int)round(font_size * info_font_scale_factor * .9), slave->approximate_current_delta()));
                                } else {
                                        _left_layout->set_text (string_compose ("%1 --pending--",
                                                                sync_source_to_string(sync_src, true)));
@@ -1165,7 +1155,8 @@ AudioClock::set_timecode (framepos_t when, bool /*force*/)
                                if (slave) {
                                        _left_layout->set_text (string_compose ("%1",
                                                                dynamic_cast<TimecodeSlave*>(slave)->approximate_current_position()));
-                                       _right_layout->set_text (slave->approximate_current_delta());
+                                       _right_layout->set_markup (string_compose ("<span size=\"%1\" foreground=\"white\">%2</span>",
+                                                               (int)round(font_size * info_font_scale_factor * .9), slave->approximate_current_delta()));
                                } else {
                                        _left_layout->set_text (string_compose ("%1 --pending--",
                                                                sync_source_to_string(sync_src, true)));
@@ -2057,13 +2048,8 @@ AudioClock::set_mode (Mode m)
 
        if (_left_layout) {
 
-               if (_mode == Timecode) {
-                       _left_layout->set_attributes (small_info_attributes);
-                       _right_layout->set_attributes (small_info_attributes);
-               } else {
-                       _left_layout->set_attributes (info_attributes);
-                       _right_layout->set_attributes (info_attributes);
-               }
+               _left_layout->set_attributes (info_attributes);
+               _right_layout->set_attributes (info_attributes);
                /* adjust info_height according to font size */
                int ignored;
                _left_layout->set_text (" 1234567890");
index 6235bbaf6906f0412f2a7fa6e3fa74d9387a5e29..5b1af6354e26e3e49456ae976df15aa99366aa36 100644 (file)
@@ -114,7 +114,6 @@ class AudioClock : public CairoWidget, public ARDOUR::SessionHandlePtr
        Pango::AttrList normal_attributes;
        Pango::AttrList editing_attributes;
        Pango::AttrList info_attributes;
-       Pango::AttrList small_info_attributes;
 
        int first_height;
        int first_width;
@@ -124,6 +123,7 @@ class AudioClock : public CairoWidget, public ARDOUR::SessionHandlePtr
        int upper_height;
        double mode_based_info_ratio;
        double corner_radius;
+       uint32_t font_size;
 
        static const double info_font_scale_factor;
        static const double separator_height;
index de58e07e36034beeb7b0c34ecf86ddfdb3765eaf..d147059ccd15b02947dbe6727dc7294c88351bb4 100644 (file)
@@ -39,7 +39,7 @@
 #endif
 
 // used for approximate_current_delta():
-#define PLUSMINUS(A) ( ((A)<0) ? "\u2012" : (((A)>0) ? "+" : "\u00B1") )
+#define PLUSMINUS(A) ( ((A)<0) ? "-" : (((A)>0) ? "+" : "\u00B1") )
 
 namespace MIDI {
        class Port;
index 3efc2eef787528688ae581f18e26071f7735270b..8cc12c2b5d2e75fdaa96171c98ecdcfe6bea4269 100644 (file)
@@ -540,13 +540,13 @@ LTC_Slave::approximate_current_position() const
 std::string
 LTC_Slave::approximate_current_delta() const
 {
-       char delta[24];
+       char delta[80];
        if (last_timestamp == 0 || engine_dll_initstate == 0) {
                snprintf(delta, sizeof(delta), "\u2012\u2012\u2012\u2012");
        } else if ((monotonic_cnt - last_timestamp) > 2 * frames_per_ltc_frame) {
-               snprintf(delta, sizeof(delta), "flywheel");
+               snprintf(delta, sizeof(delta), _("flywheel"));
        } else {
-               snprintf(delta, sizeof(delta), "\u0394 %s%4" PRIi64 " sm",
+               snprintf(delta, sizeof(delta), "\u0394<span foreground=\"green\" face=\"monospace\" >%s%5" PRIi64 "</span>sm",
                                PLUSMINUS(-current_delta), abs(current_delta));
        }
        return std::string(delta);
index 967626278e0da099d63043265e94d4e793c6bb94..3a9792a6dfcf2f8c06fb5883fbe977b19dac4968 100644 (file)
@@ -359,11 +359,11 @@ MIDIClock_Slave::resolution() const
 std::string
 MIDIClock_Slave::approximate_current_delta() const
 {
-       char delta[24];
+       char delta[80];
        if (last_timestamp == 0 || _starting) {
                snprintf(delta, sizeof(delta), "\u2012\u2012\u2012\u2012");
        } else {
-               snprintf(delta, sizeof(delta), "\u0394 %s%4" PRIi64 " sm",
+               snprintf(delta, sizeof(delta), "\u0394<span foreground=\"green\" face=\"monospace\" >%s%5" PRIi64 "</span>sm",
                                PLUSMINUS(-current_delta), abs(current_delta));
        }
        return std::string(delta);
index e7c2fde19945b510e270280e357bbc17c50e7a9b..c74958997f503f0a54955438fa68b3412aeac9fb 100644 (file)
@@ -673,14 +673,13 @@ MTC_Slave::approximate_current_position() const
 std::string
 MTC_Slave::approximate_current_delta() const
 {
-       char delta[24];
+       char delta[80];
        SafeTime last;
        read_current (&last);
        if (last.timestamp == 0 || reset_pending) {
                snprintf(delta, sizeof(delta), "\u2012\u2012\u2012\u2012");
        } else {
-               // TODO if current_delta > 1 frame -> display timecode.
-               snprintf(delta, sizeof(delta), "\u0394 %s%4" PRIi64 " sm",
+               snprintf(delta, sizeof(delta), "\u0394<span foreground=\"green\" face=\"monospace\">%s%5" PRIi64 "</span>sm",
                                PLUSMINUS(-current_delta), abs(current_delta));
        }
        return std::string(delta);