playlist.cpp
来自「VLC媒体播放程序」· C++ 代码 · 共 578 行 · 第 1/2 页
CPP
578 行
if( !Visible ) return; int xI, yI, wI, hI; // Slider Image Slider->Draw( x, y, w, h, dest ); // TextZone if( GetIntersectRgn( x, y, w, h, TextLeft, TextTop, TextWidth, TextHeight, xI, yI, wI, hI) ) { // Change clipping region SkinRegion *destClipRgn = (SkinRegion *)new OSRegion( 0, 0, w, h ); TextClipRgn->Move( TextLeft - x, TextTop - y ); dest->SetClipRegion( TextClipRgn ); // Draw each line DrawAllCase( dest, x, y, wI, hI ); // Reset clipping region to old region dest->SetClipRegion( destClipRgn ); delete destClipRgn; TextClipRgn->Move( x - TextLeft, y - TextTop ); }}//---------------------------------------------------------------------------void ControlPlayList::DrawAllCase( Graphics *dest, int x, int y, int w, int h ){ int i; for( i = 0; i < NumOfItems - StartIndex && i < Line * Column; i++ ) { DrawCase( dest, i + StartIndex, x, y, w, h ); }}//---------------------------------------------------------------------------void ControlPlayList::DrawCase( Graphics *dest, int i, int x, int y, int w, int h ){ // Test if case is in range int j = i - StartIndex; if( j < 0 || j >= Line * Column ) return; // Draw background if selected if( Select[i] ) { dest->DrawRect( CaseLeft[j] - x, TextTop + j * CaseHeight - y, CaseRight[j] - CaseLeft[j], CaseHeight, SelectColor ); } // Choose font SkinFont *F; if( PlayList->i_index == i ) F = PlayFont; else F = TextFont; // Print number sprintf( Num, "%i", i + 1 ); F->Print( dest, Num, CaseTextLeft[j] - x, TextTop + j * CaseHeight - y, NumWidth - Margin, CaseHeight, VLC_FONT_ALIGN_RIGHT ); // Print name F->Print( dest, GetFileName( i ), NumWidth + Margin + CaseTextLeft[j] - x, TextTop + j * CaseHeight - y, FileWidth - 2 * Margin, CaseHeight, VLC_FONT_ALIGN_LEFT ); // Print info F->Print( dest, "no info", NumWidth + FileWidth + Margin + CaseTextLeft[j] - x, TextTop + j * CaseHeight - y, InfoWidth - Margin, CaseHeight, VLC_FONT_ALIGN_CENTER );}//---------------------------------------------------------------------------char * ControlPlayList::GetFileName( int i ){ if( LongFileName ) { return PlayList->pp_items[i]->psz_name; } else { string f = PlayList->pp_items[i]->psz_name; int pos = f.rfind( DIRECTORY_SEPARATOR, f.size() ); return PlayList->pp_items[i]->psz_name + pos + 1; }}//---------------------------------------------------------------------------void ControlPlayList::MoveRelative( int xOff, int yOff ){ Slider->MoveRelative( xOff, yOff ); Left += xOff; Top += yOff; TextLeft += xOff; TextTop += yOff; for( int i = 1; i < Line; i++ ) { CaseLeft[i] += xOff; CaseTextLeft[i] += xOff; CaseRight[i] += xOff; }}//---------------------------------------------------------------------------double ControlPlayList::Dist( int x1, int y1, int x2, int y2 ){ return sqrt( (x1-x2)*(x1-x2) + (y1-y2)*(y1-y2) );}//---------------------------------------------------------------------------bool ControlPlayList::MouseDown( int x, int y, int button ){ if( !Enabled ) return false; // If hit into slider if( Slider->MouseDown( x, y, button ) ) { int New = Slider->GetCursorPosition(); if( New != StartIndex ) { StartIndex = New; ParentWindow->Refresh( TextLeft,TextTop,TextWidth,TextHeight ); } return true; } if( !TextClipRgn->Hit( x - TextLeft, y - TextTop ) ) return false; // If hit in a case int i, j; for( i = 0; i < PlayList->i_size - StartIndex && i < Line * Column; i++) { if( x >= CaseLeft[i] && x <= CaseRight[i] && y >= TextTop + i * CaseHeight && y < TextTop + (i + 1) * CaseHeight ) { for( j = 0; j < NumOfItems; j++ ) { if( button & KEY_CTRL ) { // CTRL is pressed if( j == i + StartIndex ) { Select[j] = !Select[j]; } } else { // CTRL is not pressed Select[j] = ( j == i + StartIndex ); } } RefreshAll(); return true; } } return false;}//---------------------------------------------------------------------------bool ControlPlayList::MouseUp( int x, int y, int button ){ if( !Enabled ) return false; // If hit into slider if( Slider->MouseUp( x, y, button ) ) return true; return false;}//---------------------------------------------------------------------------bool ControlPlayList::MouseMove( int x, int y, int button ){ if( !Enabled || !button ) return false; // If hit into slider if( Slider->MouseMove( x, y, button ) ) { int New = Slider->GetCursorPosition(); if( New != StartIndex ) { StartIndex = New; RefreshAll(); } return true; } return false;}//---------------------------------------------------------------------------bool ControlPlayList::MouseScroll( int x, int y, int direction ){ if( !Enabled ) return false; if( !TextClipRgn->Hit( x - Left, y - Top ) && !Slider->MouseOver( x, y ) ) return false; long pos = StartIndex; switch( direction ) { case MOUSE_SCROLL_UP: if( pos > 0 ) pos--; break; case MOUSE_SCROLL_DOWN: if( pos + Line < NumOfItems ) pos++; break; } StartIndex = pos; Slider->SetCursorPosition( pos ); RefreshAll(); return true;}//---------------------------------------------------------------------------bool ControlPlayList::MouseOver( int x, int y ){ if( TextClipRgn->Hit( x - Left, y - Top ) || Slider->MouseOver( x, y ) ) return true; else return false;}//---------------------------------------------------------------------------bool ControlPlayList::MouseDblClick( int x, int y, int button ){ if( !Enabled || button != 1 ) return false; int i; if( !TextClipRgn->Hit( x - TextLeft, y - TextTop ) ) return false; for( i = 0; i < PlayList->i_size - StartIndex && i < Line * Column; i++ ) { if( x >= CaseLeft[i] && x <= CaseRight[i] && y >= TextTop + i * CaseHeight && y < TextTop + (i + 1) * CaseHeight ) { playlist_Goto( PlayList, i + StartIndex ); OSAPI_PostMessage( NULL, VLC_INTF_REFRESH, 0, (int)false ); return true; } } return false;}//---------------------------------------------------------------------------bool ControlPlayList::ToolTipTest( int x, int y ){ if( !Enabled ) return false; int i, w, h; for( i = 0; i < PlayList->i_size - StartIndex && i < Line * Column; i++ ) { if( x >= CaseLeft[i] && x <= CaseRight[i] && y >= TextTop + i * CaseHeight && y < TextTop + (i + 1) * CaseHeight ) { TextFont->GetSize( PlayList->pp_items[i + StartIndex]->psz_name, w, h ); if( w > FileWidth ) { ParentWindow->ChangeToolTipText( (string)PlayList->pp_items[i + StartIndex]->psz_name ); return true; } } } return false;}//---------------------------------------------------------------------------void ControlPlayList::InitSliderCurve( double *ptx, double *pty, int nb, string scroll_up, string scroll_down ){ Slider = new ControlSlider( "none", true, "none", scroll_up, scroll_down, ptx, pty, nb, "none", "", ParentWindow );}//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?