e576003b579a7992910b4fb4d6bd0df1cc6db5fc
[ardour.git] / libs / canvas / pixbuf.cc
1 #include <cairomm/cairomm.h>
2 #include <gdkmm/general.h>
3
4 #include "pbd/xml++.h"
5
6 #include "canvas/pixbuf.h"
7
8 using namespace std;
9 using namespace ArdourCanvas;
10
11 Pixbuf::Pixbuf (Group* g)
12         : Item (g)
13 {
14         
15 }
16
17 void
18 Pixbuf::render (Rect const & /*area*/, Cairo::RefPtr<Cairo::Context> context) const
19 {
20         Gdk::Cairo::set_source_pixbuf (context, _pixbuf, 0, 0);
21         context->paint ();
22 }
23         
24 void
25 Pixbuf::compute_bounding_box () const
26 {
27         if (_pixbuf) {
28                 _bounding_box = boost::optional<Rect> (Rect (0, 0, _pixbuf->get_width(), _pixbuf->get_height()));
29         } else {
30                 _bounding_box = boost::optional<Rect> ();
31         }
32
33         _bounding_box_dirty = false;
34 }
35
36 void
37 Pixbuf::set (Glib::RefPtr<Gdk::Pixbuf> pixbuf)
38 {
39         begin_change ();
40         
41         _pixbuf = pixbuf;
42         _bounding_box_dirty = true;
43
44         end_change ();
45 }
46
47 XMLNode *
48 Pixbuf::get_state () const
49 {
50         /* XXX */
51         return new XMLNode ("Pixbuf");
52 }
53
54 void
55 Pixbuf::set_state (XMLNode const * /*node*/)
56 {
57         /* XXX */
58 }