[niepce] Remove goocanvas and use cairo directly for the ImageCanvas. Dependencies-=2



commit c4c4f51a76ec653461914ee7c6ed84268541f9ed
Author: Hubert Figuiere <hub figuiere net>
Date:   Thu May 14 23:44:08 2009 -0400

    Remove goocanvas and use cairo directly for the ImageCanvas. Dependencies-=2
---
 ChangeLog                                      |   16 +++
 README                                         |    5 +-
 configure.ac                                   |    3 -
 src/fwk/base/geometry.hpp                      |    3 +
 src/ncr/image.cpp                              |   80 ++++++++----
 src/ncr/image.hpp                              |   16 ++-
 src/niepce/Makefile.am                         |    3 +-
 src/niepce/modules/darkroom/Makefile.am        |    1 -
 src/niepce/modules/darkroom/darkroommodule.cpp |   54 +++-----
 src/niepce/modules/darkroom/imagecanvas.cpp    |  163 +++++++++++++++--------
 src/niepce/modules/darkroom/imagecanvas.hpp    |   35 +++--
 src/niepce/ui/Makefile.am                      |    1 -
 12 files changed, 239 insertions(+), 141 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index f48363c..1d022ca 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2009-05-14  Hubert Figuiere  <hub figuiere net>
+
+	* README:
+	* configure.ac:
+	* src/fwk/base/geometry.hpp:
+	* src/ncr/image.cpp:
+	* src/ncr/image.hpp:
+	* src/niepce/Makefile.am:
+	* src/niepce/modules/darkroom/Makefile.am:
+	* src/niepce/modules/darkroom/darkroommodule.cpp:
+	* src/niepce/modules/darkroom/imagecanvas.cpp:
+	* src/niepce/modules/darkroom/imagecanvas.hpp:
+	* src/niepce/ui/Makefile.am:
+	Remove goocanvas and use cairo directly for the
+	ImageCanvas. Dependencies-=2
+
 2009-05-10  Hubert Figuiere  <hub figuiere net>
 
 	* src/niepce/ui/workspacecontroller.cpp: 
diff --git a/README b/README
index e03ca6a..539157c 100644
--- a/README
+++ b/README
@@ -37,7 +37,6 @@ libopenraw >= 0.0.5
 geglmm >= 0.0.22
 gegl >= 0.0.22
 babl
-goocanvasmm 0.10.0
 
 Niepce is being developed on Linux. It should build and work on other
 UNIX systems.
@@ -47,13 +46,11 @@ Working on Debian
 ~~~~~~~~~~~~~~~~~
 In order to get Niepce working on Debian you should have to install:
 aptitude install gconf2-dev \
-> libexempi-dev libopenraw-dev libopenrawgnome-dev libgtkmm-2.4-dev \
-> libgoocanvas-dev
+> libexempi-dev libopenraw-dev libopenrawgnome-dev libgtkmm-2.4-dev 
 
 Debian (nor Ubuntu) do not still pack geglmm nor libgoocanvasmm-dev. In order
 to get them visit to get the latest version:
 http://ftp.gnome.org/pub/gnome/sources/geglmm/
-http://ftp.gnome.org/pub/gnome/sources/goocanvasmm/
 
 Working on SUSE
 ~~~~~~~~~~~~~~~
diff --git a/configure.ac b/configure.ac
index 13447ad..d0866cd 100644
--- a/configure.ac
+++ b/configure.ac
@@ -23,7 +23,6 @@ LIBGLIBMM_VERSION=2.4
 LIBGTKMM_VERSION=2.12.0
 LIBGCONF_VERSION=2.0.0
 LIBGNOMEUI_VERSION=2.0.0
-LIBGOOCANVASMM_VERSION=0.6.0
 EXEMPI_VERSION=2.0.0
 SQLITE_VERSION=3.0
 GEGL_VERSION=0.0.22
@@ -85,8 +84,6 @@ PKG_CHECK_MODULES(GEGLMM, geglmm >= $GEGLMM_VERSION)
 AC_SUBST(GEGLMM_CFLAGS)
 AC_SUBST(GEGLMM_LIBS)
 
-PKG_CHECK_MODULES(GOOCANVASMM, [goocanvasmm-1.0 >= $LIBGOOCANVASMM_VERSION])
-
 
 BOOST_REQUIRE([$BOOST_VERSION])
 BOOST_BIND
diff --git a/src/fwk/base/geometry.hpp b/src/fwk/base/geometry.hpp
index 7c444ad..f598a6f 100644
--- a/src/fwk/base/geometry.hpp
+++ b/src/fwk/base/geometry.hpp
@@ -21,9 +21,12 @@
 #ifndef __FWK_BASE_GEOMETRY_H__
 #define __FWK_BASE_GEOMETRY_H__
 
+#include <exception>
 #include <tr1/array>
 #include <string>
 
+#include <boost/lexical_cast.hpp>
+
 namespace fwk {
 
 class Rect
diff --git a/src/ncr/image.cpp b/src/ncr/image.cpp
index d009594..d04ac06 100644
--- a/src/ncr/image.cpp
+++ b/src/ncr/image.cpp
@@ -23,8 +23,6 @@ extern "C" {
 #include <babl/babl.h>
 }
 
-#include <boost/bind.hpp>
-
 #include <libopenraw/libopenraw.h>
 
 #include <geglmm/node.h>
@@ -43,7 +41,7 @@ struct Image::Private {
         {
         }
 
-    int m_width, m_height; /**< the native dimension */
+    int m_width, m_height; /**< the native dimension, with orientation */
     Glib::RefPtr<Gegl::Node> m_node;
     Glib::RefPtr<Gegl::Node> m_rgb;    /**< RGB pixmap */
     Glib::RefPtr<Gegl::Node> m_scale;
@@ -116,6 +114,7 @@ void Image::reload(const std::string & p, bool is_raw,
 
     DBG_OUT("rotation is %d", orientation);
     int degrees = 0;
+    bool vertical = false;
     bool flip = false;
     switch(orientation) {
     case 0:
@@ -135,12 +134,14 @@ void Image::reload(const std::string & p, bool is_raw,
         // fall through
     case 6:
         degrees = 270;
+        vertical = true;
         break;
     case 7:
         flip = true;
         // fall through
     case 8:
         degrees = 90;
+        vertical = true;
         break;
     }
     // @todo ideally we would have a plain GEGL op for that.
@@ -159,7 +160,6 @@ void Image::reload(const std::string & p, bool is_raw,
     current = current->link(rotate);
 
     priv->m_scale = priv->m_node->new_child("operation", "gegl:scale");
-    set_scale(0.25);
     current->link(priv->m_scale);
     priv->m_output = priv->m_scale;
     
@@ -169,8 +169,16 @@ void Image::reload(const std::string & p, bool is_raw,
     width = rect.gobj()->width;
     height = rect.gobj()->height;
     DBG_OUT("width %d height %d", width, height);
-    priv->m_width = width;
-    priv->m_height = height;
+    if(vertical) {
+        priv->m_width = height;
+        priv->m_height = width;
+    }
+    else {
+        priv->m_width = width;
+        priv->m_height = height;
+    }
+
+    signal_update();
 }
 
 void Image::set_scale(double scale)
@@ -178,38 +186,60 @@ void Image::set_scale(double scale)
     DBG_OUT("scale %f", scale);
     priv->m_scale->set("x", scale);
     priv->m_scale->set("y", scale);    
+
+    signal_update();
+}
+
+
+Cairo::RefPtr<Cairo::Surface> Image::cairo_surface_for_display()
+{
+    priv->m_output->process();
+    Gegl::Rectangle roi = priv->m_output->get_bounding_box();
+    int w, h;
+    w = roi.gobj()->width;
+    h = roi.gobj()->height;
+    // TODO not endian neutral
+    const Babl * format = babl_format_new(babl_model("R'G'B'A"),
+                                          babl_type ("u8"),
+                                          babl_component ("B'"),
+                                          babl_component ("G'"),
+                                          babl_component ("R'"),
+                                          babl_component ("A"),
+                                          NULL);
+    Cairo::RefPtr<Cairo::ImageSurface> surface 
+        = Cairo::ImageSurface::create(Cairo::FORMAT_ARGB32, w, h);
+    priv->m_output->blit(1.0, roi, format,
+                         (void*)surface->get_data(), surface->get_stride(),
+                         (Gegl::BlitFlags)(GEGL_BLIT_CACHE | GEGL_BLIT_DIRTY));
+    return surface;
 }
 
+int Image::get_original_width() const
+{
+    return priv->m_width;
+}
 
-namespace {
 
-/** callback to free the buffer */
-void _free_buf(const guint8* p) 
+int Image::get_original_height() const
 {
-    g_free(const_cast<guint8*>(p));
+    return priv->m_height;
 }
 
+
+int Image::get_output_width() const
+{
+    Gegl::Rectangle roi = priv->m_output->get_bounding_box();
+    return roi.gobj()->width;
 }
 
-Glib::RefPtr<Gdk::Pixbuf> Image::pixbuf_for_display()
+
+int Image::get_output_height() const
 {
-    priv->m_output->process();
     Gegl::Rectangle roi = priv->m_output->get_bounding_box();
-    int w, h;
-    w = roi.gobj()->width;
-    h = roi.gobj()->height;
-    guint8* buf = (guint8*)g_malloc (w * h * 3);
-    priv->m_output->blit(1.0, roi, babl_format ("R'G'B' u8"),
-                       (void*)buf, GEGL_AUTO_ROWSTRIDE,
-                       (Gegl::BlitFlags)(GEGL_BLIT_CACHE | GEGL_BLIT_DIRTY));
-    Glib::RefPtr<Gdk::Pixbuf> pix 
-        = Gdk::Pixbuf::create_from_data(buf,
-                                        Gdk::COLORSPACE_RGB,
-                                        false, 8, w, h,
-                                        w * 3, boost::bind(&_free_buf, _1));
-    return pix;
+    return roi.gobj()->height;
 }
 
+
 }
 
 /*
diff --git a/src/ncr/image.hpp b/src/ncr/image.hpp
index 1bad3e5..7cb2a90 100644
--- a/src/ncr/image.hpp
+++ b/src/ncr/image.hpp
@@ -38,7 +38,17 @@ public:
     Image();
     virtual ~Image();
 
-    Glib::RefPtr<Gdk::Pixbuf> pixbuf_for_display();
+    /* get a cairo surface to display the resulting image */
+    Cairo::RefPtr<Cairo::Surface> cairo_surface_for_display();
+
+    /* the dimensions of the original image */
+    int get_original_width() const;
+    int get_original_height() const;
+
+    /* the dimension of the output image, after scale */
+    int get_output_width() const;
+    int get_output_height() const;
+
     void reload(const std::string & p, bool is_raw,
         int orientation);
     void set_scale(double scale);
@@ -51,7 +61,9 @@ public:
     void set_saturation(int saturation);
     void set_vibrance(int vibrance);
 
-    sigc::signal<void, Image::Ptr> signal_update;
+    /** this signal is emitted each time the
+        image is changed. */
+    sigc::signal<void> signal_update;
 private:
     class Private;
     Private *priv;
diff --git a/src/niepce/Makefile.am b/src/niepce/Makefile.am
index ba31ade..ff3932a 100644
--- a/src/niepce/Makefile.am
+++ b/src/niepce/Makefile.am
@@ -27,8 +27,7 @@ niepce_LDADD = \
 	$(top_builddir)/src/ext/libview/libview.a \
 	@LIBGLIBMM_LIBS@ \
 	@LIBGTKMM_LIBS@ @SQLITE3_LIBS@ \
-	@GCONF_LIBS@ \
-	@GOOCANVASMM_LIBS@ @BABL_LIBS@ \
+	@GCONF_LIBS@ @BABL_LIBS@ \
 	@GEGLMM_LIBS@ @OPENRAW_LIBS@ @EXEMPI_LIBS@
 
 
diff --git a/src/niepce/modules/darkroom/Makefile.am b/src/niepce/modules/darkroom/Makefile.am
index b02ebc1..7501228 100644
--- a/src/niepce/modules/darkroom/Makefile.am
+++ b/src/niepce/modules/darkroom/Makefile.am
@@ -6,7 +6,6 @@ INCLUDES = -I$(top_srcdir)/src -I$(top_srcdir)/src/niepce -I$(top_srcdir)/src/ex
 	@LIBGLIBMM_CFLAGS@ \
 	@LIBGTKMM_CFLAGS@ \
 	@GCONF_CFLAGS@ \
-	@GOOCANVASMM_CFLAGS@  \
 	@GEGLMM_CFLAGS@ @EXEMPI_CFLAGS@ @OPENRAW_CFLAGS@
 
 
diff --git a/src/niepce/modules/darkroom/darkroommodule.cpp b/src/niepce/modules/darkroom/darkroommodule.cpp
index 10c618d..c101df2 100644
--- a/src/niepce/modules/darkroom/darkroommodule.cpp
+++ b/src/niepce/modules/darkroom/darkroommodule.cpp
@@ -36,12 +36,7 @@ void DarkroomModule::set_image(const eng::LibFile::Ptr & file)
     m_image->reload(file->path(), 
                     file->fileType() == eng::LibFile::FILE_TYPE_RAW,
                     file->orientation());
-/*    int w, h;
-    w = m_imagecanvas->get_width();
-    h = m_imagecanvas->get_height();
-    m_image->set_scale_to_dim(w, h);
-*/
-    m_imagecanvas->set_image(m_image->pixbuf_for_display());
+
 }
 
 
@@ -51,30 +46,25 @@ Gtk::Widget * DarkroomModule::buildWidget()
     m_imagecanvas = Gtk::manage(new ImageCanvas());
 // TODO set a proper canvas size
 //    m_canvas_scroll.add(*m_imagecanvas);
-	m_vbox.pack_start(*m_imagecanvas, Gtk::PACK_EXPAND_WIDGET);
-
-//    int w,h;
-//    w = h = 0;
-//    m_canvas_scroll.get_size_request(w, h);
-//    DBG_OUT("scroll size %d %d", w, h);
-//    m_imagecanvas->set_size_request(w, h);
-    m_imagecanvas->set_bounds(0, 0, 1000, 1000);
-
-	// build the toolbar.
-	Gtk::Toolbar * toolbar = Gtk::manage(new Gtk::Toolbar);
-
-	Glib::RefPtr<Gtk::Action> an_action;
-	an_action = m_actionGroup->get_action("PrevImage");
-	toolbar->append(*(an_action->create_tool_item()));
-	an_action = m_actionGroup->get_action("NextImage");
-	toolbar->append(*(an_action->create_tool_item()));
-	an_action = m_actionGroup->get_action("RotateLeft");
-	toolbar->append(*(an_action->create_tool_item()));
-	an_action = m_actionGroup->get_action("RotateRight");
-	toolbar->append(*(an_action->create_tool_item()));
-
-	m_vbox.pack_start(*toolbar, Gtk::PACK_SHRINK);
-	m_dr_splitview.pack1(m_vbox, Gtk::EXPAND);
+    m_vbox.pack_start(*m_imagecanvas, Gtk::PACK_EXPAND_WIDGET);
+
+    m_imagecanvas->set_image(m_image);
+
+    // build the toolbar.
+    Gtk::Toolbar * toolbar = Gtk::manage(new Gtk::Toolbar);
+
+    Glib::RefPtr<Gtk::Action> an_action;
+    an_action = m_actionGroup->get_action("PrevImage");
+    toolbar->append(*(an_action->create_tool_item()));
+    an_action = m_actionGroup->get_action("NextImage");
+    toolbar->append(*(an_action->create_tool_item()));
+    an_action = m_actionGroup->get_action("RotateLeft");
+    toolbar->append(*(an_action->create_tool_item()));
+    an_action = m_actionGroup->get_action("RotateRight");
+    toolbar->append(*(an_action->create_tool_item()));
+
+    m_vbox.pack_start(*toolbar, Gtk::PACK_SHRINK);
+    m_dr_splitview.pack1(m_vbox, Gtk::EXPAND);
     m_dock = new fwk::Dock();
     m_dr_splitview.pack2(m_dock->getWidget(), Gtk::SHRINK);
 
@@ -87,8 +77,8 @@ Gtk::Widget * DarkroomModule::buildWidget()
     add(m_toolbox_ctrl);
     (void)m_toolbox_ctrl->buildWidget();
 
-	m_widget = &m_dr_splitview;
-	return m_widget;
+    m_widget = &m_dr_splitview;
+    return m_widget;
 }
 
 
diff --git a/src/niepce/modules/darkroom/imagecanvas.cpp b/src/niepce/modules/darkroom/imagecanvas.cpp
index 2465034..1c5f8e0 100644
--- a/src/niepce/modules/darkroom/imagecanvas.cpp
+++ b/src/niepce/modules/darkroom/imagecanvas.cpp
@@ -1,7 +1,7 @@
 /*
  * niepce - darkroom/imagecanvas.cpp
  *
- * Copyright (C) 2008 Hubert Figuiere
+ * Copyright (C) 2008-2009 Hubert Figuiere
  *
  * 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
@@ -17,9 +17,10 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-/* remove this when we require a version that does not barf warnings */
-#include "fwk/toolkit/goocanvas_proxy_header.hpp"
-//#include <goocanvasmm/canvas.h>
+#include <cairomm/context.h>
+#include <gdkmm/general.h>
+
+
 #include "fwk/base/debug.hpp"
 #include "fwk/base/geometry.hpp"
 
@@ -28,27 +29,37 @@
 namespace darkroom {
 
 ImageCanvas::ImageCanvas()
-    : Goocanvas::Canvas(),
-      m_need_redisplay(true),
+    : m_need_redisplay(true),
       m_zoom_mode(ZOOM_MODE_FIT)
 {
-    m_imagecanvas = this;
-    Glib::RefPtr<Goocanvas::Item> root;
-    root = m_imagecanvas->get_root_item ();
-    
-    m_frameitem = Goocanvas::Rect::create(0,0,0,0);
-    m_imageitem = Goocanvas::Image::create(0,0);
-    
-    root->add_child(m_frameitem);
-    root->add_child(m_imageitem);
 }
 
 
-void ImageCanvas::set_image(const Glib::RefPtr<Gdk::Pixbuf> & img)
+void ImageCanvas::set_image(const ncr::Image::Ptr & img)
 {
     m_need_redisplay = true;
+    m_image_reloaded_cid.disconnect();
     m_image = img;
-    _redisplay();
+    m_image_reloaded_cid = m_image->signal_update.connect(
+        sigc::mem_fun(*this, &ImageCanvas::on_image_reloaded));
+}
+
+
+void ImageCanvas::on_image_reloaded()
+{
+    m_need_redisplay = true;
+}
+
+
+double ImageCanvas::_calc_image_scale(int img_w, int img_h)
+{
+    double b_w, b_h;
+    b_w = get_width();
+    b_h = get_height();
+
+    double scale_w = b_w / img_w;
+    double scale_h = b_h / img_h;
+    return std::min(scale_w, scale_h);
 }
 
 
@@ -57,8 +68,8 @@ void ImageCanvas::_calc_image_frame(int img_w, int img_h,
                                    double & width, double & height)
 {
     double b_w, b_h;
-    b_w = m_imagecanvas->get_width();
-    b_h = m_imagecanvas->get_height();
+    b_w = get_width();
+    b_h = get_height();
 //    DBG_OUT("bounds %f %f", b_w, b_h);
     x = (b_w - img_w) / 2;
     y = (b_h - img_h) / 2;
@@ -67,50 +78,88 @@ void ImageCanvas::_calc_image_frame(int img_w, int img_h,
 //    DBG_OUT("image frame %f %f %f %f", x, y, width, height);  
 }
 
-
-void ImageCanvas::_redisplay(bool force)
+bool ImageCanvas::on_expose_event(GdkEventExpose *ev)
 {
-    if(m_need_redisplay || force) {
-        Glib::RefPtr<Gdk::Pixbuf> img = m_image;
-        DBG_OUT("set image w %d h %d", img->get_width(), img->get_height());
-        
-        // the position and dimension of the image frame
-        double x, y, w, h;
-
-        fwk::Rect dest(0,0, m_imagecanvas->get_width() - 8,
-            m_imagecanvas->get_height() - 8);
-        fwk::Rect source(0,0, img->get_width(), img->get_height());
-        fwk::Rect frame;
-        switch(m_zoom_mode)
-        {
-        case ZOOM_MODE_FIT:
-            frame = source.fit_into(dest);
-            break;
-        case ZOOM_MODE_FILL:
-            frame = source.fill_into(dest);
-            break;
-        default:
-            frame = source;
-            break;
-        }
-        
-        _calc_image_frame(frame.w(), frame.h(),
-                          x,y,w,h);
+    Cairo::RefPtr<Cairo::Context> context = get_window()->create_cairo_context();
+
+    context->rectangle(ev->area.x, ev->area.y, ev->area.width, ev->area.height);
+    context->clip();
 
-        m_imageitem->property_x() = x;
-        m_imageitem->property_y() = y;
-        m_imageitem->property_width() = w;
-        m_imageitem->property_height() = h;
-        m_imageitem->property_pixbuf() = img->scale_simple(w, h, 
-                                                           Gdk::INTERP_BILINEAR);
+    if(m_need_redisplay) {
+        _redisplay();
 
-        m_frameitem->property_x() = x;
-        m_frameitem->property_y() = y;
-        m_frameitem->property_width() = w;
-        m_frameitem->property_height() = h;        
+        // calculate the image scale
+        int img_w, img_h;
+        img_w = m_image->get_original_width();
+        img_h = m_image->get_original_height();
+        DBG_OUT("image w = %d ; h = %d", img_w, img_h);
+        double scale = _calc_image_scale(img_w, img_h);
+        DBG_OUT("scale = %f", scale);
+        m_image->set_scale(scale);
+
+
+        // query the image.
+        Cairo::RefPtr<Cairo::Surface> img_s 
+            = m_image->cairo_surface_for_display();
+
+        int canvas_h, canvas_w;
+        canvas_h = get_height();
+        canvas_w = get_width();
+        DBG_OUT("canvas w = %d ; h = %d", canvas_w, canvas_h);
+
+        m_backingstore 
+            = Cairo::Surface::create(img_s, Cairo::CONTENT_COLOR, 
+                                     canvas_w, canvas_h);
+        Cairo::RefPtr<Cairo::Context> sc 
+            = Cairo::Context::create(m_backingstore);
+
+        // paint the background
+        sc->rectangle(0, 0, canvas_w, canvas_h);
+        Gdk::Cairo::set_source_color(sc, 
+                                     get_style()->get_bg(Gtk::STATE_NORMAL));
+        sc->fill();
+
+
+
+        double x = (canvas_w - (img_w*scale)) / 2;
+        double y = (canvas_h - (img_h*scale)) / 2;
+        DBG_OUT("x = %f ; y = %f", x, y);
+
+        sc->set_source(img_s, x, y);
+        sc->paint();
 
         m_need_redisplay = false;
     }
+
+    context->set_source(m_backingstore, 0, 0);
+    context->paint();
+
+    return true;
+}
+
+
+void ImageCanvas::_redisplay()
+{
+    int img_w, img_h; 
+    img_w = m_image->get_original_width();
+    img_h = m_image->get_original_height();
+    DBG_OUT("set image w %d h %d", img_w, img_h);
+        
+    fwk::Rect dest(0,0, get_width() - 8, get_height() - 8);
+    fwk::Rect source(0,0, img_w, img_h);
+    fwk::Rect frame;
+    switch(m_zoom_mode)
+    {
+    case ZOOM_MODE_FIT:
+        frame = source.fit_into(dest);
+        break;
+    case ZOOM_MODE_FILL:
+        frame = source.fill_into(dest);
+        break;
+    default:
+        frame = source;
+        break;
+    }
 }
 
 }
diff --git a/src/niepce/modules/darkroom/imagecanvas.hpp b/src/niepce/modules/darkroom/imagecanvas.hpp
index cc9d3ff..edc9dc2 100644
--- a/src/niepce/modules/darkroom/imagecanvas.hpp
+++ b/src/niepce/modules/darkroom/imagecanvas.hpp
@@ -1,7 +1,7 @@
 /*
  * niepce - darkroom/imagecanvas.h
  *
- * Copyright (C) 2008 Hubert Figuiere
+ * Copyright (C) 2008-2009 Hubert Figuiere
  *
  * 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
@@ -18,15 +18,18 @@
  */
 
 
+
+#include <gdk/gdk.h>
 #include <gdkmm/pixbuf.h>
-#include <gtkmm/bin.h>
+#include <gtkmm/drawingarea.h>
+#include <cairomm/surface.h>
 
-#include "fwk/toolkit/goocanvas_proxy_header.hpp"
+#include "ncr/image.hpp"
 
 namespace darkroom {
 
 class ImageCanvas
-    : public Goocanvas::Canvas
+    : public Gtk::DrawingArea
 {
 public:
     typedef enum {
@@ -38,7 +41,7 @@ public:
     } ZoomMode;
     ImageCanvas();
 
-    void set_image(const Glib::RefPtr<Gdk::Pixbuf> & img);
+    void set_image(const ncr::Image::Ptr & img);
     void set_zoom_mode(ZoomMode mode)
         {
             if(m_zoom_mode != mode) {
@@ -50,20 +53,24 @@ public:
         {
             return m_zoom_mode;
         }
+protected:
+    virtual bool on_expose_event(GdkEventExpose *);
 private:
+    void on_image_reloaded();
+
     void _calc_image_frame(int img_w, int img_h,
-                          double & x, double & y,
-                          double & width, double & height);
-    /** cause to "recalulate" the content. 
-        Only if m_need_display of force */
-    void _redisplay(bool force = false);
+                           double & x, double & y,
+                           double & width, double & height);
+    double _calc_image_scale(int img_w, int img_h);
+    /** cause to "recalulate" the content. */
+    void _redisplay();
 
     bool                           m_need_redisplay;
     ZoomMode                       m_zoom_mode;
-    Glib::RefPtr<Gdk::Pixbuf>      m_image;
-    Glib::RefPtr<Goocanvas::Image> m_imageitem;
-    Glib::RefPtr<Goocanvas::Rect>  m_frameitem;
-    Goocanvas::Canvas*             m_imagecanvas;
+    ncr::Image::Ptr                m_image;
+    Cairo::RefPtr<Cairo::Surface>  m_backingstore;
+
+    sigc::connection               m_image_reloaded_cid;
 };
 
 }
diff --git a/src/niepce/ui/Makefile.am b/src/niepce/ui/Makefile.am
index d0fc817..6b49fd7 100644
--- a/src/niepce/ui/Makefile.am
+++ b/src/niepce/ui/Makefile.am
@@ -17,7 +17,6 @@ INCLUDES = -I$(top_srcdir)/src/ -I$(srcdir)/.. -I$(srcdir)/thumb-view \
 	@LIBGLIBMM_CFLAGS@ \
 	@LIBGTKMM_CFLAGS@ \
 	@GCONF_CFLAGS@ \
-	@GOOCANVASMM_CFLAGS@ \
 	@EXEMPI_CFLAGS@
 
 EXTRA_DIST = $(gladefiles)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]