本文整理汇总了C++中Style::Gradient方法的典型用法代码示例。如果您正苦于以下问题:C++ Style::Gradient方法的具体用法?C++ Style::Gradient怎么用?C++ Style::Gradient使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Style
的用法示例。
在下文中一共展示了Style::Gradient方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: locker
//.........这里部分代码省略.........
B_TRANSLATE_CONTEXT("Add shape with style",
"Icon-O-Matic-Menu-Shape"),
0);
} else {
Command** commands = new Command*[2];
commands[0] = pathCommand;
commands[1] = shapeCommand;
command = new CompoundCommand(commands, 2,
B_TRANSLATE_CONTEXT("Add shape with path",
"Icon-O-Matic-Menu-Shape"),
0);
}
} else {
command = shapeCommand;
}
fDocument->CommandStack()->Perform(command);
break;
}
// TODO: listen to selection in CanvasView to add a manipulator
case MSG_PATH_SELECTED: {
VectorPath* path;
if (message->FindPointer("path", (void**)&path) < B_OK)
path = NULL;
fPathListView->SetCurrentShape(NULL);
fStyleListView->SetCurrentShape(NULL);
fTransformerListView->SetShape(NULL);
fState->DeleteManipulators();
if (fDocument->Icon()->Paths()->HasPath(path)) {
PathManipulator* pathManipulator = new (nothrow) PathManipulator(path);
fState->AddManipulator(pathManipulator);
}
break;
}
case MSG_STYLE_SELECTED:
case MSG_STYLE_TYPE_CHANGED: {
Style* style;
if (message->FindPointer("style", (void**)&style) < B_OK)
style = NULL;
if (!fDocument->Icon()->Styles()->HasStyle(style))
style = NULL;
fStyleView->SetStyle(style);
fPathListView->SetCurrentShape(NULL);
fStyleListView->SetCurrentShape(NULL);
fTransformerListView->SetShape(NULL);
fState->DeleteManipulators();
Gradient* gradient = style ? style->Gradient() : NULL;
if (gradient != NULL) {
TransformGradientBox* transformBox
= new (nothrow) TransformGradientBox(fCanvasView, gradient, NULL);
fState->AddManipulator(transformBox);
}
break;
}
case MSG_SHAPE_SELECTED: {
Shape* shape;
if (message->FindPointer("shape", (void**)&shape) < B_OK)
shape = NULL;
if (!fIcon || !fIcon->Shapes()->HasShape(shape))
shape = NULL;
fPathListView->SetCurrentShape(shape);
fStyleListView->SetCurrentShape(shape);
fTransformerListView->SetShape(shape);
BList selectedShapes;
ShapeContainer* shapes = fDocument->Icon()->Shapes();
int32 count = shapes->CountShapes();
for (int32 i = 0; i < count; i++) {
shape = shapes->ShapeAtFast(i);
if (shape->IsSelected()) {
selectedShapes.AddItem((void*)shape);
}
}
fState->DeleteManipulators();
if (selectedShapes.CountItems() > 0) {
TransformShapesBox* transformBox = new (nothrow) TransformShapesBox(
fCanvasView,
(const Shape**)selectedShapes.Items(),
selectedShapes.CountItems());
fState->AddManipulator(transformBox);
}
break;
}
case MSG_RENAME_OBJECT:
fPropertyListView->FocusNameProperty();
break;
default:
BWindow::MessageReceived(message);
}
if (requiresWriteLock)
fDocument->WriteUnlock();
}
示例2: if
// _WriteStyles
status_t
FlatIconExporter::_WriteStyles(LittleEndianBuffer& buffer,
StyleContainer* styles)
{
uint8 styleCount = min_c(255, styles->CountStyles());
if (!buffer.Write(styleCount))
return B_NO_MEMORY;
for (int32 i = 0; i < styleCount; i++) {
Style* style = styles->StyleAtFast(i);
// style type
uint8 styleType;
const Gradient* gradient = style->Gradient();
if (gradient) {
styleType = STYLE_TYPE_GRADIENT;
} else {
rgb_color color = style->Color();
if (color.red == color.green && color.red == color.blue) {
// gray
if (style->Color().alpha == 255)
styleType = STYLE_TYPE_SOLID_GRAY_NO_ALPHA;
else
styleType = STYLE_TYPE_SOLID_GRAY;
} else {
// color
if (style->Color().alpha == 255)
styleType = STYLE_TYPE_SOLID_COLOR_NO_ALPHA;
else
styleType = STYLE_TYPE_SOLID_COLOR;
}
}
if (!buffer.Write(styleType))
return B_NO_MEMORY;
if (styleType == STYLE_TYPE_SOLID_COLOR) {
// solid color
rgb_color color = style->Color();
if (!buffer.Write(*(uint32*)&color))
return B_NO_MEMORY;
} else if (styleType == STYLE_TYPE_SOLID_COLOR_NO_ALPHA) {
// solid color without alpha
rgb_color color = style->Color();
if (!buffer.Write(color.red)
|| !buffer.Write(color.green)
|| !buffer.Write(color.blue))
return B_NO_MEMORY;
} else if (styleType == STYLE_TYPE_SOLID_GRAY) {
// solid gray
rgb_color color = style->Color();
if (!buffer.Write(color.red)
|| !buffer.Write(color.alpha))
return B_NO_MEMORY;
} else if (styleType == STYLE_TYPE_SOLID_GRAY_NO_ALPHA) {
// solid gray without alpha
if (!buffer.Write(style->Color().red))
return B_NO_MEMORY;
} else if (styleType == STYLE_TYPE_GRADIENT) {
// gradient
if (!_WriteGradient(buffer, gradient))
return B_NO_MEMORY;
}
}
return B_OK;
}