Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Hutchinson <m.j.hutchinson@gmail.com>2011-10-29 04:44:03 +0400
committerMichael Hutchinson <m.j.hutchinson@gmail.com>2011-10-29 04:44:03 +0400
commit7dc4933b653457e5f5c4f482699f9e1972d2cfb5 (patch)
tree5d4337c45b7b6dee1c3a9d124eb2b71de1e39c2c /main/src/addins/VersionControl
parent3fda7e8a029a43e1616280dad786ec51c9d27efe (diff)
Update GTK smooth scrolling support and enable it
Diffstat (limited to 'main/src/addins/VersionControl')
-rw-r--r--main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/BlameWidget.cs34
-rw-r--r--main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/EditorCompareWidgetBase.cs27
2 files changed, 21 insertions, 40 deletions
diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/BlameWidget.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/BlameWidget.cs
index 48b4165c79..3147c6850b 100644
--- a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/BlameWidget.cs
+++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/BlameWidget.cs
@@ -259,31 +259,19 @@ namespace MonoDevelop.VersionControl.Views
}
}
- static double GetWheelDelta (Scrollbar scrollbar, ScrollDirection direction)
- {
- double delta = System.Math.Pow (scrollbar.Adjustment.PageSize, 2.0 / 3.0);
- if (direction == ScrollDirection.Up || direction == ScrollDirection.Left)
- delta = -delta;
- if (scrollbar.Inverted)
- delta = -delta;
- return delta;
- }
-
protected override bool OnScrollEvent (EventScroll evnt)
{
- var direction = evnt.Direction;
- Scrollbar scrollWidget = (direction == ScrollDirection.Up || direction == ScrollDirection.Down)
- ? (Scrollbar)vScrollBar
- : hScrollBar;
-
- if (!scrollWidget.Visible)
- return base.OnScrollEvent (evnt);
-
- var adj = scrollWidget.Adjustment;
- double newValue = adj.Value + GtkWorkarounds.GetScrollWheelDelta (evnt, adj.PageSize, scrollWidget.Inverted);
- newValue = System.Math.Max (System.Math.Min (adj.Upper - adj.PageSize, newValue), adj.Lower);
- adj.Value = newValue;
- return true;
+ var alloc = Allocation;
+ double dx, dy;
+ evnt.GetPageScrollPixelDeltas (alloc.Width, alloc.Height, out dx, out dy);
+
+ if (dx != 0.0 && hScrollBar.Visible)
+ hAdjustment.AddValueClamped (dx);
+
+ if (dy != 0.0 && vScrollBar.Visible)
+ vAdjustment.AddValueClamped (dy);
+
+ return (dx != 0.0 || dy != 0.0) || base.OnScrollEvent (evnt);
}
protected override void OnSizeRequested (ref Gtk.Requisition requisition)
diff --git a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/EditorCompareWidgetBase.cs b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/EditorCompareWidgetBase.cs
index 79dd6c2ad5..6a12147b2d 100644
--- a/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/EditorCompareWidgetBase.cs
+++ b/main/src/addins/VersionControl/MonoDevelop.VersionControl/MonoDevelop.VersionControl.Views/EditorCompareWidgetBase.cs
@@ -514,24 +514,17 @@ namespace MonoDevelop.VersionControl.Views
protected override bool OnScrollEvent (EventScroll evnt)
{
- double pageSizePx;
- Adjustment adj;
- if (evnt.Direction == ScrollDirection.Up || evnt.Direction == ScrollDirection.Down) {
- pageSizePx = Allocation.Height;
- adj = vAdjustment;
- } else {
- pageSizePx = Allocation.Width;
- adj = hAdjustment;
- }
-
- if (adj.PageSize >= (adj.Upper - adj.Lower))
- return base.OnScrollEvent (evnt);
+ var alloc = Allocation;
+ double dx, dy;
+ evnt.GetPageScrollPixelDeltas (alloc.Width, alloc.Height, out dx, out dy);
+
+ if (dx != 0.0 && hAdjustment.PageSize < (hAdjustment.Upper - hAdjustment.Lower))
+ hAdjustment.AddValueClamped (dx / (alloc.Width / hAdjustment.PageSize));
+
+ if (dy != 0.0 && vAdjustment.PageSize < (vAdjustment.Upper - vAdjustment.Lower))
+ vAdjustment.AddValueClamped (dy / (alloc.Height / vAdjustment.PageSize));
- double deltaPx = GtkWorkarounds.GetScrollWheelDelta (evnt, pageSizePx, false);
- double newValue = adj.Value + adj.PageSize * (deltaPx / pageSizePx);
- newValue = System.Math.Max (System.Math.Min (1.0 - adj.PageSize, newValue), 0.0);
- adj.Value = newValue;
- return true;
+ return (dx != 0.0 || dy != 0.0) || base.OnScrollEvent (evnt);
}
protected override void OnSizeRequested (ref Gtk.Requisition requisition)