Rockbox.org home
Downloads
Release release
Dev builds dev builds
Extras extras
themes themes
Documentation
Manual manual
Wiki wiki
Device Status device status
Support
Forums forums
Mailing lists mailing lists
IRC IRC
Development
Bugs bugs
Patches patches
Dev Guide dev guide
translations translations
Search



Donate

Rockbox Technical Forums


Login with username, password and session length
Home Help Search Staff List Login Register
News:

Thank You for your continued support and contributions!

+  Rockbox Technical Forums
|-+  Support and General Use
| |-+  Theming and Appearance Customization
| | |-+  %t(0) not functioning as intended
« previous next »
  • Print
Pages: [1]

Author Topic: %t(0) not functioning as intended  (Read 162 times)

Offline gnomacor

  • Member
  • *
  • Posts: 30
%t(0) not functioning as intended
« on: June 18, 2025, 07:00:30 PM »
I'm creating something like this:

%Vl(battCharging,277,17,23,10,-)
%Vf(-)
%Vd(batt);%?if(%bl,>=,20)<%t(0)>%xd(battery,3);%?if(%bl,>=,40)<%t(0)>%xd(battery,5);%?if(%bl,>=,60)<%t(0)>%xd(battery,7);%?if(%bl,>=,80)<%t(0)>%xd(battery,9);%xd(battery,11)

(the nested %Vd tag inside a tagged viewport also has some problems but that's a story for another day)

the intention is that you first display the current battery level, and animate up to 100%. the charge level lower than current should be skipped by the conditional and %t(0) tag, as indicated in the manual.
However, the theme behaves as if %t(0) tag didn't exist and will proceed to display everything no matter the charge level. this has happened as long as i have worked on themes and is present in the latest nightly (2025-06-18). The device I'm using is Eros Q (Surfans F20 to be more specific). i have previously worked around this by repeating the tags before and after the subline, so something like %tag;%?condition<%tag|%something_else>, but this charging animation has multiple levels that i'm uncomfortable using this workaround. i wonder if it's just me and if not, how long it's been known.
« Last Edit: June 18, 2025, 07:03:53 PM by gnomacor »
Logged

Offline Dook

  • Member
  • *
  • Posts: 77
    • D00k.net
Re: %t(0) not functioning as intended
« Reply #1 on: June 19, 2025, 11:17:50 AM »
You are definitely misunderstanding the %t tag. The tag works by defining "sublines" and then telling rockbox how long to display each one. "Sublines" in this context are containers with content, originally intended to display different kinds of metadata in the music player hence the name sublines.

There's a lot of reasons as to why your example isn't working, I'll try my best to explain but if there's any part you don't get then let me know and I can focus on it more. For starters, you have a ; on it's own near the begininning, this does absolutely nothing unless it comes after a %t tag. Secondly, I don't believe you can call on Viewports like that. They just aren't designed to work that way, call on %Vd(batt) the same time you call %Vd(battCharging), it will have the exact same result you're looking for anyway.

Next, your usage of %t ignores how they work. Take for example your first usage %?if(%bl,>=,20)<%t(0)>%xd(battery,3); If you take out %t(0)>%xd(battery,3);, you're left with invalid theme code, but that's exactly how the %t tag works. It sees each subline instance as an independent object that can be removed and reinserted, hence they can't work inside conditionals.

I might be wrong here, but they shouldn't even work if they were inside a conditional like %?bl<%t(0);..> as rockbox would treat each subline as a new line thus breaking the conditional.

It's worth stressing though that the %t tag is not the solution to your problem here. Displaying a different battery icon when charging is far better suited to conditionals on their own.
Logged

Offline gnomacor

  • Member
  • *
  • Posts: 30
Re: %t(0) not functioning as intended
« Reply #2 on: June 20, 2025, 03:05:01 PM »
First off, let me preface this by saying that what I've been doing is based on what was written in the manual, which AFAIK should be updated frequently if not in tandem with the code. I often use the CustomWPS wiki section for convenience but when I encounter problems I always compare it with the contents of the manual.

Second, nested %Vd calling has nothing to do with %t(0) not working. I know it's not its intended use, but it works somewhat (not using it in production though), and switching it out with normal expressions doesn't resolve the subline problem.

Quote
For starters, you have a ; on it's own near the begininning, this does absolutely nothing unless it comes after a %t tag.

This is false; each subline is given 2s by default (per the manual). Indeed the first subline works, and it's not the problem I'm having.

Quote
call on %Vd(batt) the same time you call %Vd(battCharging), it will have the exact same result you're looking for anyway.

So this viewport is supposed to work like this: first you display the current battery level, then you display what would be the charge level if it was charged up, and then some more, until you reach the 100% charge state (bitmap). If the current charge state is 20%, it will show 20 -> 40 -> 60 -> 80 -> 100, if it's 50, 50 -> 60 -> 80 -> 100, if it's 90, 90 -> 100. It's not about displaying batt and battCharging at once, rather it's a shorthand for temporarily displaying the current charge status. As I explained earlier, calling %Vd isn't the problem here, and copypasting the content of batt viewport doesn't solve the timing issue.

Quote
Take for example your first usage %?if(%bl,>=,20)<%t(0)>%xd(battery,3); If you take out %t(0)>%xd(battery,3);, you're left with invalid theme code, but that's exactly how the %t tag works.

This to me sounds like you're saying it's simply impossible to put %t tag inside a conditional, which is also false. At least it should be, per the manual (12.2.4.0):

Quote
Conditionals can be used with sublines to display a different set and/or number of sublines on the line depending on the evaluation of the conditional. Example subline with conditionals:
Quote
%?it<%t(8)%s%it|%s%fn>;%?ia<%t(3)%s%ia|%t(0)>
The format above will do two different things depending if ID3 tags are present. If the ID3 artist and title are present:
  • Display id3 title for 8 seconds,
  • Display id3 artist for 3 seconds,
  • repeat…
If the ID3 artist and title are not present:
  • Display the filename continuously.
Note that by using a subline display time of 0 in one branch of a conditional, a subline can be skipped (not displayed) when that condition is met.

Just as a sanity check, I've put in everything inside the conditional just like in the example, so ... ;%?if(%bl,>=,80)<%t(0)|%t(2)%xd(battery,9)>; ..., and now it just displays nothing rather than skipping, which is still incorrect. So it's either a bug or the manual needs changing (but why retract a feature that you clearly see the use case of?).

Quote
I might be wrong here, but they shouldn't even work if they were inside a conditional like %?bl<%t(0);..> as rockbox would treat each subline as a new line thus breaking the conditional.
Funny you should say that, because that's exactly what I found in the AdwaitaPod, and putting ; inside the conditional appears to be the only functioning way to skip a subline. So the practical problem has been solved, but I still have to wonder why %t(0) doesn't work.

Quote
It's worth stressing though that the %t tag is not the solution to your problem here. Displaying a different battery icon when charging is far better suited to conditionals on their own.

Hopefully I've elaborated enough till now that you can understand why this doesn't make sense. I could create a conditional jungle and basically create a viewport for every charge levels (of interest), but I'm just trying to use the function that should exist and will make the code cleaner.
« Last Edit: June 20, 2025, 03:08:16 PM by gnomacor »
Logged

Offline Dook

  • Member
  • *
  • Posts: 77
    • D00k.net
Re: %t(0) not functioning as intended
« Reply #3 on: June 20, 2025, 06:50:31 PM »
My apologies! You're absolutely right about %t functioning like that. I'd never seen that example on p.206 before in the manual, still learning new things it seems haha. I'm so sorry for being patronising, I should've double checked before replying.

I understand what you're trying to do now as well I think. You're basically trying to animate the charging icon, but make it's starting state reflect the actual level. It's a nice touch.

I'm gonna hack it out over the weekend and see if I can dig deeper into why this isn't working, based on what you shared you'd definitely assume that %t(0) would work. One possibility is that changes over time to %t has broken this, but can't say for certain yet.
Quote
Funny you should say that, because that's exactly what I found in the AdwaitaPod, and putting ; inside the conditional appears to be the only functioning way to skip a subline. So the practical problem has been solved, but I still have to wonder why %t(0) doesn't work.
Also great point, shows how little I know my own codebase these days. Pretty sure I've used %t recently in a conditional too and just forgot about it.
« Last Edit: June 20, 2025, 07:38:58 PM by Dook »
Logged

Offline Dook

  • Member
  • *
  • Posts: 77
    • D00k.net
Re: %t(0) not functioning as intended
« Reply #4 on: June 20, 2025, 08:05:37 PM »
So I've made a few tests and the results are a bit strange.

I first made a super simple test that used the hold switch for it's conditional and %t(0) worked exactly like you were saying it should, but only in one way and not the other.
Code: [Select]
%?mh<1|%t(0)>;%?if(%Lt,=,themes)<%t(2)2|%t(0)>
If you're on the "themes" page, then there is no blinking if the hold switch is off. 3 will be displayed indefinitely, no blinking in and out.
However if you're not on the themes page, and you turn the hold switch on, 1 should be displayed indefinitely but instead it blinks in and out like it had been for you.


Code: [Select]
%?mh<1|%t(0)2>;%?if(%Lt,=,themes)<%t(2)3|%t(0)4>When I set it up like this, 4 displays at the start when the hold is off. Then when the hold is on, it switches between 1 and 4. And even worse, when hold is switched off, 2 will show for a split second before being switched to 4 indefinitely.

Code: [Select]
%?if(%Lt,=,themes)<%t(2)3|%t(0)4>;%?mh<1|%t(0)2>I swapped it around, and now the first conditional works as intended but the second one bugs on the %t(0) and displays the contents anyway.

Based on this, it seems the second conditional is influencing the entire thing. Which is a very long-winded way to say that this definitely isn't working as documented and as intended. As you suspected, I'd agree that this is a bug. I'll put together a test file for this when I'm free next and get it on the bug tracker asap :)
Logged

Offline gnomacor

  • Member
  • *
  • Posts: 30
Re: %t(0) not functioning as intended
« Reply #5 on: June 21, 2025, 05:54:08 PM »
Thanks a lot for the investigation and taking the initiative for the bug report, and I accept the apology. No shame in not remembering what you've written, AdwaitaPod is huge.
Logged

  • Print
Pages: [1]
« previous next »
+  Rockbox Technical Forums
|-+  Support and General Use
| |-+  Theming and Appearance Customization
| | |-+  %t(0) not functioning as intended
 

  • SMF 2.0.19 | SMF © 2021, Simple Machines
  • Rockbox Privacy Policy
  • XHTML
  • RSS
  • WAP2

Page created in 0.061 seconds with 16 queries.