diff options
author | mike@reedtribe.org <mike@reedtribe.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-10-23 03:10:46 +0000 |
---|---|---|
committer | mike@reedtribe.org <mike@reedtribe.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-10-23 03:10:46 +0000 |
commit | c892a153aabb04da31756acad076fddc6b1ea00e (patch) | |
tree | 14e9be41e5b65cffd323a4f0e54e6b59714017af /samplecode | |
parent | 45ba2f773364771dc4a4831246bcb1e0f0992bed (diff) |
support click-drag translate
git-svn-id: http://skia.googlecode.com/svn/trunk@6041 2bbb7eff-a529-9590-31e7-b0007b416f81
Diffstat (limited to 'samplecode')
-rw-r--r-- | samplecode/SampleFatBits.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/samplecode/SampleFatBits.cpp b/samplecode/SampleFatBits.cpp index 34deec0f5d..c3d5eaa4e4 100644 --- a/samplecode/SampleFatBits.cpp +++ b/samplecode/SampleFatBits.cpp @@ -382,13 +382,19 @@ protected: } else if (fPts[1].equalsWithinTolerance(pt, tol)) { index = 1; } - return index >= 0 ? new IndexClick(this, index) : NULL; + return new IndexClick(this, index); } virtual bool onClick(Click* click) { int index = IndexClick::GetIndex(click); - SkASSERT(index >= 0 && index <= 1); - fPts[index] = click->fCurr; + if (index >= 0 && index <= 1) { + fPts[index] = click->fCurr; + } else { + SkScalar dx = click->fCurr.fX - click->fPrev.fX; + SkScalar dy = click->fCurr.fY - click->fPrev.fY; + fPts[0].offset(dx, dy); + fPts[1].offset(dx, dy); + } this->inval(NULL); return true; } |