diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2013-04-04 18:45:27 -0400 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2013-04-04 18:45:27 -0400 |
commit | 19bd6419157119b976393a0c5966b4be4c962119 (patch) | |
tree | bf27f7ea6402f39a0f3744ed6b298d91ed7f7c0e /libs/canvas | |
parent | aaea166135ace01709f7e0be64f40be80f4107ec (diff) |
commit immediately post linking
Diffstat (limited to 'libs/canvas')
-rw-r--r-- | libs/canvas/canvas/item.h | 10 | ||||
-rw-r--r-- | libs/canvas/canvas/text.h | 8 | ||||
-rw-r--r-- | libs/canvas/canvas/types.h | 3 | ||||
-rw-r--r-- | libs/canvas/canvas/wave_view.h | 9 | ||||
-rw-r--r-- | libs/canvas/group.cc | 1 | ||||
-rw-r--r-- | libs/canvas/item.cc | 14 | ||||
-rw-r--r-- | libs/canvas/text.cc | 9 | ||||
-rw-r--r-- | libs/canvas/types.cc | 6 |
8 files changed, 49 insertions, 11 deletions
diff --git a/libs/canvas/canvas/item.h b/libs/canvas/canvas/item.h index bd16fff67d..7898fb2bc8 100644 --- a/libs/canvas/canvas/item.h +++ b/libs/canvas/canvas/item.h @@ -79,7 +79,9 @@ public: } boost::optional<Rect> bounding_box () const; - + Coord height() const; + Coord width() const; + Duple item_to_parent (Duple const &) const; Rect item_to_parent (Rect const &) const; Duple parent_to_item (Duple const &) const; @@ -118,7 +120,9 @@ public: void set_data (std::string const &, void *); void* get_data (std::string const &) const; - /* XXX: maybe this should be a PBD::Signal */ + /* This is a sigc++ signal because it is solely + concerned with GUI stuff and is thus single-threaded + */ template <class T> struct EventAccumulator { @@ -135,7 +139,7 @@ public: } }; - sigc::signal<bool, GdkEvent*>::accumulated<EventAccumulator<bool> > Event; + sigc::signal1<bool, GdkEvent*, EventAccumulator<bool> > Event; #ifdef CANVAS_DEBUG std::string name; diff --git a/libs/canvas/canvas/text.h b/libs/canvas/canvas/text.h index ccc8d04dd5..08e2a469a7 100644 --- a/libs/canvas/canvas/text.h +++ b/libs/canvas/canvas/text.h @@ -1,3 +1,6 @@ +#ifndef __ardour_canvas_text_h__ +#define __ardour_canvas_text_h__ + #include <pangomm/fontdescription.h> #include <pangomm/layout.h> @@ -9,6 +12,7 @@ class Text : public Item { public: Text (Group *); + ~Text(); void render (Rect const &, Cairo::RefPtr<Cairo::Context>) const; void compute_bounding_box () const; @@ -17,7 +21,7 @@ public: void set (std::string const &); void set_color (uint32_t); - void set_font_description (Pango::FontDescription *); + void set_font_description (Pango::FontDescription); void set_alignment (Pango::Alignment); private: @@ -30,3 +34,5 @@ private: }; } + +#endif /* __ardour_canvas_text_h__ */ diff --git a/libs/canvas/canvas/types.h b/libs/canvas/canvas/types.h index 20b0799ea6..2cace4868b 100644 --- a/libs/canvas/canvas/types.h +++ b/libs/canvas/canvas/types.h @@ -12,11 +12,10 @@ namespace ArdourCanvas typedef double Coord; typedef double Distance; typedef uint32_t Color; + extern Coord const COORD_MAX; extern Coord const CAIRO_MAX; -extern Coord safe_add (Coord, Coord); - struct Duple { Duple () diff --git a/libs/canvas/canvas/wave_view.h b/libs/canvas/canvas/wave_view.h index 8ef0ce9868..b8c96cb672 100644 --- a/libs/canvas/canvas/wave_view.h +++ b/libs/canvas/canvas/wave_view.h @@ -1,6 +1,11 @@ #include <boost/shared_ptr.hpp> + #include "pbd/properties.h" + #include "ardour/types.h" + +#include <glibmm/refptr.h> + #include "canvas/item.h" #include "canvas/fill.h" #include "canvas/outline.h" @@ -9,6 +14,10 @@ namespace ARDOUR { class AudioRegion; } +namespace Gdk { + class Pixbuf; +} + class WaveViewTest; namespace ArdourCanvas { diff --git a/libs/canvas/group.cc b/libs/canvas/group.cc index c6af74229b..adb4b206a8 100644 --- a/libs/canvas/group.cc +++ b/libs/canvas/group.cc @@ -192,6 +192,7 @@ void Group::add_items_at_point (Duple const point, vector<Item const *>& items) const { boost::optional<Rect> const bbox = bounding_box (); + if (!bbox || !bbox.get().contains (point)) { return; } diff --git a/libs/canvas/item.cc b/libs/canvas/item.cc index ef207c448f..570eff9f14 100644 --- a/libs/canvas/item.cc +++ b/libs/canvas/item.cc @@ -192,6 +192,20 @@ Item::bounding_box () const return _bounding_box; } +Coord +Item::height () const +{ + boost::optional<Rect> bb = bounding_box().get(); + return bb->height (); +} + +Coord +Item::width () const +{ + boost::optional<Rect> bb = bounding_box().get(); + return bb->width (); +} + /* XXX may be called even if bbox is not changing ... bit grotty */ void Item::begin_change () diff --git a/libs/canvas/text.cc b/libs/canvas/text.cc index 541a5f7fc0..feb88e1996 100644 --- a/libs/canvas/text.cc +++ b/libs/canvas/text.cc @@ -16,6 +16,11 @@ Text::Text (Group* parent) } +Text::~Text () +{ + delete _font_description; +} + void Text::set (string const & text) { @@ -97,11 +102,11 @@ Text::set_alignment (Pango::Alignment alignment) } void -Text::set_font_description (Pango::FontDescription* font_description) +Text::set_font_description (Pango::FontDescription font_description) { begin_change (); - _font_description = font_description; + _font_description = new Pango::FontDescription (font_description); _bounding_box_dirty = true; end_change (); diff --git a/libs/canvas/types.cc b/libs/canvas/types.cc index 02ab77e000..56312741cf 100644 --- a/libs/canvas/types.cc +++ b/libs/canvas/types.cc @@ -10,10 +10,10 @@ Coord const ArdourCanvas::COORD_MAX = DBL_MAX; /* XXX: empirically arrived at */ Coord const ArdourCanvas::CAIRO_MAX = 65536; -Coord -ArdourCanvas::safe_add (Coord a, Coord b) +static inline Coord +safe_add (Coord a, Coord b) { - if (a == COORD_MAX || b == COORD_MAX) { + if (((COORD_MAX - a) > b) || ((COORD_MAX - b) > a)) { return COORD_MAX; } |