25 #ifndef __TransformTypes__ 26 #define __TransformTypes__ 29 class TransformFacade;
149 typedef uint32 value_type;
150 template<
typename, value_type v>
struct Int2Type {
enum { value = v};};
163 : base_space(v),final_space(m) { }
166 private: value_type base_space;
172 {
return CoordinateSpace( CoordinateSpace::Spread(), m);}
174 {
return CoordinateSpace( CoordinateSpace::Parent(), m);}
176 {
return CoordinateSpace( CoordinateSpace::Inner(), m);}
178 {
return CoordinateSpace( CoordinateSpace::Page(), m);}
185 typedef uint32 value_type;
186 template<
typename, value_type v>
struct Int2Type {
enum { value = v};};
199 friend bool operator==(
const ResizeMethod& lhs,
const ResizeMethod& rhs) {
return lhs.resize_method == rhs.resize_method; }
200 friend bool operator!=(
const ResizeMethod& lhs,
const ResizeMethod& rhs) {
return lhs.resize_method != rhs.resize_method; }
201 private: value_type resize_method;
205 inline ResizeMethod ResizeAdd() {
return ResizeMethod::Add();}
206 inline ResizeMethod ResizeMultiply() {
return ResizeMethod::Multiply();}
207 inline ResizeMethod AspectRatioArea() {
return ResizeMethod::ConstantArea();}
208 inline ResizeMethod AspectRatioBorder() {
return ResizeMethod::ConstantPerimeter();}
223 friend bool operator==(
const BoundsKind& lhs,
const BoundsKind& rhs) {
return lhs.bounds_kind == rhs.bounds_kind; }
224 friend bool operator!=(
const BoundsKind& lhs,
const BoundsKind& rhs) {
return lhs.bounds_kind != rhs.bounds_kind; }
225 private: value_type bounds_kind;
229 inline BoundsKind PathBounds() {
return BoundsKind::Path();}
232 BoundsKind ResolvePreferredBounds( BoundsKind kind);
234 inline BoundsKind PreferredBoundsKind(){
return ResolvePreferredBounds( BoundsKind::Preferred());}
236 inline BoundsKind PreferredBoundsKind() {
return BoundsKind::Preferred();}
256 private: value_type resize_constraint;
260 inline ResizeConstraint KeepCurrentProportions() {
return ResizeConstraint::KeepProportions();}
261 inline ResizeConstraint KeepCurrentValue() {
return ResizeConstraint::IgnoreProportions();}
262 inline ResizeConstraint MakeTallAspect() {
return ResizeConstraint::TallProportions();}
263 inline ResizeConstraint MakeWideAspect() {
return ResizeConstraint::WideProportions();}
264 inline ResizeConstraint InvertAspect() {
return ResizeConstraint::InverseProportions();}
266 enum ValueSource { kValueProvided, kValueCalculated};
274 ValueSource x_source;
275 ValueSource y_source;
276 ValueSource coordinates_source;
281 ValueSource x_source_,
PMReal provided_x_,
282 ValueSource y_source_,
PMReal provided_y_,
284 ) : method(method_), constraint(constraint_),
285 x_source(x_source_), provided_x(provided_x_),
286 y_source(y_source_), provided_y(provided_y_),
287 coordinates_source(coordinates_source_), provided_coordinates(provided_coordinates_)
294 return ResizeValue( ResizeAdd(), constrainX, kValueCalculated, 0, kValueProvided, y_delta, kValueCalculated, Transform::InnerCoordinates());
299 return ResizeValue( ResizeAdd(), constrainX, kValueCalculated, 0, kValueProvided, y_delta, kValueProvided, coordinateSpace);
303 inline ResizeValue AddTo(
PMReal x_delta, ResizeConstraint constrainY)
305 return ResizeValue( ResizeAdd(), constrainY, kValueProvided, x_delta, kValueCalculated, 0, kValueCalculated, Transform::InnerCoordinates());
310 return ResizeValue( ResizeAdd(), constrainY, kValueProvided, x_delta, kValueCalculated, 0, kValueProvided, coordinateSpace);
314 inline ResizeValue AddTo(
PMReal x_delta,
PMReal y_delta)
316 return ResizeValue( ResizeAdd(), IgnoreCurrentProportions(), kValueProvided, x_delta, kValueProvided, y_delta, kValueCalculated, Transform::InnerCoordinates());
321 return ResizeValue( ResizeAdd(), IgnoreCurrentProportions(), kValueProvided, x_delta, kValueProvided, y_delta, kValueProvided, coordinateSpace);
325 inline ResizeValue MultiplyBy( ResizeConstraint constrainX,
PMReal y_factor)
327 return ResizeValue( ResizeMultiply(), constrainX, kValueCalculated, y_factor, kValueProvided, y_factor, kValueCalculated, Transform::InnerCoordinates());
330 inline ResizeValue MultiplyBy(
PMReal x_factor, ResizeConstraint constrainY)
332 return ResizeValue( ResizeMultiply(), constrainY, kValueProvided, x_factor, kValueCalculated, x_factor, kValueCalculated, Transform::InnerCoordinates());
335 inline ResizeValue MultiplyBy(
PMReal x_factor,
PMReal y_factor)
337 return ResizeValue( ResizeMultiply(), IgnoreCurrentProportions(), kValueProvided, x_factor, kValueProvided, y_factor, kValueCalculated, Transform::InnerCoordinates());
341 inline ResizeValue ResizeTo( ResizeConstraint constrainX,
PMReal y_value)
343 return ResizeValue( ResizeEqual(), constrainX, kValueCalculated, 0, kValueProvided, y_value, kValueCalculated, Transform::InnerCoordinates());
348 return ResizeValue( ResizeEqual(), constrainX, kValueCalculated, 0, kValueProvided, y_value, kValueProvided, coordinateSpace);
352 inline ResizeValue ResizeTo(
PMReal x_value, ResizeConstraint constrainY)
354 return ResizeValue( ResizeEqual(), constrainY, kValueProvided, x_value, kValueCalculated, 0, kValueCalculated, Transform::InnerCoordinates());
359 return ResizeValue( ResizeEqual(), constrainY, kValueProvided, x_value, kValueCalculated, 0, kValueProvided, coordinateSpace);
363 inline ResizeValue ResizeTo(
PMReal x_value,
PMReal y_value)
365 return ResizeValue( ResizeEqual(), IgnoreCurrentProportions(), kValueProvided, x_value, kValueProvided, y_value, kValueCalculated, Transform::InnerCoordinates());
370 return ResizeValue( ResizeEqual(), IgnoreCurrentProportions(), kValueProvided, x_value, kValueProvided, y_value, kValueProvided, coordinateSpace);
376 inline ResizeValue ReshapeArea( ResizeConstraint orientation)
378 return ResizeValue( AspectRatioArea(), orientation, kValueCalculated, 0, kValueCalculated, 0, kValueCalculated, Transform::InnerCoordinates());
381 inline ResizeValue ReshapeArea(
PMReal width_to_height_ratio)
383 return ResizeValue( AspectRatioArea(), IgnoreCurrentProportions(), kValueProvided, width_to_height_ratio, kValueProvided, 1, kValueCalculated, Transform::InnerCoordinates());
386 inline ResizeValue ReshapeArea(
PMReal x_portion,
PMReal y_portion)
388 return ResizeValue( AspectRatioArea(), IgnoreCurrentProportions(), kValueProvided, x_portion, kValueProvided, y_portion, kValueCalculated, Transform::InnerCoordinates());
392 inline ResizeValue ReshapeBorder( ResizeConstraint orientation)
394 return ResizeValue( AspectRatioBorder(), orientation, kValueCalculated, 0, kValueCalculated, 0, kValueCalculated, Transform::InnerCoordinates());
397 inline ResizeValue ReshapeBorder(
PMReal width_to_height_ratio)
399 return ResizeValue( AspectRatioBorder(), IgnoreCurrentProportions(), kValueProvided, width_to_height_ratio, kValueProvided, 1, kValueCalculated, Transform::InnerCoordinates());
402 inline ResizeValue ReshapeBorder(
PMReal x_portion,
PMReal y_portion)
404 return ResizeValue( AspectRatioBorder(), IgnoreCurrentProportions(), kValueProvided, x_portion, kValueProvided, y_portion, kValueCalculated, Transform::InnerCoordinates());
407 inline ResizeValue MakeTallAspectRatio()
409 return ReshapeArea( Geometry::MakeTallAspect());
412 inline ResizeValue MakeWideAspectRatio()
414 return ReshapeArea( Geometry::MakeWideAspect());
417 inline ResizeValue InvertAspectRatio()
419 return ReshapeArea( Geometry::InvertAspect());
438 friend bool operator==(
const Target& lhs,
const Target& rhs) {
return lhs.transform_target == rhs.transform_target; }
439 friend bool operator!=(
const Target& lhs,
const Target& rhs) {
return lhs.transform_target != rhs.transform_target; }
440 private: value_type transform_target;
458 friend bool operator==(
const Action& lhs,
const Action& rhs) {
return lhs.transform_action == rhs.transform_action; }
459 friend bool operator!=(
const Action& lhs,
const Action& rhs) {
return lhs.transform_action != rhs.transform_action; }
460 private: value_type transform_action;
475 inline Target DuplicateItems() {
return Target::DuplicateItems();}
476 inline Target SpreadItems() {
return Target::SpreadItems();}
478 inline Action ScaleBy() {
return Action::ScaleBy();}
479 inline Action ScaleTo() {
return Action::ScaleTo();}
480 inline Action SkewBy() {
return Action::SkewBy();}
481 inline Action SkewTo() {
return Action::SkewTo();}
482 inline Action RotateBy() {
return Action::RotateBy();}
483 inline Action RotateTo() {
return Action::RotateTo();}
484 inline Action TranslateBy() {
return Action::TranslateBy();}
485 inline Action TranslateTo() {
return Action::TranslateTo();}
486 inline Action TransformBy() {
return Action::TransformBy();}
487 inline Action TransformTo() {
return Action::TransformTo();}
500 {
return lhs.location_space == rhs.location_space;}
501 friend bool operator!=(
const LocationSpace& lhs,
const LocationSpace& rhs) {
return lhs.location_space != rhs.location_space; }
502 private: value_type location_space;
513 PMPoint originLocation, pageLocator;
517 uint32 altValue, pageAltValue;
521 originLocation(location),
523 coordinateSpace( coordinates),
525 boundsKind(Geometry::PathBounds()),
532 originLocation(location),
534 coordinateSpace( PasteboardCoordinates()),
536 boundsKind(Geometry::PathBounds()),
543 originLocation(location),
546 coordinateSpace( InnerCoordinates()),
547 boundsKind(Geometry::PathBounds()),
556 originLocation( location),
558 coordinateSpace( coordinates),
567 originLocation( location),
569 coordinateSpace( PasteboardCoordinates()),
578 originLocation( location),
579 altValue( (2*spreadRuler) + (useRulerUnits ? 1 : 0)),
581 coordinateSpace( InnerCoordinates()),
582 boundsKind( Geometry::PathBounds()),
586 ASSERT( spreadRuler != 0);
591 originLocation( location),
592 altValue( useRulerUnits ? 1 : 0),
593 coordinateSpace( pageFinder.coordinateSpace),
594 boundsKind( pageFinder.boundsKind),
595 pageLocator( pageFinder.originLocation),
596 pageAltValue( pageFinder.altValue)
619 inline TransformOrigin PasteboardLocation(
PMReal x,
PMReal y)
621 return PasteboardLocation(
PMPoint(x,y));
623 inline TransformOrigin SpreadLocation(
PMPoint l)
625 return TransformOrigin( SpreadCoordinates(), l);
627 inline TransformOrigin SpreadLocation(
PMReal x,
PMReal y)
629 return SpreadLocation(
PMPoint(x,y));
631 inline TransformOrigin ParentLocation(
PMPoint l)
633 return TransformOrigin( ParentCoordinates(), l);
635 inline TransformOrigin ParentLocation(
PMReal x,
PMReal y)
637 return ParentLocation(
PMPoint(x,y));
639 inline TransformOrigin InnerLocation(
PMPoint l)
641 return TransformOrigin( InnerCoordinates(), l);
643 inline TransformOrigin InnerLocation(
PMReal x,
PMReal y)
645 return InnerLocation(
PMPoint(x,y));
647 inline TransformOrigin TransformLocation(
PMPoint l)
649 return TransformOrigin( l, (
char*)0);
651 inline TransformOrigin TransformLocation(
PMReal x,
PMReal y)
653 return TransformLocation(
PMPoint(x,y));
655 inline TransformOrigin CurrentOrigin()
657 return TransformLocation( 0,0);
661 inline TransformOrigin RulerLocation(
PMPoint l, uint32 spreadRuler, bool16 useRulerUnits =
false)
663 return TransformOrigin( l, spreadRuler, useRulerUnits);
665 inline TransformOrigin RulerLocation(
PMPoint l,
const TransformOrigin& boundsLocation, bool16 useRulerUnits =
false)
667 return TransformOrigin( l, boundsLocation, useRulerUnits);
673 return TransformOrigin( coordinates, boundsKind, l);
677 return BoundsLocation( coordinates, boundsKind,
PMPoint(x,y));
681 return TransformOrigin( boundsKind, l);
685 return BoundsLocation( boundsKind,
PMPoint(x,y));
691 return BoundsLocation( boundsKind, 0.0, 0.0);
695 return BoundsLocation( boundsKind, 0.5, 0.0);
699 return BoundsLocation( boundsKind, 1.0, 0.0);
703 return BoundsLocation( boundsKind, 0.0, 0.5);
707 return BoundsLocation( boundsKind, 0.5, 0.5);
711 return BoundsLocation( boundsKind, 1.0, 0.5);
715 return BoundsLocation( boundsKind, 0.0, 1.0);
719 return BoundsLocation( boundsKind, 0.5, 1.0);
723 return BoundsLocation( boundsKind, 1.0, 1.0);
735 uint32 matrixContent;
738 : transformAction(action), transformMatrix(matrix), matrixContent(content)
748 inline TransformValue TransformTo(
const PMMatrix& m, uint32 matrixContent)
750 return TransformValue( TransformTo(), m, matrixContent);
753 inline TransformValue ScaleBy(
PMReal xscale,
PMReal yscale)
755 return TransformValue( ScaleBy(),
PMMatrix( xscale, 0, 0, yscale, 0, 0), 0);
758 inline TransformValue ScaleTo(
PMReal xscale,
PMReal yscale)
760 return TransformValue( ScaleTo(),
PMMatrix( xscale, 0, 0, yscale, 0, 0), PMMatrix::kHasScaleContent);
763 inline TransformValue SkewBy(
PMReal degrees)
767 return TransformValue( SkewBy(), m, 0);
770 inline TransformValue SkewTo(
PMReal degrees)
774 return TransformValue( SkewTo(), m, PMMatrix::kHasSkewContent);
777 inline TransformValue SkewBySlope(
PMReal k)
779 return TransformValue( SkewBy(),
PMMatrix( 1, 0, -k, 1, 0, 0), 0);
782 inline TransformValue SkewToSlope(
PMReal k)
784 return TransformValue( SkewTo(),
PMMatrix( 1, 0, -k, 1, 0, 0), PMMatrix::kHasSkewContent);
787 inline TransformValue RotateBy(
PMReal degrees)
791 return TransformValue( RotateBy(), m, 0);
794 inline TransformValue RotateTo(
PMReal degrees)
798 return TransformValue( RotateTo(), m, PMMatrix::kHasRotateContent);
801 inline TransformValue RotateBy(
PMReal cosine,
PMReal sine)
803 return TransformValue( RotateBy(),
PMMatrix( cosine, -sine, sine, cosine, 0, 0), 0);
806 inline TransformValue RotateTo(
PMReal cosine,
PMReal sine)
808 return TransformValue( RotateTo(),
PMMatrix( cosine, -sine, sine, cosine, 0, 0), PMMatrix::kHasRotateContent);
811 inline TransformValue TranslateBy(
PMReal deltaX,
PMReal deltaY)
813 return TransformValue( TranslateBy(),
PMMatrix( 1, 0, 0, 1, deltaX, deltaY), 0);
816 inline TransformValue TranslateBy(
PMPoint delta)
818 return TranslateBy( delta.
X(), delta.
Y());
823 return TransformValue( TranslateTo(),
PMMatrix( 1, 0, 0, 1, x, y), PMMatrix::kHasTranslateContent);
826 inline TransformValue TranslateTo(
PMPoint p)
828 return TranslateTo( p.
X(), p.
Y());
832 const uint32 kNoTransformValues = 0;
833 const uint32 kScaleXValue = 1;
834 const uint32 kScaleYValue = 2;
835 const uint32 kScaleValue = kScaleXValue | kScaleYValue;
836 const uint32 kSkewValue = 4;
837 const uint32 kRotationValue = 8;
838 const uint32 kTranslationXValue = 16;
839 const uint32 kTranslationYValue = 32;
840 const uint32 kTranslationValue = kTranslationXValue | kTranslationYValue;
841 const uint32 kAllTransformValues = kScaleValue | kSkewValue | kRotationValue | kTranslationValue;
859 friend bool operator==(
const ScaleMethod& lhs,
const ScaleMethod& rhs) {
return lhs.scale_method == rhs.scale_method; }
860 friend bool operator!=(
const ScaleMethod& lhs,
const ScaleMethod& rhs) {
return lhs.scale_method != rhs.scale_method; }
861 private: value_type scale_method;
864 inline ScaleMethod UseContentScaling() {
return ScaleMethod::ContentScaling();}
865 inline ScaleMethod ConsultScalingPreference() {
return ScaleMethod::ScalingPreference();}
876 #endif // __TransformTypes__