Skip to content
Snippets Groups Projects
Commit 6104dd52 authored by Timur Pocheptsov's avatar Timur Pocheptsov
Browse files

After object or directory was found, do animation:

scroll to required shortcut, animate shortcut (to make it clear, what was found)


git-svn-id: http://root.cern.ch/svn/root/trunk@42020 27541ba8-7e3a-0410-8455-c3a389f83636
parent 0923dbf3
No related branches found
No related tags found
No related merge requests found
#import <stdlib.h> #import <stdlib.h>
#import <CoreGraphics/CGGeometry.h>
#import <QuartzCore/QuartzCore.h> #import <QuartzCore/QuartzCore.h>
#import "FileContentController.h" #import "FileContentController.h"
...@@ -17,15 +18,26 @@ ...@@ -17,15 +18,26 @@
#import "FileUtils.h" #import "FileUtils.h"
@interface FileContentController () {
@implementation FileContentController {
NSMutableArray *objectShortcuts; NSMutableArray *objectShortcuts;
UISearchBar *searchBar; UISearchBar *searchBar;
UIPopoverController *searchPopover; UIPopoverController *searchPopover;
SearchController *searchController; SearchController *searchController;
UIBarButtonItem *slideShowBtn; UIBarButtonItem *slideShowBtn;
BOOL animateDirAfterLoad;
BOOL animateObjAfterLoad;
unsigned spotElement;
} }
- (void) highlightDirectory : (unsigned)tag;
- (void) highlightObject : (unsigned)tag;
@end
@implementation FileContentController
@synthesize fileContainer; @synthesize fileContainer;
...@@ -121,6 +133,19 @@ ...@@ -121,6 +133,19 @@
// Do any additional setup after loading the view from its nib. // Do any additional setup after loading the view from its nib.
} }
//____________________________________________________________________________________________________
- (void) viewDidAppear:(BOOL)animated
{
[super viewDidAppear : animated];
if (animateDirAfterLoad) {
[self highlightDirectory : spotElement];
animateDirAfterLoad = NO;
} else if (animateObjAfterLoad) {
[self highlightObject : spotElement];
animateObjAfterLoad = NO;
}
}
//____________________________________________________________________________________________________ //____________________________________________________________________________________________________
- (void) viewDidUnload - (void) viewDidUnload
{ {
...@@ -291,9 +316,9 @@ ...@@ -291,9 +316,9 @@
NSMutableArray *keys = [[NSMutableArray alloc] init]; NSMutableArray *keys = [[NSMutableArray alloc] init];
for (size_type i = 0; i < nEntities; ++i) { for (size_type i = 0; i < nEntities; ++i) {
const auto &descriptor = fileContainer->GetElementDescriptor(i); const auto &descriptor = fileContainer->GetElementDescriptor(i);
NSString *formatString = descriptor.fIsDir ? @"%s (directory) %d" : @"%s %d"; NSString *formatString = descriptor.fIsDir ? @"%s (directory)" : @"%s";
FileContainerElement *newKey = [[FileContainerElement alloc] init]; FileContainerElement *newKey = [[FileContainerElement alloc] init];
newKey.elementName = [NSString stringWithFormat : formatString, descriptor.fName.c_str(), i]; newKey.elementName = [NSString stringWithFormat : formatString, descriptor.fName.c_str()];
newKey.elementIndex = i; newKey.elementIndex = i;
[keys addObject : newKey]; [keys addObject : newKey];
} }
...@@ -352,14 +377,90 @@ ...@@ -352,14 +377,90 @@
const auto &descriptor = fileContainer->GetElementDescriptor(key.elementIndex); const auto &descriptor = fileContainer->GetElementDescriptor(key.elementIndex);
if (descriptor.fOwner == fileContainer) { if (descriptor.fOwner == fileContainer) {
NSLog(@"Nothing to load, highlihgt object found!"); descriptor.fIsDir ? [self highlightDirectory : descriptor.fIndex] : [self highlightObject : descriptor.fIndex];
//
} else { } else {
//Create another FileContentController and push it on stack. //Create another FileContentController and push it on stack.
FileContentController *contentController = [[FileContentController alloc] initWithNibName : @"FileContentController" bundle : nil]; FileContentController *contentController = [[FileContentController alloc] initWithNibName : @"FileContentController" bundle : nil];
[contentController activateForFile : descriptor.fOwner]; [contentController activateForFile : descriptor.fOwner];
if (descriptor.fIsDir)
contentController->animateDirAfterLoad = YES;
else
contentController->animateObjAfterLoad = YES;
contentController->spotElement = descriptor.fIndex;
[self.navigationController pushViewController : contentController animated : YES]; [self.navigationController pushViewController : contentController animated : YES];
} }
} }
#pragma mark - adjust file container to show search result
//____________________________________________________________________________________________________
- (void) animateShortcut : (ObjectShortcut *) sh
{
//Now, animation!
CGAffineTransform originalTransform = sh.transform;
CGAffineTransform newTransform = CGAffineTransformScale(originalTransform, 1.4f, 1.4f);
[UIView beginAnimations : @"hide_object" context : nil];
[UIView setAnimationDuration : 1.5f];
[UIView setAnimationCurve : UIViewAnimationCurveLinear];
[UIView setAnimationTransition : UIViewAnimationTransitionNone forView : sh cache : YES];
sh.transform = newTransform;
[UIView commitAnimations];
[UIView beginAnimations : @"show_object" context : nil];
[UIView setAnimationDuration : 1.f];
[UIView setAnimationCurve : UIViewAnimationCurveLinear];
[UIView setAnimationTransition : UIViewAnimationTransitionNone forView : sh cache : YES];
sh.transform = originalTransform;
[UIView commitAnimations];
}
//____________________________________________________________________________________________________
- (void) highlightDirectory : (unsigned)tag
{
for (ObjectShortcut *sh in objectShortcuts) {
if (sh.objectIndex == tag && sh.isDirectory) {
const CGRect thumbFrame = sh.frame;
const CGRect scrollBounds = scrollView.bounds;
if (CGRectGetMaxY(thumbFrame) > CGRectGetMaxY(scrollBounds)) {
//We have to scroll view to show object's or directory's shortcut.
//Find new Y for bounds.
const CGFloat newY = CGRectGetMaxY(thumbFrame) - scrollBounds.size.height;
CGRect newBounds = scrollBounds;
newBounds.origin.y = newY;
[scrollView scrollRectToVisible : newBounds animated : YES];
}
[self animateShortcut : sh];
break;
}
}
}
//____________________________________________________________________________________________________
- (void) highlightObject : (unsigned)tag
{
for (ObjectShortcut *sh in objectShortcuts) {
if (sh.objectIndex == tag && !sh.isDirectory) {
CGRect thumbFrame = sh.frame;
const CGRect scrollBounds = scrollView.bounds;
if (CGRectGetMaxY(thumbFrame) > CGRectGetMaxY(scrollBounds)) {
//We have to scroll view to show object's or directory's shortcut.
//Find new Y for bounds.
const CGFloat newY = CGRectGetMaxY(thumbFrame) - scrollBounds.size.height;
CGRect newBounds = scrollBounds;
newBounds.origin.y = newY;
[scrollView scrollRectToVisible : newBounds animated : YES];
}
[self animateShortcut : sh];
break;
}
}
}
@end @end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment