diff --git a/gtk2_ardour/ardour_button.h b/gtk2_ardour/ardour_button.h index a1ee715f9c..64bebdace1 100644 --- a/gtk2_ardour/ardour_button.h +++ b/gtk2_ardour/ardour_button.h @@ -28,8 +28,7 @@ #include "pbd/signals.h" #include "gtkmm2ext/binding_proxy.h" #include "gtkmm2ext/activatable.h" - -#include "cairo_widget.h" +#include "gtkmm2ext/cairo_widget.h" class ArdourButton : public CairoWidget , public Gtkmm2ext::Activatable { diff --git a/gtk2_ardour/ardour_ui.h b/gtk2_ardour/ardour_ui.h index 8262d76c0a..74eafbb064 100644 --- a/gtk2_ardour/ardour_ui.h +++ b/gtk2_ardour/ardour_ui.h @@ -509,27 +509,21 @@ class ARDOUR_UI : public Gtkmm2ext::UI, public ARDOUR::SessionHandlePtr void build_menu_bar (); Gtk::Label wall_clock_label; - Gtk::EventBox wall_clock_box; gint update_wall_clock (); Gtk::Label disk_space_label; - Gtk::EventBox disk_space_box; void update_disk_space (); Gtk::Label cpu_load_label; - Gtk::EventBox cpu_load_box; void update_cpu_load (); Gtk::Label buffer_load_label; - Gtk::EventBox buffer_load_box; void update_buffer_load (); Gtk::Label sample_rate_label; - Gtk::EventBox sample_rate_box; void update_sample_rate (ARDOUR::framecnt_t); Gtk::Label format_label; - Gtk::EventBox format_box; void update_format (); gint every_second (); diff --git a/gtk2_ardour/ardour_ui_ed.cc b/gtk2_ardour/ardour_ui_ed.cc index 430886950a..b46c50cfb3 100644 --- a/gtk2_ardour/ardour_ui_ed.cc +++ b/gtk2_ardour/ardour_ui_ed.cc @@ -35,6 +35,7 @@ #include "gtkmm2ext/utils.h" #include "gtkmm2ext/window_title.h" #include "gtkmm2ext/tearoff.h" +#include "gtkmm2ext/cairo_packer.h" #include "pbd/file_utils.h" #include "pbd/fpu.h" @@ -532,37 +533,21 @@ ARDOUR_UI::build_menu_bar () EventBox* ev = manage (new EventBox); ev->show (); - HBox* hbox = manage (new HBox); + CairoHPacker* hbox = manage (new CairoHPacker); hbox->show (); ev->add (*hbox); - wall_clock_box.add (wall_clock_label); - wall_clock_box.set_name ("WallClock"); wall_clock_label.set_name ("WallClock"); - - disk_space_box.add (disk_space_label); - disk_space_box.set_name ("WallClock"); + wall_clock_label.set_use_markup (); disk_space_label.set_name ("WallClock"); disk_space_label.set_use_markup (); - - cpu_load_box.add (cpu_load_label); - cpu_load_box.set_name ("CPULoad"); cpu_load_label.set_name ("CPULoad"); cpu_load_label.set_use_markup (); - - buffer_load_box.add (buffer_load_label); - buffer_load_box.set_name ("BufferLoad"); buffer_load_label.set_name ("BufferLoad"); buffer_load_label.set_use_markup (); - - sample_rate_box.add (sample_rate_label); - sample_rate_box.set_name ("SampleRate"); sample_rate_label.set_name ("SampleRate"); sample_rate_label.set_use_markup (); - - format_box.add (format_label); - format_box.set_name ("Format"); format_label.set_name ("Format"); format_label.set_use_markup (); @@ -583,24 +568,24 @@ ARDOUR_UI::build_menu_bar () disk_space = true; } - hbox->pack_end (wall_clock_box, false, false, 2); - hbox->pack_end (disk_space_box, false, false, 4); - hbox->pack_end (cpu_load_box, false, false, 4); - hbox->pack_end (buffer_load_box, false, false, 4); - hbox->pack_end (sample_rate_box, false, false, 4); - hbox->pack_end (format_box, false, false, 4); + hbox->pack_end (wall_clock_label, false, false, 2); + hbox->pack_end (disk_space_label, false, false, 4); + hbox->pack_end (cpu_load_label, false, false, 4); + hbox->pack_end (buffer_load_label, false, false, 4); + hbox->pack_end (sample_rate_label, false, false, 4); + hbox->pack_end (format_label, false, false, 4); menu_hbox.pack_end (*ev, false, false); menu_bar_base.set_name ("MainMenuBar"); menu_bar_base.add (menu_hbox); - _status_bar_visibility.add (&wall_clock_box, X_("WallClock"), _("Wall Clock"), wall_clock); - _status_bar_visibility.add (&disk_space_box, X_("Disk"), _("Disk Space"), disk_space); - _status_bar_visibility.add (&cpu_load_box, X_("DSP"), _("DSP"), true); - _status_bar_visibility.add (&buffer_load_box, X_("Buffers"), _("Buffers"), true); - _status_bar_visibility.add (&sample_rate_box, X_("JACK"), _("JACK Sampling Rate and Latency"), true); - _status_bar_visibility.add (&format_box, X_("Format"), _("File Format"), true); + _status_bar_visibility.add (&wall_clock_label, X_("WallClock"), _("Wall Clock"), wall_clock); + _status_bar_visibility.add (&disk_space_label, X_("Disk"), _("Disk Space"), disk_space); + _status_bar_visibility.add (&cpu_load_label, X_("DSP"), _("DSP"), true); + _status_bar_visibility.add (&buffer_load_label, X_("Buffers"), _("Buffers"), true); + _status_bar_visibility.add (&sample_rate_label, X_("JACK"), _("JACK Sampling Rate and Latency"), true); + _status_bar_visibility.add (&format_label, X_("Format"), _("File Format"), true); ev->signal_button_press_event().connect (sigc::mem_fun (_status_bar_visibility, &VisibilityGroup::button_press_event)); } diff --git a/gtk2_ardour/audio_clock.h b/gtk2_ardour/audio_clock.h index 8af3f49abe..33b486a8f1 100644 --- a/gtk2_ardour/audio_clock.h +++ b/gtk2_ardour/audio_clock.h @@ -33,7 +33,7 @@ #include "ardour/ardour.h" #include "ardour/session_handle.h" -#include "cairo_widget.h" +#include "gtkmm2ext/cairo_widget.h" namespace ARDOUR { class Session; diff --git a/gtk2_ardour/editor_summary.h b/gtk2_ardour/editor_summary.h index 4da49d6e11..6746849fe3 100644 --- a/gtk2_ardour/editor_summary.h +++ b/gtk2_ardour/editor_summary.h @@ -20,7 +20,7 @@ #ifndef __gtk_ardour_editor_summary_h__ #define __gtk_ardour_editor_summary_h__ -#include "cairo_widget.h" +#include "gtkmm2ext/cairo_widget.h" #include "editor_component.h" namespace ARDOUR { diff --git a/gtk2_ardour/group_tabs.h b/gtk2_ardour/group_tabs.h index 059f3ce60b..d8c488c70f 100644 --- a/gtk2_ardour/group_tabs.h +++ b/gtk2_ardour/group_tabs.h @@ -19,7 +19,7 @@ #include #include "editor_component.h" -#include "cairo_widget.h" +#include "gtkmm2ext/cairo_widget.h" namespace ARDOUR { class Session; diff --git a/gtk2_ardour/led.h b/gtk2_ardour/led.h index edb08818b3..089c35b7a8 100644 --- a/gtk2_ardour/led.h +++ b/gtk2_ardour/led.h @@ -22,7 +22,7 @@ #include -#include "cairo_widget.h" +#include "gtkmm2ext/cairo_widget.h" class LED : public CairoWidget { diff --git a/gtk2_ardour/time_info_box.cc b/gtk2_ardour/time_info_box.cc index 7ee144015f..515d49f72b 100644 --- a/gtk2_ardour/time_info_box.cc +++ b/gtk2_ardour/time_info_box.cc @@ -143,14 +143,6 @@ TimeInfoBox::TimeInfoBox () Editor::instance().get_selection().RegionsChanged.connect (sigc::mem_fun (*this, &TimeInfoBox::selection_changed)); Editor::instance().MouseModeChanged.connect (editor_connections, invalidator(*this), ui_bind (&TimeInfoBox::track_mouse_mode, this), gui_context()); - - Gdk::Color bg; - - bg.set_red (lrint (0.149 * 65535)); - bg.set_green (lrint (0.149 * 65535)); - bg.set_blue (lrint (0.149 * 65535)); - - CairoWidget::provide_background_for_cairo_widget (*this, bg); } TimeInfoBox::~TimeInfoBox () @@ -343,31 +335,3 @@ TimeInfoBox::punch_changed (Location* loc) punch_end->set (loc->end()); } -bool -TimeInfoBox::on_expose_event (GdkEventExpose* ev) -{ - { - int x, y; - Gtk::Widget* window_parent; - Glib::RefPtr win = Gtkmm2ext::window_to_draw_on (*this, &window_parent); - - if (win) { - - Cairo::RefPtr context = win->create_cairo_context(); - -#if 0 - translate_coordinates (*window_parent, ev->area.x, ev->area.y, x, y); - context->rectangle (x, y, ev->area.width, ev->area.height); - context->clip (); -#endif - translate_coordinates (*window_parent, 0, 0, x, y); - context->set_source_rgba (0.149, 0.149, 0.149, 1.0); - Gtkmm2ext::rounded_rectangle (context, x, y, get_allocation().get_width(), get_allocation().get_height(), 9); - context->fill (); - } - } - - HBox::on_expose_event (ev); - - return false; -} diff --git a/gtk2_ardour/time_info_box.h b/gtk2_ardour/time_info_box.h index 035cdb7e00..ac4cc98ea5 100644 --- a/gtk2_ardour/time_info_box.h +++ b/gtk2_ardour/time_info_box.h @@ -26,6 +26,8 @@ #include #include +#include "gtkmm2ext/cairo_packer.h" + #include "ardour/ardour.h" #include "ardour/session_handle.h" @@ -38,7 +40,7 @@ namespace ARDOUR { class AudioClock; -class TimeInfoBox : public Gtk::HBox, public ARDOUR::SessionHandlePtr +class TimeInfoBox : public CairoHPacker, public ARDOUR::SessionHandlePtr { public: TimeInfoBox (); @@ -46,9 +48,6 @@ class TimeInfoBox : public Gtk::HBox, public ARDOUR::SessionHandlePtr void set_session (ARDOUR::Session*); - protected: - bool on_expose_event (GdkEventExpose*); - private: Gtk::Table left; Gtk::Table right; diff --git a/gtk2_ardour/wscript b/gtk2_ardour/wscript index 358f17854f..1cb0898840 100644 --- a/gtk2_ardour/wscript +++ b/gtk2_ardour/wscript @@ -54,7 +54,6 @@ gtk2_ardour_sources = [ 'automation_time_axis.cc', 'axis_view.cc', 'bundle_manager.cc', - 'cairo_widget.cc', 'canvas-flag.cc', 'canvas-hit.cc', 'canvas-note-event.cc', diff --git a/libs/gtkmm2ext/cairo_packer.cc b/libs/gtkmm2ext/cairo_packer.cc new file mode 100644 index 0000000000..70f51281dd --- /dev/null +++ b/libs/gtkmm2ext/cairo_packer.cc @@ -0,0 +1,56 @@ +#include "gtkmm2ext/utils.h" +#include "gtkmm2ext/cairo_widget.h" +#include "gtkmm2ext/cairo_packer.h" + +void +CairoPacker::draw_background (Gtk::Widget& w, GdkEventExpose* ev) +{ + int x, y; + Gtk::Widget* window_parent; + Glib::RefPtr win = Gtkmm2ext::window_to_draw_on (w, &window_parent); + + if (win) { + + Cairo::RefPtr context = win->create_cairo_context(); + w.translate_coordinates (*window_parent, 0, 0, x, y); + context->set_source_rgba (0.149, 0.149, 0.149, 1.0); + Gtkmm2ext::rounded_rectangle (context, x, y, w.get_allocation().get_width(), w.get_allocation().get_height(), 9); + context->fill (); + } +} + +CairoHPacker::CairoHPacker () +{ + Gdk::Color bg; + + bg.set_red (lrint (0.149 * 65535)); + bg.set_green (lrint (0.149 * 65535)); + bg.set_blue (lrint (0.149 * 65535)); + + CairoWidget::provide_background_for_cairo_widget (*this, bg); +} + +bool +CairoHPacker::on_expose_event (GdkEventExpose* ev) +{ + draw_background (*this, ev); + return HBox::on_expose_event (ev); +} + +CairoVPacker::CairoVPacker () +{ + Gdk::Color bg; + + bg.set_red (lrint (0.149 * 65535)); + bg.set_green (lrint (0.149 * 65535)); + bg.set_blue (lrint (0.149 * 65535)); + + CairoWidget::provide_background_for_cairo_widget (*this, bg); +} + +bool +CairoVPacker::on_expose_event (GdkEventExpose* ev) +{ + draw_background (*this, ev); + return VBox::on_expose_event (ev); +} diff --git a/gtk2_ardour/cairo_widget.cc b/libs/gtkmm2ext/cairo_widget.cc similarity index 98% rename from gtk2_ardour/cairo_widget.cc rename to libs/gtkmm2ext/cairo_widget.cc index 6abc758035..b6717252ab 100644 --- a/gtk2_ardour/cairo_widget.cc +++ b/libs/gtkmm2ext/cairo_widget.cc @@ -17,8 +17,8 @@ */ -#include "cairo_widget.h" -#include "gui_thread.h" +#include "gtkmm2ext/cairo_widget.h" +#include "gtkmm2ext/gui_thread.h" static const char* has_cairo_widget_background_info = "has_cairo_widget_background_info"; diff --git a/libs/gtkmm2ext/gtkmm2ext/cairo_packer.h b/libs/gtkmm2ext/gtkmm2ext/cairo_packer.h new file mode 100644 index 0000000000..f6d7753570 --- /dev/null +++ b/libs/gtkmm2ext/gtkmm2ext/cairo_packer.h @@ -0,0 +1,34 @@ +#ifndef __gtkmm2ext_cairo_packer_h__ +#define __gtkmm2ext_cairo_packer_h__ + +#include + +class CairoPacker +{ + public: + CairoPacker () {} + virtual ~CairoPacker () {} + + protected: + virtual void draw_background (Gtk::Widget&, GdkEventExpose*); +}; + +class CairoHPacker : public CairoPacker, public Gtk::HBox +{ + public: + CairoHPacker (); + ~CairoHPacker() {} + + bool on_expose_event (GdkEventExpose*); +}; + +class CairoVPacker : public CairoPacker, public Gtk::VBox +{ + public: + CairoVPacker (); + ~CairoVPacker () {} + + bool on_expose_event (GdkEventExpose*); +}; + +#endif /* __gtkmm2ext_cairo_packer_h__ */ diff --git a/gtk2_ardour/cairo_widget.h b/libs/gtkmm2ext/gtkmm2ext/cairo_widget.h similarity index 100% rename from gtk2_ardour/cairo_widget.h rename to libs/gtkmm2ext/gtkmm2ext/cairo_widget.h diff --git a/libs/gtkmm2ext/wscript b/libs/gtkmm2ext/wscript index ef2c623dca..1d386ce6ee 100644 --- a/libs/gtkmm2ext/wscript +++ b/libs/gtkmm2ext/wscript @@ -28,6 +28,8 @@ gtkmm2ext_sources = [ 'bindable_button.cc', 'bindings.cc', 'cairocell.cc', + 'cairo_packer.cc', + 'cairo_widget.cc', 'cell_renderer_color_selector.cc', 'cell_renderer_pixbuf_multi.cc', 'cell_renderer_pixbuf_toggle.cc',