~ubuntu-branches/ubuntu/utopic/cdrdao/utopic

« back to all changes in this revision

Viewing changes to xdao/TocEditView.cc

  • Committer: Bazaar Package Importer
  • Author(s): Andrew Suffield
  • Date: 2004-06-24 22:33:16 UTC
  • Revision ID: james.westby@ubuntu.com-20040624223316-534onzugaeeyq61j
Tags: upstream-1.1.9
ImportĀ upstreamĀ versionĀ 1.1.9

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*  cdrdao - write audio CD-Rs in disc-at-once mode
 
2
 *
 
3
 *  Copyright (C) 1998-2000 Andreas Mueller <mueller@daneb.ping.de>
 
4
 *
 
5
 *  This program is free software; you can redistribute it and/or modify
 
6
 *  it under the terms of the GNU General Public License as published by
 
7
 *  the Free Software Foundation; either version 2 of the License, or
 
8
 *  (at your option) any later version.
 
9
 *
 
10
 *  This program is distributed in the hope that it will be useful,
 
11
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
13
 *  GNU General Public License for more details.
 
14
 *
 
15
 *  You should have received a copy of the GNU General Public License
 
16
 *  along with this program; if not, write to the Free Software
 
17
 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
18
 */
 
19
 
 
20
#include "TocEditView.h"
 
21
 
 
22
#include <stddef.h>
 
23
 
 
24
#include "guiUpdate.h"
 
25
#include "TocEdit.h"
 
26
 
 
27
TocEditView::TocEditView(TocEdit *t)
 
28
{
 
29
  tocEdit_ = t;
 
30
 
 
31
  sampleMarkerValid_ = 0;
 
32
  sampleSelectionValid_ = 0;
 
33
  sampleViewMin_ = sampleViewMax_ = 0;
 
34
  trackSelectionValid_ = 0;
 
35
  indexSelectionValid_ = 0;
 
36
}
 
37
 
 
38
TocEditView::~TocEditView()
 
39
{
 
40
  tocEdit_ = 0;
 
41
}
 
42
 
 
43
TocEdit *TocEditView::tocEdit() const
 
44
{
 
45
  return tocEdit_;
 
46
}
 
47
 
 
48
 
 
49
void TocEditView::sampleMarker(unsigned long sample)
 
50
{
 
51
  if (sample < tocEdit_->toc()->length().samples()) {
 
52
    sampleMarker_ = sample;
 
53
    sampleMarkerValid_ = 1;
 
54
  }
 
55
  else {
 
56
    sampleMarkerValid_ = 0;
 
57
  }
 
58
 
 
59
  tocEdit_->updateLevel_ |= UPD_SAMPLE_MARKER;
 
60
}
 
61
 
 
62
int TocEditView::sampleMarker(unsigned long *sample) const
 
63
{
 
64
  if (sampleMarkerValid_)
 
65
    *sample = sampleMarker_;
 
66
 
 
67
  return sampleMarkerValid_;
 
68
}
 
69
 
 
70
void TocEditView::sampleSelection(unsigned long smin, unsigned long smax)
 
71
{
 
72
  unsigned long tmp;
 
73
 
 
74
  if (smin > smax) {
 
75
    tmp = smin;
 
76
    smin = smax;
 
77
    smax = tmp;
 
78
  }
 
79
 
 
80
  if (smax < tocEdit_->toc()->length().samples()) {
 
81
    sampleSelectionMin_ = smin;
 
82
    sampleSelectionMax_ = smax;
 
83
 
 
84
    sampleSelectionValid_ = 1;
 
85
  }
 
86
  else {
 
87
    sampleSelectionValid_ = 0;
 
88
  }
 
89
  
 
90
  tocEdit_->updateLevel_ |= UPD_SAMPLE_SEL;
 
91
}
 
92
 
 
93
void TocEditView::sampleSelectionClear()
 
94
{
 
95
  if (sampleSelectionValid_)
 
96
    tocEdit_->updateLevel_ |= UPD_SAMPLE_SEL;
 
97
 
 
98
  sampleSelectionValid_ = 0;
 
99
}
 
100
 
 
101
int TocEditView::sampleSelection(unsigned long *smin, unsigned long *smax) const
 
102
{
 
103
  if (sampleSelectionValid_) {
 
104
    *smin = sampleSelectionMin_;
 
105
    *smax = sampleSelectionMax_;
 
106
  }
 
107
 
 
108
  return sampleSelectionValid_;
 
109
}
 
110
 
 
111
void TocEditView::sampleView(unsigned long smin, unsigned long smax)
 
112
{
 
113
  if (smin <= smax && smax < tocEdit_->lengthSample()) {
 
114
    sampleViewMin_ = smin;
 
115
    sampleViewMax_ = smax;
 
116
    tocEdit_->updateLevel_ |= UPD_SAMPLES;
 
117
  }
 
118
}
 
119
 
 
120
void TocEditView::sampleView(unsigned long *smin, unsigned long *smax) const
 
121
{
 
122
  *smin = sampleViewMin_;
 
123
  *smax = sampleViewMax_;
 
124
}
 
125
 
 
126
void TocEditView::sampleViewFull()
 
127
{
 
128
  sampleViewMin_ = 0;
 
129
 
 
130
  if ((sampleViewMax_ = tocEdit_->lengthSample()) > 0)
 
131
    sampleViewMax_ -= 1;
 
132
 
 
133
  tocEdit_->updateLevel_ |= UPD_SAMPLES;
 
134
}
 
135
 
 
136
void TocEditView::sampleViewUpdate()
 
137
{
 
138
  if (sampleViewMax_ >= tocEdit_->lengthSample()) {
 
139
    unsigned long len = sampleViewMax_ - sampleViewMin_;
 
140
 
 
141
    if ((sampleViewMax_ = tocEdit_->lengthSample()) > 0)
 
142
      sampleViewMax_ -= 1;
 
143
    
 
144
 
 
145
    if (sampleViewMax_ >= len)
 
146
      sampleViewMin_ = sampleViewMax_ - len;
 
147
    else
 
148
      sampleViewMin_ = 0;
 
149
 
 
150
    tocEdit_->updateLevel_ |= UPD_SAMPLES;
 
151
  }
 
152
}
 
153
 
 
154
void TocEditView::sampleViewInclude(unsigned long smin, unsigned long smax)
 
155
{
 
156
  if (smin < sampleViewMin_) {
 
157
    sampleViewMin_ = smin;
 
158
    tocEdit_->updateLevel_ |= UPD_SAMPLES;
 
159
  }
 
160
 
 
161
  if (smax < tocEdit_->lengthSample() && smax > sampleViewMax_) {
 
162
    sampleViewMax_ = smax;
 
163
    tocEdit_->updateLevel_ |= UPD_SAMPLES;
 
164
  }
 
165
}
 
166
 
 
167
void TocEditView::trackSelection(int tnum)
 
168
{
 
169
  if (tnum > 0) {
 
170
    trackSelection_ = tnum;
 
171
    trackSelectionValid_ = 1;
 
172
  }
 
173
  else {
 
174
    trackSelectionValid_ = 0;
 
175
  }
 
176
 
 
177
  tocEdit_->updateLevel_ |= UPD_TRACK_MARK_SEL;
 
178
 
 
179
}
 
180
 
 
181
int TocEditView::trackSelection(int *tnum) const
 
182
{
 
183
  if (trackSelectionValid_)
 
184
    *tnum = trackSelection_;
 
185
 
 
186
  return trackSelectionValid_;
 
187
}
 
188
 
 
189
void TocEditView::indexSelection(int inum)
 
190
{
 
191
  if (inum >= 0) {
 
192
    indexSelection_ = inum;
 
193
    indexSelectionValid_ = 1;
 
194
  }
 
195
  else {
 
196
    indexSelectionValid_ = 0;
 
197
  }
 
198
 
 
199
  tocEdit_->updateLevel_ |= UPD_TRACK_MARK_SEL;
 
200
}
 
201
 
 
202
int TocEditView::indexSelection(int *inum) const
 
203
{
 
204
  if (indexSelectionValid_)
 
205
    *inum = indexSelection_;
 
206
 
 
207
  return indexSelectionValid_;
 
208
}