/** \brief Get a suitable icon for the file. * This should retrieve a suitable icon for the file to display and return * an Image pointer to it. * * \param pcNode The item from the remote view that needs an icon. * \param bSmall If true, the icon should be 24x24. Otherwise it should be 48x48. * * \todo Ask the registrar for a suitable icon, based on the file extension. * \todo Add basic file/dir icons as resources, and fall back to them if the icon file is missing. */ Image* RemoteIconView::GetNodeImage( RemoteNode* pcNode, bool bSmall ) { File* pcFile; /* Todo: ask the Registrar for suitable icon */ /* Looks like with current RegistrarManager class, either have to parse the list of registered types, or create a 'fake' temp file and query registrar about that instead */ if( pcNode->m_bIsDir ) { /* TODO: fall back to resource if file isn't present */ pcFile = new File( "/system/icons/folder.png" ); } else { pcFile = new File( "/system/icons/file.png" ); } BitmapImage* pcImage = new BitmapImage( pcFile ); if( bSmall ) { if( pcImage && pcImage->GetSize() != Point( 24,24 ) ) pcImage->SetSize( Point( 24,24 ) ); } else { if( pcImage && pcImage->GetSize() != Point( 48,48 ) ) pcImage->SetSize( Point( 48,48 ) ); } return( pcImage ); }
void DockCamera::MouseMove( const os::Point& cNewPos, int nCode, uint32 nButtons, os::Message* pcData ) { if (nCode == MOUSE_INSIDE) { if (m_bHover) { Bitmap* pcBitmap = m_pcIcon->LockBitmap(); m_bHover = false; if( pcPaint == NULL ) { pcPaint = new BitmapImage(pcBitmap->LockRaster(),IPoint((int)m_pcIcon->GetSize().x,(int)m_pcIcon->GetSize().y),pcBitmap->GetColorSpace());; pcPaint->ApplyFilter(BitmapImage::F_HIGHLIGHT); pcBitmap->UnlockRaster(); pcPaint->UnlockBitmap(); } Invalidate(GetBounds()); Flush(); } } else { m_bHover = true; Invalidate(GetBounds()); Flush(); } if( nCode != MOUSE_ENTERED && nCode != MOUSE_EXITED ) { /* Create dragging operation */ if( m_bCanDrag ) { BitmapImage* pcIcon = m_pcIcon; m_bDragging = true; os::Message* pcMsg = new os::Message(); BeginDrag( pcMsg, os::Point( pcIcon->GetBounds().Width() / 2, pcIcon->GetBounds().Height() / 2 ),pcIcon->LockBitmap() ); delete( pcMsg ); m_bCanDrag = false; Paint(GetBounds()); } } os::View::MouseMove( cNewPos, nCode, nButtons, pcData ); }
void UpdateSettings() { for(UINT i=0; i<bitmapImages.Num(); i++) delete bitmapImages[i]; bitmapImages.Clear(); //------------------------------------ bool bFirst = true; StringList bitmapList; data->GetStringList(TEXT("bitmap"), bitmapList); for(UINT i=0; i<bitmapList.Num(); i++) { String &strBitmap = bitmapList[i]; if(strBitmap.IsEmpty()) { AppWarning(TEXT("BitmapTransitionSource::UpdateSettings: Empty path")); continue; } BitmapImage *bitmapImage = new BitmapImage; bitmapImage->SetPath(strBitmap); bitmapImage->EnableFileMonitor(false); bitmapImage->Init(); if(bFirst) { fullSize = bitmapImage->GetSize(); baseAspect = double(fullSize.x)/double(fullSize.y); bFirst = false; } bitmapImages << bitmapImage; } //------------------------------------ transitionTime = data->GetFloat(TEXT("transitionTime")); if(transitionTime < MIN_TRANSITION_TIME) transitionTime = MIN_TRANSITION_TIME; else if(transitionTime > MAX_TRANSITION_TIME) transitionTime = MAX_TRANSITION_TIME; //------------------------------------ bFadeInOnly = data->GetInt(TEXT("fadeInOnly"), 1) != 0; bDisableFading = data->GetInt(TEXT("disableFading")) != 0; bRandomize = data->GetInt(TEXT("randomize")) != 0; //------------------------------------ curTransitionTime = 0.0f; curTexture = 0; if(bRandomize) { srand( (unsigned)time( NULL ) ); if(bitmapImages.Num() > 1) { curTexture = lrand(bitmapImages.Num()); while((nextTexture = lrand(bitmapImages.Num())) == curTexture); } } else nextTexture = (curTexture == bitmapImages.Num()-1) ? 0 : curTexture+1; bTransitioning = false; curFadeValue = 0.0f; }
Point DockCamera::GetPreferredSize( bool bLargest ) const { return m_pcIcon->GetSize(); }
Vect2 GetSize() const {return bitmapImage.GetSize();}
/** \brief DragSelection callback. * Handles the results of a drag selection. */ void RemoteIconView::DragSelection( Point cStartPoint ) { /* Most of this is adapted from IconDirectoryView::DragSelection */ if( m_pcServer == NULL ) { DEBUG( "DragSelection with m_pcServer== NULL\n" ); return; } String zBase = m_pcServer->GetServerAddress(); Message cMsg( 1234 ); /* Message code isn't important */ /* Add all selected icons to the message, and find the icon under the mouse. */ int nCount = 0; int nLastSelected = -1; Point cIconPos = Point( 0,0 ); for( uint i = 0; i < GetIconCount(); i++ ) { if( GetIconSelected( i ) ) { RemoteIconData* pcData = (RemoteIconData*)GetIconData( i ); // DEBUG( " %s\n", pcData->m_cNode.m_zPath.c_str() ); cMsg.AddString( "remote-file/path", pcData->m_cNode.m_zPath ); cMsg.AddString( "server", zBase ); cMsg.AddBool( "is_dir", pcData->m_cNode.m_bIsDir ); if( Rect( GetIconPosition( i ), GetIconPosition( i ) + GetIconSize() ).DoIntersect( cStartPoint ) ) { cIconPos = GetIconPosition( i ); } nLastSelected = i; nCount++; } } if( nCount == 0 ) return; /* Create a drag&drop icon */ Bitmap cBitmap( (int)GetIconSize().x + 1, (int)GetIconSize().y + 1, CS_RGB32, Bitmap::ACCEPT_VIEWS | Bitmap::SHARE_FRAMEBUFFER ); View* pcView = new View( Rect( Point(0,0), GetIconSize() ), "temp" ); cBitmap.AddChild( pcView ); Image* pcIcon = NULL; String zLabel; if( nCount == 1 ) { /* Only one file selected; use its icon */ zLabel = GetIconString( nLastSelected, 0 ); pcIcon = GetIconImage( nLastSelected ); } else { /* Multiple files selected; use dir icon */ zLabel.Format( "%i items", nCount ); /* TODO: localise the string */ /* TODO: Fall back to resource if file isn't present */ File* pcFile = new File( "/system/icons/folder.png" ); BitmapImage* pcBitmapImage = new BitmapImage( pcFile ); Point cSize = (GetView() == VIEW_LIST || GetView() == VIEW_DETAILS ? Point( 24,24 ) : Point( 48,48 )); if( pcBitmapImage->GetSize() != cSize ) pcBitmapImage->SetSize( cSize ); pcIcon = pcBitmapImage; } if( pcIcon ) { RenderIcon( zLabel, pcIcon, pcView, Point(0,0) ); } cBitmap.Sync(); if( nCount != 1 ) delete( pcIcon ); BeginDrag( &cMsg, cStartPoint - cIconPos, &cBitmap ); }