Moved the gradient_type and color_step structs into the BGradient
class/namespace. Renamed the B_GRADIENT_* types to TYPE_* as the context is already given. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28564 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -19,30 +19,29 @@ class BMessage;
|
||||
class BRect;
|
||||
|
||||
|
||||
enum gradient_type {
|
||||
B_GRADIENT_LINEAR = 0,
|
||||
B_GRADIENT_RADIAL,
|
||||
B_GRADIENT_RADIAL_FOCUS,
|
||||
B_GRADIENT_DIAMOND,
|
||||
B_GRADIENT_CONIC,
|
||||
B_GRADIENT_NONE
|
||||
};
|
||||
|
||||
|
||||
struct color_step {
|
||||
color_step(const rgb_color c, float o);
|
||||
color_step(uint8 r, uint8 g, uint8 b, uint8 a, float o);
|
||||
color_step(const color_step& other);
|
||||
color_step();
|
||||
|
||||
bool operator!=(const color_step& other) const;
|
||||
|
||||
rgb_color color;
|
||||
float offset;
|
||||
};
|
||||
|
||||
|
||||
class BGradient : public BArchivable {
|
||||
public:
|
||||
enum gradient_type {
|
||||
TYPE_LINEAR = 0,
|
||||
TYPE_RADIAL,
|
||||
TYPE_RADIAL_FOCUS,
|
||||
TYPE_DIAMOND,
|
||||
TYPE_CONIC,
|
||||
TYPE_NONE
|
||||
};
|
||||
|
||||
struct color_step {
|
||||
color_step(const rgb_color c, float o);
|
||||
color_step(uint8 r, uint8 g, uint8 b, uint8 a, float o);
|
||||
color_step(const color_step& other);
|
||||
color_step();
|
||||
|
||||
bool operator!=(const color_step& other) const;
|
||||
|
||||
rgb_color color;
|
||||
float offset;
|
||||
};
|
||||
|
||||
public:
|
||||
BGradient();
|
||||
BGradient(BMessage* archive);
|
||||
|
||||
@@ -43,10 +43,10 @@ public:
|
||||
void DrawRadialFocus(BRect update);
|
||||
void DrawDiamond(BRect update);
|
||||
void DrawConic(BRect update);
|
||||
void SetType(gradient_type type);
|
||||
void SetType(BGradient::gradient_type type);
|
||||
|
||||
private:
|
||||
gradient_type fType;
|
||||
BGradient::gradient_type fType;
|
||||
};
|
||||
|
||||
|
||||
@@ -134,19 +134,19 @@ GradientsWindow::MessageReceived(BMessage *msg)
|
||||
{
|
||||
switch (msg->what) {
|
||||
case MSG_LINEAR:
|
||||
fGradientsView->SetType(B_GRADIENT_LINEAR);
|
||||
fGradientsView->SetType(BGradient::TYPE_LINEAR);
|
||||
break;
|
||||
case MSG_RADIAL:
|
||||
fGradientsView->SetType(B_GRADIENT_RADIAL);
|
||||
fGradientsView->SetType(BGradient::TYPE_RADIAL);
|
||||
break;
|
||||
case MSG_RADIAL_FOCUS:
|
||||
fGradientsView->SetType(B_GRADIENT_RADIAL_FOCUS);
|
||||
fGradientsView->SetType(BGradient::TYPE_RADIAL_FOCUS);
|
||||
break;
|
||||
case MSG_DIAMOND:
|
||||
fGradientsView->SetType(B_GRADIENT_DIAMOND);
|
||||
fGradientsView->SetType(BGradient::TYPE_DIAMOND);
|
||||
break;
|
||||
case MSG_CONIC:
|
||||
fGradientsView->SetType(B_GRADIENT_CONIC);
|
||||
fGradientsView->SetType(BGradient::TYPE_CONIC);
|
||||
break;
|
||||
default:
|
||||
BWindow::MessageReceived(msg);
|
||||
@@ -160,7 +160,7 @@ GradientsWindow::MessageReceived(BMessage *msg)
|
||||
|
||||
GradientsView::GradientsView(const BRect &rect)
|
||||
: BView(rect, "gradientsview", B_FOLLOW_ALL, B_WILL_DRAW | B_PULSE_NEEDED),
|
||||
fType(B_GRADIENT_LINEAR)
|
||||
fType(BGradient::TYPE_LINEAR)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -174,27 +174,27 @@ void
|
||||
GradientsView::Draw(BRect update)
|
||||
{
|
||||
switch (fType) {
|
||||
case B_GRADIENT_LINEAR: {
|
||||
case BGradient::TYPE_LINEAR: {
|
||||
DrawLinear(update);
|
||||
break;
|
||||
}
|
||||
case B_GRADIENT_RADIAL: {
|
||||
case BGradient::TYPE_RADIAL: {
|
||||
DrawRadial(update);
|
||||
break;
|
||||
}
|
||||
case B_GRADIENT_RADIAL_FOCUS: {
|
||||
case BGradient::TYPE_RADIAL_FOCUS: {
|
||||
DrawRadialFocus(update);
|
||||
break;
|
||||
}
|
||||
case B_GRADIENT_DIAMOND: {
|
||||
case BGradient::TYPE_DIAMOND: {
|
||||
DrawDiamond(update);
|
||||
break;
|
||||
}
|
||||
case B_GRADIENT_CONIC: {
|
||||
case BGradient::TYPE_CONIC: {
|
||||
DrawConic(update);
|
||||
break;
|
||||
}
|
||||
case B_GRADIENT_NONE:
|
||||
case BGradient::TYPE_NONE:
|
||||
default: {
|
||||
break;
|
||||
}
|
||||
@@ -426,7 +426,7 @@ GradientsView::DrawConic(BRect update)
|
||||
|
||||
|
||||
void
|
||||
GradientsView::SetType(gradient_type type)
|
||||
GradientsView::SetType(BGradient::gradient_type type)
|
||||
{
|
||||
fType = type;
|
||||
Invalidate();
|
||||
|
||||
@@ -164,7 +164,7 @@ GradientControl::MouseMoved(BPoint where, uint32 transit, const BMessage* dragMe
|
||||
float offset = _OffsetFor(where);
|
||||
|
||||
if (fDraggingStepIndex >= 0) {
|
||||
color_step* step = fGradient->ColorAt(fDraggingStepIndex);
|
||||
BGradient::color_step* step = fGradient->ColorAt(fDraggingStepIndex);
|
||||
if (step) {
|
||||
if (fGradient->SetOffset(fDraggingStepIndex, offset)) {
|
||||
_UpdateColors();
|
||||
@@ -201,7 +201,8 @@ GradientControl::MessageReceived(BMessage* message)
|
||||
if (restore_color_from_message(message, color, 0) >= B_OK) {
|
||||
bool update = false;
|
||||
if (fDropIndex >= 0) {
|
||||
if (color_step* step = fGradient->ColorAt(fDropIndex)) {
|
||||
if (BGradient::color_step* step
|
||||
= fGradient->ColorAt(fDropIndex)) {
|
||||
color.alpha = step->color.alpha;
|
||||
}
|
||||
fGradient->SetColor(fDropIndex, color);
|
||||
@@ -209,7 +210,8 @@ GradientControl::MessageReceived(BMessage* message)
|
||||
fDropIndex = -1;
|
||||
update = true;
|
||||
} else if (fDropOffset >= 0.0) {
|
||||
fCurrentStepIndex = fGradient->AddColor(color, fDropOffset);
|
||||
fCurrentStepIndex = fGradient->AddColor(color,
|
||||
fDropOffset);
|
||||
fDropOffset = -1.0;
|
||||
update = true;
|
||||
}
|
||||
@@ -253,7 +255,8 @@ GradientControl::KeyDown(const char* bytes, int32 numBytes)
|
||||
case B_END:
|
||||
case B_LEFT_ARROW:
|
||||
case B_RIGHT_ARROW: {
|
||||
if (color_step* step = fGradient->ColorAt(fCurrentStepIndex)) {
|
||||
if (BGradient::color_step* step
|
||||
= fGradient->ColorAt(fCurrentStepIndex)) {
|
||||
BRect r = _GradientBitmapRect();
|
||||
float x = r.left + r.Width() * step->offset;
|
||||
switch (bytes[0]) {
|
||||
@@ -274,7 +277,8 @@ GradientControl::KeyDown(const char* bytes, int32 numBytes)
|
||||
x = r.right;
|
||||
break;
|
||||
}
|
||||
update = fGradient->SetOffset(fCurrentStepIndex, (x - r.left) / r.Width());
|
||||
update = fGradient->SetOffset(fCurrentStepIndex,
|
||||
(x - r.left) / r.Width());
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -377,14 +381,15 @@ GradientControl::Draw(BRect updateRect)
|
||||
markerPos.y = b.bottom + 4.0;
|
||||
BPoint leftBottom(-6.0, 6.0);
|
||||
BPoint rightBottom(6.0, 6.0);
|
||||
for (int32 i = 0; color_step* step = fGradient->ColorAt(i); i++) {
|
||||
for (int32 i = 0; BGradient::color_step* step = fGradient->ColorAt(i);
|
||||
i++) {
|
||||
markerPos.x = b.left + (b.Width() * step->offset);
|
||||
|
||||
if (i == fCurrentStepIndex) {
|
||||
SetLowColor(focus);
|
||||
if (isFocus) {
|
||||
StrokeLine(markerPos + leftBottom + BPoint(1.0, 4.0),
|
||||
markerPos + rightBottom + BPoint(-1.0, 4.0), B_SOLID_LOW);
|
||||
markerPos + rightBottom + BPoint(-1.0, 4.0), B_SOLID_LOW);
|
||||
}
|
||||
} else {
|
||||
SetLowColor(black);
|
||||
@@ -394,9 +399,8 @@ GradientControl::Draw(BRect updateRect)
|
||||
if (i == fDropIndex)
|
||||
SetLowColor(255, 0, 0, 255);
|
||||
|
||||
StrokeTriangle(markerPos,
|
||||
markerPos + leftBottom,
|
||||
markerPos + rightBottom, B_SOLID_LOW);
|
||||
StrokeTriangle(markerPos, markerPos + leftBottom,
|
||||
markerPos + rightBottom, B_SOLID_LOW);
|
||||
if (fEnabled) {
|
||||
SetHighColor(step->color);
|
||||
} else {
|
||||
@@ -459,7 +463,8 @@ GradientControl::SetCurrentStop(const rgb_color& color)
|
||||
bool
|
||||
GradientControl::GetCurrentStop(rgb_color* color) const
|
||||
{
|
||||
color_step* stop = fGradient->ColorAt(fCurrentStepIndex);
|
||||
BGradient::color_step* stop
|
||||
= fGradient->ColorAt(fCurrentStepIndex);
|
||||
if (stop && color) {
|
||||
*color = stop->color;
|
||||
return true;
|
||||
@@ -612,8 +617,10 @@ GradientControl::_StepIndexFor(BPoint where) const
|
||||
int32 index = -1;
|
||||
BRect r = _GradientBitmapRect();
|
||||
BRect markerFrame(Bounds());
|
||||
for (int32 i = 0; color_step* step = fGradient->ColorAt(i); i++) {
|
||||
markerFrame.left = markerFrame.right = r.left + (r.Width() * step->offset);
|
||||
for (int32 i = 0; BGradient::color_step* step
|
||||
= fGradient->ColorAt(i); i++) {
|
||||
markerFrame.left = markerFrame.right = r.left
|
||||
+ (r.Width() * step->offset);
|
||||
markerFrame.InsetBy(-6.0, 0.0);
|
||||
if (markerFrame.Contains(where)) {
|
||||
index = i;
|
||||
@@ -641,7 +648,7 @@ GradientControl::_UpdateCurrentColor() const
|
||||
if (!fMessage || !fTarget || !fTarget->Looper())
|
||||
return;
|
||||
// set the CanvasView current color
|
||||
if (color_step* step = fGradient->ColorAt(fCurrentStepIndex)) {
|
||||
if (BGradient::color_step* step = fGradient->ColorAt(fCurrentStepIndex)) {
|
||||
BMessage message(*fMessage);
|
||||
store_color_in_message(&message, step->color);
|
||||
fTarget->Looper()->PostMessage(&message, fTarget);
|
||||
|
||||
@@ -606,7 +606,7 @@ FlatIconExporter::_WriteGradient(LittleEndianBuffer& buffer,
|
||||
bool alpha = false;
|
||||
bool gray = true;
|
||||
for (int32 i = 0; i < gradientStopCount; i++) {
|
||||
color_step* step = gradient->ColorAtFast(i);
|
||||
BGradient::color_step* step = gradient->ColorAtFast(i);
|
||||
if (step->color.alpha < 255)
|
||||
alpha = true;
|
||||
if (step->color.red != step->color.green
|
||||
@@ -632,7 +632,7 @@ FlatIconExporter::_WriteGradient(LittleEndianBuffer& buffer,
|
||||
}
|
||||
|
||||
for (int32 i = 0; i < gradientStopCount; i++) {
|
||||
color_step* step = gradient->ColorAtFast(i);
|
||||
BGradient::color_step* step = gradient->ColorAtFast(i);
|
||||
uint8 stopOffset = (uint8)(step->offset * 255.0);
|
||||
uint32 color = (uint32&)step->color;
|
||||
if (!buffer.Write(stopOffset))
|
||||
|
||||
@@ -803,7 +803,7 @@ DocumentBuilder::_AddShape(path_attributes& attributes, bool outline,
|
||||
|
||||
rgb_color color;
|
||||
|
||||
color_step* step;
|
||||
BGradient::color_step* step;
|
||||
if (gradient && (step = gradient->ColorAt(0))) {
|
||||
color.red = step->color.red;
|
||||
color.green = step->color.green;
|
||||
|
||||
@@ -408,7 +408,7 @@ SVGExporter::_ExportGradient(const Gradient* gradient, BPositionIO* stream)
|
||||
|
||||
// write stop tags
|
||||
char color[16];
|
||||
for (int32 i = 0; color_step* stop = gradient->ColorAt(i); i++) {
|
||||
for (int32 i = 0; BGradient::color_step* stop = gradient->ColorAt(i); i++) {
|
||||
|
||||
sprintf(color, "%.2x%.2x%.2x", stop->color.red,
|
||||
stop->color.green,
|
||||
|
||||
@@ -471,20 +471,20 @@ LinkReceiver::ReadRegion(BRegion* region)
|
||||
|
||||
|
||||
static BGradient*
|
||||
gradient_for_type(gradient_type type)
|
||||
gradient_for_type(BGradient::gradient_type type)
|
||||
{
|
||||
switch (type) {
|
||||
case B_GRADIENT_LINEAR:
|
||||
case BGradient::TYPE_LINEAR:
|
||||
return new (std::nothrow) BGradientLinear();
|
||||
case B_GRADIENT_RADIAL:
|
||||
case BGradient::TYPE_RADIAL:
|
||||
return new (std::nothrow) BGradientRadial();
|
||||
case B_GRADIENT_RADIAL_FOCUS:
|
||||
case BGradient::TYPE_RADIAL_FOCUS:
|
||||
return new (std::nothrow) BGradientRadialFocus();
|
||||
case B_GRADIENT_DIAMOND:
|
||||
case BGradient::TYPE_DIAMOND:
|
||||
return new (std::nothrow) BGradientDiamond();
|
||||
case B_GRADIENT_CONIC:
|
||||
case BGradient::TYPE_CONIC:
|
||||
return new (std::nothrow) BGradientConic();
|
||||
case B_GRADIENT_NONE:
|
||||
case BGradient::TYPE_NONE:
|
||||
return new (std::nothrow) BGradient();
|
||||
}
|
||||
return NULL;
|
||||
@@ -495,10 +495,10 @@ status_t
|
||||
LinkReceiver::ReadGradient(BGradient** _gradient)
|
||||
{
|
||||
GTRACE(("LinkReceiver::ReadGradient\n"));
|
||||
gradient_type gradientType;
|
||||
BGradient::gradient_type gradientType;
|
||||
int32 colorsCount;
|
||||
status_t ret;
|
||||
if ((ret = Read(&gradientType, sizeof(gradient_type))) != B_OK)
|
||||
if ((ret = Read(&gradientType, sizeof(BGradient::gradient_type))) != B_OK)
|
||||
return ret;
|
||||
if ((ret = Read(&colorsCount, sizeof(int32))) != B_OK)
|
||||
return ret;
|
||||
@@ -509,9 +509,9 @@ LinkReceiver::ReadGradient(BGradient** _gradient)
|
||||
*_gradient = gradient;
|
||||
|
||||
if (colorsCount > 0) {
|
||||
color_step step;
|
||||
BGradient::color_step step;
|
||||
for (int i = 0; i < colorsCount; i++) {
|
||||
if ((ret = Read(&step, sizeof(color_step))) != B_OK)
|
||||
if ((ret = Read(&step, sizeof(BGradient::color_step))) != B_OK)
|
||||
return ret;
|
||||
if (!gradient->AddColor(step, i))
|
||||
return B_NO_MEMORY;
|
||||
@@ -519,8 +519,8 @@ LinkReceiver::ReadGradient(BGradient** _gradient)
|
||||
}
|
||||
|
||||
switch(gradientType) {
|
||||
case B_GRADIENT_LINEAR: {
|
||||
GTRACE(("LinkReceiver::ReadGradient> type == B_GRADIENT_LINEAR\n"));
|
||||
case BGradient::TYPE_LINEAR: {
|
||||
GTRACE(("LinkReceiver::ReadGradient> type == TYPE_LINEAR\n"));
|
||||
BGradientLinear* linear = (BGradientLinear*)gradient;
|
||||
BPoint start;
|
||||
BPoint end;
|
||||
@@ -532,8 +532,8 @@ LinkReceiver::ReadGradient(BGradient** _gradient)
|
||||
linear->SetEnd(end);
|
||||
return B_OK;
|
||||
}
|
||||
case B_GRADIENT_RADIAL: {
|
||||
GTRACE(("LinkReceiver::ReadGradient> type == B_GRADIENT_RADIAL\n"));
|
||||
case BGradient::TYPE_RADIAL: {
|
||||
GTRACE(("LinkReceiver::ReadGradient> type == TYPE_RADIAL\n"));
|
||||
BGradientRadial* radial = (BGradientRadial*)gradient;
|
||||
BPoint center;
|
||||
float radius;
|
||||
@@ -545,8 +545,8 @@ LinkReceiver::ReadGradient(BGradient** _gradient)
|
||||
radial->SetRadius(radius);
|
||||
return B_OK;
|
||||
}
|
||||
case B_GRADIENT_RADIAL_FOCUS: {
|
||||
GTRACE(("LinkReceiver::ReadGradient> type == B_GRADIENT_RADIAL_FOCUS\n"));
|
||||
case BGradient::TYPE_RADIAL_FOCUS: {
|
||||
GTRACE(("LinkReceiver::ReadGradient> type == TYPE_RADIAL_FOCUS\n"));
|
||||
BGradientRadialFocus* radialFocus =
|
||||
(BGradientRadialFocus*)gradient;
|
||||
BPoint center;
|
||||
@@ -563,8 +563,8 @@ LinkReceiver::ReadGradient(BGradient** _gradient)
|
||||
radialFocus->SetRadius(radius);
|
||||
return B_OK;
|
||||
}
|
||||
case B_GRADIENT_DIAMOND: {
|
||||
GTRACE(("LinkReceiver::ReadGradient> type == B_GRADIENT_DIAMOND\n"));
|
||||
case BGradient::TYPE_DIAMOND: {
|
||||
GTRACE(("LinkReceiver::ReadGradient> type == TYPE_DIAMOND\n"));
|
||||
BGradientDiamond* diamond = (BGradientDiamond*)gradient;
|
||||
BPoint center;
|
||||
if ((ret = Read(¢er, sizeof(BPoint))) != B_OK)
|
||||
@@ -572,8 +572,8 @@ LinkReceiver::ReadGradient(BGradient** _gradient)
|
||||
diamond->SetCenter(center);
|
||||
return B_OK;
|
||||
}
|
||||
case B_GRADIENT_CONIC: {
|
||||
GTRACE(("LinkReceiver::ReadGradient> type == B_GRADIENT_CONIC\n"));
|
||||
case BGradient::TYPE_CONIC: {
|
||||
GTRACE(("LinkReceiver::ReadGradient> type == TYPE_CONIC\n"));
|
||||
BGradientConic* conic = (BGradientConic*)gradient;
|
||||
BPoint center;
|
||||
float angle;
|
||||
@@ -585,8 +585,8 @@ LinkReceiver::ReadGradient(BGradient** _gradient)
|
||||
conic->SetAngle(angle);
|
||||
return B_OK;
|
||||
}
|
||||
case B_GRADIENT_NONE: {
|
||||
GTRACE(("LinkReceiver::ReadGradient> type == B_GRADIENT_NONE\n"));
|
||||
case BGradient::TYPE_NONE: {
|
||||
GTRACE(("LinkReceiver::ReadGradient> type == TYPE_NONE\n"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
+16
-16
@@ -126,21 +126,21 @@ status_t
|
||||
ServerLink::AttachGradient(const BGradient &gradient)
|
||||
{
|
||||
GTRACE(("ServerLink::AttachGradient\n"));
|
||||
gradient_type gradientType = gradient.Type();
|
||||
BGradient::gradient_type gradientType = gradient.Type();
|
||||
int32 colorsCount = gradient.CountColors();
|
||||
GTRACE(("ServerLink::AttachGradient> colors count == %d\n", (int)colorsCount));
|
||||
fSender->Attach(&gradientType, sizeof(gradient_type));
|
||||
fSender->Attach(&gradientType, sizeof(BGradient::gradient_type));
|
||||
fSender->Attach(&colorsCount, sizeof(int32));
|
||||
if (colorsCount > 0) {
|
||||
for (int i = 0; i < colorsCount; i++) {
|
||||
fSender->Attach((color_step*) gradient.ColorAtFast(i),
|
||||
sizeof(color_step));
|
||||
fSender->Attach(gradient.ColorAtFast(i),
|
||||
sizeof(BGradient::color_step));
|
||||
}
|
||||
}
|
||||
|
||||
switch(gradientType) {
|
||||
case B_GRADIENT_LINEAR: {
|
||||
GTRACE(("ServerLink::AttachGradient> type == B_GRADIENT_LINEAR\n"));
|
||||
case BGradient::TYPE_LINEAR: {
|
||||
GTRACE(("ServerLink::AttachGradient> type == TYPE_LINEAR\n"));
|
||||
const BGradientLinear* linear = (BGradientLinear*) &gradient;
|
||||
BPoint start = linear->Start();
|
||||
BPoint end = linear->End();
|
||||
@@ -148,8 +148,8 @@ ServerLink::AttachGradient(const BGradient &gradient)
|
||||
fSender->Attach(&end, sizeof(BPoint));
|
||||
break;
|
||||
}
|
||||
case B_GRADIENT_RADIAL: {
|
||||
GTRACE(("ServerLink::AttachGradient> type == B_GRADIENT_RADIAL\n"));
|
||||
case BGradient::TYPE_RADIAL: {
|
||||
GTRACE(("ServerLink::AttachGradient> type == TYPE_RADIAL\n"));
|
||||
const BGradientRadial* radial = (BGradientRadial*) &gradient;
|
||||
BPoint center = radial->Center();
|
||||
float radius = radial->Radius();
|
||||
@@ -157,8 +157,8 @@ ServerLink::AttachGradient(const BGradient &gradient)
|
||||
fSender->Attach(&radius, sizeof(float));
|
||||
break;
|
||||
}
|
||||
case B_GRADIENT_RADIAL_FOCUS: {
|
||||
GTRACE(("ServerLink::AttachGradient> type == B_GRADIENT_RADIAL_FOCUS\n"));
|
||||
case BGradient::TYPE_RADIAL_FOCUS: {
|
||||
GTRACE(("ServerLink::AttachGradient> type == TYPE_RADIAL_FOCUS\n"));
|
||||
const BGradientRadialFocus* radialFocus =
|
||||
(BGradientRadialFocus*) &gradient;
|
||||
BPoint center = radialFocus->Center();
|
||||
@@ -169,15 +169,15 @@ ServerLink::AttachGradient(const BGradient &gradient)
|
||||
fSender->Attach(&radius, sizeof(float));
|
||||
break;
|
||||
}
|
||||
case B_GRADIENT_DIAMOND: {
|
||||
GTRACE(("ServerLink::AttachGradient> type == B_GRADIENT_DIAMOND\n"));
|
||||
case BGradient::TYPE_DIAMOND: {
|
||||
GTRACE(("ServerLink::AttachGradient> type == TYPE_DIAMOND\n"));
|
||||
const BGradientDiamond* diamond = (BGradientDiamond*) &gradient;
|
||||
BPoint center = diamond->Center();
|
||||
fSender->Attach(¢er, sizeof(BPoint));
|
||||
break;
|
||||
}
|
||||
case B_GRADIENT_CONIC: {
|
||||
GTRACE(("ServerLink::AttachGradient> type == B_GRADIENT_CONIC\n"));
|
||||
case BGradient::TYPE_CONIC: {
|
||||
GTRACE(("ServerLink::AttachGradient> type == TYPE_CONIC\n"));
|
||||
const BGradientConic* conic = (BGradientConic*) &gradient;
|
||||
BPoint center = conic->Center();
|
||||
float angle = conic->Angle();
|
||||
@@ -185,8 +185,8 @@ ServerLink::AttachGradient(const BGradient &gradient)
|
||||
fSender->Attach(&angle, sizeof(float));
|
||||
break;
|
||||
}
|
||||
case B_GRADIENT_NONE: {
|
||||
GTRACE(("ServerLink::AttachGradient> type == B_GRADIENT_NONE\n"));
|
||||
case BGradient::TYPE_NONE: {
|
||||
GTRACE(("ServerLink::AttachGradient> type == TYPE_NONE\n"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
|
||||
// constructor
|
||||
color_step::color_step(const rgb_color c, float o)
|
||||
BGradient::color_step::color_step(const rgb_color c, float o)
|
||||
{
|
||||
color.red = c.red;
|
||||
color.green = c.green;
|
||||
@@ -27,7 +27,7 @@ color_step::color_step(const rgb_color c, float o)
|
||||
|
||||
|
||||
// constructor
|
||||
color_step::color_step(uint8 r, uint8 g, uint8 b, uint8 a, float o)
|
||||
BGradient::color_step::color_step(uint8 r, uint8 g, uint8 b, uint8 a, float o)
|
||||
{
|
||||
color.red = r;
|
||||
color.green = g;
|
||||
@@ -38,7 +38,7 @@ color_step::color_step(uint8 r, uint8 g, uint8 b, uint8 a, float o)
|
||||
|
||||
|
||||
// constructor
|
||||
color_step::color_step(const color_step& other)
|
||||
BGradient::color_step::color_step(const color_step& other)
|
||||
{
|
||||
color.red = other.color.red;
|
||||
color.green = other.color.green;
|
||||
@@ -49,7 +49,7 @@ color_step::color_step(const color_step& other)
|
||||
|
||||
|
||||
// constructor
|
||||
color_step::color_step()
|
||||
BGradient::color_step::color_step()
|
||||
{
|
||||
color.red = 0;
|
||||
color.green = 0;
|
||||
@@ -61,7 +61,7 @@ color_step::color_step()
|
||||
|
||||
// operator!=
|
||||
bool
|
||||
color_step::operator!=(const color_step& other) const
|
||||
BGradient::color_step::operator!=(const color_step& other) const
|
||||
{
|
||||
return color.red != other.color.red ||
|
||||
color.green != other.color.green ||
|
||||
@@ -72,19 +72,15 @@ color_step::operator!=(const color_step& other) const
|
||||
|
||||
|
||||
static int
|
||||
sort_color_steps_by_offset(const void* left, const void* right)
|
||||
sort_color_steps_by_offset(const void* _left, const void* _right)
|
||||
{
|
||||
const color_step **firstStep((const color_step**) left),
|
||||
**secondStep((const color_step**) right);
|
||||
int ret = 0;
|
||||
if ((*firstStep)->offset > (*secondStep)->offset) {
|
||||
ret = 1;
|
||||
} if ((*firstStep)->offset < (*secondStep)->offset) {
|
||||
ret = -1;
|
||||
} if ((*firstStep)->offset == (*secondStep)->offset) {
|
||||
ret = 0;
|
||||
}
|
||||
return ret;
|
||||
const BGradient::color_step** left = (const BGradient::color_step**)_left;
|
||||
const BGradient::color_step** right = (const BGradient::color_step**)_right;
|
||||
if ((*left)->offset > (*right)->offset)
|
||||
return 1;
|
||||
else if ((*left)->offset < (*right)->offset)
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -95,7 +91,7 @@ sort_color_steps_by_offset(const void* left, const void* right)
|
||||
BGradient::BGradient()
|
||||
: BArchivable(),
|
||||
fColors(4),
|
||||
fType(B_GRADIENT_NONE)
|
||||
fType(TYPE_NONE)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -104,7 +100,7 @@ BGradient::BGradient()
|
||||
BGradient::BGradient(BMessage* archive)
|
||||
: BArchivable(archive),
|
||||
fColors(4),
|
||||
fType(B_GRADIENT_NONE)
|
||||
fType(TYPE_NONE)
|
||||
{
|
||||
if (!archive)
|
||||
return;
|
||||
@@ -118,7 +114,7 @@ BGradient::BGradient(BMessage* archive)
|
||||
break;
|
||||
}
|
||||
if (archive->FindInt32("type", (int32*)&fType) < B_OK)
|
||||
fType = B_GRADIENT_LINEAR;
|
||||
fType = TYPE_LINEAR;
|
||||
|
||||
// linear
|
||||
if (archive->FindFloat("linear_x1", (float*)&fData.linear.x1) < B_OK)
|
||||
@@ -403,7 +399,7 @@ BGradient::CountColors() const
|
||||
|
||||
|
||||
// ColorAt
|
||||
color_step*
|
||||
BGradient::color_step*
|
||||
BGradient::ColorAt(int32 index) const
|
||||
{
|
||||
return (color_step*)fColors.ItemAt(index);
|
||||
@@ -411,7 +407,7 @@ BGradient::ColorAt(int32 index) const
|
||||
|
||||
|
||||
// ColorAtFast
|
||||
color_step*
|
||||
BGradient::color_step*
|
||||
BGradient::ColorAtFast(int32 index) const
|
||||
{
|
||||
return (color_step*)fColors.ItemAtFast(index);
|
||||
@@ -419,7 +415,7 @@ BGradient::ColorAtFast(int32 index) const
|
||||
|
||||
|
||||
// Colors
|
||||
color_step*
|
||||
BGradient::color_step*
|
||||
BGradient::Colors() const
|
||||
{
|
||||
if (CountColors() > 0) {
|
||||
|
||||
@@ -17,7 +17,7 @@ BGradientConic::BGradientConic()
|
||||
fData.conic.cx = 0.0f;
|
||||
fData.conic.cy = 0.0f;
|
||||
fData.conic.angle = 0.0f;
|
||||
fType = B_GRADIENT_CONIC;
|
||||
fType = TYPE_CONIC;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ BGradientConic::BGradientConic(const BPoint& center, float angle)
|
||||
fData.conic.cx = center.x;
|
||||
fData.conic.cy = center.y;
|
||||
fData.conic.angle = angle;
|
||||
fType = B_GRADIENT_CONIC;
|
||||
fType = TYPE_CONIC;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ BGradientConic::BGradientConic(float cx, float cy, float angle)
|
||||
fData.conic.cx = cx;
|
||||
fData.conic.cy = cy;
|
||||
fData.conic.angle = angle;
|
||||
fType = B_GRADIENT_CONIC;
|
||||
fType = TYPE_CONIC;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ BGradientDiamond::BGradientDiamond()
|
||||
{
|
||||
fData.diamond.cx = 0.0f;
|
||||
fData.diamond.cy = 0.0f;
|
||||
fType = B_GRADIENT_DIAMOND;
|
||||
fType = TYPE_DIAMOND;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ BGradientDiamond::BGradientDiamond(const BPoint& center)
|
||||
{
|
||||
fData.diamond.cx = center.x;
|
||||
fData.diamond.cy = center.y;
|
||||
fType = B_GRADIENT_DIAMOND;
|
||||
fType = TYPE_DIAMOND;
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ BGradientDiamond::BGradientDiamond(float cx, float cy)
|
||||
{
|
||||
fData.diamond.cx = cx;
|
||||
fData.diamond.cy = cy;
|
||||
fType = B_GRADIENT_DIAMOND;
|
||||
fType = TYPE_DIAMOND;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ BGradientLinear::BGradientLinear()
|
||||
fData.linear.y1 = 0.0f;
|
||||
fData.linear.x2 = 0.0f;
|
||||
fData.linear.y2 = 0.0f;
|
||||
fType = B_GRADIENT_LINEAR;
|
||||
fType = TYPE_LINEAR;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ BGradientLinear::BGradientLinear(const BPoint& start, const BPoint& end)
|
||||
fData.linear.y1 = start.y;
|
||||
fData.linear.x2 = end.x;
|
||||
fData.linear.y2 = end.y;
|
||||
fType = B_GRADIENT_LINEAR;
|
||||
fType = TYPE_LINEAR;
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ BGradientLinear::BGradientLinear(float x1, float y1, float x2, float y2)
|
||||
fData.linear.y1 = y1;
|
||||
fData.linear.x2 = x2;
|
||||
fData.linear.y2 = y2;
|
||||
fType = B_GRADIENT_LINEAR;
|
||||
fType = TYPE_LINEAR;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ BGradientRadial::BGradientRadial()
|
||||
fData.radial.cx = 0.0f;
|
||||
fData.radial.cy = 0.0f;
|
||||
fData.radial.radius = 0.0f;
|
||||
fType = B_GRADIENT_RADIAL;
|
||||
fType = TYPE_RADIAL;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ BGradientRadial::BGradientRadial(const BPoint& center, float radius)
|
||||
fData.radial.cx = center.x;
|
||||
fData.radial.cy = center.y;
|
||||
fData.radial.radius = radius;
|
||||
fType = B_GRADIENT_RADIAL;
|
||||
fType = TYPE_RADIAL;
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ BGradientRadial::BGradientRadial(float cx, float cy, float radius)
|
||||
fData.radial.cx = cx;
|
||||
fData.radial.cy = cy;
|
||||
fData.radial.radius = radius;
|
||||
fType = B_GRADIENT_RADIAL;
|
||||
fType = TYPE_RADIAL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ BGradientRadialFocus::BGradientRadialFocus()
|
||||
fData.radial_focus.fx = 0.0f;
|
||||
fData.radial_focus.fy = 0.0f;
|
||||
fData.radial_focus.radius = 0.0f;
|
||||
fType = B_GRADIENT_RADIAL_FOCUS;
|
||||
fType = TYPE_RADIAL_FOCUS;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ BGradientRadialFocus::BGradientRadialFocus(const BPoint& center, float radius,
|
||||
fData.radial_focus.fx = focal.x;
|
||||
fData.radial_focus.fy = focal.y;
|
||||
fData.radial_focus.radius = radius;
|
||||
fType = B_GRADIENT_RADIAL_FOCUS;
|
||||
fType = TYPE_RADIAL_FOCUS;
|
||||
}
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ BGradientRadialFocus::BGradientRadialFocus(float cx, float cy, float radius,
|
||||
fData.radial_focus.fx = fx;
|
||||
fData.radial_focus.fy = fy;
|
||||
fData.radial_focus.radius = radius;
|
||||
fType = B_GRADIENT_RADIAL_FOCUS;
|
||||
fType = TYPE_RADIAL_FOCUS;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -33,8 +33,8 @@ Gradient::Gradient(bool empty)
|
||||
fInheritTransformation(true)
|
||||
{
|
||||
if (!empty) {
|
||||
AddColor(color_step(0, 0, 0, 255, 0.0), 0);
|
||||
AddColor(color_step(255, 255, 255, 255, 1.0), 1);
|
||||
AddColor(BGradient::color_step(0, 0, 0, 255, 0.0), 0);
|
||||
AddColor(BGradient::color_step(255, 255, 255, 255, 1.0), 1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ Gradient::Gradient(BMessage* archive)
|
||||
LoadFrom((const double*)matrix);
|
||||
|
||||
// color steps
|
||||
color_step step;
|
||||
BGradient::color_step step;
|
||||
for (int32 i = 0; archive->FindFloat("offset", i, &step.offset) >= B_OK; i++) {
|
||||
if (archive->FindInt32("color", i, (int32*)&step.color) >= B_OK)
|
||||
AddColor(step, i);
|
||||
@@ -97,7 +97,7 @@ Gradient::Gradient(const Gradient& other)
|
||||
fInterpolation(other.fInterpolation),
|
||||
fInheritTransformation(other.fInheritTransformation)
|
||||
{
|
||||
for (int32 i = 0; color_step* step = other.ColorAt(i); i++) {
|
||||
for (int32 i = 0; BGradient::color_step* step = other.ColorAt(i); i++) {
|
||||
AddColor(*step, i);
|
||||
}
|
||||
}
|
||||
@@ -126,7 +126,7 @@ Gradient::Archive(BMessage* into, bool deep) const
|
||||
|
||||
// color steps
|
||||
if (ret >= B_OK) {
|
||||
for (int32 i = 0; color_step* step = ColorAt(i); i++) {
|
||||
for (int32 i = 0; BGradient::color_step* step = ColorAt(i); i++) {
|
||||
ret = into->AddInt32("color", (const uint32&)step->color);
|
||||
if (ret < B_OK)
|
||||
break;
|
||||
@@ -198,8 +198,8 @@ Gradient::ColorStepsAreEqual(const Gradient& other) const
|
||||
|
||||
bool equal = true;
|
||||
for (int32 i = 0; i < count; i++) {
|
||||
color_step* ourStep = ColorAtFast(i);
|
||||
color_step* otherStep = other.ColorAtFast(i);
|
||||
BGradient::color_step* ourStep = ColorAtFast(i);
|
||||
BGradient::color_step* otherStep = other.ColorAtFast(i);
|
||||
if (*ourStep != *otherStep) {
|
||||
equal = false;
|
||||
break;
|
||||
@@ -219,7 +219,7 @@ Gradient::SetColors(const Gradient& other)
|
||||
#endif
|
||||
|
||||
_MakeEmpty();
|
||||
for (int32 i = 0; color_step* step = other.ColorAt(i); i++)
|
||||
for (int32 i = 0; BGradient::color_step* step = other.ColorAt(i); i++)
|
||||
AddColor(*step, i);
|
||||
|
||||
Notify();
|
||||
@@ -232,11 +232,11 @@ int32
|
||||
Gradient::AddColor(const rgb_color& color, float offset)
|
||||
{
|
||||
// find the correct index (sorted by offset)
|
||||
color_step* step = new color_step(color, offset);
|
||||
BGradient::color_step* step = new BGradient::color_step(color, offset);
|
||||
int32 index = 0;
|
||||
int32 count = CountColors();
|
||||
for (; index < count; index++) {
|
||||
color_step* s = ColorAtFast(index);
|
||||
BGradient::color_step* s = ColorAtFast(index);
|
||||
if (s->offset > step->offset)
|
||||
break;
|
||||
}
|
||||
@@ -250,9 +250,9 @@ Gradient::AddColor(const rgb_color& color, float offset)
|
||||
|
||||
// AddColor
|
||||
bool
|
||||
Gradient::AddColor(const color_step& color, int32 index)
|
||||
Gradient::AddColor(const BGradient::color_step& color, int32 index)
|
||||
{
|
||||
color_step* step = new color_step(color);
|
||||
BGradient::color_step* step = new BGradient::color_step(color);
|
||||
if (!fColors.AddItem((void*)step, index)) {
|
||||
delete step;
|
||||
return false;
|
||||
@@ -265,7 +265,8 @@ Gradient::AddColor(const color_step& color, int32 index)
|
||||
bool
|
||||
Gradient::RemoveColor(int32 index)
|
||||
{
|
||||
color_step* step = (color_step*)fColors.RemoveItem(index);
|
||||
BGradient::color_step* step
|
||||
= (BGradient::color_step*)fColors.RemoveItem(index);
|
||||
if (!step) {
|
||||
return false;
|
||||
}
|
||||
@@ -278,9 +279,9 @@ Gradient::RemoveColor(int32 index)
|
||||
|
||||
// SetColor
|
||||
bool
|
||||
Gradient::SetColor(int32 index, const color_step& color)
|
||||
Gradient::SetColor(int32 index, const BGradient::color_step& color)
|
||||
{
|
||||
if (color_step* step = ColorAt(index)) {
|
||||
if (BGradient::color_step* step = ColorAt(index)) {
|
||||
if (*step != color) {
|
||||
step->color = color.color;
|
||||
step->offset = color.offset;
|
||||
@@ -295,7 +296,7 @@ Gradient::SetColor(int32 index, const color_step& color)
|
||||
bool
|
||||
Gradient::SetColor(int32 index, const rgb_color& color)
|
||||
{
|
||||
if (color_step* step = ColorAt(index)) {
|
||||
if (BGradient::color_step* step = ColorAt(index)) {
|
||||
if ((uint32&)step->color != (uint32&)color) {
|
||||
step->color = color;
|
||||
Notify();
|
||||
@@ -309,7 +310,7 @@ Gradient::SetColor(int32 index, const rgb_color& color)
|
||||
bool
|
||||
Gradient::SetOffset(int32 index, float offset)
|
||||
{
|
||||
color_step* step = ColorAt(index);
|
||||
BGradient::color_step* step = ColorAt(index);
|
||||
if (step && step->offset != offset) {
|
||||
step->offset = offset;
|
||||
Notify();
|
||||
@@ -328,17 +329,17 @@ Gradient::CountColors() const
|
||||
}
|
||||
|
||||
// ColorAt
|
||||
color_step*
|
||||
BGradient::color_step*
|
||||
Gradient::ColorAt(int32 index) const
|
||||
{
|
||||
return (color_step*)fColors.ItemAt(index);
|
||||
return (BGradient::color_step*)fColors.ItemAt(index);
|
||||
}
|
||||
|
||||
// ColorAtFast
|
||||
color_step*
|
||||
BGradient::color_step*
|
||||
Gradient::ColorAtFast(int32 index) const
|
||||
{
|
||||
return (color_step*)fColors.ItemAtFast(index);
|
||||
return (BGradient::color_step*)fColors.ItemAtFast(index);
|
||||
}
|
||||
|
||||
// #pragma mark -
|
||||
@@ -394,13 +395,13 @@ gauss(double f)
|
||||
void
|
||||
Gradient::MakeGradient(uint32* colors, int32 count) const
|
||||
{
|
||||
color_step* from = ColorAt(0);
|
||||
BGradient::color_step* from = ColorAt(0);
|
||||
|
||||
if (!from)
|
||||
return;
|
||||
|
||||
// find the step with the lowest offset
|
||||
for (int32 i = 0; color_step* step = ColorAt(i); i++) {
|
||||
for (int32 i = 0; BGradient::color_step* step = ColorAt(i); i++) {
|
||||
if (step->offset < from->offset)
|
||||
from = step;
|
||||
}
|
||||
@@ -425,7 +426,7 @@ Gradient::MakeGradient(uint32* colors, int32 count) const
|
||||
|
||||
// put all steps that we need to interpolate to into a list
|
||||
BList nextSteps(fColors.CountItems() - 1);
|
||||
for (int32 i = 0; color_step* step = ColorAt(i); i++) {
|
||||
for (int32 i = 0; BGradient::color_step* step = ColorAt(i); i++) {
|
||||
if (step != from)
|
||||
nextSteps.AddItem((void*)step);
|
||||
}
|
||||
@@ -434,9 +435,10 @@ Gradient::MakeGradient(uint32* colors, int32 count) const
|
||||
while (!nextSteps.IsEmpty()) {
|
||||
|
||||
// find the step with the next offset
|
||||
color_step* to = NULL;
|
||||
BGradient::color_step* to = NULL;
|
||||
float nextOffsetDist = 2.0;
|
||||
for (int32 i = 0; color_step* step = (color_step*)nextSteps.ItemAt(i); i++) {
|
||||
for (int32 i = 0; BGradient::color_step* step
|
||||
= (BGradient::color_step*)nextSteps.ItemAt(i); i++) {
|
||||
float d = step->offset - from->offset;
|
||||
if (d < nextOffsetDist && d >= 0) {
|
||||
to = step;
|
||||
@@ -586,7 +588,7 @@ Gradient::PrintToStream() const
|
||||
string_for_type(fType),
|
||||
string_for_interpolation(fInterpolation),
|
||||
fInheritTransformation);
|
||||
for (int32 i = 0; color_step* step = ColorAt(i); i++) {
|
||||
for (int32 i = 0; BGradient::color_step* step = ColorAt(i); i++) {
|
||||
printf(" %ld: offset: %.1f -> color(%d, %d, %d, %d)\n",
|
||||
i, step->offset,
|
||||
step->color.red,
|
||||
|
||||
@@ -73,17 +73,19 @@ class Gradient : public Transformable {
|
||||
|
||||
|
||||
int32 AddColor(const rgb_color& color, float offset);
|
||||
bool AddColor(const color_step& color, int32 index);
|
||||
bool AddColor(const BGradient::color_step& color,
|
||||
int32 index);
|
||||
|
||||
bool RemoveColor(int32 index);
|
||||
|
||||
bool SetColor(int32 index, const color_step& step);
|
||||
bool SetColor(int32 index,
|
||||
const BGradient::color_step& step);
|
||||
bool SetColor(int32 index, const rgb_color& color);
|
||||
bool SetOffset(int32 index, float offset);
|
||||
|
||||
int32 CountColors() const;
|
||||
color_step* ColorAt(int32 index) const;
|
||||
color_step* ColorAtFast(int32 index) const;
|
||||
BGradient::color_step* ColorAt(int32 index) const;
|
||||
BGradient::color_step* ColorAtFast(int32 index) const;
|
||||
|
||||
void SetType(gradients_type type);
|
||||
gradients_type Type() const
|
||||
|
||||
@@ -169,7 +169,7 @@ Style::HasTransparency() const
|
||||
if (fGradient) {
|
||||
int32 count = fGradient->CountColors();
|
||||
for (int32 i = 0; i < count; i++) {
|
||||
color_step* step = fGradient->ColorAtFast(i);
|
||||
BGradient::color_step* step = fGradient->ColorAtFast(i);
|
||||
if (step->color.alpha < 255)
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -815,7 +815,7 @@ void
|
||||
View::ConvertToScreenForDrawing(BGradient* gradient) const
|
||||
{
|
||||
switch(gradient->Type()) {
|
||||
case B_GRADIENT_LINEAR: {
|
||||
case BGradient::TYPE_LINEAR: {
|
||||
BGradientLinear* linear = (BGradientLinear*) gradient;
|
||||
BPoint start = linear->Start();
|
||||
BPoint end = linear->End();
|
||||
@@ -828,7 +828,7 @@ View::ConvertToScreenForDrawing(BGradient* gradient) const
|
||||
linear->SortColorStepsByOffset();
|
||||
break;
|
||||
}
|
||||
case B_GRADIENT_RADIAL: {
|
||||
case BGradient::TYPE_RADIAL: {
|
||||
BGradientRadial* radial = (BGradientRadial*) gradient;
|
||||
BPoint center = radial->Center();
|
||||
fDrawState->Transform(¢er);
|
||||
@@ -837,7 +837,7 @@ View::ConvertToScreenForDrawing(BGradient* gradient) const
|
||||
radial->SortColorStepsByOffset();
|
||||
break;
|
||||
}
|
||||
case B_GRADIENT_RADIAL_FOCUS: {
|
||||
case BGradient::TYPE_RADIAL_FOCUS: {
|
||||
BGradientRadialFocus* radialFocus = (BGradientRadialFocus*) gradient;
|
||||
BPoint center = radialFocus->Center();
|
||||
BPoint focal = radialFocus->Focal();
|
||||
@@ -850,7 +850,7 @@ View::ConvertToScreenForDrawing(BGradient* gradient) const
|
||||
radialFocus->SortColorStepsByOffset();
|
||||
break;
|
||||
}
|
||||
case B_GRADIENT_DIAMOND: {
|
||||
case BGradient::TYPE_DIAMOND: {
|
||||
BGradientDiamond* diamond = (BGradientDiamond*) gradient;
|
||||
BPoint center = diamond->Center();
|
||||
fDrawState->Transform(¢er);
|
||||
@@ -859,7 +859,7 @@ View::ConvertToScreenForDrawing(BGradient* gradient) const
|
||||
diamond->SortColorStepsByOffset();
|
||||
break;
|
||||
}
|
||||
case B_GRADIENT_CONIC: {
|
||||
case BGradient::TYPE_CONIC: {
|
||||
BGradientConic* conic = (BGradientConic*) gradient;
|
||||
BPoint center = conic->Center();
|
||||
fDrawState->Transform(¢er);
|
||||
@@ -868,7 +868,7 @@ View::ConvertToScreenForDrawing(BGradient* gradient) const
|
||||
conic->SortColorStepsByOffset();
|
||||
break;
|
||||
}
|
||||
case B_GRADIENT_NONE: {
|
||||
case BGradient::TYPE_NONE: {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2521,37 +2521,37 @@ Painter::_FillPathGradient(VertexSource& path, const BGradient& gradient) const
|
||||
GTRACE("Painter::_FillPathGradient\n");
|
||||
|
||||
switch(gradient.Type()) {
|
||||
case B_GRADIENT_LINEAR: {
|
||||
GTRACE(("Painter::_FillPathGradient> type == B_GRADIENT_LINEAR\n"));
|
||||
case BGradient::TYPE_LINEAR: {
|
||||
GTRACE(("Painter::_FillPathGradient> type == TYPE_LINEAR\n"));
|
||||
_FillPathGradientLinear(path, *((const BGradientLinear*) &gradient));
|
||||
break;
|
||||
}
|
||||
case B_GRADIENT_RADIAL: {
|
||||
GTRACE(("Painter::_FillPathGradient> type == B_GRADIENT_RADIAL\n"));
|
||||
case BGradient::TYPE_RADIAL: {
|
||||
GTRACE(("Painter::_FillPathGradient> type == TYPE_RADIAL\n"));
|
||||
_FillPathGradientRadial(path,
|
||||
*((const BGradientRadial*) &gradient));
|
||||
break;
|
||||
}
|
||||
case B_GRADIENT_RADIAL_FOCUS: {
|
||||
GTRACE(("Painter::_FillPathGradient> type == B_GRADIENT_RADIAL_FOCUS\n"));
|
||||
case BGradient::TYPE_RADIAL_FOCUS: {
|
||||
GTRACE(("Painter::_FillPathGradient> type == TYPE_RADIAL_FOCUS\n"));
|
||||
_FillPathGradientRadialFocus(path,
|
||||
*((const BGradientRadialFocus*) &gradient));
|
||||
break;
|
||||
}
|
||||
case B_GRADIENT_DIAMOND: {
|
||||
GTRACE(("Painter::_FillPathGradient> type == B_GRADIENT_DIAMOND\n"));
|
||||
case BGradient::TYPE_DIAMOND: {
|
||||
GTRACE(("Painter::_FillPathGradient> type == TYPE_DIAMOND\n"));
|
||||
_FillPathGradientDiamond(path,
|
||||
*((const BGradientDiamond*) &gradient));
|
||||
break;
|
||||
}
|
||||
case B_GRADIENT_CONIC: {
|
||||
GTRACE(("Painter::_FillPathGradient> type == B_GRADIENT_CONIC\n"));
|
||||
case BGradient::TYPE_CONIC: {
|
||||
GTRACE(("Painter::_FillPathGradient> type == TYPE_CONIC\n"));
|
||||
_FillPathGradientConic(path,
|
||||
*((const BGradientConic*) &gradient));
|
||||
break;
|
||||
}
|
||||
case B_GRADIENT_NONE: {
|
||||
GTRACE(("Painter::_FillPathGradient> type == B_GRADIENT_NONE\n"));
|
||||
case BGradient::TYPE_NONE: {
|
||||
GTRACE(("Painter::_FillPathGradient> type == TYPE_NONE\n"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -2565,8 +2565,8 @@ void
|
||||
Painter::_MakeGradient(Array& array, const BGradient& gradient) const
|
||||
{
|
||||
for (int i = 0; i < gradient.CountColors() - 1; i++) {
|
||||
color_step* from = gradient.ColorAtFast(i);
|
||||
color_step* to = gradient.ColorAtFast(i + 1);
|
||||
BGradient::color_step* from = gradient.ColorAtFast(i);
|
||||
BGradient::color_step* to = gradient.ColorAtFast(i + 1);
|
||||
agg::rgba8 fromColor(from->color.red, from->color.green,
|
||||
from->color.blue, from->color.alpha);
|
||||
agg::rgba8 toColor(to->color.red, to->color.green,
|
||||
@@ -2577,8 +2577,9 @@ Painter::_MakeGradient(Array& array, const BGradient& gradient) const
|
||||
toColor.r, toColor.g, toColor.b, to->offset);
|
||||
float dist = to->offset - from->offset;
|
||||
GTRACE("Painter::_MakeGradient> dist = %f\n", dist);
|
||||
// TODO: Review this... offset should better be on [0..1]
|
||||
if (dist > 0) {
|
||||
for (int j = from->offset; j <= to->offset; j++) {
|
||||
for (int j = (int)from->offset; j <= (int)to->offset; j++) {
|
||||
float f = (float)(to->offset - j) / (float)(dist + 1);
|
||||
array[j] = toColor.gradient(fromColor, f);
|
||||
GTRACE("Painter::_MakeGradient> array[%d](%d, %d, %d)\n",
|
||||
@@ -2652,7 +2653,8 @@ Painter::_FillPathGradientRadial(VertexSource& path,
|
||||
GTRACE("Painter::_FillPathGradientRadial\n");
|
||||
|
||||
BPoint center = radial.Center();
|
||||
float radius = radial.Radius();
|
||||
// TODO: finish this
|
||||
// float radius = radial.Radius();
|
||||
|
||||
typedef agg::span_interpolator_linear<> interpolator_type;
|
||||
typedef agg::pod_auto_array<agg::rgba8, 256> color_array_type;
|
||||
@@ -2697,8 +2699,9 @@ Painter::_FillPathGradientRadialFocus(VertexSource& path,
|
||||
GTRACE("Painter::_FillPathGradientRadialFocus\n");
|
||||
|
||||
BPoint center = focus.Center();
|
||||
BPoint focal = focus.Focal();
|
||||
float radius = focus.Radius();
|
||||
// TODO: finish this.
|
||||
// BPoint focal = focus.Focal();
|
||||
// float radius = focus.Radius();
|
||||
|
||||
typedef agg::span_interpolator_linear<> interpolator_type;
|
||||
typedef agg::pod_auto_array<agg::rgba8, 256> color_array_type;
|
||||
|
||||
Reference in New Issue
Block a user