diff --git a/src/apps/icon-o-matic/Jamfile b/src/apps/icon-o-matic/Jamfile index 6829c72633..6204c93254 100644 --- a/src/apps/icon-o-matic/Jamfile +++ b/src/apps/icon-o-matic/Jamfile @@ -289,6 +289,7 @@ Application Icon-O-Matic : TransformBoxStates.cpp TransformCommand.cpp TransformGradientBox.cpp + TransformGradientCommand.cpp TransformObjectsCommand.cpp TransformPointsBox.cpp TransformShapesBox.cpp diff --git a/src/apps/icon-o-matic/transformable/TransformGradientBox.cpp b/src/apps/icon-o-matic/transformable/TransformGradientBox.cpp index 3fd7058162..fc207ce69f 100644 --- a/src/apps/icon-o-matic/transformable/TransformGradientBox.cpp +++ b/src/apps/icon-o-matic/transformable/TransformGradientBox.cpp @@ -16,7 +16,7 @@ #include "GradientTransformable.h" #include "Shape.h" #include "StateView.h" -#include "TransformObjectsCommand.h" +#include "TransformGradientCommand.h" using std::nothrow; @@ -104,7 +104,7 @@ TransformGradientBox::ObjectChanged(const Observable* object) return; } - // any TransformObjectsCommand cannot use the TransformBox + // any TransformGradientCommand cannot use the TransformBox // anymore _NotifyDeleted(); @@ -179,11 +179,8 @@ TransformGradientBox::ViewSpaceRotation() const TransformCommand* TransformGradientBox::MakeCommand(const char* commandName, uint32 nameIndex) { - Transformable* objects[1]; - objects[0] = fGradient; - - return new TransformObjectsCommand(this, objects, fOriginals, 1, Pivot(), - Translation(), LocalRotation(), LocalXScale(), LocalYScale(), commandName, - nameIndex); + return new TransformGradientCommand(this, fGradient, Pivot(), + Translation(), LocalRotation(), LocalXScale(), LocalYScale(), + commandName, nameIndex); } diff --git a/src/apps/icon-o-matic/transformable/TransformGradientCommand.cpp b/src/apps/icon-o-matic/transformable/TransformGradientCommand.cpp new file mode 100644 index 0000000000..e7f60f9168 --- /dev/null +++ b/src/apps/icon-o-matic/transformable/TransformGradientCommand.cpp @@ -0,0 +1,91 @@ +/* + * Copyright 2006-2010, Stephan Aßmus . + * All rights reserved. Distributed under the terms of the MIT License. + */ + + +#include "TransformGradientCommand.h" + +#include +#include + +#include "GradientTransformable.h" + + +using std::nothrow; + + +TransformGradientCommand::TransformGradientCommand(TransformBox* box, + Gradient* gradient, BPoint pivot, BPoint translation, double rotation, + double xScale, double yScale, const char* name, int32 nameIndex) + : + TransformCommand(pivot, translation, rotation, xScale, yScale, name, + nameIndex), + fTransformBox(box), + fGradient(gradient) +{ + if (fGradient == NULL) + return; + +// fGradient->Acquire(); + + if (fTransformBox != NULL) + fTransformBox->AddListener(this); +} + + +TransformGradientCommand::~TransformGradientCommand() +{ +// if (fGradient != NULL) +// fGradient->Release(); + + if (fTransformBox != NULL) + fTransformBox->RemoveListener(this); +} + + +status_t +TransformGradientCommand::InitCheck() +{ + return fGradient != NULL ? TransformCommand::InitCheck() : B_NO_INIT; +} + +// #pragma mark - + +// TransformBoxDeleted +void +TransformGradientCommand::TransformBoxDeleted(const TransformBox* box) +{ + if (fTransformBox == box) { + if (fTransformBox != NULL) + fTransformBox->RemoveListener(this); + fTransformBox = NULL; + } +} + + +// #pragma mark - + + +status_t +TransformGradientCommand::_SetTransformation(BPoint pivot, BPoint translation, + double rotation, double xScale, double yScale) const +{ + if (fTransformBox) { + fTransformBox->SetTransformation(pivot, translation, rotation, xScale, + yScale); + return B_OK; + } + + ChannelTransform transform; + transform.SetTransformation(pivot, translation, rotation, xScale, yScale); + + // Reset and apply transformation. (Gradients never have an original + // transformation that needs to be taken into account, the box always + // assignes it completely.) + fGradient->Reset(); + fGradient->Multiply(transform); + + return B_OK; +} + diff --git a/src/apps/icon-o-matic/transformable/TransformGradientCommand.h b/src/apps/icon-o-matic/transformable/TransformGradientCommand.h new file mode 100644 index 0000000000..e2131d75ab --- /dev/null +++ b/src/apps/icon-o-matic/transformable/TransformGradientCommand.h @@ -0,0 +1,50 @@ +/* + * Copyright 2006-2010, Stephan Aßmus . All rights reserved. + * Distributed under the terms of the MIT License. + */ +#ifndef TRANSFORM_GRADIENT_COMMAND_H +#define TRANSFORM_GRADIENT_COMMAND_H + + +#include "TransformBox.h" +#include "TransformCommand.h" + + +namespace BPrivate { +namespace Icon { + class Gradient; +} +} +using namespace BPrivate::Icon; + + +class TransformGradientCommand : public TransformCommand, + public TransformBoxListener { +public: + TransformGradientCommand( + TransformBox* box, Gradient* gradient, + BPoint pivot, BPoint translation, + double rotation, double xScale, + double yScale, const char* name, + int32 nameIndex); + virtual ~TransformGradientCommand(); + + // Command interface + virtual status_t InitCheck(); + + // TransformBoxListener interface + virtual void TransformBoxDeleted(const TransformBox* box); + +protected: + // TransformCommand interface + virtual status_t _SetTransformation(BPoint pivotDiff, + BPoint translationDiff, + double rotationDiff, double xScaleDiff, + double yScaleDiff) const; + + TransformBox* fTransformBox; + Gradient* fGradient; +}; + + +#endif // TRANSFORM_GRADIENT_COMMAND_H diff --git a/src/apps/icon-o-matic/transformable/TransformObjectsCommand.cpp b/src/apps/icon-o-matic/transformable/TransformObjectsCommand.cpp index bd7e700738..0e2d19e247 100644 --- a/src/apps/icon-o-matic/transformable/TransformObjectsCommand.cpp +++ b/src/apps/icon-o-matic/transformable/TransformObjectsCommand.cpp @@ -103,7 +103,6 @@ TransformObjectsCommand::_SetTransformation( return B_OK; } - ChannelTransform transform; transform.SetTransformation(pivot, translation, rotation, xScale, yScale);