[Slim-Checkins] r9535 - in /branches/6.5/server/Slim: Buttons/Input/Choice.pm Buttons/Input/List.pm Buttons/Playlist.pm Player/Client.pm Player/Transporter.pm

adrian at svn.slimdevices.com adrian at svn.slimdevices.com
Sat Sep 9 10:55:22 PDT 2006


Author: adrian
Date: Sat Sep  9 10:55:18 2006
New Revision: 9535

URL: http://svn.slimdevices.com?rev=9535&view=rev
Log:
Bug: N/A
Description: merge -r 9533:9534 from trunk

Modified:
    branches/6.5/server/Slim/Buttons/Input/Choice.pm
    branches/6.5/server/Slim/Buttons/Input/List.pm
    branches/6.5/server/Slim/Buttons/Playlist.pm
    branches/6.5/server/Slim/Player/Client.pm
    branches/6.5/server/Slim/Player/Transporter.pm

Modified: branches/6.5/server/Slim/Buttons/Input/Choice.pm
URL: http://svn.slimdevices.com/branches/6.5/server/Slim/Buttons/Input/Choice.pm?rev=9535&r1=9534&r2=9535&view=diff
==============================================================================
--- branches/6.5/server/Slim/Buttons/Input/Choice.pm (original)
+++ branches/6.5/server/Slim/Buttons/Input/Choice.pm Sat Sep  9 10:55:18 2006
@@ -184,20 +184,9 @@
 	},
 	'knob' => sub {
 		my ($client,$funct,$functarg) = @_;
-		
-		my $dir = $client->knobPos - $client->param('listIndex');
-
-		# Make sure wrap-around pushes in the right direction
-		my $pushDir;
-		my $numItems = scalar @{ $client->param('listRef') };
-		if ( $client->knobPos == 0 && abs($dir) == ( $numItems - 1 ) ) {
-			# wraparound from bottom to top
-			$pushDir = 'down';
-		} elsif ( $client->knobPos == ( $numItems - 1 ) && abs($dir) == ( $numItems - 1 ) ) {
-			# wraparound from top to bottom
-			$pushDir = 'up';
-		}
-
+
+		my ($newPos, $dir, $pushDir, $wrap) = $client->knobListPos();
+		
 		changePos($client, $dir, $funct, $pushDir);
 	},
 	'numberScroll' => sub {

Modified: branches/6.5/server/Slim/Buttons/Input/List.pm
URL: http://svn.slimdevices.com/branches/6.5/server/Slim/Buttons/Input/List.pm?rev=9535&r1=9534&r2=9535&view=diff
==============================================================================
--- branches/6.5/server/Slim/Buttons/Input/List.pm (original)
+++ branches/6.5/server/Slim/Buttons/Input/List.pm Sat Sep  9 10:55:18 2006
@@ -70,20 +70,9 @@
 
 	'knob' => sub {
 		my ($client, $funct, $functarg) = @_;
+
+		my ($newPos, $dir, $pushDir, $wrap) = $client->knobListPos();
 		
-		my $dir = $client->knobPos - $client->param('listIndex');
-
-		# Make sure wrap-around pushes in the right direction
-		my $pushDir;
-		my $numItems = scalar @{ $client->param('listRef') };
-		if ( $client->knobPos == 0 && abs($dir) == ( $numItems - 1 ) ) {
-			# wraparound from bottom to top
-			$pushDir = 'down';
-		} elsif ( $client->knobPos == ( $numItems - 1 ) && abs($dir) == ( $numItems - 1 ) ) {
-			# wraparound from top to bottom
-			$pushDir = 'up';
-		}
-
 		changePos($client, $dir, $funct, $pushDir);
 	},
 

Modified: branches/6.5/server/Slim/Buttons/Playlist.pm
URL: http://svn.slimdevices.com/branches/6.5/server/Slim/Buttons/Playlist.pm?rev=9535&r1=9534&r2=9535&view=diff
==============================================================================
--- branches/6.5/server/Slim/Buttons/Playlist.pm (original)
+++ branches/6.5/server/Slim/Buttons/Playlist.pm Sat Sep  9 10:55:18 2006
@@ -94,12 +94,10 @@
 		'knob' => sub {
 				my ($client, $funct, $functarg) = @_;
 
-				my $newindex = $client->knobPos();
 				my $oldindex = browseplaylistindex($client);
 				my $songcount = Slim::Player::Playlist::count($client);
 
-				# XXXX assume list is long enough for wrapround to only occur when:
-				my $wrap = (abs($newindex - $oldindex) > $songcount / 2); 
+				my ($newindex, $dir, $pushDir, $wrap) = $client->knobListPos($oldindex, $songcount || 1);
 
 				if ($oldindex != $newindex && $songcount > 1) {
 					browseplaylistindex($client,$newindex);
@@ -111,23 +109,12 @@
 
 				if ($songcount < 2) {
 					
-					if ($newindex < 0) {
-
-						$client->bumpDown;
-
-					} elsif ($newindex > 0) {
-
-						$client->bumpUp;
-
-					}
-
-				} elsif ($oldindex > $newindex && !$wrap || $oldindex < $newindex && $wrap) {
-
-					$client->pushUp;
+					$pushDir eq 'up' ? $client->bumpUp : $client->bumpDown;
 
 				} else {
 
-					$client->pushDown;
+					$pushDir eq 'up' ? $client->pushUp : $client->pushDown;
+
 				}
 		},
 

Modified: branches/6.5/server/Slim/Player/Client.pm
URL: http://svn.slimdevices.com/branches/6.5/server/Slim/Player/Client.pm?rev=9535&r1=9534&r2=9535&view=diff
==============================================================================
--- branches/6.5/server/Slim/Player/Client.pm (original)
+++ branches/6.5/server/Slim/Player/Client.pm Sat Sep  9 10:55:18 2006
@@ -719,6 +719,7 @@
 sub prevline2 {}
 sub currBrightness {}
 sub linesPerScreen {}
+sub knobListPos {}
 
 sub pause {
 	my $client = shift;

Modified: branches/6.5/server/Slim/Player/Transporter.pm
URL: http://svn.slimdevices.com/branches/6.5/server/Slim/Player/Transporter.pm?rev=9535&r1=9534&r2=9535&view=diff
==============================================================================
--- branches/6.5/server/Slim/Player/Transporter.pm (original)
+++ branches/6.5/server/Slim/Player/Transporter.pm Sat Sep  9 10:55:18 2006
@@ -138,6 +138,47 @@
 	}
 }
 
+sub knobListPos {
+	my $client = shift;
+	my $curPos = shift || $client->param('listIndex');
+	my $listLen = shift || $client->param('listLen') || scalar @{ $client->param('listRef') };
+
+	my $newPos = $client->knobPos();
+
+	my ($direction, $wrap);
+
+	if ($listLen == 1) {
+
+		# knob return negative value anti-clockwise and +1 for clockwise
+		$direction = $newPos > 0 ? 'up' : 'down';
+		$newPos = $curPos;
+
+	} elsif ($listLen == 2) {
+
+		# knob returns pos + 2 for list of 2 items when moving anti-clockwise
+		if ($newPos > 1) {
+			$newPos = $newPos - 2;
+			$direction = 'up';
+		} else {
+			$direction = 'down';
+		}
+
+	} else {
+
+		# assume movement of more than 1/2 of list means wrapping round
+		my $wrap = (abs($newPos - $curPos) > $listLen / 2); 
+		
+		if ($newPos > $curPos && !$wrap || $newPos < $curPos && $wrap) {
+			$direction = 'down';
+		} else {
+			$direction = 'up';
+		}
+		
+	}
+
+	return ($newPos, $newPos - $curPos, $direction, $wrap);
+}
+
 sub model {
 	return 'transporter';
 }



More information about the checkins mailing list