added animation of "my position" button, when updating to first "fresh" position.

This commit is contained in:
rachytski 2011-04-03 22:17:50 +03:00 committed by Alex Zolotarev
parent 9e0a1b1204
commit 1204021c32
13 changed files with 99 additions and 14 deletions

View file

@ -23,6 +23,7 @@
bool m_isDirtyPosition;
bool m_isSticking;
size_t m_StickyThreshold;
int m_iconSequenceNumber;
m2::PointD m_Pt1, m_Pt2;
@ -31,10 +32,11 @@
- (id) initWithCoder: (NSCoder *)coder;
- (void) OnUpdateLocation: (m2::PointD const &) mercatorPoint
withErrorRadius: (double) errorRadius
withLocTimeStamp: (double) locTimeStamp
withCurTimeStamp: (double) curTimeStamp;
- (void) UpdateIcon: (NSTimer *)theTimer;
- (void) OnUpdateLocation: (m2::PointD const &) mercatorPoint
withErrorRadius: (double) errorRadius
withLocTimeStamp: (double) locTimeStamp
withCurTimeStamp: (double) curTimeStamp;
- (void) OnChangeLocatorMode: (Locator::EMode) oldMode
withNewMode: (Locator::EMode) newMode;
@ -54,5 +56,6 @@
- (IBAction)OnGuideClicked:(id)sender;
@property (nonatomic, retain) IBOutlet UIBarButtonItem * m_myPositionButton;
@property (nonatomic, retain) NSTimer * m_iconTimer;
@end

View file

@ -18,14 +18,36 @@ typedef FrameWork<model::FeaturesFetcher, Navigator> framework_t;
@implementation MapViewController
@synthesize m_myPositionButton;
@synthesize m_iconTimer;
// Make m_framework and m_storage MapsAppDelegate properties instead of global variables.
framework_t * m_framework = NULL;
shared_ptr<Locator> m_locator;
storage::Storage m_storage;
- (IBAction)OnMyPositionClicked:(id)sender
- (void)UpdateIcon:(NSTimer *)theTimer
{
MapViewController * controller = (MapViewController*)self;
controller->m_iconSequenceNumber = (controller->m_iconSequenceNumber + 1) % 8;
int iconNum = controller->m_iconSequenceNumber;
if (iconNum > 4)
iconNum = 8 - iconNum;
NSString * iconName = [[NSString alloc] initWithFormat:@"location-%d.png", iconNum];
UIImage * image = [UIImage imageNamed:iconName];
self.m_myPositionButton.image = image;
// [image release];
[iconName release];
}
- (IBAction)OnMyPositionClicked:(id)sender
{
MapViewController * controller = (MapViewController*)self;
if (m_locator->mode() == Locator::EPreciseMode)
{
m_locator->setMode(Locator::ERoughMode);
@ -37,12 +59,13 @@ typedef FrameWork<model::FeaturesFetcher, Navigator> framework_t;
m_isDirtyPosition = true;
((UIBarButtonItem *)sender).style = UIBarButtonItemStyleDone;
/// TODO : change button icon to progress indicator
//UIActivityIndicatorView * indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle: UIActivityIndicatorViewStyleGray];
//((UIBarButtonItem *)sender).customView = indicator;
//[indicator release];
controller->m_iconSequenceNumber = 0;
self.m_iconTimer = [NSTimer scheduledTimerWithTimeInterval:0.1f
target:self
selector:@selector(UpdateIcon:)
userInfo:nil
repeats:YES];
}
}
@ -51,8 +74,18 @@ typedef FrameWork<model::FeaturesFetcher, Navigator> framework_t;
{
if (newMode == Locator::ERoughMode)
{
/// TODO : change button icon to "rough mode"(UIBarButtonItemStyleBordered);
if (self.m_iconTimer != nil)
{
[self.m_iconTimer invalidate];
self.m_iconTimer = nil;
}
UIImage * image = [UIImage imageNamed:@"location-0.png"];
m_myPositionButton.image = image;
m_myPositionButton.style = UIBarButtonItemStyleBordered;
// [image release];
}
}
@ -63,8 +96,17 @@ typedef FrameWork<model::FeaturesFetcher, Navigator> framework_t;
{
if (m_isDirtyPosition)
{
/// TODO : change button icon to "precise" mode(UIBarButtonItemStyleDone).
if (self.m_iconTimer != nil)
{
[self.m_iconTimer invalidate];
self.m_iconTimer = nil;
}
UIImage * image = [UIImage imageNamed:@"location-0.png"];
m_myPositionButton.image = image;
m_myPositionButton.style = UIBarButtonItemStyleDone;
// [image release];
}
}
@ -111,7 +153,7 @@ typedef FrameWork<model::FeaturesFetcher, Navigator> framework_t;
shared_ptr<yg::ResourceManager> resourceManager = [(EAGLView*)self.view resourceManager];
m_locator = shared_ptr<Locator>(new iphone::Locator());
// tricky boost::bind for objC class methods
typedef void (*TUpdateLocationFunc)(id, SEL, m2::PointD const &, double, double, double);
SEL updateLocationSel = @selector(OnUpdateLocation:withErrorRadius:withLocTimeStamp:withCurTimeStamp:);

View file

@ -40,6 +40,16 @@
EE12020F11CD464100ABDD5D /* libindexer.a in Frameworks */ = {isa = PBXBuildFile; fileRef = EE12020511CD464100ABDD5D /* libindexer.a */; };
EE12021011CD464100ABDD5D /* libmap.a in Frameworks */ = {isa = PBXBuildFile; fileRef = EE12020611CD464100ABDD5D /* libmap.a */; };
EE12021211CD464100ABDD5D /* libyg.a in Frameworks */ = {isa = PBXBuildFile; fileRef = EE12020811CD464100ABDD5D /* libyg.a */; };
EE180DD21348EDED007F727D /* location-0.png in Resources */ = {isa = PBXBuildFile; fileRef = EE180DC81348EDED007F727D /* location-0.png */; };
EE180DD31348EDED007F727D /* location-0@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = EE180DC91348EDED007F727D /* location-0@2x.png */; };
EE180DD41348EDED007F727D /* location-1.png in Resources */ = {isa = PBXBuildFile; fileRef = EE180DCA1348EDED007F727D /* location-1.png */; };
EE180DD51348EDED007F727D /* location-1@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = EE180DCB1348EDED007F727D /* location-1@2x.png */; };
EE180DD61348EDED007F727D /* location-2.png in Resources */ = {isa = PBXBuildFile; fileRef = EE180DCC1348EDED007F727D /* location-2.png */; };
EE180DD71348EDED007F727D /* location-2@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = EE180DCD1348EDED007F727D /* location-2@2x.png */; };
EE180DD81348EDED007F727D /* location-3.png in Resources */ = {isa = PBXBuildFile; fileRef = EE180DCE1348EDED007F727D /* location-3.png */; };
EE180DD91348EDED007F727D /* location-3@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = EE180DCF1348EDED007F727D /* location-3@2x.png */; };
EE180DDA1348EDED007F727D /* location-4.png in Resources */ = {isa = PBXBuildFile; fileRef = EE180DD01348EDED007F727D /* location-4.png */; };
EE180DDB1348EDED007F727D /* location-4@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = EE180DD11348EDED007F727D /* location-4@2x.png */; };
EE583CBB12F773F00042CBE3 /* unicode_blocks.txt in Resources */ = {isa = PBXBuildFile; fileRef = EE583CBA12F773F00042CBE3 /* unicode_blocks.txt */; };
EE7F29811219ECA300EB67A9 /* RenderBuffer.mm in Sources */ = {isa = PBXBuildFile; fileRef = EE7F297D1219ECA300EB67A9 /* RenderBuffer.mm */; };
EE7F29821219ECA300EB67A9 /* RenderContext.mm in Sources */ = {isa = PBXBuildFile; fileRef = EE7F297E1219ECA300EB67A9 /* RenderContext.mm */; };
@ -147,6 +157,16 @@
EE12020611CD464100ABDD5D /* libmap.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libmap.a; sourceTree = SOURCE_ROOT; };
EE12020811CD464100ABDD5D /* libyg.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; path = libyg.a; sourceTree = SOURCE_ROOT; };
EE16192B126E374500622BD0 /* RenderContext.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; lineEnding = 0; name = RenderContext.hpp; path = Classes/RenderContext.hpp; sourceTree = SOURCE_ROOT; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
EE180DC81348EDED007F727D /* location-0.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "location-0.png"; sourceTree = "<group>"; };
EE180DC91348EDED007F727D /* location-0@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "location-0@2x.png"; sourceTree = "<group>"; };
EE180DCA1348EDED007F727D /* location-1.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "location-1.png"; sourceTree = "<group>"; };
EE180DCB1348EDED007F727D /* location-1@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "location-1@2x.png"; sourceTree = "<group>"; };
EE180DCC1348EDED007F727D /* location-2.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "location-2.png"; sourceTree = "<group>"; };
EE180DCD1348EDED007F727D /* location-2@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "location-2@2x.png"; sourceTree = "<group>"; };
EE180DCE1348EDED007F727D /* location-3.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "location-3.png"; sourceTree = "<group>"; };
EE180DCF1348EDED007F727D /* location-3@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "location-3@2x.png"; sourceTree = "<group>"; };
EE180DD01348EDED007F727D /* location-4.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "location-4.png"; sourceTree = "<group>"; };
EE180DD11348EDED007F727D /* location-4@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "location-4@2x.png"; sourceTree = "<group>"; };
EE583CBA12F773F00042CBE3 /* unicode_blocks.txt */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = unicode_blocks.txt; path = ../../data/unicode_blocks.txt; sourceTree = "<group>"; };
EE7F297C1219ECA300EB67A9 /* RenderBuffer.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; lineEnding = 0; name = RenderBuffer.hpp; path = Classes/RenderBuffer.hpp; sourceTree = SOURCE_ROOT; xcLanguageSpecificationIdentifier = xcode.lang.cpp; };
EE7F297D1219ECA300EB67A9 /* RenderBuffer.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; lineEnding = 0; name = RenderBuffer.mm; path = Classes/RenderBuffer.mm; sourceTree = SOURCE_ROOT; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
@ -309,6 +329,16 @@
29B97317FDCFA39411CA2CEA /* Resources */ = {
isa = PBXGroup;
children = (
EE180DC81348EDED007F727D /* location-0.png */,
EE180DC91348EDED007F727D /* location-0@2x.png */,
EE180DCA1348EDED007F727D /* location-1.png */,
EE180DCB1348EDED007F727D /* location-1@2x.png */,
EE180DCC1348EDED007F727D /* location-2.png */,
EE180DCD1348EDED007F727D /* location-2@2x.png */,
EE180DCE1348EDED007F727D /* location-3.png */,
EE180DCF1348EDED007F727D /* location-3@2x.png */,
EE180DD01348EDED007F727D /* location-4.png */,
EE180DD11348EDED007F727D /* location-4@2x.png */,
4945D21A1334187D0082387C /* settings.png */,
4945D21B1334187D0082387C /* settings@2x.png */,
49B3FB8B132FA43E00057053 /* location.png */,
@ -582,6 +612,16 @@
4938BB1D1343652600E0815A /* dictionary.slf in Resources */,
4983AE11134631F600C82DB7 /* GuideView-iPad.xib in Resources */,
FAFF422A1347F101009BBB14 /* World.mwm in Resources */,
EE180DD21348EDED007F727D /* location-0.png in Resources */,
EE180DD31348EDED007F727D /* location-0@2x.png in Resources */,
EE180DD41348EDED007F727D /* location-1.png in Resources */,
EE180DD51348EDED007F727D /* location-1@2x.png in Resources */,
EE180DD61348EDED007F727D /* location-2.png in Resources */,
EE180DD71348EDED007F727D /* location-2@2x.png in Resources */,
EE180DD81348EDED007F727D /* location-3.png in Resources */,
EE180DD91348EDED007F727D /* location-3@2x.png in Resources */,
EE180DDA1348EDED007F727D /* location-4.png in Resources */,
EE180DDB1348EDED007F727D /* location-4@2x.png in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};

BIN
iphone/Maps/location-0.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 292 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 467 B

BIN
iphone/Maps/location-1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 326 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 482 B

BIN
iphone/Maps/location-2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 319 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 485 B

BIN
iphone/Maps/location-3.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 293 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 422 B

BIN
iphone/Maps/location-4.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 284 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 388 B