Enhanced look for detail window and zoom guides, Issue 2306, thanks also to DrSlony, Hombre and Michael

This commit is contained in:
Ingo 2014-04-12 16:08:17 +02:00
parent 69eee8036a
commit d1dfc0c8f0
10 changed files with 118 additions and 110 deletions

View File

@ -696,6 +696,7 @@ PREFERENCES_CUSTPROFBUILDKEYFORMAT_TID;TagID
PREFERENCES_CUSTPROFBUILDPATH;Executable path
PREFERENCES_CUSTPROFBUILD;Custom Processing Profile Builder
PREFERENCES_CUTOVERLAYBRUSH;Crop mask color/transparency
PREFERENCES_NAVGUIDEBRUSH;Navigator guide color
PREFERENCES_D50;5000K
PREFERENCES_D55;5500K
PREFERENCES_D60;6000K

View File

@ -83,12 +83,11 @@ CropWindow::CropWindow (ImageArea* parent, rtengine::StagedImageProcessor* ipc_,
titleHeight = ih;
resizeSurface = safe_create_from_png ("resize.png");
bZoomIn = new LWButton (safe_create_from_png ("gtk-zoom-in.png"), 0, NULL, LWButton::Left, LWButton::Center, "Zoom In");
bZoomOut = new LWButton (safe_create_from_png ("gtk-zoom-out.png"), 1, NULL, LWButton::Left, LWButton::Center, "Zoom Out");
bZoom100 = new LWButton (safe_create_from_png ("gtk-zoom-100.png"), 2, NULL, LWButton::Left, LWButton::Center, "Zoom 100/%");
bZoomIn = new LWButton (safe_create_from_png ("gtk-zoom-in-small.png"), 0, NULL, LWButton::Left, LWButton::Center, "Zoom In");
bZoomOut = new LWButton (safe_create_from_png ("gtk-zoom-out-small.png"), 1, NULL, LWButton::Left, LWButton::Center, "Zoom Out");
bZoom100 = new LWButton (safe_create_from_png ("gtk-zoom-100-small.png"), 2, NULL, LWButton::Left, LWButton::Center, "Zoom 100/%");
//bZoomFit = new LWButton (safe_create_from_png ("gtk-zoom-fit.png"), 3, NULL, LWButton::Left, LWButton::Center, "Zoom Fit");
bClose = new LWButton (safe_create_from_png ("gtk-close.png"), 4, NULL, LWButton::Right, LWButton::Center, "Close");
bClose = new LWButton (safe_create_from_png ("gtk-close-small.png"), 4, NULL, LWButton::Right, LWButton::Center, "Close");
buttonSet.add (bZoomIn);
buttonSet.add (bZoomOut);
@ -1254,7 +1253,7 @@ void CropWindow::expose (Cairo::RefPtr<Cairo::Context> cr) {
if (cropHandler.cropParams.enabled) {
int cropX, cropY;
cropHandler.getPosition (cropX, cropY);
drawCrop (cr, x+imgX, y+imgY, imgW, imgH, cropX, cropY, zoomSteps[cropZoom].zoom, cropHandler.cropParams);
drawCrop (cr, x+imgX, y+imgY, imgW, imgH, cropX, cropY, zoomSteps[cropZoom].zoom, cropHandler.cropParams,(this == iarea->mainCropWindow));
}
if (observedCropWin)
drawObservedFrame (cr);
@ -1359,7 +1358,7 @@ void CropWindow::expose (Cairo::RefPtr<Cairo::Context> cr) {
if (rough) {
iarea->get_window()->draw_pixbuf (iarea->get_style()->get_base_gc(Gtk::STATE_NORMAL), rough, 0, 0, x+imgAreaX+(imgAreaW-rough->get_width())/2, y+imgAreaY+(imgAreaH-rough->get_height())/2, -1, -1, Gdk::RGB_DITHER_NORMAL, 0, 0);
if (cropHandler.cropParams.enabled) {
drawCrop (cr, x+imgAreaX+(imgAreaW-rough->get_width())/2, y+imgAreaY+(imgAreaH-rough->get_height())/2, rough->get_width(), rough->get_height(), cropX, cropY, zoomSteps[cropZoom].zoom, cropHandler.cropParams);
drawCrop (cr, x+imgAreaX+(imgAreaW-rough->get_width())/2, y+imgAreaY+(imgAreaH-rough->get_height())/2, rough->get_width(), rough->get_height(), cropX, cropY, zoomSteps[cropZoom].zoom, cropHandler.cropParams, (this == iarea->mainCropWindow));
}
if (observedCropWin)
drawObservedFrame (cr, rough->get_width(), rough->get_height());
@ -1367,22 +1366,6 @@ void CropWindow::expose (Cairo::RefPtr<Cairo::Context> cr) {
}
}
// if cursor stays above resize area, draw the icon
if (decorated && (state==SCropWinResize || onResizeArea)) {
int rw = resizeSurface->get_width ();
int rh = resizeSurface->get_height ();
cr->set_source_rgb (0.5,0.5,0.5);
cr->rectangle (x+w-1.5-rw-1, y+h-1.5-rh-1, rw+1, rh+1);
cr->stroke_preserve ();
cr->fill ();
cr->set_source (resizeSurface, x+w-1.5-rw, y+h-1.5-rh);
cr->paint ();
cr->set_source_rgb (0,0,0);
cr->move_to (x+w-2.5-rw, y+h-1.5);
cr->line_to (x+w-2.5-rw, y+h-2.5-rh);
cr->line_to (x+w-1.5, y+h-2.5-rh);
cr->stroke ();
}
if (state==SRotateSelecting)
drawStraightenGuide (cr);
if (state==SNormal && isFlawnOver) {
@ -1655,51 +1638,35 @@ double CropWindow::scaleValueToScreen (double value) {
void CropWindow::drawDecoration (Cairo::RefPtr<Cairo::Context> cr) {
int x = xpos, y = ypos;
// prepare label
Glib::RefPtr<Pango::Context> context = iarea->get_pango_context () ;
Pango::FontDescription fontd = context->get_font_description ();
fontd.set_weight (Pango::WEIGHT_BOLD);
fontd.set_size(8*Pango::SCALE);
context->set_font_description (fontd);
Glib::RefPtr<Pango::Layout> cllayout = iarea->create_pango_layout(cropLabel);
int iw, ih;
cllayout->get_pixel_size (iw, ih);
int x = xpos, y = ypos;
// prepare label
Glib::RefPtr<Pango::Context> context = iarea->get_pango_context () ;
Pango::FontDescription fontd = context->get_font_description ();
fontd.set_weight (Pango::WEIGHT_BOLD);
fontd.set_size(8*Pango::SCALE);
context->set_font_description (fontd);
Glib::RefPtr<Pango::Layout> cllayout = iarea->create_pango_layout(cropLabel);
int iw, ih;
cllayout->get_pixel_size (iw, ih);
// draw decoration (border)
int h = height, w = width;
cr->set_source_rgb (0,0,0);
cr->set_line_width (1.0);
cr->move_to (x+0.5, y+h-0.5);
cr->line_to (x+0.5, y+0.5);
cr->line_to (x+w-0.5, y+0.5);
cr->stroke ();
cr->set_source_rgb (1,1,1);
cr->move_to (x+w-0.5, y+0.5);
cr->line_to (x+w-0.5, y+h-0.5);
cr->line_to (x+0.5, y+h-0.5);
cr->stroke ();
cr->set_source_rgb (0.5,0.5,0.5);
cr->rectangle (x+1.5, y+1.5+titleHeight, w-3, h-titleHeight-3);
cr->stroke ();
cr->set_source_rgb (1,1,1);
cr->move_to (x+2.5, y+h-2.5);
cr->line_to (x+2.5, y+titleHeight+2.5);
cr->line_to (x+w-2.5, y+titleHeight+2.5);
cr->stroke ();
cr->set_source_rgb (0,0,0);
cr->move_to (x+w-2.5, y+titleHeight+2.5);
cr->line_to (x+w-2.5, y+h-2.5);
cr->line_to (x+2.5, y+h-2.5);
cr->stroke ();
cr->set_source_rgb (0.5,0.5,0.5);
cr->rectangle (x+1.5, y+1.5, w-3, titleHeight);
// draw decoration (border)
int h = height, w = width;
cr->set_source_rgb (0.1,0.1,0.1);
cr->set_line_width (1.0);
cr->move_to (x+2.5, y+titleHeight+2.5 );
cr->line_to (x+2.5, y+h-2.5);
cr->line_to (x+w-2.5, y+h-2.5);
cr->line_to (x+w-2.5, y+titleHeight+2.5 );
cr->set_source_rgba (0.0,0.0,0.0,0.5);
cr->rectangle (x+2.5, y+0.5, w-5, titleHeight+2);
cr->stroke_preserve ();
cr->fill ();
// draw label
cr->set_source_rgb (1,1,1);
cr->move_to (x+6+sideBorderWidth+bZoomIn->getIcon()->get_width()+bZoomOut->getIcon()->get_width()+bZoom100->getIcon()->get_width(), y+upperBorderWidth+(titleHeight-ih)/2);
cr->set_source_rgba (1,1,1,0.5);
cr->move_to (x+10+sideBorderWidth+bZoomIn->getIcon()->get_width()+bZoomOut->getIcon()->get_width()+bZoom100->getIcon()->get_width(), y+1+upperBorderWidth+(titleHeight-ih)/2);
cllayout->add_to_cairo_context (cr);
cr->fill ();
@ -1852,13 +1819,15 @@ void CropWindow::drawObservedFrame (Cairo::RefPtr<Cairo::Context> cr, int rw, in
int x, y, w, h;
getObservedFrameArea (x, y, w, h, rw, rh);
cr->set_source_rgb (1.0, 1.0, 1.0);
cr->set_line_width (4);
cr->rectangle (x-2, y-2, w+4, h+4);
// draw a black "shadow" line
cr->set_source_rgba( 0, 0, 0, 0.65);
cr->set_line_width (1);
cr->rectangle (x-0.5, y-0.5, w+4, h+4);
cr->stroke ();
cr->set_source_rgb (1.0, 0.0, 0.0);
cr->set_line_width (2);
cr->rectangle (x-2, y-2, w+4, h+4);
// draw a "frame" line. Color of frame line can be set in preferences
cr->set_source_rgba(options.navGuideBrush[0], options.navGuideBrush[1], options.navGuideBrush[2], options.navGuideBrush[3]); //( 1, 1, 1, 1.0);
cr->rectangle (x-1.5, y-1.5, w+4, h+4);
cr->stroke ();
}

View File

@ -54,7 +54,6 @@ class CropWindow : public LWButtonListener, public CropHandlerListener, public E
bool isLowUpdatePriority;
// decoration
Cairo::RefPtr<Cairo::ImageSurface> resizeSurface;
LWButton *bZoomIn, *bZoomOut, *bZoom100, /**bZoomFit,*/ *bClose;
LWButtonSet buttonSet;
Glib::ustring cropLabel;

View File

@ -126,7 +126,7 @@ void writeFailed (Gtk::Window& parent, const std::string& filename) {
msgd.run ();
}
void drawCrop (Cairo::RefPtr<Cairo::Context> cr, int imx, int imy, int imw, int imh, int startx, int starty, double scale, const rtengine::procparams::CropParams& cparams) {
void drawCrop (Cairo::RefPtr<Cairo::Context> cr, int imx, int imy, int imw, int imh, int startx, int starty, double scale, const rtengine::procparams::CropParams& cparams, bool drawGuide) {
cr->set_line_width (0.);
cr->rectangle (imx, imy, imw, imh);
@ -153,7 +153,7 @@ void drawCrop (Cairo::RefPtr<Cairo::Context> cr, int imx, int imy, int imw, int
cr->fill ();
// rectangle around the cropped area and guides
if (cparams.guide!="None") {
if (cparams.guide!="None" && drawGuide) {
double rectx1 = round(c1x) + imx + 0.5;
double recty1 = round(c1y) + imy + 0.5;
double rectx2 = min(round(c2x) + imx + 0.5, imx+imw-0.5);

View File

@ -31,7 +31,7 @@ Glib::ustring removeExtension (const Glib::ustring& filename);
Glib::ustring getExtension (const Glib::ustring& filename);
bool confirmOverwrite (Gtk::Window& parent, const std::string& filename);
void writeFailed (Gtk::Window& parent, const std::string& filename);
void drawCrop (Cairo::RefPtr<Cairo::Context> cr, int imx, int imy, int imw, int imh, int startx, int starty, double scale, const rtengine::procparams::CropParams& cparams);
void drawCrop (Cairo::RefPtr<Cairo::Context> cr, int imx, int imy, int imw, int imh, int startx, int starty, double scale, const rtengine::procparams::CropParams& cparams, bool drawGuide = true);
/**
* @brief Lock GTK for critical section.

View File

@ -395,6 +395,13 @@ void Options::setDefaults () {
cutOverlayBrush = std::vector<double> (4);
cutOverlayBrush[3] = 0.667; // :-p
navGuideBrush = std::vector<double> (4);
//default to red
navGuideBrush[0] = 1.0;
navGuideBrush[1] = 0.0;
navGuideBrush[2] = 0.0;
navGuideBrush[3] = 1.0;
sndEnable=true;
sndLngEditProcDoneSecs=3.0;
#ifdef __linux__
@ -722,6 +729,7 @@ if (keyFile.has_group ("GUI")) {
if (keyFile.has_key ("GUI", "MultiDisplayMode")) multiDisplayMode = keyFile.get_integer ("GUI", "MultiDisplayMode");
//if (keyFile.has_key ("GUI", "CurvePanelsExpanded")) crvOpen = keyFile.get_integer_list ("GUI", "CurvePanelsExpanded");
if (keyFile.has_key ("GUI", "CutOverlayBrush")) cutOverlayBrush = keyFile.get_double_list ("GUI", "CutOverlayBrush");
if (keyFile.has_key ("GUI", "NavGuideBrush")) navGuideBrush = keyFile.get_double_list ("GUI", "NavGuideBrush");
if (keyFile.has_key ("GUI", "HistogramPosition")) histogramPosition = keyFile.get_integer ("GUI", "HistogramPosition");
if (keyFile.has_key ("GUI", "HistogramBar")) histogramBar = keyFile.get_boolean ("GUI", "HistogramBar");
if (keyFile.has_key ("GUI", "HistogramFullMode")) histogramFullMode = keyFile.get_boolean ("GUI", "HistogramFullMode");
@ -1009,6 +1017,7 @@ int Options::saveToFile (Glib::ustring fname) {
keyFile.set_integer_list ("GUI", "ToolPanelsExpanded", tpopen);
keyFile.set_integer ("GUI", "MultiDisplayMode", multiDisplayMode);
keyFile.set_double_list ("GUI", "CutOverlayBrush", cutOverlayBrush);
keyFile.set_double_list ("GUI", "NavGuideBrush", navGuideBrush);
keyFile.set_integer ("GUI", "HistogramPosition", histogramPosition);
keyFile.set_boolean ("GUI", "HistogramBar", histogramBar);
keyFile.set_boolean ("GUI", "HistogramFullMode", histogramFullMode);

View File

@ -188,6 +188,7 @@ class Options {
int previewSizeTab,previewSizeBrowser;
int multiDisplayMode; // 0=none, 1=Edit panels on other display
std::vector<double> cutOverlayBrush; // Red;Green;Blue;Alpha , all ranging 0..1
std::vector<double> navGuideBrush; // Red;Green;Blue;Alpha , all ranging 0..1
Glib::ustring sndBatchQueueDone;
Glib::ustring sndLngEditProcDone;

View File

@ -668,8 +668,14 @@ Gtk::Widget* Preferences::getGeneralPanel () {
butCropCol= Gtk::manage( new Gtk::ColorButton() );
butCropCol->set_use_alpha(true);
Gtk::Label* navGuideLabel = Gtk::manage( new Gtk::Label (M("PREFERENCES_NAVGUIDEBRUSH") + ":") );
butNavGuideCol= Gtk::manage( new Gtk::ColorButton() );
butNavGuideCol->set_use_alpha(true);
hbUseSystemTheme->pack_start(*chUseSystemTheme, Gtk::PACK_SHRINK);
hbUseSystemTheme->pack_start (*useNextStart, Gtk::PACK_SHRINK, 0);
hbUseSystemTheme->pack_end (*butNavGuideCol, Gtk::PACK_SHRINK, 0);
hbUseSystemTheme->pack_end (*navGuideLabel, Gtk::PACK_SHRINK, 0);
hbUseSystemTheme->pack_end (*butCropCol, Gtk::PACK_SHRINK, 0);
hbUseSystemTheme->pack_end (*cutOverlayLabel, Gtk::PACK_SHRINK, 0);
vbftheme->pack_start(*hbUseSystemTheme, Gtk::PACK_SHRINK, 0);
@ -1125,6 +1131,12 @@ void Preferences::storePreferences () {
moptions.cutOverlayBrush[2]=cropCol.get_blue_p();
moptions.cutOverlayBrush[3]=butCropCol->get_alpha()/65535.0;
Gdk::Color NavGuideCol=butNavGuideCol->get_color();
moptions.navGuideBrush[0]=NavGuideCol.get_red_p();
moptions.navGuideBrush[1]=NavGuideCol.get_green_p();
moptions.navGuideBrush[2]=NavGuideCol.get_blue_p();
moptions.navGuideBrush[3]=butNavGuideCol->get_alpha()/65535.0;
moptions.font = fontbutton->get_font_name();
#ifdef WIN32
moptions.gimpDir = gimpDir->get_filename ();
@ -1262,6 +1274,11 @@ void Preferences::fillPreferences () {
butCropCol->set_color(cropCol);
butCropCol->set_alpha ( (unsigned short)(moptions.cutOverlayBrush[3]*65535.0));
Gdk::Color NavGuideCol;
NavGuideCol.set_rgb_p(moptions.navGuideBrush[0],moptions.navGuideBrush[1],moptions.navGuideBrush[2]);
butNavGuideCol->set_color(NavGuideCol);
butNavGuideCol->set_alpha ( (unsigned short)(moptions.navGuideBrush[3]*65535.0));
fontbutton->set_font_name(moptions.font);
showDateTime->set_active (moptions.fbShowDateTime);
showBasicExif->set_active (moptions.fbShowBasicExif);

View File

@ -101,6 +101,7 @@ class Preferences : public Gtk::Dialog, public ProfileStoreListener {
Gtk::CheckButton* chUseSystemTheme;
Gtk::FontButton* fontbutton;
Gtk::ColorButton* butCropCol;
Gtk::ColorButton* butNavGuideCol;
Gtk::SpinButton* maxThumbSize;
Gtk::SpinButton* maxCacheEntries;

View File

@ -38,10 +38,10 @@ void PreviewWindow::getObservedFrameArea (int& x, int& y, int& w, int& h) {
int cropX, cropY, cropW, cropH;
mainCropWin->getCropRectangle (cropX, cropY, cropW, cropH);
// translate it to screen coordinates
x = imgX + cropX*zoom;
y = imgY + cropY*zoom;
w = cropW * zoom;
h = cropH * zoom;
x = imgX + round(cropX*zoom);
y = imgY + round(cropY*zoom);
w = round(cropW * zoom);
h = round(cropH * zoom);
}
}
@ -105,14 +105,21 @@ bool PreviewWindow::on_expose_event (GdkEventExpose* event) {
Cairo::RefPtr<Cairo::Context> cr = get_window()->create_cairo_context();
int x, y, w, h;
getObservedFrameArea (x, y, w, h);
cr->set_source_rgb (1.0, 1.0, 1.0);
cr->set_line_width (3);
cr->rectangle (x-1.5, y-1.5, w+2, h+2);
cr->stroke ();
cr->set_source_rgb (1.0, 0.0, 0.0);
double rectX = x + 0.5;
double rectY = y + 0.5;
double rectW = std::min(w, (int)(imgW - (x-imgX) - 1));
double rectH = std::min(h, (int)(imgH - (y-imgY) - 1));
// draw a black "shadow" line
cr->set_source_rgba (0.0, 0.0, 0.0, 0.65);
cr->set_line_width (1);
cr->rectangle (x-1.5, y-1.5, w+2, h+2);
cr->stroke ();
cr->rectangle (rectX+1., rectY+1, rectW, rectH);
cr->stroke ();
// draw a "frame" line. Color of frame line can be set in preferences
cr->set_source_rgba(options.navGuideBrush[0], options.navGuideBrush[1], options.navGuideBrush[2], options.navGuideBrush[3]); //( 1.0, 1.0, 1.0, 1.0);
cr->rectangle (rectX, rectY, rectW, rectH);
cr->stroke ();
}
}
}
@ -153,17 +160,19 @@ bool PreviewWindow::on_motion_notify_event (GdkEventMotion* event) {
if (!mainCropWin)
return true;
int x, y, w, h;
getObservedFrameArea (x, y, w, h);
bool inside = event->x > x-6 && event->x < x+w-1+6 && event->y > y-6 && event->y < y+h-1+6;
bool moreInside = event->x > x+6 && event->x < x+w-1-6 && event->y > y+6 && event->y < y+h-1-6;
if(mainCropWin->getZoom() > mainCropWin->cropHandler.getFitZoom()) {
int x, y, w, h;
getObservedFrameArea (x, y, w, h);
bool inside = event->x > x-6 && event->x < x+w-1+6 && event->y > y-6 && event->y < y+h-1+6;
bool moreInside = event->x > x+6 && event->x < x+w-1-6 && event->y > y+6 && event->y < y+h-1-6;
if (isMoving)
mainCropWin->remoteMove ((event->x - press_x)/zoom, (event->y - press_y)/zoom);
else if (inside && !moreInside)
cursorManager.setCursor (get_window(), CSClosedHand);
else
cursorManager.setCursor (get_window(), CSArrow);
if (isMoving)
mainCropWin->remoteMove ((event->x - press_x)/zoom, (event->y - press_y)/zoom);
else if (inside && !moreInside)
cursorManager.setCursor (get_window(), CSClosedHand);
else
cursorManager.setCursor (get_window(), CSArrow);
}
return true;
}
@ -172,23 +181,25 @@ bool PreviewWindow::on_button_press_event (GdkEventButton* event) {
if (!mainCropWin)
return true;
int x, y, w, h;
getObservedFrameArea (x, y, w, h);
bool inside = event->x > x-6 && event->x < x+w-1+6 && event->y > y-6 && event->y < y+h-1+6;
bool moreInside = event->x > x+6 && event->x < x+w-1-6 && event->y > y+6 && event->y < y+h-1-6;
if(mainCropWin->getZoom() > mainCropWin->cropHandler.getFitZoom()) {
int x, y, w, h;
getObservedFrameArea (x, y, w, h);
bool inside = event->x > x-6 && event->x < x+w-1+6 && event->y > y-6 && event->y < y+h-1+6;
bool moreInside = event->x > x+6 && event->x < x+w-1-6 && event->y > y+6 && event->y < y+h-1-6;
if (!isMoving) {
isMoving = true;
if (!inside || moreInside) {
mainCropWin->remoteMove ((event->x - (x+w/2))/zoom, (event->y - (y+h/2))/zoom);
press_x = x+w/2;
press_y = y+h/2;
}
else {
press_x = event->x;
press_y = event->y;
}
cursorManager.setCursor (get_window(), CSClosedHand);
if (!isMoving) {
isMoving = true;
if (!inside || moreInside) {
mainCropWin->remoteMove ((event->x - (x+w/2))/zoom, (event->y - (y+h/2))/zoom);
press_x = x+w/2;
press_y = y+h/2;
}
else {
press_x = event->x;
press_y = event->y;
}
cursorManager.setCursor (get_window(), CSClosedHand);
}
}
return true;
}