From abb02bc4a40395682a9dd4ad13361653412d82f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stephan=20A=C3=9Fmus?= Date: Fri, 26 Mar 2010 11:20:53 +0000 Subject: [PATCH] Moved BAffineTransform from shared kit into interface kit. Still in BPrivate namespace. Applied 80 char/line limit. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@35955 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../shared => os/interface}/AffineTransform.h | 77 ++++++++----- .../{shared => interface}/AffineTransform.cpp | 104 +++++++++++------- src/kits/interface/Jamfile | 1 + src/kits/shared/Jamfile | 1 - 4 files changed, 114 insertions(+), 69 deletions(-) rename headers/{private/shared => os/interface}/AffineTransform.h (51%) rename src/kits/{shared => interface}/AffineTransform.cpp (92%) diff --git a/headers/private/shared/AffineTransform.h b/headers/os/interface/AffineTransform.h similarity index 51% rename from headers/private/shared/AffineTransform.h rename to headers/os/interface/AffineTransform.h index 1a5e900d11..cf226f7bad 100644 --- a/headers/private/shared/AffineTransform.h +++ b/headers/os/interface/AffineTransform.h @@ -1,12 +1,12 @@ /* - * Copyright 2008, Haiku, Inc. All Rights Reserved. + * Copyright 2008-2010, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. * * Authors: * Stephen Deken, stephen.deken@gmail.com */ -#ifndef _AFFINETRANSFORM_H -#define _AFFINETRANSFORM_H +#ifndef _AFFINE_TRANSFORM_H +#define _AFFINE_TRANSFORM_H #include @@ -19,9 +19,12 @@ namespace BPrivate { class BAffineTransform { public: BAffineTransform(); - BAffineTransform(const BAffineTransform& copyFrom); + BAffineTransform( + const BAffineTransform& copyFrom); virtual ~BAffineTransform(); - virtual BAffineTransform& operator=(const BAffineTransform& copyFrom); + + virtual BAffineTransform& operator=( + const BAffineTransform& copyFrom); virtual bool operator==( const BAffineTransform& other) const; @@ -33,58 +36,79 @@ public: // Application BPoint Apply(const BPoint& point) const; + void Apply(BPoint* point) const; void Apply(BPoint* points, uint32 count) const; // Rotation void Rotate(float angle); void Rotate(const BPoint& center, float angle); BAffineTransform& RotateBySelf(float angle); - BAffineTransform& RotateBySelf(const BPoint& center, float angle); + BAffineTransform& RotateBySelf(const BPoint& center, + float angle); BAffineTransform RotateByCopy(float angle) const; - BAffineTransform RotateByCopy(const BPoint& center, float angle) const; + BAffineTransform RotateByCopy(const BPoint& center, + float angle) const; // Translation void Translate(float deltaX, float deltaY); void Translate(const BPoint& delta); - BAffineTransform& TranslateBySelf(float deltaX, float deltaY); + BAffineTransform& TranslateBySelf(float deltaX, + float deltaY); BAffineTransform& TranslateBySelf(const BPoint& delta); - BAffineTransform TranslateByCopy(float deltaX, float deltaY) const; + BAffineTransform TranslateByCopy(float deltaX, + float deltaY) const; BAffineTransform TranslateByCopy(const BPoint& delta) const; // Scaling void Scale(float scale); void Scale(const BPoint& center, float scale); void Scale(float scaleX, float scaleY); - void Scale(const BPoint& center, float scaleX, float scaleY); + void Scale(const BPoint& center, float scaleX, + float scaleY); void Scale(const BPoint& scale); - void Scale(const BPoint& center, const BPoint& scale); + void Scale(const BPoint& center, + const BPoint& scale); BAffineTransform& ScaleBySelf(float scale); - BAffineTransform& ScaleBySelf(const BPoint& center, float scale); + BAffineTransform& ScaleBySelf(const BPoint& center, + float scale); BAffineTransform& ScaleBySelf(float scaleX, float scaleY); - BAffineTransform& ScaleBySelf(const BPoint& center, float scaleX, float scaleY); + BAffineTransform& ScaleBySelf(const BPoint& center, + float scaleX, float scaleY); BAffineTransform& ScaleBySelf(const BPoint& scale); - BAffineTransform& ScaleBySelf(const BPoint& center, const BPoint& scale); + BAffineTransform& ScaleBySelf(const BPoint& center, + const BPoint& scale); BAffineTransform ScaleByCopy(float scale) const; - BAffineTransform ScaleByCopy(const BPoint& center, float scale) const; - BAffineTransform ScaleByCopy(float scaleX, float scaleY) const; - BAffineTransform ScaleByCopy(const BPoint& center, float scaleX, float scaleY) const; + BAffineTransform ScaleByCopy(const BPoint& center, + float scale) const; + BAffineTransform ScaleByCopy(float scaleX, + float scaleY) const; + BAffineTransform ScaleByCopy(const BPoint& center, + float scaleX, float scaleY) const; BAffineTransform ScaleByCopy(const BPoint& scale) const; - BAffineTransform ScaleByCopy(const BPoint& center, const BPoint& scale) const; + BAffineTransform ScaleByCopy(const BPoint& center, + const BPoint& scale) const; // Shearing void Shear(float shearX, float shearY); - void Shear(const BPoint& center, float shearX, float shearY); + void Shear(const BPoint& center, float shearX, + float shearY); void Shear(const BPoint& shear); - void Shear(const BPoint& center, const BPoint& shear); + void Shear(const BPoint& center, + const BPoint& shear); BAffineTransform& ShearBySelf(float shearX, float shearY); - BAffineTransform& ShearBySelf(const BPoint& center, float shearX, float shearY); + BAffineTransform& ShearBySelf(const BPoint& center, + float shearX, float shearY); BAffineTransform& ShearBySelf(const BPoint& shear); - BAffineTransform& ShearBySelf(const BPoint& center, const BPoint& shear); - BAffineTransform ShearByCopy(float shearX, float shearY) const; - BAffineTransform ShearByCopy(const BPoint& center, float shearX, float shearY) const; + BAffineTransform& ShearBySelf(const BPoint& center, + const BPoint& shear); + BAffineTransform ShearByCopy(float shearX, + float shearY) const; + BAffineTransform ShearByCopy(const BPoint& center, + float shearX, float shearY) const; BAffineTransform ShearByCopy(const BPoint& shear) const; - BAffineTransform ShearByCopy(const BPoint& center, const BPoint& shear) const; + BAffineTransform ShearByCopy(const BPoint& center, + const BPoint& shear) const; private: void _Rotate(float angle); @@ -94,6 +118,7 @@ private: void _TransformPoint(BPoint& point) const; +private: agg::trans_affine fTransformMatrix; }; @@ -101,4 +126,4 @@ private: using namespace BPrivate; -#endif // _AFFINETRANSFORM_H +#endif // _AFFINE_TRANSFORM_H diff --git a/src/kits/shared/AffineTransform.cpp b/src/kits/interface/AffineTransform.cpp similarity index 92% rename from src/kits/shared/AffineTransform.cpp rename to src/kits/interface/AffineTransform.cpp index 5b7811fb4a..f33a4233cc 100644 --- a/src/kits/shared/AffineTransform.cpp +++ b/src/kits/interface/AffineTransform.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2008, Haiku, Inc. All Rights Reserved. + * Copyright 2008-2010, Haiku, Inc. All Rights Reserved. * Distributed under the terms of the MIT License. * * Authors: @@ -9,14 +9,17 @@ #include #include + BAffineTransform::BAffineTransform() - : fTransformMatrix() + : + fTransformMatrix() { } BAffineTransform::BAffineTransform(const BAffineTransform& copyFrom) - : fTransformMatrix(copyFrom.fTransformMatrix) + : + fTransformMatrix(copyFrom.fTransformMatrix) { } @@ -62,49 +65,27 @@ BAffineTransform::TransformationChanged() const BPoint BAffineTransform::Apply(const BPoint& point) const { - BPoint rval(point); - _TransformPoint(rval); - return rval; + BPoint result(point); + _TransformPoint(result); + return result; +} + + +void +BAffineTransform::Apply(BPoint* point) const +{ + if (point) + _TransformPoint(*point); } void BAffineTransform::Apply(BPoint* points, uint32 count) const { - for (uint32 i = 0; i < count; ++i) - _TransformPoint(points[i]); -} - - -void -BAffineTransform::_Rotate(float angle) -{ - if (angle != 0.0) - fTransformMatrix.multiply(agg::trans_affine_rotation(angle)); -} - - -void -BAffineTransform::_Scale(float scaleX, float scaleY) -{ - if (scaleX != 0.0 || scaleY != 0.0) - fTransformMatrix.multiply(agg::trans_affine_scaling(scaleX, scaleY)); -} - - -void -BAffineTransform::_Translate(float deltaX, float deltaY) -{ - if (deltaX != 0.0 || deltaY != 0.0) - fTransformMatrix.multiply(agg::trans_affine_translation(deltaX, deltaY)); -} - - -void -BAffineTransform::_Shear(float shearX, float shearY) -{ - if (shearX != 0.0 || shearY != 0.0) - fTransformMatrix.multiply(agg::trans_affine_skewing(shearX, shearY)); + if (points) { + for (uint32 i = 0; i < count; ++i) + _TransformPoint(points[i]); + } } @@ -320,7 +301,8 @@ BAffineTransform::ScaleByCopy(float scaleX, float scaleY) const BAffineTransform -BAffineTransform::ScaleByCopy(const BPoint& center, float scaleX, float scaleY) const +BAffineTransform::ScaleByCopy(const BPoint& center, float scaleX, + float scaleY) const { BAffineTransform copy(*this); copy.Scale(center, scaleX, scaleY); @@ -416,7 +398,8 @@ BAffineTransform::ShearByCopy(float shearX, float shearY) const BAffineTransform -BAffineTransform::ShearByCopy(const BPoint& center, float shearX, float shearY) const +BAffineTransform::ShearByCopy(const BPoint& center, float shearX, + float shearY) const { BAffineTransform copy(*this); copy.Shear(center, shearX, shearY); @@ -442,6 +425,43 @@ BAffineTransform::ShearByCopy(const BPoint& center, const BPoint& shear) const } +// #pragma mark - + + +void +BAffineTransform::_Rotate(float angle) +{ + if (angle != 0.0) + fTransformMatrix.multiply(agg::trans_affine_rotation(angle)); +} + + +void +BAffineTransform::_Scale(float scaleX, float scaleY) +{ + if (scaleX != 0.0 || scaleY != 0.0) + fTransformMatrix.multiply(agg::trans_affine_scaling(scaleX, scaleY)); +} + + +void +BAffineTransform::_Translate(float deltaX, float deltaY) +{ + if (deltaX != 0.0 || deltaY != 0.0) { + fTransformMatrix.multiply( + agg::trans_affine_translation(deltaX, deltaY)); + } +} + + +void +BAffineTransform::_Shear(float shearX, float shearY) +{ + if (shearX != 0.0 || shearY != 0.0) + fTransformMatrix.multiply(agg::trans_affine_skewing(shearX, shearY)); +} + + void BAffineTransform::_TransformPoint(BPoint& point) const { diff --git a/src/kits/interface/Jamfile b/src/kits/interface/Jamfile index 5eedda5613..2cad5dcd04 100644 --- a/src/kits/interface/Jamfile +++ b/src/kits/interface/Jamfile @@ -33,6 +33,7 @@ SEARCH_SOURCE += [ FDirName $(SUBDIR) layouter ] ; MergeObject interface_kit.o : AbstractLayoutItem.cpp + AffineTransform.cpp Alert.cpp Alignment.cpp Bitmap.cpp diff --git a/src/kits/shared/Jamfile b/src/kits/shared/Jamfile index 001ee6f446..90edf0eac0 100644 --- a/src/kits/shared/Jamfile +++ b/src/kits/shared/Jamfile @@ -12,7 +12,6 @@ UsePrivateHeaders kernel libroot ; StaticLibrary libshared.a : AboutWindow.cpp - AffineTransform.cpp CalendarView.cpp ColorQuantizer.cpp CommandPipe.cpp