Index: Slim/Display/Display.pm =================================================================== --- Slim/Display/Display.pm (revision 2530) +++ Slim/Display/Display.pm (revision 2531) @@ -162,13 +162,12 @@ $featureHeader = $client->string(uc($feature)) . " ($headerValue)"; - my @lines = Slim::Buttons::Input::Bar::lines($client, $featureValue, $featureHeader, - $client->mixerConstant($feature,'min'), - $mid, - $client->mixerConstant($feature,'max')); + my @lines = Slim::Buttons::Input::Bar::barLines($client, $featureValue, $featureHeader, + $client->mixerConstant($feature,'min'), + $mid, + $client->mixerConstant($feature,'max')); - # trim off any overlay for showBriefly - $client->showBriefly(@lines[0,1]); + $client->showBriefly(@lines); } Index: Slim/Buttons/Input/Bar.pm =================================================================== --- Slim/Buttons/Input/Bar.pm (revision 2530) +++ Slim/Buttons/Input/Bar.pm (revision 2531) @@ -101,9 +101,46 @@ $client->update(); } +# display lines when in Bar mode. +# to briefly display a bar when in another mode, use barLines below. sub lines { my $client = shift; - # These parameters are used when calling this function from Slim::Display::Display + + # sanity check, make sure this code is only called from the right place. + my $xxx = shift; + assert(!defined($xxx), + "Bar::lines is deprecated. Use Bar::barLines().\n"); + + my $valueRef = $client->param('valueRef'); + + my $listIndex = $client->param('listIndex'); + + my $header = Slim::Buttons::Input::List::getExtVal($client,$$valueRef,$listIndex,'header'); + if ($client->param('stringHeader') && Slim::Utils::Strings::stringExists($header)) { + $header = $client->string($header); + } + if (ref $client->param('headerValue') eq "CODE") { + $header .= Slim::Buttons::Input::List::getExtVal($client,$$valueRef,$listIndex,'headerValue'); + } + + my $min = $client->param('min') || 0; + my $mid = $client->param('mid') || 0; + my $max = $client->param('max') || 100; + + my $value = $max == $min ? 0 : int(($$valueRef - $min)*100/($max-$min)); + my $fullstep = 1 unless $client->param('smoothing'); + + my ($line1, $line2) = barLines($client, $value, $header, $min, $max, $fullstep); + + my @overlay = Slim::Buttons::Input::List::getExtVal($client,$valueRef,$listIndex,'overlayRef'); + return ($line1,$line2,@overlay); +} + +# generate bar lines. +# this method may be called from other modes to briefly display a bar +# for instance when the volume buttons are pressed. +sub barLines { + my $client = shift; my $value = shift; my $header = shift; @@ -111,34 +148,14 @@ my $mid = shift; my $max = shift; + my $fullstep = shift || 1; + my ($line1, $line2); - my $valueRef = $client->param('valueRef'); - $valueRef = \$value if defined $value; + $line1 = $header; - my $listIndex = $client->param('listIndex'); - - if (defined $header) { - $line1 = $header; - } else { - $line1 = Slim::Buttons::Input::List::getExtVal($client,$$valueRef,$listIndex,'header'); - if ($client->param('stringHeader') && Slim::Utils::Strings::stringExists($line1)) { - $line1 = $client->string($line1); - } - if (ref $client->param('headerValue') eq "CODE") { - $line1 .= Slim::Buttons::Input::List::getExtVal($client,$$valueRef,$listIndex,'headerValue'); - } - } + $line2 = $client->sliderBar($client->displayWidth(), $value,$max == $min ? 0 :($mid-$min)/($max-$min)*100,$fullstep); - $min = $client->param('min') || 0 unless defined $min; - $mid = $client->param('mid') || 0 unless defined $mid; - $max = $client->param('max') || 100 unless defined $max; - - my $val = $max == $min ? 0 : int(($$valueRef - $min)*100/($max-$min)); - my $fullstep = 1 unless $client->param('smoothing'); - - $line2 = $client->sliderBar($client->displayWidth(), $val,$max == $min ? 0 :($mid-$min)/($max-$min)*100,$fullstep); - if ($client->linesPerScreen() == 1) { if ($client->param('barOnDouble')) { $line1 = $line2; @@ -147,8 +164,8 @@ $line2 = $line1; } } - my @overlay = Slim::Buttons::Input::List::getExtVal($client,$valueRef,$listIndex,'overlayRef'); - return ($line1,$line2,@overlay); + + return ($line1, $line2); }