本文整理汇总了C++中CanvasItem类的典型用法代码示例。如果您正苦于以下问题:C++ CanvasItem类的具体用法?C++ CanvasItem怎么用?C++ CanvasItem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CanvasItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: valueChanged
void PropertiesEditorDialog::valueChanged(QtProperty *property, const QVariant &value)
{
if (!m_property_to_id.contains(property))
{
return;
}
if (!m_canvas)
{
return;
}
QList<CanvasItem *> list = m_canvas->selectedItems();
m_canvas->beginUndoMacro(tr("Change Property"));
if (list.empty())
{
// Set the property directly on the canvas:
m_canvas->setProperty(m_property_to_id[property].toLatin1().constData(), value);
}
else
{
// Otherwise, set it on the first item in the selection:
CanvasItem *item = list.front();
item->setProperty(m_property_to_id[property].toLatin1().constData(), value);
}
}
示例2: get_parent_item
void Node2D::set_global_transform(const Transform2D &p_transform) {
CanvasItem *pi = get_parent_item();
if (pi)
set_transform(pi->get_global_transform().affine_inverse() * p_transform);
else
set_transform(p_transform);
}
示例3: while
CanvasItem *CanvasItem::get_toplevel() const {
CanvasItem *ci = const_cast<CanvasItem *>(this);
while (!ci->toplevel && Object::cast_to<CanvasItem>(ci->get_parent())) {
ci = Object::cast_to<CanvasItem>(ci->get_parent());
}
return ci;
}
示例4: switch
void CanvasItem::_notification(int p_what) {
switch(p_what) {
case NOTIFICATION_ENTER_TREE: {
first_draw=true;
pending_children_sort=false;
if (get_parent()) {
CanvasItem *ci = get_parent()->cast_to<CanvasItem>();
if (ci)
C=ci->children_items.push_back(this);
}
_enter_canvas();
if (!block_transform_notify && !xform_change.in_list()) {
get_tree()->xform_change_list.add(&xform_change);
}
} break;
case NOTIFICATION_MOVED_IN_PARENT: {
if (group!="") {
get_tree()->call_group(SceneTree::GROUP_CALL_UNIQUE,group,"_raise_self");
} else {
CanvasItem *p = get_parent_item();
ERR_FAIL_COND(!p);
p->_queue_sort_children();
}
} break;
case NOTIFICATION_EXIT_TREE: {
if (xform_change.in_list())
get_tree()->xform_change_list.remove(&xform_change);
_exit_canvas();
if (C) {
get_parent()->cast_to<CanvasItem>()->children_items.erase(C);
C=NULL;
}
global_invalid=true;
} break;
case NOTIFICATION_DRAW: {
} break;
case NOTIFICATION_TRANSFORM_CHANGED: {
} break;
case NOTIFICATION_VISIBILITY_CHANGED: {
emit_signal(SceneStringNames::get_singleton()->visibility_changed);
} break;
}
}
示例5: get_parent_item
void Node2D::set_global_pos(const Point2& p_pos) {
Matrix32 inv;
CanvasItem *pi = get_parent_item();
if (pi) {
inv = pi->get_global_transform().affine_inverse();
set_pos(inv.xform(p_pos));
} else {
set_pos(p_pos);
}
}
示例6: _edit_get_rect
Rect2 CanvasItem::_edit_get_item_and_children_rect() const {
Rect2 rect = _edit_get_rect();
for (int i = 0; i < get_child_count(); i++) {
CanvasItem *c = Object::cast_to<CanvasItem>(get_child(i));
if (c) {
Rect2 sir = c->get_transform().xform(c->_edit_get_item_and_children_rect());
rect = rect.merge(sir);
}
}
return rect;
}
示例7: ERR_FAIL_COND_V
Ref<World2D> CanvasItem::get_world_2d() const {
ERR_FAIL_COND_V(!is_inside_tree(), Ref<World2D>());
CanvasItem *tl = get_toplevel();
if (tl->canvas_layer) {
return tl->canvas_layer->get_world_2d();
} else if (tl->get_viewport()) {
return tl->get_viewport()->find_world_2d();
} else {
return Ref<World2D>();
}
}
示例8: connectToSprite
bool StateFactory::connectToSprite(AbstractSpriteState *state, QString name){
CanvasItem *item = Drawer::instance()->getItems()->value(name, NULL);
if(item){
Sprite *sprite = new Sprite(name, item->getX(), item->getY(), item->getWidth(), item->getHeight());
sprite->getStateMachine()->addState(state);
Drawer::instance()->getItems()->insert(name, sprite);
delete item;
return true;
}
return false;
}
示例9: Q_UNUSED
void Guideline::move_to(int x, int y, bool store_undo, bool human)
{
Q_UNUSED (x)
Q_UNUSED (y)
Q_UNUSED (store_undo)
Q_UNUSED (human)
#if 0
CanvasItem *cobj = this;
int newval = 0;
bool is_leader = false;
int newx = 4 - cxoff, newy = 4 - cyoff;
if (type == GUIDE_TYPE_VERT)
{
newval = x;
newx = x;
}
else if (type == GUIDE_TYPE_HORI)
{
newval = y;
newy = y;
}
fPos = newval;
if ((newx == xpos) && (newy == ypos))
{
// Not moving, so do nothing.
return;
}
bool freeshift = canvas()->isLayoutSuspended();
if (freeshift)
{
d_printf("FREESHIFT\n");
}
if (human && (!is_leader || freeshift))
{
removeFromDistributions(freeshift);
// Since the previous call will have suggested new values for
// the guidelines involved in the distribution we need to resolve
// here to avoid what looks like an unsovable state.
}
cobj->move_to(newx, newy, store_undo);
#endif
}
示例10: while
void CanvasItem::_enter_canvas() {
if ((!get_parent() || !get_parent()->cast_to<CanvasItem>()) || toplevel) {
Node *n = this;
Viewport *viewport=NULL;
canvas_layer=NULL;
while(n) {
if (n->cast_to<Viewport>()) {
viewport = n->cast_to<Viewport>();
break;
}
if (!canvas_layer && n->cast_to<CanvasLayer>()) {
canvas_layer = n->cast_to<CanvasLayer>();
}
n=n->get_parent();
}
RID canvas;
if (canvas_layer)
canvas=canvas_layer->get_world_2d()->get_canvas();
else
canvas=viewport->find_world_2d()->get_canvas();
VisualServer::get_singleton()->canvas_item_set_parent(canvas_item,canvas);
group = "root_canvas"+itos(canvas.get_id());
add_to_group(group);
get_tree()->call_group(SceneTree::GROUP_CALL_UNIQUE,group,"_raise_self");
} else {
CanvasItem *parent = get_parent_item();
VisualServer::get_singleton()->canvas_item_set_parent(canvas_item,parent->get_canvas_item());
parent->_queue_sort_children();
}
pending_update=false;
update();
notification(NOTIFICATION_ENTER_CANVAS);
}
示例11: pickColor
QColor Core::pickColor(const QPointF& point, const QVariantList& canvasItems) {
QPixmap pixmap;
for (int i = canvasItems.count() - 1; i >= 0; i--) {
QObject* obj = qvariant_cast<QObject*>(canvasItems.at(i));
CanvasItem* canvasItem = qobject_cast<CanvasItem*>(obj);
QPixmap* canvasPixmap = canvasItem->pixmap();
if (pixmap.isNull()) {
pixmap = QPixmap(canvasPixmap->width(), canvasPixmap->height());
pixmap.fill(Qt::white);
}
QPainter painter(&pixmap);
painter.drawPixmap(0, 0, *canvasPixmap);
}
return QColor(pixmap.toImage().pixel(qRound(point.x()), qRound(point.y())));
}
示例12: writePng
void Core::writePng(const QString& pngPath, const QVariantList& canvasItems) {
QPixmap pixmap;
for (int i = canvasItems.count() - 1; i >= 0; i--)
{
QObject* obj = qvariant_cast<QObject*>(canvasItems.at(i));
CanvasItem* canvasItem = qobject_cast<CanvasItem*>(obj);
QPixmap* canvasPixmap = canvasItem->pixmap();
if (pixmap.isNull()) {
pixmap = QPixmap(canvasPixmap->width(), canvasPixmap->height());
pixmap.fill(Qt::white);
}
QPainter painter(&pixmap);
painter.drawPixmap(0, 0, *canvasPixmap);
}
pixmap.save(pngPath);
}
示例13: collisions
void Floater::moveBy(double dx, double dy)
{
if (!isEnabled())
return;
QCanvasItemList l = collisions(false);
for (QCanvasItemList::Iterator it = l.begin(); it != l.end(); ++it)
{
CanvasItem *item = dynamic_cast<CanvasItem *>(*it);
if (!noUpdateZ && item && item->canBeMovedByOthers())
item->updateZ(this);
if ((*it)->z() >= z())
{
if (item && item->canBeMovedByOthers() && collidesWith(*it))
{
if ((*it)->rtti() == Rtti_Ball)
{
//((Ball *)(*it))->setState(Rolling);
(*it)->moveBy(dx, dy);
if (game && game->hasFocus() && !game->isEditing() && game->curBall() == (Ball *)(*it))
game->ballMoved();
}
else if ((*it)->rtti() != Rtti_Putter)
(*it)->moveBy(dx, dy);
}
}
}
point->dontMove();
point->move(x() + width(), y() + height());
// this call must come after we have tested for collisions, otherwise we skip them when saving!
// that's a bad thing
QCanvasRectangle::moveBy(dx, dy);
// because we don't do Bridge::moveBy();
topWall->move(x(), y());
botWall->move(x(), y() - 1);
leftWall->move(x(), y());
rightWall->move(x(), y());
if (game && game->isEditing())
game->updateHighlighter();
}
示例14: _update_project_buttons
void ProjectManager::_update_project_buttons()
{
for(int i=0;i<scroll_childs->get_child_count();i++) {
CanvasItem *item = scroll_childs->get_child(i)->cast_to<CanvasItem>();
item->update();
}
bool has_runnable_scene = false;
for (Map<String,String>::Element *E=selected_list.front(); E; E=E->next()) {
const String &selected_main = E->get();
if (selected_main == "") continue;
has_runnable_scene = true;
break;
}
erase_btn->set_disabled(selected_list.size()<1);
open_btn->set_disabled(selected_list.size()<1);
run_btn->set_disabled(!has_runnable_scene);
}
示例15: notification
void CanvasItem::_propagate_visibility_changed(bool p_visible) {
notification(NOTIFICATION_VISIBILITY_CHANGED);
if (p_visible)
update(); //todo optimize
else
emit_signal(SceneStringNames::get_singleton()->hide);
_block();
for (int i = 0; i < get_child_count(); i++) {
CanvasItem *c = Object::cast_to<CanvasItem>(get_child(i));
if (c && c->visible) //should the toplevels stop propagation? i think so but..
c->_propagate_visibility_changed(p_visible);
}
_unblock();
}