Created
November 17, 2008 11:50
-
-
Save snaka/25731 to your computer and use it in GitHub Desktop.
Ganttproject2.0,7 patch for mouse wheel behavior
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Please see for more info. | |
http://sumimasen2.blogspot.com/2008/11/hack-ganttproject-for-mouse-wheel.html |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: D:/MyProject/GanttProject/ganttproject/src/net/sourceforge/ganttproject/ChartComponentBase.java | |
=================================================================== | |
--- D:/MyProject/GanttProject/ganttproject/src/net/sourceforge/ganttproject/ChartComponentBase.java (revision 118) | |
+++ D:/MyProject/GanttProject/ganttproject/src/net/sourceforge/ganttproject/ChartComponentBase.java (working copy) | |
@@ -290,7 +290,14 @@ | |
protected class MouseWheelListenerBase implements MouseWheelListener { | |
public void mouseWheelMoved(MouseWheelEvent e) { | |
- if (isRotationUp(e)) { | |
+ // Scroll | |
+ if (!e.isControlDown()) { | |
+ scrollTreePane(e.getWheelRotation() * 90) | |
+ return | |
+ } | |
+ | |
+ // Zoom | |
+ if (isRotationUp(e)) { | |
fireZoomOut() | |
} else { | |
fireZoomIn() | |
@@ -313,6 +320,9 @@ | |
return e.getWheelRotation() < 0 | |
} | |
} | |
+ | |
+ protected void scrollTreePane(int amount) { | |
+ } | |
protected abstract AbstractChartImplementation getImplementation() | |
Index: D:/MyProject/GanttProject/ganttproject/src/net/sourceforge/ganttproject/GanttGraphicArea.java | |
=================================================================== | |
--- D:/MyProject/GanttProject/ganttproject/src/net/sourceforge/ganttproject/GanttGraphicArea.java (revision 118) | |
+++ D:/MyProject/GanttProject/ganttproject/src/net/sourceforge/ganttproject/GanttGraphicArea.java (working copy) | |
@@ -973,6 +973,13 @@ | |
setActiveInteraction(new MoveTaskInteractions(e, tasks)) | |
} | |
} | |
+ | |
+ /** | |
+ * Scrolling by relative amount. | |
+ */ | |
+ protected void scrollTreePane(int amount) { | |
+ tree.scrollVertical(amount) | |
+ } | |
private class NewChartComponentImpl extends ChartImplementationBase | |
implements ChartImplementation { | |
Index: D:/MyProject/GanttProject/ganttproject/src/net/sourceforge/ganttproject/GanttTree2.java | |
=================================================================== | |
--- D:/MyProject/GanttProject/ganttproject/src/net/sourceforge/ganttproject/GanttTree2.java (revision 118) | |
+++ D:/MyProject/GanttProject/ganttproject/src/net/sourceforge/ganttproject/GanttTree2.java (working copy) | |
@@ -558,6 +558,24 @@ | |
+ (vbar.isVisible() ? vbar.getWidth() : 0), y - vbar.getValue() | |
+ 20) | |
} | |
+ | |
+ /** | |
+ * Scroll up/down | |
+ */ | |
+ public void scrollVertical(int amount) { | |
+ int originalValue = vbar.getValue() | |
+ | |
+ int newValue = originalValue + amount | |
+ | |
+ if (newValue < vbar.getMinimum()) { | |
+ newValue = vbar.getMinimum() | |
+ } | |
+ else if (vbar.getMaximum() < newValue) { | |
+ newValue = vbar.getMaximum() | |
+ } | |
+ | |
+ vbar.setValue(newValue) | |
+ } | |
/** Change grpahic part */ | |
public void setGraphicArea(GanttGraphicArea area) { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment