Solving issue 735 : "Zooming with mouse wheel should zoom where the mouse is".
The scroll wheel is now used for scrolling the editor's tab content. If you want to change the spin button's/slider's value or combobox entry, press the SHIFT key while using the scroll wheel. This patch also: - reduce the spin buttons size (50px wide, instead of 70px) - reduce the minimum size of the combobox (tool panels can now be narrower before showing the horizontal scrollbar) Note to developers: ------------------- When creating GUI for editor tools, please use the MyComboBox, MyComboBoxText, MySpinButton and MyFileChooserButton derived class only in order to handle the scroll wheel properly (-> #include <guiutils.h>). Known bug: The MyFileChooserButton thas is a FILE_CHOOSER_ACTION_SELECT_FOLDER does not respond correctly to the new behaviour.
This commit is contained in:
@@ -802,16 +802,51 @@ void CropWindow::expose (Cairo::RefPtr<Cairo::Context> cr) {
|
||||
// printf ("etime --> %d, %d\n", t2.etime (t1), t4.etime (t3));
|
||||
}
|
||||
|
||||
// zoom* is called from the zoomPanel
|
||||
void CropWindow::zoomIn () {
|
||||
// calculate the center of the zommed in/out preview given a cursor position
|
||||
void CropWindow::findCenter (int deltaZoom, int& x, int& y) {
|
||||
int cursorX, cursorY;
|
||||
translateCoord(x, y, cursorX, cursorY);
|
||||
|
||||
changeZoom (cropZoom+1);
|
||||
fitZoom = false;
|
||||
int cropX, cropY, cropW, cropH, skip;
|
||||
cropHandler.getWindow (cropX, cropY, cropW, cropH, skip);
|
||||
|
||||
int currCenterX = cropX + cropW/2;
|
||||
int currCenterY = cropY + cropH/2;
|
||||
|
||||
int deltaX = currCenterX - cursorX;
|
||||
int deltaY = currCenterY - cursorY;
|
||||
|
||||
double factor = zoomSteps[cropZoom].zoom / zoomSteps[cropZoom+deltaZoom].zoom;
|
||||
x = cursorX + (int)((double)(deltaX)*factor);
|
||||
y = cursorY + (int)((double)(deltaY)*factor);
|
||||
}
|
||||
|
||||
void CropWindow::zoomOut () {
|
||||
// zoom* is called from the zoomPanel or the scroll wheel in the preview area
|
||||
void CropWindow::zoomIn (bool toCursor, int cursorX, int cursorY) {
|
||||
|
||||
changeZoom (cropZoom-1);
|
||||
int x = -1;
|
||||
int y = -1;
|
||||
|
||||
if (toCursor) {
|
||||
x = cursorX;
|
||||
y = cursorY;
|
||||
}
|
||||
|
||||
changeZoom (cropZoom+1, true, x, y);
|
||||
fitZoom = false;
|
||||
}
|
||||
|
||||
void CropWindow::zoomOut (bool toCursor, int cursorX, int cursorY) {
|
||||
|
||||
int x = -1;
|
||||
int y = -1;
|
||||
|
||||
if (toCursor) {
|
||||
x = cursorX;
|
||||
y = cursorY;
|
||||
}
|
||||
|
||||
changeZoom (cropZoom-1, true, x, y);
|
||||
fitZoom = false;
|
||||
}
|
||||
|
||||
@@ -826,6 +861,14 @@ double CropWindow::getZoom () {
|
||||
return zoomSteps[cropZoom].zoom;
|
||||
}
|
||||
|
||||
bool CropWindow::isMinZoom () {
|
||||
return cropZoom <= 0;
|
||||
}
|
||||
|
||||
bool CropWindow::isMaxZoom () {
|
||||
return cropZoom >= MAXZOOMSTEPS;
|
||||
}
|
||||
|
||||
void CropWindow::setZoom (double zoom) {
|
||||
int cz = MAXZOOMSTEPS;
|
||||
if (zoom < zoomSteps[0].zoom)
|
||||
|
Reference in New Issue
Block a user