From ec7d5029597f826001822756582157b3e14bd2f0 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 17 Jul 2023 20:55:13 -0600 Subject: [PATCH] cairo single pixel line offset fix, part 2 This will need careful visual inspection of the items drawn by the affected code to make sure they are still precisely as intended --- gtk2_ardour/editor_cursors.cc | 2 +- gtk2_ardour/mini_timeline.cc | 4 ++-- gtk2_ardour/mono_panner.cc | 2 +- gtk2_ardour/piano_roll_header.cc | 6 +++--- gtk2_ardour/plugin_dspload_ui.cc | 8 ++++---- gtk2_ardour/plugin_eq_gui.cc | 8 ++++---- gtk2_ardour/plugin_pin_dialog.cc | 6 +++--- gtk2_ardour/processor_box.cc | 4 ++-- gtk2_ardour/region_peak_cursor.cc | 2 +- 9 files changed, 21 insertions(+), 21 deletions(-) diff --git a/gtk2_ardour/editor_cursors.cc b/gtk2_ardour/editor_cursors.cc index 52eff719f1..9159b2cb06 100644 --- a/gtk2_ardour/editor_cursors.cc +++ b/gtk2_ardour/editor_cursors.cc @@ -86,7 +86,7 @@ EditorCursor::set_position (samplepos_t sample) double const new_pos = _editor.sample_to_pixel_unrounded (sample); if (rint(new_pos) != rint(_track_canvas_item->x ())) { - _track_canvas_item->set_x (new_pos-0.5); //accommodate the 1/2 pixel "line" offset in cairo + _track_canvas_item->set_x (new_pos + 0.5); //accommodate the 1/2 pixel "line" offset in cairo } _current_sample = sample; diff --git a/gtk2_ardour/mini_timeline.cc b/gtk2_ardour/mini_timeline.cc index 9fba4aaa16..be778941f7 100644 --- a/gtk2_ardour/mini_timeline.cc +++ b/gtk2_ardour/mini_timeline.cc @@ -636,10 +636,10 @@ MiniTimeline::render (Cairo::RefPtr const& ctx, cairo_rectangle_ cairo_set_line_width (cr, 1.0); double r,g,b,a; Gtkmm2ext::color_to_rgba(_phead_color, r,g,b,a); cairo_set_source_rgb (cr, r,g,b); // playhead color - cairo_move_to (cr, xc - .5, 0); + cairo_move_to (cr, xc + .5, 0); cairo_rel_line_to (cr, 0, height); cairo_stroke (cr); - cairo_move_to (cr, xc - .5, height); + cairo_move_to (cr, xc + .5, height); cairo_rel_line_to (cr, -3, 0); cairo_rel_line_to (cr, 3, -4); cairo_rel_line_to (cr, 3, 4); diff --git a/gtk2_ardour/mono_panner.cc b/gtk2_ardour/mono_panner.cc index 49934521e7..578be0c035 100644 --- a/gtk2_ardour/mono_panner.cc +++ b/gtk2_ardour/mono_panner.cc @@ -207,7 +207,7 @@ MonoPanner::on_expose_event (GdkEventExpose*) /* right box */ rounded_right_half_rectangle (context, - right - half_lr_box - .5, + right - half_lr_box + .5, half_lr_box + step_down, lr_box_size, lr_box_size, corner_radius); context->set_source_rgba (UINT_RGBA_R_FLT(f), UINT_RGBA_G_FLT(f), UINT_RGBA_B_FLT(f), UINT_RGBA_A_FLT(f)); diff --git a/gtk2_ardour/piano_roll_header.cc b/gtk2_ardour/piano_roll_header.cc index 6ff6e54f6b..7e2e660436 100644 --- a/gtk2_ardour/piano_roll_header.cc +++ b/gtk2_ardour/piano_roll_header.cc @@ -331,8 +331,8 @@ PianoRollHeader::on_expose_event (GdkEventExpose* ev) cr->move_to (0.5f, rect.y); cr->line_to (0.5f, rect.y + rect.height); cr->stroke (); - cr->move_to (get_width () - 0.5f, rect.y); - cr->line_to (get_width () - 0.5f, rect.y + rect.height); + cr->move_to (get_width () + 0.5f, rect.y); + cr->line_to (get_width () + 0.5f, rect.y + rect.height); cr->stroke (); //pat->add_color_stop_rgb(0.0, 0.33, 0.33, 0.33); @@ -446,7 +446,7 @@ PianoRollHeader::on_expose_event (GdkEventExpose* ev) /* render the name of which C this is */ if (oct_rel == 0) { std::stringstream s; - double y = floor (_view.note_to_y (i)) - 0.5f; + double y = floor (_view.note_to_y (i)) + 0.5f; double note_height = floor (_view.note_to_y (i - 1)) - y; int cn = i / 12 - 1; diff --git a/gtk2_ardour/plugin_dspload_ui.cc b/gtk2_ardour/plugin_dspload_ui.cc index cd82f694db..948acbc70b 100644 --- a/gtk2_ardour/plugin_dspload_ui.cc +++ b/gtk2_ardour/plugin_dspload_ui.cc @@ -197,12 +197,12 @@ PluginLoadStatsGui::draw_bar (GdkEventExpose* ev) const int dx = w * i / 9.; // == DEFLECT (v) - cairo_move_to (cr, x0 + dx - .5, y0); - cairo_line_to (cr, x0 + dx - .5, y1); + cairo_move_to (cr, x0 + dx + .5, y0); + cairo_line_to (cr, x0 + dx + .5, y1); cairo_set_source_rgba (cr, 1., 1., 1., 1.); cairo_stroke (cr); - cairo_move_to (cr, x0 + dx - .5 * text_width, y1 + 1); + cairo_move_to (cr, x0 + dx + .5 * text_width, y1 + 1); cairo_set_source_rgb (cr, fg.get_red_p (), fg.get_green_p (), fg.get_blue_p ()); pango_cairo_show_layout (cr, layout->gobj ()); } @@ -225,7 +225,7 @@ PluginLoadStatsGui::draw_bar (GdkEventExpose* ev) double xd0 = DEFLECT((_avg - _dev) / 1000.); double xd1 = DEFLECT((_avg + _dev) / 1000.); - cairo_move_to (cr, x0 + xavg - .5, y0 - 1); + cairo_move_to (cr, x0 + xavg + .5, y0 - 1); cairo_rel_line_to (cr, -5, -5); cairo_rel_line_to (cr, 10, 0); cairo_close_path (cr); diff --git a/gtk2_ardour/plugin_eq_gui.cc b/gtk2_ardour/plugin_eq_gui.cc index b6f072792e..266d835256 100644 --- a/gtk2_ardour/plugin_eq_gui.cc +++ b/gtk2_ardour/plugin_eq_gui.cc @@ -599,8 +599,8 @@ PluginEqGui::redraw_analysis_area () cairo_set_line_cap (cr, CAIRO_LINE_CAP_ROUND); cairo_set_source_rgb (cr, 1.0, 1.0, 1.0); cairo_set_line_width (cr, 1.0); - cairo_move_to (cr, _pointer_in_area_freq - .5, -.5); - cairo_line_to (cr, _pointer_in_area_freq - .5, _analysis_height - .5); + cairo_move_to (cr, _pointer_in_area_freq + .5, +.5); + cairo_line_to (cr, _pointer_in_area_freq + .5, _analysis_height + .5); cairo_stroke (cr); } @@ -637,7 +637,7 @@ PluginEqGui::draw_scales_phase (Gtk::Widget*, cairo_t *cr) continue; } - y = roundf (y) - .5; + y = roundf (y) + .5; cairo_set_source_rgba (cr, .8, .9, .2, 0.4); cairo_move_to (cr, 0.0, y); @@ -654,7 +654,7 @@ PluginEqGui::draw_scales_phase (Gtk::Widget*, cairo_t *cr) cairo_move_to (cr, _analysis_width - t_ext.width - t_ext.x_bearing - 2.0, y - extents.descent); cairo_show_text (cr, buf); - y = roundf (y) - .5; + y = roundf (y) + .5; // line cairo_set_source_rgba (cr, .8, .9, .2, 0.4); cairo_move_to (cr, 0.0, y); diff --git a/gtk2_ardour/plugin_pin_dialog.cc b/gtk2_ardour/plugin_pin_dialog.cc index 9841ef2f87..73c3d00c01 100644 --- a/gtk2_ardour/plugin_pin_dialog.cc +++ b/gtk2_ardour/plugin_pin_dialog.cc @@ -853,11 +853,11 @@ PluginPinWidget::draw_plugin_pin (cairo_t* cr, const CtrlWidget& w) layout->set_text (w.name); layout->get_pixel_size (text_width, text_height); - rounded_rectangle (cr, w.x + dx - .5 * text_width - 2, w.y - text_height - 2, text_width + 4, text_height + 2, 7); + rounded_rectangle (cr, w.x + dx + .5 * text_width - 2, w.y - text_height - 2, text_width + 4, text_height + 2, 7); cairo_set_source_rgba (cr, 0, 0, 0, .5); cairo_fill (cr); - cairo_move_to (cr, w.x + dx - .5 * text_width, w.y - text_height - 1); + cairo_move_to (cr, w.x + dx + .5 * text_width, w.y - text_height - 1); cairo_set_source_rgba (cr, 1., 1., 1., 1.); pango_cairo_show_layout (cr, layout->gobj ()); } @@ -880,7 +880,7 @@ double PluginPinWidget::pin_x_pos (uint32_t i, double x0, double width, uint32_t n_total, uint32_t n_midi, bool midi) { if (!midi) { i += n_midi; } - return rint (x0 + (i + 1) * width / (1. + n_total)) - .5; + return rint (x0 + (i + 1) * width / (1. + n_total)) + .5; } const PluginPinWidget::CtrlWidget& diff --git a/gtk2_ardour/processor_box.cc b/gtk2_ardour/processor_box.cc index 008c41a478..a23e22a48d 100644 --- a/gtk2_ardour/processor_box.cc +++ b/gtk2_ardour/processor_box.cc @@ -1308,7 +1308,7 @@ ProcessorEntry::PortIcon::on_expose_event (GdkEventExpose* ev) for (uint32_t i = 0; i < _ports.n_total(); ++i) { set_routing_color (cr, i < _ports.n_midi()); const double x = ProcessorEntry::RoutingIcon::pin_x_pos (i, width, _ports.n_total(), 0 , false); - cairo_rectangle (cr, x - .5 - dx * .5, 0, 1 + dx, height); + cairo_rectangle (cr, x + .5 - dx * .5, 0, 1 + dx, height); cairo_fill(cr); } @@ -1460,7 +1460,7 @@ void ProcessorEntry::RoutingIcon::draw_sidechain (cairo_t* cr, double x0, double y0, double height, bool midi) { const double dx = 1 + rint (max(2., 2. * UIConfiguration::instance().get_ui_scale())); - const double y1 = rint (height * .5) - .5; + const double y1 = rint (height * .5) + .5; cairo_save (cr); cairo_translate (cr, x0, y0); diff --git a/gtk2_ardour/region_peak_cursor.cc b/gtk2_ardour/region_peak_cursor.cc index c20e7e87b2..f05da7a275 100644 --- a/gtk2_ardour/region_peak_cursor.cc +++ b/gtk2_ardour/region_peak_cursor.cc @@ -131,7 +131,7 @@ RegionPeakCursor::set (AudioRegionView* arv, samplepos_t when, samplecnt_t sampl _canvas_text->set_x_position (xpos + 3); _canvas_text->set_y_position (pos.y + 3); - _canvas_line->set_x (xpos - 0.5); + _canvas_line->set_x (xpos + 0.5); _canvas_line->set_y0 (pos.y); _canvas_line->set_y1 (pos.y + arv->height ());