📄 freeampui.cpp
字号:
{
int32 hours = m_timeView->CurrentHours();
int32 minutes = m_timeView->CurrentMinutes();
int32 seconds = m_timeView->CurrentSeconds();
m_lastTimeDisplay = m_timeView->Display();
m_timeView->SetDisplay(DisplaySeekTime);
m_timeView->SetSeekTime(hours, minutes, seconds);
// oops broken with new buffering scheme
// let's try to calculate this...
// NOTE: won't work for VBR files...grrrr
//m_seekFrame = m_currentFrame;
int32 currentTimeInSeconds = hours * 3600;
currentTimeInSeconds += minutes * 60;
currentTimeInSeconds += seconds;
m_seekFrame = (int32)((float)currentTimeInSeconds/m_secondsPerFrame);
/*char buffer[256];
wsprintf(buffer,"m_seekFrame = %d\r\n", m_seekFrame);
OutputDebugString(buffer);*/
SetTimer(m_hwnd, TIMER_SEEK_POSITION, 100, NULL);
break;
}
case DIAL_BUTTON_UP:
{
KillTimer(m_hwnd, TIMER_SEEK_POSITION);
int32 seconds = (int32)ceil(m_secondsPerFrame * m_seekFrame);
int32 hours = seconds / 3600;
int32 minutes = seconds / 60 - hours * 60;
seconds = seconds - minutes * 60 - hours * 3600;
m_timeView->SetCurrentTime(hours, minutes, seconds);
m_timeView->SetDisplay(m_lastTimeDisplay);
m_seekView->SetPosition(0);
if(m_state == UIState_Playing)
{
m_target->AcceptEvent(new ChangePositionEvent(m_seekFrame));
}
break;
}
case DIAL_MOVE:
{
m_seekAcceleration = m_seekView->Position() / 5;
break;
}
}
break;
}
}
}
}
void
FreeAmpUI::
CancelMode()
{
if(m_captureView)
{
m_captureView = NULL;
ReleaseCapture();
}
if(m_mouseView)
{
POINT pt;
GetCursorPos(&pt);
ScreenToClient(m_hwnd, &pt);
if(!m_mouseView->PointInView(pt.x, pt.y))
{
m_mouseView->MouseLeft();
m_mouseView = NULL;
}
}
}
void
FreeAmpUI::
Timer(int32 timerID)
{
switch(timerID)
{
case TIMER_SHOW_STATUS_INFO:
{
if(m_prevSongInfoText)
m_songTitleView->SetText(m_prevSongInfoText);
KillTimer(m_hwnd, TIMER_SHOW_STATUS_INFO);
break;
}
case TIMER_MOUSE_POSITION:
{
bool pointInWindow;
POINT pt;
GetCursorPos(&pt);
ScreenToClient(m_hwnd, &pt);
pointInWindow = MouseMove(pt.x, pt.y, 0);
if(!pointInWindow)
{
KillTimer(m_hwnd, TIMER_MOUSE_POSITION);
SetMouseCapture(false);
}
break;
}
case TIMER_SEEK_POSITION:
{
m_seekFrame += m_seekAcceleration*20*abs(m_seekAcceleration);
if(m_seekFrame < 0)
m_seekFrame = 0;
else if(m_seekFrame > m_totalFrames)
m_seekFrame = m_totalFrames;
//sprintf(foo,"position: %d\r\n",position);
//OutputDebugString(foo);
int32 seconds = (int32)ceil(m_secondsPerFrame * m_seekFrame);
int32 hours = seconds / 3600;
int32 minutes = seconds / 60 - hours * 60;
seconds = seconds - minutes * 60 - hours * 3600;
//sprintf(foo,"seconds: %d\r\n",seconds);
m_timeView->SetSeekTime(hours, minutes, seconds);
break;
}
case TIMER_VOLUME_POSITION:
{
int32 volume = m_volumeInfoView->Volume();
volume += m_volumeAcceleration;
if(volume > 100)
volume = 100;
else if(volume < 0)
volume = 0;
m_volumeInfoView->SetPrefInt32(kVolumePref, volume);
m_target->AcceptEvent(new VolumeEvent(CMD_SetVolume, volume));
/*MMRESULT result;
//float percent = (float)volume/(float)100;
result = waveOutSetPrefInt32(kVolumePref, (HWAVEOUT)WAVE_MAPPER,
MAKELPARAM( 0xFFFF*volume/100,
0xFFFF*volume/100));*/
break;
}
}
}
bool
FreeAmpUI::
MouseMove(int32 xPos,
int32 yPos,
int32 modifiers)
{
bool result = false;
Item<View*>* viewItem = m_viewList->LastItem();
POINT pt;
RECT rect;
pt.x = xPos;
pt.y = yPos;
/*char buffer[256];
wsprintf(buffer,"x = %d y = %d \r\n", xPos, yPos);
OutputDebugString(buffer);*/
GetClientRect(m_hwnd, &rect);
if(m_captureView)
{
m_captureView->MouseMove(xPos, yPos, modifiers);
}
else if(!PtInRect(&rect, pt))
{
if(m_mouseView)
m_mouseView->MouseLeft();
m_mouseView = NULL;
}
else
{
do
{
if( viewItem->Member()->PointInView(xPos, yPos) &&
viewItem->Member()->Visible() &&
viewItem->Member()->Enabled())
{
if(m_mouseView != viewItem->Member())
{
if(m_mouseView)
m_mouseView->MouseLeft();
m_mouseView = viewItem->Member();
m_mouseView->MouseEntered();
}
viewItem->Member()->MouseMove(xPos, yPos, modifiers);
break;
}
}while(viewItem = m_viewList->PriorItem(viewItem) );
result = true;
}
return result;
}
bool
FreeAmpUI::
LeftButtonDown( int32 xPos,
int32 yPos,
int32 modifiers)
{
bool result = false;
Item<View*>* viewItem = m_viewList->LastItem();
do
{
if( viewItem->Member()->PointInView(xPos, yPos) &&
viewItem->Member()->Visible() &&
viewItem->Member()->Enabled())
{
viewItem->Member()->LeftButtonDown(xPos, yPos, modifiers);
m_captureView = viewItem->Member();
SetCapture(m_hwnd);
result = true;
break;
}
}while(viewItem = m_viewList->PriorItem(viewItem) );
return result;
}
bool
FreeAmpUI::
LeftButtonUp( int32 xPos,
int32 yPos,
int32 modifiers)
{
bool result = false;
Item<View*>* viewItem = m_viewList->LastItem();
if(m_captureView)
{
m_captureView->LeftButtonUp(xPos, yPos, modifiers);
m_captureView = NULL;
ReleaseCapture();
}
else
{
do
{
if( viewItem->Member()->PointInView(xPos, yPos) &&
viewItem->Member()->Visible() &&
viewItem->Member()->Enabled())
{
viewItem->Member()->LeftButtonUp(xPos, yPos, modifiers);
result = true;
break;
}
}while(viewItem = m_viewList->PriorItem(viewItem) );
}
return result;
}
bool
FreeAmpUI::
LeftButtonDoubleClick( int32 xPos,
int32 yPos,
int32 modifiers)
{
bool result = false;
//OutputDebugString("LeftButtonDoubleClick\r\n");
Item<View*>* viewItem = m_viewList->LastItem();
do
{
if( viewItem->Member()->PointInView(xPos, yPos) &&
viewItem->Member()->Visible() &&
viewItem->Member()->Enabled())
{
viewItem->Member()->LeftButtonDoubleClick(xPos, yPos, modifiers);
result = true;
break;
}
}while(viewItem = m_viewList->PriorItem(viewItem) );
return result;
}
bool
FreeAmpUI::
RightButtonUp( int32 xPos,
int32 yPos,
int32 modifiers)
{
bool result = false;
if(PtInRegion(m_playerRegion, xPos, yPos))
{
HMENU menuHandle, popupHandle;
HINSTANCE hinst = (HINSTANCE)GetWindowLong(m_hwnd, GWL_HINSTANCE);
POINT pt;
int32 command;
// need coordinates relative to screen
pt.x = xPos;
pt.y = yPos;
ClientToScreen(m_hwnd, &pt);
// make sure we are in the foreground
SetForegroundWindow(m_hwnd);
// load the menu and retrieve its popup
menuHandle = LoadMenu(hinst, MAKEINTRESOURCE(IDM_MAIN));
popupHandle = GetSubMenu(menuHandle, 0);
// display the popup
command = TrackPopupMenu( popupHandle,
TPM_RETURNCMD | TPM_RIGHTBUTTON,
pt.x,
pt.y,
0,
m_hwnd,
NULL);
switch(command)
{
case IDC_ABOUT:
SendMessage(m_hwnd, WM_COMMAND, kAboutControl, 0);
break;
case IDC_OPEN:
SendMessage(m_hwnd, WM_COMMAND, kOpenControl, 0);
break;
case IDC_SAVE:
SendMessage(m_hwnd, WM_COMMAND, kSaveControl, 0);
break;
case IDC_PREF:
SendMessage(m_hwnd, WM_COMMAND, kPrefControl, 0);
break;
case IDC_EXIT:
SendMessage(m_hwnd, WM_COMMAND, kCloseControl, 0);
break;
}
}
return result;
}
bool
FreeAmpUI::
RightButtonDown(int32 xPos,
int32 yPos,
int32 modifiers)
{
bool result = false;
return result;
}
void
FreeAmpUI::
TrayNotify(int32 notifyMessage)
{
switch(notifyMessage)
{
case WM_LBUTTONUP:
{
ShowWindow( m_hwnd, SW_NORMAL);
SetForegroundWindow(m_hwnd);
break;
}
case WM_RBUTTONUP:
{
HMENU menuHandle, popupHandle;
HINSTANCE hinst = (HINSTANCE)GetWindowLong(m_hwnd, GWL_HINSTANCE);
POINT pt;
int32 command;
// need mouse coordinates relative to screen
GetCursorPos(&pt);
// load the menu and retrieve its popup
menuHandle = LoadMenu(hinst, MAKEINTRESOURCE(IDM_TRAY));
popupHandle = GetSubMenu(menuHandle, 0);
if(m_state != UIState_Stopped)
{
MENUITEMINFO mii;
memset(&mii, 0x00, sizeof(MENUITEMINFO));
mii.cbSize = sizeof(MENUITEMINFO);
mii.fMask = MIIM_TYPE|MIIM_ID ;
mii.fType = MFT_STRING;
mii.dwTypeData = "Stop";
mii.cch = strlen("Stop");
mii.wID = IDC_STOP;
SetMenuItemInfo(popupHandle,
5,
TRUE,
&mii);
}
if(m_state == UIState_Paused)
{
MENUITEMINFO mii;
memset(&mii, 0x00, sizeof(MENUITEMINFO));
mii.cbSize = sizeof(MENUITEMINFO);
mii.fMask = MIIM_STATE;
mii.fState = MFS_CHECKED;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -