Icons are resized depending on the current scale/resolution

See issue #3547 and #4803
This commit is contained in:
Hombre
2018-12-08 22:48:15 +01:00
parent 434e121f99
commit 5ea0bacddd
23 changed files with 259 additions and 192 deletions

View File

@@ -112,6 +112,7 @@ void cleanup ()
ProcParams::cleanup (); ProcParams::cleanup ();
Color::cleanup (); Color::cleanup ();
RawImageSource::cleanup (); RawImageSource::cleanup ();
#ifdef RT_FFTW3F_OMP #ifdef RT_FFTW3F_OMP
fftwf_cleanup_threads(); fftwf_cleanup_threads();
#else #else

View File

@@ -27,7 +27,7 @@
#include "thumbbrowserbase.h" #include "thumbbrowserbase.h"
bool BatchQueueEntry::iconsLoaded(false); bool BatchQueueEntry::iconsLoaded(false);
Cairo::RefPtr<Cairo::ImageSurface> BatchQueueEntry::savedAsIcon; Glib::RefPtr<Gdk::Pixbuf> BatchQueueEntry::savedAsIcon;
BatchQueueEntry::BatchQueueEntry (rtengine::ProcessingJob* pjob, const rtengine::procparams::ProcParams& pparams, Glib::ustring fname, int prevw, int prevh, Thumbnail* thm) : BatchQueueEntry::BatchQueueEntry (rtengine::ProcessingJob* pjob, const rtengine::procparams::ProcParams& pparams, Glib::ustring fname, int prevw, int prevh, Thumbnail* thm) :
ThumbBrowserEntryBase(fname), ThumbBrowserEntryBase(fname),
@@ -55,7 +55,7 @@ BatchQueueEntry::BatchQueueEntry (rtengine::ProcessingJob* pjob, const rtengine:
#endif #endif
if (!iconsLoaded) { if (!iconsLoaded) {
savedAsIcon = RTImage::createFromFile ("save-small.png"); savedAsIcon = RTImage::createPixbufFromFile ("save-small.png");
iconsLoaded = true; iconsLoaded = true;
} }
@@ -145,10 +145,10 @@ void BatchQueueEntry::removeButtonSet ()
buttonSet = nullptr; buttonSet = nullptr;
} }
std::vector<Cairo::RefPtr<Cairo::ImageSurface> > BatchQueueEntry::getIconsOnImageArea () std::vector<Glib::RefPtr<Gdk::Pixbuf> > BatchQueueEntry::getIconsOnImageArea ()
{ {
std::vector<Cairo::RefPtr<Cairo::ImageSurface> > ret; std::vector<Glib::RefPtr<Gdk::Pixbuf> > ret;
if (!outFileName.empty()) { if (!outFileName.empty()) {
ret.push_back (savedAsIcon); ret.push_back (savedAsIcon);

View File

@@ -43,7 +43,7 @@ class BatchQueueEntry : public ThumbBrowserEntryBase, public BQEntryUpdateListen
public: public:
static Cairo::RefPtr<Cairo::ImageSurface> savedAsIcon; static Glib::RefPtr<Gdk::Pixbuf> savedAsIcon;
rtengine::ProcessingJob* job; rtengine::ProcessingJob* job;
rtengine::procparams::ProcParams params; rtengine::procparams::ProcParams params;
@@ -65,7 +65,7 @@ public:
void removeButtonSet (); void removeButtonSet ();
std::vector<Cairo::RefPtr<Cairo::ImageSurface> > getIconsOnImageArea () override; std::vector<Glib::RefPtr<Gdk::Pixbuf> > getIconsOnImageArea () override;
void getIconSize (int& w, int& h) override; void getIconSize (int& w, int& h) override;
Glib::ustring getToolTip (int x, int y) override; Glib::ustring getToolTip (int x, int y) override;

View File

@@ -36,25 +36,25 @@ void CursorManager::init (Glib::RefPtr<Gdk::Window> mainWindow)
#endif #endif
Cairo::RefPtr<Cairo::ImageSurface> add = RTImage::createFromFile("crosshair-small.png"); Glib::RefPtr<Gdk::Pixbuf> add = RTImage::createPixbufFromFile("crosshair-small.png");
Cairo::RefPtr<Cairo::ImageSurface> colPick = RTImage::createFromFile("color-picker-hicontrast.png"); Glib::RefPtr<Gdk::Pixbuf> colPick = RTImage::createPixbufFromFile("color-picker-hicontrast.png");
Cairo::RefPtr<Cairo::ImageSurface> colPickAdd = RTImage::createFromFile("color-picker-add-hicontrast.png"); Glib::RefPtr<Gdk::Pixbuf> colPickAdd = RTImage::createPixbufFromFile("color-picker-add-hicontrast.png");
Cairo::RefPtr<Cairo::ImageSurface> cropDraw = RTImage::createFromFile("crop-point-hicontrast.png"); Glib::RefPtr<Gdk::Pixbuf> cropDraw = RTImage::createPixbufFromFile("crop-point-hicontrast.png");
Cairo::RefPtr<Cairo::ImageSurface> crosshair = RTImage::createFromFile("crosshair-hicontrast.png"); Glib::RefPtr<Gdk::Pixbuf> crosshair = RTImage::createPixbufFromFile("crosshair-hicontrast.png");
Cairo::RefPtr<Cairo::ImageSurface> empty = RTImage::createFromFile("empty.png"); Glib::RefPtr<Gdk::Pixbuf> empty = RTImage::createPixbufFromFile("empty.png");
Cairo::RefPtr<Cairo::ImageSurface> handClosed = RTImage::createFromFile("hand-closed-hicontrast.png"); Glib::RefPtr<Gdk::Pixbuf> handClosed = RTImage::createPixbufFromFile("hand-closed-hicontrast.png");
Cairo::RefPtr<Cairo::ImageSurface> handOpen = RTImage::createFromFile("hand-open-hicontrast.png"); Glib::RefPtr<Gdk::Pixbuf> handOpen = RTImage::createPixbufFromFile("hand-open-hicontrast.png");
Cairo::RefPtr<Cairo::ImageSurface> moveBL = RTImage::createFromFile("node-move-sw-ne-hicontrast.png"); Glib::RefPtr<Gdk::Pixbuf> moveBL = RTImage::createPixbufFromFile("node-move-sw-ne-hicontrast.png");
Cairo::RefPtr<Cairo::ImageSurface> moveBR = RTImage::createFromFile("node-move-nw-se-hicontrast.png"); Glib::RefPtr<Gdk::Pixbuf> moveBR = RTImage::createPixbufFromFile("node-move-nw-se-hicontrast.png");
Cairo::RefPtr<Cairo::ImageSurface> moveL = RTImage::createFromFile("node-move-x-hicontrast.png"); Glib::RefPtr<Gdk::Pixbuf> moveL = RTImage::createPixbufFromFile("node-move-x-hicontrast.png");
Cairo::RefPtr<Cairo::ImageSurface> moveR = RTImage::createFromFile("node-move-x-hicontrast.png"); Glib::RefPtr<Gdk::Pixbuf> moveR = RTImage::createPixbufFromFile("node-move-x-hicontrast.png");
Cairo::RefPtr<Cairo::ImageSurface> moveTL = RTImage::createFromFile("node-move-nw-se-hicontrast.png"); Glib::RefPtr<Gdk::Pixbuf> moveTL = RTImage::createPixbufFromFile("node-move-nw-se-hicontrast.png");
Cairo::RefPtr<Cairo::ImageSurface> moveTR = RTImage::createFromFile("node-move-sw-ne-hicontrast.png"); Glib::RefPtr<Gdk::Pixbuf> moveTR = RTImage::createPixbufFromFile("node-move-sw-ne-hicontrast.png");
Cairo::RefPtr<Cairo::ImageSurface> moveX = RTImage::createFromFile("node-move-x-hicontrast.png"); Glib::RefPtr<Gdk::Pixbuf> moveX = RTImage::createPixbufFromFile("node-move-x-hicontrast.png");
Cairo::RefPtr<Cairo::ImageSurface> moveXY = RTImage::createFromFile("node-move-xy-hicontrast.png"); Glib::RefPtr<Gdk::Pixbuf> moveXY = RTImage::createPixbufFromFile("node-move-xy-hicontrast.png");
Cairo::RefPtr<Cairo::ImageSurface> moveY = RTImage::createFromFile("node-move-y-hicontrast.png"); Glib::RefPtr<Gdk::Pixbuf> moveY = RTImage::createPixbufFromFile("node-move-y-hicontrast.png");
Cairo::RefPtr<Cairo::ImageSurface> rotate = RTImage::createFromFile("rotate-aroundnode-hicontrast.png"); Glib::RefPtr<Gdk::Pixbuf> rotate = RTImage::createPixbufFromFile("rotate-aroundnode-hicontrast.png");
Cairo::RefPtr<Cairo::ImageSurface> wait = RTImage::createFromFile("gears.png"); // Currently unused, create *-hicontrast once used. Glib::RefPtr<Gdk::Pixbuf> wait = RTImage::createPixbufFromFile("gears.png"); // Currently unused, create *-hicontrast once used.
cAdd = add ? Gdk::Cursor::create(display, add, 8, 8) : Gdk::Cursor::create(display, Gdk::PLUS); cAdd = add ? Gdk::Cursor::create(display, add, 8, 8) : Gdk::Cursor::create(display, Gdk::PLUS);
cAddPicker = colPickAdd ? Gdk::Cursor::create(display, colPickAdd, 4, 21) : Gdk::Cursor::create(display, Gdk::PLUS); cAddPicker = colPickAdd ? Gdk::Cursor::create(display, colPickAdd, 4, 21) : Gdk::Cursor::create(display, Gdk::PLUS);

View File

@@ -121,20 +121,13 @@ DirBrowser::~DirBrowser()
void DirBrowser::fillDirTree () void DirBrowser::fillDirTree ()
{ {
Cairo::RefPtr<Cairo::ImageSurface> openfolder_ = RTImage::createFromFile ("folder-open-small.png"); openfolder = RTImage::createPixbufFromFile ("folder-open-small.png");
openfolder = Gdk::Pixbuf::create(openfolder_, 0, 0, openfolder_->get_width(), openfolder_->get_height()); closedfolder = RTImage::createPixbufFromFile ("folder-closed-small.png");
Cairo::RefPtr<Cairo::ImageSurface> closedfolder_ = RTImage::createFromFile ("folder-open-small.png"); icdrom = RTImage::createPixbufFromFile ("device-optical.png");
closedfolder = Gdk::Pixbuf::create(closedfolder_, 0, 0, closedfolder_->get_width(), closedfolder_->get_height()); ifloppy = RTImage::createPixbufFromFile ("device-floppy.png");
Cairo::RefPtr<Cairo::ImageSurface> icdrom_ = RTImage::createFromFile ("folder-open-small.png"); ihdd = RTImage::createPixbufFromFile ("device-hdd.png");
icdrom = Gdk::Pixbuf::create(icdrom_, 0, 0, icdrom_->get_width(), icdrom_->get_height()); iremovable = RTImage::createPixbufFromFile ("device-usb.png");
Cairo::RefPtr<Cairo::ImageSurface> ifloppy_ = RTImage::createFromFile ("folder-open-small.png"); inetwork = RTImage::createPixbufFromFile ("device-network.png");
ifloppy = Gdk::Pixbuf::create(ifloppy_, 0, 0, ifloppy_->get_width(), ifloppy_->get_height());
Cairo::RefPtr<Cairo::ImageSurface> ihdd_ = RTImage::createFromFile ("folder-open-small.png");
ihdd = Gdk::Pixbuf::create(ihdd_, 0, 0, ihdd_->get_width(), ihdd_->get_height());
Cairo::RefPtr<Cairo::ImageSurface> iremovable_ = RTImage::createFromFile ("folder-open-small.png");
iremovable = Gdk::Pixbuf::create(iremovable_, 0, 0, iremovable_->get_width(), iremovable_->get_height());
Cairo::RefPtr<Cairo::ImageSurface> inetwork_ = RTImage::createFromFile ("folder-open-small.png");
inetwork = Gdk::Pixbuf::create(inetwork_, 0, 0, inetwork_->get_width(), inetwork_->get_height());
//Create the Tree model: //Create the Tree model:
dirTreeModel = Gtk::TreeStore::create(dtColumns); dirTreeModel = Gtk::TreeStore::create(dtColumns);

View File

@@ -48,12 +48,9 @@ ExifPanel::ExifPanel () : idata (nullptr)
exifTree->set_grid_lines (Gtk::TREE_VIEW_GRID_LINES_NONE); exifTree->set_grid_lines (Gtk::TREE_VIEW_GRID_LINES_NONE);
exifTree->set_row_separator_func (sigc::mem_fun(*this, &ExifPanel::rowSeperatorFunc)); exifTree->set_row_separator_func (sigc::mem_fun(*this, &ExifPanel::rowSeperatorFunc));
Cairo::RefPtr<Cairo::ImageSurface> delicon_ = RTImage::createFromFile ("cancel-small.png"); delicon = RTImage::createPixbufFromFile ("cancel-small.png");
delicon = Gdk::Pixbuf::create(delicon_, 0, 0, delicon_->get_width(), delicon_->get_height()); keepicon = RTImage::createPixbufFromFile ("tick-small.png");
Cairo::RefPtr<Cairo::ImageSurface> keepicon_ = RTImage::createFromFile ("tick-small.png"); editicon = RTImage::createPixbufFromFile ("add-small.png");
keepicon = Gdk::Pixbuf::create(keepicon_, 0, 0, keepicon_->get_width(), keepicon_->get_height());
Cairo::RefPtr<Cairo::ImageSurface> editicon_ = RTImage::createFromFile ("add-small.png");
editicon = Gdk::Pixbuf::create(editicon_, 0, 0, editicon_->get_width(), editicon_->get_height());
Gtk::TreeView::Column *viewcol = Gtk::manage (new Gtk::TreeView::Column ("Field Name")); Gtk::TreeView::Column *viewcol = Gtk::manage (new Gtk::TreeView::Column ("Field Name"));
Gtk::CellRendererPixbuf* render_pb = Gtk::manage (new Gtk::CellRendererPixbuf ()); Gtk::CellRendererPixbuf* render_pb = Gtk::manage (new Gtk::CellRendererPixbuf ());

View File

@@ -59,9 +59,9 @@ private:
add (isSeparator); add (isSeparator);
} }
}; };
Glib::RefPtr<Gdk::Pixbuf> delicon; Glib::RefPtr<Gdk::Pixbuf> delicon;
Glib::RefPtr<Gdk::Pixbuf> keepicon; Glib::RefPtr<Gdk::Pixbuf> keepicon;
Glib::RefPtr<Gdk::Pixbuf> editicon; Glib::RefPtr<Gdk::Pixbuf> editicon;
ExifColumns exifColumns; ExifColumns exifColumns;
Gtk::TreeView* exifTree; Gtk::TreeView* exifTree;

View File

@@ -33,11 +33,11 @@
//extern Glib::Threads::Thread* mainThread; //extern Glib::Threads::Thread* mainThread;
bool FileBrowserEntry::iconsLoaded(false); bool FileBrowserEntry::iconsLoaded(false);
Cairo::RefPtr<Cairo::ImageSurface> FileBrowserEntry::editedIcon; Glib::RefPtr<Gdk::Pixbuf> FileBrowserEntry::editedIcon;
Cairo::RefPtr<Cairo::ImageSurface> FileBrowserEntry::recentlySavedIcon; Glib::RefPtr<Gdk::Pixbuf> FileBrowserEntry::recentlySavedIcon;
Cairo::RefPtr<Cairo::ImageSurface> FileBrowserEntry::enqueuedIcon; Glib::RefPtr<Gdk::Pixbuf> FileBrowserEntry::enqueuedIcon;
Cairo::RefPtr<Cairo::ImageSurface> FileBrowserEntry::hdr; Glib::RefPtr<Gdk::Pixbuf> FileBrowserEntry::hdr;
Cairo::RefPtr<Cairo::ImageSurface> FileBrowserEntry::ps; Glib::RefPtr<Gdk::Pixbuf> FileBrowserEntry::ps;
FileBrowserEntry::FileBrowserEntry (Thumbnail* thm, const Glib::ustring& fname) FileBrowserEntry::FileBrowserEntry (Thumbnail* thm, const Glib::ustring& fname)
: ThumbBrowserEntryBase (fname), wasInside(false), iatlistener(nullptr), press_x(0), press_y(0), action_x(0), action_y(0), rot_deg(0.0), landscape(true), cropgl(nullptr), state(SNormal), crop_custom_ratio(0.f) : ThumbBrowserEntryBase (fname), wasInside(false), iatlistener(nullptr), press_x(0), press_y(0), action_x(0), action_y(0), rot_deg(0.0), landscape(true), cropgl(nullptr), state(SNormal), crop_custom_ratio(0.f)
@@ -56,11 +56,11 @@ FileBrowserEntry::FileBrowserEntry (Thumbnail* thm, const Glib::ustring& fname)
scale = 1; scale = 1;
if (!iconsLoaded) { if (!iconsLoaded) {
editedIcon = RTImage::createFromFile ("tick-small.png"); editedIcon = RTImage::createPixbufFromFile ("tick-small.png");
recentlySavedIcon = RTImage::createFromFile ("save-small.png"); recentlySavedIcon = RTImage::createPixbufFromFile ("save-small.png");
enqueuedIcon = RTImage::createFromFile ("gears-small.png"); enqueuedIcon = RTImage::createPixbufFromFile ("gears-small.png");
hdr = RTImage::createFromFile ("filetype-hdr.png"); hdr = RTImage::createPixbufFromFile ("filetype-hdr.png");
ps = RTImage::createFromFile ("filetype-ps.png"); ps = RTImage::createPixbufFromFile ("filetype-ps.png");
iconsLoaded = true; iconsLoaded = true;
} }
@@ -117,10 +117,10 @@ void FileBrowserEntry::calcThumbnailSize ()
} }
} }
std::vector<Cairo::RefPtr<Cairo::ImageSurface> > FileBrowserEntry::getIconsOnImageArea () std::vector<Glib::RefPtr<Gdk::Pixbuf> > FileBrowserEntry::getIconsOnImageArea ()
{ {
std::vector<Cairo::RefPtr<Cairo::ImageSurface> > ret; std::vector<Glib::RefPtr<Gdk::Pixbuf> > ret;
if (!thumbnail) { if (!thumbnail) {
return ret; return ret;
@@ -141,10 +141,10 @@ std::vector<Cairo::RefPtr<Cairo::ImageSurface> > FileBrowserEntry::getIconsOnIma
return ret; return ret;
} }
std::vector<Cairo::RefPtr<Cairo::ImageSurface> > FileBrowserEntry::getSpecificityIconsOnImageArea () std::vector<Glib::RefPtr<Gdk::Pixbuf> > FileBrowserEntry::getSpecificityIconsOnImageArea ()
{ {
std::vector<Cairo::RefPtr<Cairo::ImageSurface> > ret; std::vector<Glib::RefPtr<Gdk::Pixbuf> > ret;
if (!thumbnail) { if (!thumbnail) {
return ret; return ret;

View File

@@ -71,11 +71,11 @@ class FileBrowserEntry : public ThumbBrowserEntryBase,
public: public:
static Cairo::RefPtr<Cairo::ImageSurface> editedIcon; static Glib::RefPtr<Gdk::Pixbuf> editedIcon;
static Cairo::RefPtr<Cairo::ImageSurface> recentlySavedIcon; static Glib::RefPtr<Gdk::Pixbuf> recentlySavedIcon;
static Cairo::RefPtr<Cairo::ImageSurface> enqueuedIcon; static Glib::RefPtr<Gdk::Pixbuf> enqueuedIcon;
static Cairo::RefPtr<Cairo::ImageSurface> hdr; static Glib::RefPtr<Gdk::Pixbuf> hdr;
static Cairo::RefPtr<Cairo::ImageSurface> ps; static Glib::RefPtr<Gdk::Pixbuf> ps;
FileBrowserEntry (Thumbnail* thm, const Glib::ustring& fname); FileBrowserEntry (Thumbnail* thm, const Glib::ustring& fname);
~FileBrowserEntry () override; ~FileBrowserEntry () override;
@@ -92,8 +92,8 @@ public:
void refreshQuickThumbnailImage () override; void refreshQuickThumbnailImage () override;
void calcThumbnailSize () override; void calcThumbnailSize () override;
std::vector<Cairo::RefPtr<Cairo::ImageSurface> > getIconsOnImageArea () override; std::vector<Glib::RefPtr<Gdk::Pixbuf> > getIconsOnImageArea () override;
std::vector<Cairo::RefPtr<Cairo::ImageSurface> > getSpecificityIconsOnImageArea () override; std::vector<Glib::RefPtr<Gdk::Pixbuf> > getSpecificityIconsOnImageArea () override;
void getIconSize (int& w, int& h) override; void getIconSize (int& w, int& h) override;
// thumbnaillistener interface // thumbnaillistener interface

View File

@@ -564,7 +564,7 @@ void MyExpander::init()
MyExpander::MyExpander(bool useEnabled, Gtk::Widget* titleWidget) : MyExpander::MyExpander(bool useEnabled, Gtk::Widget* titleWidget) :
enabled(false), inconsistent(false), flushEvent(false), expBox(nullptr), enabled(false), inconsistent(false), flushEvent(false), expBox(nullptr),
child(nullptr), headerWidget(nullptr), child(nullptr), headerWidget(nullptr), statusImage(nullptr),
label(nullptr), useEnabled(useEnabled) label(nullptr), useEnabled(useEnabled)
{ {
set_spacing(0); set_spacing(0);
@@ -760,12 +760,12 @@ void MyExpander::set_inconsistent(bool isInconsistent)
if (useEnabled) { if (useEnabled) {
if (isInconsistent) { if (isInconsistent) {
statusImage->from(inconsistentImage); statusImage->set(inconsistentImage->get_pixbuf());
} else { } else {
if (enabled) { if (enabled) {
statusImage->from(enabledImage); statusImage->set(enabledImage->get_pixbuf());
} else { } else {
statusImage->from(disabledImage); statusImage->set(disabledImage->get_pixbuf());
} }
} }
} }
@@ -791,14 +791,14 @@ void MyExpander::setEnabled(bool isEnabled)
enabled = false; enabled = false;
if (!inconsistent) { if (!inconsistent) {
statusImage->from(disabledImage); statusImage->set(disabledImage->get_pixbuf());
message.emit(); message.emit();
} }
} else { } else {
enabled = true; enabled = true;
if (!inconsistent) { if (!inconsistent) {
statusImage->from(enabledImage); statusImage->set(enabledImage->get_pixbuf());
message.emit(); message.emit();
} }
} }
@@ -834,9 +834,9 @@ void MyExpander::set_expanded( bool expanded )
if (!useEnabled) { if (!useEnabled) {
if (expanded ) { if (expanded ) {
statusImage->from(openedImage); statusImage->set(openedImage->get_pixbuf());
} else { } else {
statusImage->from(closedImage); statusImage->set(closedImage->get_pixbuf());
} }
} }
@@ -879,9 +879,9 @@ bool MyExpander::on_toggle(GdkEventButton* event)
if (!useEnabled) { if (!useEnabled) {
if (isVisible) { if (isVisible) {
statusImage->from(closedImage); statusImage->set(closedImage->get_pixbuf());
} else { } else {
statusImage->from(openedImage); statusImage->set(openedImage->get_pixbuf());
} }
} }
@@ -906,10 +906,10 @@ bool MyExpander::on_enabled_change(GdkEventButton* event)
if (event->button == 1) { if (event->button == 1) {
if (enabled) { if (enabled) {
enabled = false; enabled = false;
statusImage->from(disabledImage); statusImage->set(disabledImage->get_pixbuf());
} else { } else {
enabled = true; enabled = true;
statusImage->from(enabledImage); statusImage->set(enabledImage->get_pixbuf());
} }
message.emit(); message.emit();

View File

@@ -65,6 +65,8 @@ Glib::ustring argv2;
bool simpleEditor = false; bool simpleEditor = false;
bool gimpPlugin = false; bool gimpPlugin = false;
bool remote = false; bool remote = false;
unsigned char scale = 1;
float fontScale = 1.f;
Glib::RefPtr<Gtk::CssProvider> cssForced; Glib::RefPtr<Gtk::CssProvider> cssForced;
Glib::RefPtr<Gtk::CssProvider> cssRT; Glib::RefPtr<Gtk::CssProvider> cssRT;
//Glib::Threads::Thread* mainThread; //Glib::Threads::Thread* mainThread;
@@ -316,17 +318,62 @@ RTWindow *create_rt_window()
} }
// Set the font face and size // Set the font face and size
Glib::ustring css;
if (options.fontFamily != "default") { if (options.fontFamily != "default") {
//GTK318
#if GTK_MAJOR_VERSION == 3 && GTK_MINOR_VERSION < 20
css = Glib::ustring::compose ("* { font-family: %1; font-size: %2px }", options.fontFamily, options.fontSize * scale);
#else
css = Glib::ustring::compose ("* { font-family: %1; font-size: %2pt }", options.fontFamily, options.fontSize * scale);
#endif
//GTK318
fontScale = options.fontSize / 9;
} else if (scale == 2) {
Glib::RefPtr<Gtk::StyleContext> style = Gtk::StyleContext::create();
Pango::FontDescription pfd = style->get_font(Gtk::STATE_FLAG_NORMAL);
if (pfd.get_set_fields() & Pango::FONT_MASK_SIZE) {
int fontSize = pfd.get_size();
bool isPix = pfd.get_size_is_absolute();
printf("FONT SIZE = %d pt\n", fontSize);
double r = style->get_screen()->get_resolution();
printf("RESOLUTION = %.3f\n", r);
if (isPix) {
// 1pt = 0.3527mm @ 96 ppi
double resolution = style->get_screen()->get_resolution();
// px >inch >mm >pt >"scaled pt"
int pt = (int)(fontSize / 96. * 25.4 / 0.3527 * (96. / resolution) + 0.49);
// if resolution is lower than 192ppi, we're supposing that it's already expressed in a scale==1 scenario
if (resolution >= 192) {
// it's already scaled up, no need to set the font size
resolution /= 2.; // Reducing the value for a scale==1 case
pt /= 2.;
} else {
// fontSize is for scale==1, we have to scale up
css = Glib::ustring::compose ("* { font-size: %1px }", pt * scale);
}
fontScale = pt / 9;
} else {
int pt = fontSize / Pango::SCALE;
css = Glib::ustring::compose ("* { font-size: %1pt }", pt * scale);
fontScale = pt / 9;
}
} else {
printf("La taille n'est pas specifiee\n");
fontScale = 1.f;
}
}
if (!css.empty()) {
printf("CSS: %s", css.c_str());
try { try {
cssForced = Gtk::CssProvider::create(); cssForced = Gtk::CssProvider::create();
//GTK318 cssForced->load_from_data (css);
#if GTK_MAJOR_VERSION == 3 && GTK_MINOR_VERSION < 20
cssForced->load_from_data (Glib::ustring::compose ("* { font-family: %1; font-size: %2px }", options.fontFamily, options.fontSize));
#else
cssForced->load_from_data (Glib::ustring::compose ("* { font-family: %1; font-size: %2pt }", options.fontFamily, options.fontSize));
#endif
//GTK318
Gtk::StyleContext::add_provider_for_screen (screen, cssForced, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION); Gtk::StyleContext::add_provider_for_screen (screen, cssForced, GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
} catch (Glib::Error &err) { } catch (Glib::Error &err) {
printf ("Error: \"%s\"\n", err.what().c_str()); printf ("Error: \"%s\"\n", err.what().c_str());
} catch (...) { } catch (...) {
@@ -346,7 +393,6 @@ RTWindow *create_rt_window()
//gdk_threads_enter (); //gdk_threads_enter ();
RTWindow *rtWindow = new RTWindow(); RTWindow *rtWindow = new RTWindow();
return rtWindow; return rtWindow;
} }
@@ -471,6 +517,12 @@ int main (int argc, char **argv)
Glib::init(); // called by Gtk::Main, but this may be important for thread handling, so we call it ourselves now Glib::init(); // called by Gtk::Main, but this may be important for thread handling, so we call it ourselves now
Gio::init (); Gio::init ();
const gchar *gscale = g_getenv("GDK_SCALE");
if (gscale && gscale[0] == '2') {
scale = 2;
g_setenv("GDK_SCALE", "1", true);
}
#ifdef WIN32 #ifdef WIN32
if (GetFileType (GetStdHandle (STD_OUTPUT_HANDLE)) == 0x0003) { if (GetFileType (GetStdHandle (STD_OUTPUT_HANDLE)) == 0x0003) {
// started from msys2 console => do not buffer stdout // started from msys2 console => do not buffer stdout

View File

@@ -28,7 +28,8 @@
namespace namespace
{ {
std::map<std::string, Cairo::RefPtr<Cairo::ImageSurface>> surfaceCache; std::map<std::string, Glib::RefPtr<Gdk::Pixbuf> > pixbufCache;
std::map<std::string, Cairo::RefPtr<Cairo::ImageSurface> > surfaceCache;
} }
@@ -37,14 +38,22 @@ int RTImage::scaleBack = 0;
RTImage::RTImage () {} RTImage::RTImage () {}
RTImage::RTImage (const Glib::ustring& fileName, const Glib::ustring& rtlFileName)
{
setImage (fileName, rtlFileName);
}
RTImage::RTImage (RTImage &other) RTImage::RTImage (RTImage &other)
{ {
from(&other); dpiBack = other.dpiBack;
scaleBack = other.scaleBack;
pixbuf = other.pixbuf;
surface = other.surface;
if (pixbuf) {
set(pixbuf);
} else if (surface) {
set(surface);
}
}
RTImage::RTImage (const Glib::ustring& fileName, const Glib::ustring& rtlFileName) : Gtk::Image()
{
setImage (fileName, rtlFileName);
} }
RTImage::RTImage (Glib::RefPtr<Gdk::Pixbuf> &pixbuf) RTImage::RTImage (Glib::RefPtr<Gdk::Pixbuf> &pixbuf)
@@ -54,13 +63,6 @@ RTImage::RTImage (Glib::RefPtr<Gdk::Pixbuf> &pixbuf)
} }
} }
RTImage::RTImage (Glib::RefPtr<RTImage> &other)
{
if (other) {
from(other.get());
}
}
void RTImage::setImage (const Glib::ustring& fileName, const Glib::ustring& rtlFileName) void RTImage::setImage (const Glib::ustring& fileName, const Glib::ustring& rtlFileName)
{ {
Glib::ustring imageName; Glib::ustring imageName;
@@ -92,15 +94,22 @@ void RTImage::changeImage (const Glib::ustring& imageName)
{ {
clear (); clear ();
auto iterator = surfaceCache.find (imageName); if (pixbuf) {
auto iterator = pixbufCache.find (imageName);
if (iterator == surfaceCache.end ()) { printf("changeImage / pixbufCache[%d] : \"%s\" %s!\n", (int)(pixbufCache.size()), imageName.c_str(), iterator == pixbufCache.end () ? "not found" : "found");
const auto pixbuf = createFromFile(imageName); assert(iterator != pixbufCache.end ());
iterator = surfaceCache.emplace (imageName, pixbuf).first; pixbuf = iterator->second;
set(iterator->second);
} else { // if no Pixbuf is set, we update or create a Cairo::ImageSurface
auto iterator = surfaceCache.find (imageName);
printf("changeImage / surfaceCache[%d] : \"%s\" %s!\n", (int)(surfaceCache.size()), imageName.c_str(), iterator == surfaceCache.end () ? "not found" : "found");
if (iterator == surfaceCache.end ()) {
auto surf = createImgSurfFromFile(imageName);
iterator = surfaceCache.emplace (imageName, surf).first;
}
surface = iterator->second;
set(iterator->second);
} }
surface = iterator->second;
set(iterator->second);
} }
void RTImage::init() void RTImage::init()
@@ -111,36 +120,26 @@ void RTImage::init()
void RTImage::updateImages() void RTImage::updateImages()
{ {
for (auto& entry : pixbufCache) {
entry.second = createPixbufFromFile(entry.first);
}
for (auto& entry : surfaceCache) { for (auto& entry : surfaceCache) {
entry.second = createFromFile(entry.first); entry.second = createImgSurfFromFile(entry.first);
} }
} }
void RTImage::from(RTImage* other) Glib::RefPtr<Gdk::Pixbuf> RTImage::createPixbufFromFile (const Glib::ustring& fileName)
{ {
if (!other) { Cairo::RefPtr<Cairo::ImageSurface> imgSurf = createImgSurfFromFile(fileName);
return; Glib::RefPtr<Gdk::Pixbuf> pixbuf = Gdk::Pixbuf::create(imgSurf, 0, 0, imgSurf->get_width(), imgSurf->get_height());
} return pixbuf;
if (other->get_pixbuf()) {
set(other->get_pixbuf());
} else {
surface = other->surface;
set(surface);
}
} }
void RTImage::from(Glib::RefPtr<RTImage> other) Cairo::RefPtr<Cairo::ImageSurface> RTImage::createImgSurfFromFile (const Glib::ustring& fileName)
{
if (other) {
from (other.get());
}
}
Cairo::RefPtr<Cairo::ImageSurface> RTImage::createFromFile (const Glib::ustring& fileName)
{ {
Cairo::RefPtr<Cairo::ImageSurface> surf; Cairo::RefPtr<Cairo::ImageSurface> surf;
printf("Creating \"%s\"\n", fileName.c_str());
try { try {
double requestedDPI = getDPI(); double requestedDPI = getDPI();
@@ -161,6 +160,8 @@ Cairo::RefPtr<Cairo::ImageSurface> RTImage::createFromFile (const Glib::ustring&
resizeImage(surf, getDPI() / requestedDPI); resizeImage(surf, getDPI() / requestedDPI);
} }
// HOMBRE: As of now, GDK_SCALE is forced to 1, so setting the Cairo::ImageSurface scale is not required
/*
double x=0., y=0.; double x=0., y=0.;
cairo_surface_get_device_scale(surf->cobj(), &x, &y); cairo_surface_get_device_scale(surf->cobj(), &x, &y);
printf(" -> Cairo::ImageSurface is now %dx%d (scale: %.1f)\n", surf->get_width(), surf->get_height(), (float)x); printf(" -> Cairo::ImageSurface is now %dx%d (scale: %.1f)\n", surf->get_width(), surf->get_height(), (float)x);
@@ -170,6 +171,7 @@ Cairo::RefPtr<Cairo::ImageSurface> RTImage::createFromFile (const Glib::ustring&
surf->flush(); surf->flush();
printf(" Cairo::ImageSurface is now %dx%d (scale: %.1f)\n", surf->get_width(), surf->get_height(), (float)x); printf(" Cairo::ImageSurface is now %dx%d (scale: %.1f)\n", surf->get_width(), surf->get_height(), (float)x);
} }
*/
} catch (const Glib::Exception& exception) { } catch (const Glib::Exception& exception) {
if (options.rtSettings.verbose) { if (options.rtSettings.verbose) {
std::cerr << "Failed to load image \"" << fileName << "\": " << exception.what() << std::endl; std::cerr << "Failed to load image \"" << fileName << "\": " << exception.what() << std::endl;
@@ -178,9 +180,3 @@ Cairo::RefPtr<Cairo::ImageSurface> RTImage::createFromFile (const Glib::ustring&
return surf; return surf;
} }
/*
bool RTImage::on_configure_event(GdkEventConfigure* configure_event)
{
}
*/

View File

@@ -33,11 +33,13 @@ class RTImage : public Gtk::Image, public RTScalable
protected: protected:
Cairo::RefPtr<Cairo::ImageSurface> surface; Cairo::RefPtr<Cairo::ImageSurface> surface;
Glib::RefPtr<Gdk::Pixbuf> pixbuf;
public: public:
RTImage (); RTImage ();
RTImage (RTImage &other); RTImage (RTImage &other);
RTImage (Glib::RefPtr<Gdk::Pixbuf> &pixbuf); RTImage (Glib::RefPtr<Gdk::Pixbuf> &pixbuf);
RTImage(Cairo::RefPtr<Cairo::ImageSurface> other);
RTImage (Glib::RefPtr<RTImage> &other); RTImage (Glib::RefPtr<RTImage> &other);
RTImage (const Glib::ustring& fileName, const Glib::ustring& rtlFileName = Glib::ustring()); RTImage (const Glib::ustring& fileName, const Glib::ustring& rtlFileName = Glib::ustring());
@@ -49,8 +51,7 @@ public:
static void setDPInScale (const double newDPI, const int newScale); static void setDPInScale (const double newDPI, const int newScale);
static void setScale (const int newScale); static void setScale (const int newScale);
static Cairo::RefPtr<Cairo::ImageSurface> createFromFile (const Glib::ustring& fileName); static Glib::RefPtr<Gdk::Pixbuf> createPixbufFromFile (const Glib::ustring& fileName);
static Cairo::RefPtr<Cairo::ImageSurface> createImgSurfFromFile (const Glib::ustring& fileName);
void from(RTImage* other);
void from(Glib::RefPtr<RTImage> other);
}; };

View File

@@ -22,6 +22,8 @@
double RTScalable::dpi = 0.; double RTScalable::dpi = 0.;
int RTScalable::scale = 0; int RTScalable::scale = 0;
extern float fontScale;
extern unsigned char scale;
Gtk::TextDirection RTScalable::direction = Gtk::TextDirection::TEXT_DIR_NONE; Gtk::TextDirection RTScalable::direction = Gtk::TextDirection::TEXT_DIR_NONE;
void RTScalable::setDPInScale (const double newDPI, const int newScale) void RTScalable::setDPInScale (const double newDPI, const int newScale)
@@ -30,14 +32,17 @@ void RTScalable::setDPInScale (const double newDPI, const int newScale)
// reload all images // reload all images
scale = newScale; scale = newScale;
// HOMBRE: On windows, if scale = 2, the dpi is non significant, i.e. should be considered = 192 ; don't know for linux/macos // HOMBRE: On windows, if scale = 2, the dpi is non significant, i.e. should be considered = 192 ; don't know for linux/macos
dpi = scale == 2 ? 192 : newDPI; dpi = newDPI;
if (scale == 2 && newDPI < 192) {
dpi *= 2;
}
printf("RTScalable::setDPInScale / New scale = %d & new DPI = %.3f (%.3f asked) -> Reloading all RTScalable\n", scale, dpi, newDPI); printf("RTScalable::setDPInScale / New scale = %d & new DPI = %.3f (%.3f asked) -> Reloading all RTScalable\n", scale, dpi, newDPI);
} }
} }
double RTScalable::getDPI () double RTScalable::getDPI ()
{ {
return dpi; return dpi * fontScale;
} }
int RTScalable::getScale () int RTScalable::getScale ()
@@ -53,11 +58,15 @@ Gtk::TextDirection RTScalable::getDirection()
void RTScalable::init(Gtk::Window *window) void RTScalable::init(Gtk::Window *window)
{ {
printf("RTScalable::init\n"); printf("RTScalable::init\n");
setDPInScale(window->get_screen()->get_resolution(), window->get_scale_factor()); setDPInScale(window->get_screen()->get_resolution(), ::scale);
direction = window->get_direction();
} }
void RTScalable::resizeImage(Cairo::RefPtr<Cairo::ImageSurface> &surf, double factor) void RTScalable::resizeImage(Cairo::RefPtr<Cairo::ImageSurface> &surf, double factor)
{ {
if (options.fontFamily != "default") {
factor *= options.fontSize / 9;
}
int newWidth = int((double)surf->get_width() * factor); int newWidth = int((double)surf->get_width() * factor);
int newHeight = int((double)surf->get_height() * factor); int newHeight = int((double)surf->get_height() * factor);
printf("Resizing from %dx%d to %dx%d (factor: %.5f)\n", surf->get_width(), surf->get_height(), newWidth, newHeight, factor); printf("Resizing from %dx%d to %dx%d (factor: %.5f)\n", surf->get_width(), surf->get_height(), newWidth, newHeight, factor);

View File

@@ -32,7 +32,7 @@ class RTScalable
protected: protected:
static void setDPInScale (const double newDPI, const int newScale); static void setDPInScale (const double newDPI, const int newScale);
static double getDPI (); static double getDPI (); // The returned value is tweaked DPI to adapt to main the font size. Maybe not an ideal solution.
static int getScale (); static int getScale ();
static void resizeImage(Cairo::RefPtr<Cairo::ImageSurface> &surf, double factor); static void resizeImage(Cairo::RefPtr<Cairo::ImageSurface> &surf, double factor);
Gtk::TextDirection getDirection(); Gtk::TextDirection getDirection();

View File

@@ -33,11 +33,17 @@ std::map<std::string, Cairo::RefPtr<Cairo::ImageSurface>> surfaceCache;
double RTSurface::dpiBack = 0.; double RTSurface::dpiBack = 0.;
int RTSurface::scaleBack = 0; int RTSurface::scaleBack = 0;
RTSurface::RTSurface () : RTScalable() { RTSurface::RTSurface () : RTScalable()
{
Cairo::RefPtr<Cairo::ImageSurface> imgSurf(new Cairo::ImageSurface(nullptr, false)); Cairo::RefPtr<Cairo::ImageSurface> imgSurf(new Cairo::ImageSurface(nullptr, false));
surface = imgSurf; surface = imgSurf;
} }
RTSurface::RTSurface(const RTSurface& other) : RTScalable()
{
surface = other.surface;
}
RTSurface::RTSurface (Glib::ustring fileName, Glib::ustring rtlFileName) : RTScalable() RTSurface::RTSurface (Glib::ustring fileName, Glib::ustring rtlFileName) : RTScalable()
{ {
Cairo::RefPtr<Cairo::ImageSurface> imgSurf(new Cairo::ImageSurface(nullptr, false)); Cairo::RefPtr<Cairo::ImageSurface> imgSurf(new Cairo::ImageSurface(nullptr, false));
@@ -84,6 +90,8 @@ void RTSurface::changeImage (Glib::ustring imageName)
resizeImage(surface, getDPI() / requestedDPI); resizeImage(surface, getDPI() / requestedDPI);
} }
// HOMBRE: As of now, GDK_SCALE is forced to 1, so setting the Cairo::ImageSurface scale is not required
/*
double x=0., y=0.; double x=0., y=0.;
cairo_surface_get_device_scale(surface->cobj(), &x, &y); cairo_surface_get_device_scale(surface->cobj(), &x, &y);
printf(" -> Cairo::ImageSurface is now %dx%d (scale: %.1f)\n", surface->get_width(), surface->get_height(), (float)x); printf(" -> Cairo::ImageSurface is now %dx%d (scale: %.1f)\n", surface->get_width(), surface->get_height(), (float)x);
@@ -93,6 +101,7 @@ void RTSurface::changeImage (Glib::ustring imageName)
surface->flush(); surface->flush();
printf(" Cairo::ImageSurface is now %dx%d (scale: %.1f)\n", surface->get_width(), surface->get_height(), (float)x); printf(" Cairo::ImageSurface is now %dx%d (scale: %.1f)\n", surface->get_width(), surface->get_height(), (float)x);
} }
*/
iterator = surfaceCache.emplace (imageName, surface).first; iterator = surfaceCache.emplace (imageName, surface).first;
} }
@@ -100,12 +109,12 @@ void RTSurface::changeImage (Glib::ustring imageName)
surface = iterator->second; surface = iterator->second;
} }
int RTSurface::getWidth() int RTSurface::getWidth() const
{ {
return surface ? surface->get_width() : -1; return surface ? surface->get_width() : -1;
} }
int RTSurface::getHeight() int RTSurface::getHeight() const
{ {
return surface ? surface->get_height() : -1; return surface ? surface->get_height() : -1;
} }
@@ -130,3 +139,8 @@ void RTSurface::from(Glib::RefPtr<RTSurface> other)
{ {
surface = other->surface; surface = other->surface;
} }
bool RTSurface::hasSurface() const
{
return surface ? true : false;
}

View File

@@ -33,12 +33,14 @@ public:
Cairo::RefPtr<Cairo::ImageSurface> surface; Cairo::RefPtr<Cairo::ImageSurface> surface;
RTSurface (); RTSurface ();
RTSurface (const RTSurface& other);
RTSurface (Glib::ustring fileName, Glib::ustring rtlFileName = Glib::ustring()); RTSurface (Glib::ustring fileName, Glib::ustring rtlFileName = Glib::ustring());
void setImage (Glib::ustring fileName, Glib::ustring rtlFileName = Glib::ustring()); void setImage (Glib::ustring fileName, Glib::ustring rtlFileName = Glib::ustring());
void changeImage (Glib::ustring imageName); void changeImage (Glib::ustring imageName);
int getWidth(); int getWidth() const;
int getHeight(); int getHeight() const;
bool hasSurface() const;
static void init(); static void init();
static void updateImages (); static void updateImages ();

View File

@@ -25,9 +25,10 @@
#include "cursormanager.h" #include "cursormanager.h"
#include "rtimage.h" #include "rtimage.h"
#include "whitebalance.h" #include "whitebalance.h"
#include "rtscalable.h"
#include "../rtengine/icons.h" #include "../rtengine/icons.h"
extern int scale;
#if defined(__APPLE__) #if defined(__APPLE__)
static gboolean static gboolean
osx_should_quit_cb (GtkosxApplication *app, gpointer data) osx_should_quit_cb (GtkosxApplication *app, gpointer data)
@@ -101,11 +102,11 @@ RTWindow::RTWindow ()
#ifndef WIN32 #ifndef WIN32
const std::vector<Glib::RefPtr<Gdk::Pixbuf>> appIcons = { const std::vector<Glib::RefPtr<Gdk::Pixbuf>> appIcons = {
RTImage::createFromFile("rawtherapee-logo-16.png"), RTImage::createPixbufFromFile("rawtherapee-logo-16.png"),
RTImage::createFromFile("rawtherapee-logo-24.png"), RTImage::createPixbufFromFile("rawtherapee-logo-24.png"),
RTImage::createFromFile("rawtherapee-logo-48.png"), RTImage::createPixbufFromFile("rawtherapee-logo-48.png"),
RTImage::createFromFile("rawtherapee-logo-128.png"), RTImage::createPixbufFromFile("rawtherapee-logo-128.png"),
RTImage::createFromFile("rawtherapee-logo-256.png") RTImage::createPixbufFromFile("rawtherapee-logo-256.png")
}; };
try { try {
set_default_icon_list(appIcons); set_default_icon_list(appIcons);
@@ -406,7 +407,8 @@ bool RTWindow::on_configure_event (GdkEventConfigure* event)
} }
printf("RTWindow::on_configure_event : May update the RTImage and RTSurface\n"); printf("RTWindow::on_configure_event : May update the RTImage and RTSurface\n");
int newScale = get_window()->get_scale_factor(); int newScale = scale;
printf("********** scale = %d / get_window()->get_scale_factor() = %d\n", scale, get_window()->get_scale_factor());
double newDPI = get_window()->get_screen()->get_resolution(); double newDPI = get_window()->get_screen()->get_resolution();
RTImage::setDPInScale(newDPI, newScale); // will update the RTImage on scale/resolution change RTImage::setDPInScale(newDPI, newScale); // will update the RTImage on scale/resolution change
RTSurface::setDPInScale(newDPI, newScale); // will update the RTSurface on scale/resolution change RTSurface::setDPInScale(newDPI, newScale); // will update the RTSurface on scale/resolution change

View File

@@ -29,7 +29,7 @@ extern Glib::ustring versionString;
SplashImage::SplashImage () SplashImage::SplashImage ()
{ {
surface = RTImage::createFromFile ("splash.png"); surface = RTImage::createImgSurfFromFile ("splash.png");
} }
bool SplashImage::on_draw(const ::Cairo::RefPtr< Cairo::Context> &cr) bool SplashImage::on_draw(const ::Cairo::RefPtr< Cairo::Context> &cr)

View File

@@ -315,7 +315,7 @@ void ThumbBrowserEntryBase::updateBackBuffer ()
for (size_t i = 0; i < bbIcons.size(); i++) { for (size_t i = 0; i < bbIcons.size(); i++) {
// Draw the image at 110, 90, except for the outermost 10 pixels. // Draw the image at 110, 90, except for the outermost 10 pixels.
cc->set_source(bbIcons[i], istartx, istarty); Gdk::Cairo::set_source_pixbuf(cc, bbIcons[i], istartx, istarty);
cc->rectangle(istartx, istarty, bbIcons[i]->get_width(), bbIcons[i]->get_height()); cc->rectangle(istartx, istarty, bbIcons[i]->get_width(), bbIcons[i]->get_height());
cc->fill(); cc->fill();
istartx += bbIcons[i]->get_width() + igap; istartx += bbIcons[i]->get_width() + igap;
@@ -329,7 +329,7 @@ void ThumbBrowserEntryBase::updateBackBuffer ()
for (size_t i = 0; i < bbSpecificityIcons.size(); ++i) { for (size_t i = 0; i < bbSpecificityIcons.size(); ++i) {
istartx2 -= bbSpecificityIcons[i]->get_width() - igap; istartx2 -= bbSpecificityIcons[i]->get_width() - igap;
cc->set_source(bbSpecificityIcons[i], istartx2, istarty2 - bbSpecificityIcons[i]->get_height()); Gdk::Cairo::set_source_pixbuf(cc, bbSpecificityIcons[i], istartx2, istarty2 - bbSpecificityIcons[i]->get_height());
cc->rectangle(istartx2, istarty2 - bbSpecificityIcons[i]->get_height(), bbSpecificityIcons[i]->get_width(), bbSpecificityIcons[i]->get_height()); cc->rectangle(istartx2, istarty2 - bbSpecificityIcons[i]->get_height(), bbSpecificityIcons[i]->get_width(), bbSpecificityIcons[i]->get_height());
cc->fill(); cc->fill();
} }
@@ -700,14 +700,14 @@ bool ThumbBrowserEntryBase::insideWindow (int x, int y, int w, int h)
return !(ofsX + startx > x + w || ofsX + startx + exp_width < x || ofsY + starty > y + h || ofsY + starty + exp_height < y); return !(ofsX + startx > x + w || ofsX + startx + exp_width < x || ofsY + starty > y + h || ofsY + starty + exp_height < y);
} }
std::vector<Cairo::RefPtr<Cairo::ImageSurface> > ThumbBrowserEntryBase::getIconsOnImageArea() std::vector<Glib::RefPtr<Gdk::Pixbuf> > ThumbBrowserEntryBase::getIconsOnImageArea()
{ {
return std::vector<Cairo::RefPtr<Cairo::ImageSurface> >(); return std::vector<Glib::RefPtr<Gdk::Pixbuf> >();
} }
std::vector<Cairo::RefPtr<Cairo::ImageSurface> > ThumbBrowserEntryBase::getSpecificityIconsOnImageArea() std::vector<Glib::RefPtr<Gdk::Pixbuf> > ThumbBrowserEntryBase::getSpecificityIconsOnImageArea()
{ {
return std::vector<Cairo::RefPtr<Cairo::ImageSurface> >(); return std::vector<Glib::RefPtr<Gdk::Pixbuf> >();
} }
void ThumbBrowserEntryBase::getIconSize(int& w, int& h) void ThumbBrowserEntryBase::getIconSize(int& w, int& h)

View File

@@ -82,8 +82,8 @@ protected:
Glib::RefPtr<BackBuffer> backBuffer; Glib::RefPtr<BackBuffer> backBuffer;
bool bbSelected, bbFramed; bool bbSelected, bbFramed;
guint8* bbPreview; guint8* bbPreview;
std::vector<Cairo::RefPtr<Cairo::ImageSurface> > bbIcons; std::vector<Glib::RefPtr<Gdk::Pixbuf> > bbIcons;
std::vector<Cairo::RefPtr<Cairo::ImageSurface> > bbSpecificityIcons; std::vector<Glib::RefPtr<Gdk::Pixbuf> > bbSpecificityIcons;
CursorShape cursor_type; CursorShape cursor_type;
void drawFrame (Cairo::RefPtr<Cairo::Context> cr, const Gdk::RGBA& bg, const Gdk::RGBA& fg); void drawFrame (Cairo::RefPtr<Cairo::Context> cr, const Gdk::RGBA& bg, const Gdk::RGBA& fg);
@@ -188,8 +188,8 @@ public:
virtual void drawProgressBar (Glib::RefPtr<Gdk::Window> win, const Gdk::RGBA& foregr, const Gdk::RGBA& backgr, int x, int w, int y, int h) {} virtual void drawProgressBar (Glib::RefPtr<Gdk::Window> win, const Gdk::RGBA& foregr, const Gdk::RGBA& backgr, int x, int w, int y, int h) {}
virtual std::vector<Cairo::RefPtr<Cairo::ImageSurface> > getIconsOnImageArea (); virtual std::vector<Glib::RefPtr<Gdk::Pixbuf> > getIconsOnImageArea ();
virtual std::vector<Cairo::RefPtr<Cairo::ImageSurface> > getSpecificityIconsOnImageArea (); virtual std::vector<Glib::RefPtr<Gdk::Pixbuf> > getSpecificityIconsOnImageArea ();
virtual void getIconSize (int& w, int& h); virtual void getIconSize (int& w, int& h);
virtual bool motionNotify (int x, int y); virtual bool motionNotify (int x, int y);

View File

@@ -34,34 +34,34 @@
using namespace rtengine; using namespace rtengine;
using namespace rtengine::procparams; using namespace rtengine::procparams;
Glib::RefPtr<RTImage> WhiteBalance::wbIcon[toUnderlying(WBEntry::Type::CUSTOM) + 1]; Glib::RefPtr<Gdk::Pixbuf> WhiteBalance::wbPixbufs[toUnderlying(WBEntry::Type::CUSTOM) + 1];
/* /*
Glib::RefPtr<RTImage> WhiteBalance::wbCameraPB, WhiteBalance::wbAutoPB, WhiteBalance::wbSunPB, WhiteBalance::wbTungstenPB, Glib::RefPtr<Gdk::Pixbuf> WhiteBalance::wbCameraPB, WhiteBalance::wbAutoPB, WhiteBalance::wbSunPB, WhiteBalance::wbTungstenPB,
WhiteBalance::wbCloudyPB, WhiteBalance::wbShadePB, WhiteBalance::wbFluorescentPB, WhiteBalance::wbLampPB, WhiteBalance::wbCloudyPB, WhiteBalance::wbShadePB, WhiteBalance::wbFluorescentPB, WhiteBalance::wbLampPB,
WhiteBalance::wbFlashPB, WhiteBalance::wbLedPB, WhiteBalance::wbCustomPB; WhiteBalance::wbFlashPB, WhiteBalance::wbLedPB, WhiteBalance::wbCustomPB;
*/ */
void WhiteBalance::init () void WhiteBalance::init ()
{ {
wbIcon[toUnderlying(WBEntry::Type::CAMERA)] = Glib::RefPtr<RTImage>( new RTImage("wb-camera-small.png")); wbPixbufs[toUnderlying(WBEntry::Type::CAMERA)] = RTImage::createPixbufFromFile ("wb-camera-small.png");
wbIcon[toUnderlying(WBEntry::Type::AUTO)] = Glib::RefPtr<RTImage>( new RTImage("wb-auto-small.png")); wbPixbufs[toUnderlying(WBEntry::Type::AUTO)] = RTImage::createPixbufFromFile ("wb-auto-small.png");
wbIcon[toUnderlying(WBEntry::Type::DAYLIGHT)] = Glib::RefPtr<RTImage>( new RTImage("wb-sun-small.png")); wbPixbufs[toUnderlying(WBEntry::Type::DAYLIGHT)] = RTImage::createPixbufFromFile ("wb-sun-small.png");
wbIcon[toUnderlying(WBEntry::Type::CLOUDY)] = Glib::RefPtr<RTImage>( new RTImage("wb-cloudy-small.png")); wbPixbufs[toUnderlying(WBEntry::Type::CLOUDY)] = RTImage::createPixbufFromFile ("wb-cloudy-small.png");
wbIcon[toUnderlying(WBEntry::Type::SHADE)] = Glib::RefPtr<RTImage>( new RTImage("wb-shade-small.png")); wbPixbufs[toUnderlying(WBEntry::Type::SHADE)] = RTImage::createPixbufFromFile ("wb-shade-small.png");
wbIcon[toUnderlying(WBEntry::Type::WATER)] = Glib::RefPtr<RTImage>( new RTImage("wb-water-small.png")); wbPixbufs[toUnderlying(WBEntry::Type::WATER)] = RTImage::createPixbufFromFile ("wb-water-small.png");
//wbIcon[toUnderlying(WBEntry::Type::WATER2)] = Glib::RefPtr<RTImage>( new RTImage("wb-water-small.png")); //wbPixbufs[toUnderlying(WBEntry::Type::WATER2)] = RTImage::createPixbufFromFile ("wb-water-small.png");
wbIcon[toUnderlying(WBEntry::Type::TUNGSTEN)] = Glib::RefPtr<RTImage>( new RTImage("wb-tungsten-small.png")); wbPixbufs[toUnderlying(WBEntry::Type::TUNGSTEN)] = RTImage::createPixbufFromFile ("wb-tungsten-small.png");
wbIcon[toUnderlying(WBEntry::Type::FLUORESCENT)] = Glib::RefPtr<RTImage>( new RTImage("wb-fluorescent-small.png")); wbPixbufs[toUnderlying(WBEntry::Type::FLUORESCENT)] = RTImage::createPixbufFromFile ("wb-fluorescent-small.png");
wbIcon[toUnderlying(WBEntry::Type::LAMP)] = Glib::RefPtr<RTImage>( new RTImage("wb-lamp-small.png")); wbPixbufs[toUnderlying(WBEntry::Type::LAMP)] = RTImage::createPixbufFromFile ("wb-lamp-small.png");
wbIcon[toUnderlying(WBEntry::Type::FLASH)] = Glib::RefPtr<RTImage>( new RTImage("wb-flash-small.png")); wbPixbufs[toUnderlying(WBEntry::Type::FLASH)] = RTImage::createPixbufFromFile ("wb-flash-small.png");
wbIcon[toUnderlying(WBEntry::Type::LED)] = Glib::RefPtr<RTImage>( new RTImage("wb-led-small.png")); wbPixbufs[toUnderlying(WBEntry::Type::LED)] = RTImage::createPixbufFromFile ("wb-led-small.png");
wbIcon[toUnderlying(WBEntry::Type::CUSTOM)] = Glib::RefPtr<RTImage>( new RTImage("wb-custom-small.png")); wbPixbufs[toUnderlying(WBEntry::Type::CUSTOM)] = RTImage::createPixbufFromFile ("wb-custom-small.png");
} }
void WhiteBalance::cleanup () void WhiteBalance::cleanup ()
{ {
for (unsigned int i = 0; i < toUnderlying(WBEntry::Type::CUSTOM) + 1; i++) { for (unsigned int i = 0; i < toUnderlying(WBEntry::Type::CUSTOM) + 1; i++) {
wbIcon[i].reset(); wbPixbufs[i].reset();
} }
} }
@@ -175,7 +175,7 @@ WhiteBalance::WhiteBalance () : FoldableToolPanel(this, "whitebalance", M("TP_WB
if (currType == WBEntry::Type::FLUORESCENT) { if (currType == WBEntry::Type::FLUORESCENT) {
// Creating the Fluorescent subcategory header // Creating the Fluorescent subcategory header
row = *(refTreeModel->append()); row = *(refTreeModel->append());
row[methodColumns.colIcon] = wbIcon[toUnderlying(currType)]; row[methodColumns.colIcon] = wbPixbufs[toUnderlying(currType)];
row[methodColumns.colLabel] = M("TP_WBALANCE_FLUO_HEADER"); row[methodColumns.colLabel] = M("TP_WBALANCE_FLUO_HEADER");
row[methodColumns.colId] = i + 100; row[methodColumns.colId] = i + 100;
} }
@@ -183,7 +183,7 @@ WhiteBalance::WhiteBalance () : FoldableToolPanel(this, "whitebalance", M("TP_WB
if (currType == WBEntry::Type::WATER) { if (currType == WBEntry::Type::WATER) {
// Creating the under water subcategory header // Creating the under water subcategory header
row = *(refTreeModel->append()); row = *(refTreeModel->append());
row[methodColumns.colIcon] = wbIcon[toUnderlying(currType)]; row[methodColumns.colIcon] = wbPixbufs[toUnderlying(currType)];
row[methodColumns.colLabel] = M("TP_WBALANCE_WATER_HEADER"); row[methodColumns.colLabel] = M("TP_WBALANCE_WATER_HEADER");
row[methodColumns.colId] = i + 100; row[methodColumns.colId] = i + 100;
} }
@@ -191,7 +191,7 @@ WhiteBalance::WhiteBalance () : FoldableToolPanel(this, "whitebalance", M("TP_WB
if (currType == WBEntry::Type::LAMP) { if (currType == WBEntry::Type::LAMP) {
// Creating the Lamp subcategory header // Creating the Lamp subcategory header
row = *(refTreeModel->append()); row = *(refTreeModel->append());
row[methodColumns.colIcon] = wbIcon[toUnderlying(currType)]; row[methodColumns.colIcon] = wbPixbufs[toUnderlying(currType)];
row[methodColumns.colLabel] = M("TP_WBALANCE_LAMP_HEADER"); row[methodColumns.colLabel] = M("TP_WBALANCE_LAMP_HEADER");
row[methodColumns.colId] = i + 100; row[methodColumns.colId] = i + 100;
} }
@@ -199,7 +199,7 @@ WhiteBalance::WhiteBalance () : FoldableToolPanel(this, "whitebalance", M("TP_WB
if (currType == WBEntry::Type::LED) { if (currType == WBEntry::Type::LED) {
// Creating the LED subcategory header // Creating the LED subcategory header
row = *(refTreeModel->append()); row = *(refTreeModel->append());
row[methodColumns.colIcon] = wbIcon[toUnderlying(currType)]; row[methodColumns.colIcon] = wbPixbufs[toUnderlying(currType)];
row[methodColumns.colLabel] = M("TP_WBALANCE_LED_HEADER"); row[methodColumns.colLabel] = M("TP_WBALANCE_LED_HEADER");
row[methodColumns.colId] = i + 100; row[methodColumns.colId] = i + 100;
} }
@@ -207,7 +207,7 @@ WhiteBalance::WhiteBalance () : FoldableToolPanel(this, "whitebalance", M("TP_WB
if (currType == WBEntry::Type::FLASH) { if (currType == WBEntry::Type::FLASH) {
// Creating the Flash subcategory header // Creating the Flash subcategory header
row = *(refTreeModel->append()); row = *(refTreeModel->append());
row[methodColumns.colIcon] = wbIcon[toUnderlying(currType)]; row[methodColumns.colIcon] = wbPixbufs[toUnderlying(currType)];
row[methodColumns.colLabel] = M("TP_WBALANCE_FLASH_HEADER"); row[methodColumns.colLabel] = M("TP_WBALANCE_FLASH_HEADER");
row[methodColumns.colId] = i + 100; row[methodColumns.colId] = i + 100;
} }
@@ -220,12 +220,12 @@ WhiteBalance::WhiteBalance () : FoldableToolPanel(this, "whitebalance", M("TP_WB
|| currType == WBEntry::Type::LED || currType == WBEntry::Type::LED
) { ) {
childrow = *(refTreeModel->append(row.children())); childrow = *(refTreeModel->append(row.children()));
childrow[methodColumns.colIcon] = wbIcon[toUnderlying(currType)]; childrow[methodColumns.colIcon] = wbPixbufs[toUnderlying(currType)];
childrow[methodColumns.colLabel] = WBParams::getWbEntries()[i].GUILabel; childrow[methodColumns.colLabel] = WBParams::getWbEntries()[i].GUILabel;
childrow[methodColumns.colId] = i; childrow[methodColumns.colId] = i;
} else { } else {
row = *(refTreeModel->append()); row = *(refTreeModel->append());
row[methodColumns.colIcon] = wbIcon[toUnderlying(currType)]; row[methodColumns.colIcon] = wbPixbufs[toUnderlying(currType)];
row[methodColumns.colLabel] = WBParams::getWbEntries()[i].GUILabel; row[methodColumns.colLabel] = WBParams::getWbEntries()[i].GUILabel;
row[methodColumns.colId] = i; row[methodColumns.colId] = i;
} }

View File

@@ -45,7 +45,7 @@ protected:
class MethodColumns : public Gtk::TreeModel::ColumnRecord class MethodColumns : public Gtk::TreeModel::ColumnRecord
{ {
public: public:
Gtk::TreeModelColumn< Glib::RefPtr<RTImage> > colIcon; Gtk::TreeModelColumn< Glib::RefPtr<Gdk::Pixbuf> > colIcon;
Gtk::TreeModelColumn<Glib::ustring> colLabel; Gtk::TreeModelColumn<Glib::ustring> colLabel;
Gtk::TreeModelColumn<int> colId; Gtk::TreeModelColumn<int> colId;
MethodColumns() MethodColumns()
@@ -56,7 +56,7 @@ protected:
} }
}; };
static Glib::RefPtr<RTImage> wbIcon[rtengine::toUnderlying(rtengine::procparams::WBEntry::Type::CUSTOM) + 1]; static Glib::RefPtr<Gdk::Pixbuf> wbPixbufs[rtengine::toUnderlying(rtengine::procparams::WBEntry::Type::CUSTOM) + 1];
Glib::RefPtr<Gtk::TreeStore> refTreeModel; Glib::RefPtr<Gtk::TreeStore> refTreeModel;
MethodColumns methodColumns; MethodColumns methodColumns;
MyComboBox* method; MyComboBox* method;