"Fossies" - the Fresh Open Source Software Archive

Member "rawtherapee-5.7/rtgui/thumbbrowserentrybase.h" (10 Sep 2019, 5538 Bytes) of package /linux/misc/rawtherapee-5.7.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "thumbbrowserentrybase.h" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 5.6_vs_5.7.

    1 /*
    2  *  This file is part of RawTherapee.
    3  *
    4  *  Copyright (c) 2004-2010 Gabor Horvath <hgabor@rawtherapee.com>
    5  *
    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.
   10  *
   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.
   15  *
   16  *  You should have received a copy of the GNU General Public License
   17  *  along with RawTherapee.  If not, see <https://www.gnu.org/licenses/>.
   18  */
   19 #pragma once
   20 
   21 #include <atomic>
   22 #include <tuple>
   23 #include <gtkmm.h>
   24 
   25 #include "cursormanager.h"
   26 #include "guiutils.h"
   27 #include "lwbuttonset.h"
   28 #include "threadutils.h"
   29 #include "thumbnail.h"
   30 
   31 class ThumbBrowserBase;
   32 class ThumbBrowserEntryBase
   33 {
   34 
   35 public:
   36     enum eWithFilename {
   37         WFNAME_NONE,
   38         WFNAME_REDUCED,
   39         WFNAME_FULL
   40     };
   41 
   42 protected:
   43     int fnlabw, fnlabh; // dimensions of the filename label
   44     int dtlabw, dtlabh; // dimensions of the date/time label
   45     int exlabw, exlabh; // dimensions of the exif label
   46     int prew;       // width of the thumbnail
   47     int preh;       // height of the thumbnail
   48     int prex;
   49     int prey;
   50 
   51     int upperMargin;
   52     int borderWidth;
   53     int textGap;
   54     int sideMargin;
   55     int lowerMargin;
   56 
   57 
   58     MyRWMutex lockRW;  // Locks access to all image thumb changing actions
   59 
   60     guint8* preview;  // holds the preview image. used in updateBackBuffer. TODO Olli: Make a cache to reduce mem significantly
   61 
   62     Glib::ustring dispname;
   63 
   64     LWButtonSet* buttonSet;
   65 
   66     int width;      // minimal width
   67     int height;     // minimal height
   68 // set by arrangeFiles() of thumbbrowser
   69     int exp_width;  // arranged width (backbuffer dimensions)
   70     int exp_height; // arranged height
   71     int startx;     // x coord. in the widget
   72     int starty;     // y coord. in the widget
   73 
   74     int ofsX, ofsY; // offset due to the scrolling of the parent
   75 
   76     std::atomic<int> redrawRequests;
   77 
   78     ThumbBrowserBase* parent;
   79     ThumbBrowserEntryBase* original;
   80 
   81     Glib::RefPtr<BackBuffer> backBuffer;
   82     bool bbSelected, bbFramed;
   83     guint8* bbPreview;
   84     std::vector<Glib::RefPtr<Gdk::Pixbuf>> bbIcons;
   85     std::vector<Glib::RefPtr<Gdk::Pixbuf>> bbSpecificityIcons;
   86     CursorShape cursor_type;
   87 
   88     void drawFrame (Cairo::RefPtr<Cairo::Context> cr, const Gdk::RGBA& bg, const Gdk::RGBA& fg);
   89     void getTextSizes (int& w, int& h);
   90 
   91     // called during updateBackBuffer for custom overlays
   92     virtual void customBackBufferUpdate (Cairo::RefPtr<Cairo::Context> c) {}
   93 
   94 private:
   95     const std::string collate_name;
   96 
   97 public:
   98 
   99     Thumbnail* thumbnail;
  100 
  101 // thumbnail preview properties:
  102     Glib::ustring filename;
  103     Glib::ustring exifline;
  104     Glib::ustring datetimeline;
  105 
  106 // misc attributes
  107     bool selected;
  108     bool drawable;
  109     bool filtered;
  110     bool framed;
  111     bool processing;
  112     bool italicstyle;
  113     bool edited;
  114     bool recentlysaved;
  115     bool updatepriority;
  116     eWithFilename withFilename;
  117 
  118     explicit ThumbBrowserEntryBase (const Glib::ustring& fname);
  119     virtual ~ThumbBrowserEntryBase ();
  120 
  121     void setParent (ThumbBrowserBase* l)
  122     {
  123         parent = l;
  124     }
  125 
  126     void updateBackBuffer ();
  127     void resize (int h);
  128     virtual void draw (Cairo::RefPtr<Cairo::Context> cc);
  129 
  130     void addButtonSet (LWButtonSet* bs);
  131     int getMinimalHeight () const
  132     {
  133         return height;
  134     }
  135     int getMinimalWidth () const
  136     {
  137         return width;
  138     }
  139 
  140     int getEffectiveWidth () const
  141     {
  142         return exp_width;
  143     }
  144     int getEffectiveHeight () const
  145     {
  146         return exp_height;
  147     }
  148     int getPreviewHeight () const
  149     {
  150         return preh;
  151     }
  152     int getStartX () const
  153     {
  154         return startx;
  155     }
  156     int getStartY () const
  157     {
  158         return starty;
  159     }
  160     int getX () const
  161     {
  162         return ofsX + startx;
  163     }
  164     int getY () const
  165     {
  166         return ofsY + starty;
  167     }
  168 
  169     bool inside (int x, int y) const;
  170     rtengine::Coord2D getPosInImgSpace (int x, int y) const;
  171     bool insideWindow (int x, int y, int w, int h) const;
  172     void setPosition (int x, int y, int w, int h);
  173     void setOffset (int x, int y);
  174 
  175     bool operator <(const ThumbBrowserEntryBase& other) const
  176     {
  177         return collate_name < other.collate_name;
  178     }
  179 
  180     virtual void refreshThumbnailImage () = 0;
  181     virtual void refreshQuickThumbnailImage () {}
  182     virtual void calcThumbnailSize () = 0;
  183 
  184     virtual void drawProgressBar (Glib::RefPtr<Gdk::Window> win, const Gdk::RGBA& foregr, const Gdk::RGBA& backgr, int x, int w, int y, int h) {}
  185 
  186     virtual std::vector<Glib::RefPtr<Gdk::Pixbuf>> getIconsOnImageArea ();
  187     virtual std::vector<Glib::RefPtr<Gdk::Pixbuf>> getSpecificityIconsOnImageArea ();
  188     virtual void getIconSize (int& w, int& h) const = 0;
  189 
  190     virtual bool motionNotify (int x, int y);
  191     virtual bool pressNotify (int button, int type, int bstate, int x, int y);
  192     virtual bool releaseNotify (int button, int type, int bstate, int x, int y);
  193     virtual std::tuple<Glib::ustring, bool> getToolTip (int x, int y) const;
  194 
  195     inline ThumbBrowserEntryBase* getOriginal() const
  196     {
  197         return original;
  198     }
  199 
  200     inline void setOriginal(ThumbBrowserEntryBase* original)
  201     {
  202         this->original = original;
  203     }
  204 
  205 };