[Summary] Progressing embedded meterbridge

This commit is contained in:
VKamyshniy 2014-07-20 18:02:36 +03:00
parent a5caa2778b
commit dd51b638bc
9 changed files with 89 additions and 122 deletions

View file

@ -17,6 +17,7 @@
*/
#include "ardour/meter.h"
#include "ardour/track.h"
#include "ardour_ui.h"
#include "gui_thread.h"
#include "meter_patterns.h"
@ -38,24 +39,42 @@ CompactMeterStrip::CompactMeterStrip (Session* sess, boost::shared_ptr<ARDOUR::R
: EventBox()
, WavesUI ("compact_meter_strip.xml", *this)
, _route(rt)
, level_meter_home (get_box ("level_meter_home"))
, level_meter (sess)
, _level_meter_home (get_box ("level_meter_home"))
, _level_meter (sess)
, _record_indicator (get_event_box ("record_indicator"))
{
set_attributes (*this, *xml_tree ()->root (), XMLNodeMap ());
const XMLNode& definition = *xml_tree ()->root ();
XMLNodeMap nothing;
set_attributes (*this, *xml_tree ()->root (), nothing);
level_meter.set_meter (_route->shared_peak_meter().get());
level_meter.clear_meters();
level_meter.set_type (_route->meter_type());
level_meter.setup_meters (__meter_width, __meter_width);
level_meter_home.add (level_meter);
_level_meter.set_meter (_route->shared_peak_meter().get());
_level_meter.clear_meters();
_level_meter.set_type (_route->meter_type());
_level_meter.setup_meters (__meter_width, __meter_width);
_level_meter_home.add (_level_meter);
_route->shared_peak_meter()->ConfigurationChanged.connect (
route_connections, invalidator (*this), boost::bind (&CompactMeterStrip::meter_configuration_changed, this, _1), gui_context()
);
_route->shared_peak_meter()->ConfigurationChanged.connect (_route_connections,
invalidator (*this),
boost::bind (&CompactMeterStrip::meter_configuration_changed,
this,
_1),
gui_context());
meter_configuration_changed (_route->shared_peak_meter()->input_streams ());
_route->DropReferences.connect (route_connections, invalidator (*this), boost::bind (&CompactMeterStrip::self_delete, this), gui_context());
_route->DropReferences.connect (_route_connections,
invalidator (*this),
boost::bind (&CompactMeterStrip::self_delete,
this),
gui_context());
boost::shared_ptr<Track> t = boost::dynamic_pointer_cast<Track> (_route);
if (t) {
t->RecordEnableChanged.connect (_route_connections,
invalidator (*this),
boost::bind (&CompactMeterStrip::update_rec_display,
this), gui_context());
update_rec_display ();
}
}
CompactMeterStrip::~CompactMeterStrip ()
@ -72,17 +91,18 @@ CompactMeterStrip::self_delete ()
void
CompactMeterStrip::update_rec_display ()
{
_record_indicator.set_state ((_route && _route->record_enabled ()) ? Gtk::STATE_ACTIVE : Gtk::STATE_NORMAL);
}
void
CompactMeterStrip::fast_update ()
{
level_meter.update_meters();
_level_meter.update_meters();
}
void
CompactMeterStrip::meter_configuration_changed (ChanCount c)
{
level_meter.setup_meters (__meter_width, __meter_width);
_level_meter.setup_meters (__meter_width, __meter_width);
}

View file

@ -43,9 +43,10 @@ class CompactMeterStrip :public Gtk::EventBox, public WavesUI
void self_delete ();
private:
Gtk::Box& level_meter_home;
LevelMeterHBox level_meter;
PBD::ScopedConnectionList route_connections;
Gtk::Box& _level_meter_home;
LevelMeterHBox _level_meter;
Gtk::EventBox& _record_indicator;
PBD::ScopedConnectionList _route_connections;
static int __meter_width;
void meter_configuration_changed (ARDOUR::ChanCount);
void update_rec_display ();

View file

@ -646,12 +646,10 @@ Editor::Editor ()
Glib::PropertyProxy<int> proxy = edit_pane.property_position();
proxy.signal_changed().connect (bind (sigc::ptr_fun (pane_size_watcher), static_cast<Paned*> (&edit_pane)));
top_hbox.pack_start (toolbar_frame);
HBox *hbox = manage (new HBox);
hbox->pack_start (edit_pane, true, true);
global_vpacker.pack_start (top_hbox, false, false);
global_vpacker.pack_start (*hbox, true, true);
set_name ("EditorWindow");
@ -3003,15 +3001,6 @@ Editor::setup_toolbar ()
_mouse_mode_tearoff->set_can_be_torn_off (false);
}
_mouse_mode_tearoff->Detach.connect (sigc::bind (sigc::mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&toolbar_hbox),
&_mouse_mode_tearoff->tearoff_window()));
_mouse_mode_tearoff->Attach.connect (sigc::bind (sigc::mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&toolbar_hbox),
&_mouse_mode_tearoff->tearoff_window(), 1));
_mouse_mode_tearoff->Hidden.connect (sigc::bind (sigc::mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&toolbar_hbox),
&_mouse_mode_tearoff->tearoff_window()));
_mouse_mode_tearoff->Visible.connect (sigc::bind (sigc::mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&toolbar_hbox),
&_mouse_mode_tearoff->tearoff_window(), 1));
/* Zoom */
_zoom_box.set_spacing (2);
@ -3085,14 +3074,6 @@ Editor::setup_toolbar ()
if (!ARDOUR::Profile->get_trx()) {
_zoom_tearoff = manage (new TearOff (_zoom_box));
_zoom_tearoff->Detach.connect (sigc::bind (sigc::mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&toolbar_hbox),
&_zoom_tearoff->tearoff_window()));
_zoom_tearoff->Attach.connect (sigc::bind (sigc::mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&toolbar_hbox),
&_zoom_tearoff->tearoff_window(), 0));
_zoom_tearoff->Hidden.connect (sigc::bind (sigc::mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&toolbar_hbox),
&_zoom_tearoff->tearoff_window()));
_zoom_tearoff->Visible.connect (sigc::bind (sigc::mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&toolbar_hbox),
&_zoom_tearoff->tearoff_window(), 0));
}
snap_box.set_spacing (2);
@ -3144,15 +3125,6 @@ Editor::setup_toolbar ()
_tools_tearoff->set_can_be_torn_off (false);
}
_tools_tearoff->Detach.connect (sigc::bind (sigc::mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&toolbar_hbox),
&_tools_tearoff->tearoff_window()));
_tools_tearoff->Attach.connect (sigc::bind (sigc::mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&toolbar_hbox),
&_tools_tearoff->tearoff_window(), 0));
_tools_tearoff->Hidden.connect (sigc::bind (sigc::mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&toolbar_hbox),
&_tools_tearoff->tearoff_window()));
_tools_tearoff->Visible.connect (sigc::bind (sigc::mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&toolbar_hbox),
&_tools_tearoff->tearoff_window(), 0));
toolbar_hbox.set_spacing (10);
toolbar_hbox.set_border_width (1);
@ -3929,24 +3901,6 @@ Editor::pane_allocation_handler (Allocation &alloc, Paned* which)
}
}
void
Editor::detach_tearoff (Box* /*b*/, Window* /*w*/)
{
if ((_tools_tearoff->torn_off() || !_tools_tearoff->visible()) &&
(_mouse_mode_tearoff->torn_off() || !_mouse_mode_tearoff->visible()) &&
(_zoom_tearoff && (_zoom_tearoff->torn_off() || !_zoom_tearoff->visible()))) {
top_hbox.remove (toolbar_frame);
}
}
void
Editor::reattach_tearoff (Box* /*b*/, Window* /*w*/, int32_t /*n*/)
{
if (toolbar_frame.get_parent() == 0) {
top_hbox.pack_end (toolbar_frame);
}
}
void
Editor::set_show_measures (bool yn)
{

View file

@ -959,7 +959,6 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
std::vector<ARDOUR::framepos_t> region_boundary_cache;
void build_region_boundary_cache ();
Gtk::HBox top_hbox;
Gtk::HBox bottom_hbox;
Gtk::Table edit_packer;
@ -1912,8 +1911,6 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
void cms_new (boost::shared_ptr<ARDOUR::Route>);
void current_mixer_strip_hidden ();
void detach_tearoff (Gtk::Box* b, Gtk::Window* w);
void reattach_tearoff (Gtk::Box* b, Gtk::Window* w, int32_t n);
#ifdef GTKOSX
void ensure_all_elements_drawn ();
#endif

View file

@ -6,7 +6,7 @@
<icon source="meter_bridge_level_scale.png"/>
</VBox>
<VBox>
<Hbox height="13"/>
<Hbox height="10"/>
<Hbox id="compact_meter_strips_home" spacing="2"/>
</VBox>
</HBox>

View file

@ -1,7 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<CompactMeterStrip>
<VBox>
<Hbox id="level_meter_home" height="51"/>
<CompactMeterStrip bgnormal="#353535">
<VBox spacing="6">
<Hbox id="level_meter_home"
height="51"/>
<EventBox id="record_indicator"
bgnormal="#000000"
bgactive="#FF0000"
height="2"/>
</VBox>
</CompactMeterStrip>

View file

@ -504,7 +504,7 @@ FastMeter::vertical_size_allocate (Gtk::Allocation &alloc)
pixwidth = request_width;
}
DrawingArea::on_size_allocate (alloc);
CairoWidget::on_size_allocate (alloc);
}
void
@ -529,31 +529,28 @@ FastMeter::horizontal_size_allocate (Gtk::Allocation &alloc)
pixheight = request_height;
}
DrawingArea::on_size_allocate (alloc);
CairoWidget::on_size_allocate (alloc);
}
bool
FastMeter::on_expose_event (GdkEventExpose* ev)
void
FastMeter::render (cairo_t* cr)
{
if (orientation == Vertical) {
return vertical_expose (ev);
vertical_render (cr);
} else {
return horizontal_expose (ev);
horizontal_render (cr);
}
}
bool
FastMeter::vertical_expose (GdkEventExpose* ev)
void
FastMeter::vertical_render (cairo_t* cr)
{
Glib::RefPtr<Gdk::Window> win = get_window ();
gint top_of_meter;
GdkRectangle intersection;
GdkRectangle background;
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_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
//rounded_rectangle (cr, 0, 0, pixwidth + 2, pixheight + 2, 2);
@ -572,19 +569,22 @@ FastMeter::vertical_expose (GdkEventExpose* ev)
background.width = pixrect.width;
background.height = pixheight - top_of_meter;
if (gdk_rectangle_intersect (&background, &ev->area, &intersection)) {
cairo_set_source (cr, bgpattern->cobj());
cairo_rectangle (cr, intersection.x, intersection.y, intersection.width, intersection.height);
cairo_fill (cr);
}
// Switching to CAIRO we would like to draw on the container's bkg.
//if (gdk_rectangle_intersect (&background, &ev->area, &intersection)) {
// cairo_set_source (cr, bgpattern->cobj());
// cairo_rectangle (cr, intersection.x, intersection.y, intersection.width, intersection.height);
// cairo_fill (cr);
//}
if (gdk_rectangle_intersect (&pixrect, &ev->area, &intersection)) {
// MEMO: Normaly MATURE OS clips so called invalidated rects itself making APP free of
// heavy operations which OS does with graphic HW
//if (gdk_rectangle_intersect (&pixrect, &ev->area, &intersection)) {
// 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_rgba (cr, 0.69, 0.69, 0.69, 1);
cairo_rectangle (cr, intersection.x, intersection.y, intersection.width, intersection.height);
cairo_rectangle (cr, pixrect.x, pixrect.y, pixrect.width, pixrect.height);
cairo_fill (cr);
}
//}
// draw peak bar
@ -611,24 +611,17 @@ FastMeter::vertical_expose (GdkEventExpose* ev)
last_peak_rect.width = 0;
last_peak_rect.height = 0;
}
cairo_destroy (cr);
return TRUE;
}
bool
FastMeter::horizontal_expose (GdkEventExpose* ev)
void
FastMeter::horizontal_render (cairo_t* cr)
{
Glib::RefPtr<Gdk::Window> win = get_window ();
gint right_of_meter;
GdkRectangle intersection;
GdkRectangle background;
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_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
//rounded_rectangle (cr, 0, 0, pixwidth + 2, pixheight + 2, 2);
@ -646,17 +639,17 @@ FastMeter::horizontal_expose (GdkEventExpose* ev)
background.width = pixwidth - right_of_meter;
background.height = pixheight;
if (gdk_rectangle_intersect (&background, &ev->area, &intersection)) {
cairo_set_source (cr, bgpattern->cobj());
cairo_rectangle (cr, intersection.x, intersection.y, intersection.width, intersection.height);
cairo_fill (cr);
}
//if (gdk_rectangle_intersect (&background, &ev->area, &intersection)) {
// cairo_set_source (cr, bgpattern->cobj());
// cairo_rectangle (cr, intersection.x, intersection.y, intersection.width, intersection.height);
// cairo_fill (cr);
//}
if (gdk_rectangle_intersect (&pixrect, &ev->area, &intersection)) {
cairo_set_source (cr, fgpattern->cobj());
cairo_rectangle (cr, intersection.x, intersection.y, intersection.width, intersection.height);
cairo_fill (cr);
}
//if (gdk_rectangle_intersect (&pixrect, &ev->area, &intersection)) {
// cairo_set_source (cr, fgpattern->cobj());
// cairo_rectangle (cr, intersection.x, intersection.y, intersection.width, intersection.height);
// cairo_fill (cr);
//}
// draw peak bar
@ -684,10 +677,6 @@ FastMeter::horizontal_expose (GdkEventExpose* ev)
last_peak_rect.width = 0;
last_peak_rect.height = 0;
}
cairo_destroy (cr);
return TRUE;
}
void

View file

@ -24,14 +24,14 @@
#include <boost/tuple/tuple.hpp>
#include <boost/tuple/tuple_comparison.hpp>
#include <cairomm/pattern.h>
#include <gtkmm/drawingarea.h>
#include <gdkmm/pixbuf.h>
#include "gtkmm2ext/cairo_widget.h"
#include "gtkmm2ext/visibility.h"
namespace Gtkmm2ext {
class LIBGTKMM2EXT_API FastMeter : public Gtk::DrawingArea {
class LIBGTKMM2EXT_API FastMeter : public CairoWidget {
public:
enum Orientation {
Horizontal,
@ -67,7 +67,8 @@ class LIBGTKMM2EXT_API FastMeter : public Gtk::DrawingArea {
bool get_highlight () { return highlight; }
protected:
bool on_expose_event (GdkEventExpose*);
//bool on_expose_event (GdkEventExpose*);
void render (cairo_t* cr);
void on_size_request (GtkRequisition*);
void on_size_allocate (Gtk::Allocation&);
private:
@ -96,12 +97,12 @@ private:
float current_user_level;
bool highlight;
bool vertical_expose (GdkEventExpose*);
void vertical_render (cairo_t* cr);
void vertical_size_request (GtkRequisition*);
void vertical_size_allocate (Gtk::Allocation&);
void queue_vertical_redraw (const Glib::RefPtr<Gdk::Window>&, float);
bool horizontal_expose (GdkEventExpose*);
void horizontal_render (cairo_t* cr);
void horizontal_size_request (GtkRequisition*);
void horizontal_size_allocate (Gtk::Allocation&);
void queue_horizontal_redraw (const Glib::RefPtr<Gdk::Window>&, float);