banshee r3647 - in trunk/banshee: . src/Core/Banshee.ThickClient/Banshee.Gui.Widgets src/Core/Banshee.ThickClient/Banshee.Sources.Gui src/Libraries/Hyena.Gui src/Libraries/Hyena.Gui/Hyena.Gui.Theatrics src/Libraries/Hyena.Gui/Hyena.Widgets
- From: scottp svn gnome org
- To: svn-commits-list gnome org
- Subject: banshee r3647 - in trunk/banshee: . src/Core/Banshee.ThickClient/Banshee.Gui.Widgets src/Core/Banshee.ThickClient/Banshee.Sources.Gui src/Libraries/Hyena.Gui src/Libraries/Hyena.Gui/Hyena.Gui.Theatrics src/Libraries/Hyena.Gui/Hyena.Widgets
- Date: Wed, 2 Apr 2008 18:44:44 +0100 (BST)
Author: scottp
Date: Wed Apr 2 18:44:44 2008
New Revision: 3647
URL: http://svn.gnome.org/viewvc/banshee?rev=3647&view=rev
Log:
This adds experimental smooth scrolling. The behavior still needs to be
tweaked, and comments/opinions are welcome. To enable smooth
scrolling, run banshee with the command line argument --smooth-scroll.
* src/Core/Banshee.ThickClient/Banshee.Gui.Widgets/UserJobTileHost.cs:
* src/Libraries/Hyena.Gui/Hyena.Widgets/AnimatedBox.cs:
* src/Libraries/Hyena.Gui/Hyena.Widgets/AnimatedVBox.cs:
* src/Libraries/Hyena.Gui/Hyena.Widgets/AnimatedHBox.cs:
* src/Libraries/Hyena.Gui/Hyena.Widgets/AnimatedWidget.cs:
* src/Libraries/Hyena.Gui/Hyena.Gui.Theatrics/Choreographer.cs: Fixed
some namespace stuff.
* src/Core/Banshee.ThickClient/Banshee.Sources.Gui/CompositeTrackSourceContents.cs:
Use smooth scrolling if --smooth-scroll command argument is passed.
* src/Libraries/Hyena.Gui/Hyena.Widgets/SmoothScrolledWindow.cs: A
first-pass smooth scrolling widget.
Added:
trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Widgets/SmoothScrolledWindow.cs
Modified:
trunk/banshee/ChangeLog
trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui.Widgets/UserJobTileHost.cs
trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/CompositeTrackSourceContents.cs
trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Gui.Theatrics/Choreographer.cs
trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Gui.mdp
trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Widgets/AnimatedBox.cs
trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Widgets/AnimatedHBox.cs
trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Widgets/AnimatedVBox.cs
trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Widgets/AnimatedWidget.cs
trunk/banshee/src/Libraries/Hyena.Gui/Makefile.am
Modified: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui.Widgets/UserJobTileHost.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui.Widgets/UserJobTileHost.cs (original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Gui.Widgets/UserJobTileHost.cs Wed Apr 2 18:44:44 2008
@@ -31,7 +31,7 @@
using Gtk;
-using Hyena.Gui;
+using Hyena.Widgets;
using Banshee.Base;
using Banshee.ServiceStack;
Modified: trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/CompositeTrackSourceContents.cs
==============================================================================
--- trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/CompositeTrackSourceContents.cs (original)
+++ trunk/banshee/src/Core/Banshee.ThickClient/Banshee.Sources.Gui/CompositeTrackSourceContents.cs Wed Apr 2 18:44:44 2008
@@ -36,6 +36,7 @@
using Hyena.Data;
using Hyena.Data.Gui;
+using Hyena.Widgets;
using Banshee.Sources;
using Banshee.ServiceStack;
@@ -58,9 +59,9 @@
private Dictionary<object, double> model_positions = new Dictionary<object, double> ();
- private ScrolledWindow artist_scrolled_window;
- private ScrolledWindow album_scrolled_window;
- private ScrolledWindow track_scrolled_window;
+ private Gtk.ScrolledWindow artist_scrolled_window;
+ private Gtk.ScrolledWindow album_scrolled_window;
+ private Gtk.ScrolledWindow track_scrolled_window;
private bool view_is_built = false;
private Paned container;
@@ -140,17 +141,24 @@
artist_view.HeaderVisible = false;
album_view.HeaderVisible = false;
- artist_scrolled_window = new ScrolledWindow ();
+ if (Banshee.Base.ApplicationContext.CommandLine.Contains ("smooth-scroll")) {
+ artist_scrolled_window = new SmoothScrolledWindow ();
+ album_scrolled_window = new SmoothScrolledWindow ();
+ track_scrolled_window = new SmoothScrolledWindow ();
+ } else {
+ artist_scrolled_window = new Gtk.ScrolledWindow ();
+ album_scrolled_window = new Gtk.ScrolledWindow ();
+ track_scrolled_window = new Gtk.ScrolledWindow ();
+ }
+
artist_scrolled_window.Add (artist_view);
artist_scrolled_window.HscrollbarPolicy = PolicyType.Automatic;
artist_scrolled_window.VscrollbarPolicy = PolicyType.Automatic;
- album_scrolled_window = new ScrolledWindow ();
album_scrolled_window.Add (album_view);
album_scrolled_window.HscrollbarPolicy = PolicyType.Automatic;
album_scrolled_window.VscrollbarPolicy = PolicyType.Automatic;
- track_scrolled_window = new ScrolledWindow ();
track_scrolled_window.Add (track_view);
track_scrolled_window.HscrollbarPolicy = PolicyType.Automatic;
track_scrolled_window.VscrollbarPolicy = PolicyType.Automatic;
Modified: trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Gui.Theatrics/Choreographer.cs
==============================================================================
--- trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Gui.Theatrics/Choreographer.cs (original)
+++ trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Gui.Theatrics/Choreographer.cs Wed Apr 2 18:44:44 2008
@@ -27,8 +27,9 @@
//
using System;
+using Hyena.Widgets;
-namespace Hyena.Gui
+namespace Hyena.Widgets
{
public enum Blocking
{
@@ -46,7 +47,10 @@
ExponentialOut,
ExponentialInOut
}
-
+}
+
+namespace Hyena.Gui.Theatrics
+{
public static class Choreographer
{
public static int Compose (double percent, int size, Easing easing)
Modified: trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Gui.mdp
==============================================================================
--- trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Gui.mdp (original)
+++ trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Gui.mdp Wed Apr 2 18:44:44 2008
@@ -1,4 +1,4 @@
-<Project name="Hyena.Gui" fileversion="2.0" UseParentDirectoryAsNamespace="True" language="C#" clr-version="Net_2_0" ctype="DotNetProject">
+<Project name="Hyena.Gui" fileversion="2.0" language="C#" clr-version="Net_2_0" UseParentDirectoryAsNamespace="True" ctype="DotNetProject">
<Configurations active="Debug">
<Configuration name="Debug" ctype="DotNetProjectConfiguration">
<Output directory="../../../bin" assembly="Hyena.Gui" />
@@ -64,6 +64,7 @@
<File name="Hyena.Query.Gui/RelativeTimeSpanQueryValueEntry.cs" subtype="Code" buildaction="Compile" />
<File name="Hyena.Query.Gui/TimeSpanQueryValueEntry.cs" subtype="Code" buildaction="Compile" />
<File name="Hyena.Data.Gui/IListView.cs" subtype="Code" buildaction="Compile" />
+ <File name="Hyena.Widgets/SmoothScrolledWindow.cs" subtype="Code" buildaction="Compile" />
</Contents>
<References>
<ProjectReference type="Gac" localcopy="True" refto="System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
Modified: trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Widgets/AnimatedBox.cs
==============================================================================
--- trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Widgets/AnimatedBox.cs (original)
+++ trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Widgets/AnimatedBox.cs Wed Apr 2 18:44:44 2008
@@ -34,7 +34,7 @@
using Hyena.Gui.Theatrics;
-namespace Hyena.Gui
+namespace Hyena.Widgets
{
public abstract class AnimatedBox : Container
{
Modified: trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Widgets/AnimatedHBox.cs
==============================================================================
--- trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Widgets/AnimatedHBox.cs (original)
+++ trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Widgets/AnimatedHBox.cs Wed Apr 2 18:44:44 2008
@@ -30,7 +30,7 @@
using Gdk;
using Gtk;
-namespace Hyena.Gui
+namespace Hyena.Widgets
{
public class AnimatedHBox : AnimatedBox
{
Modified: trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Widgets/AnimatedVBox.cs
==============================================================================
--- trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Widgets/AnimatedVBox.cs (original)
+++ trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Widgets/AnimatedVBox.cs Wed Apr 2 18:44:44 2008
@@ -30,7 +30,7 @@
using Gdk;
using Gtk;
-namespace Hyena.Gui
+namespace Hyena.Widgets
{
public class AnimatedVBox : AnimatedBox
{
Modified: trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Widgets/AnimatedWidget.cs
==============================================================================
--- trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Widgets/AnimatedWidget.cs (original)
+++ trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Widgets/AnimatedWidget.cs Wed Apr 2 18:44:44 2008
@@ -31,7 +31,9 @@
using Gdk;
using Gtk;
-namespace Hyena.Gui
+using Hyena.Gui.Theatrics;
+
+namespace Hyena.Widgets
{
internal enum AnimationState
{
Added: trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Widgets/SmoothScrolledWindow.cs
==============================================================================
--- (empty file)
+++ trunk/banshee/src/Libraries/Hyena.Gui/Hyena.Widgets/SmoothScrolledWindow.cs Wed Apr 2 18:44:44 2008
@@ -0,0 +1,145 @@
+// SmoothScrolledWindow.cs
+//
+// Copyright (c) 2008 Scott Peterson <lunchtimemama gmail com>
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+//
+
+using System;
+using Gdk;
+using Gtk;
+
+using Hyena.Gui.Theatrics;
+
+namespace Hyena.Widgets
+{
+ public class SmoothScrolledWindow : Gtk.ScrolledWindow
+ {
+ private bool ignore_value_changed;
+ private uint timeout;
+ private double value;
+ private double target_value;
+ private double velocity = 0;
+
+ protected virtual double MaxVelocity {
+ get { return Vadjustment.StepIncrement * 4; }
+ }
+
+ private double Accelerate (double velocity)
+ {
+ return Math.Min (AccelerateCore (velocity), MaxVelocity);
+ }
+
+ private double Decelerate (double velocity)
+ {
+ return Math.Max (DecelerateCore (velocity), 0);
+ }
+
+ protected virtual double AccelerateCore (double velocity)
+ {
+ return velocity + 2;
+ }
+
+ protected virtual double DecelerateCore (double velocity)
+ {
+ return velocity - 1;
+ }
+
+ private double TargetValue {
+ get { return target_value; }
+ set {
+ if (value == target_value) {
+ return;
+ }
+
+ target_value = value;
+ if (timeout == 0) {
+ timeout = GLib.Timeout.Add (20, OnTimeout);
+ }
+ }
+ }
+
+ private bool OnTimeout ()
+ {
+ double delta = target_value - value;
+ if (delta == 0) {
+ velocity = 0;
+ timeout = 0;
+ return false;
+ }
+
+ int sign = Math.Sign (delta);
+ delta = Math.Abs (delta);
+
+ velocity = TimeToAccelerate (delta) ? Accelerate (velocity) : Decelerate (velocity);
+
+ value += Math.Max (velocity, 0.5) * sign;
+ ignore_value_changed = true;
+ Vadjustment.Value = Math.Round (value);
+ ignore_value_changed = false;
+
+ return true;
+ }
+
+ private bool TimeToAccelerate (double delta)
+ {
+ double hypothetical = delta;
+ double v = Accelerate (velocity);
+ while (v > 0) {
+ hypothetical -= v;
+ v = Decelerate (v);
+ }
+ return hypothetical > 0;
+ }
+
+ protected override bool OnScrollEvent (Gdk.EventScroll evnt)
+ {
+ switch (evnt.Direction) {
+ case ScrollDirection.Up:
+ TargetValue = Math.Max (TargetValue - Vadjustment.StepIncrement, 0);
+ break;
+ case ScrollDirection.Down:
+ TargetValue = Math.Min (TargetValue + Vadjustment.StepIncrement, Vadjustment.Upper - Vadjustment.PageSize);
+ break;
+ default:
+ return base.OnScrollEvent (evnt);
+ }
+ return true;
+ }
+
+ protected override void OnRealized ()
+ {
+ base.OnRealized ();
+ Vadjustment.ValueChanged += OnValueChanged;
+ }
+
+ protected override void OnUnrealized ()
+ {
+ Vadjustment.ValueChanged -= OnValueChanged;
+ base.OnUnrealized ();
+ }
+
+ private void OnValueChanged (object o, EventArgs args)
+ {
+ if (!ignore_value_changed) {
+ value = target_value = Vadjustment.Value;
+ }
+ }
+ }
+}
Modified: trunk/banshee/src/Libraries/Hyena.Gui/Makefile.am
==============================================================================
--- trunk/banshee/src/Libraries/Hyena.Gui/Makefile.am (original)
+++ trunk/banshee/src/Libraries/Hyena.Gui/Makefile.am Wed Apr 2 18:44:44 2008
@@ -57,7 +57,8 @@
Hyena.Widgets/AnimatedWidget.cs \
Hyena.Widgets/MessageBar.cs \
Hyena.Widgets/RoundedFrame.cs \
- Hyena.Widgets/ScrolledWindow.cs
+ Hyena.Widgets/ScrolledWindow.cs \
+ Hyena.Widgets/SmoothScrolledWindow.cs
include $(top_srcdir)/build/build.mk
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]