mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-06 23:05:04 +01:00
change the meters into CairoWidget, add expose_area to CairoWidget::render()
This commit is contained in:
parent
9df3157dfc
commit
ab44e41dfd
18 changed files with 53 additions and 56 deletions
|
|
@ -195,7 +195,7 @@ ArdourButton::set_alignment (const float xa, const float ya)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ArdourButton::render (cairo_t* cr)
|
ArdourButton::render (cairo_t* cr, cairo_rectangle_t *)
|
||||||
{
|
{
|
||||||
void (*rounded_function)(cairo_t*, double, double, double, double, double);
|
void (*rounded_function)(cairo_t*, double, double, double, double, double);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -99,7 +99,7 @@ class ArdourButton : public CairoWidget , public Gtkmm2ext::Activatable
|
||||||
void set_fixed_colors (const uint32_t active_color, const uint32_t inactive_color);
|
void set_fixed_colors (const uint32_t active_color, const uint32_t inactive_color);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void render (cairo_t *);
|
void render (cairo_t *, cairo_rectangle_t *);
|
||||||
void on_size_request (Gtk::Requisition* req);
|
void on_size_request (Gtk::Requisition* req);
|
||||||
void on_size_allocate (Gtk::Allocation&);
|
void on_size_allocate (Gtk::Allocation&);
|
||||||
void on_style_changed (const Glib::RefPtr<Gtk::Style>&);
|
void on_style_changed (const Glib::RefPtr<Gtk::Style>&);
|
||||||
|
|
|
||||||
|
|
@ -282,7 +282,7 @@ AudioClock::set_colors ()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
AudioClock::render (cairo_t* cr)
|
AudioClock::render (cairo_t* cr, cairo_rectangle_t*)
|
||||||
{
|
{
|
||||||
/* main layout: rounded rect, plus the text */
|
/* main layout: rounded rect, plus the text */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -85,7 +85,7 @@ class AudioClock : public CairoWidget, public ARDOUR::SessionHandlePtr
|
||||||
static std::vector<AudioClock*> clocks;
|
static std::vector<AudioClock*> clocks;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void render (cairo_t*);
|
void render (cairo_t*, cairo_rectangle_t*);
|
||||||
|
|
||||||
virtual void build_ops_menu ();
|
virtual void build_ops_menu ();
|
||||||
Gtk::Menu *ops_menu;
|
Gtk::Menu *ops_menu;
|
||||||
|
|
|
||||||
|
|
@ -99,7 +99,7 @@ ButtonJoiner::~ButtonJoiner ()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ButtonJoiner::render (cairo_t* cr)
|
ButtonJoiner::render (cairo_t* cr, cairo_rectangle_t*)
|
||||||
{
|
{
|
||||||
double h = get_height();
|
double h = get_height();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ class ButtonJoiner : public CairoWidget, public Gtkmm2ext::Activatable {
|
||||||
void set_active_state (Gtkmm2ext::ActiveState);
|
void set_active_state (Gtkmm2ext::ActiveState);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void render (cairo_t*);
|
void render (cairo_t*, cairo_rectangle_t*);
|
||||||
bool on_button_release_event (GdkEventButton*);
|
bool on_button_release_event (GdkEventButton*);
|
||||||
void on_size_request (Gtk::Requisition*);
|
void on_size_request (Gtk::Requisition*);
|
||||||
void on_size_allocate (Gtk::Allocation&);
|
void on_size_allocate (Gtk::Allocation&);
|
||||||
|
|
|
||||||
|
|
@ -89,7 +89,7 @@ EditorSummary::set_session (Session* s)
|
||||||
* @param cr Context.
|
* @param cr Context.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
EditorSummary::render (cairo_t* cr)
|
EditorSummary::render (cairo_t* cr, cairo_rectangle_t*)
|
||||||
{
|
{
|
||||||
/* background (really just the dividing lines between tracks */
|
/* background (really just the dividing lines between tracks */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,7 @@ private:
|
||||||
bool on_leave_notify_event (GdkEventCrossing*);
|
bool on_leave_notify_event (GdkEventCrossing*);
|
||||||
|
|
||||||
void centre_on_click (GdkEventButton *);
|
void centre_on_click (GdkEventButton *);
|
||||||
void render (cairo_t *);
|
void render (cairo_t *, cairo_rectangle_t*);
|
||||||
void render_region (RegionView*, cairo_t*, double) const;
|
void render_region (RegionView*, cairo_t*, double) const;
|
||||||
void get_editor (std::pair<double, double> *, std::pair<double, double> *) const;
|
void get_editor (std::pair<double, double> *, std::pair<double, double> *) const;
|
||||||
void set_editor (double, double);
|
void set_editor (double, double);
|
||||||
|
|
|
||||||
|
|
@ -237,7 +237,7 @@ GroupTabs::on_button_release_event (GdkEventButton*)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
GroupTabs::render (cairo_t* cr)
|
GroupTabs::render (cairo_t* cr, cairo_rectangle_t*)
|
||||||
{
|
{
|
||||||
if (_dragging == 0) {
|
if (_dragging == 0) {
|
||||||
_tabs = compute_tabs ();
|
_tabs = compute_tabs ();
|
||||||
|
|
|
||||||
|
|
@ -108,7 +108,7 @@ private:
|
||||||
void disable_all ();
|
void disable_all ();
|
||||||
void remove_group (ARDOUR::RouteGroup *);
|
void remove_group (ARDOUR::RouteGroup *);
|
||||||
|
|
||||||
void render (cairo_t *);
|
void render (cairo_t *, cairo_rectangle_t*);
|
||||||
void on_size_request (Gtk::Requisition *);
|
void on_size_request (Gtk::Requisition *);
|
||||||
bool on_button_press_event (GdkEventButton *);
|
bool on_button_press_event (GdkEventButton *);
|
||||||
bool on_motion_notify_event (GdkEventMotion *);
|
bool on_motion_notify_event (GdkEventMotion *);
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ LED::~LED()
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
LED::render (cairo_t* cr)
|
LED::render (cairo_t* cr, cairo_rectangle_t*)
|
||||||
{
|
{
|
||||||
if (!_fixed_diameter) {
|
if (!_fixed_diameter) {
|
||||||
_diameter = std::min (get_width(), get_height());
|
_diameter = std::min (get_width(), get_height());
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ class LED : public CairoWidget
|
||||||
void set_diameter (float);
|
void set_diameter (float);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void render (cairo_t *);
|
void render (cairo_t *, cairo_rectangle_t*);
|
||||||
void on_size_request (Gtk::Requisition* req);
|
void on_size_request (Gtk::Requisition* req);
|
||||||
void on_realize ();
|
void on_realize ();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -512,7 +512,7 @@ ShuttleControl::use_shuttle_fract (bool force, bool zero_ok)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ShuttleControl::render (cairo_t* cr)
|
ShuttleControl::render (cairo_t* cr, cairo_rectangle_t*)
|
||||||
{
|
{
|
||||||
cairo_text_extents_t extents;
|
cairo_text_extents_t extents;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,7 @@ class ShuttleControl : public CairoWidget, public ARDOUR::SessionHandlePtr
|
||||||
bool on_scroll_event (GdkEventScroll*);
|
bool on_scroll_event (GdkEventScroll*);
|
||||||
bool on_motion_notify_event(GdkEventMotion*);
|
bool on_motion_notify_event(GdkEventMotion*);
|
||||||
|
|
||||||
void render (cairo_t *);
|
void render (cairo_t *, cairo_rectangle_t*);
|
||||||
|
|
||||||
void on_size_allocate (Gtk::Allocation&);
|
void on_size_allocate (Gtk::Allocation&);
|
||||||
bool on_query_tooltip (int, int, bool, const Glib::RefPtr<Gtk::Tooltip>&);
|
bool on_query_tooltip (int, int, bool, const Glib::RefPtr<Gtk::Tooltip>&);
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,13 @@ CairoWidget::on_expose_event (GdkEventExpose *ev)
|
||||||
cairo_set_source_rgb (cr, bg.get_red_p(), bg.get_green_p(), bg.get_blue_p());
|
cairo_set_source_rgb (cr, bg.get_red_p(), bg.get_green_p(), bg.get_blue_p());
|
||||||
cairo_fill (cr);
|
cairo_fill (cr);
|
||||||
|
|
||||||
render (cr);
|
cairo_rectangle_t expose_area;
|
||||||
|
expose_area.x = ev->area.x;
|
||||||
|
expose_area.y = ev->area.y;
|
||||||
|
expose_area.width = ev->area.width;
|
||||||
|
expose_area.height = ev->area.height;
|
||||||
|
|
||||||
|
render (cr, &expose_area);
|
||||||
|
|
||||||
cairo_destroy (cr);
|
cairo_destroy (cr);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -504,7 +504,7 @@ FastMeter::vertical_size_allocate (Gtk::Allocation &alloc)
|
||||||
pixwidth = request_width - 2;
|
pixwidth = request_width - 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
DrawingArea::on_size_allocate (alloc);
|
CairoWidget::on_size_allocate (alloc);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
@ -529,31 +529,26 @@ FastMeter::horizontal_size_allocate (Gtk::Allocation &alloc)
|
||||||
pixheight = request_height - 2;
|
pixheight = request_height - 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
DrawingArea::on_size_allocate (alloc);
|
CairoWidget::on_size_allocate (alloc);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
void
|
||||||
FastMeter::on_expose_event (GdkEventExpose* ev)
|
FastMeter::render (cairo_t* cr, cairo_rectangle_t* area)
|
||||||
{
|
{
|
||||||
if (orientation == Vertical) {
|
if (orientation == Vertical) {
|
||||||
return vertical_expose (ev);
|
return vertical_expose (cr, area);
|
||||||
} else {
|
} else {
|
||||||
return horizontal_expose (ev);
|
return horizontal_expose (cr, area);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
void
|
||||||
FastMeter::vertical_expose (GdkEventExpose* ev)
|
FastMeter::vertical_expose (cairo_t* cr, cairo_rectangle_t* area)
|
||||||
{
|
{
|
||||||
Glib::RefPtr<Gdk::Window> win = get_window ();
|
|
||||||
gint top_of_meter;
|
gint top_of_meter;
|
||||||
GdkRectangle intersection;
|
GdkRectangle intersection;
|
||||||
GdkRectangle background;
|
GdkRectangle background;
|
||||||
|
GdkRectangle eventarea;
|
||||||
cairo_t* cr = gdk_cairo_create (get_window ()->gobj());
|
|
||||||
|
|
||||||
cairo_rectangle (cr, ev->area.x, ev->area.y, ev->area.width, ev->area.height);
|
|
||||||
cairo_clip (cr);
|
|
||||||
|
|
||||||
cairo_set_source_rgb (cr, 0, 0, 0); // black
|
cairo_set_source_rgb (cr, 0, 0, 0); // black
|
||||||
rounded_rectangle (cr, 0, 0, pixwidth + 2, pixheight + 2, 2);
|
rounded_rectangle (cr, 0, 0, pixwidth + 2, pixheight + 2, 2);
|
||||||
|
|
@ -572,13 +567,18 @@ FastMeter::vertical_expose (GdkEventExpose* ev)
|
||||||
background.width = pixrect.width;
|
background.width = pixrect.width;
|
||||||
background.height = pixheight - top_of_meter;
|
background.height = pixheight - top_of_meter;
|
||||||
|
|
||||||
if (gdk_rectangle_intersect (&background, &ev->area, &intersection)) {
|
eventarea.x = area->x;
|
||||||
|
eventarea.y = area->y;
|
||||||
|
eventarea.width = area->width;
|
||||||
|
eventarea.height = area->height;
|
||||||
|
|
||||||
|
if (gdk_rectangle_intersect (&background, &eventarea, &intersection)) {
|
||||||
cairo_set_source (cr, bgpattern->cobj());
|
cairo_set_source (cr, bgpattern->cobj());
|
||||||
cairo_rectangle (cr, intersection.x, intersection.y, intersection.width, intersection.height);
|
cairo_rectangle (cr, intersection.x, intersection.y, intersection.width, intersection.height);
|
||||||
cairo_fill (cr);
|
cairo_fill (cr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gdk_rectangle_intersect (&pixrect, &ev->area, &intersection)) {
|
if (gdk_rectangle_intersect (&pixrect, &eventarea, &intersection)) {
|
||||||
// draw the part of the meter image that we need. the area we draw is bounded "in reverse" (top->bottom)
|
// draw the part of the meter image that we need. the area we draw is bounded "in reverse" (top->bottom)
|
||||||
cairo_set_source (cr, fgpattern->cobj());
|
cairo_set_source (cr, fgpattern->cobj());
|
||||||
cairo_rectangle (cr, intersection.x, intersection.y, intersection.width, intersection.height);
|
cairo_rectangle (cr, intersection.x, intersection.y, intersection.width, intersection.height);
|
||||||
|
|
@ -610,24 +610,15 @@ FastMeter::vertical_expose (GdkEventExpose* ev)
|
||||||
last_peak_rect.width = 0;
|
last_peak_rect.width = 0;
|
||||||
last_peak_rect.height = 0;
|
last_peak_rect.height = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
cairo_destroy (cr);
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
void
|
||||||
FastMeter::horizontal_expose (GdkEventExpose* ev)
|
FastMeter::horizontal_expose (cairo_t* cr, cairo_rectangle_t* area)
|
||||||
{
|
{
|
||||||
Glib::RefPtr<Gdk::Window> win = get_window ();
|
|
||||||
gint right_of_meter;
|
gint right_of_meter;
|
||||||
GdkRectangle intersection;
|
GdkRectangle intersection;
|
||||||
GdkRectangle background;
|
GdkRectangle background;
|
||||||
|
GdkRectangle eventarea;
|
||||||
cairo_t* cr = gdk_cairo_create (get_window ()->gobj());
|
|
||||||
|
|
||||||
cairo_rectangle (cr, ev->area.x, ev->area.y, ev->area.width, ev->area.height);
|
|
||||||
cairo_clip (cr);
|
|
||||||
|
|
||||||
cairo_set_source_rgb (cr, 0, 0, 0); // black
|
cairo_set_source_rgb (cr, 0, 0, 0); // black
|
||||||
rounded_rectangle (cr, 0, 0, pixwidth + 2, pixheight + 2, 2);
|
rounded_rectangle (cr, 0, 0, pixwidth + 2, pixheight + 2, 2);
|
||||||
|
|
@ -645,13 +636,18 @@ FastMeter::horizontal_expose (GdkEventExpose* ev)
|
||||||
background.width = pixwidth - right_of_meter;
|
background.width = pixwidth - right_of_meter;
|
||||||
background.height = pixheight;
|
background.height = pixheight;
|
||||||
|
|
||||||
if (gdk_rectangle_intersect (&background, &ev->area, &intersection)) {
|
eventarea.x = area->x;
|
||||||
|
eventarea.y = area->y;
|
||||||
|
eventarea.width = area->width;
|
||||||
|
eventarea.height = area->height;
|
||||||
|
|
||||||
|
if (gdk_rectangle_intersect (&background, &eventarea, &intersection)) {
|
||||||
cairo_set_source (cr, bgpattern->cobj());
|
cairo_set_source (cr, bgpattern->cobj());
|
||||||
cairo_rectangle (cr, intersection.x, intersection.y, intersection.width, intersection.height);
|
cairo_rectangle (cr, intersection.x, intersection.y, intersection.width, intersection.height);
|
||||||
cairo_fill (cr);
|
cairo_fill (cr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gdk_rectangle_intersect (&pixrect, &ev->area, &intersection)) {
|
if (gdk_rectangle_intersect (&pixrect, &eventarea, &intersection)) {
|
||||||
cairo_set_source (cr, fgpattern->cobj());
|
cairo_set_source (cr, fgpattern->cobj());
|
||||||
cairo_rectangle (cr, intersection.x, intersection.y, intersection.width, intersection.height);
|
cairo_rectangle (cr, intersection.x, intersection.y, intersection.width, intersection.height);
|
||||||
cairo_fill (cr);
|
cairo_fill (cr);
|
||||||
|
|
@ -683,10 +679,6 @@ FastMeter::horizontal_expose (GdkEventExpose* ev)
|
||||||
last_peak_rect.width = 0;
|
last_peak_rect.width = 0;
|
||||||
last_peak_rect.height = 0;
|
last_peak_rect.height = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
cairo_destroy (cr);
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
|
|
||||||
|
|
@ -69,7 +69,7 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
/** Render the widget to the given Cairo context */
|
/** Render the widget to the given Cairo context */
|
||||||
virtual void render (cairo_t *) = 0;
|
virtual void render (cairo_t *, cairo_rectangle_t*) = 0;
|
||||||
virtual bool on_expose_event (GdkEventExpose *);
|
virtual bool on_expose_event (GdkEventExpose *);
|
||||||
void on_size_allocate (Gtk::Allocation &);
|
void on_size_allocate (Gtk::Allocation &);
|
||||||
void on_state_changed (Gtk::StateType);
|
void on_state_changed (Gtk::StateType);
|
||||||
|
|
|
||||||
|
|
@ -24,14 +24,13 @@
|
||||||
#include <boost/tuple/tuple.hpp>
|
#include <boost/tuple/tuple.hpp>
|
||||||
#include <boost/tuple/tuple_comparison.hpp>
|
#include <boost/tuple/tuple_comparison.hpp>
|
||||||
#include <cairomm/pattern.h>
|
#include <cairomm/pattern.h>
|
||||||
#include <gtkmm/drawingarea.h>
|
#include "gtkmm2ext/cairo_widget.h"
|
||||||
#include <gdkmm/pixbuf.h>
|
|
||||||
|
|
||||||
#include "gtkmm2ext/visibility.h"
|
#include "gtkmm2ext/visibility.h"
|
||||||
|
|
||||||
namespace Gtkmm2ext {
|
namespace Gtkmm2ext {
|
||||||
|
|
||||||
class LIBGTKMM2EXT_API FastMeter : public Gtk::DrawingArea {
|
class LIBGTKMM2EXT_API FastMeter : public CairoWidget {
|
||||||
public:
|
public:
|
||||||
enum Orientation {
|
enum Orientation {
|
||||||
Horizontal,
|
Horizontal,
|
||||||
|
|
@ -67,7 +66,7 @@ class LIBGTKMM2EXT_API FastMeter : public Gtk::DrawingArea {
|
||||||
bool get_highlight () { return highlight; }
|
bool get_highlight () { return highlight; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool on_expose_event (GdkEventExpose*);
|
void render (cairo_t *, cairo_rectangle_t*);
|
||||||
void on_size_request (GtkRequisition*);
|
void on_size_request (GtkRequisition*);
|
||||||
void on_size_allocate (Gtk::Allocation&);
|
void on_size_allocate (Gtk::Allocation&);
|
||||||
private:
|
private:
|
||||||
|
|
@ -96,12 +95,12 @@ private:
|
||||||
float current_user_level;
|
float current_user_level;
|
||||||
bool highlight;
|
bool highlight;
|
||||||
|
|
||||||
bool vertical_expose (GdkEventExpose*);
|
void vertical_expose (cairo_t*, cairo_rectangle_t*);
|
||||||
void vertical_size_request (GtkRequisition*);
|
void vertical_size_request (GtkRequisition*);
|
||||||
void vertical_size_allocate (Gtk::Allocation&);
|
void vertical_size_allocate (Gtk::Allocation&);
|
||||||
void queue_vertical_redraw (const Glib::RefPtr<Gdk::Window>&, float);
|
void queue_vertical_redraw (const Glib::RefPtr<Gdk::Window>&, float);
|
||||||
|
|
||||||
bool horizontal_expose (GdkEventExpose*);
|
void horizontal_expose (cairo_t*, cairo_rectangle_t*);
|
||||||
void horizontal_size_request (GtkRequisition*);
|
void horizontal_size_request (GtkRequisition*);
|
||||||
void horizontal_size_allocate (Gtk::Allocation&);
|
void horizontal_size_allocate (Gtk::Allocation&);
|
||||||
void queue_horizontal_redraw (const Glib::RefPtr<Gdk::Window>&, float);
|
void queue_horizontal_redraw (const Glib::RefPtr<Gdk::Window>&, float);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue