Relax dependency from procparams.h
This commit is contained in:
@@ -18,15 +18,17 @@
|
||||
*/
|
||||
#include "filebrowserentry.h"
|
||||
|
||||
#include <iomanip>
|
||||
#include <cstring>
|
||||
#include <iomanip>
|
||||
|
||||
#include "guiutils.h"
|
||||
#include "threadutils.h"
|
||||
#include "rtimage.h"
|
||||
#include "cursormanager.h"
|
||||
#include "thumbbrowserbase.h"
|
||||
#include "guiutils.h"
|
||||
#include "inspector.h"
|
||||
#include "rtimage.h"
|
||||
#include "threadutils.h"
|
||||
#include "thumbbrowserbase.h"
|
||||
|
||||
#include "../rtengine/procparams.h"
|
||||
|
||||
#define CROPRESIZEBORDER 4
|
||||
|
||||
@@ -40,7 +42,7 @@ Glib::RefPtr<Gdk::Pixbuf> FileBrowserEntry::hdr;
|
||||
Glib::RefPtr<Gdk::Pixbuf> FileBrowserEntry::ps;
|
||||
|
||||
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), cropParams(new rtengine::procparams::CropParams), cropgl(nullptr), state(SNormal), crop_custom_ratio(0.f)
|
||||
{
|
||||
thumbnail = thm;
|
||||
|
||||
@@ -163,9 +165,9 @@ std::vector<Glib::RefPtr<Gdk::Pixbuf> > FileBrowserEntry::getSpecificityIconsOnI
|
||||
|
||||
void FileBrowserEntry::customBackBufferUpdate (Cairo::RefPtr<Cairo::Context> c)
|
||||
{
|
||||
if(scale != 1.0 && cropParams.enabled) { // somewhere in pipeline customBackBufferUpdate is called when scale == 1.0, which is nonsense for a thumb
|
||||
if(scale != 1.0 && cropParams->enabled) { // somewhere in pipeline customBackBufferUpdate is called when scale == 1.0, which is nonsense for a thumb
|
||||
if (state == SCropSelecting || state == SResizeH1 || state == SResizeH2 || state == SResizeW1 || state == SResizeW2 || state == SResizeTL || state == SResizeTR || state == SResizeBL || state == SResizeBR || state == SCropMove) {
|
||||
drawCrop (c, prex, prey, prew, preh, 0, 0, scale, cropParams, true, false);
|
||||
drawCrop (c, prex, prey, prew, preh, 0, 0, scale, *cropParams, true, false);
|
||||
} else {
|
||||
rtengine::procparams::CropParams cparams = thumbnail->getProcParams().crop;
|
||||
switch (options.cropGuides) {
|
||||
@@ -246,7 +248,7 @@ void FileBrowserEntry::_updateImage(rtengine::IImage8* img, double s, const rten
|
||||
|
||||
redrawRequests--;
|
||||
scale = s;
|
||||
this->cropParams = cropParams;
|
||||
*this->cropParams = cropParams;
|
||||
|
||||
bool newLandscape = img->getWidth() > img->getHeight();
|
||||
bool rotated = false;
|
||||
@@ -319,65 +321,65 @@ bool FileBrowserEntry::motionNotify (int x, int y)
|
||||
action_y = y;
|
||||
parent->redrawNeeded (this);
|
||||
} else if (state == SResizeH1 && cropgl) {
|
||||
int oy = cropParams.y;
|
||||
cropParams.y = action_y + (y - press_y) / scale;
|
||||
cropParams.h += oy - cropParams.y;
|
||||
cropgl->cropHeight1Resized (cropParams.x, cropParams.y, cropParams.w, cropParams.h, crop_custom_ratio);
|
||||
int oy = cropParams->y;
|
||||
cropParams->y = action_y + (y - press_y) / scale;
|
||||
cropParams->h += oy - cropParams->y;
|
||||
cropgl->cropHeight1Resized (cropParams->x, cropParams->y, cropParams->w, cropParams->h, crop_custom_ratio);
|
||||
updateBackBuffer ();
|
||||
parent->redrawNeeded (this);
|
||||
} else if (state == SResizeH2 && cropgl) {
|
||||
cropParams.h = action_y + (y - press_y) / scale;
|
||||
cropgl->cropHeight2Resized (cropParams.x, cropParams.y, cropParams.w, cropParams.h, crop_custom_ratio);
|
||||
cropParams->h = action_y + (y - press_y) / scale;
|
||||
cropgl->cropHeight2Resized (cropParams->x, cropParams->y, cropParams->w, cropParams->h, crop_custom_ratio);
|
||||
updateBackBuffer ();
|
||||
parent->redrawNeeded (this);
|
||||
} else if (state == SResizeW1 && cropgl) {
|
||||
int ox = cropParams.x;
|
||||
cropParams.x = action_x + (x - press_x) / scale;
|
||||
cropParams.w += ox - cropParams.x;
|
||||
cropgl->cropWidth1Resized (cropParams.x, cropParams.y, cropParams.w, cropParams.h, crop_custom_ratio);
|
||||
int ox = cropParams->x;
|
||||
cropParams->x = action_x + (x - press_x) / scale;
|
||||
cropParams->w += ox - cropParams->x;
|
||||
cropgl->cropWidth1Resized (cropParams->x, cropParams->y, cropParams->w, cropParams->h, crop_custom_ratio);
|
||||
updateBackBuffer ();
|
||||
parent->redrawNeeded (this);
|
||||
} else if (state == SResizeW2 && cropgl) {
|
||||
cropParams.w = action_x + (x - press_x) / scale;
|
||||
cropgl->cropWidth2Resized (cropParams.x, cropParams.y, cropParams.w, cropParams.h, crop_custom_ratio);
|
||||
cropParams->w = action_x + (x - press_x) / scale;
|
||||
cropgl->cropWidth2Resized (cropParams->x, cropParams->y, cropParams->w, cropParams->h, crop_custom_ratio);
|
||||
updateBackBuffer ();
|
||||
parent->redrawNeeded (this);
|
||||
} else if (state == SResizeTL && cropgl) {
|
||||
int ox = cropParams.x;
|
||||
cropParams.x = action_x + (x - press_x) / scale;
|
||||
cropParams.w += ox - cropParams.x;
|
||||
int oy = cropParams.y;
|
||||
cropParams.y = action_y + (y - press_y) / scale;
|
||||
cropParams.h += oy - cropParams.y;
|
||||
cropgl->cropTopLeftResized (cropParams.x, cropParams.y, cropParams.w, cropParams.h, crop_custom_ratio);
|
||||
int ox = cropParams->x;
|
||||
cropParams->x = action_x + (x - press_x) / scale;
|
||||
cropParams->w += ox - cropParams->x;
|
||||
int oy = cropParams->y;
|
||||
cropParams->y = action_y + (y - press_y) / scale;
|
||||
cropParams->h += oy - cropParams->y;
|
||||
cropgl->cropTopLeftResized (cropParams->x, cropParams->y, cropParams->w, cropParams->h, crop_custom_ratio);
|
||||
updateBackBuffer ();
|
||||
parent->redrawNeeded (this);
|
||||
} else if (state == SResizeTR && cropgl) {
|
||||
cropParams.w = action_x + (x - press_x) / scale;
|
||||
int oy = cropParams.y;
|
||||
cropParams.y = action_y + (y - press_y) / scale;
|
||||
cropParams.h += oy - cropParams.y;
|
||||
cropgl->cropTopRightResized (cropParams.x, cropParams.y, cropParams.w, cropParams.h, crop_custom_ratio);
|
||||
cropParams->w = action_x + (x - press_x) / scale;
|
||||
int oy = cropParams->y;
|
||||
cropParams->y = action_y + (y - press_y) / scale;
|
||||
cropParams->h += oy - cropParams->y;
|
||||
cropgl->cropTopRightResized (cropParams->x, cropParams->y, cropParams->w, cropParams->h, crop_custom_ratio);
|
||||
updateBackBuffer ();
|
||||
parent->redrawNeeded (this);
|
||||
} else if (state == SResizeBL && cropgl) {
|
||||
int ox = cropParams.x;
|
||||
cropParams.x = action_x + (x - press_x) / scale;
|
||||
cropParams.w += ox - cropParams.x;
|
||||
cropParams.h = action_y + (y - press_y) / scale;
|
||||
cropgl->cropBottomLeftResized (cropParams.x, cropParams.y, cropParams.w, cropParams.h, crop_custom_ratio);
|
||||
int ox = cropParams->x;
|
||||
cropParams->x = action_x + (x - press_x) / scale;
|
||||
cropParams->w += ox - cropParams->x;
|
||||
cropParams->h = action_y + (y - press_y) / scale;
|
||||
cropgl->cropBottomLeftResized (cropParams->x, cropParams->y, cropParams->w, cropParams->h, crop_custom_ratio);
|
||||
updateBackBuffer ();
|
||||
parent->redrawNeeded (this);
|
||||
} else if (state == SResizeBR && cropgl) {
|
||||
cropParams.w = action_x + (x - press_x) / scale;
|
||||
cropParams.h = action_y + (y - press_y) / scale;
|
||||
cropgl->cropBottomRightResized (cropParams.x, cropParams.y, cropParams.w, cropParams.h, crop_custom_ratio);
|
||||
cropParams->w = action_x + (x - press_x) / scale;
|
||||
cropParams->h = action_y + (y - press_y) / scale;
|
||||
cropgl->cropBottomRightResized (cropParams->x, cropParams->y, cropParams->w, cropParams->h, crop_custom_ratio);
|
||||
updateBackBuffer ();
|
||||
parent->redrawNeeded (this);
|
||||
} else if (state == SCropMove && cropgl) {
|
||||
cropParams.x = action_x + (x - press_x) / scale;
|
||||
cropParams.y = action_y + (y - press_y) / scale;
|
||||
cropgl->cropMoved (cropParams.x, cropParams.y, cropParams.w, cropParams.h);
|
||||
cropParams->x = action_x + (x - press_x) / scale;
|
||||
cropParams->y = action_y + (y - press_y) / scale;
|
||||
cropgl->cropMoved (cropParams->x, cropParams->y, cropParams->w, cropParams->h);
|
||||
updateBackBuffer ();
|
||||
parent->redrawNeeded (this);
|
||||
} else if (state == SCropSelecting && cropgl) {
|
||||
@@ -386,19 +388,19 @@ bool FileBrowserEntry::motionNotify (int x, int y)
|
||||
cropgl->cropResized (cx1, cy1, cx2, cy2);
|
||||
|
||||
if (cx2 > cx1) {
|
||||
cropParams.x = cx1;
|
||||
cropParams.w = cx2 - cx1 + 1;
|
||||
cropParams->x = cx1;
|
||||
cropParams->w = cx2 - cx1 + 1;
|
||||
} else {
|
||||
cropParams.x = cx2;
|
||||
cropParams.w = cx1 - cx2 + 1;
|
||||
cropParams->x = cx2;
|
||||
cropParams->w = cx1 - cx2 + 1;
|
||||
}
|
||||
|
||||
if (cy2 > cy1) {
|
||||
cropParams.y = cy1;
|
||||
cropParams.h = cy2 - cy1 + 1;
|
||||
cropParams->y = cy1;
|
||||
cropParams->h = cy2 - cy1 + 1;
|
||||
} else {
|
||||
cropParams.y = cy2;
|
||||
cropParams.h = cy1 - cy2 + 1;
|
||||
cropParams->y = cy2;
|
||||
cropParams->h = cy1 - cy2 + 1;
|
||||
}
|
||||
|
||||
updateBackBuffer ();
|
||||
@@ -429,71 +431,71 @@ bool FileBrowserEntry::pressNotify (int button, int type, int bstate, int x, i
|
||||
|
||||
if (!b && selected && inside (x, y)) {
|
||||
if (button == 1 && type == GDK_BUTTON_PRESS && state == SNormal) {
|
||||
if ((bstate & GDK_SHIFT_MASK) && cropParams.w > 0 && cropParams.h > 0) {
|
||||
crop_custom_ratio = float(cropParams.w) / float(cropParams.h);
|
||||
if ((bstate & GDK_SHIFT_MASK) && cropParams->w > 0 && cropParams->h > 0) {
|
||||
crop_custom_ratio = float(cropParams->w) / float(cropParams->h);
|
||||
}
|
||||
if (onArea (CropTopLeft, ix, iy)) {
|
||||
state = SResizeTL;
|
||||
press_x = x;
|
||||
action_x = cropParams.x;
|
||||
action_x = cropParams->x;
|
||||
press_y = y;
|
||||
action_y = cropParams.y;
|
||||
action_y = cropParams->y;
|
||||
cropgl = iatlistener->startCropEditing (thumbnail);
|
||||
b = true;
|
||||
} else if (onArea (CropTopRight, ix, iy)) {
|
||||
state = SResizeTR;
|
||||
press_x = x;
|
||||
action_x = cropParams.w;
|
||||
action_x = cropParams->w;
|
||||
press_y = y;
|
||||
action_y = cropParams.y;
|
||||
action_y = cropParams->y;
|
||||
cropgl = iatlistener->startCropEditing (thumbnail);
|
||||
b = true;
|
||||
} else if (onArea (CropBottomLeft, ix, iy)) {
|
||||
state = SResizeBL;
|
||||
press_x = x;
|
||||
action_x = cropParams.x;
|
||||
action_x = cropParams->x;
|
||||
press_y = y;
|
||||
action_y = cropParams.h;
|
||||
action_y = cropParams->h;
|
||||
cropgl = iatlistener->startCropEditing (thumbnail);
|
||||
b = true;
|
||||
} else if (onArea (CropBottomRight, ix, iy)) {
|
||||
state = SResizeBR;
|
||||
press_x = x;
|
||||
action_x = cropParams.w;
|
||||
action_x = cropParams->w;
|
||||
press_y = y;
|
||||
action_y = cropParams.h;
|
||||
action_y = cropParams->h;
|
||||
cropgl = iatlistener->startCropEditing (thumbnail);
|
||||
b = true;
|
||||
} else if (onArea (CropTop, ix, iy)) {
|
||||
state = SResizeH1;
|
||||
press_y = y;
|
||||
action_y = cropParams.y;
|
||||
action_y = cropParams->y;
|
||||
cropgl = iatlistener->startCropEditing (thumbnail);
|
||||
b = true;
|
||||
} else if (onArea (CropBottom, ix, iy)) {
|
||||
state = SResizeH2;
|
||||
press_y = y;
|
||||
action_y = cropParams.h;
|
||||
action_y = cropParams->h;
|
||||
cropgl = iatlistener->startCropEditing (thumbnail);
|
||||
b = true;
|
||||
} else if (onArea (CropLeft, ix, iy)) {
|
||||
state = SResizeW1;
|
||||
press_x = x;
|
||||
action_x = cropParams.x;
|
||||
action_x = cropParams->x;
|
||||
cropgl = iatlistener->startCropEditing (thumbnail);
|
||||
b = true;
|
||||
} else if (onArea (CropRight, ix, iy)) {
|
||||
state = SResizeW2;
|
||||
press_x = x;
|
||||
action_x = cropParams.w;
|
||||
action_x = cropParams->w;
|
||||
cropgl = iatlistener->startCropEditing (thumbnail);
|
||||
b = true;
|
||||
} else if ((bstate & GDK_SHIFT_MASK) && onArea (CropInside, ix, iy)) {
|
||||
state = SCropMove;
|
||||
press_x = x;
|
||||
press_y = y;
|
||||
action_x = cropParams.x;
|
||||
action_y = cropParams.y;
|
||||
action_x = cropParams->x;
|
||||
action_y = cropParams->y;
|
||||
cropgl = iatlistener->startCropEditing (thumbnail);
|
||||
b = true;
|
||||
} else if (onArea (CropImage, ix, iy)) {
|
||||
@@ -513,10 +515,10 @@ bool FileBrowserEntry::pressNotify (int button, int type, int bstate, int x, i
|
||||
|
||||
if (cropgl) {
|
||||
state = SCropSelecting;
|
||||
press_x = cropParams.x = (ix - prex) / scale;
|
||||
press_y = cropParams.y = (iy - prey) / scale;
|
||||
cropParams.w = cropParams.h = 1;
|
||||
cropgl->cropInit (cropParams.x, cropParams.y, cropParams.w, cropParams.h);
|
||||
press_x = cropParams->x = (ix - prex) / scale;
|
||||
press_y = cropParams->y = (iy - prey) / scale;
|
||||
cropParams->w = cropParams->h = 1;
|
||||
cropgl->cropInit (cropParams->x, cropParams->y, cropParams->w, cropParams->h);
|
||||
b = true;
|
||||
}
|
||||
}
|
||||
@@ -582,67 +584,67 @@ bool FileBrowserEntry::onArea (CursorArea a, int x, int y)
|
||||
return x >= prex && x < prex + prew && y >= prey && y < prey + preh;
|
||||
|
||||
case CropTopLeft:
|
||||
return cropParams.enabled &&
|
||||
y1 >= cropParams.y - cropResizeBorder &&
|
||||
y1 <= cropParams.y + cropResizeBorder &&
|
||||
x1 >= cropParams.x - cropResizeBorder &&
|
||||
x1 <= cropParams.x + cropResizeBorder;
|
||||
return cropParams->enabled &&
|
||||
y1 >= cropParams->y - cropResizeBorder &&
|
||||
y1 <= cropParams->y + cropResizeBorder &&
|
||||
x1 >= cropParams->x - cropResizeBorder &&
|
||||
x1 <= cropParams->x + cropResizeBorder;
|
||||
|
||||
case CropTopRight:
|
||||
return cropParams.enabled &&
|
||||
y1 >= cropParams.y - cropResizeBorder &&
|
||||
y1 <= cropParams.y + cropResizeBorder &&
|
||||
x1 >= cropParams.x + cropParams.w - 1 - cropResizeBorder &&
|
||||
x1 <= cropParams.x + cropParams.w - 1 + cropResizeBorder;
|
||||
return cropParams->enabled &&
|
||||
y1 >= cropParams->y - cropResizeBorder &&
|
||||
y1 <= cropParams->y + cropResizeBorder &&
|
||||
x1 >= cropParams->x + cropParams->w - 1 - cropResizeBorder &&
|
||||
x1 <= cropParams->x + cropParams->w - 1 + cropResizeBorder;
|
||||
|
||||
case CropBottomLeft:
|
||||
return cropParams.enabled &&
|
||||
y1 >= cropParams.y + cropParams.h - 1 - cropResizeBorder &&
|
||||
y1 <= cropParams.y + cropParams.h - 1 + cropResizeBorder &&
|
||||
x1 >= cropParams.x - cropResizeBorder &&
|
||||
x1 <= cropParams.x + cropResizeBorder;
|
||||
return cropParams->enabled &&
|
||||
y1 >= cropParams->y + cropParams->h - 1 - cropResizeBorder &&
|
||||
y1 <= cropParams->y + cropParams->h - 1 + cropResizeBorder &&
|
||||
x1 >= cropParams->x - cropResizeBorder &&
|
||||
x1 <= cropParams->x + cropResizeBorder;
|
||||
|
||||
case CropBottomRight:
|
||||
return cropParams.enabled &&
|
||||
y1 >= cropParams.y + cropParams.h - 1 - cropResizeBorder &&
|
||||
y1 <= cropParams.y + cropParams.h - 1 + cropResizeBorder &&
|
||||
x1 >= cropParams.x + cropParams.w - 1 - cropResizeBorder &&
|
||||
x1 <= cropParams.x + cropParams.w - 1 + cropResizeBorder;
|
||||
return cropParams->enabled &&
|
||||
y1 >= cropParams->y + cropParams->h - 1 - cropResizeBorder &&
|
||||
y1 <= cropParams->y + cropParams->h - 1 + cropResizeBorder &&
|
||||
x1 >= cropParams->x + cropParams->w - 1 - cropResizeBorder &&
|
||||
x1 <= cropParams->x + cropParams->w - 1 + cropResizeBorder;
|
||||
|
||||
case CropTop:
|
||||
return cropParams.enabled &&
|
||||
x1 > cropParams.x + cropResizeBorder &&
|
||||
x1 < cropParams.x + cropParams.w - 1 - cropResizeBorder &&
|
||||
y1 > cropParams.y - cropResizeBorder &&
|
||||
y1 < cropParams.y + cropResizeBorder;
|
||||
return cropParams->enabled &&
|
||||
x1 > cropParams->x + cropResizeBorder &&
|
||||
x1 < cropParams->x + cropParams->w - 1 - cropResizeBorder &&
|
||||
y1 > cropParams->y - cropResizeBorder &&
|
||||
y1 < cropParams->y + cropResizeBorder;
|
||||
|
||||
case CropBottom:
|
||||
return cropParams.enabled &&
|
||||
x1 > cropParams.x + cropResizeBorder &&
|
||||
x1 < cropParams.x + cropParams.w - 1 - cropResizeBorder &&
|
||||
y1 > cropParams.y + cropParams.h - 1 - cropResizeBorder &&
|
||||
y1 < cropParams.y + cropParams.h - 1 + cropResizeBorder;
|
||||
return cropParams->enabled &&
|
||||
x1 > cropParams->x + cropResizeBorder &&
|
||||
x1 < cropParams->x + cropParams->w - 1 - cropResizeBorder &&
|
||||
y1 > cropParams->y + cropParams->h - 1 - cropResizeBorder &&
|
||||
y1 < cropParams->y + cropParams->h - 1 + cropResizeBorder;
|
||||
|
||||
case CropLeft:
|
||||
return cropParams.enabled &&
|
||||
y1 > cropParams.y + cropResizeBorder &&
|
||||
y1 < cropParams.y + cropParams.h - 1 - cropResizeBorder &&
|
||||
x1 > cropParams.x - cropResizeBorder &&
|
||||
x1 < cropParams.x + cropResizeBorder;
|
||||
return cropParams->enabled &&
|
||||
y1 > cropParams->y + cropResizeBorder &&
|
||||
y1 < cropParams->y + cropParams->h - 1 - cropResizeBorder &&
|
||||
x1 > cropParams->x - cropResizeBorder &&
|
||||
x1 < cropParams->x + cropResizeBorder;
|
||||
|
||||
case CropRight:
|
||||
return cropParams.enabled &&
|
||||
y1 > cropParams.y + cropResizeBorder &&
|
||||
y1 < cropParams.y + cropParams.h - 1 - cropResizeBorder &&
|
||||
x1 > cropParams.x + cropParams.w - 1 - cropResizeBorder &&
|
||||
x1 < cropParams.x + cropParams.w - 1 + cropResizeBorder;
|
||||
return cropParams->enabled &&
|
||||
y1 > cropParams->y + cropResizeBorder &&
|
||||
y1 < cropParams->y + cropParams->h - 1 - cropResizeBorder &&
|
||||
x1 > cropParams->x + cropParams->w - 1 - cropResizeBorder &&
|
||||
x1 < cropParams->x + cropParams->w - 1 + cropResizeBorder;
|
||||
|
||||
case CropInside:
|
||||
return cropParams.enabled &&
|
||||
y1 > cropParams.y &&
|
||||
y1 < cropParams.y + cropParams.h - 1 &&
|
||||
x1 > cropParams.x &&
|
||||
x1 < cropParams.x + cropParams.w - 1;
|
||||
return cropParams->enabled &&
|
||||
y1 > cropParams->y &&
|
||||
y1 < cropParams->y + cropParams->h - 1 &&
|
||||
x1 > cropParams->x &&
|
||||
x1 < cropParams->x + cropParams->w - 1;
|
||||
default: /* do nothing */ ;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user