X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fgtkmm2ext%2Fgtkmm2ext%2Ffastmeter.h;h=6802481777c0819cf6d6319adc7df091db53cba8;hb=8648a8a13b04549362f14a0738947d997ef1abc7;hp=49076fa73a75b8f4f7a3ca19701d5dfe1d08eb66;hpb=447e736139f61dbc8697fbd7a19a5fd3cb7d1609;p=ardour.git diff --git a/libs/gtkmm2ext/gtkmm2ext/fastmeter.h b/libs/gtkmm2ext/gtkmm2ext/fastmeter.h index 49076fa73a..6802481777 100644 --- a/libs/gtkmm2ext/gtkmm2ext/fastmeter.h +++ b/libs/gtkmm2ext/gtkmm2ext/fastmeter.h @@ -27,9 +27,11 @@ #include #include +#include "gtkmm2ext/visibility.h" + namespace Gtkmm2ext { -class FastMeter : public Gtk::DrawingArea { +class LIBGTKMM2EXT_API FastMeter : public Gtk::DrawingArea { public: enum Orientation { Horizontal, @@ -37,12 +39,22 @@ class FastMeter : public Gtk::DrawingArea { }; FastMeter (long hold_cnt, unsigned long width, Orientation, int len=0, - int clr0=0x00ff00, int clr1=0xffff00, int clr2=0xffaa00, int clr3=0xff0000, - int bgc0=0x111111ff, int bgc1=0x333333ff, int bgc2=0x333333ff, int bgc3=0x444444ff + 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 ~FastMeter (); - void set (float level); + void set (float level, float peak = -1); void clear (); float get_level() { return current_level; } @@ -51,20 +63,25 @@ class FastMeter : public Gtk::DrawingArea { long hold_count() { return hold_cnt; } void set_hold_count (long); + void set_highlight (bool); + bool get_highlight () { return highlight; } protected: bool on_expose_event (GdkEventExpose*); void on_size_request (GtkRequisition*); void on_size_allocate (Gtk::Allocation&); - private: Cairo::RefPtr fgpattern; Cairo::RefPtr bgpattern; gint pixheight; gint pixwidth; - int _clr0, _clr1, _clr2, _clr3; - int _bgc0, _bgc1, _bgc2, _bgc3; + + float _stp[4]; + int _clr[10]; + int _bgc[2]; + int _bgh[2]; + int _styleflags; Orientation orientation; GdkRectangle pixrect; @@ -73,33 +90,83 @@ private: gint request_height; unsigned long hold_cnt; unsigned long hold_state; + bool bright_hold; float current_level; float current_peak; float current_user_level; - bool resized; + bool highlight; bool vertical_expose (GdkEventExpose*); + void vertical_size_request (GtkRequisition*); + void vertical_size_allocate (Gtk::Allocation&); void queue_vertical_redraw (const Glib::RefPtr&, float); + bool horizontal_expose (GdkEventExpose*); + void horizontal_size_request (GtkRequisition*); + void horizontal_size_allocate (Gtk::Allocation&); + void queue_horizontal_redraw (const Glib::RefPtr&, float); + + static bool no_rgba_overlay; + static Cairo::RefPtr generate_meter_pattern ( - int w, int h, int clr0, int clr1, int clr2, int clr3); + int, int, int *, float *, int, bool); static Cairo::RefPtr request_vertical_meter ( - int w, int h, int clr0, int clr1, int clr2, int clr3); + int, int, int *, float *, int); + static Cairo::RefPtr request_horizontal_meter ( + int, int, int *, float *, int); + + static Cairo::RefPtr generate_meter_background ( + int, int, int *, bool, bool); + static Cairo::RefPtr request_vertical_background ( + int, int, int *, bool); + static Cairo::RefPtr request_horizontal_background ( + int, int, int *, bool); + + struct Pattern10MapKey { + Pattern10MapKey ( + int w, int h, + float stp0, float stp1, float stp2, float stp3, + int c0, int c1, int c2, int c3, + int c4, int c5, int c6, int c7, + int c8, int c9, int st + ) + : dim(w, h) + , stp(stp0, stp1, stp2, stp3) + , cols(c0, c1, c2, c3, c4, c5, c6, c7, c8, c9) + , style(st) + {} + inline bool operator<(const Pattern10MapKey& rhs) const { + return (dim < rhs.dim) + || (dim == rhs.dim && stp < rhs.stp) + || (dim == rhs.dim && stp == rhs.stp && cols < rhs.cols) + || (dim == rhs.dim && stp == rhs.stp && cols == rhs.cols && style < rhs.style); + } + boost::tuple dim; + boost::tuple stp; + boost::tuple cols; + int style; + }; + typedef std::map > Pattern10Map; - struct PatternMapKey { - PatternMapKey (int w, int h, int c0, int c1, int c2, int c3) + struct PatternBgMapKey { + PatternBgMapKey (int w, int h, int c0, int c1, bool shade) : dim(w, h) - , cols(c0, c1, c2, c3) + , cols(c0, c1) + , sh(shade) {} - inline bool operator<(const PatternMapKey& rhs) const { - return (dim < rhs.dim) || (dim == rhs.dim && cols < rhs.cols); + inline bool operator<(const PatternBgMapKey& rhs) const { + return (dim < rhs.dim) || (dim == rhs.dim && cols < rhs.cols) || (dim == rhs.dim && cols == rhs.cols && (sh && !rhs.sh)); } - boost::tuple dim; // width, height - boost::tuple cols; // c0, c1, c2, c3 + boost::tuple dim; + boost::tuple cols; + bool sh; }; - typedef std::map > PatternMap; + typedef std::map > PatternBgMap; - static PatternMap v_pattern_cache; + static Pattern10Map vm_pattern_cache; + static PatternBgMap vb_pattern_cache; + static Pattern10Map hm_pattern_cache; + static PatternBgMap hb_pattern_cache; static int min_pattern_metric_size; // min dimension for axis that displays the meter level static int max_pattern_metric_size; // max dimension for axis that displays the meter level };