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

Modify SlideViewController to use external pads.

git-svn-id: http://root.cern.ch/svn/root/trunk@41569 27541ba8-7e3a-0410-8455-c3a389f83636
parent 92d45844
No related branches found
No related tags found
No related merge requests found
......@@ -15,6 +15,7 @@ class Pad;
+ (CGSize) slideSize;
+ (CGRect) slideFrame;
- (id) initWithFrame : (CGRect)rect andPad : (ROOT::iOS::Pad *)pad;
- (id) initWithFrame : (CGRect)rect;
- (void) setPad : (ROOT::iOS::Pad *)pad;
@end
......@@ -23,13 +23,11 @@ static const CGRect slideFrame = CGRectMake(0.f, 0.f, 650.f, 650.f);
}
//____________________________________________________________________________________________________
- (id) initWithFrame : (CGRect)frame andPad : (ROOT::iOS::Pad *)p
- (id) initWithFrame : (CGRect)frame
{
self = [super initWithFrame : frame];
if (self) {
pad = p;
self.layer.shadowOpacity = 0.3f;
self.layer.shadowColor = [UIColor blackColor].CGColor;
self.layer.shadowOffset = CGSizeMake(10.f, 10.f);
......@@ -39,6 +37,11 @@ static const CGRect slideFrame = CGRectMake(0.f, 0.f, 650.f, 650.f);
return self;
}
- (void) setPad : (ROOT::iOS::Pad *)newPad
{
pad = newPad;
}
//____________________________________________________________________________________________________
- (void) drawRect : (CGRect)rect
{
......@@ -47,6 +50,9 @@ static const CGRect slideFrame = CGRectMake(0.f, 0.f, 650.f, 650.f);
CGContextSetRGBFillColor(ctx, 1.f, 1.f, 1.f, 1.f);
CGContextFillRect(ctx, rect);
if (!pad)
return;
CGContextTranslateCTM(ctx, 0.f, rect.size.height);
CGContextScaleCTM(ctx, 1.f, -1.f);
......
......@@ -13,7 +13,6 @@ class Pad;
@interface SlideshowController : UIViewController <UIScrollViewDelegate> {
@private
ROOT::iOS::Pad *pads[2];
SlideView *padViews[2];//The current and the next in a slide show.
unsigned visiblePad;
......
......@@ -47,29 +47,21 @@
nObjects = 2;
for (unsigned i = 0; i < nObjects; ++i) {
pads[i] = new ROOT::iOS::Pad(padFrame.size.width, padFrame.size.height);
padViews[i] = [[SlideView alloc] initWithFrame : padFrame andPad : pads[i]];
padViews[i] = [[SlideView alloc] initWithFrame : padFrame];
[padParentView addSubview : padViews[i]];
padViews[i].hidden = YES;
[padViews[i] release];
}
}
//____________________________________________________________________________________________________
- (void) drawObject : (TObject *)obj inAPad : (ROOT::iOS::Pad *)pad option : (const char *)opt
{
pad->cd();
pad->Clear();
obj->Draw(opt);
}
//____________________________________________________________________________________________________
- (id)initWithNibName : (NSString *)nibNameOrNil bundle : (NSBundle *)nibBundleOrNil fileContainer : (ROOT::iOS::FileContainer *)container
{
self = [super initWithNibName : nibNameOrNil bundle : nibBundleOrNil];
[self view];
if (self) {
[self view];
fileContainer = container;
if (fileContainer->GetNumberOfObjects()) {
......@@ -78,11 +70,11 @@
nCurrentObject = 0;
visiblePad = 0;
[self drawObject : fileContainer->GetObject(0) inAPad : pads[0] option:fileContainer->GetDrawOption(0)];
[padViews[0] setPad : fileContainer->GetPadAttached(0)];
[padViews[0] setNeedsDisplay];
if (fileContainer->GetNumberOfObjects() > 1) {
[self drawObject : fileContainer->GetObject(1) inAPad : pads[1] option:fileContainer->GetDrawOption(1)];
[padViews[1] setPad:fileContainer->GetPadAttached(1)];
[padParentView addSubview : padViews[1]];
}
......@@ -94,14 +86,8 @@
}
//____________________________________________________________________________________________________
- (void)dealloc
- (void) dealloc
{
for (unsigned i = 0; i < 2; ++i) {
//Delete for null and message to nil means nothing.
delete pads[i];
[padViews[i] release];
}
if (timer)
[timer invalidate];
......@@ -147,7 +133,8 @@
//____________________________________________________________________________________________________
- (void) viewDidAppear : (BOOL)animated
{
timer = [NSTimer scheduledTimerWithTimeInterval : 2.f target : self selector : @selector(changeViews) userInfo : nil repeats : YES];
if (fileContainer->GetNumberOfObjects() > 1)
timer = [NSTimer scheduledTimerWithTimeInterval : 2.f target : self selector : @selector(changeViews) userInfo : nil repeats : YES];
}
......@@ -174,6 +161,7 @@
}
#pragma mark - Animation.
//____________________________________________________________________________________________________
- (void) changeViews
{
......@@ -197,7 +185,7 @@
nCurrentObject + 1 == fileContainer->GetNumberOfObjects() ? nCurrentObject = 0 : ++nCurrentObject;
visiblePad = viewToShow;
const unsigned next = nCurrentObject + 1 == fileContainer->GetNumberOfObjects() ? 0 : nCurrentObject + 1;
[self drawObject : fileContainer->GetObject(next) inAPad : pads[viewToHide] option : fileContainer->GetDrawOption(next)];
[padViews[viewToHide] setPad : fileContainer->GetPadAttached(next)];
[padViews[viewToHide] setNeedsDisplay];
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment