How can I dynamically toggle between includes?
#1
Hi,

I have for example a toggle button in the context menu (let call its setting value as "tButton").
My purpose is that:
- When the button is True, Include "A" will show up, and Include "B" will be hidden.
- When the button is False, Include "B" will show up, and Include "A" will be hidden.

* Each "Include" represents a panel control, and each of them should be placed under the same panel id.

In other words. I want that my panel id (59) will be changed (params, layput etc...) according to the toggle button dynamically without go out and back in.

How can I do that?

The most close I got is that the Includes switchs only after exit/enter again and not dynamically (With the include condition attribute)
I tried with <animation> tags but it didn't work or I didn't do it right.

Thanks.
Reply
#2
(2021-10-20, 17:44)burekas Wrote: Hi,

I have for example a toggle button in the context menu (let call its setting value as "tButton").
My purpose is that:
- When the button is True, Include "A" will show up, and Include "B" will be hidden.
- When the button is False, Include "B" will show up, and Include "A" will be hidden.

* Each "Include" represents a panel control.

How can I do that?

The most close I got is that the Includes switchs only after exit/enter again and not dynamically (With the include condition attribute)
I tried with <animation> tags but it didn't work or I didn't do it right.

Thanks.

you need to use 2 button controls,
a visible condition and probably with allowhiddenfocus attribute
description at the bottom
https://kodi.wiki/view/Conditional_visib...Conditions

or a toggle button and define the usealttexture tag and fefine ALT(ernative) tags
( e.g. altclick)
https://kodi.wiki/view/Toggle_button_control


includes are just loaded on window initialisation, not when it is activ.
Skins
       Titan M O D
       S W A N (WIP)
Addon
       script.playlist.helper
Reply
#3
@mardukL 

Can you tell me please what's wrong with this kind of thinking:
In this case Include_A is show up,
But when changing the state, Include_A is hidden (which is ok) but Include_B isn't show up (empty)

Code:
            <control type="group">
                <visible>
                    !Skin.HasSetting(toggleButton)
                </visible>                
                <include>Include_A</include>
            </control>                    
            <control type="group">
                <visible>
                    Skin.HasSetting(toggleButton)
                </visible>   
                <include>Include_B</include>
            </control>

When:
Code:
    <include name="Include_A">
            <control type="panel" id="59">
                   .....
            </control> 
    </include>

    <include name="Include_B">
            <control type="panel" id="59">
                   .....
            </control> 
    </include>
Reply
#4
(2021-10-20, 19:58)burekas Wrote: @mardukL 

Can you tell me please what's wrong with this kind of thinking:
In this case Include_A is show up,
But when changing the state, Include_A is hidden (which is ok) but Include_B isn't show up (empty)

Code:
            <control type="group">
                <visible>
                    !Skin.HasSetting(toggleButton)
                </visible>                
                <include>Include_A</include>
            </control>                    
            <control type="group">
                <visible>
                    Skin.HasSetting(toggleButton)
                </visible>   
                <include>Include_B</include>
            </control>

When:
Code:
    <include name="Include_A">
            <control type="panel" id="59">
                   .....
            </control> 
    </include>

    <include name="Include_B">
            <control type="panel" id="59">
                   .....
            </control> 
    </include>


visible conditions ( in the simple meaning of true vs. false ) looks fine.
so it seems it has to do with the stuff/control in include_b is failing to show up.

edit: plus, look at first answer.
includes are loaded on window initialisation.
so if you toggle the state without reload skin or reopen the current window , include_b will not show, even if the group control is visible.

ps. i would`nt handle includes that way, but i am not sure about the usecase, and it was not part of the question
Skins
       Titan M O D
       S W A N (WIP)
Addon
       script.playlist.helper
Reply
#5
So back to the panel question.

why not use the condition without include, you just have to deal with unique id s for each panel ??
Skins
       Titan M O D
       S W A N (WIP)
Addon
       script.playlist.helper
Reply
#6
@mardukL 

1) There is no problem with Include_B, because even if I put the same Include_A in both cases, the second one isn't show up, only the first case.

2) The problem is that each of the panels on each include is defined by different values/content (So the toggle button should switch between them),
but the problem is that they should using the same id.

So how can I solve this situation?
Reply
#7
@burekas , I do something similar to what you are looking for in media views, in that if the user selects in the sideblade different options, then the layout of the view will change. 

As @mardukL mentioned before, using includes that are "activated" depending on the value of a radiobutton, for example, will not work, since all of the includes are only evaluated by kodi when the window loads.  So, for example, when you load your view, the value of your button is A, so the inlcude for A is loaded.  If you then change the value to B, the include for B will not be loaded, since at window load, the value was A, not B, and Kodi does not evaluate includes again, until the window is reloaded.

You could, of course, add a ReloadSkin() command as part of the <onclick> of your togglebutton, which would essentially reload the window and the includes would be evaluated again.  That has the drawback of having that "refresh" occur, which the user will certainly notice.  It is, however, as far as I know, the simplest way to do what you want with very minor modifications to your current code.

What I do is that I have just one panel, and different itemlayout/focusedlayout depending on what options have been chosen for the view.  This has the advantage that the layout can change on the fly as the user changes options, but it is more code.   A similar principle applies if you want to display different things (outside of the panel's itemlayout/focusedlayout) in the view, you can have those options/controls in includes, but you do not use them conditionally, you put all of the controls inside a group inside the include, and have a visibility condition for the whole group.

If this is close to what you are looking for, please feel free to look at the Amber code for examples.

Regards,

Bart
Amber Maintainer
Main HTPC: Intel Core i7, 32GB, nVidia GTX1080, Windows 11 Soundbar: Samsung HW-Q950A TV: LG CX Kodi: 19.3 Skin: Amber
Reply
#8
@bsoriano 

Thanks for you detailed answer.

Regarding to "itemlayout/focusedlayout" I think was thinking about it also with using the condition attribure for each of them,
But what I'm doing with all the parameters of the panel which are different between the layouts?
For example "<bottom>11%</bottom>" in A, and "<bottom>8%</bottom>" in B
Reply
#9
(2021-10-20, 22:53)burekas Wrote: @bsoriano 

Thanks for you detailed answer.

Regarding to "itemlayout/focusedlayout" I think was thinking about it also with using the condition attribure for each of them,
But what I'm doing with all the parameters of the panel which are different between the layouts?
For example "<bottom>11%</bottom>" in A, and "<bottom>8%</bottom>" in B
@burekas , if the positioning parameters for you panel need to be different between the two options, and that cannot be resolved by changing the <posx>, <posy>, etc. of the items in the panel, then your best bet is to use ReloadSkin() in the onclick for your togglebutton, and then you can use separate includes like you were asking initially.  I have had to do that, and I have not had complaints from users about the refresh that happens.

Regards,

Bart
Amber Maintainer
Main HTPC: Intel Core i7, 32GB, nVidia GTX1080, Windows 11 Soundbar: Samsung HW-Q950A TV: LG CX Kodi: 19.3 Skin: Amber
Reply
#10
(2021-10-20, 23:14)bsoriano Wrote:
(2021-10-20, 22:53)burekas Wrote: @bsoriano 

Thanks for you detailed answer.

Regarding to "itemlayout/focusedlayout" I think was thinking about it also with using the condition attribure for each of them,
But what I'm doing with all the parameters of the panel which are different between the layouts?
For example "<bottom>11%</bottom>" in A, and "<bottom>8%</bottom>" in B
@burekas , if the positioning parameters for you panel need to be different between the two options, and that cannot be resolved by changing the <posx>, <posy>, etc. of the items in the panel, then your best bet is to use ReloadSkin() in the onclick for your togglebutton, and then you can use separate includes like you were asking initially.  I have had to do that, and I have not had complaints from users about the refresh that happens.

Regards,

Bart
Yes, it works. Thanks.
Basically it can stay that way, because this is not a setting that someone should change it all the time.
But still, if anyone else has another way to do it without the SkinRefresh() option regarding the different positioning parameters between the panels, I would be glad to know.
Reply
#11
I think I have an idea, using VARs for these panel values.
The question is if they act like includes so their values are set only when the window is loaded or they are dynamically like "conditions" attributes.
Reply
#12
@bsoriano 

I'm trying to use variables but it seems that it doesn't work even without the condition:

For example:
 
Code:
  <variable name="BPG_right">
        <value>50</value>
  </variable>

The value isn't getting here as set in the variable value:
Code:
            <control type="panel" id="59">
                ....
                <right>$VAR[BPG_right]</right>
            </control>

Does it even possible to use  VAR in case like this, for panel dimensions values?
Reply
#13
(2021-10-21, 12:07)burekas Wrote: @bsoriano 

I'm trying to use variables but it seems that it doesn't work event without the condition:

For example:
 
Code:
  <variable name="BPG_right">
        <value>50</value>
  </variable>

The value isn't getting here as set in the variable value:
Code:
            <control type="panel" id="59">
                ....
                <right>$VAR[BPG_right]</right>
            </control>

Does it even possible to use  VAR in case like this, for panel dimensions values?

@burekas, unfortunately, it is not possible to use VARs for those parameters.

Regards,

Bart
Amber Maintainer
Main HTPC: Intel Core i7, 32GB, nVidia GTX1080, Windows 11 Soundbar: Samsung HW-Q950A TV: LG CX Kodi: 19.3 Skin: Amber
Reply



Logout Mark Read Team Forum Stats Members Help
How can I dynamically toggle between includes?0
This forum uses Lukasz Tkacz MyBB addons.