add canvas-based Meter object

This commit is contained in:
Paul Davis 2016-09-25 15:01:26 -05:00
parent 85c1523611
commit 29b8072555
3 changed files with 72 additions and 7 deletions

View File

@ -29,9 +29,11 @@
#include "canvas/item.h"
namespace ArdourSurface {
namespace ArdourCanvas {
class Meter : public ArdourCanvas::Item {
class Canvas;
class Meter : public Item {
public:
enum Orientation {
Horizontal,
@ -53,6 +55,22 @@ class Meter : public ArdourCanvas::Item {
float stp3 = 100.0,
int styleflags = 3
);
Meter (ArdourCanvas::Canvas* canvas,
long hold_cnt, unsigned long width, Orientation, int len=0,
int clr0=0x008800ff, int clr1=0x008800ff,
int clr2=0x00ff00ff, int clr3=0x00ff00ff,
int clr4=0xffaa00ff, int clr5=0xffaa00ff,
int clr6=0xffff00ff, int clr7=0xffff00ff,
int clr8=0xff0000ff, int clr9=0xff0000ff,
int bgc0=0x333333ff, int bgc1=0x444444ff,
int bgh0=0x991122ff, int bgh1=0x551111ff,
float stp0 = 55.0, // log_meter(-18);
float stp1 = 77.5, // log_meter(-9);
float stp2 = 92.5, // log_meter(-3); // 95.0, // log_meter(-2);
float stp3 = 100.0,
int styleflags = 3
);
virtual ~Meter ();
static void flush_pattern_cache();
@ -95,6 +113,15 @@ class Meter : public ArdourCanvas::Item {
float current_user_level;
bool highlight;
void init (int clr0, int clr1, int clr2, int clr3,
int clr4, int clr5, int clr6, int clr7,
int clr8, int clr9,
int bgc0, int bgc1,
int bgh0, int bgh1,
float stp0, float stp1,
float stp2, float stp3,
int dimen, int len);
void vertical_expose (ArdourCanvas::Rect const & area, Cairo::RefPtr<Cairo::Context> context) const;
void queue_vertical_redraw (float old_level);

View File

@ -31,16 +31,14 @@
#include <gtkmm2ext/rgb_macros.h>
#include "canvas/canvas.h"
#include "canvas/utils.h"
#include "canvas/colors.h"
#include "meter.h"
#include "canvas/meter.h"
#include "canvas/utils.h"
using namespace Glib;
using namespace Gtkmm2ext;
using namespace std;
using namespace ArdourCanvas;
using namespace ArdourSurface;
using namespace Gtkmm2ext;
int Meter::min_pattern_metric_size = 16;
int Meter::max_pattern_metric_size = 1024;
@ -73,6 +71,45 @@ Meter::Meter (Item* parent, long hold, unsigned long dimen, Orientation o, int l
, current_level(0)
, current_peak(0)
, highlight(false)
{
init (clr0, clr1, clr2, clr3, clr4, clr5, clr6, clr7, clr8, clr9, bgc0, bgc1, bgh0, bgh1, stp0, stp1, stp2, stp3, dimen, len);
}
Meter::Meter (Canvas* canvas, long hold, unsigned long dimen, Orientation o, int len,
int clr0, int clr1, int clr2, int clr3,
int clr4, int clr5, int clr6, int clr7,
int clr8, int clr9,
int bgc0, int bgc1,
int bgh0, int bgh1,
float stp0, float stp1,
float stp2, float stp3,
int styleflags
)
: Item (canvas)
, pixheight(0)
, pixwidth(0)
, _styleflags(styleflags)
, orientation(o)
, hold_cnt(hold)
, hold_state(0)
, bright_hold(false)
, current_level(0)
, current_peak(0)
, highlight(false)
{
init (clr0, clr1, clr2, clr3, clr4, clr5, clr6, clr7, clr8, clr9, bgc0, bgc1, bgh0, bgh1, stp0, stp1, stp2, stp3, dimen, len);
}
void
Meter::init (int clr0, int clr1, int clr2, int clr3,
int clr4, int clr5, int clr6, int clr7,
int clr8, int clr9,
int bgc0, int bgc1,
int bgh0, int bgh1,
float stp0, float stp1,
float stp2, float stp3,
int dimen,
int len)
{
last_peak_rect.width = 0;
last_peak_rect.height = 0;

View File

@ -46,6 +46,7 @@ canvas_sources = [
'line.cc',
'line_set.cc',
'lookup_table.cc',
'meter.cc',
'outline.cc',
'pixbuf.cc',
'poly_item.cc',