[Slim-Checkins] r9534 - in /trunk/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:42:11 PDT 2006
Author: adrian
Date: Sat Sep 9 10:42:07 2006
New Revision: 9534
URL: http://svn.slimdevices.com?rev=9534&view=rev
Log:
Bug: N/A
Description:
- support for special knob case with list of 2 added in fw14
- new client method knobListPos to hide logic for special cases [listLen of 1 or 2 at present]
Modified:
trunk/server/Slim/Buttons/Input/Choice.pm
trunk/server/Slim/Buttons/Input/List.pm
trunk/server/Slim/Buttons/Playlist.pm
trunk/server/Slim/Player/Client.pm
trunk/server/Slim/Player/Transporter.pm
Modified: trunk/server/Slim/Buttons/Input/Choice.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Buttons/Input/Choice.pm?rev=9534&r1=9533&r2=9534&view=diff
==============================================================================
--- trunk/server/Slim/Buttons/Input/Choice.pm (original)
+++ trunk/server/Slim/Buttons/Input/Choice.pm Sat Sep 9 10:42:07 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: trunk/server/Slim/Buttons/Input/List.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Buttons/Input/List.pm?rev=9534&r1=9533&r2=9534&view=diff
==============================================================================
--- trunk/server/Slim/Buttons/Input/List.pm (original)
+++ trunk/server/Slim/Buttons/Input/List.pm Sat Sep 9 10:42:07 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: trunk/server/Slim/Buttons/Playlist.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Buttons/Playlist.pm?rev=9534&r1=9533&r2=9534&view=diff
==============================================================================
--- trunk/server/Slim/Buttons/Playlist.pm (original)
+++ trunk/server/Slim/Buttons/Playlist.pm Sat Sep 9 10:42:07 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: trunk/server/Slim/Player/Client.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Player/Client.pm?rev=9534&r1=9533&r2=9534&view=diff
==============================================================================
--- trunk/server/Slim/Player/Client.pm (original)
+++ trunk/server/Slim/Player/Client.pm Sat Sep 9 10:42:07 2006
@@ -719,6 +719,7 @@
sub prevline2 {}
sub currBrightness {}
sub linesPerScreen {}
+sub knobListPos {}
sub pause {
my $client = shift;
Modified: trunk/server/Slim/Player/Transporter.pm
URL: http://svn.slimdevices.com/trunk/server/Slim/Player/Transporter.pm?rev=9534&r1=9533&r2=9534&view=diff
==============================================================================
--- trunk/server/Slim/Player/Transporter.pm (original)
+++ trunk/server/Slim/Player/Transporter.pm Sat Sep 9 10:42:07 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