From 10cda4ab818c84d66b7f2aaa681996fb0923664e Mon Sep 17 00:00:00 2001 From: Oliver Duis Date: Thu, 11 Nov 2010 18:30:51 +0100 Subject: [PATCH] Different thumbnails zoom levels for tab ribbon and main file browser, plus save (see issue #325) --- rtgui/filebrowser.cc | 2 +- rtgui/options.cc | 3 +++ rtgui/options.h | 3 ++- rtgui/rtwindow.cc | 4 ++-- rtgui/thumbbrowserbase.cc | 23 ++++++++++++++++++----- rtgui/thumbbrowserbase.h | 4 ++++ 6 files changed, 30 insertions(+), 9 deletions(-) diff --git a/rtgui/filebrowser.cc b/rtgui/filebrowser.cc index 766ebb751..6d73cc722 100644 --- a/rtgui/filebrowser.cc +++ b/rtgui/filebrowser.cc @@ -202,7 +202,7 @@ void FileBrowser::addEntry_ (FileBrowserEntry* entry) { while (i!=fd.end() && *entry < *((FileBrowserEntry*)*i)) i++; - fd.insert (i, entry); + fd.insert (i, entry); initEntry (entry); redraw (); diff --git a/rtgui/options.cc b/rtgui/options.cc index 25af21c41..17f171c51 100644 --- a/rtgui/options.cc +++ b/rtgui/options.cc @@ -76,6 +76,7 @@ void Options::setDefaults () { multiUser = false; version = 290; thumbSize = 80; + thumbSizeTab = 80; showHistory = true; showFilePanelState = 0; showInfo = false; @@ -217,6 +218,7 @@ if (keyFile.has_group ("Profiles")) { if (keyFile.has_group ("File Browser")) { if (keyFile.has_key ("File Browser", "ThumbnailSize")) thumbSize = keyFile.get_integer ("File Browser", "ThumbnailSize"); + if (keyFile.has_key ("File Browser", "ThumbnailSizeTab")) thumbSizeTab = keyFile.get_integer ("File Browser", "ThumbnailSizeTab"); if (keyFile.has_key ("File Browser", "BrowseOnlyRaw")) fbOnlyRaw = keyFile.get_boolean ("File Browser", "BrowseOnlyRaw"); if (keyFile.has_key ("File Browser", "BrowserShowsDate")) fbShowDateTime = keyFile.get_boolean ("File Browser", "BrowserShowsDate"); if (keyFile.has_key ("File Browser", "BrowserShowsExif")) fbShowBasicExif = keyFile.get_boolean ("File Browser", "BrowserShowsExif"); @@ -327,6 +329,7 @@ int Options::saveToFile (Glib::ustring fname) { keyFile.set_boolean ("File Browser", "BrowserShowsExif", fbShowBasicExif); keyFile.set_boolean ("File Browser", "BrowserShowsHidden", fbShowHidden); keyFile.set_integer ("File Browser", "ThumbnailSize", thumbSize); + keyFile.set_integer ("File Browser", "ThumbnailSizeTab", thumbSizeTab); keyFile.set_integer ("File Browser", "MaxPreviewHeight", maxThumbnailHeight); keyFile.set_integer ("File Browser", "MaxCacheEntries", maxCacheEntries); keyFile.set_integer ("File Browser", "ThumbnailFormat", (int)thumbnailFormat); diff --git a/rtgui/options.h b/rtgui/options.h index ce92ee03f..9e190c337 100644 --- a/rtgui/options.h +++ b/rtgui/options.h @@ -84,7 +84,7 @@ class Options { bool multiUser; static Glib::ustring rtdir; int version; - int thumbSize; + int thumbSize,thumbSizeTab; bool showHistory; int showFilePanelState; // 0: normal, 1: maximized, 2: normal, 3: hidden bool showInfo; @@ -131,6 +131,7 @@ class Options { bool overlayedFileNames; bool showFileNames; bool tabbedUI; + int previewSizeTab,previewSizeBrowser; Options (); diff --git a/rtgui/rtwindow.cc b/rtgui/rtwindow.cc index 61aa92cfd..550015431 100644 --- a/rtgui/rtwindow.cc +++ b/rtgui/rtwindow.cc @@ -343,7 +343,7 @@ void RTWindow::MoveFileBrowserToMain() FileCatalog *fCatalog = fpanel->fileCatalog; epanel->catalogPane->remove(*fCatalog); fpanel->ribbonPane->add(*fCatalog); - fCatalog->fileBrowser->setArrangement(ThumbBrowserBase::TB_Vertical); + fCatalog->fileBrowser->enableTabMode(false); fCatalog->redrawAll(); } } @@ -355,7 +355,7 @@ void RTWindow::MoveFileBrowserToEditor() FileCatalog *fCatalog = fpanel->fileCatalog; fpanel->ribbonPane->remove(*fCatalog); epanel->catalogPane->add(*fCatalog); - fCatalog->fileBrowser->setArrangement(ThumbBrowserBase::TB_Horizontal); + fCatalog->fileBrowser->enableTabMode(true); fCatalog->redrawAll(); fCatalog->refreshHeight(); } diff --git a/rtgui/thumbbrowserbase.cc b/rtgui/thumbbrowserbase.cc index 29eb9502e..48f4d358b 100644 --- a/rtgui/thumbbrowserbase.cc +++ b/rtgui/thumbbrowserbase.cc @@ -24,7 +24,7 @@ ThumbBrowserBase::ThumbBrowserBase () : lastClicked(NULL), previewHeight(options.thumbSize) { - + inTabMode=false; // corresponding to take thumbSize inW = -1; inH = -1; Gtk::HBox* hb1 = new Gtk::HBox (); @@ -467,19 +467,22 @@ void ThumbBrowserBase::zoomChanged (bool zoomIn) { int newHeight; int i=0; + int optThumbSize=inTabMode ? options.thumbSizeTab : options.thumbSize; if (zoomIn) for (i=0; i options.thumbSize) + if (newHeight > optThumbSize) break; } else for (i=options.thumbnailZoomRatios.size()-1; i>=0; i--) { newHeight = (int)(options.thumbnailZoomRatios[i] * options.maxThumbnailHeight); - if (newHeight < options.thumbSize) + if (newHeight < optThumbSize) break; } - previewHeight = options.thumbSize = newHeight; + previewHeight = newHeight; + if (inTabMode) options.thumbSizeTab = newHeight; else options.thumbSize = newHeight; + for (int i=0; iresize (previewHeight); redraw (); @@ -490,7 +493,7 @@ void ThumbBrowserBase::zoomChanged (bool zoomIn) { void ThumbBrowserBase::refreshThumbImages () { for (int i=0; iresize (previewHeight);// TODO!!! Might be performance bottleneck fd[i]->refreshThumbnailImage (); } @@ -518,6 +521,16 @@ void ThumbBrowserBase::setArrangement (Arrangement a) { redraw (); } +void ThumbBrowserBase::enableTabMode(bool enable) { + inTabMode = enable; + arrangement = inTabMode ? ThumbBrowserBase::TB_Horizontal : ThumbBrowserBase::TB_Vertical; + + if (options.thumbSizeTab!=options.thumbSize) + refreshThumbImages(); + else + redraw(); +} + void ThumbBrowserBase::initEntry (ThumbBrowserEntryBase* entry) { entry->setOffset ((int)(hscroll.get_value()), (int)(vscroll.get_value())); diff --git a/rtgui/thumbbrowserbase.h b/rtgui/thumbbrowserbase.h index f4e8a3268..3728e64cb 100644 --- a/rtgui/thumbbrowserbase.h +++ b/rtgui/thumbbrowserbase.h @@ -55,6 +55,8 @@ class ThumbBrowserBase : public Gtk::VBox { Gtk::VScrollbar vscroll; int inW, inH; + + bool inTabMode; // Tab mode has e.g. different preview heights void resizeThumbnailArea (int w, int h); void internalAreaResized (Gtk::Allocation& req); @@ -105,6 +107,8 @@ class ThumbBrowserBase : public Gtk::VBox { void setScrollPosition (double h, double v); void setArrangement (Arrangement a); + void enableTabMode(bool enable); // set both thumb sizes and arrangements + virtual bool checkFilter (ThumbBrowserEntryBase* entry) { return true; } virtual void rightClicked (ThumbBrowserEntryBase* entry) {} virtual void doubleClicked (ThumbBrowserEntryBase* entry) {}