This commit is contained in:
fgerlits 2006-10-24 18:03:32 +00:00
parent 6d62a97b05
commit 1df4de1571
9 changed files with 108 additions and 47 deletions

View File

@ -128,11 +128,7 @@ CuePlayer :: onPlayItem(void) throw ()
Ptr<Playable>::Ref playable = (*iter)[modelColumns.playableColumn];
try {
gLiveSupport->playCueAudio(playable);
audioState = playingState;
remove(*playButton);
pack_end(*pauseButton, Gtk::PACK_SHRINK, 3);
pauseButton->show();
gLiveSupport->runMainLoop();
setAudioState(playingState);
} catch (std::runtime_error &e) {
std::cerr << "GLiveSupport::playCueAudio() error:"
<< std::endl << e.what() << std::endl;
@ -151,24 +147,22 @@ CuePlayer :: onPlayButtonClicked(void) throw ()
case waitingState:
onPlayItem();
break;
case pausedState:
try {
gLiveSupport->pauseCueAudio(); // ie, restart
audioState = playingState;
remove(*playButton);
pack_end(*pauseButton, Gtk::PACK_SHRINK, 3);
pauseButton->show();
gLiveSupport->runMainLoop();
} catch (std::logic_error &e) {
std::cerr << "GLiveSupport::pauseCueAudio() error:" << std::endl
<< e.what() << std::endl;
}
break;
case playingState: // should never happen
std::cerr << "Assertion failed in CuePlayer:" << std::endl
<< "play button clicked when it should not be visible."
<< std::endl;
break;
case pausedState:
try {
gLiveSupport->pauseCueAudio(); // ie, restart
setAudioState(playingState);
} catch (std::logic_error &e) {
std::cerr << "GLiveSupport::pauseCueAudio() error:" << std::endl
<< e.what() << std::endl;
}
break;
}
}
@ -181,11 +175,7 @@ CuePlayer :: onPauseButtonClicked(void) throw ()
{
try {
gLiveSupport->pauseCueAudio();
audioState = pausedState;
remove(*pauseButton);
pack_end(*playButton, Gtk::PACK_SHRINK, 3);
playButton->show();
gLiveSupport->runMainLoop();
setAudioState(pausedState);
} catch (std::logic_error &e) {
std::cerr << "GLiveSupport::pauseCueAudio() error:" << std::endl
<< e.what() << std::endl;
@ -206,7 +196,7 @@ CuePlayer :: onStopButtonClicked(void) throw ()
std::cerr << "GLiveSupport::stopCueAudio() error:" << std::endl
<< e.what() << std::endl;
}
onStop();
setAudioState(waitingState);
}
}
@ -217,19 +207,31 @@ CuePlayer :: onStopButtonClicked(void) throw ()
void
CuePlayer :: onStop(void) throw ()
{
switch (audioState) {
case pausedState:
remove(*playButton);
break;
case playingState:
remove(*pauseButton);
break;
case waitingState: // sometimes onStop() is called twice
return;
}
audioState = waitingState;
pack_end(*playButton, Gtk::PACK_SHRINK, 3);
playButton->show();
gLiveSupport->runMainLoop();
setAudioState(waitingState);
}
/*------------------------------------------------------------------------------
* Set the state of the widget.
*----------------------------------------------------------------------------*/
void
CuePlayer :: setAudioState(AudioState newState) throw ()
{
if ((audioState == waitingState || audioState == pausedState)
&& newState == playingState) {
remove(*playButton);
pack_end(*pauseButton, Gtk::PACK_SHRINK, 3);
pauseButton->show();
gLiveSupport->runMainLoop();
} else if (audioState == playingState
&& (newState == waitingState || newState == pausedState)) {
remove(*pauseButton);
pack_end(*playButton, Gtk::PACK_SHRINK, 3);
playButton->show();
gLiveSupport->runMainLoop();
}
audioState = newState;
}

View File

@ -140,6 +140,16 @@ class CuePlayer : public Gtk::HBox,
void
onStopButtonClicked(void) throw ();
/**
* Set the state of the widget.
* It sets the value of the audioState variable, and changes the
* play/pause button if necessary.
*
* @param newState the new value of the audioState variable.
*/
void
setAudioState(AudioState newState) throw ();
public:

View File

@ -1358,6 +1358,8 @@ GLiveSupport :: stopCueAudio(void)
cuePlayer->close();
cuePlayerIsPaused = false;
cueItemPlayingNow.reset();
masterPanel->showCuePlayerStopped();
}
}

View File

@ -140,7 +140,7 @@ LiveModeWindow :: LiveModeWindow (Ptr<GLiveSupport>::Ref gLiveSupport,
std::exit(1);
}
Gtk::HBox * cueAudioButtonsBox = Gtk::manage(new Gtk::HBox);
CuePlayer * cueAudioButtons = Gtk::manage(new CuePlayer(
cueAudioButtons = Gtk::manage(new CuePlayer(
gLiveSupport, treeView, modelColumns ));
buttonBox->pack_start(*outputPlayButton, Gtk::PACK_EXPAND_PADDING, 10);
buttonBox->pack_start(*cueAudioBox, Gtk::PACK_EXPAND_PADDING, 10);

View File

@ -85,6 +85,11 @@ class LiveModeWindow : public GuiWindow
*/
Ptr<ExportPlaylistWindow>::Ref exportPlaylistWindow;
/**
* The cue player widget with play/pause and stop buttons.
*/
CuePlayer * cueAudioButtons;
protected:
@ -251,6 +256,15 @@ class LiveModeWindow : public GuiWindow
*/
Ptr<Playable>::Ref
popTop(void) throw ();
/**
* Update the cue player display to show a stopped state.
*/
void
showCuePlayerStopped(void) throw ()
{
cueAudioButtons->onStop();
}
};
/* ================================================= external data structures */

View File

@ -888,3 +888,19 @@ MasterPanelWindow :: setSchedulerAvailable(bool status) throw ()
}
}
/*------------------------------------------------------------------------------
* Update the cue player displays to show a stopped state.
*----------------------------------------------------------------------------*/
void
MasterPanelWindow :: showCuePlayerStopped(void) throw ()
{
if (scratchpadWindow) {
scratchpadWindow->showCuePlayerStopped();
}
if (liveModeWindow) {
liveModeWindow->showCuePlayerStopped();
}
}

View File

@ -551,6 +551,14 @@ class MasterPanelWindow : public Gtk::Window, public LocalizedObject
*/
void
setSchedulerAvailable(bool status) throw ();
/**
* Update the cue player displays to show a stopped state.
* Two cue player displays are updated by this method:
* one in the Scratchpad, and one in the Live Mode window.
*/
void
showCuePlayerStopped(void) throw ();
};
/* ================================================= external data structures */

View File

@ -149,9 +149,9 @@ ScratchpadWindow :: ScratchpadWindow (
// Only show the scrollbars when they are necessary:
scrolledWindow.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
audioButtonBox = Gtk::manage(new CuePlayer(
cueAudioButtons = Gtk::manage(new CuePlayer(
gLiveSupport, treeView, modelColumns ));
topButtonBox.pack_start(*audioButtonBox, Gtk::PACK_EXPAND_PADDING);
topButtonBox.pack_start(*cueAudioButtons, Gtk::PACK_EXPAND_PADDING);
middleButtonBox.set_layout(Gtk::BUTTONBOX_END);
middleButtonBox.set_spacing(5);
@ -191,7 +191,7 @@ ScratchpadWindow :: ScratchpadWindow (
&ZebraTreeView::onRemoveMenuOption)));
audioClipMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
*getResourceUstring("cueMenuItem"),
sigc::mem_fun(*audioButtonBox,
sigc::mem_fun(*cueAudioButtons,
&CuePlayer::onPlayItem)));
audioClipMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
*getResourceUstring("addToLiveModeMenuItem"),
@ -240,7 +240,7 @@ ScratchpadWindow :: ScratchpadWindow (
&ZebraTreeView::onRemoveMenuOption)));
playlistMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
*getResourceUstring("cueMenuItem"),
sigc::mem_fun(*audioButtonBox,
sigc::mem_fun(*cueAudioButtons,
&CuePlayer::onPlayItem)));
playlistMenuList.push_back(Gtk::Menu_Helpers::MenuElem(
*getResourceUstring("addToLiveModeMenuItem"),

View File

@ -84,7 +84,7 @@ class ScratchpadWindow : public GuiWindow,
* The Export Playlist pop-up window.
*/
Ptr<ExportPlaylistWindow>::Ref exportPlaylistWindow;
/**
* Check whether exactly one row is selected, and if so, set
* the currentRow variable to point to it.
@ -193,9 +193,9 @@ class ScratchpadWindow : public GuiWindow,
Gtk::HBox topButtonBox;
/**
* The box containing the audio buttons.
* The cue player widget containing the audio buttons.
*/
CuePlayer * audioButtonBox;
CuePlayer * cueAudioButtons;
/**
* The box containing the close button.
@ -405,10 +405,19 @@ class ScratchpadWindow : public GuiWindow,
* @return the user preference key.
*/
Ptr<const Glib::ustring>::Ref
getUserPreferencesKey(void) throw ()
getUserPreferencesKey(void) throw ()
{
return userPreferencesKey;
}
/**
* Update the cue player display to show a stopped state.
*/
void
showCuePlayerStopped(void) throw ()
{
cueAudioButtons->onStop();
}
};
/* ================================================= external data structures */