add the ability to use cairo scaling to warp the rendering of the main clock text
This commit is contained in:
parent
168d187994
commit
d8405e2ebe
@ -95,6 +95,8 @@ AudioClock::AudioClock (const string& clock_name, bool transient, const string&
|
||||
, last_sdelta (0)
|
||||
, dragging (false)
|
||||
, drag_field (Field (0))
|
||||
, xscale (1.0)
|
||||
, yscale (1.0)
|
||||
{
|
||||
set_flags (CAN_FOCUS);
|
||||
|
||||
@ -277,6 +279,15 @@ AudioClock::set_colors ()
|
||||
queue_draw ();
|
||||
}
|
||||
|
||||
void
|
||||
AudioClock::set_scale (double x, double y)
|
||||
{
|
||||
xscale = x;
|
||||
yscale = y;
|
||||
|
||||
queue_draw ();
|
||||
}
|
||||
|
||||
void
|
||||
AudioClock::render (cairo_t* cr, cairo_rectangle_t*)
|
||||
{
|
||||
@ -296,10 +307,22 @@ AudioClock::render (cairo_t* cr, cairo_rectangle_t*)
|
||||
cairo_fill (cr);
|
||||
}
|
||||
|
||||
cairo_move_to (cr, (get_width() - layout_width) / 2.0, (upper_height - layout_height) / 2.0);
|
||||
double lw = layout_width * xscale;
|
||||
double lh = layout_height * yscale;
|
||||
|
||||
cairo_move_to (cr, (get_width() - lw) / 2.0, (upper_height - lh) / 2.0);
|
||||
|
||||
if (xscale != 1.0 || yscale != 1.0) {
|
||||
cairo_save (cr);
|
||||
cairo_scale (cr, xscale, yscale);
|
||||
}
|
||||
|
||||
pango_cairo_show_layout (cr, _layout->gobj());
|
||||
|
||||
if (xscale != 1.0 || yscale != 1.0) {
|
||||
cairo_restore (cr);
|
||||
}
|
||||
|
||||
if (_left_layout) {
|
||||
|
||||
double h = get_height() - upper_height - separator_height;
|
||||
|
@ -77,6 +77,14 @@ class AudioClock : public CairoWidget, public ARDOUR::SessionHandlePtr
|
||||
void set_session (ARDOUR::Session *s);
|
||||
void set_negative_allowed (bool yn);
|
||||
|
||||
/** Alter cairo scaling during rendering.
|
||||
*
|
||||
* Used by clocks that resize themselves
|
||||
* to fit any given space. Can lead
|
||||
* to font distortion.
|
||||
*/
|
||||
void set_scale (double x, double y);
|
||||
|
||||
static void print_minsec (framepos_t, char* buf, size_t bufsize, float frame_rate);
|
||||
|
||||
sigc::signal<void> ValueChanged;
|
||||
@ -232,6 +240,9 @@ class AudioClock : public CairoWidget, public ARDOUR::SessionHandlePtr
|
||||
|
||||
double bg_r, bg_g, bg_b, bg_a;
|
||||
double cursor_r, cursor_g, cursor_b, cursor_a;
|
||||
|
||||
double xscale;
|
||||
double yscale;
|
||||
};
|
||||
|
||||
#endif /* __audio_clock_h__ */
|
||||
|
Loading…
Reference in New Issue
Block a user