[Amis-vcs] SF.net SVN: amis: [2375] branches/amis3
Brought to you by:
julienq,
marisademeglio
From: <mar...@us...> - 2008-03-03 00:59:28
|
Revision: 2375 http://amis.svn.sourceforge.net/amis/?rev=2375&view=rev Author: marisademeglio Date: 2008-03-02 16:59:30 -0800 (Sun, 02 Mar 2008) Log Message: ----------- Moderate success with toggling the play/pause button images. Needs testing though, and it still doesn't react to audio events (just user button presses). Also, the slowdown button is disabled unless the user has already increased the rate (this needs testing) Modified Paths: -------------- branches/amis3/AmisGuiMFC2/include/gui/toolbar/Toolbar.h branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp branches/amis3/AmisGuiMFC2/src/gui/toolbar/Toolbar.cpp branches/amis3/AmisGuiMFC2/src/io/ToolbarIO.cpp branches/amis3/bin/settings/defaultToolbar.xml Modified: branches/amis3/AmisGuiMFC2/include/gui/toolbar/Toolbar.h =================================================================== --- branches/amis3/AmisGuiMFC2/include/gui/toolbar/Toolbar.h 2008-03-03 00:00:21 UTC (rev 2374) +++ branches/amis3/AmisGuiMFC2/include/gui/toolbar/Toolbar.h 2008-03-03 00:59:30 UTC (rev 2375) @@ -63,9 +63,15 @@ void setCommandId(UINT); const ambulant::net::url* getImageSrc(); UINT getCommandId(); + std::string getId(); + void setId(std::string); + void setImageIndex(int); + int getImageIndex(); private: ambulant::net::url mSrc; UINT mMfcId; + std::string mId; + int mImageIndex; }; class ToolbarToggleButton : public ToolbarItem { @@ -114,8 +120,7 @@ Toolbar(); virtual ~Toolbar(); void setSettings(ToolbarSettings*); - void enableSlowdown(bool); - void setPlayPauseToggle(bool); + void togglePlayPause(bool); void enable(UINT, bool); protected: afx_msg int OnCreate(LPCREATESTRUCT); Modified: branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp 2008-03-03 00:00:21 UTC (rev 2374) +++ branches/amis3/AmisGuiMFC2/src/gui/AmisApp.cpp 2008-03-03 00:59:30 UTC (rev 2375) @@ -426,11 +426,13 @@ if (view->isPlaying() == true) { amis::util::Log::Instance()->writeMessage("Pausing", "CAmisApp::OnPlayPause", "AmisGuiMFC2"); + MainWndParts::Instance()->mpDefaultToolbar->togglePlayPause(true); view->OnFilePause(); } else { amis::util::Log::Instance()->writeMessage("Playing", "CAmisApp::OnPlayPause", "AmisGuiMFC2"); + MainWndParts::Instance()->mpDefaultToolbar->togglePlayPause(false); view->OnFilePlay(); } } Modified: branches/amis3/AmisGuiMFC2/src/gui/toolbar/Toolbar.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/gui/toolbar/Toolbar.cpp 2008-03-03 00:00:21 UTC (rev 2374) +++ branches/amis3/AmisGuiMFC2/src/gui/toolbar/Toolbar.cpp 2008-03-03 00:59:30 UTC (rev 2375) @@ -23,6 +23,7 @@ #include "stdafx.h" #include "gui/toolbar/Toolbar.h" #include "gui/AmisApp.h" +#include "util/Log.h" using namespace amis::gui::toolbar; @@ -79,7 +80,22 @@ { return mMfcId; } - +void ToolbarButton::setId(string id) +{ + mId = id; +} +string ToolbarButton::getId() +{ + return mId; +} +void ToolbarButton::setImageIndex(int idx) +{ + mImageIndex = idx; +} +int ToolbarButton::getImageIndex() +{ + return mImageIndex; +} /** * a toggle button **/ @@ -219,14 +235,58 @@ { mpSettings = pSettings; } -void Toolbar::enableSlowdown(bool bIsEnabled) +void Toolbar::togglePlayPause(bool bShowPlay) { - //TODO: write this! + //find the toggle button that has the ID_AMIS_PLAYPAUSE command + ToolbarToggleButton* play_pause_button = NULL; + ToolbarItems items = mpSettings->getItems(); + int index_of_toggle = 0; + for (int i = 0; i<items.size(); i++) + { + if (items[i]->getType() == TOGGLE) + { + ToolbarToggleButton* p_tmp = (ToolbarToggleButton*)items[i]; + if (p_tmp->getButtonOne()->getCommandId() == ID_AMIS_PLAYPAUSE) + { + play_pause_button = p_tmp; + index_of_toggle = i; + break; + } + } + } + if (play_pause_button == NULL) + { + amis::util::Log::Instance()->writeError("Play/pause button not found on toolbar", "Toolbar::togglePlayPause", "AmisGuiMFC2"); + return; + } + + ToolbarButton* play_button = NULL; + ToolbarButton* pause_button = NULL; + if (play_pause_button->getButtonOne()->getId() == "play") + { + play_button = play_pause_button->getButtonOne(); + pause_button = play_pause_button->getButtonTwo(); + } + else + { + play_button = play_pause_button->getButtonTwo(); + pause_button = play_pause_button->getButtonOne(); + } + + TBBUTTON play_or_pause; + GetButton(index_of_toggle, &play_or_pause); + if (bShowPlay == true) + { + play_or_pause.iBitmap = play_button->getImageIndex(); + } + else + { + play_or_pause.iBitmap = pause_button->getImageIndex(); + } + DeleteButton(index_of_toggle); + InsertButton(index_of_toggle, &play_or_pause); + } -void Toolbar::setPlayPauseToggle(bool bShowPlay) -{ - //TODO: write this! -} HICON Toolbar::makeIcon(ToolbarButton* pButton) { USES_CONVERSION; @@ -294,6 +354,7 @@ else if (items[i]->getType() == BUTTON) { ToolbarButton* p_button = (ToolbarButton*)items[i]; + p_button->setImageIndex(j); buttons[i].iBitmap = j; buttons[i].fsState = TBSTATE_ENABLED; buttons[i].fsStyle=TBSTYLE_BUTTON; @@ -305,6 +366,8 @@ { ToolbarToggleButton* p_button = (ToolbarToggleButton*)items[i]; buttons[i].iBitmap = j; + p_button->getButtonOne()->setImageIndex(j); + p_button->getButtonTwo()->setImageIndex(j+1); buttons[i].fsState = TBSTATE_ENABLED; buttons[i].fsStyle=TBSTYLE_BUTTON; buttons[i].iString = 0; //TODO: fill this in Modified: branches/amis3/AmisGuiMFC2/src/io/ToolbarIO.cpp =================================================================== --- branches/amis3/AmisGuiMFC2/src/io/ToolbarIO.cpp 2008-03-03 00:00:21 UTC (rev 2374) +++ branches/amis3/AmisGuiMFC2/src/io/ToolbarIO.cpp 2008-03-03 00:59:30 UTC (rev 2375) @@ -107,12 +107,14 @@ amis::gui::toolbar::ToolbarButton* p_button = new amis::gui::toolbar::ToolbarButton(); string image_path = SimpleAttrs::get("src", &attributes); string mfcid = SimpleAttrs::get("mfcid", &attributes); + string id = SimpleAttrs::get("id", &attributes); ambulant::net::url image_url = ambulant::net::url::from_filename(image_path); const ambulant::net::url* base_file = getFilepath(); image_url = image_url.join_to_base(*base_file); UINT n_mfcid = getIdForCommandString(mfcid); p_button->setImageSrc(image_url); p_button->setCommandId(n_mfcid); + p_button->setId(id); if (mbFlagInToggle == true) mpCurrentToggle->addButton(p_button); else Modified: branches/amis3/bin/settings/defaultToolbar.xml =================================================================== --- branches/amis3/bin/settings/defaultToolbar.xml 2008-03-03 00:00:21 UTC (rev 2374) +++ branches/amis3/bin/settings/defaultToolbar.xml 2008-03-03 00:59:30 UTC (rev 2375) @@ -41,6 +41,8 @@ ID_AMIS_SHOW_HELP_CONTENTS ID_AMIS_ABOUT ID_AMIS_NEXT_PAGE_STYLE + +the id's "play" and "pause" are keywords to identify which image is the play button and which is the pause button --> <toolbar xmlns="http://amisproject.org" view="default" placement="top" buttonHeight="32" buttonWidth="32"> <button src="./img/defaultToolbar/document_open.ico" mfcid="ID_AMIS_OPEN_FILE"/> @@ -48,8 +50,8 @@ <separator/> <button src="./img/defaultToolbar/media_seek_backward.ico" mfcid="ID_AMIS_PREVIOUS_PHRASE"/> <toggle> - <button src="./img/defaultToolbar/media_playback_start.ico" mfcid="ID_AMIS_PLAYPAUSE"/> - <button src="./img/defaultToolbar/media_playback_pause.ico" mfcid="ID_AMIS_PLAYPAUSE"/> + <button src="./img/defaultToolbar/media_playback_start.ico" mfcid="ID_AMIS_PLAYPAUSE" id="play"/> + <button src="./img/defaultToolbar/media_playback_pause.ico" mfcid="ID_AMIS_PLAYPAUSE" id="pause"/> </toggle> <button src="./img/defaultToolbar/media_seek_forward.ico" mfcid="ID_AMIS_NEXT_PHRASE"/> <separator/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |