[niepce] Add cell renderer for the film strip.
- From: Hubert Figuière <hub src gnome org>
- To: svn-commits-list gnome org
- Subject: [niepce] Add cell renderer for the film strip.
- Date: Fri, 17 Jul 2009 03:57:02 +0000 (UTC)
commit f9f6b0bf0354a3322310358a209467c839abf288
Author: Hubert Figuiere <hub figuiere net>
Date: Tue Jul 14 21:58:15 2009 -0400
Add cell renderer for the film strip.
ChangeLog | 2 +
src/niepce/ui/filmstripcontroller.cpp | 2 +-
src/niepce/ui/gridviewmodule.cpp | 10 +++++++
src/niepce/ui/librarycellrenderer.cpp | 49 +++++++++++++++++++-------------
src/niepce/ui/librarycellrenderer.hpp | 43 +++++++++++++++++++++++++----
src/niepce/ui/thumbstripview.cpp | 27 +++++++++++++++++-
6 files changed, 105 insertions(+), 28 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index d8bdc48..51ac9f6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
2009-07-14 Hubert Figuiere <hub figuiere net>
+ * Add cell renderer for the film strip.
+
* po/POTFILES.in: update for latest changes.
* Fix SelectionController::getLibraryClient().
diff --git a/src/niepce/ui/filmstripcontroller.cpp b/src/niepce/ui/filmstripcontroller.cpp
index d0bfa7e..0e34b75 100644
--- a/src/niepce/ui/filmstripcontroller.cpp
+++ b/src/niepce/ui/filmstripcontroller.cpp
@@ -47,7 +47,7 @@ Gtk::Widget * FilmStripController::buildWidget(const Glib::RefPtr<Gtk::UIManager
EOG_THUMB_NAV_MODE_ONE_ROW, true);
m_thumbview->set_selection_mode(Gtk::SELECTION_SINGLE);
m_widget = Glib::wrap(thn);
- m_widget->set_size_request(-1, 145);
+ m_widget->set_size_request(-1, 134);
return m_widget;
}
diff --git a/src/niepce/ui/gridviewmodule.cpp b/src/niepce/ui/gridviewmodule.cpp
index 1bf035c..b1e2bfb 100644
--- a/src/niepce/ui/gridviewmodule.cpp
+++ b/src/niepce/ui/gridviewmodule.cpp
@@ -85,6 +85,7 @@ Gtk::Widget * GridViewModule::buildWidget(const Glib::RefPtr<Gtk::UIManager> & m
m_librarylistview.property_row_spacing() = 0;
m_librarylistview.property_column_spacing() = 0;
m_librarylistview.property_spacing() = 0;
+ m_librarylistview.property_margin() = 0;
// the main cell
LibraryCellRenderer * libcell = Gtk::manage(new LibraryCellRenderer());
@@ -158,3 +159,12 @@ void GridViewModule::select_image(int id)
}
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0))
+ indent-tabs-mode:nil
+ fill-column:80
+ End:
+*/
diff --git a/src/niepce/ui/librarycellrenderer.cpp b/src/niepce/ui/librarycellrenderer.cpp
index 97735f5..6195f42 100644
--- a/src/niepce/ui/librarycellrenderer.cpp
+++ b/src/niepce/ui/librarycellrenderer.cpp
@@ -29,12 +29,14 @@
namespace ui {
-#define PAD 16
-
LibraryCellRenderer::LibraryCellRenderer()
: Glib::ObjectBase(typeid(LibraryCellRenderer)),
Gtk::CellRendererPixbuf(),
- m_size(160),
+ m_size(160),
+ m_pad(16),
+ m_drawborder(true),
+ m_drawemblem(true),
+ m_drawrating(true),
m_libfileproperty(*this, "libfile")
{
try {
@@ -71,15 +73,14 @@ LibraryCellRenderer::LibraryCellRenderer()
}
-namespace {
-void drawThumbnail(const Cairo::RefPtr<Cairo::Context> & cr,
- Glib::RefPtr<Gdk::Pixbuf> & pixbuf,
- const GdkRectangle & r)
+void LibraryCellRenderer::_drawThumbnail(const Cairo::RefPtr<Cairo::Context> & cr,
+ Glib::RefPtr<Gdk::Pixbuf> & pixbuf,
+ const GdkRectangle & r)
{
double x, y;
- x = r.x + PAD;
- y = r.y + PAD;
+ x = r.x + pad();
+ y = r.y + pad();
int w = pixbuf->get_width();
int h = pixbuf->get_height();
int min = std::min(w,h);
@@ -106,6 +107,8 @@ void drawThumbnail(const Cairo::RefPtr<Cairo::Context> & cr,
cr->paint();
}
+namespace {
+
void drawFormatEmblem(const Cairo::RefPtr<Cairo::Context> & cr,
const Cairo::RefPtr<Cairo::ImageSurface> & emblem,
const GdkRectangle & r)
@@ -167,7 +170,7 @@ LibraryCellRenderer::get_size_vfunc (Gtk::Widget& /*widget*/,
// TODO this should just be a property
//
Glib::RefPtr<Gdk::Pixbuf> pixbuf = property_pixbuf();
- int maxdim = m_size + PAD * 2;
+ int maxdim = m_size + pad() * 2;
if(width)
*width = maxdim;
@@ -207,13 +210,21 @@ LibraryCellRenderer::render_vfunc (const Glib::RefPtr<Gdk::Drawable>& window,
cr->rectangle(r.x, r.y, r.width, r.height);
cr->fill();
- color = widget.get_style()->get_dark(Gtk::STATE_SELECTED);
- Gdk::Cairo::set_source_color(cr, color);
- cr->set_line_width(1.0);
- cr->rectangle(r.x, r.y, r.width, r.height);
- cr->stroke();
-
+ if(m_drawborder) {
+ color = widget.get_style()->get_dark(Gtk::STATE_SELECTED);
+ Gdk::Cairo::set_source_color(cr, color);
+ cr->set_line_width(1.0);
+ cr->rectangle(r.x, r.y, r.width, r.height);
+ cr->stroke();
+ }
+ Glib::RefPtr<Gdk::Pixbuf> pixbuf = property_pixbuf();
+ _drawThumbnail(cr, pixbuf, r);
+ if(m_drawrating) {
+ drawRating(cr, file->rating(), m_star, m_unstar, r);
+ }
+
+ if(m_drawemblem) {
Cairo::RefPtr<Cairo::ImageSurface> emblem;
// DBG_OUT("the filetype: %i", file->fileType());
@@ -236,10 +247,8 @@ LibraryCellRenderer::render_vfunc (const Glib::RefPtr<Gdk::Drawable>& window,
break;
}
- Glib::RefPtr<Gdk::Pixbuf> pixbuf = property_pixbuf();
- drawThumbnail(cr, pixbuf, r);
- drawRating(cr, file->rating(), m_star, m_unstar, r);
- drawFormatEmblem(cr, emblem, r);
+ drawFormatEmblem(cr, emblem, r);
+ }
}
diff --git a/src/niepce/ui/librarycellrenderer.hpp b/src/niepce/ui/librarycellrenderer.hpp
index 822e54b..78723d0 100644
--- a/src/niepce/ui/librarycellrenderer.hpp
+++ b/src/niepce/ui/librarycellrenderer.hpp
@@ -46,17 +46,38 @@ public:
const Gdk::Rectangle& expose_area,
Gtk::CellRendererState flags);
- void set_size(int _size)
- { m_size = _size; }
- int size() const
- { return m_size; }
+ void set_size(int _size)
+ { m_size = _size; }
+ int size() const
+ { return m_size; }
+
+ void set_pad(int _pad)
+ { m_pad = _pad; }
+ int pad() const
+ { return m_pad; }
+ void set_drawborder(bool val)
+ { m_drawborder = val; }
+ void set_drawemblem(bool val)
+ { m_drawemblem = val; }
+ void set_drawrating(bool val)
+ { m_drawrating = val; }
Glib::PropertyProxy_ReadOnly<eng::LibFile::Ptr> property_libfile() const;
Glib::PropertyProxy<eng::LibFile::Ptr> property_libfile();
+protected:
+ /* drawing implementations */
+ void _drawThumbnail(const Cairo::RefPtr<Cairo::Context> & cr,
+ Glib::RefPtr<Gdk::Pixbuf> & pixbuf,
+ const GdkRectangle & r);
+
private:
- int m_size;
- Glib::Property<eng::LibFile::Ptr> m_libfileproperty;
+ int m_size;
+ int m_pad;
+ bool m_drawborder;
+ bool m_drawemblem;
+ bool m_drawrating;
+ Glib::Property<eng::LibFile::Ptr> m_libfileproperty;
Cairo::RefPtr<Cairo::ImageSurface> m_raw_format_emblem;
Cairo::RefPtr<Cairo::ImageSurface> m_rawjpeg_format_emblem;
@@ -71,4 +92,14 @@ private:
}
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0))
+ indent-tabs-mode:nil
+ fill-column:80
+ End:
+*/
+
#endif
diff --git a/src/niepce/ui/thumbstripview.cpp b/src/niepce/ui/thumbstripview.cpp
index ad0da72..70bc1b7 100644
--- a/src/niepce/ui/thumbstripview.cpp
+++ b/src/niepce/ui/thumbstripview.cpp
@@ -24,6 +24,7 @@
#include <string>
#include <glibmm/i18n.h>
+#include <gdkmm/general.h>
#include <gtkmm/adjustment.h>
#include <gtkmm/scrolledwindow.h>
@@ -31,6 +32,7 @@
#include "fwk/utils/boost.hpp"
#include "engine/db/libfile.hpp"
#include "thumbstripview.hpp"
+#include "librarycellrenderer.hpp"
struct EogThumbView;
@@ -51,6 +53,26 @@ static GtkTargetEntry target_table[] = {
};
#endif
+class ThumbStripCell
+ : public LibraryCellRenderer
+{
+public:
+ ThumbStripCell();
+};
+
+
+ThumbStripCell::ThumbStripCell()
+ : Glib::ObjectBase(typeid(ThumbStripCell))
+{
+ set_pad(0);
+ set_size(100);
+ set_drawborder(false);
+ set_drawemblem(false);
+ set_drawrating(false);
+}
+
+
+
ThumbStripView::ThumbStripView(const Glib::RefPtr<ui::ImageListStore> & store)
: m_start_thumb(0)
, m_end_thumb(0)
@@ -58,7 +80,7 @@ ThumbStripView::ThumbStripView(const Glib::RefPtr<ui::ImageListStore> & store)
{
IconView::set_model(store);
- m_renderer = new Gtk::CellRendererPixbuf();
+ m_renderer = new ThumbStripCell();
GtkCellLayout *cl = GTK_CELL_LAYOUT(gobj());
DBG_ASSERT(cl, "No cell layout");
@@ -72,11 +94,14 @@ ThumbStripView::ThumbStripView(const Glib::RefPtr<ui::ImageListStore> & store)
gtk_cell_layout_set_attributes (cl, GTK_CELL_RENDERER(m_renderer->gobj()),
"pixbuf",
ui::ImageListStore::Columns::STRIP_THUMB_INDEX,
+ "libfile",
+ ui::ImageListStore::Columns::FILE_INDEX,
NULL);
set_selection_mode(Gtk::SELECTION_MULTIPLE);
set_column_spacing(THUMB_STRIP_VIEW_SPACING);
set_row_spacing (THUMB_STRIP_VIEW_SPACING);
+ set_margin (0);
signal_parent_changed().connect(
sigc::mem_fun(*this, &ThumbStripView::on_parent_set));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]