/usr/include/tse3/app/PartSelection.h is in libtse3-dev 0.3.1-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 | /*
* @(#)app/PartSelection.h 1.00 18 June 2000
*
* Copyright (c) 2000 Pete Goodliffe (pete@cthree.org)
*
* This file is part of TSE3 - the Trax Sequencer Engine version 3.00.
*
* This library is modifiable/redistributable under the terms of the GNU
* General Public License.
*
* You should have received a copy of the GNU General Public License along
* with this program; see the file COPYING. If not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#ifndef TSE3_APP_PARTSELECTION_H
#define TSE3_APP_PARTSELECTION_H
#include "tse3/listen/app/PartSelection.h"
#include "tse3/Notifier.h"
#include "tse3/Part.h"
#include "tse3/Midi.h"
#include "tse3/listen/app/TrackSelection.h"
#include <vector>
#include <cstddef>
namespace TSE3
{
class Phrase;
class Song;
class Track;
namespace App
{
/**
* The PartSelection class allows an Application to provide the facility
* to 'select' one or more @ref TSE3::Part in a @ref TSE3::Song. These
* @ref TSE3::Part objects must be held in a @ref TSE3::Track. As soon
* as a @ref TSE3::Part is removed from a @ref TSE3::Track, it is
* removed from the selection.
*
* This behviour is useful when using the command history system in
* the @ref TSE3::Cmd namespace where undoing a @ref TSE3::Part add,
* for example, may cause a selected Part to be removed from the @ref
* TSE3::Song.
*
* Internally, the Parts are held in an STL vector of type <Part*>.
* In order to get access to the contents of this vector, access
* is provided to it's iterator.
*
* If you are using the iterators and performing any operations that
* may affect the PartSelection (i.e. removing a @ref TSE3::Part from
* it's @ref TSE3::Track and reinserting it elsewhere) then you
* will invalidate the iterator.
*
* A method of avoiding this would be to, rather than iterate over each
* Part, to remove a Part from the head of the list, work on it,
* and place it into a second PartSelection. Do this for each Part
* in the PartSelection, and when finished, copy the new PartSelection
* into the old one.
*
* @sect Interaction with @ref TrackSelection
*
* You may want to use this selection utility in connection with the
* @ref TrackSelection class to ensure that the user has only selected
* one type of object at any time.
*
* To facilitate this, the PartSelection is a
* @ref TrackSelectionListener. You can attach it to a
* @ref TrackSelection object, and whenever the @ref TrackSelection
* has a @ref TSE3::Track selected the PartSelection will be cleared.
*
* You will need to use an attach like this:
* <pre>
* PartSelection ps;
* TrackSelection *ts = someTrackSelection();
* ps.TSE3::Listener<TSE3::App::TrackSelectionListener>::attachTo(ts);
* </pre>
*
* @short Support class for selecting one or more @ref Part object
* @author Pete Goodliffe
* @version 1.00
* @see TSE3
*/
class PartSelection : public TSE3::Listener<TSE3::PartListener>,
public TSE3::Listener<TrackSelectionListener>,
public TSE3::Notifier<PartSelectionListener>
{
public:
/**
* The PartSelection begins with no @ref Part selected.
*/
PartSelection();
~PartSelection();
PartSelection(const PartSelection &);
/**************************************************************
* Setting the selection
*************************************************************/
/**
* Returns the earliest start time of any @ref TSE3::Part in the
* selection.
*
* If there is no selection, this will return -1.
*
* @return Earliest @ref TSE3::Part start time
*/
TSE3::Clock earliest() const { return _earliest; }
/**
* Returns the latest end time of any @ref TSE3::Part in the
* selection.
*
* If there is no selection, this will return -1.
*
* @return Latest @ref TSE3::Part start time
*/
TSE3::Clock latest() const { return _latest; }
/**
* Returns the lowest @ref TSE3::Track index that any selected
* @ref TSE3::Part is in.
*
* If there is no selection, this will return 0.
*
* @return Lowest @ref TSE3::Track index.
*/
size_t minTrack() const { return _minTrack; }
/**
* Returns the greatest @ref TSE3::Track index that any selected
* @ref TSE3::Part is in.
*
* If there is no selection, this will return 0.
*
* @return Greatest @ref TSE3::Track index.
*/
size_t maxTrack() const { return _maxTrack; }
/**
* Selects a @ref TSE3::Part.
*
* If the @ref TSE3::Part is not in a @ref TSE3::Track, it
* will not be selected.
*
* @param part The @ref Part to select
* @param add Whether to add the @ref TSE3::Part to the
* selection (true) or to replace the current
* selection (false).
*/
void select(TSE3::Part *part, bool add);
/**
* Deselects a @ref Part. If the @ref Part is not selected,
* then nothing will happen.
*
* @param part The @ref Part to deselect
*/
void deselect(TSE3::Part *part);
/**
* Clears the entire selection.
*/
void clear();
/**
* Selects all the @ref TSE3::Part objects in the
* given @ref TSE3::Song (this 'should' include any Parts
* alreadys selected!).
*
* @param song @ref TSE3::Song whose @ref TSE3::Part objects
* are all to be selected
*/
void selectAll(TSE3::Song *song);
/**
* Adds to the selection all the @ref TSE3::Part objects in the
* given @ref TSE3::Track.
*
* @param track @ref TSE3::Track whose @ref TSE3::Part objects
* are all to be selected
*/
void selectAll(TSE3::Track *track);
/**
* Inverts the selection for all the @ref TSE3::Part objects in
* the given @ref TSE3::Song (i.e. all selected Parts are
* deselected and all deselected Parts are selected).
*
* @param song @ref TSE3::Song whose @ref TSE3::Part objects
* are all to be inverted
*/
void invert(TSE3::Song *song);
/**
* Adds to the selection all the Parts which have a section
* lying either inside or outside the window between a
* @p start time and an @p end time.
*
* @param song @ref TSE3::Song whose @ref TSE3::Part objects
* are all to be operated on
* @param start Start of selection window
* @param end End of selection window
* @param inside If true, select @ref TSE3::Part objects between
* @p start and @p end, else select Parts NOT
* between these times
*/
void selectBetween(TSE3::Song *song,
TSE3::Clock start, TSE3::Clock end,
bool inside = true);
/**
* Adds to the selection all the Parts which have a section
* lying either inside or outside the window between a
* @p start time and an @p end time.
*
* @param track @ref TSE3::Track whose @ref TSE3::Part objects
* are all to be operated on
* @param start Start of selection window
* @param end End of selection window
* @param inside If true, select @ref TSE3::Part objects between
* @p start and @p end, else select Parts NOT
* between these times
*/
void selectBetween(TSE3::Track *track,
TSE3::Clock start, TSE3::Clock end,
bool inside = true);
/**
* Copy PartSelection contents.
*/
PartSelection &operator=(const PartSelection &);
/**************************************************************
* Access to the selected Parts
*************************************************************/
/**
* Returns how many @ref TSE3::Part objects are selected.
*
* @return No of selected @ref TSE3::Part objects
*/
size_t size() const { return parts.size(); }
/**
* Returns whether a particular @ref TSE3::Part is selected.
*
* @param part The @ref TSE3::Part to run selection test on
* @return Whether the @ref TSE3::Part is selected
*/
bool isSelected(TSE3::Part *part) const;
typedef std::vector<TSE3::Part*>::const_iterator iterator_t;
/**
* Returns the first item in the PartSelection, or zero if
* there are no selected Parts.
*
* @return First selected @ref TSE3::Part
*/
Part *front() const
{
return parts.size() ? parts.front() : 0;
}
/**
* Returns the last item in the PartSelection, or zero if
* there are no selected Parts.
*
* @return Last selected @ref TSE3::Part
*/
Part *back() const
{
return parts.size() ? parts.back() : 0;
}
/**
* Returns an iterator pointing to the first @ref TSE3::Part in
* this selection.
*
* @return Iterator pointing to first selected @ref TSE3::Part
*/
iterator_t begin() const { return parts.begin(); }
/**
* Returns an iterator pointing to the last @ref TSE3::Part in
* this selection.
*
* @return Iterator pointing to last selected @ref TSE3::Part
*/
iterator_t end() const { return parts.end(); }
/**
* @reimplemented
*/
virtual void Part_StartAltered(Part *, Clock start);
/**
* @reimplemented
*/
virtual void Part_EndAltered(Part *, Clock end);
/**
* @reimplemented
*/
virtual void Part_Reparented(Part *);
/**
* @reimplemented
*/
virtual void Notifier_Deleted(Part *);
/**
* @reimplemented
*/
virtual void TrackSelection_Selected
(TrackSelection *, TSE3::Track *, bool);
private:
/**
* Adds the @ref TSE3::Part to the vector and attaches the
* PartSelection to it, then updates the _earliest and _latest
* values.
*/
void addPart(TSE3::Part *part);
/**
* Removes the @ref TSE3::Part from the vector and detaches the
* PartSelection from it, then updates the _earliest and _latest
* values.
*/
void removePart(TSE3::Part *part);
/**
* Recalculates _earliest and _latest;
*/
void recalculateEnds();
std::vector<TSE3::Part*> parts;
bool timesValid;
TSE3::Clock _earliest;
TSE3::Clock _latest;
bool tracksValid;
size_t _minTrack;
size_t _maxTrack;
};
}
}
#endif
|