Updated code taking into account Adam's comments + bugfix
This commit is contained in:
@@ -100,48 +100,50 @@ void PreviewWindow::on_resized (Gtk::Allocation& req)
|
||||
bool PreviewWindow::on_expose_event (GdkEventExpose* event)
|
||||
{
|
||||
|
||||
if (backBuffer) {
|
||||
Glib::RefPtr<Gdk::Window> window = get_window();
|
||||
if (!backBuffer) {
|
||||
return true;
|
||||
}
|
||||
|
||||
int bufferW, bufferH;
|
||||
backBuffer->get_size (bufferW, bufferH);
|
||||
Glib::RefPtr<Gdk::Window> window = get_window();
|
||||
|
||||
if (!mainCropWin && imageArea) {
|
||||
mainCropWin = imageArea->getMainCropWindow ();
|
||||
int bufferW, bufferH;
|
||||
backBuffer->get_size (bufferW, bufferH);
|
||||
|
||||
if (mainCropWin) {
|
||||
mainCropWin->addCropWindowListener (this);
|
||||
}
|
||||
if (!mainCropWin && imageArea) {
|
||||
mainCropWin = imageArea->getMainCropWindow ();
|
||||
|
||||
if (mainCropWin) {
|
||||
mainCropWin->addCropWindowListener (this);
|
||||
}
|
||||
}
|
||||
|
||||
if ((get_width() != bufferW && get_height() != bufferH) || needsUpdate) {
|
||||
needsUpdate = false;
|
||||
updatePreviewImage ();
|
||||
}
|
||||
if ((get_width() != bufferW && get_height() != bufferH) || needsUpdate) {
|
||||
needsUpdate = false;
|
||||
updatePreviewImage ();
|
||||
}
|
||||
|
||||
window->draw_drawable (get_style()->get_base_gc(Gtk::STATE_NORMAL), backBuffer, 0, 0, 0, 0, -1, -1);
|
||||
window->draw_drawable (get_style()->get_base_gc(Gtk::STATE_NORMAL), backBuffer, 0, 0, 0, 0, -1, -1);
|
||||
|
||||
if (mainCropWin && zoom > 0.0) {
|
||||
if(mainCropWin->getZoom() > mainCropWin->cropHandler.getFitZoom()) {
|
||||
Cairo::RefPtr<Cairo::Context> cr = get_window()->create_cairo_context();
|
||||
int x, y, w, h;
|
||||
getObservedFrameArea (x, y, w, h);
|
||||
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));
|
||||
if (mainCropWin && zoom > 0.0) {
|
||||
Cairo::RefPtr<Cairo::Context> cr = get_window()->create_cairo_context();
|
||||
int x, y, w, h;
|
||||
getObservedFrameArea (x, y, w, h);
|
||||
if (x>imgX || y>imgY || w < imgW || h < imgH) {
|
||||
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 (rectX + 1., rectY + 1, rectW, rectH);
|
||||
cr->stroke ();
|
||||
// draw a black "shadow" line
|
||||
cr->set_source_rgba (0.0, 0.0, 0.0, 0.65);
|
||||
cr->set_line_width (1);
|
||||
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 ();
|
||||
}
|
||||
// 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 ();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -191,9 +193,9 @@ bool PreviewWindow::on_motion_notify_event (GdkEventMotion* event)
|
||||
return true;
|
||||
}
|
||||
|
||||
if(mainCropWin->getZoom() > mainCropWin->cropHandler.getFitZoom()) {
|
||||
int x, y, w, h;
|
||||
getObservedFrameArea (x, y, w, h);
|
||||
int x, y, w, h;
|
||||
getObservedFrameArea (x, y, w, h);
|
||||
if (x>imgX || y>imgY || w < imgW || h < imgH) {
|
||||
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;
|
||||
|
||||
@@ -207,7 +209,7 @@ bool PreviewWindow::on_motion_notify_event (GdkEventMotion* event)
|
||||
cursorManager.setCursor (get_window(), CSArrow);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -218,9 +220,9 @@ bool PreviewWindow::on_button_press_event (GdkEventButton* event)
|
||||
return true;
|
||||
}
|
||||
|
||||
if(mainCropWin->getZoom() > mainCropWin->cropHandler.getFitZoom()) {
|
||||
int x, y, w, h;
|
||||
getObservedFrameArea (x, y, w, h);
|
||||
int x, y, w, h;
|
||||
getObservedFrameArea (x, y, w, h);
|
||||
if (x>imgX || y>imgY || w < imgW || h < imgH) {
|
||||
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;
|
||||
|
||||
|
Reference in New Issue
Block a user