void GraphicsLayer::addAnimationEntry(AnimatedPropertyID property, short index, bool isTransition, const Animation* transition) { int i = findAnimationEntry(property, index); if (i >= 0) m_animations[i].reset(transition, isTransition); else m_animations.append(AnimationEntry(transition, property, index, isTransition)); }
void FileSystemActor::setSizeAnim( Vec3 &startSize, Vec3 &lastSize, uint steps ) { sizeAnim.clear(); // Create a nice Bounce animation sizeAnim = bounceGrow(startSize, lastSize, steps); // Add to the animation manager if (isObjectType(ObjectType(BumpActor, FileSystem, StickyNote))) animManager->addAnimation(AnimationEntry(this, (FinishedCallBack) SyncStickyNoteAfterResize, NULL, true)); else animManager->addAnimation(AnimationEntry(this, NULL, NULL, true)); bool hasGridPileParent = getParent() && getParent()->isObjectType(ObjectType(BumpPile, NULL, Grid)); if (hasGridPileParent && isFileSystemType(Image)) { animManager->finishAnimation(this); // We need to add an animation to make sure the updatePileStateAfterAnim is called sizeAnim.push_back(lastSize); animManager->addAnimation(AnimationEntry(this, (FinishedCallBack) updatePileStateAfterAnim, NULL, true)); } }
void FileSystemActor::onLaunch() { assert(!filePath.isNull()); if (!_onLaunchHandler.empty()) _onLaunchHandler(this); // override for widgets Widget * w = widgetManager->getActiveWidgetForFile(getFullPath()); if (w && w->isWidgetOverrideActor(this)) { w->launchWidgetOverride(this); return; } // Do a quick pass to determine what needs to be created or not bool isWatchingHighlighted = cam->isWatchedActorHighlighted(this); bool zoomIntoImage = isFileSystemType(Image) && !isWatchingHighlighted && texMgr->isTextureState(thumbnailID, TextureLoaded); bool launchImage = (isFileSystemType(Image) && isWatchingHighlighted) && !texMgr->isTextureState(thumbnailID, TextureLoaded); bool createTemporaryActor = !zoomIntoImage && !launchImage; bool createRandomAnimPath = createTemporaryActor; Actor * obj = NULL; if (createTemporaryActor) { obj = new Actor(); Vec3 startPosition; // Set up the state of the Actor obj->pushActorType(Temporary); obj->setDims(getDims()); obj->setGravity(false); obj->setCollisions(false); obj->setAlphaAnim(getAlpha(), 0.2f, 40); obj->setGlobalPose(getGlobalPose()); obj->setObjectToMimic(this); } // Special case for launching a pileized actor Vec3 startPosition; if (isPileized()) { startPosition = pileizedPile->getGlobalPosition(); }else{ startPosition = getGlobalPosition(); } // create random animation path from the icon up to the camera eye if (createRandomAnimPath) { // Set an animation that moves the icon into the camera CreateRandomAnimPath(obj, startPosition, cam->getEye(), 40); // Delete the object after the random animation is over. animManager->removeAnimation(obj); animManager->addAnimation(AnimationEntry(obj, (FinishedCallBack) DeleteActorAfterAnim)); } // handle the launch override if there is one if (!getLaunchOverride().isEmpty()) { fsManager->launchFileAsync(getLaunchOverride()); return; } // Execute this Icon if (!isFileSystemType(Virtual)) { // If this is a folder, then try and browse to it if (scnManager->isShellExtension && isFileSystemType(Folder)) { // try and send a custom message to the proxy window to move to the child incrementNumTimesLaunched(); animManager->finishAnimation(this); SaveSceneToFile(); winOS->ShellExtBrowseToChild(filePath); return; } // This is an image, so zoom to it if we are not already watching it else if (zoomIntoImage && isFileSystemType(Image) && texMgr->isTextureState(thumbnailID, TextureLoaded)) { Key_EnableSlideShow(); this->putToSleep(); // record this zoom interaction statsManager->getStats().bt.interaction.actors.highlightedImage++; return; } // Execute it as normal // QString lnkTarget, lnkArgs, lnkWorkingDir; bool fileLaunched = false; /* if (isFileSystemType(Link)) { fsManager->getShortcutTarget(getFullPath(), &lnkTarget, &lnkArgs, &lnkWorkingDir); fileLaunched = fsManager->launchFileAsync(lnkTarget, lnkArgs, lnkWorkingDir); } else */ fileLaunched = fsManager->launchFileAsync(filePath); if (fileLaunched) { // otherwise, just increment this file launch count and execute it // it is decided that images do not auto-grow (was a design decision) if (!launchImage) { incrementNumTimesLaunched(); } // record this launch statsManager->getStats().bt.interaction.actors.launchedFile++; } } else { incrementNumTimesLaunched(); fsManager->launchFile(filePath); } }
vector<BumpObject *> FileSystemActor::onDrop(vector<BumpObject *> &objList) { QString fPath; FileSystemActor *fsData; Pile *pile; FileSystemPile *fsPile; Vec3 topPt; bool moveItem = true; bool operationSucceeded = false; vector<FileSystemActor *> failedObj, fsObjList; vector<BumpObject *> failedBumpObjs; vector<FileSystemActor *> hardPileOwners; if (!isSourceValid()) { return objList; } else { // Convert Piles to Free Items for (int i = 0; i < objList.size(); i++) { // Do Pile to free Item conversions if (objList[i]->getObjectType() == ObjectType(BumpPile, HardPile, Stack)) { // If its a Hard Pile, get its owner and use it instead of pile members fsPile = (FileSystemPile *) objList[i]; objList.erase(objList.begin() + i); objList.push_back(fsPile->getOwner()); hardPileOwners.push_back(fsPile->getOwner()); fsPile->folderize(false); i--; }else if (objList[i]->getObjectType() == ObjectType(BumpPile, SoftPile, Stack)) { pile = (Pile *) objList[i]; objList.erase(objList.begin() + i); i--; // If its a Soft Pile, use its members instead of the pile for (uint j = 0; j < pile->getNumItems(); j++) { objList.push_back((*pile)[j]); } } } if (isFileSystemType(Executable)) { for (uint i = 0; i < objList.size(); i++) { // Create a parameter list separated by spaces fsData = (FileSystemActor *) objList[i]; if (!fsData || !scnManager->containsObject(fsData)) continue; fPath.append(fsData->getFullPath()); fPath.append(" "); } // We just tossed into an executable // QString lnkTarget, dummyLnkArgs, lnkWorkingDir; QString lnkArgs = fPath; /* if (isFileSystemType(Link)) { fsManager->getShortcutTarget(getFullPath(), &lnkTarget, &dummyLnkArgs, &lnkWorkingDir); fsManager->launchFileAsync(lnkTarget, lnkArgs, lnkWorkingDir); } else */ fsManager->launchFileAsync(filePath, lnkArgs); }else if (isFileSystemType(Folder)) { bool itemNeedsPrompt = false; bool onlyPhotoFrame = true; int iconType = winOS->GetIconTypeFromFileName(getFullPath()); bool isRecycleBin = iconType == RecycleBin; bool isMyDocuments = iconType == MyDocuments; // Convert BumpObject to FileSystemActors, delete WebActors since they are not FileSystemActors for (uint i = 0; i < objList.size(); i++) { if (objList[i]->isObjectType(ObjectType(BumpActor, Webpage))) { if (isRecycleBin) { sel->remove(objList[i]); objList[i]->markDragCancelled(true); objList[i]->onDragEnd(); FadeAndDeleteActor((Actor *)objList[i]); objList.erase(objList.begin() + i); } else _ASSERT(0); } else { fsObjList.push_back((FileSystemActor *) objList[i]); if (fsObjList[i]->getObjectType() == ObjectType(BumpActor, FileSystem, PhotoFrame)) itemNeedsPrompt = true; else onlyPhotoFrame = false; } } if (isFileSystemType(Virtual)) { // Handle tossing into the recycle bin if (isRecycleBin || isMyDocuments) { if (itemNeedsPrompt) { dlgManager->clearState(); dlgManager->setPrompt(QT_TR_NOOP("A Photo Frame was detected in the selection, would you like to delete it?")); dlgManager->setCaption(QT_NT("BumpTop")); if (dlgManager->promptDialog(DialogYesNo)) { vector<FileSystemActor *>::iterator iter = fsObjList.begin(); while (iter != fsObjList.end()) { FileSystemActor * fsActor = *iter; if (fsActor->getObjectType() == ObjectType(BumpActor, FileSystem, PhotoFrame)) { // Remove the photo frame by deferring deletion until after the anim is over fsActor->fadeOut(); animManager->removeAnimation(fsActor); animManager->addAnimation(AnimationEntry(fsActor, (FinishedCallBack) DeleteActorAfterAnim, NULL, true)); iter = fsObjList.erase(iter); } else iter++; } } else { vector<FileSystemActor *>::iterator iter = fsObjList.begin(); while (iter != fsObjList.end()) { FileSystemActor * fsActor = *iter; if (fsActor->getObjectType() == ObjectType(BumpActor, FileSystem, PhotoFrame)) { failedObj.push_back(fsActor); iter = fsObjList.erase(iter); } else iter++; } } } if (!fsObjList.empty()) { if (isRecycleBin) operationSucceeded = fsManager->deleteFiles(fsObjList, failedObj, !onlyPhotoFrame); else operationSucceeded = fsManager->moveFiles(fsObjList, winOS->GetSystemPath(iconType), failedObj, true); } } }else{ if (!isCopyIntoActor(objList)) // Shift forces move, Ctrl forces copy, common root defaults to move { // Handle tossing into a regular folder operationSucceeded = fsManager->moveFiles(fsObjList, getTargetPath(), failedObj, true); if (operationSucceeded) { printUnique("FileSystemActor::onDrop", QT_TR_NOOP("%1 file(s) moved to %2").arg(fsObjList.size()).arg(getText())); } } else { // Handle tossing into a regular folder on another resource (will copy instead of move) operationSucceeded = fsManager->copyFiles(fsObjList, getTargetPath(), failedObj, true); if (operationSucceeded) { printUnique("FileSystemActor::onDrop", QT_TR_NOOP("%1 file(s) copied to %2").arg(fsObjList.size()).arg(getText())); } // Animate back to the original starting pose animateObjectsBackToPreDropPose(objList); } } } if (!operationSucceeded) { // re-pileize hard piles if move failed vector<FileSystemActor *>::iterator iter = hardPileOwners.begin(); while (iter != hardPileOwners.end()) { (*iter)->pileize(); iter++; } } // record this drop statsManager->getStats().bt.interaction.dragAndDrop.toActor++; } // Convert from a list of FileSYstemActors to BumpObjects for (uint i = 0; i < failedObj.size(); i++) { failedBumpObjs.push_back(failedObj[i]); } return failedBumpObjs; }
void FileSystemActor::setFilePath(QString fullPath, bool skipTextureResolution /*=false*/) { if (_isAnimatedTexture) _animatedTextureSource.setPath(fullPath); // Save the Path (or Virtual Folder Name) filePath = fullPath; winOS->GetShortPathName(fullPath, shortPath); if (skipTextureResolution) return; // resolve the texture to load for this file if there is one QString ext = fsManager->getFileExtension(fullPath); QString texId; GLTextureDetail detail = FileIcon; GLTextureLoadPriority priority = NormalPriority; bool isVista = winOS->IsWindowsVersionGreaterThanOrEqualTo(WindowsVista); bool overrideSystemTextures = GLOBAL(settings).useThemeIconOverrides; int virtualIconId = winOS->GetIconTypeFromFileName(fullPath); if (virtualIconId > -1) { // mark this is a virtual icon pushFileSystemType(Virtual); pushFileSystemType(Folder); // check if we are overloading any virtual icons (only My Computer for now) if (overrideSystemTextures && (virtualIconId == MyComputer) && texMgr->hasTexture("override.virtual.mycomputer")) { texId = QT_NT("override.virtual.mycomputer"); detail = HiResImage; } else { // otherwise, we will just load the icon later texId = fullPath; // NOTE: we force load these icons here because we do not do so if the // texture id is set below loadThumbnailTexture(GLTextureObject(Load, texId, texId, FileIcon, priority, false)); } } else { // not a virtual icon, just a random icon then unsigned int fileAttributes = fsManager->getFileAttributes(fullPath); // delete this object if it doesn't exist (and it's not a photo frame or volume) if (!fileAttributes && !(isFileSystemType(PhotoFrame) || isFileSystemType(LogicalVolume))) { animManager->addAnimation(AnimationEntry(this, (FinishedCallBack) DeleteActorAfterAnim)); setAlpha(0.0f); return; } // make sure there's no lingering animations animManager->removeAnimation(this); setAlpha(1.0f); // XXX: check if we are using animated textures // _isAnimatedTexture = (fileExtension == ".gif"); // check if this is a shortcut // NOTE: if it is a valid shortcut, the file attributes and extension // now refer to the target and not the shortcut itself if (fileAttributes && ext == ".lnk") { // resolve the shortcut target fsManager->getShortcutTarget(fullPath, &lnkFullPath); if (fsManager->isValidFileName(lnkFullPath)) { pushFileSystemType(Link); popFileSystemType(DeadLink); fileAttributes = fsManager->getFileAttributes(lnkFullPath); ext = fsManager->getFileExtension(lnkFullPath); } else { pushFileSystemType(DeadLink); } } // check if it is a folder if (fileAttributes & Directory) { pushFileSystemType(Folder); // XXX: only override shortcuts, and not folders? /* if (!overrideSystemTextures || !enableFileTypeIconsForShortcuts) { texId = winOS->GetSystemIconInfo(getFullPath()); } else */ if (overrideSystemTextures) { texId = QT_NT("override.ext.folder"); detail = HiResImage; } } else { // normal file pushFileSystemType(File); hasExtension(true); //only files have extension, so the nameable extension hide only applies here // resolve some information about the file if (ext.size() > 0) { if (ext == ".exe") pushFileSystemType(Executable); else { // XXX: check if it's a document // pushFileSystemType(Document); if (overrideSystemTextures) { QString potentialOverrideTex = QString(QT_NT("override.ext")) + ext; if (texMgr->hasTexture(potentialOverrideTex)) { texId = potentialOverrideTex; detail = HiResImage; } } } // load the thumbnail if this is an image // NOTE: we append the period because if the extension is empty // the search is always true if (GLOBAL(supportedExtensions).contains(ext + ".")) { if (!isThumbnailized()) enableThumbnail(true, !winOS->IsFileInUse(fullPath)); pushFileSystemType(Image); pushFileSystemType(Thumbnail); hideText(true); } } } } // at this point, resolve the file icon texture id if there was no override if (texId.isEmpty()) { texId = winOS->GetSystemIconInfo(fullPath); // mark the texture for loading loadThumbnailTexture(GLTextureObject(Load, texId, texId, detail, priority,false)); } setTextureID(texId); // we also want to try and load thumbnails for normal files if they exist // (as long as it's not a widget file) Widget * w = widgetManager->getActiveWidgetForFile(fullPath); if (!isThumbnailized() && (detail == FileIcon) && !w) { FileSystemActorType typesToIgnore = FileSystemActorType(Executable | Virtual); // on vista, just queue the thumbnail for loading if (isVista && !isFileSystemType(typesToIgnore)) { QString ext = fsManager->getFileExtension(getTargetPath()); loadThumbnailTexture(GLTextureObject(Load|Reload, _alternateThumbnailId, getTargetPath(), SampledImage, IdlePriority)); } // on windows xp, check if the thumbs db has a record first else if (winOS->IsWindowsVersion(WindowsXP)) { if (texMgr->hasWinThumbnail(getTargetPath())) { loadThumbnailTexture(GLTextureObject(Load|Reload, _alternateThumbnailId, getTargetPath(), SampledImage, IdlePriority)); } } } // XXX: (disabled) set the initial dimensions and weight of this file based on it's size // setDimsFromFileSize(this); // set the text if(!isFileSystemType(PhotoFrame)) { if (w && w->isWidgetOverrideActor(this)) { setText(w->getWidgetOverrideLabel(this)); Vec3 actorDims = getDims(); float aspect = (actorDims.x / actorDims.y); Vec3 dims(GLOBAL(settings).xDist, GLOBAL(settings).zDist / aspect, GLOBAL(settings).yDist); float scale = w->getWidgetOverrideScale(this); if (scale > 0.0f) { dims *= scale; setSizeAnim(getDims(), dims, 25); } } else setText(getFileName(isFileSystemType(Link) || isFileSystemType(DeadLink))); } setRespectIconExtensionVisibility(!isFileSystemType(Folder)); // New name was set, invalidate text textManager->invalidate(); rndrManager->invalidateRenderer(); }