Towards a consistent render() API.

This fixes an -Woverloaded-virtual ambiguity introduced in b5e613d45

  void render (cairo_t*, cairo_rectagle*)
  void render (Cairo::RefPtr<Cairo::Context> const&, cairo_rectangle_t*)

ArdourCanvas prefers cairomm and CairoWidget itself uses Cairo::Context,
this improves overall API consistency.
This commit is contained in:
Robin Gareus 2017-03-20 17:11:56 +01:00
parent 3294b82e25
commit d06de26a4f
30 changed files with 55 additions and 49 deletions

View File

@ -44,7 +44,6 @@
#define BASELINESTRETCH (1.25)
#define TRACKHEADERBTNW (3.10)
using namespace Gdk;
using namespace Gtk;
using namespace Glib;
using namespace PBD;
@ -256,8 +255,10 @@ ArdourButton::set_alignment (const float xa, const float ya)
* ARDOUR_UI_UTILS::render_vector_icon()
*/
void
ArdourButton::render (cairo_t* cr, cairo_rectangle_t *)
ArdourButton::render (Cairo::RefPtr<Cairo::Context> const& ctx, cairo_rectangle_t*)
{
cairo_t* cr = ctx->cobj();
uint32_t text_color;
uint32_t led_color;

View File

@ -127,7 +127,7 @@ class ArdourButton : public CairoWidget , public Gtkmm2ext::Activatable
float char_avg_pixel_width() { if (_char_pixel_width < 1) recalc_char_pixel_geometry() ; return _char_avg_pixel_width; }
protected:
void render (cairo_t *, cairo_rectangle_t *);
void render (Cairo::RefPtr<Cairo::Context> const&, cairo_rectangle_t*);
void on_size_request (Gtk::Requisition* req);
void on_size_allocate (Gtk::Allocation&);
void on_style_changed (const Glib::RefPtr<Gtk::Style>&);

View File

@ -46,7 +46,6 @@
#include "pbd/i18n.h"
using namespace Gtkmm2ext;
using namespace Gdk;
using namespace Gtk;
using namespace Glib;
using namespace PBD;
@ -79,8 +78,9 @@ ArdourKnob::~ArdourKnob()
}
void
ArdourKnob::render (cairo_t* cr, cairo_rectangle_t *)
ArdourKnob::render (Cairo::RefPtr<Cairo::Context> const& ctx, cairo_rectangle_t*)
{
cairo_t* cr = ctx->cobj();
cairo_pattern_t* shade_pattern;
float width = get_width();

View File

@ -91,7 +91,7 @@ public:
void color_handler ();
protected:
void render (cairo_t *, cairo_rectangle_t *);
void render (Cairo::RefPtr<Cairo::Context> const&, cairo_rectangle_t*);
void on_size_request (Gtk::Requisition* req);
void on_size_allocate (Gtk::Allocation&);
void on_style_changed (const Glib::RefPtr<Gtk::Style>&);

View File

@ -27,12 +27,12 @@ public:
ArdourVSpacer (float r = 0.75f) : CairoWidget (), ratio (r) {}
protected:
void render (cairo_t* cr, cairo_rectangle_t* r) {
void render (Cairo::RefPtr<Cairo::Context> const& ctx, cairo_rectangle_t* r) {
float h = r->height * ratio;
float t = .5f * (r->height - h);
cairo_rectangle (cr, 0, t, 1, h);
cairo_set_source_rgb (cr, 0, 0, 0);
cairo_fill (cr);
ctx->rectangle (0, t, 1, h);
ctx->set_source_rgb (0, 0, 0);
ctx->fill ();
}
void on_size_request (Gtk::Requisition* req) {

View File

@ -275,8 +275,9 @@ AudioClock::set_scale (double x, double y)
}
void
AudioClock::render (cairo_t* cr, cairo_rectangle_t*)
AudioClock::render (Cairo::RefPtr<Cairo::Context> const& ctx, cairo_rectangle_t*)
{
cairo_t* cr = ctx->cobj();
/* main layout: rounded rect, plus the text */
if (_need_bg) {

View File

@ -102,7 +102,7 @@ class AudioClock : public CairoWidget, public ARDOUR::SessionHandlePtr
static std::vector<AudioClock*> clocks;
protected:
void render (cairo_t*, cairo_rectangle_t*);
void render (Cairo::RefPtr<Cairo::Context> const&, cairo_rectangle_t*);
bool get_is_duration () const { return is_duration; } ;
virtual void build_ops_menu ();

View File

@ -101,8 +101,9 @@ ButtonJoiner::~ButtonJoiner ()
}
void
ButtonJoiner::render (cairo_t* cr, cairo_rectangle_t*)
ButtonJoiner::render (Cairo::RefPtr<Cairo::Context> const& ctx, cairo_rectangle_t*)
{
cairo_t* cr = ctx->cobj();
double h = get_height();
if (!get_active()) {

View File

@ -36,7 +36,7 @@ class ButtonJoiner : public CairoWidget, public Gtkmm2ext::Activatable {
void set_active_state (Gtkmm2ext::ActiveState);
protected:
void render (cairo_t*, cairo_rectangle_t*);
void render (Cairo::RefPtr<Cairo::Context> const&, cairo_rectangle_t*);
bool on_button_release_event (GdkEventButton*);
void on_size_request (Gtk::Requisition*);
void on_size_allocate (Gtk::Allocation&);

View File

@ -211,8 +211,9 @@ EditorSummary::render_background_image ()
* @param cr Context.
*/
void
EditorSummary::render (cairo_t* cr, cairo_rectangle_t*)
EditorSummary::render (Cairo::RefPtr<Cairo::Context> const& ctx, cairo_rectangle_t*)
{
cairo_t* cr = ctx->cobj();
if (_session == 0) {
return;

View File

@ -73,7 +73,7 @@ private:
bool on_leave_notify_event (GdkEventCrossing*);
void centre_on_click (GdkEventButton *);
void render (cairo_t *, cairo_rectangle_t*);
void render (Cairo::RefPtr<Cairo::Context> const&, cairo_rectangle_t*);
void render_region (RegionView*, cairo_t*, double) const;
void get_editor (std::pair<double, double> *, std::pair<double, double> *) const;
void set_editor (double, double);

View File

@ -46,12 +46,12 @@ protected:
virtual void overlay (cairo_t* cr, cairo_rectangle_t* r) {}
virtual void render (cairo_t* cr, cairo_rectangle_t* r)
virtual void render (Cairo::RefPtr<Cairo::Context> const& ctx, cairo_rectangle_t* r)
{
cairo_rectangle (cr, r->x, r->y, r->width, r->height);
cairo_clip (cr);
background (cr, r);
overlay (cr, r);
ctx->rectangle (r->x, r->y, r->width, r->height);
ctx->clip ();
background (ctx->cobj(), r);
overlay (ctx->cobj(), r);
}
Cairo::RefPtr<Cairo::ImageSurface> _surface;

View File

@ -241,8 +241,9 @@ GroupTabs::on_button_release_event (GdkEventButton*)
}
void
GroupTabs::render (cairo_t* cr, cairo_rectangle_t*)
GroupTabs::render (Cairo::RefPtr<Cairo::Context> const& ctx, cairo_rectangle_t*)
{
cairo_t* cr = ctx->cobj();
if (_dragging == 0) {
_tabs = compute_tabs ();
}

View File

@ -115,7 +115,7 @@ private:
void disable_all ();
void remove_group (ARDOUR::RouteGroup *);
void render (cairo_t *, cairo_rectangle_t*);
void render (Cairo::RefPtr<Cairo::Context> const&, cairo_rectangle_t*);
void on_size_request (Gtk::Requisition *);
bool on_button_press_event (GdkEventButton *);
bool on_motion_notify_event (GdkEventMotion *);

View File

@ -42,8 +42,9 @@ LED::~LED()
}
void
LED::render (cairo_t* cr, cairo_rectangle_t*)
LED::render (Cairo::RefPtr<Cairo::Context> const& ctx, cairo_rectangle_t*)
{
cairo_t* cr = ctx->cobj();
if (!_fixed_diameter) {
_diameter = std::min (get_width(), get_height());
}

View File

@ -33,7 +33,7 @@ class LED : public CairoWidget
void set_diameter (float);
protected:
void render (cairo_t *, cairo_rectangle_t*);
void render (Cairo::RefPtr<Cairo::Context> const&, cairo_rectangle_t*);
void on_size_request (Gtk::Requisition* req);
void on_realize ();

View File

@ -405,8 +405,9 @@ struct LocationMarkerSort {
};
void
MiniTimeline::render (cairo_t* cr, cairo_rectangle_t*)
MiniTimeline::render (Cairo::RefPtr<Cairo::Context> const& ctx, cairo_rectangle_t*)
{
cairo_t* cr = ctx->cobj();
// TODO cache, set_colors()
ArdourCanvas::Color base = UIConfiguration::instance().color ("ruler base");
ArdourCanvas::Color text = UIConfiguration::instance().color ("ruler text");

View File

@ -67,7 +67,7 @@ private:
void draw_dots (cairo_t*, int left, int right, int y, ArdourCanvas::Color);
int draw_mark (cairo_t*, int x0, int x1, const std::string&, bool& prelight);
void render (cairo_t*, cairo_rectangle_t*);
void render (Cairo::RefPtr<Cairo::Context> const&, cairo_rectangle_t*);
void format_time (framepos_t when);
bool on_button_press_event (GdkEventButton*);

View File

@ -570,8 +570,9 @@ ShuttleControl::set_colors ()
}
void
ShuttleControl::render (cairo_t* cr, cairo_rectangle_t*)
ShuttleControl::render (Cairo::RefPtr<Cairo::Context> const& ctx, cairo_rectangle_t*)
{
cairo_t* cr = ctx->cobj();
// center slider line
float yc = get_height() / 2;
float lw = 3;

View File

@ -93,7 +93,7 @@ protected:
bool on_scroll_event (GdkEventScroll*);
bool on_motion_notify_event(GdkEventMotion*);
void render (cairo_t *, cairo_rectangle_t*);
void render (Cairo::RefPtr<Cairo::Context> const&, cairo_rectangle_t*);
void on_size_allocate (Gtk::Allocation&);
bool on_query_tooltip (int, int, bool, const Glib::RefPtr<Gtk::Tooltip>&);

View File

@ -104,7 +104,7 @@ Widget::render (Rect const & area, Cairo::RefPtr<Cairo::Context> context) const
//context->rectangle (draw.x0, draw.y0, draw.width(), draw.height());
//context->clip ();
_widget.render (context->cobj(), &crect);
_widget.render (context, &crect);
context->restore ();
}

View File

@ -195,7 +195,7 @@ CairoWidget::on_expose_event (GdkEventExpose *ev)
cr->fill ();
}
render (cr->cobj(), &expose_area);
render (cr, &expose_area);
#ifdef USE_CAIRO_IMAGE_SURFACE_FOR_CAIRO_WIDGET
if(get_visible_window ()) {
@ -283,7 +283,7 @@ CairoWidget::on_expose_event (GdkEventExpose *ev)
expose_area.width = ev->area.width;
expose_area.height = ev->area.height;
render (cr->cobj(), &expose_area);
render (cr, &expose_area);
#ifdef OPTIONAL_CAIRO_IMAGE_SURFACE
if (getenv("ARDOUR_IMAGE_SURFACE")) {

View File

@ -184,8 +184,9 @@ Fader::set_touch_cursor (const Glib::RefPtr<Gdk::Pixbuf>& touch_cursor)
}
void
Fader::render (cairo_t* cr, cairo_rectangle_t*)
Fader::render (Cairo::RefPtr<Cairo::Context> const& ctx, cairo_rectangle_t*)
{
cairo_t* cr = ctx->cobj();
double xscale = 1.0;
double yscale = 1.0;

View File

@ -544,12 +544,12 @@ FastMeter::horizontal_size_allocate (Gtk::Allocation &alloc)
}
void
FastMeter::render (cairo_t* cr, cairo_rectangle_t* area)
FastMeter::render (Cairo::RefPtr<Cairo::Context> const& ctx, cairo_rectangle_t* area)
{
if (orientation == Vertical) {
return vertical_expose (cr, area);
return vertical_expose (ctx->cobj(), area);
} else {
return horizontal_expose (cr, area);
return horizontal_expose (ctx->cobj(), area);
}
}

View File

@ -20,6 +20,7 @@
#ifndef __gtk2_ardour_cairo_widget_h__
#define __gtk2_ardour_cairo_widget_h__
#include <cairomm/context.h>
#include <cairomm/surface.h>
#include <gtkmm/eventbox.h>
@ -81,12 +82,6 @@ public:
static void provide_background_for_cairo_widget (Gtk::Widget& w, const Gdk::Color& bg);
virtual void render (cairo_t *, cairo_rectangle_t*) = 0;
virtual void render (Cairo::RefPtr<Cairo::Context> const & ctx, cairo_rectangle_t* r) {
render (ctx->cobj(), r);
}
uint32_t background_color ();
static void set_flat_buttons (bool yn);

View File

@ -62,7 +62,7 @@ class LIBGTKMM2EXT_API Fader : public CairoWidget
void on_size_request (GtkRequisition*);
void on_size_allocate (Gtk::Allocation& alloc);
void render (cairo_t* cr, cairo_rectangle_t*);
void render (Cairo::RefPtr<Cairo::Context> const&, cairo_rectangle_t*);
bool on_button_press_event (GdkEventButton*);
bool on_button_release_event (GdkEventButton*);
bool on_motion_notify_event (GdkEventMotion*);

View File

@ -65,9 +65,9 @@ class LIBGTKMM2EXT_API FastMeter : public CairoWidget {
void set_hold_count (long);
void set_highlight (bool);
bool get_highlight () { return highlight; }
void render (Cairo::RefPtr<Cairo::Context> const&, cairo_rectangle_t*);
protected:
void render (cairo_t *, cairo_rectangle_t*);
void on_size_request (GtkRequisition*);
void on_size_allocate (Gtk::Allocation&);
private:

View File

@ -58,7 +58,7 @@ class LIBGTKMM2EXT_API PixFader : public CairoWidget
void on_size_request (GtkRequisition*);
void on_size_allocate (Gtk::Allocation& alloc);
void render (cairo_t *, cairo_rectangle_t*);
void render (Cairo::RefPtr<Cairo::Context> const&, cairo_rectangle_t*);
bool on_grab_broken_event (GdkEventGrabBroken*);
bool on_button_press_event (GdkEventButton*);
bool on_button_release_event (GdkEventButton*);

View File

@ -205,8 +205,10 @@ PixFader::create_patterns ()
}
void
PixFader::render (cairo_t *cr, cairo_rectangle_t* area)
PixFader::render (Cairo::RefPtr<Cairo::Context> const& ctx, cairo_rectangle_t* area)
{
cairo_t* cr = ctx->cobj();
if (!_pattern) {
create_patterns();
}

View File

@ -542,12 +542,12 @@ FastMeter::horizontal_size_allocate (Gtk::Allocation &alloc)
}
void
FastMeter::render (cairo_t* cr, cairo_rectangle_t* area)
FastMeter::render (Cairo::RefPtr<Cairo::Context> const& ctx, cairo_rectangle_t* area)
{
if (orientation == Vertical) {
return vertical_expose (cr, area);
return vertical_expose (cr->cobj(), area);
} else {
return horizontal_expose (cr, area);
return horizontal_expose (cr->cobj(), area);
}
}