-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add new infolabel ListItem.CurrentItem and new Boolean expression IsEven/IsOdd #15527
Conversation
can't tell if it should be an infolabel or a property... the difference has never been clear to me. could you please use |
Unless there is a specific reason for using a property, my preference is for an infolabel as they are easier to read in the skin xml +1 for |
Or |
One question, I think related to this conversation. Is it possible from Python to set the focus of a ListItem on a particular item row? |
@HitcherUK - I agree, @Wintermute0110 - you can set focus with the builtin |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
@jurialmunkey Thanks a lot! I though it was not possible to set the position so if someone was proposing to return the position I was about to propose to be able to also set the position. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
agreed, ListItem.CurrentItem
would be the best name for this new infolabel.
35743f3
to
8664b85
Compare
@ronie OK, I finally got some time to change the PR. |
xbmc/guilib/GUIListItem.cpp
Outdated
unsigned int CGUIListItem::GetCurrentItem() const | ||
{ | ||
return m_currentItem; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add an empty line at the end of file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
8664b85
to
8f2141c
Compare
At a guess I think the difference was once related to where the data was from, with infolabels relating to data held in one of the |
When you request additional properties through json rpc, they are directly translated into fileitem-properties. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm uncertain whether we actually need this.
First, it increases the size of every CGUIListItem instance, second I'm not sure that this functionality does actually not exist.
xbmc/GUIInfoManager.cpp
Outdated
@@ -5687,6 +5687,14 @@ const infomap container_str[] = {{ "property", CONTAINER_PROPERTY }, | |||
/// @return The parental rating of the list item (PVR). | |||
/// <p> | |||
/// } | |||
/// \table_row3{ <b>`ListItem.CurrentItem`</b>, | |||
/// \anchor ListItem_CurrentItem | |||
/// _integer_, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Type 'integer' does not match implementation, which returns a string. (GUIInfoManager.cpp line 9838). Do you only want to to display the value, then string is correct. If you want to do 'greater', 'less' etc math with the value, then you should go with integer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think display is enough.
I can't see a benefit of comparing them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given the latest conversation I found it doesn't matter if its _integer_
.
The sample with ListItem.Year
is also a _string_
and can be used in comparisons.
So I changed the documentation to align with the code.
CurrentItem
is now _string_
.
@@ -172,6 +186,7 @@ class CGUIListItem | |||
CGUIListItemLayoutPtr m_layout; | |||
CGUIListItemLayoutPtr m_focusedLayout; | |||
bool m_bSelected; // item is selected or not | |||
unsigned int m_currentItem; // current item number within container (starting at 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CGUIListItems are mass objects, for instance every PVR EPG event is a CFileItem which is derived from CGUIListItem. One can easily have tens of thousands of those instances in one Kodi process. Thus, we should think twice before adding new members to this class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had an implementation based on ListItem.Properties
first - you point is valid, where could I put this new infolabel instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be possible to ignore the epggrid layout altogether?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No not in this case.
The CGUIListItem
has no idea about grids, panels, lists or whatever.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also tbh I think it's kinda neglectable.
Given an unsigend int
takes up around 4 byte of memory, it may be more due to padding though, 1mio items would take up addionally 4mb of ram.
I really can't imagine, that this would break any platform.
I could not figure out how to do it without my change. |
https://github.com/xbmc/xbmc/blob/master/xbmc/GUIInfoManager.cpp#L3439 ff. Container(id).Position , Container(id).CurrentItem, ... ??? |
Doesn't that fit? |
Description wise, yes. |
Both methods seem to operate on the current selection or focus, so it's not what I want. |
Seems to fit better, yes. |
I just talked to @HitcherUK and I was told the |
Not sure I get what you exactly want to achieve, but I'm not a skinner, so feel free to ignore me. 😃 |
Basically I want to be able to not only show a list, but also number the items.
|
AFAIK, an item instance can be shared among different containers, no? If so, the index the item has in an container cannot be a member of the item, because it can have another index in another container it might be contained as well. |
But if i see 'CGUILIstItem' members like 'm_bSelected' I might be wrong with my previous comment. Time to shut up, I guess. ;-) |
It needs to be a listitem so that you can use it inside <itemlayout> Having this infolabel will also allow skinners to do things like apply a texture only to odd rows by using something like Having a way to apply textures only to specific rows inside itemlayout and have those move only when the list scrolls has not been possible previously because options for comparing labels based upon itemlayout position are either:
None of these options provides a sane way to have a condition in the itemlayout based upon the absolute position of the item in the list (the 3rd option comes closest, but requires a condition for every single possible position just to do something simple like highlighting every second row). |
@jurialmunkey the even/odd usecase for textures is an interesting case.
|
This infolabel allows a skinner to print the current index of an item in within it's container.
8f2141c
to
13b1667
Compare
Inspired by @jurialmunkey's usecase I checked the code and found it's easy to implement the odd/even boolean condition. |
I gave the testbuild a spin. Working well afaict. 👍 I tested with/without parent folder items, in panels, in wrap/fixedlists, and referencing other containers and all worked as expected. The IsOdd/Even conditions worked correctly everywhere I tried them. |
Awesome news! |
As testing have been successful, I changed the PR description and will merge this week if there are no objections. |
This was written 29 days ago. As there were no objections, let's do it now. :-) |
Description
Looks like we have no way to just print the position
of an item within it's container.
Adds a new ListItem property to obtain the current
position within a container.
Additionally it adds new boolean conditions to check if an item is on an even or odd place, so one can easily apply different textures to every second row in a list.
Types of change
Checklist: