Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Track Info Panel with ability to change font (Read 729419 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Track Info Panel with ability to change font

Reply #925

Does anyone know if there is a more accurate way to trim long text. The problem is currently that the more text that is trimmed the more inaccurate it gets. Cuts more than necessary. This is basically what I currently use.

Code: [Select]
$left($get(tracktitle),$sub($sub($len($get(tracktitle)),
$div($sub($calcwidth($get(tracktitle)),$get(areaWidth)),$get(charWidth))),3))'...'


If you're not using a fixed-width font, the string will vary in length.  There's no way to get the length of a string of text in pixels to use for trimming purposes.  Too bad that most fixed-width fonts are ugly.

... and still there is a way 
$calcwidth(text)

Track Info Panel with ability to change font

Reply #926
Seems counter-intuitive because of differing font sizes. Oh well.

Track Info Panel with ability to change font

Reply #927
^Since charWidth is $div($calcwidth(text),$len(text)) you can't make it more accurate without loops I think.

Track Info Panel with ability to change font

Reply #928
That link doesn't appear to be very specific and I'd like to offer a solution to the problem because I've seen this asked many times.  This can be handled like so:

Code: [Select]
$puts(text,This is a string of text to test with)
$puts(width,$sub($div(%_width%,2),38))

$alignabs(4,4,$get(width),$calcheight(X),,)$get(text)
$ifgreater($calcwidth($get(text)),$get(width),
$alignabs($add(4,$get(width)),4,%_width%,$calcheight(X),,)...
,)


The only drawback to this approach is that there sometimes appears a gap between the last character of the text and the ellipse. If anyone has a better solution please post.

Is there any way to disable wordwrapping?

It would take some doing to accomplish, but-
1.  create a text box long enough to avoid wordwrapping
2.  if the text is beyond your width limit, overlay the end of it with a PNG that fades from transparent to your background color, and the rest of the text box with a $drawrect the color of you background
3.  optionally add the ellipsis at a point that is visually pleasing.

That should block out the text you don't want to see and add a nice fade effect to the end of your title, etc.

Track Info Panel with ability to change font

Reply #929
Or using mil3s's idea, this should get reasonably close -

Code: [Select]
$puts(text,'Text to calculate, ie %title%')
$puts(charWidth,$div($calcwidth($get(text)),$len($get(text))))
$puts(width,$sub($div(%_width%,2),38))

$ifgreater($calcwidth($get(text)),$get(width),
$cut($get(text),$sub($div($get(width),$get(charWidth)),3))'...'
,$get(text))


That should work, right?  Uses average charWidth to determine approximate number of characters to cut the text length.

Track Info Panel with ability to change font

Reply #930
Why is my trackinfo empty when i start foobar, and I have to go into settings and click "apply" to make my buttons reappear?

Track Info Panel with ability to change font

Reply #931
im sure its been remarked before, but woah trackinfo is now so much more than.. a trackinfo panel. what code would i use to make the whole panel respond to mouse clicks? would i have to make the entire thing act like a giant button?

Track Info Panel with ability to change font

Reply #932
I'm not sure why the wiki says that.  I use $imageabs2() currently in trackinfo_mod to display albumart and the image will stretch larger if you use NOKEEPASPECT.  See my post about 5 back.

Sorry, I didn't discover that quirk with NOKEEPASPECT.  All fixed in the wiki now. ;-)

Track Info Panel with ability to change font

Reply #933
Why is my trackinfo empty when i start foobar, and I have to go into settings and click "apply" to make my buttons reappear?

Try adding a leading '/' to your relative image paths. That did the trick for me.

@Terrestrial: Could you add an option (e.g. "NOCACHE") to the imageabs-functions that enables me to prevent specific images from being cached? At the moment my [a href='index.php?act=findpost&pid=464466']fullscreen config[/a] eats RAM like nothing.

Track Info Panel with ability to change font

Reply #934
i like my solution... its basically wraithdu/mil3s' idea, but lets you define the length of each item

Code: [Select]
$align(center,middle)
$puts(text,[%artist%])
$puts(charWidth,$div($calcwidth($get(text)),$len($get(text))))
$puts(width,$add($div(%_width%,.1),100))

$ifgreater($calcwidth($get(text)),$get(width),
$cut($get(text),$sub($div($get(width),$get(charWidth)),3))'...'
,$get(text))


$puts(text2,[ - %title%])
$puts(charWidth,$div($calcwidth($get(text2)),$len($get(text2))))
$puts(width,$add($div(%_width%,.1),100))

$ifgreater($calcwidth($get(text2)),$get(width),
$cut($get(text2),$sub($div($get(width),$get(charWidth)),3))'...'
,$get(text2))


$puts(text3,[ - %album%])
$puts(charWidth,$div($calcwidth($get(text3)),$len($get(text3))))
$puts(width,$add($div(%_width%,.1),100))

$ifgreater($calcwidth($get(text3)),$get(width),
$cut($get(text3),$sub($div($get(width),$get(charWidth)),3))'...'
,$get(text3))


i'd like to make it so that it judges how to shorten each item based on the total length of the text [%artist%][ - %title%][ - %album%]


and i still think that the easiest way would be to make the font size dependent upon the character length.

Track Info Panel with ability to change font

Reply #935
I've updated the handling of long song titles in my current config.
Here's the relevant parts:
Code: [Select]
//Display Art?
$if($and($greater(%_width%,400),$fileexists($replace(%path%,%filename_ext%,folder.*))),$puts(position,142),$puts(position,8))

////Main block of text////
$alignabs($get(position),18,$sub(%_width%,$get(position)),$sub(%_height%,54),left,middle)
$font(,16,bold glow-107-132-153,234-232-227)
'#LINEHEIGHT,21#'
%artist%
//cut bracketed info from title if needed
$ifgreater($calcwidth(%title%),$sub(%_width%,$get(position)),$puts(title,$cut(%title%,$sub($strchr(%title%,'['),2))),$puts(title,%title%))
//If the title is still too long, use smaller font
$ifgreater($calcwidth($get(title)),$mul(2,$sub(%_width%,$get(position))),'#LINEHEIGHT,22#'$char(10)'#LINEHEIGHT,14#'$font(,10,bold glow-107-132-153,234-232-227)$get(title),'#LINEHEIGHT,19#'$char(10)$get(title)'#LINEHEIGHT,22#')
$char(10)
'#LINEHEIGHT,14#'
$font(,10,bold glow-107-132-153,234-232-227)%album%

I put any version or mix info found in the track listing in square brackets in the title tag.
I doubt this is exactly to standard, but it really cuts down on a lot of formatting issues, especially with all the bonus content found on reissued CDs.
So, the first step is to trim that bracketed content if it's causing length issues.

If the title is still to long, I then switch to the smaller font.
elevatorladylevitateme

Track Info Panel with ability to change font

Reply #936
terrestrial.

Why doesn't track_info_mod update when playback is paused or stopped?
I'd like to be able to use %cwb_systemdatetime% when stopped.
elevatorladylevitateme

Track Info Panel with ability to change font

Reply #937
Thanks terrestrial. I tried that, but that just deletes everything from the "Bla" playlist. I assume that this is because there are several commands that could be accessed with just the name "Bla" - i.e. the button action "Bla" could be interpreted as "Edit other/Add to specified playlist and play/Bla" or "Edit other/Remove from specified playlist and play/Bla" or "Edit other/Send to specified playlist and play/Bla". So if the button action "Bla" is all that is needed, how do I specify which of these "parent" commands to use?
-Nate


you can't  I've been meaning to rewrite the button to handle paths but haven't had the chance to yet.

Apparently it's been asked already but i didn't find it via the search:
Any chance to have a function for getting image X Y resolutoin?


on the todo list.

@Terrestrial: Could you add an option (e.g. "NOCACHE") to the imageabs-functions that enables me to prevent specific images from being cached? At the moment my [a href='index.php?act=findpost&pid=464466']fullscreen config[/a] eats RAM like nothing.


already on the todo list.

Why doesn't track_info_mod update when playback is paused or stopped?
I'd like to be able to use %cwb_systemdatetime% when stopped.


the "per second" is a bit of a misnomer. it should be "on playback time" which is the notification foobar sends when the track is playing. when paused/stopped no such notifications are sent.

Track Info Panel with ability to change font

Reply #938
Feature request. I was wondering if you might consider adding a function to calculate the number of characters in %text to check% that would fit in a specified width. To do this requires the use of a loop which is not possible in scripts.

Code: [Select]
$put(text2,text)
:loop:
$ifgreater or equal($calcwidth(text),$get(areawidth),$put(text2,$left($get(text2),$sub($len($get(text2)),1))) goto :loop:,:endloop:)
:endloop:
$get(text2)


This way it's possible to have much more accurate truncations (...) on long text.

Track Info Panel with ability to change font

Reply #939
Feature request. I was wondering if you might consider adding a function to calculate the number of characters in %text to check% that would fit in a specified width. To do this requires the use of a loop which is not possible in scripts.

Code: [Select]
$put(text2,text)
:loop:
$ifgreater or equal($calcwidth(text),$get(areawidth),$put(text2,$left($get(text2),$sub($len($get(text2)),1))) goto :loop:,:endloop:)
:endloop:
$get(text2)


This way it's possible to have much more accurate truncations (...) on long text.

What about non-fixed-width fonts? Obviously, an 'i' takes up less space than say 'B'. I could fit two 'i's in one 'B', if that makes sense.

I think it'd be a lot easier if the component automatically trimmed text when it exceeds the text bounding box, automatically appending '...'. At the moment it just cuts off the last word/s until it fits. [/feature request]
</signature>

Track Info Panel with ability to change font

Reply #940
Or how about the ability to disable wordwrapping so that text will be chopped exactly at the end of an $alignabs() window? like maybe $alignabs(4,4,100,10,,nowrap)

Track Info Panel with ability to change font

Reply #941

Thanks terrestrial. I tried that, but that just deletes everything from the "Bla" playlist. I assume that this is because there are several commands that could be accessed with just the name "Bla" - i.e. the button action "Bla" could be interpreted as "Edit other/Add to specified playlist and play/Bla" or "Edit other/Remove from specified playlist and play/Bla" or "Edit other/Send to specified playlist and play/Bla". So if the button action "Bla" is all that is needed, how do I specify which of these "parent" commands to use?
-Nate


you can't  I've been meaning to rewrite the button to handle paths but haven't had the chance to yet.



Ok, gotcha. At least I know it's not just me now  . I'll keep an eye out for updates. Thanks!

-Nate

Track Info Panel with ability to change font

Reply #942

Feature request. I was wondering if you might consider adding a function to calculate the number of characters in %text to check% that would fit in a specified width. To do this requires the use of a loop which is not possible in scripts.

Code: [Select]
$put(text2,text)
:loop:
$ifgreater or equal($calcwidth(text),$get(areawidth),$put(text2,$left($get(text2),$sub($len($get(text2)),1))) goto :loop:,:endloop:)
:endloop:
$get(text2)


This way it's possible to have much more accurate truncations (...) on long text.

What about non-fixed-width fonts? Obviously, an 'i' takes up less space than say 'B'. I could fit two 'i's in one 'B', if that makes sense.

I think it'd be a lot easier if the component automatically trimmed text when it exceeds the text bounding box, automatically appending '...'. At the moment it just cuts off the last word/s until it fits. [/feature request]

Maybe you should read the post again or look at the code. This feature would allow better accuracy on non-fixed-width fonts.

Track Info Panel with ability to change font

Reply #943
Code: [Select]
 // TrackInfo_Mod
// Put Background RGB colors to 99-39-33 in Settings
$puts(centre,$div(%_width%,2))

$puts(addy,40)
$imageabs2(%_width%,340,0,0,%_width%,340,0,-130,'images4\horizon2.png',alpha-100nokeepaspect)

$imageabs2(339,300,0,0,339,300,25,$add(0,$get(addy)),'images4\cdcase.png',alpha-230nokeepaspect)
$imageabs2(339,250,0,0,339,250,25,$add(301,$get(addy)),'images4\cdcase.png',alpha-230nokeepaspectROTATEFLIP-6)
$imageabs2(292,287,0,0,292,287,61,$add(7,$get(addy)),'images4\nocover.png',alpha-255nokeepaspect)
$imageabs2(292,240,0,0,292,240,61,$add(307,$get(addy)),'images4\nocover.png',alpha-255nokeepaspectROTATEFLIP-6)

$if($fileexists($replace(%path%,%filename_ext%,*.jpg)),
$imageabs2(292,287,0,0,292,287,61,$add(7,$get(addy)),$replace(%path%,%filename_ext%,*.jpg),nokeepaspect)
$imageabs2(292,240,0,0,292,240,61,$add(307,$get(addy)),$replace(%path%,%filename_ext%,*.jpg),nokeepaspectROTATEFLIP-6),
$imageabs2(292,287,0,0,292,287,61,$add(7,$get(addy)),$replace(%path%,%filename_ext%,../*.jpg),nokeepaspect)
$imageabs2(292,240,0,0,292,240,61,$add(307,$get(addy)),$replace(%path%,%filename_ext%,../*.jpg),nokeepaspectROTATEFLIP-6)
)

$imageabs2(350,302,0,0,350,302,20,$add(300,$get(addy)),'images4\reverse_overlay7.png',nokeepaspect)
$imageabs2(300,300,0,0,300,300,59,$add(5,$get(addy)),'images4\reflet300.png',alpha-125)

// Track infos libelles
$alignabs(0,$add(395,$get(addy)),390,38,center,top)
$font(Calibri,9,boldshadow glow-040-040-040 glowalpha-250,180-180-180 glowexpand-2 glowblur-3)'--- playing ---'
$alignabs(0,$add(455,$get(addy)),390,38,center,top)
$font(Calibri,9,boldshadow glow-040-040-040 glowalpha-250,180-180-180glowexpand-2 glowblur-3)'--- from ---'

// Track Infos variables
$alignabs(25,$add(340,$get(addy)),340,48,center,top)
$font(Swis721 Cn BT D-Type,16,boldshadow glow-255-255-255 glowalpha-50,10-10-10)[%artist%]
$alignabs(25,$add(410,$get(addy)),340,38,center,top)
$font(Swis721 Cn BT D-Type,12,boldshadow glow-040-040-040 glowalpha-250,180-180-180)[%title%]
$alignabs(25,$add(469,$get(addy)),340,38,center,top)
$font(Swis721 Cn BT D-Type,12,boldshadow glow-040-040-040 glowalpha-250,180-180-180)
$if(%album%,[%album%],'Unknow Album')
$if(%date%,
$font(Swis721 Cn BT D-Type,12,boldshadow glow-040-040-040 glowalpha-250,180-180-180)' - '[%date%],)

// --- show playback status over the cover ---
$if(%ispaused%,
$imageabs2(0,0,0,0,0,0,320,$add(10,$get(addy)),'.\images4\big_pause.png',),
$imageabs2(0,0,0,0,0,0,320,$add(10,$get(addy)),'.\images4\big_play.png',)
)

// Search cover art and traklists
$button($sub($get(centre),101),8,0,0,64,28,images4\buttons\google0.png,images4\buttons\google1.png,artsearch,)
$button($sub($get(centre),32),8,0,0,64,28,images4\buttons\allmusic0.png,images4\buttons\allmusic1.png,allmusicalbum,)
$button($add($get(centre),37),8,0,0,64,28,images4\buttons\allmusic2.png,images4\buttons\allmusic3.png,allmusicartist,)

// ---- lovely dots buttons ---- //
//
$imageabs2(300,38,0,0,300,38,45,$add(555,$get(addy)),'images4\bg_buttons0.png',)
// PLAY/PAUSE
$button(180,$add(561,$get(addy)),0,0,30,26,
$if($or(%ispaused%,$not(%isplaying%)),images4\buttons\play0.png,images4\buttons\pause0.png),
$if($or(%ispaused%,$not(%isplaying%)),images4\buttons\play1.png,images4\buttons\pause1.png),
$if($or(%ispaused%,$not(%isplaying%)),play,pause)
,)
// RESCAN
$button(52,$add(561,$get(addy)),0,0,30,26,images4\buttons\rescan0.png,images4\buttons\rescan1.png,Rescan Media Library,)
// SEARCH
//$button(69,$add(561,$get(addy)),0,0,30,26,images4\buttons\search0.png,images4\buttons\search1.png,Search,)
$button(84,$add(561,$get(addy)),0,0,30,26,images4\buttons\search0.png,images4\buttons\search1.png,artsearch,)
// PREVIOUS
$button(116,$add(561,$get(addy)),0,0,30,26,images4\buttons\prev0.png,images4\buttons\prev1.png,previous,)
// FAST BACKWARD
$button(148,$add(561,$get(addy)),0,0,30,26,images4\buttons\back0.png,images4\buttons\back1.png,seek back by 10 seconds,)
// FAST FORWARD
$button(212,$add(561,$get(addy)),0,0,30,26,images4\buttons\fwd0.png,images4\buttons\fwd1.png,seek ahead by 10 seconds,)
// NEXT
$button(244,$add(561,$get(addy)),0,0,30,26,images4\buttons\next0.png,images4\buttons\next1.png,next,)
// VIEW PLAYLIST MANAGER
$button(276,$add(561,$get(addy)),0,0,30,26,images4\buttons\libr0.png,images4\buttons\libr1.png,playlist manager,)

// playback order
$if($stricmp(%cwb_playback_order%,'Repeat (track)'),
$button(308,$add(561,$get(addy)),0,0,30,26,images4\buttons\rpt0.png,images4\buttons\seq1.png,'Repeat (playlist)',)
)
$if($stricmp(%cwb_playback_order%,'Repeat (playlist)'),
$button(308,$add(561,$get(addy)),0,0,30,26,images4\buttons\seq0.png,images4\buttons\rand1.png,'Shuffle (tracks)',)
)
$if($stricmp(%cwb_playback_order%,'Shuffle (tracks)'),
$button(308,$add(561,$get(addy)),0,0,30,26,images4\buttons\rand0.png,images4\buttons\rpt1.png,'Repeat (track)',)
)

// overlay (bottom)
$imageabs2(%_width%,340,0,0,%_width%,340,0,460,'images4\horizon2.png',alpha-100nokeepaspectROTATEFLIP-6)

$puts(write_tags,%rating%)
$puts(back,$rgb(105,26,26))
$puts(active,$rgb(250,250,150))

// rating system
$if($get(write_tags),$puts(rating,%rating%),$puts(rating,$cinfo(RATING)))
$if($get(write_tags),$puts(mood,%mood%),$puts(mood,$cinfo(MOOD)))
$alignabs(147,$add(515,$get(addy)),%_width%,%_height%,,)$font(wingdings,16,normal glow-255-125-05 glowexpand-1 glowblur-2,255-255-165)
$get(active)$repeat($char(171),$get(rating))
$font(wingdings,16,,)
$get(back)$repeat($char(171),$sub(5,$get(rating)))

// buttons rating
$button2(147,$add(515,$get(addy)),0,0,13,17,,,$if($get(write_tags),TAG:SET:Rating:1,'Heart 1'),)
$button2(167,$add(515,$get(addy)),0,0,13,17,,,$if($get(write_tags),TAG:SET:Rating:2,'Heart 2'),)
$button2(187,$add(515,$get(addy)),0,0,13,17,,,$if($get(write_tags),TAG:SET:Rating:3,'Heart 3'),)
$button2(207,$add(515,$get(addy)),0,0,13,17,,,$if($get(write_tags),TAG:SET:Rating:4,'Heart 4'),)
$button2(227,$add(515,$get(addy)),0,0,13,17,,,$if($get(write_tags),TAG:SET:Rating:5,'Heart 5'),)

// PerSecond

$puts(addy,39)

$alignabs(45,$add(528,$get(addy)),300,20,left,top)$font(Calibri,8,,140-135-130)[%playback_time%]
$alignabs(67,$add(528,$get(addy)),278,20,right,top)$font(Calibri,8,,140-135-130)[%length%]

$drawrect(45,$add(542,$get(addy)),300,8,brushcolor-null pencolor-120-115-110)

$puts(percent,$muldiv(%_time_elapsed_seconds%,100,
%_time_total_seconds%))
$if($greater($get(percent),0),
$drawrect(47,$add(544,$get(addy)),$muldiv($get(percent),295,100),4,
brushcolor-150-20-20 pencolor-null))


Can anyone tell me why it won't update the playorder button each click? It only changes the image when you change tracks.

Track Info Panel with ability to change font

Reply #944
I'm not 100% on this, but you need

// PerTrack

somewhere before your button code.  I always use all the headings -

// Global
// Background
// PerTrack
// PerSecond

even if I don't have anything in that section.  Check the wiki for what goes where (buttons go under PerTrack).

Track Info Panel with ability to change font

Reply #945
I found a graphical bug (probably unrelated to the SCP bug mentioned).  When blurring a rectangle, the bottom of the image is not rendered correctly.  See the code and image below.

Code: [Select]
$drawrect(10,10,150,150,brushcolor-255-255-255 pencolor-255-255-255)
$drawrect(170,10,150,150,brushcolor-255-255-255 pencolor-255-255-255 blur-1)



Track Info Panel with ability to change font

Reply #946
I'm not 100% on this, but you need

// PerTrack

somewhere before your button code.  I always use all the headings -

// Global
// Background
// PerTrack
// PerSecond

even if I don't have anything in that section.  Check the wiki for what goes where (buttons go under PerTrack).


If I place the buttons behind the // PerSecond the buttons disappear.

 

Track Info Panel with ability to change font

Reply #947
Buttons can not be in the // Background section. This much I am fairly certain, however they should work in the // PerTrack section as I use that myself.

Track Info Panel with ability to change font

Reply #948
Buttons can not be in the // Background section. This much I am fairly certain, however they should work in the // PerTrack section as I use that myself.


I've moved it below the // PerSecond thing and it does nothing but make the button disappear.

Track Info Panel with ability to change font

Reply #949
Three "bugs" (annoyances):

1. You can't bring foobar2000 to front if a trackinfo-panel are clicked
2. Often you are unable to click buttons on windows appearing over a trackinfo-panel (mostly the prefs-window)
3. If you drag files from explorer over a trackinfo-panel, they are immedately dropped
Can't wait for a HD-AAC encoder :P