Skip to content

Commit

Permalink
Added documentation for project.select_item()
Browse files Browse the repository at this point in the history
  • Loading branch information
Dage committed Jan 18, 2021
1 parent 7fc89a7 commit dd4be8c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ All notable changes to this project will be documented in this file.
It checks if a the file or folder exists.
If it's a path to a file, it make sure that it's in a format supported by REAPER.
You can specify a specific extension or a list of extensions and it will raise if the choosen file does not match

- `Project.select_item()` method to select a specific item.

This comment has been minimized.

Copy link
@Levitanus

Levitanus Jan 18, 2021

Contributor

There is property is_selected.
At least in my fork it can be set)))

This comment has been minimized.

Copy link
@Levitanus

Levitanus Jan 18, 2021

Contributor

Ahh, I see. Can not get, how does it help, if Item is still needed.

This comment has been minimized.

Copy link
@makingpippop

makingpippop Jan 18, 2021

Maybe we could add @is_selected.setter which would add or remove the item to the current selection.

Although Project.select_item() is still useful in the case where we want to make sure we select only one Item (using the makeUnique argument)

This comment has been minimized.

Copy link
@Levitanus

Levitanus Jan 18, 2021

Contributor

I've already added in 9315e41

And, maybe we could add reapy.Item.make_only_selected_item() method in analogy with the reapy.Track API.

This comment has been minimized.

Copy link
@makingpippop

makingpippop Jan 18, 2021

I guess there's two way to approach this.

From my perspective, since a Track or an Item cannot exist if there is no Project, the role of Project would be to control high level features (like creation, selection, ...) of these items. Project is the one we need to go through to access a Track or an Item.

Some high level feature examples:

Project.get_selected_tracks
Project.tracks
Project.unsolo_all_tracks
Project.n_items
Project.items

Keeping that logic in mind, a single Item has no way to know the state of another Item since it doesn't have access to that kind of information. Only Project knows. So, in my opinion, it would be the role of Project to control which Item or Track is selected.

Of course, an Item or Track can add itself to the current project selection, but since he doesn't have access to other items, I don't think he could make himself the only selected item.

@RomeoDespres what is your take on this? (no pun intended)

This comment has been minimized.

Copy link
@Levitanus

Levitanus Jan 18, 2021

Contributor

just look for my last commit in the hotfixes PR (#92)

This comment has been minimized.

Copy link
@makingpippop

makingpippop Jan 18, 2021

I understand that's its doable, my question is more about, should an Item be able to do that, semantically speaking.

I'm fine with both! It's just not my place to say :)

## [Unreleased] - 2020-12-30

### Fixed
Expand Down
12 changes: 12 additions & 0 deletions reapy/core/project/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -989,6 +989,18 @@ def select_all_items(self, selected=True):
RPR.SelectAllMediaItems(self.id, selected)

def select_item(self, item_obj, selected=True, makeUnique=False):
"""
Select or unselect an item, depending on `selected`.
Parameters
----------
item_obj : reapy.Item
The item to select
selected : bool [optional]
Whether to select or unselect the item.
makeUnique : bool [optional]
If False the Item will be added to the current selection, if True it will become the only selected item
"""
if makeUnique:
self.select_all_items(selected=False)
RPR.SetMediaItemSelected(item_obj.id, selected)
Expand Down
14 changes: 14 additions & 0 deletions reapy/core/project/project.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -790,6 +790,20 @@ class Project(ReapyObject):
"""
...

def select_item(self, item_obj, selected:bool=True, makeUnique:bool=False) -> None:
"""
Select or unselect an item, depending on `selected`.
Parameters
----------
item_obj : reapy.Item
The item to select
selected : bool [optional]
Whether to select or unselect the item.
makeUnique : bool [optional]
If False the Item will be added to the current selection, if True it will become the only selected item
"""
...
def select_all_tracks(self) -> None:
"""Select all tracks."""
...
Expand Down

0 comments on commit dd4be8c

Please sign in to comment.