tweak meter-metric red-boxes/stripes
This commit is contained in:
parent
385b1121da
commit
d4c74b1718
@ -203,6 +203,15 @@ static inline float mtr_col_and_fract(
|
||||
return fraction;
|
||||
}
|
||||
|
||||
static void mtr_red_stripe(cairo_t* cr, float l, float w, int h, float top, float bot) {
|
||||
if (w <= 0) return;
|
||||
int t = h - floorf (h * (top));
|
||||
int b = h - floorf (h * (bot));
|
||||
cairo_set_source_rgba (cr, .75, 0, 0, 0.75);
|
||||
cairo_rectangle (cr, l, t + .5, w, b - t);
|
||||
cairo_fill (cr);
|
||||
}
|
||||
|
||||
static void set_bg_color(Gtk::Widget& w, cairo_t* cr, MeterType type) {
|
||||
float r,g,b;
|
||||
switch(type) {
|
||||
@ -267,13 +276,18 @@ meter_render_ticks (Gtk::Widget& w, MeterType type, vector<ARDOUR::DataType> typ
|
||||
tickright = w.get_name().substr(w.get_name().length() - 5) == "Right";
|
||||
background = types.size() == 0 || tickleft || tickright;
|
||||
|
||||
int box_l, box_r;
|
||||
float box_l=0;
|
||||
float box_w=0;
|
||||
if (tickleft) {
|
||||
box_l = 2; box_r = 3;
|
||||
if (w.get_name().substr(0, 3) == "Bar") {
|
||||
box_l = width-2; box_w = 2;
|
||||
}
|
||||
} else if (tickright) {
|
||||
box_l = 0; box_r = 1;
|
||||
if (w.get_name().substr(0, 3) == "Bar") {
|
||||
box_l = 0; box_w = 2;
|
||||
}
|
||||
} else {
|
||||
box_l = 0; box_r = 3;
|
||||
box_l = 0; box_w = 3;
|
||||
}
|
||||
|
||||
cairo_surface_t* surface = cairo_image_surface_create (CAIRO_FORMAT_RGB24, width, height);
|
||||
@ -303,17 +317,13 @@ meter_render_ticks (Gtk::Widget& w, MeterType type, vector<ARDOUR::DataType> typ
|
||||
c = w.get_style()->get_fg (Gtk::STATE_ACTIVE);
|
||||
} else if (background) {
|
||||
set_fg_color(w, type, &c);
|
||||
cairo_set_source_rgb (cr, c.get_red_p(), c.get_green_p(), c.get_blue_p());
|
||||
} else {
|
||||
c = w.get_style()->get_fg (Gtk::STATE_NORMAL);
|
||||
}
|
||||
cairo_set_source_rgb (cr, c.get_red_p(), c.get_green_p(), c.get_blue_p());
|
||||
|
||||
// tick-maker position in dBFS, line-thickness
|
||||
std::map<float,float> points;
|
||||
|
||||
#define DFL_H(fract) (height - floor (height * (fract)) + .5)
|
||||
|
||||
switch (*i) {
|
||||
case DataType::AUDIO:
|
||||
|
||||
@ -392,11 +402,8 @@ meter_render_ticks (Gtk::Widget& w, MeterType type, vector<ARDOUR::DataType> typ
|
||||
points.insert (std::pair<float,float>(-12.0f, 1.0));
|
||||
points.insert (std::pair<float,float>( -9.0f, 1.0));
|
||||
points.insert (std::pair<float,float>( -6.0f, 0.5));
|
||||
cairo_set_source_rgba (cr, .8, 0, 0, 0.8);
|
||||
cairo_rectangle (cr,
|
||||
box_l, DFL_H(meter_deflect_nordic( -6)),
|
||||
box_r, DFL_H(meter_deflect_nordic(-12)));
|
||||
cairo_fill (cr);
|
||||
mtr_red_stripe(cr, box_l, box_w, height,
|
||||
meter_deflect_nordic(-6.0f), meter_deflect_nordic(-12.0f));
|
||||
break;
|
||||
case MeterIEC1DIN:
|
||||
points.insert (std::pair<float,float>( -3.0f, 0.5)); // "200%"
|
||||
@ -422,11 +429,8 @@ meter_render_ticks (Gtk::Widget& w, MeterType type, vector<ARDOUR::DataType> typ
|
||||
points.insert (std::pair<float,float>(-49.0f, 1.0));
|
||||
points.insert (std::pair<float,float>(-54.0f, 0.5));
|
||||
points.insert (std::pair<float,float>(-59.0f, 1.0));
|
||||
cairo_set_source_rgba (cr, .8, 0, 0, 0.8);
|
||||
cairo_rectangle (cr,
|
||||
box_l, DFL_H(meter_deflect_din(0)),
|
||||
box_r, DFL_H(meter_deflect_din(-9.0)));
|
||||
cairo_fill (cr);
|
||||
mtr_red_stripe(cr, box_l, box_w, height,
|
||||
meter_deflect_din(0.0f), meter_deflect_din(-9.0f));
|
||||
break;
|
||||
case MeterVU:
|
||||
points.insert (std::pair<float,float>(-17.0f, 1.0)); //+3 VU
|
||||
@ -445,12 +449,8 @@ meter_render_ticks (Gtk::Widget& w, MeterType type, vector<ARDOUR::DataType> typ
|
||||
points.insert (std::pair<float,float>(-30.0f, 1.0));
|
||||
points.insert (std::pair<float,float>(-35.0f, 0.5));
|
||||
points.insert (std::pair<float,float>(-40.0f, 1.0));
|
||||
// red-box
|
||||
cairo_set_source_rgba (cr, .8, 0, 0, 0.8);
|
||||
cairo_rectangle (cr,
|
||||
box_l, DFL_H(meter_deflect_vu(-16)),
|
||||
box_r, DFL_H(meter_deflect_vu(-20)));
|
||||
cairo_fill (cr);
|
||||
mtr_red_stripe(cr, box_l, box_w, height,
|
||||
meter_deflect_vu(-17.0f), meter_deflect_vu(-20.0f));
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -531,6 +531,7 @@ meter_render_ticks (Gtk::Widget& w, MeterType type, vector<ARDOUR::DataType> typ
|
||||
fraction = (j->first) / 127.0;
|
||||
pos = 1 + height - (gint) floor (height * fraction);
|
||||
pos = min (pos, height);
|
||||
cairo_set_source_rgb (cr, c.get_red_p(), c.get_green_p(), c.get_blue_p());
|
||||
cairo_arc(cr, 1.5, pos + .5, 1.0, 0, 2 * M_PI);
|
||||
cairo_fill(cr);
|
||||
break;
|
||||
|
@ -64,6 +64,7 @@ MeterStrip::MeterStrip (int metricmode, MeterType mt)
|
||||
{
|
||||
level_meter = 0;
|
||||
_strip_type = 0;
|
||||
_tick_bar = 0;
|
||||
mtr_vbox.set_spacing(2);
|
||||
nfo_vbox.set_spacing(2);
|
||||
peakbx.set_size_request(-1, 14);
|
||||
@ -121,6 +122,7 @@ MeterStrip::MeterStrip (Session* sess, boost::shared_ptr<ARDOUR::Route> rt)
|
||||
SessionHandlePtr::set_session (sess);
|
||||
|
||||
_has_midi = false;
|
||||
_tick_bar = 0;
|
||||
|
||||
int meter_width = 6;
|
||||
if (_route->shared_peak_meter()->input_streams().n_total() == 1) {
|
||||
@ -384,13 +386,13 @@ MeterStrip::meter_configuration_changed (ChanCount c)
|
||||
if (boost::dynamic_pointer_cast<AudioTrack>(_route) == 0
|
||||
&& boost::dynamic_pointer_cast<MidiTrack>(_route) == 0
|
||||
) {
|
||||
meter_ticks1_area.set_name ("AudioBusMetricsLeft");
|
||||
meter_ticks2_area.set_name ("AudioBusMetricsRight");
|
||||
meter_ticks1_area.set_name ("MyAudioBusMetricsLeft");
|
||||
meter_ticks2_area.set_name ("MyAudioBusMetricsRight");
|
||||
_has_midi = false;
|
||||
}
|
||||
else if (type == (1 << DataType::AUDIO)) {
|
||||
meter_ticks1_area.set_name ("AudioTrackMetricsLeft");
|
||||
meter_ticks2_area.set_name ("AudioTrackMetricsRight");
|
||||
meter_ticks1_area.set_name ("MyAudioTrackMetricsLeft");
|
||||
meter_ticks2_area.set_name ("MyAudioTrackMetricsRight");
|
||||
_has_midi = false;
|
||||
}
|
||||
else if (type == (1 << DataType::MIDI)) {
|
||||
@ -402,12 +404,42 @@ MeterStrip::meter_configuration_changed (ChanCount c)
|
||||
meter_ticks2_area.set_name ("AudioMidiTrackMetricsRight");
|
||||
_has_midi = true;
|
||||
}
|
||||
set_tick_bar(_tick_bar);
|
||||
|
||||
on_theme_changed();
|
||||
if (old_has_midi != _has_midi) MetricChanged();
|
||||
else ConfigurationChanged();
|
||||
}
|
||||
|
||||
void
|
||||
MeterStrip::set_tick_bar (int m)
|
||||
{
|
||||
std::string n;
|
||||
_tick_bar = m;
|
||||
if (_tick_bar & 1) {
|
||||
n = meter_ticks1_area.get_name();
|
||||
if (n.substr(0,3) != "Bar") {
|
||||
meter_ticks1_area.set_name("Bar" + n);
|
||||
}
|
||||
} else {
|
||||
n = meter_ticks1_area.get_name();
|
||||
if (n.substr(0,3) == "Bar") {
|
||||
meter_ticks1_area.set_name(n.substr(3,-1));
|
||||
}
|
||||
}
|
||||
if (_tick_bar & 2) {
|
||||
n = meter_ticks2_area.get_name();
|
||||
if (n.substr(0,3) != "Bar") {
|
||||
meter_ticks2_area.set_name("Bar" + n);
|
||||
}
|
||||
} else {
|
||||
n = meter_ticks2_area.get_name();
|
||||
if (n.substr(0,3) == "Bar") {
|
||||
meter_ticks2_area.set_name(n.substr(3,-1));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
MeterStrip::on_size_request (Gtk::Requisition* r)
|
||||
{
|
||||
|
@ -65,6 +65,8 @@ class MeterStrip : public Gtk::VBox, public RouteUI
|
||||
void set_meter_type_multi (int, ARDOUR::RouteGroup*, ARDOUR::MeterType);
|
||||
|
||||
void set_metric_mode (int, ARDOUR::MeterType);
|
||||
void set_tick_bar (int);
|
||||
int get_tick_bar() { return _tick_bar; }
|
||||
bool has_midi() { return _has_midi; }
|
||||
bool is_metric_display() { return _strip_type == 0; }
|
||||
ARDOUR::MeterType meter_type();
|
||||
@ -117,6 +119,7 @@ class MeterStrip : public Gtk::VBox, public RouteUI
|
||||
|
||||
float max_peak;
|
||||
bool _has_midi;
|
||||
int _tick_bar;
|
||||
int _strip_type;
|
||||
|
||||
LevelMeterHBox *level_meter;
|
||||
|
@ -600,6 +600,7 @@ Meterbridge::sync_order_keys (RouteSortOrderKey src)
|
||||
|
||||
int pos = 0;
|
||||
int vis = 0;
|
||||
MeterStrip * last = 0;
|
||||
|
||||
unsigned int metrics = 0;
|
||||
MeterType lmt = MeterPeak;
|
||||
@ -651,14 +652,24 @@ Meterbridge::sync_order_keys (RouteSortOrderKey src)
|
||||
vis++;
|
||||
}
|
||||
|
||||
(*i).s->set_tick_bar(0);
|
||||
|
||||
MeterType nmt = (*i).s->meter_type();
|
||||
if (nmt == MeterKrms) nmt = MeterPeak; // identical metrics
|
||||
if (pos == 0) {
|
||||
(*i).s->set_tick_bar(1);
|
||||
}
|
||||
|
||||
if ((*i).visible && nmt != lmt && pos == 0) {
|
||||
lmt = nmt;
|
||||
metrics_left.set_metric_mode(1, lmt);
|
||||
} else if ((*i).visible && nmt != lmt) {
|
||||
|
||||
if (last) {
|
||||
last->set_tick_bar(last->get_tick_bar() | 2);
|
||||
}
|
||||
(*i).s->set_tick_bar((*i).s->get_tick_bar() | 1);
|
||||
|
||||
if (_metrics.size() <= metrics) {
|
||||
_metrics.push_back(new MeterStrip(have_midi ? 2 : 3, lmt));
|
||||
meterarea.pack_start (*_metrics[metrics], false, false);
|
||||
@ -690,6 +701,13 @@ Meterbridge::sync_order_keys (RouteSortOrderKey src)
|
||||
}
|
||||
|
||||
meterarea.reorder_child(*((*i).s), pos++);
|
||||
if ((*i).visible) {
|
||||
last = (*i).s;
|
||||
}
|
||||
}
|
||||
|
||||
if (last) {
|
||||
last->set_tick_bar(last->get_tick_bar() | 2);
|
||||
}
|
||||
|
||||
metrics_right.set_metric_mode(have_midi ? 2 : 3, lmt);
|
||||
|
Loading…
Reference in New Issue
Block a user