From: Chip Black Date: Wed, 16 Sep 2009 04:14:39 +0000 (-0500) Subject: Fix scrolling functionality X-Git-Url: http://git.bytex64.net/?a=commitdiff_plain;h=2744fefc32dbe9b59a570f6515d51121b8fcfbe3;hp=de68be10ae8d84f85431c704bb06d89e4d93cc98;p=WebThing.git Fix scrolling functionality Added Scroll(x, y) and Bump(x, y) functions to WebThing. Scroll moves in pixels (or whatever unit measure Gtk uses), and Bump moves in default scroll increments (like what you'd get if you used the arrow keys). --- diff --git a/WebThing.cs b/WebThing.cs index 8bc589a..ff51354 100644 --- a/WebThing.cs +++ b/WebThing.cs @@ -225,5 +225,18 @@ namespace bytex64.WebThing { wtv.WebView.Open(uri); return true; } + + public void Scroll(double x, double y) { + ScrolledWindow.Hadjustment.Value += x; + if (ScrolledWindow.Hadjustment.Value > ScrolledWindow.Hadjustment.Upper - ScrolledWindow.Hadjustment.PageSize) + ScrolledWindow.Hadjustment.Value = ScrolledWindow.Hadjustment.Upper - ScrolledWindow.Hadjustment.PageSize; + ScrolledWindow.Vadjustment.Value += y; + if (ScrolledWindow.Vadjustment.Value > ScrolledWindow.Vadjustment.Upper - ScrolledWindow.Vadjustment.PageSize) + ScrolledWindow.Vadjustment.Value = ScrolledWindow.Vadjustment.Upper - ScrolledWindow.Vadjustment.PageSize; + } + + public void Bump(int x, int y) { + Scroll(x * ScrolledWindow.Hadjustment.StepIncrement, y * ScrolledWindow.Vadjustment.StepIncrement); + } } } diff --git a/plugins/Vimish.cs b/plugins/Vimish.cs index 51c2cfc..22f2532 100644 --- a/plugins/Vimish.cs +++ b/plugins/Vimish.cs @@ -66,16 +66,16 @@ public class Vimish : WebThingPlugin { if (e.Event.State == Gdk.ModifierType.None) { switch(e.Event.Key) { case Gdk.Key.j: - wt.ScrolledWindow.Vadjustment.Value += wt.ScrolledWindow.Vadjustment.StepIncrement; + wt.Bump(0, 1); break; case Gdk.Key.k: - wt.ScrolledWindow.Vadjustment.Value -= wt.ScrolledWindow.Vadjustment.StepIncrement; + wt.Bump(0, -1); break; case Gdk.Key.l: - wt.ScrolledWindow.Hadjustment.Value += wt.ScrolledWindow.Hadjustment.StepIncrement; + wt.Bump(1, 0); break; case Gdk.Key.h: - wt.ScrolledWindow.Hadjustment.Value -= wt.ScrolledWindow.Hadjustment.StepIncrement; + wt.Bump(-1, 0); break; case Gdk.Key.r: wv.Reload();