2 * This file is part of RawTherapee.
4 * Copyright (c) 2004-2010 Gabor Horvath <hgabor@rawtherapee.com>
6 * RawTherapee is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * RawTherapee is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with RawTherapee. If not, see <http://www.gnu.org/licenses/>.
19 #ifndef _THUMBNAILBROWSER_
20 #define _THUMBNAILBROWSER_
23 #include <thumbnail.h>
24 #include <filecatalog.h>
26 class ThumbBrowserEntry
{
29 // set by arrangeFiles():
30 int width
; // minimal width
31 int height
; // minimal height
32 int exp_width
; // ararnged width
33 int startx
; // x coord. in the widget
34 int starty
; // y coord. in the widget
35 // thumbnail preview properties:
36 int prew
; // width of the thumbnail
37 int preh
; // height of the thumbnail
39 // file and directory attributes:
40 Glib::ustring filename
;
41 Glib::ustring shortname
;
42 Glib::ustring dirname
;
43 // the associated thumbnail instance:
46 ThumbBrowserEntry (Thumbnail
* thm
, Glib::ustring fname
, Glib::ustring sname
, Glib::ustring dname
, int h
)
47 : thumbnail(thm
), filename(fname
), shortname(sname
), dirname(dname
), preh(h
) {
48 preview
= thumbnail
? (guint8
*) thumbnail
->getThumbnailImage (prew
, preh
) : NULL
;
51 bool operator< (FileDescr
& other
) {
52 return shortname
>other
.shortname
;
56 class ThumbBrowser
: public Gtk::DrawingArea
{
61 Glib::RefPtr
<Gdk::GC
> gc_
;
67 std::vector
<ThumbBrowserEntry
*> fd
;
68 std::vector
<ThumbBrowserEntry
*> selected
;
73 ThumbBrowserListener
* tbl
;
75 void arrangeFiles (int rows
);
81 void addEntry (ThumbBrowserEntry
* entry
);
82 void setThumbBrowserListener (ThumbBrowserListener
* l
) { tbl
= l
; }
84 virtual void on_realize();
85 virtual bool on_expose_event(GdkEventExpose
* event
);
86 virtual bool on_button_press_event (GdkEventButton
* event
);
87 virtual bool on_button_release_event (GdkEventButton
* event
);
88 virtual void previewReady (FileDescr
* fdn
);
90 void resized (Gtk::Allocation
& req
);
92 void styleChanged (const Glib::RefPtr
<Gtk::Style
>& style
);