diff --git a/rtgui/crophandler.cc b/rtgui/crophandler.cc index 2d6fd79ce..f9fc597ce 100644 --- a/rtgui/crophandler.cc +++ b/rtgui/crophandler.cc @@ -297,7 +297,7 @@ void CropHandler::update () { // To save threads, try to mark "needUpdate" without a thread first if (crop->tryUpdate()) { if (isLowUpdatePriority) - Glib::Thread::create(sigc::mem_fun(*crop, &DetailedCrop::fullUpdate), 0, false, true, Glib::THREAD_PRIORITY_LOW); + Glib::Thread::create(sigc::mem_fun(*crop, &DetailedCrop::fullUpdate), 0, false, true, Glib::THREAD_PRIORITY_LOW); else Glib::Thread::create(sigc::mem_fun(*crop, &DetailedCrop::fullUpdate), false ); } diff --git a/rtgui/cropwindow.cc b/rtgui/cropwindow.cc index 71082a79a..dc36f5b4b 100644 --- a/rtgui/cropwindow.cc +++ b/rtgui/cropwindow.cc @@ -1273,7 +1273,7 @@ void CropWindow::cropImageUpdated () { void CropWindow::cropWindowChanged () { if (!decorated) - iarea->updateScrollbars (); + iarea->syncBeforeAfterViews (); iarea->redraw (); } diff --git a/rtgui/editorpanel.cc b/rtgui/editorpanel.cc index 744fc23a6..1202fd307 100644 --- a/rtgui/editorpanel.cc +++ b/rtgui/editorpanel.cc @@ -128,7 +128,7 @@ EditorPanel::EditorPanel (FilePanel* filePanel) Gtk::VSeparator* vsepz3 = Gtk::manage (new Gtk::VSeparator ()); Gtk::VSeparator* vsepz4 = Gtk::manage (new Gtk::VSeparator ()); - iarea = new ImageAreaPanel (); + iareapanel = new ImageAreaPanel (); Gtk::HBox* toolBarPanel = Gtk::manage (new Gtk::HBox ()); toolBarPanel->pack_start (*hidehp, Gtk::PACK_SHRINK, 1); @@ -143,13 +143,13 @@ EditorPanel::EditorPanel (FilePanel* filePanel) toolBarPanel->pack_end (*vsep1, Gtk::PACK_SHRINK, 2); toolBarPanel->pack_end (*tpc->coarse, Gtk::PACK_SHRINK, 2); toolBarPanel->pack_end (*vsepcl, Gtk::PACK_SHRINK, 2); - toolBarPanel->pack_end (*iarea->imageArea->indClippedPanel, Gtk::PACK_SHRINK, 0); + toolBarPanel->pack_end (*iareapanel->imageArea->indClippedPanel, Gtk::PACK_SHRINK, 0); toolBarPanel->pack_end (*vsepz, Gtk::PACK_SHRINK, 2); - toolBarPanel->pack_end (*iarea->imageArea->previewModePanel, Gtk::PACK_SHRINK, 0); + toolBarPanel->pack_end (*iareapanel->imageArea->previewModePanel, Gtk::PACK_SHRINK, 0); toolBarPanel->pack_end (*vsepz4, Gtk::PACK_SHRINK, 2); afterBox = Gtk::manage (new Gtk::VBox ()); - afterBox->pack_start (*iarea); + afterBox->pack_start (*iareapanel); beforeAfterBox = Gtk::manage (new Gtk::HBox()); beforeAfterBox->pack_start (*afterBox); @@ -215,7 +215,7 @@ EditorPanel::EditorPanel (FilePanel* filePanel) iops->pack_end (*vsepz2, Gtk::PACK_SHRINK,1); // Zoom panel - iops->pack_end (*iarea->imageArea->zoomPanel, Gtk::PACK_SHRINK, 1); + iops->pack_end (*iareapanel->imageArea->zoomPanel, Gtk::PACK_SHRINK, 1); iops->pack_end (*vsepz3, Gtk::PACK_SHRINK, 2); editbox->pack_start (*Gtk::manage(new Gtk::HSeparator()), Gtk::PACK_SHRINK, 0); @@ -274,9 +274,9 @@ EditorPanel::EditorPanel (FilePanel* filePanel) tpc->addPParamsChangeListener (profilep); tpc->addPParamsChangeListener (history); tpc->addPParamsChangeListener (this); - iarea->imageArea->setCropGUIListener (tpc->getCropGUIListener()); - iarea->imageArea->setPointerMotionListener (navigator); - iarea->imageArea->setImageAreaToolListener (tpc); + iareapanel->imageArea->setCropGUIListener (tpc->getCropGUIListener()); + iareapanel->imageArea->setPointerMotionListener (navigator); + iareapanel->imageArea->setImageAreaToolListener (tpc); // initialize components info->set_active (options.showInfo); @@ -298,9 +298,9 @@ EditorPanel::~EditorPanel () { history->setHistoryBeforeLineListener (NULL); // the order is important! - iarea->setBeforeAfterViews (NULL, iarea); - delete iarea; - iarea = NULL; + iareapanel->setBeforeAfterViews (NULL, iareapanel); + delete iareapanel; + iareapanel = NULL; if (beforeIpc) beforeIpc->stopProcessing (); @@ -394,10 +394,10 @@ void EditorPanel::open (Thumbnail* tmb, rtengine::InitialImage* isrc) { ipc->setHistogramListener (this); // iarea->fitZoom (); // tell to the editorPanel that the next image has to be fitted to the screen - iarea->imageArea->setPreviewHandler (previewHandler); - iarea->imageArea->setImProcCoordinator (ipc); + iareapanel->imageArea->setPreviewHandler (previewHandler); + iareapanel->imageArea->setImProcCoordinator (ipc); navigator->previewWindow->setPreviewHandler (previewHandler); - navigator->previewWindow->setImageArea (iarea->imageArea); + navigator->previewWindow->setImageArea (iareapanel->imageArea); rtengine::ImageSource* is=isrc->getImageSource(); is->setProgressListener( this ); @@ -420,17 +420,17 @@ void EditorPanel::open (Thumbnail* tmb, rtengine::InitialImage* isrc) { // If in single tab mode, the main crop window is not constructed the very first time // since there was no resize event - if (iarea->imageArea->mainCropWindow) + if (iareapanel->imageArea->mainCropWindow) { - iarea->imageArea->mainCropWindow->cropHandler.newImage(ipc); - iarea->imageArea->mainCropWindow->initialImageArrived(); + iareapanel->imageArea->mainCropWindow->cropHandler.newImage(ipc); + iareapanel->imageArea->mainCropWindow->initialImageArrived(); // In single tab mode, the image is not always updated between switches // normal redraw don't work, so this is the hard way - if (!options.tabbedUI) iarea->imageArea->mainCropWindow->cropHandler.update(); + if (!options.tabbedUI) iareapanel->imageArea->mainCropWindow->cropHandler.update(); } else { Gtk::Allocation alloc; - iarea->imageArea->on_resized(alloc); + iareapanel->imageArea->on_resized(alloc); } } @@ -453,10 +453,10 @@ void EditorPanel::close () { delete previewHandler; previewHandler= NULL; - if(iarea) + if(iareapanel) { - iarea->imageArea->setPreviewHandler (NULL); - iarea->imageArea->setImProcCoordinator (NULL); + iareapanel->imageArea->setPreviewHandler (NULL); + iareapanel->imageArea->setImProcCoordinator (NULL); } rtengine::StagedImageProcessor::destroy (ipc); ipc = NULL; @@ -700,8 +700,8 @@ void EditorPanel::info_toggled () { else infoString = M("QINFO_NOEXIF"); - iarea->imageArea->setInfoText (infoString); - iarea->imageArea->infoEnabled (info->get_active ()); + iareapanel->imageArea->setInfoText (infoString); + iareapanel->imageArea->infoEnabled (info->get_active ()); } void EditorPanel::hideHistoryActivated () { @@ -832,40 +832,40 @@ bool EditorPanel::handleShortcutKey (GdkEventKey* event) { return true; case GDK_plus: case GDK_equal: - iarea->imageArea->zoomPanel->zoomInClicked(); + iareapanel->imageArea->zoomPanel->zoomInClicked(); return true; case GDK_minus: case GDK_underscore: - iarea->imageArea->zoomPanel->zoomOutClicked(); + iareapanel->imageArea->zoomPanel->zoomOutClicked(); return true; case GDK_1: - iarea->imageArea->zoomPanel->zoom11Clicked(); + iareapanel->imageArea->zoomPanel->zoom11Clicked(); return true; case GDK_r: //preview mode Red - iarea->imageArea->previewModePanel->toggleR(); + iareapanel->imageArea->previewModePanel->toggleR(); return true; case GDK_g: //preview mode Green - iarea->imageArea->previewModePanel->toggleG(); + iareapanel->imageArea->previewModePanel->toggleG(); return true; case GDK_b: //preview mode Blue - iarea->imageArea->previewModePanel->toggleB(); + iareapanel->imageArea->previewModePanel->toggleB(); return true; case GDK_v: //preview mode Luminosity - iarea->imageArea->previewModePanel->toggleL(); + iareapanel->imageArea->previewModePanel->toggleL(); return true; case GDK_F: //preview mode Focus Mask - iarea->imageArea->previewModePanel->toggleFocusMask(); + iareapanel->imageArea->previewModePanel->toggleFocusMask(); return true; case GDK_f: - iarea->imageArea->zoomPanel->zoomFitClicked(); + iareapanel->imageArea->zoomPanel->zoomFitClicked(); return true; case GDK_less: - iarea->imageArea->indClippedPanel->toggleClipped(true); + iareapanel->imageArea->indClippedPanel->toggleClipped(true); return true; case GDK_greater: - iarea->imageArea->indClippedPanel->toggleClipped(false); + iareapanel->imageArea->indClippedPanel->toggleClipped(false); return true; case GDK_F5: @@ -1248,8 +1248,8 @@ void EditorPanel::beforeAfterToggled () { if (beforeIarea) { if (beforeIpc) beforeIpc->stopProcessing (); - iarea->setBeforeAfterViews (NULL, iarea); - iarea->imageArea->iLinkedImageArea = NULL; + iareapanel->setBeforeAfterViews (NULL, iareapanel); + iareapanel->imageArea->iLinkedImageArea = NULL; delete beforeIarea; beforeIarea = NULL; if (beforeIpc) @@ -1308,12 +1308,12 @@ void EditorPanel::beforeAfterToggled () { beforeIarea->imageArea->setPreviewHandler (beforePreviewHandler); beforeIarea->imageArea->setImProcCoordinator (beforeIpc); - beforeIarea->imageArea->setPreviewModePanel(iarea->imageArea->previewModePanel); - beforeIarea->imageArea->setIndicateClippedPanel(iarea->imageArea->indClippedPanel); - iarea->imageArea->iLinkedImageArea = beforeIarea->imageArea; + beforeIarea->imageArea->setPreviewModePanel(iareapanel->imageArea->previewModePanel); + beforeIarea->imageArea->setIndicateClippedPanel(iareapanel->imageArea->indClippedPanel); + iareapanel->imageArea->iLinkedImageArea = beforeIarea->imageArea; - iarea->setBeforeAfterViews (beforeIarea, iarea); - beforeIarea->setBeforeAfterViews (beforeIarea, iarea); + iareapanel->setBeforeAfterViews (beforeIarea, iareapanel); + beforeIarea->setBeforeAfterViews (beforeIarea, iareapanel); rtengine::procparams::ProcParams params; if (history->getBeforeLineParams (params)) @@ -1447,5 +1447,5 @@ void EditorPanel::updateHistogramPosition (int oldPosition, int newPosition) { break; } - iarea->imageArea->setPointerMotionHListener (histogramPanel); + iareapanel->imageArea->setPointerMotionHListener (histogramPanel); } diff --git a/rtgui/editorpanel.h b/rtgui/editorpanel.h index 2bc445021..e0e12e999 100644 --- a/rtgui/editorpanel.h +++ b/rtgui/editorpanel.h @@ -78,7 +78,7 @@ class EditorPanel : public Gtk::VBox, Gtk::Button* saveimgas; Gtk::Button* sendtogimp; - ImageAreaPanel* iarea; + ImageAreaPanel* iareapanel; PreviewHandler* previewHandler; PreviewHandler* beforePreviewHandler; // for the before-after view Navigator* navigator; diff --git a/rtgui/imagearea.cc b/rtgui/imagearea.cc index 913ab54da..e56fc44ea 100644 --- a/rtgui/imagearea.cc +++ b/rtgui/imagearea.cc @@ -89,7 +89,8 @@ void ImageArea::on_resized (Gtk::Allocation& req) { else { mainCropWindow->setSize (get_width(), get_height()); } - } + parent->syncBeforeAfterViews(); + } } void ImageArea::setImProcCoordinator (rtengine::StagedImageProcessor* ipc_) { @@ -382,19 +383,19 @@ void ImageArea::setScrollPosition (int x, int y) { void ImageArea::cropPositionChanged (CropWindow* cw) { - updateScrollbars (); + syncBeforeAfterViews (); } void ImageArea::cropWindowSizeChanged (CropWindow* cw) { - updateScrollbars (); + syncBeforeAfterViews (); } void ImageArea::cropZoomChanged (CropWindow* cw) { if (cw==mainCropWindow) { parent->zoomChanged (); - updateScrollbars (); + syncBeforeAfterViews (); zoomPanel->refreshZoomLabel (); } } @@ -421,8 +422,8 @@ void ImageArea::initialImageArrived (CropWindow* cw) { mainCropWindow->zoomFit (); } -void ImageArea::updateScrollbars () { - parent->refreshScrollBars (); +void ImageArea::syncBeforeAfterViews () { + parent->syncBeforeAfterViews (); } void ImageArea::setCropGUIListener (CropGUIListener* l) { diff --git a/rtgui/imagearea.h b/rtgui/imagearea.h index f8cf6f704..97b630e63 100644 --- a/rtgui/imagearea.h +++ b/rtgui/imagearea.h @@ -92,7 +92,7 @@ class ImageArea : public Gtk::DrawingArea, public CropWindowListener { bool on_scroll_event (GdkEventScroll* event); void on_resized (Gtk::Allocation& req); void styleChanged (const Glib::RefPtr& style); - void updateScrollbars (); + void syncBeforeAfterViews (); void setCropGUIListener (CropGUIListener* l); void setPointerMotionListener (PointerMotionListener* pml); diff --git a/rtgui/imageareapanel.cc b/rtgui/imageareapanel.cc index b19a3f1ba..e7c91d5e9 100644 --- a/rtgui/imageareapanel.cc +++ b/rtgui/imageareapanel.cc @@ -22,36 +22,20 @@ ImageAreaPanel::ImageAreaPanel () : before(NULL), after(NULL) { set_border_width (2); - Gtk::HBox* hb1 = Gtk::manage (new Gtk::HBox ()); - Gtk::HBox* hb2 = Gtk::manage (new Gtk::HBox ()); - hscroll = Gtk::manage (new Gtk::HScrollbar ()); - vscroll = Gtk::manage (new Gtk::VScrollbar ()); imageArea = new ImageArea (this); + + Gtk::HBox* hb1 = Gtk::manage (new Gtk::HBox ()); Gtk::Frame* frame = Gtk::manage (new Gtk::Frame ()); + frame->add (*imageArea); frame->set_shadow_type (Gtk::SHADOW_IN ); hb1->pack_start (*frame, Gtk::PACK_EXPAND_WIDGET); - hb1->pack_end (*vscroll, Gtk::PACK_SHRINK, 0); pack_start (*hb1); - vscroll->show (); frame->show (); imageArea->show (); hb1->show (); - hb2->pack_start (*hscroll); - - pack_start (*hb2,Gtk::PACK_SHRINK, 0); - hscroll->show (); - hb2->show (); - - hscroll->set_update_policy (Gtk::UPDATE_CONTINUOUS); - vscroll->set_update_policy (Gtk::UPDATE_CONTINUOUS); - - vscrollconn = vscroll->signal_value_changed().connect( sigc::mem_fun(*this, &ImageAreaPanel::scrollChanged) ); - hscrollconn = hscroll->signal_value_changed().connect( sigc::mem_fun(*this, &ImageAreaPanel::scrollChanged) ); - - imageArea->signal_size_allocate().connect( sigc::mem_fun(*this, &ImageAreaPanel::imageAreaResized) ); } ImageAreaPanel::~ImageAreaPanel () { @@ -59,88 +43,21 @@ ImageAreaPanel::~ImageAreaPanel () { delete imageArea; } -void ImageAreaPanel::configScrollBars () { +void ImageAreaPanel::syncBeforeAfterViews () { - int imgw, imgh; - imageArea->getScrollImageSize (imgw, imgh); - - if (imgw>0 && imgh>0) { - - int iw = imageArea->get_width (); - int ih = imageArea->get_height (); - - hscrollconn.block (true); - vscrollconn.block (true); - - hscroll->get_adjustment()->set_upper (imgw); - vscroll->get_adjustment()->set_upper (imgh); - hscroll->get_adjustment()->set_lower (0); - vscroll->get_adjustment()->set_lower (0); - hscroll->get_adjustment()->set_step_increment (imgw/100); - vscroll->get_adjustment()->set_step_increment (imgh/100); - hscroll->get_adjustment()->set_page_increment (imgw/5); - vscroll->get_adjustment()->set_page_increment (imgh/5); - hscroll->get_adjustment()->set_page_size (iw); - vscroll->get_adjustment()->set_page_size (ih); - - int x, y; - imageArea->getScrollPosition (x, y); - hscroll->set_value (x); - vscroll->set_value (y); - - // A "gray zone" where scrollbars stays displayed/hidden between imgw and imgw+30 - // has been introduced to avoid infinite loop. 30px should be enough and represent - // the width of the scrollbar - if(iw >= (imgw+30)) - hscroll->hide(); - else if(iw < imgw) - hscroll->show(); - - if(ih >= (imgh+30)) - vscroll->hide(); - else if(ih < imgh) - vscroll->show(); - - if (before && this==after) - before->synchronize (); - else if (after && this==before) - after->synchronize (); - - hscrollconn.block (false); - vscrollconn.block (false); - } -} - -void ImageAreaPanel::refreshScrollBars () { - - configScrollBars (); - queue_draw (); -} - -void ImageAreaPanel::imageAreaResized (Gtk::Allocation& req) { - - configScrollBars (); - queue_draw (); -} - -void ImageAreaPanel::scrollChanged () { - - imageArea->setScrollPosition ((int)(hscroll->get_value()), (int)(vscroll->get_value())); - imageArea->queue_draw (); -#ifdef WIN32 - gdk_window_process_updates (get_window()->gobj(), true); -#endif - if (before && this==after) + if (before && this==after) before->synchronize (); else if (after && this==before) after->synchronize (); + + queue_draw (); } void ImageAreaPanel::setBeforeAfterViews (ImageAreaPanel* bef, ImageAreaPanel* aft) { before = bef; after = aft; - configScrollBars (); + syncBeforeAfterViews (); } void ImageAreaPanel::zoomChanged () { @@ -153,29 +70,28 @@ void ImageAreaPanel::zoomChanged () { void ImageAreaPanel::synchronize () { - hscrollconn.block (true); - vscrollconn.block (true); - if (after && this==before) { int imgw, imgh, x, y; after->imageArea->getScrollImageSize (imgw, imgh); after->imageArea->getScrollPosition (x, y); - int bimgw, bimgh; - imageArea->getScrollImageSize (bimgw, bimgh); - imageArea->setScrollPosition (x*bimgw/imgw, y*bimgh/imgh); - imageArea->queue_draw (); + if (imgw>0 && imgh>0) { + int bimgw, bimgh; + imageArea->getScrollImageSize (bimgw, bimgh); + imageArea->setScrollPosition (x*bimgw/imgw, y*bimgh/imgh); + imageArea->queue_draw (); + } } else if (before && this==after) { int imgw, imgh, x, y; before->imageArea->getScrollImageSize (imgw, imgh); before->imageArea->getScrollPosition (x, y); - int bimgw, bimgh; - imageArea->getScrollImageSize (bimgw, bimgh); - imageArea->setScrollPosition (x*bimgw/imgw, y*bimgh/imgh); - imageArea->queue_draw (); + if (imgw>0 && imgh>0) { + int bimgw, bimgh; + imageArea->getScrollImageSize (bimgw, bimgh); + imageArea->setScrollPosition (x*bimgw/imgw, y*bimgh/imgh); + imageArea->queue_draw (); + } } - hscrollconn.block (false); - vscrollconn.block (false); } diff --git a/rtgui/imageareapanel.h b/rtgui/imageareapanel.h index afadfe267..1b62682a1 100644 --- a/rtgui/imageareapanel.h +++ b/rtgui/imageareapanel.h @@ -25,15 +25,10 @@ class ImageArea; class ImageAreaPanel : public Gtk::VBox { protected: - Gtk::HScrollbar* hscroll; - Gtk::VScrollbar* vscroll; - sigc::connection hscrollconn; - sigc::connection vscrollconn; + + ImageAreaPanel *before, *after; void synchronize (); - void configScrollBars (); - - ImageAreaPanel *before, *after; public: ImageArea* imageArea; @@ -41,13 +36,10 @@ class ImageAreaPanel : public Gtk::VBox { ImageAreaPanel (); ~ImageAreaPanel (); - void scrollChanged (); - void imageAreaResized (Gtk::Allocation& req); - - void refreshScrollBars (); void zoomChanged (); void setBeforeAfterViews (ImageAreaPanel* bef, ImageAreaPanel* aft); + void syncBeforeAfterViews(); }; #endif