Beispiel #1
0
/** \brief MouseUp Callback.
 * This handles the situation where someone does a drag and drop of an item.
 * In this case we should copy it to the desired location.
 *
 * \todo Implement recursive transfer when a folder is dropped.
 */
void RemoteIconView::MouseUp( const Point& cPoint, uint32 nButtons, Message* pcData )
{
	if( pcData == NULL || m_pcServer == NULL ) {
		/* No drag & drop, or no connection */
		IconView::MouseUp( cPoint, nButtons, pcData );
		return;
	}
	StopScroll();
	
	/* We got a drag & drop. Check if it contains a local file */
	int nCount, nType;
	pcData->GetNameInfo( "file/path", &nType, &nCount );
	if( nType != T_STRING || nCount == 0 ) {
		/* Something was dropped that isn't a file. Ignore it */
		IconView::MouseUp( cPoint, nButtons, pcData );
		return;
	}
	
	/* Check if there is a directory icon under the mouse. If so, we transfer the file into that directory.
	   Otherwise, we transfer it into this directory. */
	String zDestPath = m_zPath;
	for( uint i = 0; i < GetIconCount(); i++ ) {
		if( Rect( GetIconPosition( i ), GetIconPosition( i ) + GetIconSize() ).DoIntersect( ConvertToView( cPoint ) ) ) {
			/* Found an icon under the mouse */
			RemoteIconData* pcData = (RemoteIconData*)GetIconData( i );
			if( pcData->m_cNode.IsDir() ) {
				/* Found a dir under the mouse. Add it to the destination path */
				zDestPath += "/";
				zDestPath += pcData->m_cNode.m_zName;
				break;
			}
		}
	}
	
	/* Start transferring the files */
	String zSource;
	String zDest;
	for( int i = 0; pcData->FindString( "file/path", &zSource, i ) == 0; i++ )
	{
		Path cPath( zSource );
		zDest = zDestPath;
		if( zDest.Length() > 0 && zDest[zDest.Length()-1] != '/' ) zDest += "/";
		zDest += cPath.GetLeaf();
		DEBUG( "GUI: Drag & drop %s to %s\n", zSource.c_str(), zDest.c_str() );
		
		/* Ask the Server object to start the transfer */
		/* Need to determine if it is a file or a dir first though */
		FileReference cFileRef( zSource );
		struct stat sStat;
		cFileRef.GetStat( &sStat );
		if( S_ISDIR( sStat.st_mode ) ) {
			m_pcServer->SendLocalDir( zSource, zDest );
		} else {
			m_pcServer->SendLocalFile( zSource, zDest );
		}
	}
}
Beispiel #2
0
LPARAM TileGroup::ItemLoaded(UINT64 id, LoadItemResponse *item) {
  int iconPosition = GetIconPosition(item->id);
  RECT pos = mLayoutSettings.RectFromID(iconPosition, mTileWidth, mTileHeight, int(mWindow->GetSize().width + 0.5f), int(mWindow->GetSize().height + 0.5f));
  Tile *icon = new Tile(this, item->id, mWorkingFolder, mTileWidth, mTileHeight, mTileSettings, item->thumbnail);
  icon->SetPosition(iconPosition, (int)pos.left, (int)pos.top);
  mTiles.push_back(icon);

  return 0;
}
Beispiel #3
0
void CPWL_Icon::GetImageOffset(FX_FLOAT& x, FX_FLOAT& y) {
  FX_FLOAT fLeft, fBottom;

  GetIconPosition(fLeft, fBottom);
  x = 0.0f;
  y = 0.0f;

  FX_FLOAT fImageWidth, fImageHeight;
  GetImageSize(fImageWidth, fImageHeight);

  FX_FLOAT fHScale, fVScale;
  GetScale(fHScale, fVScale);

  FX_FLOAT fImageFactWidth = fImageWidth * fHScale;
  FX_FLOAT fImageFactHeight = fImageHeight * fVScale;

  FX_FLOAT fPlateWidth, fPlateHeight;
  CFX_FloatRect rcPlate = GetClientRect();
  fPlateWidth = rcPlate.right - rcPlate.left;
  fPlateHeight = rcPlate.top - rcPlate.bottom;

  x = (fPlateWidth - fImageFactWidth) * fLeft;
  y = (fPlateHeight - fImageFactHeight) * fBottom;
}
Beispiel #4
0
/** \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 );
}