remove the length limit control, it simplifies the UI.

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28505 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Jérôme Duval
2008-11-04 20:36:57 +00:00
parent 94f41556bf
commit 07db0c6fd0
2 changed files with 4 additions and 73 deletions
+4 -69
View File
@@ -114,7 +114,6 @@ RecorderWindow::RecorderWindow() :
fStopButton = NULL; fStopButton = NULL;
fSaveButton = NULL; fSaveButton = NULL;
fLoopButton = NULL; fLoopButton = NULL;
fLengthControl = NULL;
fInputField = NULL; fInputField = NULL;
fRecordNode = 0; fRecordNode = 0;
fRecording = false; fRecording = false;
@@ -453,22 +452,6 @@ RecorderWindow::InitWindow()
fInputField->SetDivider(fInputField->StringWidth("Input:") + 4.0f); fInputField->SetDivider(fInputField->StringWidth("Input:") + 4.0f);
fBottomBox->AddChild(fInputField); fBottomBox->AddChild(fInputField);
// Text field for entering length to record (in seconds)
r.OffsetBy(0, 1);
r.left = r.right + 10;
r.right = frame.right - (frame.right - frame.left) / 4;
msg = new BMessage(LENGTH_CHANGED);
fLengthControl = new BTextControl(r, "Length", "Length:", "8", msg);
fLengthControl->SetDivider(fLengthControl->StringWidth("Length:") + 4.0f);
fLengthControl->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_RIGHT);
fBottomBox->AddChild(fLengthControl);
r.left += r.Width()+5;
r.right = r.left + 65;
r.bottom -= 1;
BStringView* lenUnits = new BStringView(r, "Seconds", "seconds");
fBottomBox->AddChild(lenUnits);
fBottomBox->AddChild(fFileInfoBox); fBottomBox->AddChild(fFileInfoBox);
fBottomBox->Hide(); fBottomBox->Hide();
@@ -523,9 +506,6 @@ RecorderWindow::MessageReceived(BMessage * message)
case INPUT_SELECTED: case INPUT_SELECTED:
Input(message); Input(message);
break; break;
case LENGTH_CHANGED:
Length(message);
break;
case SOUND_SELECTED: case SOUND_SELECTED:
Selected(message); Selected(message);
break; break;
@@ -621,12 +601,6 @@ RecorderWindow::Record(BMessage * message)
{ {
// User pressed Record button // User pressed Record button
fRecording = true; fRecording = true;
int seconds = atoi(fLengthControl->Text());
if (seconds < 1) {
ErrorAlert("record a sound that's shorter than a second", B_ERROR);
return;
}
if (fButtonState != btnPaused) { if (fButtonState != btnPaused) {
StopRecording(); StopRecording();
return; // user is too fast on the mouse return; // user is too fast on the mouse
@@ -654,7 +628,7 @@ RecorderWindow::Record(BMessage * message)
return; return;
} }
// Reserve space on disk (creates fewer fragments) // Reserve space on disk (creates fewer fragments)
err = fRecFile.SetSize(seconds * fRecordFormat.u.raw_audio.channel_count err = fRecFile.SetSize(4 * fRecordFormat.u.raw_audio.channel_count
* fRecordFormat.u.raw_audio.frame_rate * (fRecordFormat.u.raw_audio.format & 0xf)); * fRecordFormat.u.raw_audio.frame_rate * (fRecordFormat.u.raw_audio.format & 0xf));
if (err < B_OK) { if (err < B_OK) {
ErrorAlert("record a sound that long", err); ErrorAlert("record a sound that long", err);
@@ -662,8 +636,6 @@ RecorderWindow::Record(BMessage * message)
fRecEntry.Unset(); fRecEntry.Unset();
return; return;
} }
fRecLimit = (off_t)(seconds * fRecordFormat.u.raw_audio.channel_count
* fRecordFormat.u.raw_audio.frame_rate * (fRecordFormat.u.raw_audio.format & 0xf));
fRecSize = 0; fRecSize = 0;
fRecFile.Seek(sizeof(struct wave_struct), SEEK_SET); fRecFile.Seek(sizeof(struct wave_struct), SEEK_SET);
@@ -808,36 +780,6 @@ RecorderWindow::DoSave(BMessage * message)
} }
void
RecorderWindow::Length(BMessage * message)
{
// User changed the Length field -- validate
const char * ptr = fLengthControl->Text();
const char * start = ptr;
const char * anchor = ptr;
const char * end = fLengthControl->Text() + fLengthControl->TextView()->TextLength();
while (ptr < end) {
// Remember the last start-of-character for UTF-8 compatibility
// needed in call to Select() below (which takes bytes).
if (*ptr & 0x80) {
if (*ptr & 0xc0 == 0xc0) {
anchor = ptr;
}
}
else {
anchor = ptr;
}
if (!isdigit(*ptr)) {
fLengthControl->TextView()->MakeFocus(true);
fLengthControl->TextView()->Select(anchor-start, fLengthControl->TextView()->TextLength());
beep();
break;
}
ptr++;
}
}
void void
RecorderWindow::Input(BMessage * message) RecorderWindow::Input(BMessage * message)
{ {
@@ -1006,7 +948,6 @@ RecorderWindow::StopRecording()
// Close the file. // Close the file.
fRecFile.Unset(); fRecFile.Unset();
// No more recording going on. // No more recording going on.
fRecLimit = 0;
fRecSize = 0; fRecSize = 0;
SetButtonState(btnPaused); SetButtonState(btnPaused);
fRecordButton->SetStopped(); fRecordButton->SetStopped();
@@ -1051,7 +992,6 @@ RecorderWindow::UpdateButtons()
fForwardButton->SetEnabled((fButtonState != btnRecording) && hasSelection); fForwardButton->SetEnabled((fButtonState != btnRecording) && hasSelection);
fStopButton->SetEnabled(fButtonState != btnPaused); fStopButton->SetEnabled(fButtonState != btnPaused);
fSaveButton->SetEnabled(hasSelection && (fButtonState != btnRecording)); fSaveButton->SetEnabled(hasSelection && (fButtonState != btnRecording));
fLengthControl->SetEnabled(fButtonState != btnRecording);
fInputField->SetEnabled(fButtonState != btnRecording); fInputField->SetEnabled(fButtonState != btnRecording);
} }
@@ -1217,14 +1157,9 @@ RecorderWindow::RecordFile(void * cookie, bigtime_t timestamp, void * data, size
if (window->fRecording) { if (window->fRecording) {
// Write the data to file (we don't buffer or guard file access // Write the data to file (we don't buffer or guard file access
// or anything) // or anything)
if (window->fRecSize < window->fRecLimit) { window->fRecFile.WriteAt(window->fRecSize, data, size);
window->fRecFile.WriteAt(window->fRecSize, data, size); window->fVUView->ComputeNextLevel(data, size);
window->fVUView->ComputeNextLevel(data, size); window->fRecSize += size;
window->fRecSize += size;
} else {
// We're done!
window->PostMessage(STOP_RECORDING);
}
} }
} }
-4
View File
@@ -30,7 +30,6 @@ class BMediaRoster;
class BBox; class BBox;
class BButton; class BButton;
class BCheckBox; class BCheckBox;
class BTextControl;
class BMenuField; class BMenuField;
class SoundConsumer; class SoundConsumer;
class SoundListView; class SoundListView;
@@ -58,7 +57,6 @@ public:
VIEW_LIST, VIEW_LIST,
LOOP, LOOP,
INPUT_SELECTED = 'cW00', // control messages INPUT_SELECTED = 'cW00', // control messages
LENGTH_CHANGED,
SOUND_SELECTED, SOUND_SELECTED,
STOP_PLAYING, STOP_PLAYING,
STOP_RECORDING, STOP_RECORDING,
@@ -84,7 +82,6 @@ private:
VolumeSlider *fVolumeSlider; VolumeSlider *fVolumeSlider;
TrackSlider *fTrackSlider; TrackSlider *fTrackSlider;
UpDownButton * fUpDownButton; UpDownButton * fUpDownButton;
BTextControl * fLengthControl;
BMenuField * fInputField; BMenuField * fInputField;
SoundConsumer * fRecordNode; SoundConsumer * fRecordNode;
BSoundPlayer * fPlayer; BSoundPlayer * fPlayer;
@@ -114,7 +111,6 @@ private:
media_format fRecordFormat; media_format fRecordFormat;
BFile fRecFile; BFile fRecFile;
off_t fRecLimit;
off_t fRecSize; off_t fRecSize;
media_node fAudioInputNode; media_node fAudioInputNode;