diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2011-12-07 13:57:45 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2011-12-07 13:57:45 +0000 |
commit | 20aeb5af0abd50dc01db503d65897c7dfebf6467 (patch) | |
tree | 41ff627d236157a4de7fdf8d1ebc97e55fe1b433 /gtk2_ardour | |
parent | bb737997aea86f08ec16e6444f3666ff6a524be2 (diff) |
move CairoWidget into gtkmm2ext, add CairoPacker, made the time info box use CairoPacker, make the info status "bar" use CairoPacker
git-svn-id: svn://localhost/ardour2/branches/3.0@10933 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour')
-rw-r--r-- | gtk2_ardour/ardour_button.h | 3 | ||||
-rw-r--r-- | gtk2_ardour/ardour_ui.h | 6 | ||||
-rw-r--r-- | gtk2_ardour/ardour_ui_ed.cc | 45 | ||||
-rw-r--r-- | gtk2_ardour/audio_clock.h | 2 | ||||
-rw-r--r-- | gtk2_ardour/cairo_widget.cc | 178 | ||||
-rw-r--r-- | gtk2_ardour/cairo_widget.h | 81 | ||||
-rw-r--r-- | gtk2_ardour/editor_summary.h | 2 | ||||
-rw-r--r-- | gtk2_ardour/group_tabs.h | 2 | ||||
-rw-r--r-- | gtk2_ardour/led.h | 2 | ||||
-rw-r--r-- | gtk2_ardour/time_info_box.cc | 36 | ||||
-rw-r--r-- | gtk2_ardour/time_info_box.h | 7 | ||||
-rw-r--r-- | gtk2_ardour/wscript | 1 |
12 files changed, 23 insertions, 342 deletions
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/cairo_widget.cc b/gtk2_ardour/cairo_widget.cc deleted file mode 100644 index 6abc758035..0000000000 --- a/gtk2_ardour/cairo_widget.cc +++ /dev/null @@ -1,178 +0,0 @@ -/* - Copyright (C) 2009 Paul Davis - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -*/ - -#include "cairo_widget.h" -#include "gui_thread.h" - -static const char* has_cairo_widget_background_info = "has_cairo_widget_background_info"; - -CairoWidget::CairoWidget () - : _active_state (Gtkmm2ext::ActiveState (0)) - , _visual_state (Gtkmm2ext::VisualState (0)) - , _need_bg (true) -{ - -} - -CairoWidget::~CairoWidget () -{ -} - -bool -CairoWidget::on_expose_event (GdkEventExpose *ev) -{ - 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); - - /* paint expose area the color of the parent window bg - */ - - Gdk::Color bg (get_parent_bg()); - - cairo_rectangle (cr, ev->area.x, ev->area.y, ev->area.width, ev->area.height); - cairo_set_source_rgb (cr, bg.get_red_p(), bg.get_green_p(), bg.get_blue_p()); - cairo_fill (cr); - - render (cr); - - cairo_destroy (cr); - - return true; -} - -/** Marks the widget as dirty, so that render () will be called on - * the next GTK expose event. - */ - -void -CairoWidget::set_dirty () -{ - ENSURE_GUI_THREAD (*this, &CairoWidget::set_dirty); - queue_draw (); -} - -/** Handle a size allocation. - * @param alloc GTK allocation. - */ -void -CairoWidget::on_size_allocate (Gtk::Allocation& alloc) -{ - Gtk::EventBox::on_size_allocate (alloc); - - set_dirty (); -} - -Gdk::Color -CairoWidget::get_parent_bg () -{ - Widget* parent; - - parent = get_parent (); - - while (parent) { - void* p = g_object_get_data (G_OBJECT(parent->gobj()), has_cairo_widget_background_info); - - if (p) { - Glib::RefPtr<Gtk::Style> style = parent->get_style(); - return style->get_bg (get_state()); - } - - if (!parent->get_has_window()) { - parent = parent->get_parent(); - } else { - break; - } - } - - if (parent && parent->get_has_window()) { - return parent->get_style ()->get_bg (parent->get_state()); - } - - return get_style ()->get_bg (get_state()); -} - -void -CairoWidget::set_active_state (Gtkmm2ext::ActiveState s) -{ - if (_active_state != s) { - _active_state = s; - StateChanged (); - } -} - -void -CairoWidget::set_visual_state (Gtkmm2ext::VisualState s) -{ - if (_visual_state != s) { - _visual_state = s; - StateChanged (); - } -} - -void -CairoWidget::set_active (bool yn) -{ - /* this is an API simplification for buttons - that only use the Active and Normal states. - */ - - if (yn) { - set_active_state (Gtkmm2ext::Active); - } else { - unset_active_state (); - } -} - -void -CairoWidget::on_state_changed (Gtk::StateType) -{ - /* this will catch GTK-level state changes from calls like - ::set_sensitive() - */ - - if (get_state() == Gtk::STATE_INSENSITIVE) { - set_visual_state (Gtkmm2ext::VisualState (visual_state() | Gtkmm2ext::Insensitive)); - } else { - set_visual_state (Gtkmm2ext::VisualState (visual_state() & ~Gtkmm2ext::Insensitive)); - } - - queue_draw (); -} - -void -CairoWidget::set_draw_background (bool yn) -{ - _need_bg = yn; -} - -void -CairoWidget::provide_background_for_cairo_widget (Gtk::Widget& w, const Gdk::Color& bg) -{ - /* set up @w to be able to provide bg information to - any CairoWidgets that are packed inside it. - */ - - w.modify_bg (Gtk::STATE_NORMAL, bg); - w.modify_bg (Gtk::STATE_INSENSITIVE, bg); - w.modify_bg (Gtk::STATE_ACTIVE, bg); - w.modify_bg (Gtk::STATE_SELECTED, bg); - - g_object_set_data (G_OBJECT(w.gobj()), has_cairo_widget_background_info, (void*) 0xfeedface); -} diff --git a/gtk2_ardour/cairo_widget.h b/gtk2_ardour/cairo_widget.h deleted file mode 100644 index e3ef7bafad..0000000000 --- a/gtk2_ardour/cairo_widget.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - Copyright (C) 2009 Paul Davis - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - -*/ - -#ifndef __gtk2_ardour_cairo_widget_h__ -#define __gtk2_ardour_cairo_widget_h__ - -#include <gtkmm/eventbox.h> -#include "gtkmm2ext/widget_state.h" - -/** A parent class for widgets that are rendered using Cairo. - */ - -class CairoWidget : public Gtk::EventBox -{ -public: - CairoWidget (); - virtual ~CairoWidget (); - - void set_dirty (); - - Gtkmm2ext::ActiveState active_state() const { return _active_state; } - Gtkmm2ext::VisualState visual_state() const { return _visual_state; } - - /* derived widgets can override these two to catch - changes in active & visual state - */ - - virtual void set_active_state (Gtkmm2ext::ActiveState); - virtual void set_visual_state (Gtkmm2ext::VisualState); - - void unset_active_state () { set_active_state (Gtkmm2ext::ActiveState (0)); } - void unset_visual_state () { set_visual_state (Gtkmm2ext::VisualState (0)); } - - /* this is an API simplification for widgets - that only use the Active and Normal active states. - */ - void set_active (bool); - bool get_active () { return active_state() != Gtkmm2ext::ActiveState (0); } - - /* widgets can be told to only draw their "foreground, and thus leave - in place whatever background is drawn by their parent. the default - is that the widget will fill its event window with the background - color of the parent container. - */ - - void set_draw_background (bool yn); - - sigc::signal<void> StateChanged; - - static void provide_background_for_cairo_widget (Gtk::Widget& w, const Gdk::Color& bg); - -protected: - /** Render the widget to the given Cairo context */ - virtual void render (cairo_t *) = 0; - virtual bool on_expose_event (GdkEventExpose *); - void on_size_allocate (Gtk::Allocation &); - void on_state_changed (Gtk::StateType); - Gdk::Color get_parent_bg (); - - Gtkmm2ext::ActiveState _active_state; - Gtkmm2ext::VisualState _visual_state; - bool _need_bg; -}; - -#endif 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 <gtkmm/menu.h> #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 <stdint.h> -#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<Gdk::Window> win = Gtkmm2ext::window_to_draw_on (*this, &window_parent); - - if (win) { - - Cairo::RefPtr<Cairo::Context> 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 <gtkmm/label.h> #include <gtkmm/table.h> +#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', |