本文整理汇总了C++中ObjectGroup::drawOrder方法的典型用法代码示例。如果您正苦于以下问题:C++ ObjectGroup::drawOrder方法的具体用法?C++ ObjectGroup::drawOrder怎么用?C++ ObjectGroup::drawOrder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ObjectGroup
的用法示例。
在下文中一共展示了ObjectGroup::drawOrder方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: applyObjectGroupValue
void PropertyBrowser::applyObjectGroupValue(PropertyId id, const QVariant &val)
{
ObjectGroup *objectGroup = static_cast<ObjectGroup*>(mObject);
QUndoCommand *command = 0;
switch (id) {
case ColorProperty: {
QColor color = val.value<QColor>();
if (color == Qt::gray)
color = QColor();
command = new ChangeObjectGroupProperties(mMapDocument,
objectGroup,
color,
objectGroup->drawOrder());
break;
}
case DrawOrderProperty: {
ObjectGroup::DrawOrder drawOrder = static_cast<ObjectGroup::DrawOrder>(val.toInt());
command = new ChangeObjectGroupProperties(mMapDocument,
objectGroup,
objectGroup->color(),
drawOrder);
break;
}
default:
break;
}
if (command)
mMapDocument->undoStack()->push(command);
}
示例2: toVariant
QVariant MapToVariantConverter::toVariant(const ObjectGroup &objectGroup) const
{
QVariantMap objectGroupVariant;
objectGroupVariant[QLatin1String("type")] = QLatin1String("objectgroup");
if (objectGroup.color().isValid())
objectGroupVariant[QLatin1String("color")] = colorToString(objectGroup.color());
objectGroupVariant[QLatin1String("draworder")] = drawOrderToString(objectGroup.drawOrder());
addLayerAttributes(objectGroupVariant, objectGroup);
QVariantList objectVariants;
for (const MapObject *object : objectGroup.objects())
objectVariants << toVariant(*object);
objectGroupVariant[QLatin1String("objects")] = objectVariants;
return objectGroupVariant;
}
示例3: showContextMenu
/**
* Shows the context menu for map objects. The menu allows you to duplicate and
* remove the map objects, or to edit their properties.
*/
void AbstractObjectTool::showContextMenu(MapObjectItem *clickedObjectItem,
QPoint screenPos)
{
QSet<MapObjectItem *> selection = mMapScene->selectedObjectItems();
if (clickedObjectItem && !selection.contains(clickedObjectItem)) {
selection.clear();
selection.insert(clickedObjectItem);
mMapScene->setSelectedObjectItems(selection);
}
if (selection.isEmpty())
return;
const QList<MapObject*> &selectedObjects = mapDocument()->selectedObjects();
const QList<ObjectGroup*> objectGroups = mapDocument()->map()->objectGroups();
QMenu menu;
QAction *duplicateAction = menu.addAction(tr("Duplicate %n Object(s)", "", selection.size()),
this, SLOT(duplicateObjects()));
QAction *removeAction = menu.addAction(tr("Remove %n Object(s)", "", selection.size()),
this, SLOT(removeObjects()));
duplicateAction->setIcon(QIcon(QLatin1String(":/images/16x16/stock-duplicate-16.png")));
removeAction->setIcon(QIcon(QLatin1String(":/images/16x16/edit-delete.png")));
bool anyTileObjectSelected = std::any_of(selectedObjects.begin(),
selectedObjects.end(),
isTileObject);
if (anyTileObjectSelected) {
auto resetTileSizeAction = menu.addAction(tr("Reset Tile Size"), this, SLOT(resetTileSize()));
resetTileSizeAction->setEnabled(std::any_of(selectedObjects.begin(),
selectedObjects.end(),
isResizedTileObject));
auto changeTileAction = menu.addAction(tr("Replace Tile"), this, SLOT(changeTile()));
changeTileAction->setEnabled(tile());
}
// Create action for replacing an object with a template
auto selectedTemplate = objectTemplate();
auto replaceTemplateAction = menu.addAction(tr("Replace With Template"), this, SLOT(replaceObjectsWithTemplate()));
if (selectedTemplate) {
QString name = QFileInfo(selectedTemplate->fileName()).fileName();
replaceTemplateAction->setText(tr("Replace With Template \"%1\"").arg(name));
} else {
replaceTemplateAction->setEnabled(false);
}
if (selectedObjects.size() == 1) {
MapObject *currentObject = selectedObjects.first();
if (!(currentObject->isTemplateBase() || currentObject->isTemplateInstance())) {
const Cell cell = selectedObjects.first()->cell();
// Saving objects with embedded tilesets is disabled
if (cell.isEmpty() || cell.tileset()->isExternal())
menu.addAction(tr("Save As Template"), this, SLOT(saveSelectedObject()));
}
if (currentObject->isTemplateBase()) { // Hide this operations for template base
duplicateAction->setVisible(false);
removeAction->setVisible(false);
replaceTemplateAction->setVisible(false);
}
}
bool anyIsTemplateInstance = std::any_of(selectedObjects.begin(),
selectedObjects.end(),
[](MapObject *object) { return object->isTemplateInstance(); });
if (anyIsTemplateInstance) {
menu.addAction(tr("Detach"), this, SLOT(detachSelectedObjects()));
auto resetToTemplateAction = menu.addAction(tr("Reset Template Instance(s)"), this, SLOT(resetInstances()));
resetToTemplateAction->setEnabled(std::any_of(selectedObjects.begin(),
selectedObjects.end(),
isChangedTemplateInstance));
}
menu.addSeparator();
menu.addAction(tr("Flip Horizontally"), this, SLOT(flipHorizontally()), QKeySequence(tr("X")));
menu.addAction(tr("Flip Vertically"), this, SLOT(flipVertically()), QKeySequence(tr("Y")));
ObjectGroup *objectGroup = RaiseLowerHelper::sameObjectGroup(selection);
if (objectGroup && objectGroup->drawOrder() == ObjectGroup::IndexOrder) {
menu.addSeparator();
menu.addAction(tr("Raise Object"), this, SLOT(raise()), QKeySequence(tr("PgUp")));
menu.addAction(tr("Lower Object"), this, SLOT(lower()), QKeySequence(tr("PgDown")));
menu.addAction(tr("Raise Object to Top"), this, SLOT(raiseToTop()), QKeySequence(tr("Home")));
menu.addAction(tr("Lower Object to Bottom"), this, SLOT(lowerToBottom()), QKeySequence(tr("End")));
}
if (objectGroups.size() > 1) {
menu.addSeparator();
QMenu *moveToLayerMenu = menu.addMenu(tr("Move %n Object(s) to Layer",
"", selectedObjects.size()));
//.........这里部分代码省略.........
示例4: showContextMenu
/**
* Shows the context menu for map objects. The menu allows you to duplicate and
* remove the map objects, or to edit their properties.
*/
void AbstractObjectTool::showContextMenu(MapObjectItem *clickedObjectItem,
QPoint screenPos)
{
QSet<MapObjectItem *> selection = mMapScene->selectedObjectItems();
if (clickedObjectItem && !selection.contains(clickedObjectItem)) {
selection.clear();
selection.insert(clickedObjectItem);
mMapScene->setSelectedObjectItems(selection);
}
if (selection.isEmpty())
return;
const QList<MapObject*> &selectedObjects = mapDocument()->selectedObjects();
const QList<ObjectGroup*> objectGroups = mapDocument()->map()->objectGroups();
QMenu menu;
QAction *duplicateAction = menu.addAction(tr("Duplicate %n Object(s)", "", selection.size()),
this, SLOT(duplicateObjects()));
QAction *removeAction = menu.addAction(tr("Remove %n Object(s)", "", selection.size()),
this, SLOT(removeObjects()));
duplicateAction->setIcon(QIcon(QLatin1String(":/images/16x16/stock-duplicate-16.png")));
removeAction->setIcon(QIcon(QLatin1String(":/images/16x16/edit-delete.png")));
menu.addSeparator();
menu.addAction(tr("Flip Horizontally"), this, SLOT(flipHorizontally()), QKeySequence(tr("X")));
menu.addAction(tr("Flip Vertically"), this, SLOT(flipVertically()), QKeySequence(tr("Y")));
ObjectGroup *objectGroup = RaiseLowerHelper::sameObjectGroup(selection);
if (objectGroup && objectGroup->drawOrder() == ObjectGroup::IndexOrder) {
menu.addSeparator();
menu.addAction(tr("Raise Object"), this, SLOT(raise()), QKeySequence(tr("PgUp")));
menu.addAction(tr("Lower Object"), this, SLOT(lower()), QKeySequence(tr("PgDown")));
menu.addAction(tr("Raise Object to Top"), this, SLOT(raiseToTop()), QKeySequence(tr("Home")));
menu.addAction(tr("Lower Object to Bottom"), this, SLOT(lowerToBottom()), QKeySequence(tr("End")));
}
if (objectGroups.size() > 1) {
menu.addSeparator();
QMenu *moveToLayerMenu = menu.addMenu(tr("Move %n Object(s) to Layer",
"", selectedObjects.size()));
for (ObjectGroup *objectGroup : objectGroups) {
QAction *action = moveToLayerMenu->addAction(objectGroup->name());
action->setData(QVariant::fromValue(objectGroup));
}
}
menu.addSeparator();
QIcon propIcon(QLatin1String(":images/16x16/document-properties.png"));
QAction *propertiesAction = menu.addAction(propIcon,
tr("Object &Properties..."));
// TODO: Implement editing of properties for multiple objects
propertiesAction->setEnabled(selectedObjects.size() == 1);
Utils::setThemeIcon(removeAction, "edit-delete");
Utils::setThemeIcon(propertiesAction, "document-properties");
QAction *action = menu.exec(screenPos);
if (!action)
return;
if (action == propertiesAction) {
MapObject *mapObject = selectedObjects.first();
mapDocument()->setCurrentObject(mapObject);
mapDocument()->emitEditCurrentObject();
return;
}
if (ObjectGroup *objectGroup = action->data().value<ObjectGroup*>()) {
mapDocument()->moveObjectsToGroup(mapDocument()->selectedObjects(),
objectGroup);
}
}