SageTV Community  

Go Back   SageTV Community > SageTV Development and Customizations > SageTV Studio
Forum Rules FAQs Community Downloads Today's Posts Search

Notices

SageTV Studio Discussion related to the SageTV Studio application produced by SageTV. Questions, issues, problems, suggestions, etc. relating to the Studio software application should be posted here.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 03-01-2006, 12:32 PM
dflachbart dflachbart is offline
SageTVaholic
 
Join Date: Jan 2006
Location: Brookfield, CT
Posts: 2,743
Conditional themes

Hi,

I am trying to apply a theme to a widget depending on some condition at runtime (one import, different look&feel for different STVs), like this:

Code:
cond=...

OptionsMenu
   +- item1
   +- item2
   +- item3
   +- other code / widgets

   +- If cond
       +- > true
          +- 
          +- theme1
       +- > false
          +- 
          +- theme2
Well, unfortunately the above is not possible, since a theme can't be child of a condition statement.

The closest I could get is to define two separate OptionMenus with their respective themes, but link all other menu contents from one widget to the other by reference:

Code:

cond=...

If cond
   +- > true
      +- OptionsMenu1
             +- item1
             +- item2
             +- item3
             +- other code / widgets

             +- theme1

   +- > false
      +- OptionsMenu2
             +- link to item1
             +- link to item2
             +- link to item3
             +- link to other code / widgets

             +- theme2
This saves code duplication, but it is still very messy and bloats/complicates the STV code. Is there any alternative I might have missed ?


Thanks,
Dirk
Reply With Quote
  #2  
Old 03-01-2006, 04:30 PM
GKusnick's Avatar
GKusnick GKusnick is offline
SageTVaholic
 
Join Date: Dec 2005
Posts: 5,083
If I understand you right, you're trying to make an addon that's compatible with two different base STVs that use different theme sets. Seems to me the right way to handle that would be to choose which theme set you want to link up to at import time, and then run through your code fixing up the (unconditional) theme refs. That seems cleaner than having conditional runtime refs to themes that may not actually be present.

If your themes are self-contained in your addon, and you just want a different look-and-feel depending on some runtime variable, then maybe the thing to do is to put as much of the conditional code as possible into the theme itself, so you don't have to be testing the condition on every use of the theme.
__________________
-- Greg
Reply With Quote
  #3  
Old 03-01-2006, 08:26 PM
dflachbart dflachbart is offline
SageTVaholic
 
Join Date: Jan 2006
Location: Brookfield, CT
Posts: 2,743
Greg, thanks a lot for your answer !

Quote:
Originally Posted by GKusnick
If I understand you right, you're trying to make an addon that's compatible with two different base STVs that use different theme sets. Seems to me the right way to handle that would be to choose which theme set you want to link up to at import time, and then run through your code fixing up the (unconditional) theme refs. That seems cleaner than having conditional runtime refs to themes that may not actually be present.
I haven't thought of this, and you are right it makes indeed sense to link at import time.


Quote:
Originally Posted by GKusnick
If your themes are self-contained in your addon, and you just want a different look-and-feel depending on some runtime variable, then maybe the thing to do is to put as much of the conditional code as possible into the theme itself,
Yeah, the themes are self contained, the addon is not referencing any existing ones. When you say to put as much conditional code as possible into the theme itself, you are refering to 'If()' expressions for widget properties, right ? Or can you also put action widgets into themes ?

Quote:
Originally Posted by GKusnick
so you don't have to be testing the condition on every use of the theme.
So the conditions in a theme are only evaluated once ? When is this happening, the first time a theme is used to draw a widget ?

Dirk
Reply With Quote
  #4  
Old 03-01-2006, 08:35 PM
Narflex's Avatar
Narflex Narflex is offline
Sage
 
Join Date: Feb 2003
Location: Redondo Beach, CA
Posts: 6,349
Quote:
Originally Posted by flachbar
Yeah, the themes are self contained, the addon is not referencing any existing ones. When you say to put as much conditional code as possible into the theme itself, you are refering to 'If()' expressions for widget properties, right ? Or can you also put action widgets into themes ?
You can put Action Widgets into Themes. Check out the CES UI that I put in the downloads section. In that one I think it's got a Panel in a Theme that has a hook child which animates the rendering. You can basically put about anything in a Theme's children and it'll work. It's made code reuse much easier we found. You can also use If() in properties.

Quote:
Originally Posted by flachbar
So the conditions in a theme are only evaluated once ? When is this happening, the first time a theme is used to draw a widget ?
Dirk
They're evaluated when they need to be. You can see this using the Tracer in the Studio. The Studio's debugger tools are fairly useful and can tell you a lot about what's going on inside of it. I use them quite often.
__________________
Jeffrey Kardatzke
Google
Founder of SageTV
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -6. The time now is 06:40 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2023, vBulletin Solutions Inc.
Copyright 2003-2005 SageTV, LLC. All rights reserved.